diff options
Diffstat (limited to 'public/javascripts/tiny_mce/plugins/visualchars')
| -rwxr-xr-x | public/javascripts/tiny_mce/plugins/visualchars/editor_plugin.js | 1 | ||||
| -rwxr-xr-x | public/javascripts/tiny_mce/plugins/visualchars/editor_plugin_src.js | 73 |
2 files changed, 74 insertions, 0 deletions
diff --git a/public/javascripts/tiny_mce/plugins/visualchars/editor_plugin.js b/public/javascripts/tiny_mce/plugins/visualchars/editor_plugin.js new file mode 100755 index 0000000..e1e4238 --- /dev/null +++ b/public/javascripts/tiny_mce/plugins/visualchars/editor_plugin.js | |||
| @@ -0,0 +1 @@ | |||
| (function(){tinymce.create('tinymce.plugins.VisualChars',{init:function(ed,url){var t=this;t.editor=ed;ed.addCommand('mceVisualChars',t._toggleVisualChars,t);ed.addButton('visualchars',{title:'visualchars.desc',cmd:'mceVisualChars'});ed.onBeforeGetContent.add(function(ed,o){if(t.state){t.state=true;t._toggleVisualChars();}});},getInfo:function(){return{longname:'Visual characters',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualchars',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_toggleVisualChars:function(){var t=this,ed=t.editor,nl,i,h,d=ed.getDoc(),b=ed.getBody(),nv,s=ed.selection,bo;t.state=!t.state;ed.controlManager.setActive('visualchars',t.state);if(t.state){nl=[];tinymce.walk(b,function(n){if(n.nodeType==3&&n.nodeValue&&n.nodeValue.indexOf('\u00a0')!=-1)nl.push(n);},'childNodes');for(i=0;i<nl.length;i++){nv=nl[i].nodeValue;nv=nv.replace(/(\u00a0+)/g,'<span class="mceItemHidden mceVisualNbsp">$1</span>');nv=nv.replace(/\u00a0/g,'\u00b7');ed.dom.setOuterHTML(nl[i],nv,d);}}else{nl=tinymce.grep(ed.dom.select('span',b),function(n){return ed.dom.hasClass(n,'mceVisualNbsp');});for(i=0;i<nl.length;i++)ed.dom.setOuterHTML(nl[i],nl[i].innerHTML.replace(/(·|\u00b7)/g,' '),d);}}});tinymce.PluginManager.add('visualchars',tinymce.plugins.VisualChars);})(); \ No newline at end of file | |||
diff --git a/public/javascripts/tiny_mce/plugins/visualchars/editor_plugin_src.js b/public/javascripts/tiny_mce/plugins/visualchars/editor_plugin_src.js new file mode 100755 index 0000000..02ec4e6 --- /dev/null +++ b/public/javascripts/tiny_mce/plugins/visualchars/editor_plugin_src.js | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | /** | ||
| 2 | * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ | ||
| 3 | * | ||
| 4 | * @author Moxiecode | ||
| 5 | * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. | ||
| 6 | */ | ||
| 7 | |||
| 8 | (function() { | ||
| 9 | tinymce.create('tinymce.plugins.VisualChars', { | ||
| 10 | init : function(ed, url) { | ||
| 11 | var t = this; | ||
| 12 | |||
| 13 | t.editor = ed; | ||
| 14 | |||
| 15 | // Register commands | ||
| 16 | ed.addCommand('mceVisualChars', t._toggleVisualChars, t); | ||
| 17 | |||
| 18 | // Register buttons | ||
| 19 | ed.addButton('visualchars', {title : 'visualchars.desc', cmd : 'mceVisualChars'}); | ||
| 20 | |||
| 21 | ed.onBeforeGetContent.add(function(ed, o) { | ||
| 22 | if (t.state) { | ||
| 23 | t.state = true; | ||
| 24 | t._toggleVisualChars(); | ||
| 25 | } | ||
| 26 | }); | ||
| 27 | }, | ||
| 28 | |||
| 29 | getInfo : function() { | ||
| 30 | return { | ||
| 31 | longname : 'Visual characters', | ||
| 32 | author : 'Moxiecode Systems AB', | ||
| 33 | authorurl : 'http://tinymce.moxiecode.com', | ||
| 34 | infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualchars', | ||
| 35 | version : tinymce.majorVersion + "." + tinymce.minorVersion | ||
| 36 | }; | ||
| 37 | }, | ||
| 38 | |||
| 39 | // Private methods | ||
| 40 | |||
| 41 | _toggleVisualChars : function() { | ||
| 42 | var t = this, ed = t.editor, nl, i, h, d = ed.getDoc(), b = ed.getBody(), nv, s = ed.selection, bo; | ||
| 43 | |||
| 44 | t.state = !t.state; | ||
| 45 | ed.controlManager.setActive('visualchars', t.state); | ||
| 46 | |||
| 47 | if (t.state) { | ||
| 48 | nl = []; | ||
| 49 | tinymce.walk(b, function(n) { | ||
| 50 | if (n.nodeType == 3 && n.nodeValue && n.nodeValue.indexOf('\u00a0') != -1) | ||
| 51 | nl.push(n); | ||
| 52 | }, 'childNodes'); | ||
| 53 | |||
| 54 | for (i=0; i<nl.length; i++) { | ||
| 55 | nv = nl[i].nodeValue; | ||
| 56 | nv = nv.replace(/(\u00a0+)/g, '<span class="mceItemHidden mceVisualNbsp">$1</span>'); | ||
| 57 | nv = nv.replace(/\u00a0/g, '\u00b7'); | ||
| 58 | ed.dom.setOuterHTML(nl[i], nv, d); | ||
| 59 | } | ||
| 60 | } else { | ||
| 61 | nl = tinymce.grep(ed.dom.select('span', b), function(n) { | ||
| 62 | return ed.dom.hasClass(n, 'mceVisualNbsp'); | ||
| 63 | }); | ||
| 64 | |||
| 65 | for (i=0; i<nl.length; i++) | ||
| 66 | ed.dom.setOuterHTML(nl[i], nl[i].innerHTML.replace(/(·|\u00b7)/g, ' '), d); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | }); | ||
| 70 | |||
| 71 | // Register plugin | ||
| 72 | tinymce.PluginManager.add('visualchars', tinymce.plugins.VisualChars); | ||
| 73 | })(); \ No newline at end of file | ||
