editor-br-debug.js revision 33a04233c7a32ec1ac1b5d5991097fe0b099e87b
/**
* Plugin for Editor to normalize BR's.
* @class Plugin.EditorBR
* @extends Base
* @constructor
* @module editor
* @submodule editor-br
*/
var EditorBR = function() {
/**
* Frame keyDown handler that normalizes BR's when pressing ENTER.
* @private
* @method _onKeyDown
*/
_onKeyDown: function(e) {
if (e.stopped) {
e.halt();
return;
}
if (e.keyCode == 13) {
last = '';
if (sel) {
e.halt();
}
}
e.halt();
}
}
}
}
},
/**
* Adds listeners for keydown in IE and Webkit. Also fires insertbeonreturn for supporting browsers.
* @private
* @method _afterEditorReady
*/
_afterEditorReady: function() {
try {
} catch (bre) {}
}
},
/**
* Adds a nodeChange listener only for FF, in the event of a backspace or delete, it creates an empy textNode
* inserts it into the DOM after the e.changedNode, then removes it. Causing FF to redraw the content.
* @private
* @method _onNodeChange
* @param {Event} e The nodeChange event.
*/
_onNodeChange: function(e) {
switch (e.changedType) {
case 'backspace-up':
case 'backspace-down':
case 'delete-up':
/*
* This forced FF to redraw the content on backspace.
* On some occasions FF will leave a cursor residue after content has been deleted.
* Dropping in the empty textnode and then removing it causes FF to redraw and
* remove the "ghost cursors"
*/
var d = e.changedNode;
d.appendChild(t);
d.removeChild(t);
break;
}
},
initializer: function() {
if (host.editorPara) {
Y.error('Can not plug EditorBR and EditorPara at the same time.');
return;
}
}
}
}, {
/**
* editorBR
* @static
* @property NAME
*/
NAME: 'editorBR',
/**
* editorBR
* @static
* @property NS
*/
NS: 'editorBR',
ATTRS: {
host: {
value: false
}
}
});
Y.namespace('Plugin');