ux-datagrid-expandRows.min.js |
|
! ux-angularjs-datagrid v.1.4.11 (c) 2016, Obogo https://github.com/obogo/ux-angularjs-datagrid License: MIT. |
(function (exports, global) {
if (typeof define === "function" && define.amd) {
define(exports);
} else if (typeof module !== "undefined" && module.exports) {
module.exports = exports;
} else {
global.ux = exports;
}
!function(a,b){"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&module.exports?module.exports=a:b.ux=a,a.datagrid.events.COLLAPSE_ROW="datagrid:collapseRow",a.datagrid.events.EXPAND_ROW="datagrid:expandRow",a.datagrid.events.TOGGLE_ROW="datagrid:toggleRow",a.datagrid.events.ROW_TRANSITION_COMPLETE="datagrid:rowTransitionComplete",a.datagrid.events.COLLAPSE_ALL_EXPANDED_ROWS="datagrid:collapseAllExpandedRows",a.datagrid.options.expandRows=[],a.datagrid.options.expandRows.autoClose=!0,a.datagrid.options.expandRows.scrollOnExpand=!0,angular.module("ux").factory("expandRows",function(){return["inst",function(b){function c(a){return s="number"==typeof a?a:b.getNormalizedIndex(a,s)}function d(a){a.template=a.template||b.templateModel.defaultName,a.cls||a.style||a.swap||b.throwError("expandRows will not work without an cls|style|swap property"),u[a.template]=a}function e(){ux.each(b.options.expandRows,d)}function f(a){var b=c(a);return v[b]?x.opened:x.closed}function g(a){f(a)===x.closed?h(a):i(a)}function h(a){var d=c(a);if(f(d)===x.closed){if(t.log("expand %s",a),b.options.expandRows.autoClose&&w)return;w=!0,j([d],!0),l(d,x.opened)}}function i(a,b){var d=c(a);f(d)===x.opened&&(t.log("collapse %s",a),l(d,x.closed,b))}function j(a,c){b.options.expandRows.autoClose&&k(a,!1,c)}function k(c,d,e){a.each(v,function(a,f){var g=parseInt(f,10);(!c||b.rowsLength>g&&-1===c.indexOf(g))&&(d?(i(g,!0),delete v[f]):i(g,e))})}function l(a,c,d){var e,f,g,h=b.templateModel.getTemplate(b.data[a]);if(u[h.name]){if(e=b.getExistingRow(a),!e||!e.scope())return void delete v[a];e.scope().$state=c,f=u[h.name],f.transition!==!1&&e[0].addEventListener(B,o),f.style&&(f.reverse||(f.reverse=m(e,f.style)),e.css(c===x.opened?f.style:f.reverse)),f.swap&&f.state!==c?(g=u[f.swap],g.cls=g.cls||"",b.templateModel.setTemplate(a,f.swap,[g.cls]),e=b.getRowElm(a)):f.cls&&(e[c===x.opened?"addClass":"removeClass"](f.cls),e.addClass("animating"));var i={target:e[0],index:a,state:c};d?o(i,d):b.flow.add(o,[i],0)}else b.throwError("unable to toggle template. cls for template '"+h.name+"' was not set.")}function m(a,b){var c={elm:a,style:b,reverse:{}};return ux.each(b,n,c),c.reverse}function n(a,b,c,d){d.reverse[b]=d.elm.css(b)}function o(c,d){var e,f,g,h;a.util.apply(Object.prototype.hasOwnProperty,c,["index"])?(e=b.getRowElm(c.index),g=c.index,h=c.state):e=angular.element(c.target),f=e.scope(),h&&f?(f.$index=g,f.$state=h):f&&(g=f.$index,h=f.$state),e[0].removeEventListener(B,o),e.removeClass("animating"),h===x.opened?(v[g]={index:g,height:parseInt(e[0].offsetHeight||0,10)},isNaN(v[g].height)&&b.throwError("Invalid Height")):delete v[g],b.updateHeights(g),d?w=!1:b.flow.add(function(){b.options.expandRows.scrollOnExpand&&b.scrollModel.scrollIntoView(g,!0),b.dispatch(a.datagrid.events.ROW_TRANSITION_COMPLETE),w=!1,b.options.expandRows.scrollOnExpand&&b.flow.add(function(){h===x.opened&&g===b.data.length-1&&b.getViewportHeight()<b.getContentHeight()&&b.scrollModel.scrollToBottom(!0)},[],0)},[],0)}function p(a){var b=c(a);return!!v[b]}function q(a){var b=c(a);return v[b]?(t.log(" expandRow %s to height %s",b,v[b].height),v[b].height):y(a)}function r(){t=null,u=null,v=null,x=null}var s,t=a.logWrapper("expandRows",{},"green",b),u={},v={},w=!1,x={opened:"opened",closed:"closed"},y=b.templateModel.getTemplateHeight,z=document.createElement("div").style,A=function(){for(var a,b="t,webkitT,MozT,msT,OT".split(","),c=0,d=b.length;d>c;c++)if(a=b[c]+"ransform",a in z)return b[c].substr(0,b[c].length-1);return!1}(),B=function(){if(A===!1)return!1;var a={"":"transitionend",webkit:"webkitTransitionEnd",Moz:"transitionend",O:"oTransitionEnd",ms:"MSTransitionEnd"};return a[A]}();return z=null,b.templateModel.getTemplateHeight=q,t.states=x,t.getIndex=c,t.toggle=function(a){b.flow.add(g,[a])},t.expand=function(a){b.flow.add(h,[a])},t.collapse=function(a){b.flow.add(i,[a])},t.isExpanded=p,t.destroy=r,b.unwatchers.push(b.scope.$on(a.datagrid.events.ON_READY,e)),b.unwatchers.push(b.scope.$on(a.datagrid.events.EXPAND_ROW,function(a,b){t.expand(b)})),b.unwatchers.push(b.scope.$on(a.datagrid.events.COLLAPSE_ROW,function(a,b){t.collapse(b)})),b.unwatchers.push(b.scope.$on(a.datagrid.events.TOGGLE_ROW,function(a,b){t.toggle(b)})),b.unwatchers.push(b.scope.$on(a.datagrid.events.ON_ROW_COMPILE,function(a,c,d){if(v[c.$index]){var e=b.templateModel.getTemplate(b.data[c.$index]),f=u[e.name];d[0].classList.add(f.cls)}})),b.unwatchers.push(b.scope.$on(a.datagrid.events.COLLAPSE_ALL_EXPANDED_ROWS,function(a,b){k(null,b)})),a.datagrid.events.ON_BEFORE_TOGGLE_SORT&&b.unwatchers.push(b.scope.$on(a.datagrid.events.ON_BEFORE_TOGGLE_SORT,function(a){k()})),b.unwatchers.push(b.scope.$on(a.datagrid.events.ON_BEFORE_DATA_CHANGE,function(a){k(null,!0)})),b.expandRows=t,b}]})}(this.ux=this.ux||{},function(){return this}());
|
¶ sourceMappingURL=ux-datagrid-expandRows.min.js.map |
}(this.ux = this.ux || {}, function() {return this;}()));
|