-
Notifications
You must be signed in to change notification settings - Fork 253
Expand file tree
/
Copy pathng.pqgrid.min.js
More file actions
10 lines (9 loc) · 5.53 KB
/
ng.pqgrid.min.js
File metadata and controls
10 lines (9 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
/*!
* ParamQuery Pro v3.5.0
*
* Copyright (c) 2012-2021 Paramvir Dhindsa (http://paramquery.com)
* Released under GNU General Public License v3
* http://paramquery.com/license
*
*/
!function(e){"use strict";function t(e,t){return e.arr==t.arr&&e.len==t.len&&e.first==t.first&&e.last==t.last}function n(e){var t=e.length;return{arr:e,len:t,first:t?e[0]:null,last:t?e[t-1]:null}}function r(t,n,r,i,a,c){var s=this;s.$scope=t,s.$compile=i,s.$timeout=a,s.$parse=c,s.rowScopes=[],s.$ele=n;var l=r.cloneOptions,d=r.options,u=t.$eval(d),p=r.rebind,f=l?e.extend(!0,{},u):u,h=f.ngModel||{},$=s.readCellTemplates(f.colModel||[])||h.compileRows,g=f.dataModel,v="string"==typeof g.data?g.data:null,m=h.watch||1,w=s.detailTmpl=f.detailTemplate;s.timerDigest=o.timer(),p&&("all"==p?s.rebindAll(u,d):s.rebind(p,d)),w&&s.templateDetail(w,f),s.unregWatch=m&&v?function(){return m===!0?t.$watchCollection(v,s.watchCollListener(s)):t.$watch(s.watch(s,v))}():null,v&&(g.data=t.$eval(v)),f.render=s.onRender(s,f,f.render,function(e){h.compileHeader&&e.on("refreshHeader",s.onRefreshHeader(s)),h.compileToolbar&&e.one("dataReady",s.oneDataReady(s)),e.on("dataReady",s.onDataReady(s,v)),$&&e.on("refresh",s.onRefresh(s))}),s.grid=pq.grid(n,f).on("refreshRow refreshCell",s.onRefreshRowCell(s,$)).on("destroy",s.onDestroy(s)),s.bindEvents(r),m===!0&&v&&s.digest(t)}if(!pq.ng){pq.ng={};var o={timer:function(){var e;return{setTimeout:function(t){e&&clearTimeout(e),e=setTimeout(t)}}}};pq.ng.cGrid=r;var i=r.prototype;i.onEvent=function(e,t){return function(n,r){var o=e.$scope.$new();o.evt=n,o.ui=r,o.$eval(t),o.$destroy(),e.digestAsync()}},i.bindEvents=function(e){var t,n,r=e.$attr,o=this;for(n in r)0===n.indexOf("on")&&(t=n.substring(2,3).toLowerCase()+n.substr(3),o.grid.on(t,o.onEvent(o,e[n])))},i.rebindWListen=function(e,t){return function(n,r){n!==r&&(e.grid.option(t,n),e.grid.refreshView())}},i.compareObj=function(t,n,r,o){var i,a,c,s;for(i in n)a=t[i],c=n[i],s=(o?o+".":"")+i,e.isPlainObject(a)?this.compareObj(a,c,r,s):a===c||e.isArray(a)||r(s,a)},i.copy=function(t,n){var r,o,i=this;for(var r in t)o=t[r],e.isPlainObject(o)?(n[r]={},i.copy(o,n[r])):n[r]=o;return n},i.rebindAll=function(e,t){var n=this,r=n.$scope,o=n.copy(e,{});r.$watch(function(){var e=!1,i=r.$eval(t);n.compareObj(i,o,function(t,r){e=!0,n.grid.option(t,r)}),e&&(o=n.copy(i,{}),n.grid.refreshView())})},i.rebind=function(e,t){for(var n=e.split(" "),r=this,o=r.$scope,i=0;i<n.length;i++){var a=n[i],c=t+"."+a;o.$watch(c,r.rebindWListen(r,a))}},i.templateDetail=function(e,t){var n=this;t.detailModel=t.detailModel||{},t.detailModel.init=function(t){var r,o=n.$scope.$new(!1);return o.ui=t,t.rowData.pq_scope_detail=o,e="function"==typeof e?e.call(this,t):e,r=n.$compile(e)(o),n.digest(o),r}},i.detailDestroyScopes=function(){if(this.detailTmpl)for(var e,t,n=this.grid.option("dataModel.data"),r=0,o=n.length;o>r;r++)t=n[r],(e=t.pq_scope_detail)&&e.$destroy()},i.onDataReady=function(e,t){return function(n){if(t){var r=this.options.dataModel.data;e.updateObjInt(r),e.$parse(t).assign(e.$scope,r)}e.digestAsync()}},i.watchCollListener=function(e){return function(t,n){t!==n&&e.refreshGrid(t)}},i.watch=function(e,r){return function(){var o,i,a=e.$scope.$eval(r);i=n(a),o=e.objInt,o&&!t(o,i)&&e.refreshGrid(a)}},i.updateObjInt=function(e){this.objInt=n(e)},i.cleanRowScopes=function(){for(var e=0,t=this.rowScopes,n=t.length;n>e;e++)t[e].$destroy();t.length=0},i.onRefreshRowCell=function(e,t){return function(n,r){if(t){var o=this.getRow(r);e.rowScope(o,r.rowData,r.rowIndx)}}},i.onRefresh=function(t){return function(){var n,r,o,i,a,c=this,s=0;for(t.cleanRowScopes(),n=c.$cont.children().children().children().children(".pq-grid-row:not('.pq-detail-child')"),o=n.length;o>s;s++)r=e(n[s]),i=c.getRowIndx({$tr:r}),a=c.getRowData(i),t.rowScope(r,a,i.rowIndx)}},i.onRefreshHeader=function(e){return function(){var t=this,n=e.$scope;e.$compile(t.$header)(n),e.digest(n)}},i.oneDataReady=function(e){return function(){var t=this,n=e.$scope;e.$compile(t.toolbar())(n),e.digest(n)}},i.onRender=function(e,t,n,r){return function(o,i){var a=this,c=e.$scope;c.grid=a,a.$scope=c,t.grid=a,n&&n.call(a,o,i),r(a)}},i.onDestroy=function(e){return function(){e.$scope.$destroy(),e.cleanRowScopes(),e.detailDestroyScopes(),e.unregWatch&&e.unregWatch()}},i.digestAsync=function(){var e=this,t=e.timerDigest,n=e.$scope.$root,r=n.$$phase;"$apply"!=r&&"$digest"!=r&&t.setTimeout(function(){r=n.$$phase,"$apply"!=r&&"$digest"!=r&&n.$digest()})},i.digest=function(e){var t=e.$root.$$phase;"$apply"!=t&&"$digest"!=t&&e.$digest()},i.rowScope=function(e,t,n){var r=this,o=r.$scope.$new(!1);r.rowScopes.push(o),o.rd=t,o.ri=n,r.$compile(e)(o),r.digest(o)},i.readCellTemplates=function(e){for(var t,n,r,o,i=0,a=e.length,c=this,s=c.$scope,l=c.$compile;a>i;i++)if(t=e[i],(n=t.template)&&(r=!0,t.render=c.templateCell(n)),(n=t.editorTemplate)&&(t.editor=c.templateEditor(c,t.editor,n,l,s)),o=t.validations)for(var d=0;d<o.length;d++)(n=o[d].template)&&(o[i].type=c.templateValid(n,l,s));return r},i.templateValid=function(e,t,n){return function(r){var o,i=n.$new(!1);return i.ui=r,t(e)(i),o=i["return"],i.$destroy(),o}},i.templateEditor=function(t,n,r,o,i){return function(t){var a,c=i.$new(!1);return c.ui=t,o(r)(c),a=c.editor,c.$destroy(),e.extend(n,a)}},i.templateCell=function(e){return function(){return e}},i.refreshGrid=function(e){var t=this.grid;t.option("dataModel.data",e),t.refreshView()},angular.module("pq.grid",[]).directive("pqGrid",["$compile","$timeout","$parse",function(e,t,n){return{restrict:"AE",scope:!0,replace:!0,link:function(o,i,a){new r(o,i,a,e,t,n)},template:"<div></div>"}}])}}(jQuery);