[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /* 2 YUI 3.17.2 (build 9c3c78e) 3 Copyright 2014 Yahoo! Inc. All rights reserved. 4 Licensed under the BSD License. 5 http://yuilibrary.com/license/ 6 */ 7 8 YUI.add('editor-para-base', function (Y, NAME) { 9 10 11 /** 12 * Base Plugin for Editor to paragraph auto wrapping and correction. 13 * @class Plugin.EditorParaBase 14 * @extends Base 15 * @constructor 16 * @module editor 17 * @submodule editor-para-base 18 */ 19 20 21 var EditorParaBase = function() { 22 EditorParaBase.superclass.constructor.apply(this, arguments); 23 }, HOST = 'host', 24 FIRST_P = '> p', P = 'p', BR = '<br>'; 25 26 27 Y.extend(EditorParaBase, Y.Base, { 28 /** 29 * Resolves the ROOT editor element. 30 * @method _getRoot 31 * @private 32 */ 33 _getRoot: function() { 34 return this.get(HOST).getInstance().EditorSelection.ROOT; 35 }, 36 37 /** 38 * Utility method to create an empty paragraph when the document is empty. 39 * @private 40 * @method _fixFirstPara 41 */ 42 _fixFirstPara: function() { 43 var host = this.get(HOST), inst = host.getInstance(), sel, n, 44 root = this._getRoot(), 45 html = root.getHTML(), 46 col = ((html.length) ? true : false); 47 48 if (html === BR) { 49 html = ''; 50 col = false; 51 } 52 53 root.setHTML('<' + P + '>' + html + inst.EditorSelection.CURSOR + '</' + P + '>'); 54 55 n = root.one(FIRST_P); 56 sel = new inst.EditorSelection(); 57 58 sel.selectNode(n, true, col); 59 }, 60 /** 61 * Performs a block element filter when the Editor is first ready 62 * @private 63 * @method _afterEditorReady 64 */ 65 _afterEditorReady: function() { 66 var host = this.get(HOST), inst = host.getInstance(), btag; 67 if (inst) { 68 inst.EditorSelection.filterBlocks(); 69 btag = inst.EditorSelection.DEFAULT_BLOCK_TAG; 70 FIRST_P = '> ' + btag; 71 P = btag; 72 } 73 }, 74 /** 75 * Performs a block element filter when the Editor after an content change 76 * @private 77 * @method _afterContentChange 78 */ 79 _afterContentChange: function() { 80 var host = this.get(HOST), inst = host.getInstance(); 81 if (inst && inst.EditorSelection) { 82 inst.EditorSelection.filterBlocks(); 83 } 84 }, 85 /** 86 * Performs block/paste filtering after paste. 87 * @private 88 * @method _afterPaste 89 */ 90 _afterPaste: function() { 91 var host = this.get(HOST), inst = host.getInstance(); 92 93 Y.later(50, host, function() { 94 inst.EditorSelection.filterBlocks(); 95 }); 96 97 }, 98 initializer: function() { 99 var host = this.get(HOST); 100 if (host.editorBR) { 101 Y.error('Can not plug EditorPara and EditorBR at the same time.'); 102 return; 103 } 104 105 host.after('ready', Y.bind(this._afterEditorReady, this)); 106 host.after('contentChange', Y.bind(this._afterContentChange, this)); 107 if (Y.Env.webkit) { 108 host.after('dom:paste', Y.bind(this._afterPaste, this)); 109 } 110 } 111 }, { 112 /** 113 * editorPara 114 * @static 115 * @property NAME 116 */ 117 NAME: 'editorParaBase', 118 /** 119 * editorPara 120 * @static 121 * @property NS 122 */ 123 NS: 'editorParaBase', 124 ATTRS: { 125 host: { 126 value: false 127 } 128 } 129 }); 130 131 Y.namespace('Plugin'); 132 133 Y.Plugin.EditorParaBase = EditorParaBase; 134 135 136 137 138 }, '3.17.2', {"requires": ["editor-base"]});
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |