From 5124643bc24345df0bc64207e2a22f72b2a60251 Mon Sep 17 00:00:00 2001 From: Alexander Castillo Date: Mon, 29 Dec 2014 16:25:35 -0500 Subject: [PATCH] version and minified file updated --- angular-css.js | 2 +- angular-css.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-css.js b/angular-css.js index 7fe157b..8c3d11b 100644 --- a/angular-css.js +++ b/angular-css.js @@ -1,6 +1,6 @@ /** * CSS on-demand for AngularJS - * @version v1.0.3 + * @version v1.0.4 * @author DOOR3, Alex Castillo * @link http://door3.github.io/angular-css * @license MIT License, http://www.opensource.org/licenses/MIT diff --git a/angular-css.min.js b/angular-css.min.js index 8137399..a243b28 100644 --- a/angular-css.min.js +++ b/angular-css.min.js @@ -1 +1 @@ -/*! angular-css 1.0.3 | Copyright (c) 2014 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","$window","$timeout","$compile","$http","$filter","$log",function(d,e,f,g,h,i,j,k){function l(a,b,c){c&&b.hasOwnProperty("css")&&u.bind([o(b.css)],c)}function m(a,b,c){c&&u.remove(u.getFromRoute(c)),b&&u.add(u.getFromRoute(b))}function n(a,b,c,d){d&&u.remove(u.getFromState(d)),b&&u.add(u.getFromState(b))}function o(b){return b?(a.isString(b)&&(b=a.extend({href:b},z)),a.isArray(b)&&a.isString(b[0])&&a.forEach(b,function(c){b=a.extend({href:c},z)}),a.isObject(b)&&!a.isArray(b)&&(b=a.extend(b,z)),a.isArray(b)&&a.isObject(b[0])&&a.forEach(b,function(c){b=a.extend(c,z)}),b):void 0}function p(a){if(!a)return k.error("No stylesheets provided");var b="?cache=";-1===a.href.indexOf(b)&&(a.href=a.href+(a.bustCache?b+(new Date).getTime():""))}function q(a,b){return a&&b?j("filter")(a,function(a){return a[b]}):k.error("filterBy: missing array or property")}function r(a){return a?(w[a.href]=f.matchMedia(a.media),x[a.href]=function(b){g(function(){if(b.matches)d.stylesheets.push(a);else{var c=d.stylesheets.indexOf(j("filter")(d.stylesheets,{href:a.href})[0]);-1!==c&&d.stylesheets.splice(c,1)}})},w[a.href].addListener(x[a.href]),void x[a.href](w[a.href])):k.error("No stylesheet provided")}function s(b){return b?void(d&&a.isDefined(w)&&w[b.href]&&a.isDefined(x)&&w[b.href].removeListener(x[b.href])):k.error("No stylesheet provided")}function t(a){return a?!(!a.media||-1!==y.indexOf(a.media)||!f.matchMedia):k.error("No stylesheet provided")}var u={},v='',w={},x={},y=["print"],z=a.extend({},b),A=a.element(document.querySelector?document.querySelector(z.container):document.getElementsByTagName(z.container)[0]);return a.forEach(c,function(a,b){a.hasOwnProperty("css")&&(c[b]=o(a.css))}),d.stylesheets=[],A[z.method](h(v)(d)),d.$on("$directiveAdd",l),d.$on("$routeChangeStart",m),d.$on("$stateChangeStart",n),u.getFromRoute=function(b){if(!b)return k.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(a){d.push(o(a))}):d.push(o(c))),d},u.getFromRoutes=function(b){if(!b)return k.error("Get From Routes: No routes provided");var c=[];return a.forEach(b,function(a){var b=u.getFromRoute(a);b.length&&c.push(b[0])}),c},u.getFromState=function(b){if(!b)return k.error("Get From State: No state provided");var c=[];return a.isDefined(b.views)&&a.forEach(b.views,function(a){a.css&&c.push(o(a.css))}),a.isDefined(b.children)&&a.forEach(b.children,function(b){b.css&&c.push(o(b.css)),a.isDefined(b.children)&&a.forEach(b.children,function(a){a.css&&c.push(o(a.css))})}),a.isDefined(b.css)&&(a.isArray(b.css)?a.forEach(b.css,function(a){c.push(o(a))}):c.push(o(b.css))),c},u.getFromStates=function(b){if(!b)return k.error("Get From States: No states provided");var c=[];return a.forEach(b,function(b){var d=u.getFromState(b);a.isArray(d)?a.forEach(d,function(a){c.push(a)}):c.push(d)}),c},u.preload=function(b,d){b||(b=[],c.length&&Array.prototype.push.apply(b,c),e.has("$route")&&Array.prototype.push.apply(b,u.getFromRoutes(e.get("$route").routes)),e.has("$state")&&Array.prototype.push.apply(b,u.getFromStates(e.get("$state").get()))),b=q(b,"preload"),a.forEach(b,function(c,e){i.get(c.href).success(function(c){k.debug("preload response: "+c),b.length===e+1&&a.isFunction(d)&&d(b)}).error(function(){k.error("Incorrect path for "+c.href)})})},u.bind=function(b,c){if(!b||!c)return k.error("No scope or stylesheets provided");var d=[];a.isArray(b)?a.forEach(b,function(a){d.push(o(a))}):d.push(o(b)),u.add(d),k.debug("$css.bind(): Added",d),c.$on("$destroy",function(){u.remove(d),k.debug("$css.bind(): Removed",d)})},u.add=function(b){return b?(a.isArray(b)||(b=[b]),a.forEach(b,function(a){a=o(a),a.href&&!j("filter")(d.stylesheets,{href:a.href}).length&&(p(a),t(a)?r(a):d.stylesheets.push(a),k.debug("$css.add(): "+a.href))}),void d.$broadcast("$cssAdd",b,d.stylesheets)):k.error("No stylesheets provided")},u.remove=function(b){return b?(b=j("filter")(b,function(a){return!a.persist}),a.forEach(b,function(a){var b=d.stylesheets.indexOf(j("filter")(d.stylesheets,{href:a.href})[0]);-1!==b&&d.stylesheets.splice(b,1),s(a),k.debug("$css.remove(): "+a.href)}),void d.$broadcast("$cssRemove",b,d.stylesheets)):k.error("No stylesheets provided")},u.removeAll=function(){d&&d.hasOwnProperty("stylesheets")&&(d.stylesheets.length=0),k.debug("all stylesheets removed")},u.preload(),u}]}]),b.filter("$cssLinks",function(){return function(b){if(!b||!a.isArray(b))return b;var c="";return a.forEach(b,function(a){c+='',w={},x={},y=["print"],z=a.extend({},b),A=a.element(document.querySelector?document.querySelector(z.container):document.getElementsByTagName(z.container)[0]);return a.forEach(c,function(a,b){a.hasOwnProperty("css")&&(c[b]=o(a.css))}),d.stylesheets=[],A[z.method](h(v)(d)),d.$on("$directiveAdd",l),d.$on("$routeChangeStart",m),d.$on("$stateChangeStart",n),u.getFromRoute=function(b){if(!b)return k.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(a){d.push(o(a))}):d.push(o(c))),d},u.getFromRoutes=function(b){if(!b)return k.error("Get From Routes: No routes provided");var c=[];return a.forEach(b,function(a){var b=u.getFromRoute(a);b.length&&c.push(b[0])}),c},u.getFromState=function(b){if(!b)return k.error("Get From State: No state provided");var c=[];return a.isDefined(b.views)&&a.forEach(b.views,function(a){a.css&&c.push(o(a.css))}),a.isDefined(b.children)&&a.forEach(b.children,function(b){b.css&&c.push(o(b.css)),a.isDefined(b.children)&&a.forEach(b.children,function(a){a.css&&c.push(o(a.css))})}),a.isDefined(b.css)&&(a.isArray(b.css)?a.forEach(b.css,function(a){c.push(o(a))}):c.push(o(b.css))),c},u.getFromStates=function(b){if(!b)return k.error("Get From States: No states provided");var c=[];return a.forEach(b,function(b){var d=u.getFromState(b);a.isArray(d)?a.forEach(d,function(a){c.push(a)}):c.push(d)}),c},u.preload=function(b,c){b||(b=[],e.has("$route")&&Array.prototype.push.apply(b,u.getFromRoutes(e.get("$route").routes)),e.has("$state")&&Array.prototype.push.apply(b,u.getFromStates(e.get("$state").get()))),b=q(b,"preload"),a.forEach(b,function(d,e){i.get(d.href).success(function(d){k.debug("preload response: "+d),b.length===e+1&&a.isFunction(c)&&c(b)}).error(function(){k.error("Incorrect path for "+d.href)})})},u.bind=function(b,c){if(!b||!c)return k.error("No scope or stylesheets provided");var d=[];a.isArray(b)?a.forEach(b,function(a){d.push(o(a))}):d.push(o(b)),u.add(d),k.debug("$css.bind(): Added",d),c.$on("$destroy",function(){u.remove(d),k.debug("$css.bind(): Removed",d)})},u.add=function(b){return b?(a.isArray(b)||(b=[b]),a.forEach(b,function(a){a=o(a),a.href&&!j("filter")(d.stylesheets,{href:a.href}).length&&(p(a),t(a)?r(a):d.stylesheets.push(a),k.debug("$css.add(): "+a.href))}),void d.$broadcast("$cssAdd",b,d.stylesheets)):k.error("No stylesheets provided")},u.remove=function(b){return b?(b=j("filter")(b,function(a){return!a.persist}),a.forEach(b,function(a){var b=d.stylesheets.indexOf(j("filter")(d.stylesheets,{href:a.href})[0]);-1!==b&&d.stylesheets.splice(b,1),s(a),k.debug("$css.remove(): "+a.href)}),void d.$broadcast("$cssRemove",b,d.stylesheets)):k.error("No stylesheets provided")},u.removeAll=function(){d&&d.hasOwnProperty("stylesheets")&&(d.stylesheets.length=0),k.debug("all stylesheets removed")},u.preload(),u}]}]),b.filter("$cssLinks",function(){return function(b){if(!b||!a.isArray(b))return b;var c="";return a.forEach(b,function(a){c+='