mise a jour pour mtweb.0.9.0
[mw_pages] / app / out / default / tiny_mce / plugins / wordcount / editor_plugin_src.js
diff --git a/app/out/default/tiny_mce/plugins/wordcount/editor_plugin_src.js b/app/out/default/tiny_mce/plugins/wordcount/editor_plugin_src.js
new file mode 100644 (file)
index 0000000..5cb92fa
--- /dev/null
@@ -0,0 +1,98 @@
+/**\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
+(function() {\r
+    tinymce.create('tinymce.plugins.WordCount', {\r
+               block : 0,\r
+               id : null,\r
+               countre : null,\r
+               cleanre : null,\r
+\r
+               init : function(ed, url) {\r
+                       var t = this, last = 0;\r
+\r
+                       t.countre = ed.getParam('wordcount_countregex', /\S\s+/g);\r
+                       t.cleanre = ed.getParam('wordcount_cleanregex', /[0-9.(),;:!?%#$¿'"_+=\\\/-]*/g);\r
+                       t.id = ed.id + '-word-count';\r
+\r
+                       ed.onPostRender.add(function(ed, cm) {\r
+                               var row, id;\r
+\r
+                               // Add it to the specified id or the theme advanced path\r
+                               id = ed.getParam('wordcount_target_id');\r
+                               if (!id) {\r
+                                       row = tinymce.DOM.get(ed.id + '_path_row');\r
+\r
+                                       if (row)\r
+                                               tinymce.DOM.add(row.parentNode, 'div', {'style': 'float: right'}, ed.getLang('wordcount.words', 'Words: ') + '<span id="' + t.id + '">0</span>');\r
+                               } else\r
+                                       tinymce.DOM.add(id, 'span', {}, '<span id="' + t.id + '">0</span>');\r
+                       });\r
+\r
+            ed.onInit.add(function(ed) {\r
+                               ed.selection.onSetContent.add(function() {\r
+                                       t._count(ed);\r
+                               });\r
+\r
+                               t._count(ed);\r
+                       });\r
+\r
+                       ed.onSetContent.add(function(ed) {\r
+                               t._count(ed);\r
+                       });\r
+\r
+                       ed.onKeyUp.add(function(ed, e) {\r
+                               if (e.keyCode == last)\r
+                                       return;\r
+\r
+                               if (13 == e.keyCode || 8 == last || 46 == last)\r
+                                       t._count(ed);\r
+\r
+                               last = e.keyCode;\r
+                       });\r
+               },\r
+\r
+               _count : function(ed) {\r
+                       var t = this, tc = 0;\r
+\r
+                       // Keep multiple calls from happening at the same time\r
+                       if (t.block)\r
+                               return;\r
+\r
+                       t.block = 1;\r
+\r
+                       setTimeout(function() {\r
+                               var tx = ed.getContent({format : 'raw'});\r
+\r
+                               if (tx) {\r
+                                       tx = tx.replace(/<.[^<>]*?>/g, ' ').replace(/&nbsp;|&#160;/gi, ' '); // remove html tags and space chars\r
+                                       tx = tx.replace(t.cleanre, ''); // remove numbers and punctuation\r
+                                       tx.replace(t.countre, function() {tc++;}); // count the words\r
+                               }\r
+\r
+                               tinymce.DOM.setHTML(t.id, tc.toString());\r
+\r
+                               setTimeout(function() {t.block = 0;}, 2000);\r
+                       }, 1);\r
+               },\r
+\r
+        getInfo: function() {\r
+                       return {\r
+                               longname : 'Word Count plugin',\r
+                               author : 'Moxiecode Systems AB',\r
+                               authorurl : 'http://tinymce.moxiecode.com',\r
+                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/wordcount',\r
+                               version : tinymce.majorVersion + "." + tinymce.minorVersion\r
+                       };\r
+        }\r
+    });\r
+\r
+    tinymce.PluginManager.add('wordcount', tinymce.plugins.WordCount);\r
+})();\r