fix clipboard unbind; add history events

This commit is contained in:
rlx 2013-08-06 18:59:15 +00:00
parent da7b637948
commit bcb7e3f720
2 changed files with 16 additions and 2 deletions

View file

@ -64,7 +64,7 @@ Ox.Clipboard = function() {
return clipboard.type;
},
unbindEvent: function() {
$element && $element.bindEvent.apply(this, arguments);
$element && $element.unbindEvent.apply(this, arguments);
}
};
};

View file

@ -9,7 +9,8 @@ Ox.History = function(options) {
}, options || {});
var history = [],
position = 0;
position = 0,
$element;
return {
_print: function() {
@ -19,11 +20,19 @@ Ox.History = function(options) {
items = Ox.makeArray(items);
history = history.slice(0, position).concat(items);
position += items.length;
$element && $element.triggerEvent('add');
return history.length;
},
bindEvent: function() {
if (!$element) {
$element = Ox.Element();
}
$element.bindEvent.apply(this, arguments);
},
clear: function() {
history = [];
position = 0;
$element && $element.triggerEvent('clear');
return history.length;
},
items: function() {
@ -31,6 +40,7 @@ Ox.History = function(options) {
},
redo: function() {
if (position < history.length) {
$element && $element.triggerEvent('redo');
return history[position++];
}
},
@ -41,9 +51,13 @@ Ox.History = function(options) {
},
remove: function(test) {
},
unbindEvent: function() {
$element && $element.unbindEvent.apply(this, arguments);
},
undo: function() {
if (position > 0) {
$element && $element.triggerEvent('undo');
return history[--position];
}
},