Skip to content

Commit

Permalink
added stopTracking to the api; minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
delambo committed Nov 13, 2012
1 parent db21419 commit a18ceac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/dom.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ dom.bind = function(element, event, callback) {
return jQuery(element).bind(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) { dom.attr = function (elements, key, val) {
if(val) if(val)
return jQuery(elements).attr(key, val); return jQuery(elements).attr(key, val);
Expand Down
21 changes: 18 additions & 3 deletions src/ice.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ defaults = {
noTrack: '.ice-no-track', noTrack: '.ice-no-track',


// Selector for elements to avoid - move range before or after - similar handling to deletes // Selector for elements to avoid - move range before or after - similar handling to deletes
avoid: '.ice-avoid', avoid: '.ice-avoid'
}; };


InlineChangeEditor = function(options) { InlineChangeEditor = function(options) {
Expand Down Expand Up @@ -96,7 +96,7 @@ InlineChangeEditor.prototype = {
// If we are handling events setup the delegate to handle various events on `this.element`. // If we are handling events setup the delegate to handle various events on `this.element`.
if(this.handleEvents) { if(this.handleEvents) {
var self = this; 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); return self.handleEvent(e);
}); });
} }
Expand All @@ -109,6 +109,22 @@ InlineChangeEditor.prototype = {
return this; return this;
}, },


/**
* 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. * Initializes the `env` object with pointers to key objects of the page.
*/ */
Expand Down Expand Up @@ -760,7 +776,6 @@ InlineChangeEditor.prototype = {
betweenBlocks = new Array(), betweenBlocks = new Array(),
eln = elements.length; eln = elements.length;


var eln = elements.length;
for (var i = 0; i < eln; i++) { for (var i = 0; i < eln; i++) {
var elem = elements[i]; var elem = elements[i];


Expand Down

0 comments on commit a18ceac

Please sign in to comment.