mirror of https://github.com/k3s-io/k3s
1 line
6.3 KiB
JavaScript
1 line
6.3 KiB
JavaScript
/*! angular-css 1.0.7 | Copyright (c) 2015 DOOR3, Alex Castillo | MIT License */"use strict";!function(a){var b=a.module("door3.css",[]);b.config(["$logProvider",function(a){a.debugEnabled(!1)}]),b.provider("$css",[function(){var b=this.defaults={element:"link",rel:"stylesheet",type:"text/css",container:"head",method:"append",weight:0};this.$get=["$rootScope","$injector","$q","$window","$timeout","$compile","$http","$filter","$log",function(d,e,f,g,h,i,j,k,l){function m(a,b,c){c&&b.hasOwnProperty("css")&&w.bind([q(b.css)],c)}function n(a,b,c){c&&(w.remove(w.getFromRoute(c).concat(D)),D.length=0),b&&w.add(w.getFromRoute(b))}function o(a,b,c,d){d&&(w.remove(w.getFromState(d).concat(D)),D.length=0),b&&w.add(w.getFromState(b))}function p(b){a.isDefined(B.breakpoints)&&(b.breakpoint in B.breakpoints&&(b.media=B.breakpoints[b.breakpoint]),delete b.breakpoints)}function q(b){return b?(a.isFunction(b)&&(b=a.copy(e.invoke(b))),a.isString(b)&&(b=a.extend({href:b},B)),a.isArray(b)&&a.isString(b[0])&&a.forEach(b,function(c){b=a.extend({href:c},B)}),a.isObject(b)&&!a.isArray(b)&&(b=a.extend(b,B)),a.isArray(b)&&a.isObject(b[0])&&a.forEach(b,function(c){b=a.extend(c,B)}),p(b),b):void 0}function r(a){if(!a)return l.error("No stylesheets provided");var b="?cache=";-1===a.href.indexOf(b)&&(a.href=a.href+(a.bustCache?b+(new Date).getTime():""))}function s(a,b){return a&&b?k("filter")(a,function(a){return a[b]}):l.error("filterBy: missing array or property")}function t(a){return a?(y[a.href]=g.matchMedia(a.media),z[a.href]=function(b){h(function(){if(b.matches)d.stylesheets.push(a);else{var c=d.stylesheets.indexOf(k("filter")(d.stylesheets,{href:a.href})[0]);-1!==c&&d.stylesheets.splice(c,1)}})},y[a.href].addListener(z[a.href]),void z[a.href](y[a.href])):l.error("No stylesheet provided")}function u(b){return b?void(d&&a.isDefined(y)&&y[b.href]&&a.isDefined(z)&&y[b.href].removeListener(z[b.href])):l.error("No stylesheet provided")}function v(a){return a?!(!a.media||-1!==A.indexOf(a.media)||!g.matchMedia):l.error("No stylesheet provided")}var w={},x='<link ng-repeat="stylesheet in stylesheets track by $index | orderBy: \'weight\' " rel="{{ stylesheet.rel }}" type="{{ stylesheet.type }}" ng-href="{{ stylesheet.href }}" ng-attr-media="{{ stylesheet.media }}">',y={},z={},A=["print"],B=a.extend({},b),C=a.element(document.querySelector?document.querySelector(B.container):document.getElementsByTagName(B.container)[0]),D=[];return a.forEach(c,function(a,b){a.hasOwnProperty("css")&&(c[b]=q(a.css))}),d.stylesheets=[],C[B.method](i(x)(d)),d.$on("$directiveAdd",m),d.$on("$routeChangeSuccess",n),d.$on("$stateChangeSuccess",o),w.getFromRoute=function(b){if(!b)return l.error("Get From Route: No route provided");var c=null,d=[];return b.$$route&&b.$$route.css?c=b.$$route.css:b.css&&(c=b.css),c&&(a.isArray(c)?a.forEach(c,function(b){a.isFunction(b)&&D.push(q(b)),d.push(q(b))}):(a.isFunction(c)&&D.push(q(c)),d.push(q(c)))),d},w.getFromRoutes=function(b){if(!b)return l.error("Get From Routes: No routes provided");var c=[];return a.forEach(b,function(a){var b=w.getFromRoute(a);b.length&&c.push(b[0])}),c},w.getFromState=function(b){if(!b)return l.error("Get From State: No state provided");var c=[];return a.isDefined(b.views)&&a.forEach(b.views,function(b){b.css&&(a.isFunction(b.css)&&D.push(q(b.css)),c.push(q(b.css)))}),a.isDefined(b.children)&&a.forEach(b.children,function(b){b.css&&(a.isFunction(b.css)&&D.push(q(b.css)),c.push(q(b.css))),a.isDefined(b.children)&&a.forEach(b.children,function(b){b.css&&(a.isFunction(b.css)&&D.push(q(b.css)),c.push(q(b.css)))})}),a.isDefined(b.css)&&(a.isArray(b.css)?a.forEach(b.css,function(b){a.isFunction(b)&&D.push(q(b)),c.push(q(b))}):(a.isFunction(b.css)&&D.push(q(b.css)),c.push(q(b.css)))),c},w.getFromStates=function(b){if(!b)return l.error("Get From States: No states provided");var c=[];return a.forEach(b,function(b){var d=w.getFromState(b);a.isArray(d)?a.forEach(d,function(a){c.push(a)}):c.push(d)}),c},w.preload=function(b,d){b||(b=[],c.length&&Array.prototype.push.apply(b,c),e.has("$route")&&Array.prototype.push.apply(b,w.getFromRoutes(e.get("$route").routes)),e.has("$state")&&Array.prototype.push.apply(b,w.getFromStates(e.get("$state").get())),b=s(b,"preload")),a.isArray(b)||(b=[b]);var g=[];a.forEach(b,function(a,c){a=b[c]=q(a),g.push(j.get(a.href).error(function(){l.error("AngularCSS: Incorrect path for "+a.href)}))}),a.isFunction(d)&&f.all(g).then(function(){d(b)})},w.bind=function(b,c){if(!b||!c)return l.error("No scope or stylesheets provided");var d=[];a.isArray(b)?a.forEach(b,function(a){d.push(q(a))}):d.push(q(b)),w.add(d),l.debug("$css.bind(): Added",d),c.$on("$destroy",function(){w.remove(d),l.debug("$css.bind(): Removed",d)})},w.add=function(b){return b?(a.isArray(b)||(b=[b]),a.forEach(b,function(a){a=q(a),a.href&&!k("filter")(d.stylesheets,{href:a.href}).length&&(r(a),v(a)?t(a):d.stylesheets.push(a),l.debug("$css.add(): "+a.href))}),void d.$broadcast("$cssAdd",b,d.stylesheets)):l.error("No stylesheets provided")},w.remove=function(b){return b?(a.isArray(b)||(b=[b]),b=k("filter")(b,function(a){return!a.persist}),a.forEach(b,function(a){a=q(a);var b=d.stylesheets.indexOf(k("filter")(d.stylesheets,{href:a.href})[0]);-1!==b&&d.stylesheets.splice(b,1),u(a),l.debug("$css.remove(): "+a.href)}),void d.$broadcast("$cssRemove",b,d.stylesheets)):l.error("No stylesheets provided")},w.removeAll=function(){d&&d.hasOwnProperty("stylesheets")&&(d.stylesheets.length=0),l.debug("all stylesheets removed")},w.preload(),w}]}]),b.filter("$cssLinks",function(){return function(b){if(!b||!a.isArray(b))return b;var c="";return a.forEach(b,function(a){c+='<link rel="'+a.rel+'" type="'+a.type+'" href="'+a.href+'"',c+=a.media?' media="'+a.media+'"':"",c+=">\n\n"}),c}}),b.run(["$css",function(){}]);var c=[],d=a.module;a.module=function(){var b=d.apply(this,arguments),e=b.directive;return b.directive=function(b,d){var f=a.isFunction(d)?d:d[d.length-1];try{var g=a.copy(f)();g.directiveName=b,g.hasOwnProperty("css")&&c.push(g)}catch(h){}return e.apply(this,arguments)},b.config(["$provide","$injector",function(b,d){a.forEach(c,function(a){var c=a.directiveName+"Directive";d.has(c)&&b.decorator(c,["$delegate","$rootScope","$timeout",function(b,c,d){var e=b[0],f=e.compile;return e.css&&(a.css=e.css),e.compile=function(){var a=f?f.apply(this,arguments):!1;return function(b){var f=arguments;d(function(){a&&a.apply(this,f)}),c.$broadcast("$directiveAdd",e,b)}},b}])})}]),b}}(angular); |