~andreserl/maas/packaging_precise_rebase

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/editor-para-ie/editor-para-ie-debug.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-20 18:12:30 UTC
  • mfrom: (145.2.22 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130320181230-6l5guc0nhlv2z4p7
Re-base againts latest quantal released branch towards SRU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('editor-para-ie', function(Y) {
 
8
 
 
9
 
 
10
    /**
 
11
     * Extends EditorParaBase with IE support
 
12
     * @class Plugin.EditorParaIE
 
13
     * @extends Plugin.EditorParaBase
 
14
     * @constructor
 
15
     * @module editor
 
16
     * @submodule editor-para-ie
 
17
     */
 
18
 
 
19
 
 
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';
 
24
 
 
25
 
 
26
    Y.extend(EditorParaIE, Y.Plugin.EditorParaBase, {
 
27
        /**
 
28
        * nodeChange handler to handle fixing an empty document.
 
29
        * @private
 
30
        * @method _onNodeChange
 
31
        */
 
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';
 
37
 
 
38
            switch (e.changedType) {
 
39
                case 'enter-up':
 
40
                    var para = ((this._lastPara) ? this._lastPara : e.changedNode),
 
41
                        b = para.one('br.yui-cursor');
 
42
 
 
43
                    if (this._lastPara) {
 
44
                        delete this._lastPara;
 
45
                    }
 
46
 
 
47
                    if (b) {
 
48
                        if (b.previous() || b.next()) {
 
49
                            if (b.ancestor(P)) {
 
50
                                b.remove();
 
51
                            }
 
52
                        }
 
53
                    }
 
54
                    if (!para.test(btag)) {
 
55
                        var para2 = para.ancestor(btag);
 
56
                        if (para2) {
 
57
                            para = para2;
 
58
                            para2 = null;
 
59
                        }
 
60
                    }
 
61
                    if (para.test(btag)) {
 
62
                        var prev = para.previous(), lc, lc2, found = false;
 
63
                        if (prev) {
 
64
                            lc = prev.one(LAST_CHILD);
 
65
                            while (!found) {
 
66
                                if (lc) {
 
67
                                    lc2 = lc.one(LAST_CHILD);
 
68
                                    if (lc2) {
 
69
                                        lc = lc2;
 
70
                                    } else {
 
71
                                        found = true;
 
72
                                    }
 
73
                                } else {
 
74
                                    found = true;
 
75
                                }
 
76
                            }
 
77
                            if (lc) {
 
78
                                host.copyStyles(lc, para);
 
79
                            }
 
80
                        }
 
81
                    }
 
82
                    break;
 
83
                case 'enter':
 
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');
 
88
                        if (b) {
 
89
                            b.remove();
 
90
                        }
 
91
                    }
 
92
                    break;
 
93
            }
 
94
        },
 
95
        initializer: function() {
 
96
            var host = this.get(HOST);
 
97
            if (host.editorBR) {
 
98
                Y.error('Can not plug EditorPara and EditorBR at the same time.');
 
99
                return;
 
100
            }
 
101
 
 
102
            host.on(NODE_CHANGE, Y.bind(this._onNodeChange, this));
 
103
        }
 
104
    }, {
 
105
        /**
 
106
        * editorPara
 
107
        * @static
 
108
        * @property NAME
 
109
        */
 
110
        NAME: 'editorPara',
 
111
        /**
 
112
        * editorPara
 
113
        * @static
 
114
        * @property NS
 
115
        */
 
116
        NS: 'editorPara',
 
117
        ATTRS: {
 
118
            host: {
 
119
                value: false
 
120
            }
 
121
        }
 
122
    });
 
123
    
 
124
    Y.namespace('Plugin');
 
125
    
 
126
    Y.Plugin.EditorPara = EditorParaIE;
 
127
 
 
128
 
 
129
 
 
130
 
 
131
}, '3.5.1' ,{skinnable:false, requires:['editor-para-base']});