From bcb7e3f7202bd042f87174e394f23af69cb61190 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Tue, 6 Aug 2013 18:59:15 +0000 Subject: [PATCH] fix clipboard unbind; add history events --- source/Ox.UI/js/Core/Clipboard.js | 2 +- source/Ox.UI/js/Core/History.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/Ox.UI/js/Core/Clipboard.js b/source/Ox.UI/js/Core/Clipboard.js index 0eed8a11..2b616b3f 100644 --- a/source/Ox.UI/js/Core/Clipboard.js +++ b/source/Ox.UI/js/Core/Clipboard.js @@ -64,7 +64,7 @@ Ox.Clipboard = function() { return clipboard.type; }, unbindEvent: function() { - $element && $element.bindEvent.apply(this, arguments); + $element && $element.unbindEvent.apply(this, arguments); } }; }; diff --git a/source/Ox.UI/js/Core/History.js b/source/Ox.UI/js/Core/History.js index 61fb93f9..cbc21d07 100644 --- a/source/Ox.UI/js/Core/History.js +++ b/source/Ox.UI/js/Core/History.js @@ -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]; } },