3
Copyright 2012 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
7
YUI.add('editor-para-ie', function(Y) {
11
* Extends EditorParaBase with IE support
12
* @class Plugin.EditorParaIE
13
* @extends Plugin.EditorParaBase
16
* @submodule editor-para-ie
20
var EditorParaIE = function() {
21
EditorParaIE.superclass.constructor.apply(this, arguments);
22
}, HOST = 'host', BODY = 'body', NODE_CHANGE = 'nodeChange', PARENT_NODE = 'parentNode',
23
FIRST_P = BODY + ' > p', P = 'p', BR = '<br>', FC = 'firstChild', LI = 'li';
26
Y.extend(EditorParaIE, Y.Plugin.EditorParaBase, {
28
* nodeChange handler to handle fixing an empty document.
30
* @method _onNodeChange
32
_onNodeChange: function(e) {
33
var host = this.get(HOST), inst = host.getInstance(),
34
html, txt, par , d, sel, btag = inst.EditorSelection.DEFAULT_BLOCK_TAG,
35
inHTML, txt2, childs, aNode, index, node2, top, n, sib,
36
ps, br, item, p, imgs, t, LAST_CHILD = ':last-child';
38
switch (e.changedType) {
40
var para = ((this._lastPara) ? this._lastPara : e.changedNode),
41
b = para.one('br.yui-cursor');
44
delete this._lastPara;
48
if (b.previous() || b.next()) {
54
if (!para.test(btag)) {
55
var para2 = para.ancestor(btag);
61
if (para.test(btag)) {
62
var prev = para.previous(), lc, lc2, found = false;
64
lc = prev.one(LAST_CHILD);
67
lc2 = lc.one(LAST_CHILD);
78
host.copyStyles(lc, para);
84
if (e.changedNode.test('br')) {
85
e.changedNode.remove();
86
} else if (e.changedNode.test('p, span')) {
87
var b = e.changedNode.one('br.yui-cursor');
95
initializer: function() {
96
var host = this.get(HOST);
98
Y.error('Can not plug EditorPara and EditorBR at the same time.');
102
host.on(NODE_CHANGE, Y.bind(this._onNodeChange, this));
124
Y.namespace('Plugin');
126
Y.Plugin.EditorPara = EditorParaIE;
131
}, '3.5.1' ,{skinnable:false, requires:['editor-para-base']});