@stratusjs/angularjs
Version:
This is the AngularJS package for StratusJS.
1 lines • 3.07 kB
JavaScript
System.register(["lodash","@stratusjs/runtime/stratus","@stratusjs/core/environment","angular","angular-sanitize","../services/collection","@stratusjs/core/misc"],function(exports_1,context_1){"use strict";var lodash_1,stratus_1,environment_1,collection_1,misc_1;context_1&&context_1.id;return{setters:[function(lodash_1_1){lodash_1=lodash_1_1},function(stratus_1_1){stratus_1=stratus_1_1},function(environment_1_1){environment_1=environment_1_1},function(_1){},function(_2){},function(collection_1_1){collection_1=collection_1_1},function(misc_1_1){misc_1=misc_1_1}],execute:function(){stratus_1.Stratus.Modules.ngSanitize=!0,stratus_1.Stratus.Controllers.Generic=["$scope","$element","$log","$sce","$parse","$window","Registry",async($scope,$element,$log,$sce,$parse,$window,R)=>{if($scope.uid=misc_1.safeUniqueId("controller_generic_"),stratus_1.Stratus.Instances[$scope.uid]=$scope,await R.fetch($element,$scope),$scope.ctrlParent=$scope.$parent,$scope.Stratus=stratus_1.Stratus,$scope._=lodash_1.default,$scope.cookie=environment_1.cookie,$scope.$window=$window,$scope.getUrlParams=misc_1.getUrlParams,$scope.setUrlParams=misc_1.setUrlParams,$scope.$log=$log,$scope.Math=Math,$scope.isArray=lodash_1.isArray,$scope.isDate=lodash_1.isDate,$scope.isDefined=value=>!lodash_1.isUndefined(value),$scope.isElement=lodash_1.isElement,$scope.isFunction=lodash_1.isFunction,$scope.isNumber=lodash_1.isNumber,$scope.isObject=lodash_1.isObject,$scope.isString=lodash_1.isString,$scope.isUndefined=lodash_1.isUndefined,$scope.getHTML=$sce.trustAsHtml,$scope.getURL=$sce.trustAsResourceUrl,$scope.getAnchor=()=>{const url=window.location.href;if(!url||!url.length)return!1;const anchor=url.indexOf("#");return!(anchor<0)&&(!(anchor+1>=url.length)&&url.substring(anchor+1,url.length))},$scope.scrollToAnchor=(anchor,inUrl,delay)=>{if(!anchor||lodash_1.isEmpty(anchor))return $log.warn("anchor id not set!"),!1;if(lodash_1.isUndefined(inUrl)&&(inUrl=!1),inUrl&&anchor!==$scope.getAnchor())return!1;const el=$window.document.getElementById(anchor);return el?delay?setTimeout(()=>{$scope.scrollToAnchor(anchor,inUrl,--delay)},1):(el.scrollIntoView({behavior:"smooth"}),!0):($log.warn(`element not found: ${anchor}`),!1)},$scope.data&&lodash_1.isFunction($scope.data.on)&&$scope.data.on("change",()=>$scope.$applyAsync()),!($scope.collection&&$scope.collection instanceof collection_1.Collection))return;const selected={id:$element.attr("data-selected"),raw:$element.attr("data-raw")};if(selected.id&&lodash_1.isString(selected.id))if(misc_1.isJSON(selected.id))selected.id=JSON.parse(selected.id),$scope.$watch("collection.models",models=>{$scope.selected||$scope.selectedInit||lodash_1.forEach(models,model=>{selected.id===model.getIdentifier()&&($scope.selected=selected.raw?model.data:model,$scope.selectedInit=!0)})});else{if(selected.model=$parse(selected.id),selected.value=selected.model($scope.$parent),!lodash_1.isArray(selected.value))return;if(selected.value=selected.value.filter(n=>n),selected.value.length)return;$scope.selected=lodash_1.head(selected.value)}}]}}});