1 |
- !function(X,Q){"use strict";var R="ht",U=X[R],l=U.Default,$=l.def,o="add",G="remove",h=l.getInternal(),Y="propertyChange";U.HistoryManager=function(Y){this._histories=[],this.setDataModel(Y)},$(U.HistoryManager,Q,{ms_ac:["dataModel","histories","historyIndex","maxHistoryCount"],ms_fire:1,_historyIndex:-1,$4p:0,$8p:0,_maxHistoryCount:10,beginInteraction:function(){var r=this;r.$4p++,1===r.$4p&&(r.$3p=[])},endInteraction:function(){var s=this,E=s._histories,p=s._historyIndex,D=s.$3p;s.$4p>0&&s.$4p--,0===s.$4p&&(delete s.$3p,D&&D.length&&(E=E.slice(0,p+1),E.push(D),E.length>s._maxHistoryCount&&(E=E.slice(E.length-s._maxHistoryCount)),s.setHistories(E),s.setHistoryIndex(E.length-1,!0)))},beginTransient:function(){this.$4p||this.$8p++},endTransient:function(){this.$4p||this.$8p--},setDataModel:function(m){var S=this,y=S._dataModel;y!==m&&(y&&(delete y._historyManager,y.umm(S.$5p,S),y.umd(S.$6p,S)),S._dataModel=m,m._historyManager=S,m.mm(S.$5p,S),m.md(S.$6p,S),S.fp("dataModel",y,m),S.clear())},setHistoryIndex:function(j,A){var a=this,_=a._historyIndex,I=a._histories.length;if(-1>j?j=-1:j>=I&&(j=I-1),_!==j){if(!A){var p=j-_;p>0?a.$2p(p):0>p&&a.$1p(-p)}a._historyIndex=j,a.fp("historyIndex",_,j)}},setMaxHistoryCount:function(u){var z=this,C=z._histories,B=z._maxHistoryCount;(!u||0>=u)&&(u=10),B!==u&&(z._maxHistoryCount=u,z.fp("maxHistoryCount",B,u),C.length>u&&z.clear())},$5p:function(p){if(!this.$7p&&!this.$8p){var H,e,M=this,t=M._histories,v=p.kind,W=p.property,x=M._historyIndex;if(v===o||v===G?e={type:p.kind,data:p.data}:W&&"children"!==W&&"attaches"!==W&&"shape"!==W&&(e={type:Y,data:p.data,property:W,oldValue:p.oldValue,newValue:p.newValue}),e)if(M.$4p){H=M.$3p;var s=!1;if(e.type===Y)for(var Z=H.length-1;Z>=0;Z--){var h=H[Z];if(h.type!==Y)break;e.property===h.property&&h.property&&e.data===h.data&&(e.oldValue=h.oldValue,H[Z]=e,s=!0)}s||H.push(e)}else H=[e],t=t.slice(0,x+1),t.push(H),t.length>M._maxHistoryCount&&(t=t.slice(t.length-M._maxHistoryCount)),M.setHistories(t),M.setHistoryIndex(t.length-1,!0)}},$6p:function(z){this.$5p(z)},undo:function(p){(!p||0>=p)&&(p=1),this.setHistoryIndex(this._historyIndex-p)},$1p:function(M){var _,X=this,L=X._dataModel,n=X._histories,B=X._historyIndex;for(X.$7p=1,l.setIsolating(!0);M>0;){if(B>=0&&B<n.length){_=n[B],B--;for(var q=_.length-1;q>=0;q--){var O=_[q],p=O.type,I=O.data,f=O.property,r=O.oldValue;if(p===o)L.remove(I);else if(p===G)L.add(I);else{var N=null;0===f.indexOf("a:")?(N="attr",f=f.replace("a:","")):0===f.indexOf("s:")&&(N="style",f=f.replace("s:","")),h.setPropertyValue(I,N,f,r)}}}M--}l.setIsolating(!1),delete X.$7p},redo:function(c){(!c||0>=c)&&(c=1),this.setHistoryIndex(this._historyIndex+c)},$2p:function(P){var B,Z=this,m=Z._dataModel,X=Z._histories,b=Z._historyIndex;for(Z.$7p=1,l.setIsolating(!0);P>0;){if(b>=-1&&b<X.length-1){b++,B=X[b];for(var F=0;F<B.length;F++){var O=B[F],H=O.type,x=O.data,I=O.property,S=O.newValue;if(H===o)m.add(x);else if(H===G)m.remove(x);else{var W=null;0===I.indexOf("a:")?(W="attr",I=I.replace("a:","")):0===I.indexOf("s:")&&(W="style",I=I.replace("s:","")),h.setPropertyValue(x,W,I,S)}}}P--}l.setIsolating(!1),delete Z.$7p},clear:function(){this.setHistories([]),this.setHistoryIndex(-1,!0),this.$4p=0,delete this.$3p}})}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:this,Object);
|