forked from fewagewasd/angular-deckgrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-deckgrid.min.js
2 lines (2 loc) · 6.08 KB
/
angular-deckgrid.min.js
1
2
/*! angular-deckgrid (v0.9.0) - Copyright: 2013, André König ([email protected]) - MIT */
angular.module("akoenig.deckgrid",[]),angular.module("akoenig.deckgrid").directive("deckgrid",["DeckgridDescriptor",function(a){"use strict";return a.create()}]),angular.module("akoenig.deckgrid").factory("DeckgridDescriptor",["$rootScope","Deckgrid",function(a,b){"use strict";function c(){this.restrict="AE",this.scope={model:"=source"},this.$$deckgrid=null,this.template='<div data-ng-repeat="column in columns" class="{{layout.classList}}"><div data-ng-repeat="item in column"></div></div>',this.compile=function(b,c){var d=c.deckgrid,e=c.extraType,f=c.extraIcon,g=c.showLearnIf,h=c.learnText,i=c.isExamples,j=b.find('[data-ng-repeat="column in columns"]'),k=b.find('[data-ng-repeat="item in column"]'),l={"data-bb-wrap-card":"item"},m="",n="",o="";if("card"===d?(i&&(l["data-allow-marketing"]=!0),h&&(n="<div "+(g?'data-ng-if="'+g+'" ':"")+'class="{{layout.classList}}" ><div class="component learn" data-type="'+e+'" data-icon="'+f+'" ><div class="contents"> '+("css"==h?"":h)+"</div></div></div>")):"asset"===d?(a.isDetailPage&&b.attr("data-deckgrid","assets-full"),l={"data-bb-wrap-asset":"item"}):"gallery"===d?(l={"data-ng-click":"$event.stopPropagation(); mother.showSlide(item.id);","class":"image loading-spinner","data-unveil-item":"item.asset","data-constrain-width":"270","data-fit":"max","data-force":"true","data-has-image":"true"},m='<div class="spinner" data-icon="spinner"></div> <img class="pusher" data-pusher-gif data-constrain-width="270" data-calc-width="{{item.asset.width}}" data-calc-height="{{item.asset.height}}" data-fp-fallback="item.asset.url" /><div data-iw-multi-select-btn="item" data-ng-if="$root.multiSelect.enabled && $root.multiSelect.options.type == \'slide\'"></div>',o='<div class="{{layout.classList}}" ><div class="image new" data-ng-show="$root.activeWrap.editable" data-ng-click="$root.addFiles(mother.asset.id, \'gallery\', \'image/*\')"></div></div>'):"notification"===d?(l={"data-bb-notification-card":"item","data-dashboard":"true","data-wraps":"mother.wraps","data-groups":"mother.groups"},n="<div "+(g?'data-ng-if="'+g+'" ':"")+'class="{{layout.classList}}" ><div class="component learn" data-type="'+e+'" data-icon="'+f+'" ><div class="contents"> '+("css"==h?"":h)+"</div></div></div>"):"user"===d?(l={"data-bb-user-row":"item","data-user-type":e},n='<div class="{{layout.classList}}" ><div class="component learn" data-type="'+e+'" data-icon="'+f+'" ><div class="contents"> '+("css"==h?"":h)+"</div></div></div>",o='<div class="{{layout.classList}}" ><div class="component new '+e+'" data-bb-share data-ng-click="showOptions($event)" data-target="$root.activeWrap" data-type="'+("followers"===e?"follow":"collaborate")+'" data-target-name="$root.activeWrap.name" data-title="Invite '+_.capitalize(e)+'" ></div></div>'):"member"===d&&(l={"data-bb-user-row":"item","data-user-type":e},o='<div class="{{layout.classList}}" ><div class="component new '+e+'" data-bb-share data-ng-click="showOptions($event)" data-target="mother.group.id" data-type="member" data-target-name="mother.group.name" data-title="Invite Group Members" ></div></div>'),l)for(var p in l)k.attr(p,l[p]);return m&&k.html(m),n&&$(n).insertAfter(j),o&&$(o).insertAfter(j),this.$$link.bind(this)}}return c.prototype.$$destroy=function(){this.$$deckgrid.destroy()},c.prototype.$$link=function(a,c){a.$on("$destroy",this.$$destroy.bind(this)),a.mother=a.$parent,this.$$deckgrid=b.create(a,c[0])},{create:function(){return new c}}}]),angular.module("akoenig.deckgrid").provider("Deckgrid",function(){var a=3,b={columns:1,classList:"column column-1-width"};return{setConfigLoopLimit:function(b){b&&(a=b)},setDefaultLayout:function(a){a&&(b=a)},$get:["$window","$log","$rootScope","$q","$timeout",function(c,d,e,f,g){"use strict";function h(a,b){var c,d=this;this.$$elem=b,this.$$watchers=[],this.$$scope=a,this.$$scope.columns=[],this.$$getLayout().then(function(a){d.$$scope.layout=a,d.$$createColumns(),c=d.$$scope.$watch("model",d.$$onModelChange.bind(d),!0),d.$$watchers.push(c),angular.forEach(d.$$getMediaQueries(),function(a){function b(){a.removeListener(d.$$onMediaQueryChange.bind(d))}a.addListener(d.$$onMediaQueryChange.bind(d)),d.$$watchers.push(b)})})}return h.prototype.$$getMediaQueries=function(){function a(a){var b=/\[(\w*-)?deckgrid[^\]]*\]::?before/g,c=0,d="";if(!a.media||angular.isUndefined(a.cssRules))return!1;for(c=a.cssRules.length-1;c>=0;c-=1)if(d=a.cssRules[c].selectorText,angular.isDefined(d)&&d.match(b))return!0;return!1}var b=[],d=document.styleSheets;return angular.forEach(d,function(d){var e=d.cssRules;angular.forEach(e,function(d){d.constructor===CSSMediaRule&&a(d)&&b.push(c.matchMedia(d.media.mediaText))})}),b},h.prototype.$$createColumns=function(){var a=this;return this.$$scope.layout?(this.$$scope.columns=[],void angular.forEach(this.$$scope.model,function(b,c){var d=c%a.$$scope.layout.columns|0;a.$$scope.columns[d]||(a.$$scope.columns[d]=[]),a.$$scope.columns[d].push(b)})):d.log("angular-deckgrid: No CSS configuration found (see https://github.com/akoenig/angular-deckgrid#the-grid-configuration)")},h.prototype.$$getLayout=function(){var d,e,h,i=f.defer(),j=this,k=a,l=0,m=function(){d=c.getComputedStyle(j.$$elem,":before").content},n=function(){d=d.replace(/'/g,""),d=d.replace(/"/g,""),d=d.split(" "),e={},2===d.length?(e.columns=0|d[0],e.classList=d[1].replace(/\./g," ").trim()):e=b,h&&g.cancel(h),i.resolve(e)},o=function(){h=g(function(){m(),d?n():k>l&&(l++,o())},300)};return m(),d?n():o(),i.promise},h.prototype.$$onMediaQueryChange=function(){var a=this;this.$$getLayout().then(function(b){if(b&&b.columns!==a.$$scope.layout.columns){a.$$scope.layout=b;var c=function(){a.$$createColumns()},d=e.$$phase;"$apply"===d||"$digest"===d?c():a.$$scope.$apply(c)}})},h.prototype.$$onModelChange=function(a,b){var c=this;a&&(angular.isUndefined(b)?c.$$createColumns():a.length!==b.length?c.$$createColumns():a.length>0&&(angular.isUndefined(c.$$scope.columns)||0===c.$$scope.columns.length)&&c.$$createColumns())},h.prototype.destroy=function(){var a=this.$$watchers.length-1;for(a;a>=0;a-=1)this.$$watchers[a]()},{create:function(a,b){return new h(a,b)}}}]}});