Permalink
Browse files

added stopTracking to the api; minor fixes

  • Loading branch information...
1 parent db21419 commit a18ceacc20d67cbef74ae52d5120dffeb80157f5 @delambo delambo committed Nov 13, 2012
Showing with 22 additions and 3 deletions.
  1. +4 −0 src/dom.js
  2. +18 −3 src/ice.js
View
4 src/dom.js
@@ -304,6 +304,10 @@ dom.bind = function(element, event, callback) {
return jQuery(element).bind(event, callback);
};
+dom.unbind = function(element, event, callback) {
+ return jQuery(element).unbind(event, callback);
+};
+
dom.attr = function (elements, key, val) {
if(val)
return jQuery(elements).attr(key, val);
View
21 src/ice.js
@@ -46,7 +46,7 @@ defaults = {
noTrack: '.ice-no-track',
// Selector for elements to avoid - move range before or after - similar handling to deletes
- avoid: '.ice-avoid',
+ avoid: '.ice-avoid'
};
InlineChangeEditor = function(options) {
@@ -96,7 +96,7 @@ InlineChangeEditor.prototype = {
// If we are handling events setup the delegate to handle various events on `this.element`.
if(this.handleEvents) {
var self = this;
- ice.dom.bind(self.element, 'keyup keydown keypress mousedown mouseup', function(e) {
+ ice.dom.bind(self.element, 'keyup.ice keydown.ice keypress.ice mousedown.ice mouseup.ice', function(e) {
return self.handleEvent(e);
});
}
@@ -110,6 +110,22 @@ InlineChangeEditor.prototype = {
},
/**
+ * Removes contenteditability and stops event handling.
+ */
+ stopTracking: function() {
+ this.element.setAttribute('contentEditable', !this.contentEditable);
+
+ // If we are handling events setup the delegate to handle various events on `this.element`.
+ if(this.handleEvents) {
+ var self = this;
+ ice.dom.unbind(self.element, 'keyup.ice keydown.ice keypress.ice mousedown.ice mouseup.ice');
+ }
+
+ this.pluginsManager.fireDisabled(this.element);
+ return this;
+ },
+
+ /**
* Initializes the `env` object with pointers to key objects of the page.
*/
initializeEnvironment: function() {
@@ -760,7 +776,6 @@ InlineChangeEditor.prototype = {
betweenBlocks = new Array(),
eln = elements.length;
- var eln = elements.length;
for (var i = 0; i < eln; i++) {
var elem = elements[i];

0 comments on commit a18ceac

Please sign in to comment.