Vergleich jscripts/sceditor/editor_plugins/undo.js - 1.8.4 - 1.8.6

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 1
/* SCEditor v1.4.5 | (C) 2011-2014, Sam Clarke | sceditor.com/license */
(function(e){"use strict";e.sceditor.plugins.undo=function(){var e=this;var t;var n=0;var r;var i=50;var s=[];var o=[];var u=false;var a=function(e){u=true;r=e.value;t.sourceMode(e.sourceMode);t.val(e.value,false);t.focus();if(e.sourceMode){t.sourceEditorCaret(e.caret)}else{t.getRangeHelper().restoreRange()}u=false};var f=function(e,t){var n,r,i,s,o=e.length,u=t.length,a=Math.max(o,u);for(n=0;n<a;n++){if(e[n]!==t[n]){break}}i=o<u?u-o:0;s=u<o?o-u:0;for(r=a-1;r>=0;r--){if(e[r-i]!==t[r-s]){break}}return r-n+1};e.init=function(){t=this;i=t.undoLimit||i;t.addShortcut("ctrl+z",e.undo);t.addShortcut("ctrl+shift+z",e.redo);t.addShortcut("ctrl+y",e.redo)};e.undo=function(){var e=o.pop();var n=t.val(null,false);if(e&&!s.length&&n===e.value){e=o.pop()}if(e){if(!s.length){s.push({caret:t.sourceEditorCaret(),sourceMode:t.sourceMode(),value:n})}s.push(e);a(e)}return false};e.redo=function(){var e=s.pop();if(!o.length){o.push(e);e=s.pop()}if(e){o.push(e);a(e)}return false};e.signalReady=function(){var e=t.val(null,false);r=e;o.push({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:e})};e.signalValuechangedEvent=function(e){var a=e.rawValue;if(i>0&&o.length>i){o.shift()}if(u||r===a){return}s.length=0;n+=f(r,a);if(n<20){return}else if(n<50&&!e.rawValue[e.rawValue.length-1].match(/\s/g)){return}o.push({caret:t.sourceEditorCaret(),sourceMode:t.sourceMode(),value:a});n=0;r=a}}})(jQuery)

/* SCEditor v1.4.7 | (C) 2015, Sam Clarke | sceditor.com/license */
!function(a){"use strict";a.sceditor.plugins.undo=function(){var a,b,c=this,d=0,e=50,f=[],g=[],h=!1,i=function(c){h=!0,b=c.value,a.sourceMode(c.sourceMode),a.val(c.value,!1),a.focus(),c.sourceMode?a.sourceEditorCaret(c.caret):a.getRangeHelper().restoreRange(),h=!1},j=function(a,b){var c,d,e,f,g=a.length,h=b.length,i=Math.max(g,h);for(c=0;i>c&&a.charAt(c)===b.charAt(c);c++);for(e=h>g?h-g:0,f=g>h?g-h:0,d=i-1;d>=0&&a.charAt(d-e)===b.charAt(d-f);d--);return d-c+1};c.init=function(){a=this,e=a.undoLimit||e,a.addShortcut("ctrl+z",c.undo),a.addShortcut("ctrl+shift+z",c.redo),a.addShortcut("ctrl+y",c.redo)},c.undo=function(){var b=g.pop(),c=a.val(null,!1);return b&&!f.length&&c===b.value&&(b=g.pop()),b&&(f.length||f.push({caret:a.sourceEditorCaret(),sourceMode:a.sourceMode(),value:c}),f.push(b),i(b)),!1},c.redo=function(){var a=f.pop();return g.length||(g.push(a),a=f.pop()),a&&(g.push(a),i(a)),!1},c.signalReady=function(){var c=a.val(null,!1);b=c,g.push({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:c})},c.signalValuechangedEvent=function(c){var i=c.rawValue;e>0&&g.length>e&&g.shift(),!h&&b&&b!==i&&(f.length=0,d+=j(b,i),20>d||50>d&&!/\s$/g.test(c.rawValue)||(g.push({caret:a.sourceEditorCaret(),sourceMode:a.sourceMode(),value:i}),d=0,b=i))}}}(jQuery);