annotate static/js/tiny_mce/plugins/visualchars/editor_plugin_src.js @ 926:22ed8451e163

Update debug toolbar options for newer version. For Django 1.7.7 upgrade.
author Brian Neal <bgneal@gmail.com>
date Sun, 12 Apr 2015 21:19:22 -0500
parents 6c182ceb7147
children
rev   line source
bgneal@312 1 /**
bgneal@312 2 * editor_plugin_src.js
bgneal@312 3 *
bgneal@312 4 * Copyright 2009, Moxiecode Systems AB
bgneal@312 5 * Released under LGPL License.
bgneal@312 6 *
bgneal@312 7 * License: http://tinymce.moxiecode.com/license
bgneal@312 8 * Contributing: http://tinymce.moxiecode.com/contributing
bgneal@312 9 */
bgneal@312 10
bgneal@312 11 (function() {
bgneal@312 12 tinymce.create('tinymce.plugins.VisualChars', {
bgneal@312 13 init : function(ed, url) {
bgneal@312 14 var t = this;
bgneal@312 15
bgneal@312 16 t.editor = ed;
bgneal@312 17
bgneal@312 18 // Register commands
bgneal@312 19 ed.addCommand('mceVisualChars', t._toggleVisualChars, t);
bgneal@312 20
bgneal@312 21 // Register buttons
bgneal@312 22 ed.addButton('visualchars', {title : 'visualchars.desc', cmd : 'mceVisualChars'});
bgneal@312 23
bgneal@312 24 ed.onBeforeGetContent.add(function(ed, o) {
bgneal@312 25 if (t.state && o.format != 'raw' && !o.draft) {
bgneal@312 26 t.state = true;
bgneal@312 27 t._toggleVisualChars(false);
bgneal@312 28 }
bgneal@312 29 });
bgneal@312 30 },
bgneal@312 31
bgneal@312 32 getInfo : function() {
bgneal@312 33 return {
bgneal@312 34 longname : 'Visual characters',
bgneal@312 35 author : 'Moxiecode Systems AB',
bgneal@312 36 authorurl : 'http://tinymce.moxiecode.com',
bgneal@312 37 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualchars',
bgneal@312 38 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@312 39 };
bgneal@312 40 },
bgneal@312 41
bgneal@312 42 // Private methods
bgneal@312 43
bgneal@312 44 _toggleVisualChars : function(bookmark) {
bgneal@312 45 var t = this, ed = t.editor, nl, i, h, d = ed.getDoc(), b = ed.getBody(), nv, s = ed.selection, bo, div, bm;
bgneal@312 46
bgneal@312 47 t.state = !t.state;
bgneal@312 48 ed.controlManager.setActive('visualchars', t.state);
bgneal@312 49
bgneal@312 50 if (bookmark)
bgneal@312 51 bm = s.getBookmark();
bgneal@312 52
bgneal@312 53 if (t.state) {
bgneal@312 54 nl = [];
bgneal@312 55 tinymce.walk(b, function(n) {
bgneal@312 56 if (n.nodeType == 3 && n.nodeValue && n.nodeValue.indexOf('\u00a0') != -1)
bgneal@312 57 nl.push(n);
bgneal@312 58 }, 'childNodes');
bgneal@312 59
bgneal@312 60 for (i = 0; i < nl.length; i++) {
bgneal@312 61 nv = nl[i].nodeValue;
bgneal@442 62 nv = nv.replace(/(\u00a0)/g, '<span data-mce-bogus="1" class="mceItemHidden mceItemNbsp">$1</span>');
bgneal@312 63
bgneal@312 64 div = ed.dom.create('div', null, nv);
bgneal@312 65 while (node = div.lastChild)
bgneal@312 66 ed.dom.insertAfter(node, nl[i]);
bgneal@312 67
bgneal@312 68 ed.dom.remove(nl[i]);
bgneal@312 69 }
bgneal@312 70 } else {
bgneal@312 71 nl = ed.dom.select('span.mceItemNbsp', b);
bgneal@312 72
bgneal@312 73 for (i = nl.length - 1; i >= 0; i--)
bgneal@312 74 ed.dom.remove(nl[i], 1);
bgneal@312 75 }
bgneal@312 76
bgneal@312 77 s.moveToBookmark(bm);
bgneal@312 78 }
bgneal@312 79 });
bgneal@312 80
bgneal@312 81 // Register plugin
bgneal@312 82 tinymce.PluginManager.add('visualchars', tinymce.plugins.VisualChars);
bgneal@312 83 })();