~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to lib/yuilib/3.9.1/build/editor-para-ie/editor-para-ie.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

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