UNPKG

angular-material

Version:

**[Support for legacy AngularJS ended on January 1st, 2022](https://goo.gle/angularjs-end-of-life). [See `@angular/core` for the actively supported Angular](https://npmjs.com/@angular/core).**

7 lines 6.11 kB
/*! * AngularJS Material Design * https://github.com/angular/material * @license MIT * v1.2.4-master-bfc8ae7 */ !function(t,T){"use strict";function e(f,v,w,y,$){return{restrict:"E",controller:i,scope:{mdOnLayout:"&"},link:function(i,o,g,e){o.addClass("_md"),o.attr("role","list"),e.layoutDelegate=function(t){var n=[].filter.call(o.children(),function(t){return"MD-GRID-TILE"==t.tagName&&!t.$$mdDestroyed}),r={tileSpans:function(t){return[].map.call(t,function(t){var e=T.element(t).controller("mdGridTile");return{row:parseInt(y.getResponsiveAttribute(e.$attrs,"md-rowspan"),10)||1,col:parseInt(y.getResponsiveAttribute(e.$attrs,"md-colspan"),10)||1}})}(n),colCount:function(){var t=parseInt(y.getResponsiveAttribute(g,"md-cols"),10);if(isNaN(t))throw"md-grid-list: md-cols attribute was not found, or contained a non-numeric value";return t}(),rowMode:d(),rowHeight:function(){var t=y.getResponsiveAttribute(g,"md-row-height");if(!t)throw"md-grid-list: md-row-height attribute was not found";switch(d()){case"fixed":return c(t);case"ratio":var e=t.split(":");return parseFloat(e[0])/parseFloat(e[1]);case"fit":return 0}}(),gutter:c(y.getResponsiveAttribute(g,"md-gutter")||1)};if(!t&&T.equals(r,a))return;var e=w(r.colCount,r.tileSpans,n).map(function(t,i){return{grid:{element:o,style:function(t,e,i,n,r){var o={};switch(n){case"fixed":o.height=h({unit:r,span:e,gutter:i}),o.paddingBottom="";break;case"ratio":var a=m({share:1/r*(1/t*100),gutterShare:1===t?0:(t-1)/t,gutter:i});o.height="",o.paddingBottom=h({unit:a,span:e,gutter:i})}return o}(r.colCount,i,r.gutter,r.rowMode,r.rowHeight)},tiles:t.map(function(t,e){return{element:T.element(n[e]),style:function(t,e,i,n,r,o,a){var u=1/i*100,s=(i-1)/i,l=m({share:u,gutterShare:s,gutter:r}),d=$.isRtl(g)?{right:p({unit:l,offset:t.col,gutter:r}),width:h({unit:l,span:e.col,gutter:r}),paddingTop:"",marginTop:"",top:"",height:""}:{left:p({unit:l,offset:t.col,gutter:r}),width:h({unit:l,span:e.col,gutter:r}),paddingTop:"",marginTop:"",top:"",height:""};switch(o){case"fixed":d.top=p({unit:a,offset:t.row,gutter:r}),d.height=h({unit:a,span:e.row,gutter:r});break;case"ratio":var c=u/a,f=m({share:c,gutterShare:s,gutter:r});d.paddingTop=h({unit:f,span:e.row,gutter:r}),d.marginTop=p({unit:f,offset:t.row,gutter:r});break;case"fit":f=m({share:c=1/n*100,gutterShare:(n-1)/n,gutter:r}),d.top=p({unit:f,offset:t.row,gutter:r}),d.height=h({unit:f,span:e.row,gutter:r})}return d}(t.position,t.spans,r.colCount,i,r.gutter,r.rowMode,r.rowHeight)}})}}).reflow().performance();i.mdOnLayout({$event:{performance:e}}),a=r};var a,n=T.bind(e,e.invalidateLayout),r=function(){for(var t in v.MEDIA)y(t),y.getQuery(v.MEDIA[t]).addListener(n);return y.watchResponsiveAttributes(["md-cols","md-row-height","md-gutter"],g,u)}();function u(t){null==t?e.invalidateLayout():y(t)&&e.invalidateLayout()}i.$on("$destroy",function(){for(var t in e.layoutDelegate=T.noop,r(),v.MEDIA)y.getQuery(v.MEDIA[t]).removeListener(n)});var s=f.startSymbol(),l=f.endSymbol();function t(t){return s+t+l}var m=f(t("share")+"% - ("+t("gutter")+" * "+t("gutterShare")+")"),p=f("calc(("+t("unit")+" + "+t("gutter")+") * "+t("offset")+")"),h=f("calc(("+t("unit")+") * "+t("span")+" + ("+t("span")+" - 1) * "+t("gutter")+")");function d(){var t=y.getResponsiveAttribute(g,"md-row-height");if(!t)throw"md-grid-list: md-row-height attribute was not found";return"fit"==t?"fit":-1!==t.indexOf(":")?"ratio":"fixed"}function c(t){return/\D$/.test(t)?t:t+"px"}}}}function i(t){this.layoutInvalidated=!1,this.tilesInvalidated=!1,this.$timeout_=t.nextTick,this.layoutDelegate=T.noop}function n(s){var l=e;return t.animateWith=function(t){l=T.isFunction(t)?t:e},t;function t(t,e){var i,n,r,o,a,u;return o=s.time(function(){n=function(r,t){var o=0,a=0,u=function(){for(var t=[],e=0;e<r;e++)t.push(0);return t}();return{positioning:t.map(function(t,e){return{spans:t,position:function(t,e){if(t.col>r)throw"md-grid-list: Tile at position "+e+" has a colspan ("+t.col+") that exceeds the column count ("+r+")";var i=0,n=0;for(;n-i<t.col;)r<=o?s():-1!==(i=u.indexOf(0,o))&&-1!==(n=d(i+1))?o=n+1:(i=n=0,s());return l(i,t.col,t.row),o=i+t.col,{col:i,row:a}}(t,e)}}),rowCount:a+Math.max.apply(Math,u)};function s(){a++,l(o=0,r,-1)}function l(t,e,i){for(var n=t;n<t+e;n++)u[n]=Math.max(u[n]+i,0)}function d(t){var e;for(e=t;e<u.length;e++)if(0!==u[e])return e;if(e===u.length)return e}}(t,e)}),i={layoutInfo:function(){return n},map:function(e){return a=s.time(function(){var t=i.layoutInfo();r=e(t.positioning,t.rowCount)}),i},reflow:function(t){return u=s.time(function(){(t||l)(r.grid,r.tiles)}),i},performance:function(){return{tileCount:e.length,layoutTime:o,mapTime:a,reflowTime:u,totalTime:o+a+u}}}}function e(t,e){t.element.css(t.style),e.forEach(function(t){t.element.css(t.style)})}}function r(o){return{restrict:"E",require:"^mdGridList",template:"<figure ng-transclude></figure>",transclude:!0,scope:{},controller:["$attrs",function(t){this.$attrs=t}],link:function(t,e,i,n){e.attr("role","listitem");var r=o.watchResponsiveAttributes(["md-colspan","md-rowspan"],i,T.bind(n,n.invalidateLayout));n.invalidateTiles(),t.$on("$destroy",function(){e[0].$$mdDestroyed=!0,r(),n.invalidateLayout()}),T.isDefined(t.$parent.$index)&&t.$watch(function(){return t.$parent.$index},function(t,e){t!==e&&n.invalidateTiles()})}}}function o(){return{template:"<figcaption ng-transclude></figcaption>",transclude:!0}}i.$inject=["$mdUtil"],n.$inject=["$mdUtil"],e.$inject=["$interpolate","$mdConstant","$mdGridLayout","$mdMedia","$mdUtil"],r.$inject=["$mdMedia"],T.module("material.components.gridList",["material.core"]).directive("mdGridList",e).directive("mdGridTile",r).directive("mdGridTileFooter",o).directive("mdGridTileHeader",o).factory("$mdGridLayout",n),i.prototype={invalidateTiles:function(){this.tilesInvalidated=!0,this.invalidateLayout()},invalidateLayout:function(){this.layoutInvalidated||(this.layoutInvalidated=!0,this.$timeout_(T.bind(this,this.layout)))},layout:function(){try{this.layoutDelegate(this.tilesInvalidated)}finally{this.layoutInvalidated=!1,this.tilesInvalidated=!1}}}}(window,window.angular);