HTMLArea.UndoRedo=HTMLArea.Plugin.extend({constructor:function(editor,pluginName){this.base(editor,pluginName);},configurePlugin:function(editor){this.pageTSconfiguration=this.editorConfiguration.buttons.undo;this.customUndo=true;this.undoQueue=new Array();this.undoPosition=-1;this.undoSteps=25;this.undoTimeout=500;var pluginInformation={version:'2.0',developer:'Stanislas Rolland',developerUrl:'http://www.sjbr.ca',copyrightOwner:'Stanislas Rolland',sponsor:'SJBR',sponsorUrl:'http://www.sjbr.ca',license:'GPL'};this.registerPluginInformation(pluginInformation);var buttonList=this.buttonList,buttonId;for(var i=0;i=this.undoSteps){this.undoQueue.shift();--this.undoPosition;}
if(this.undoPosition<0||this.undoQueue[this.undoPosition].time0){this.takeSnapshot();this.setContent(--this.undoPosition);this.updateButtonsState();}},redo:function(){if(this.undoPosition=this.undoQueue.length-1);break;}}else{try{button.setDisabled(!this.editor._doc.queryCommandEnabled(button.itemId));}catch(e){button.setDisabled(true);}}}else{button.setDisabled(!button.textMode);}},updateButtonsState:function(){var mode=this.getEditorMode(),selectionEmpty=true,ancestors=null;if(mode==='wysiwyg'){selectionEmpty=this.editor._selectionEmpty(this.editor._getSelection());ancestors=this.editor.getAllAncestors();}
var button=this.getButton('Undo');if(button){this.onUpdateToolbar(button,mode,selectionEmpty,ancestors)}
var button=this.getButton('Redo');if(button){this.onUpdateToolbar(button,mode,selectionEmpty,ancestors)}},onButtonPress:function(editor,id){var buttonId=this.translateHotKey(id);buttonId=buttonId?buttonId:id;if(this.getButton(buttonId)&&!this.getButton(buttonId).disabled){if(this.customUndo){this[buttonId.toLowerCase()]();}else{this.editor._doc.execCommand(buttonId,false,null);}}
return false;}});