TinyMCE_UndoRedo.class.js
Summary
No overview generated for 'TinyMCE_UndoRedo.class.js'
function TinyMCE_UndoRedo(inst) {
this.instance = inst;
this.undoLevels = new Array();
this.undoIndex = 0;
this.typingUndoIndex = -1;
this.undoRedo = true;
};
TinyMCE_UndoRedo.prototype = {
add : function(l) {
var b;
if (l) {
this.undoLevels[this.undoLevels.length] = l;
return true;
}
var inst = this.instance;
if (this.typingUndoIndex != -1) {
this.undoIndex = this.typingUndoIndex;
}
var newHTML = tinyMCE.trim(inst.getBody().innerHTML);
if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) {
tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst);
var customUndoLevels = tinyMCE.settings['custom_undo_redo_levels'];
if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) {
for (var i=0; i<this.undoLevels.length-1; i++) {
this.undoLevels[i] = this.undoLevels[i+1];
}
this.undoLevels.length--;
this.undoIndex--;
}
b = inst.undoBookmark;
if (!b)
b = inst.selection.getBookmark();
this.undoIndex++;
this.undoLevels[this.undoIndex] = {
content : newHTML,
bookmark : b
};
this.undoLevels.length = this.undoIndex + 1;
return true;
}
return false;
},
undo : function() {
var inst = this.instance;
if (this.undoIndex > 0) {
this.undoIndex--;
tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
inst.repaint();
if (inst.settings.custom_undo_redo_restore_selection)
inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
}
},
redo : function() {
var inst = this.instance;
tinyMCE.execCommand("mceEndTyping");
if (this.undoIndex < (this.undoLevels.length-1)) {
this.undoIndex++;
tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
inst.repaint();
if (inst.settings.custom_undo_redo_restore_selection)
inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
}
tinyMCE.triggerNodeChange();
}
};
Documentation generated by
JSDoc on Fri Feb 24 13:38:20 2006