]> git.mxchange.org Git - friendica.git/blobdiff - library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
updated tinymce to 3.5.11
[friendica.git] / library / tinymce / jscripts / tiny_mce / plugins / bbcode / editor_plugin_src.js
index ed200e702056b02ee3c337dd8d5ba03bc5d64212..3d3a27faa4f006fe7bf87e749a3aa4646d74673a 100644 (file)
@@ -1,88 +1,53 @@
-/**
- * editor_plugin_src.js
- *
- * Copyright 2009, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://tinymce.moxiecode.com/license
- * Contributing: http://tinymce.moxiecode.com/contributing
- */
-
+/**\r
+ * editor_plugin_src.js\r
+ *\r
+ * Copyright 2009, Moxiecode Systems AB\r
+ * Released under LGPL License.\r
+ *\r
+ * License: http://tinymce.moxiecode.com/license\r
+ * Contributing: http://tinymce.moxiecode.com/contributing\r
+ */\r
+\r
 /* Macgirvin Aug-2010 changed from punbb to dfrn dialect */
 
-(function() {
-       tinymce.create('tinymce.plugins.BBCodePlugin', {
-               init : function(ed, url) {
+(function() {\r
+       tinymce.create('tinymce.plugins.BBCodePlugin', {\r
+               init : function(ed, url) {\r
                        var t = this, dialect = ed.getParam('bbcode_dialect', 'dfrn').toLowerCase();
-
-                       ed.onBeforeSetContent.add(function(ed, o) {
-                               o.content = t['_' + dialect + '_bbcode2html'](o.content);
-                       });
-
-                       ed.onPostProcess.add(function(ed, o) {
-                               if (o.set)
-                                       o.content = t['_' + dialect + '_bbcode2html'](o.content);
-
-                               if (o.get)
-                                       o.content = t['_' + dialect + '_html2bbcode'](o.content);
-                       });
-               },
-
-               getInfo : function() {
-                       return {
-                               longname : 'BBCode Plugin',
-                               author : 'Moxiecode Systems AB',
-                               authorurl : 'http://tinymce.moxiecode.com',
-                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',
-                               version : tinymce.majorVersion + "." + tinymce.minorVersion
-                       };
-               },
-
-               // Private methods
-
+\r
+                       ed.onBeforeSetContent.add(function(ed, o) {\r
+                               o.content = t['_' + dialect + '_bbcode2html'](o.content);\r
+                       });\r
+\r
+                       ed.onPostProcess.add(function(ed, o) {\r
+                               if (o.set)\r
+                                       o.content = t['_' + dialect + '_bbcode2html'](o.content);\r
+\r
+                               if (o.get)\r
+                                       o.content = t['_' + dialect + '_html2bbcode'](o.content);\r
+                       });\r
+               },\r
+\r
+               getInfo : function() {\r
+                       return {\r
+                               longname : 'BBCode Plugin',\r
+                               author : 'Moxiecode Systems AB',\r
+                               authorurl : 'http://tinymce.moxiecode.com',\r
+                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',\r
+                               version : tinymce.majorVersion + "." + tinymce.minorVersion\r
+                       };\r
+               },\r
+\r
+               // Private methods\r
+\r
                // HTML -> BBCode in DFRN dialect
                _dfrn_html2bbcode : function(s) {
-                       s = tinymce.trim(s);
-
-                       function rep(re, str) {
-
-
-                               s = s.replace(re,str);
-
-                               //modify code to keep stuff intact within [code][/code] blocks
-                               //Waitman Gobble NO WARRANTY
-
-                               /* This doesn't seem to work well with
-                               [code]line1
-                               line2[/code]
-                               commenting out for now
-                               */
-
-/*
-                               var o = new Array();
-                               var x = s.split("[code]");
-                               var i = 0;
-
-                               var si = "";
-                               si = x.shift();
-                               si = si.replace(re,str);
-                               o.push(si);
-
-                               for (i = 0; i < x.length; i++) {
-                                       var no = new Array();
-                                       var j = x.shift();
-                                       var g = j.split("[/code]");
-                                       no.push(g.shift());
-                                       si = g.shift();
-                                       si = si.replace(re,str);
-                                       no.push(si);
-                                       o.push(no.join("[/code]"));
-                               }
-
-                               s = o.join("[code]");
-*/
-                       };
-
+                       s = tinymce.trim(s);\r
+\r
+                       function rep(re, str) {\r
+                               s = s.replace(re, str);\r
+                       };\r
+\r
 
                        function get(re) {
                                return s.match(re);
                        var codes = get(/<code>(.*?)<\/code>/gi);
                        rep(/<code>(.*?)<\/code>/gi,"[$!$!CODEBLOCK!$!$]");
 
-                       // example: <strong> to [b]
+                       // example: <strong> to [b]\r
                        rep(/<a class=\"bookmark\" href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]");
-                       rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
-                       rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
+                       rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");\r
+                       rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");\r
                        rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
-                       rep(/<font>(.*?)<\/font>/gi,"$1");
+                       rep(/<font>(.*?)<\/font>/gi,"$1");\r
 
                        // Use [^>]* instead of .* to prevent a match against two separate <img> tags
                        rep(/<img[^>]*?width=\"([^>]*?)\"[^>]*?height=\"([^>]*?)\"[^>]*?src=\"([^>]*?)\"[^>]*?\/>/gi,"[img=$1x$2]$3[/img]");
                        rep(/<li>(.*?)<\/li>/gi,'[li]$1[/li]');
 
                        //rep(/<code>(.*?)<\/code>/gi,"[code]$1[/code]");
-                       rep(/<\/(strong|b)>/gi,"[/b]");
-                       rep(/<(strong|b)>/gi,"[b]");
-                       rep(/<\/(em|i)>/gi,"[/i]");
-                       rep(/<(em|i)>/gi,"[i]");
-                       rep(/<\/u>/gi,"[/u]");
-                       rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
-                       rep(/<u>/gi,"[u]");
-                       rep(/<blockquote[^>]*>/gi,"[quote]");
-                       rep(/<\/blockquote>/gi,"[/quote]");
+                       rep(/<\/(strong|b)>/gi,"[/b]");\r
+                       rep(/<(strong|b)>/gi,"[b]");\r
+                       rep(/<\/(em|i)>/gi,"[/i]");\r
+                       rep(/<(em|i)>/gi,"[i]");\r
+                       rep(/<\/u>/gi,"[/u]");\r
+                       rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");\r
+                       rep(/<u>/gi,"[u]");\r
+                       rep(/<blockquote[^>]*>/gi,"[quote]");\r
+                       rep(/<\/blockquote>/gi,"[/quote]");\r
                        rep(/<hr \/>/gi,"[hr]");
                        rep(/<br (.*?)\/>/gi,"\n");
-                       rep(/<br\/>/gi,"\n");
-                       rep(/<br>/gi,"\n");
-                       rep(/<p>/gi,"");
-                       rep(/<\/p>/gi,"\n");
-                       rep(/&nbsp;|\u00a0/gi," ");
-                       rep(/&quot;/gi,"\"");
-                       rep(/&lt;/gi,"<");
-                       rep(/&gt;/gi,">");
-                       rep(/&amp;/gi,"&");
-
+                       rep(/<br \/>/gi,"\n");\r
+                       rep(/<br>/gi,"\n");\r
+                       rep(/<p>/gi,"");\r
+                       rep(/<\/p>/gi,"\n");\r
+                       rep(/&nbsp;|\u00a0/gi," ");\r
+                       rep(/&quot;/gi,"\"");\r
+                       rep(/&lt;/gi,"<");\r
+                       rep(/&gt;/gi,">");\r
+                       rep(/&amp;/gi,"&");\r
+\r
                        // Hack to fix an annoying bug of TinyMCE where block formats don't
                        // work when forced_root_block = ''. So set forced_root_block = 'div'
                        // and then strip out the divs manually
                                }
                        }
 
-                       return s; 
-               },
-
+                       return s; \r
+               },\r
+\r
                // BBCode -> HTML from DFRN dialect
                _dfrn_bbcode2html : function(s) {
-                       s = tinymce.trim(s);
-
-
-            function rep(re, str) {
-
-
-                /*//modify code to keep stuff intact within [code][/code] blocks
-                //Waitman Gobble NO WARRANTY
-
-
-                var o = new Array();
-                var x = s.split("[code]");
-                var i = 0;
-
-                var si = "";
-                si = x.shift();
-                si = si.replace(re,str);
-                o.push(si);
-
-                for (i = 0; i < x.length; i++) {
-                        var no = new Array();
-                        var j = x.shift();
-                        var g = j.split("[/code]");
-                        no.push(g.shift());
-                        si = g.shift();
-                        si = si.replace(re,str);
-                        no.push(si);
-                        o.push(no.join("[/code]"));
-                }
-
-                s = o.join("[code]");*/
-
-                               s = s.replace(re, str);
-
-            };
-
+                       s = tinymce.trim(s);\r
+\r
+                       function rep(re, str) {\r
+                               s = s.replace(re, str);\r
+                       };\r
+\r
 
 
                        function get(re) {
                        var codes = get(/\[code\](.*?)\[\/code\]/gi);
                        rep(/\[code\](.*?)\[\/code\]/gi,"[$!$!CODEBLOCK!$!$]");
 
-                       // example: [b] to <strong>
-                       rep(/\n/gi,"<br />");
-                       rep(/\[b\]/gi,"<strong>");
-                       rep(/\[\/b\]/gi,"</strong>");
-                       rep(/\[i\]/gi,"<em>");
-                       rep(/\[\/i\]/gi,"</em>");
-                       rep(/\[u\]/gi,"<u>");
-                       rep(/\[\/u\]/gi,"</u>");
+                       // example: [b] to <strong>\r
+                       rep(/\n/gi,"<br />");\r
+                       rep(/\[b\]/gi,"<strong>");\r
+                       rep(/\[\/b\]/gi,"</strong>");\r
+                       rep(/\[i\]/gi,"<em>");\r
+                       rep(/\[\/i\]/gi,"</em>");\r
+                       rep(/\[u\]/gi,"<u>");\r
+                       rep(/\[\/u\]/gi,"</u>");\r
                        rep(/\[hr\]/gi,"<hr />");
                        rep(/\[bookmark=([^\]]+)\](.*?)\[\/bookmark\]/gi,"<a class=\"bookmark\" href=\"$1\">$2</a>");
-                       rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
-                       rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
+                       rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");\r
+                       rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");\r
                        rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
-                       rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
-
+                       rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");\r
+\r
                        rep(/\[list\](.*?)\[\/list\]/gi, '<ul class="listbullet" style="list-style-type: circle;">$1</ul>');
                        rep(/\[list=\](.*?)\[\/list\]/gi, '<ul class="listnone" style="list-style-type: none;">$1</ul>');
                        rep(/\[list=1\](.*?)\[\/list\]/gi, '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>');
                                }
                        }
 
-                       return s; 
-               }
-       });
-
-       // Register plugin
-       tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);
-})();
+                       return s; \r
+               }\r
+       });\r
+\r
+       // Register plugin\r
+       tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);\r
+})();
\ No newline at end of file