{"version":3,"sources":["2sxc4ng.min.js"],"names":["angular","module","config","$httpProvider","HttpHeaders","extend","defaults","headers","common","interceptors","push","$q","sxc","request","url","resolveServiceUrl","responseError","rejection","ignoreErrors","showDetailedHttpError","reject","factory","$2sxc","AppInstanceId","ngSxc","$http","contentType","oneType","root","get","read","id","create","values","post","update","patch","realId","Id","createQueryObj","name","qry","data","sourceUrl","directive","restrict","scope","toolbar","settings","link","element","attrs","manageCtrl","manage","tbObj","undefined","setObj","getToolbar","html","getNgAttribute","ngAttr","attr","i","ii","ng","ngAttrPrefixes","length","findInstanceId","attrib","ngElement","iidAttrNames","iid","parseInt","toString","replace","findContentBlockId","el","cbid","getAttribute","cbidAttrName","parentNode","autoFindId","$","appAttribute","ngAttrDependencies","bootstrap","ngModName","dependencies","urlParams","sf","ServicesFramework","confMod","constant","ModuleId","ContentBlockId","TabId","getTabId","RequestVerificationToken","getAntiForgeryValue","Debugging-Hint","Cache-Control","Pragma","allDependencies","concat","document","ready","e","console","error","bootstrapAll","allAppTags","querySelectorAll","forEach","appTag","configDependencyInjection","strictDi","split","autoRunBootstrap","window","bootstrappingAlreadyStarted"],"mappings":"CAKA,SAAWA,GACPA,EAAQC,OAAO,WAAY,OAGtBC,QAAQ,gBAAiB,cAAe,SAASC,EAAeC,GAE7DJ,EAAQK,OAAOF,EAAcG,SAASC,QAAQC,OAAQJ,GACtDD,EAAcM,aAAaC,MAAM,KAAM,MAAO,SAASC,EAAIC,GACvD,OAEIC,QAAW,SAASX,GAEhB,MADAA,GAAOY,IAAMF,EAAIG,kBAAkBb,EAAOY,KACnCZ,GAIXc,cAAiB,SAASC,GAGtB,MAFKA,GAAUf,OAAOgB,cAClBN,EAAIO,sBAAsBF,GACvBN,EAAGS,OAAOH,WAQhCI,QAAQ,QAAS,WACd,IAAKC,MAAO,KAAM,wFAClB,OAAOA,SAKVD,QAAQ,OAAQ,gBAAiB,QAAS,SAASE,EAAeD,GAG/D,GAAIE,GAAQF,EAAMC,EAClB,OAAO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G,SAAS,eACNC,SAAYtB,EACZuB,eAAkBjB,EAClBkB,MAASN,EAAGO,WACZC,yBAA4BR,EAAGS,sBAC/BC,iBAAkB,0BAClBC,gBAAiB,WACjBC,OAAU,aAEdC,GAAmBX,EAAQnD,KAAM,WAAW+D,OAAOhB,IAAiBD,GAExEtF,GAAQkD,QAAQsD,UAAUC,MAAM,WAC5B,IACIzG,EAAQqF,UAAUnC,EAASoD,EAAiBpG,GAC9C,MAAOwG,GACDC,SAAWA,QAAQC,OACnBD,QAAQC,MAAMF,OAM9BG,aAAc,SAAsB3D,GAChCA,EAAUA,GAAWsD,QACrB,IAAIM,GAAa5D,EAAQ6D,iBAAiB,IAAM/C,EAAGmB,aAAe,IAClEnF,GAAQgH,QAAQF,EAAY,SAASG,GACjC,GAAI3B,GAAY2B,EAAOnC,aAAad,EAAGmB,cACnC+B,GAA8BC,SAAkD,OAAxCxD,EAAesD,EAAQ,cAE/D1B,EAAe5B,EAAesD,EAAQjD,EAAGoB,mBACzCG,KAAcA,EAAeA,EAAa6B,MAAM,MACpDpD,EAAGqB,UAAU4B,EAAQ3B,EAAW,KAAMC,EAAc2B,MAK5DG,iBAAkB,WAEVC,OAAOC,8BAEXD,OAAOC,6BAA8B,EAGjCvH,GACAA,EAAQkD,QAAQsD,UAAUC,MAAM,WAC5BzC,EAAG6C,mBAiDnB7C,GAAGqD,oBAEJrH","file":"2sxc4ng.min.js","sourcesContent":["/*\r\n Extending 2sxc with angular capabilities\r\n This is an angular module which provides all 2sxc-information and services to an angular app\r\n It will be auto-added to your app when you use the bootstrapping\r\n*/\r\n(function (angular) {\r\n angular.module(\"2sxc4ng\", [\"ng\"])\r\n // Configure $http for DNN web services (security tokens etc.)\r\n // ReSharper disable InconsistentNaming\r\n .config([\"$httpProvider\", \"HttpHeaders\", function($httpProvider, HttpHeaders) {\r\n // ReSharper restore InconsistentNaming\r\n angular.extend($httpProvider.defaults.headers.common, HttpHeaders);\r\n $httpProvider.interceptors.push([\"$q\", \"sxc\", function($q, sxc) {\r\n return {\r\n // Rewrite 2sxc-urls if necessary\r\n 'request': function(config) {\r\n config.url = sxc.resolveServiceUrl(config.url);\r\n return config;\r\n },\r\n\r\n // Show very nice error if necessary\r\n 'responseError': function(rejection) {\r\n if (!rejection.config.ignoreErrors)\r\n sxc.showDetailedHttpError(rejection);\r\n return $q.reject(rejection);\r\n }\r\n };\r\n }]);\r\n\r\n }])\r\n\r\n // provide the global $2sxc object to angular modules as a clear, clean dependency\r\n .factory(\"$2sxc\", function() {\r\n if (!$2sxc) throw \"the Angular service '$2sxc' in module '2sxc4ng' can't find the global $2sxc controller\";\r\n return $2sxc;\r\n })\r\n\r\n // Provide the app-specific sxc helper for this module\r\n // ReSharper disable InconsistentNaming\r\n .factory(\"sxc\", [\"AppInstanceId\", \"$2sxc\", function(AppInstanceId, $2sxc) {\r\n // ReSharper restore InconsistentNaming\r\n // if (window.console) console.log(\"creating sxc service for id: \" + AppInstanceId);\r\n var ngSxc = $2sxc(AppInstanceId); // make this service be the 2sxc-controller for this module\r\n return ngSxc;\r\n }])\r\n\r\n\r\n /// Standard entity commands like get one, many etc.\r\n .factory(\"content\", [\"$http\", function($http) {\r\n // construct a service just for this content-type\r\n return function(contentType) {\r\n var oneType = {};\r\n oneType.contentType = contentType;\r\n oneType.root = \"app/auto/content/\" + contentType;\r\n\r\n // will get one or all of a content-type, depending on if an id was supplied\r\n oneType.get = oneType.read = function get(id) {\r\n return $http.get(oneType.root + (id ? \"/\" + id : \"\"));\r\n };\r\n oneType.create = function create(values) {\r\n return $http.post(oneType.root, values);\r\n };\r\n oneType.update = oneType.patch = function update(values, id) {\r\n var realId = id || values.Id || values.id; // automatically use the correct Id\r\n return $http.post(oneType.root + \"/\" + realId, values);\r\n };\r\n oneType.delete = function del(id) {\r\n return $http.delete(oneType.root + \"/\" + id);\r\n };\r\n return oneType;\r\n };\r\n }])\r\n\r\n /// simple helper service which will call a query\r\n .factory(\"query\", [\"$http\", \"sxc\", function($http, sxc) {\r\n var createQueryObj = function(name) {\r\n var qry = {\r\n root: \"app/auto/query/\" + name\r\n };\r\n\r\n qry.get = function(config) {\r\n return !name\r\n ? $http(angular.extend({ url: sxc.data.sourceUrl() }, config)) // otherwise use the current-view stuff\r\n : $http.get(qry.root, config); // if it has a name, call that specific query\r\n };\r\n\r\n return qry;\r\n };\r\n\r\n return createQueryObj;\r\n }])\r\n\r\n .directive(\"sxcToolbar\", [\"sxc\", function(sxc) {\r\n return {\r\n restrict: \"E\",\r\n scope: {\r\n // official syntax uses the toolbar configuration and the settings as standardized in 2sxc 8.6\r\n // read about it in https://github.com/2sic/2sxc/wiki/AngularJs-1-Overview\r\n toolbar: \"&toolbar\",\r\n settings: \"&settings\"\r\n },\r\n link: function(scope, element, attrs) {\r\n var manageCtrl = sxc.manage;\r\n var toolbar = \"\";\r\n\r\n // the manage only exists when in edit mode\r\n if (manageCtrl) {\r\n // run in new mode as defined in 2sxc 8.6\r\n var tbObj = scope.toolbar();\r\n if (tbObj !== undefined) {\r\n var setObj = scope.settings();\r\n toolbar = manageCtrl.getToolbar(tbObj, setObj);\r\n }\r\n\r\n }\r\n\r\n element.html(toolbar);\r\n }\r\n };\r\n }]);\r\n})(angular);\n/*\r\n Extending 2sxc with angular capabilities\r\n In general, this should automatically take care of everything just by including it in your sources. \r\n Make sure it's added after AngularJS and after the 2sxc.api.js\r\n It will then look for all sxc-apps and initialize them, ensuring that $http is pre-configured to work with DNN\r\n\r\n Required HTML Attributes \r\n * sxc-app=\"MyAppNameWhatever\" - required for auto-bootstrapping\r\n \r\n Optional HTML Attributes\r\n * ng-controller=\"AngularControllerName\" - required for auto-bootstrapping\r\n * dependencies=\"\" - here you can add additional dependencies if you need them\r\n * id, data-instanceid, app-instanceid - would tell 2sxc what module-id to use, for example when doing server requests\r\n * Note that the id etc. are optional, because since 2sxc 8.x it can be auto-detected\r\n * data-cb-id - the content-block id, only used for advanced use cases and is normally auto-detected\r\n \r\n Angular Constants / Variables added\r\n * AppInstanceId - the module-id for accessing the HTML-block or for server-requests\r\n * ContentBlockId - advanced use case, not explained here\r\n * AppServiceFramework - a real or fake DNN sf-object\r\n * HttpHeaders - the headers which we use to initialize the $http to ensure it works / authenticates correctly\r\n \r\n Angular Modules added\r\n * 2sxc4ng\r\n * all the dependencies listed in the dependencies attribute\r\n*/\r\n\r\n(function(angular) {\r\n var ng = $2sxc.ng = {\r\n appAttribute: \"sxc-app\",\r\n ngAttrPrefixes: [\"ng-\", \"data-ng-\", \"ng:\", \"x-ng-\"],\r\n iidAttrNames: [\"app-instanceid\", \"data-instanceid\", \"id\"],\r\n cbidAttrName: \"data-cb-id\",\r\n ngAttrDependencies: \"dependencies\",\r\n\r\n // bootstrap: an App-Start-Help; normally you won't call this manually as it will be auto-bootstrapped. \r\n // All params optional except for 'element'\r\n bootstrap: function(element, ngModName, iid, dependencies, config) {\r\n // first, try to get moduleId from function-param or from from URL\r\n iid = iid || findInstanceId(element) || $2sxc.urlParams.get(\"mid\") || autoFindId(element);\r\n\r\n var cbid = findContentBlockId(element) || $2sxc.urlParams.get(\"cbid\") || iid;\r\n // then provide access to the dnn-services framework (or a fake thereof)\r\n var sf = $.ServicesFramework(iid);\r\n\r\n // create a micro-module to configure sxc-init parameters, add to dependencies. Note that the order is important!\r\n var confMod = angular.module(\"confSxcApp\" + iid + \"-\" + cbid, [])\r\n .constant(\"AppInstanceId\", iid)\r\n .constant(\"ContentBlockId\", cbid)\r\n .constant(\"AppServiceFramework\", sf)\r\n .constant(\"HttpHeaders\", {\r\n \"ModuleId\": iid,\r\n \"ContentBlockId\": cbid,\r\n \"TabId\": sf.getTabId(),\r\n \"RequestVerificationToken\": sf.getAntiForgeryValue(),\r\n \"Debugging-Hint\": \"bootstrapped by 2sxc4ng\",\r\n \"Cache-Control\": \"no-cache\", // had to add because of browser ajax caching issue #437\r\n \"Pragma\": \"no-cache\"\r\n });\r\n var allDependencies = [confMod.name, \"2sxc4ng\"].concat(dependencies || [ngModName]);\r\n\r\n angular.element(document).ready(function() {\r\n try {\r\n angular.bootstrap(element, allDependencies, config); // start the app\r\n } catch (e) { // Make sure that if one app breaks, others continue to work\r\n if (console && console.error)\r\n console.error(e);\r\n }\r\n });\r\n },\r\n\r\n // Auto-bootstrap all sub-tags having an 'sxc-app' attribute - for Multiple-Apps-per-Page\r\n bootstrapAll: function bootstrapAll(element) {\r\n element = element || document;\r\n var allAppTags = element.querySelectorAll(\"[\" + ng.appAttribute + \"]\");\r\n angular.forEach(allAppTags, function(appTag) {\r\n var ngModName = appTag.getAttribute(ng.appAttribute);\r\n var configDependencyInjection = { strictDi: getNgAttribute(appTag, \"strict-di\") !== null };\r\n\r\n var dependencies = getNgAttribute(appTag, ng.ngAttrDependencies);\r\n if (dependencies) dependencies = dependencies.split(\",\");\r\n ng.bootstrap(appTag, ngModName, null, dependencies, configDependencyInjection);\r\n });\r\n },\r\n\r\n // if the page contains angular, do auto-bootstrap of all 2sxc apps\r\n autoRunBootstrap: function autoRunBootstrap() {\r\n // prevent multiple bootstrapping in case this file was included multiple times\r\n if (window.bootstrappingAlreadyStarted)\r\n return;\r\n window.bootstrappingAlreadyStarted = true;\r\n\r\n // bootstrap, if it has angular\r\n if (angular)\r\n angular.element(document).ready(function() {\r\n ng.bootstrapAll();\r\n });\r\n },\r\n\r\n };\r\n\r\n\r\n // Helper function to try various attribute-prefixes\r\n function getNgAttribute(element, ngAttr) {\r\n var attr, i, ii = ng.ngAttrPrefixes.length;\r\n element = angular.element(element);\r\n for (i = 0; i < ii; ++i) {\r\n attr = ng.ngAttrPrefixes[i] + ngAttr;\r\n if (typeof (attr = element.attr(attr)) == \"string\")\r\n return attr;\r\n }\r\n return null;\r\n }\r\n\r\n // find instance Id in an attribute of the tag - typically with id=\"app-700\" or something and use the number as IID\r\n function findInstanceId(element) {\r\n var attrib, ngElement = angular.element(element);\r\n for (var i = 0; i < ng.iidAttrNames.length; i++) {\r\n attrib = ngElement.attr(ng.iidAttrNames[i]);\r\n if (attrib) {\r\n var iid = parseInt(attrib.toString().replace(/\\D/g, \"\")); // filter all characters if necessary\r\n if(iid) return iid; // if it contained a number, use it, otherwise continue\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n function findContentBlockId(el) {\r\n var cbid;\r\n while (el.getAttribute) { // loop as long as it knows this command\r\n if ((cbid = el.getAttribute(ng.cbidAttrName))) return cbid;\r\n el = el.parentNode;\r\n }\r\n return null;\r\n }\r\n\r\n // this can't be in the find-instance-id, because it needs jQuery internally and only works on the real page\r\n function autoFindId(element) {\r\n if (!$) return null;\r\n var sxc = $2sxc(element);\r\n return sxc && sxc.id;\r\n }\r\n\r\n\r\n ng.autoRunBootstrap();\r\n\r\n})(angular);\r\n"],"sourceRoot":"/source/"}