A tumblelog CMS built on AJAX, PHP and MySQL.

editor_plugin_src.js 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /**
  2. * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $
  3. *
  4. * @author Moxiecode
  5. * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
  6. */
  7. tinyMCE.importPluginLanguagePack('devkit');
  8. var TinyMCE_DevKitPlugin = {
  9. _logFilter : '\\[(importCSS|execCommand|execInstanceCommand|debug)\\]',
  10. _logPadding : '',
  11. _startTime : null,
  12. _benchMark : false,
  13. _winLoaded : false,
  14. _isDebugEvents : false,
  15. getInfo : function() {
  16. return {
  17. longname : 'Development Kit',
  18. author : 'Moxiecode Systems AB',
  19. authorurl : 'http://tinymce.moxiecode.com',
  20. infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/devkit',
  21. version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
  22. };
  23. },
  24. initInstance : function(inst) {
  25. this._setup();
  26. },
  27. _setup : function() {
  28. if (this._loaded)
  29. return;
  30. this._loaded = true;
  31. // Register a document reference for more easy access in the FF DOM inspector
  32. document.___TinyMCE = tinyMCE;
  33. // Setup devkit by settings
  34. this._logFilter = tinyMCE.getParam('devkit_log_filter', this._logFilter);
  35. this._benchMark = tinyMCE.getParam('devkit_bench_mark', false);
  36. var ifr = document.createElement('iframe');
  37. ifr.setAttribute("id", "devkit");
  38. ifr.setAttribute("frameBorder", "0");
  39. ifr.setAttribute("src", tinyMCE.baseURL + '/plugins/devkit/devkit.htm');
  40. document.body.appendChild(ifr);
  41. // Workaround for strange IE reload bug
  42. //if (tinyMCE.isRealIE)
  43. // document.getElementById('devkit').outerHTML = document.getElementById('devkit').outerHTML;
  44. tinyMCE.importCSS(document, tinyMCE.baseURL + '/plugins/devkit/css/devkit_ui.css');
  45. },
  46. _start : function() {
  47. this._logPadding += '\u00a0';
  48. return new Date().getTime();
  49. },
  50. _end : function(st) {
  51. if (this._logPadding.length > 0)
  52. this._logPadding = this._logPadding.substring(0, this._logPadding.length - 1);
  53. if (this._benchMark)
  54. this._log("benchmark", "Execution time: " + (new Date().getTime() - st));
  55. },
  56. _log : function(t) {
  57. var m, a, i, e = document.getElementById('devkit'), now = new Date().getTime();
  58. if (!this._startTime)
  59. this._startTime = now;
  60. m = (this._logPadding.length > 1 ? this._logPadding : '') + '[' + (now - this._startTime) + '] [' + t + '] ';
  61. a = this._log.arguments;
  62. for (i=1; i<a.length; i++) {
  63. if (typeof(a[i]) == 'undefined')
  64. continue;
  65. if (i > 1)
  66. m += ', ';
  67. m += a[i];
  68. }
  69. if (!new RegExp(this._logFilter, 'gi').test(m)) {
  70. if (this._logPadding.length > 0)
  71. this._logPadding = this._logPadding.substring(0, this._logPadding.length - 1);
  72. return;
  73. }
  74. if (!this._winLoaded)
  75. tinyMCE.log[tinyMCE.log.length] = m;
  76. else
  77. e.contentWindow.debug(m);
  78. },
  79. _debugEvents : function(s) {
  80. var i, ld, inst, n, ev = ['CheckboxStateChange','DOMAttrModified','DOMMenuItemActive',
  81. 'DOMMenuItemInactive','DOMMouseScroll','DOMNodeInserted','DOMNodeRemoved',
  82. 'RadioStateChange','blur','broadcast','change','click','close','command',
  83. 'commandupdate','contextmenu','dblclick','dragdrop','dragenter','dragexit',
  84. 'draggesture','dragover','focus','input','keydown','keypress','keyup','load',
  85. 'mousedown','mouseout','mouseover','mouseup','overflow','overflowchanged','popuphidden',
  86. 'popuphiding','popupshowing','popupshown','select','syncfrompreference','synctopreference',
  87. 'underflow','unload','abort','activate','afterprint','afterupdate','beforeactivate',
  88. 'beforecopy','beforecut','beforedeactivate','beforeeditfocus','beforepaste','beforeprint',
  89. 'beforeunload','beforeupdate','bounce','cellchange','controlselect','copy','cut',
  90. 'dataavailable','datasetchanged','datasetcomplete','deactivate','dragend','dragleave',
  91. 'dragstart','drop','error','errorupdate','filterchange','finish','focusin','focusout',
  92. 'help','layoutcomplete','losecapture','mouseenter','mouseleave','mousewheel',
  93. 'move','moveend','movestart','paste','propertychange','readystatechange','reset','resize',
  94. 'resizeend','resizestart','rowenter','rowexit','rowsdelete','rowsinserted','scroll',
  95. 'selectionchange','selectstart','start','stop','submit'];
  96. // mousemove
  97. if (TinyMCE_DevKitPlugin._isDebugEvents == s)
  98. return;
  99. TinyMCE_DevKitPlugin._isDebugEvents = s;
  100. for (n in tinyMCE.instances) {
  101. inst = tinyMCE.instances[n];
  102. if (!tinyMCE.isInstance(inst) || inst.getDoc() == ld)
  103. continue;
  104. ld = inst.getDoc();
  105. for (i=0; i<ev.length; i++) {
  106. if (s)
  107. tinyMCE.addEvent(ld, ev[i], TinyMCE_DevKitPlugin._debugEvent);
  108. else
  109. tinyMCE.removeEvent(ld, ev[i], TinyMCE_DevKitPlugin._debugEvent);
  110. }
  111. }
  112. },
  113. _debugEvent : function(e) {
  114. var t;
  115. e = e ? e : tinyMCE.selectedInstance.getWin().event;
  116. t = e.srcElement ? e.srcElement : e.target;
  117. tinyMCE.debug(e.type, t ? t.nodeName : '');
  118. },
  119. _serialize : function(o) {
  120. var i, v, s = TinyMCE_DevKitPlugin._serialize;
  121. if (o == null)
  122. return 'null';
  123. switch (typeof o) {
  124. case 'string':
  125. v = '\bb\tt\nn\ff\rr\""\'\'\\\\';
  126. return '"' + o.replace(new RegExp('([\u0080-\uFFFF\\x00-\\x1f\\"])', 'g'), function(a, b) {
  127. i = v.indexOf(b);
  128. if (i+1)
  129. return '\\' + v.charAt(i + 1);
  130. a = b.charCodeAt().toString(16);
  131. return '\\u' + '0000'.substring(a.length) + a;
  132. }) + '"';
  133. case 'object':
  134. if (o instanceof Array) {
  135. for (i=0, v = '['; i<o.length; i++)
  136. v += (i > 0 ? ',' : '') + s(o[i]);
  137. return v + ']';
  138. }
  139. v = '{';
  140. for (i in o)
  141. v += typeof o[i] != 'function' ? (v.length > 1 ? ',"' : '"') + i + '":' + s(o[i]) : '';
  142. return v + '}';
  143. }
  144. return '' + o;
  145. }
  146. };
  147. // Patch and piggy back functions
  148. tinyMCE.__debug = tinyMCE.debug;
  149. tinyMCE.debug = function() {
  150. var a, i, m = '', now = new Date().getTime(), start = TinyMCE_DevKitPlugin._startTime;
  151. if (!start)
  152. TinyMCE_DevKitPlugin._startTime = start = now;
  153. a = this.debug.arguments;
  154. for (i=0; i<a.length; i++) {
  155. if (typeof(a[i]) == 'undefined')
  156. continue;
  157. if (i > 0)
  158. m += ', ';
  159. m += a[i];
  160. }
  161. TinyMCE_DevKitPlugin._log('debug', m);
  162. };
  163. tinyMCE.dump = function(o) {
  164. tinyMCE.debug(TinyMCE_DevKitPlugin._serialize(o));
  165. };
  166. tinyMCE.sleep = function(t) {
  167. var s = new Date().getTime(), b;
  168. while (new Date().getTime() - s < t) b=1;
  169. };
  170. tinyMCE.__execCommand = tinyMCE.execCommand;
  171. tinyMCE.execCommand = function(command, user_interface, value) {
  172. var r, st, dk = TinyMCE_DevKitPlugin;
  173. st = dk._start();
  174. dk._log('execCommand', command, user_interface, value);
  175. r = tinyMCE.__execCommand(command, user_interface, value);
  176. dk._end(st);
  177. return r;
  178. };
  179. tinyMCE.__execInstanceCommand = tinyMCE.execInstanceCommand;
  180. tinyMCE.execInstanceCommand = function(editor_id, command, user_interface, value, focus) {
  181. var r, st, dk = TinyMCE_DevKitPlugin;
  182. st = dk._start();
  183. dk._log('execInstanceCommand', editor_id, command, user_interface, value);
  184. r = tinyMCE.__execInstanceCommand(editor_id, command, user_interface, value);
  185. dk._end(st);
  186. return r;
  187. };
  188. TinyMCE_Engine.prototype.__handleEvent = TinyMCE_Engine.prototype.handleEvent;
  189. TinyMCE_Engine.prototype.handleEvent = function(e) {
  190. var r, st, dk = TinyMCE_DevKitPlugin;
  191. st = dk._start();
  192. dk._log('handleEvent', e.type);
  193. r = tinyMCE.__handleEvent(e);
  194. dk._end(st);
  195. return r;
  196. };
  197. tinyMCE.__importCSS = tinyMCE.importCSS;
  198. tinyMCE.importCSS = function(doc, css) {
  199. var r, st, dk = TinyMCE_DevKitPlugin;
  200. st = dk._start();
  201. dk._log('importCSS', doc, css);
  202. r = tinyMCE.__importCSS(doc, css);
  203. dk._end(st);
  204. return r;
  205. };
  206. tinyMCE.__triggerNodeChange = tinyMCE.triggerNodeChange;
  207. tinyMCE.triggerNodeChange = function(focus, setup_content) {
  208. var r, st, dk = TinyMCE_DevKitPlugin;
  209. st = dk._start();
  210. dk._log('triggerNodeChange', focus, setup_content);
  211. r = tinyMCE.__triggerNodeChange(focus, setup_content);
  212. dk._end(st);
  213. return r;
  214. };
  215. tinyMCE.__dispatchCallback = tinyMCE.dispatchCallback;
  216. tinyMCE.dispatchCallback = function(i, p, n) {
  217. var r, st, dk = TinyMCE_DevKitPlugin;
  218. st = dk._start();
  219. dk._log('dispatchCallback', i, p, n);
  220. r = tinyMCE.__dispatchCallback(i, p, n);
  221. dk._end(st);
  222. return r;
  223. };
  224. tinyMCE.__executeCallback = tinyMCE.executeCallback;
  225. tinyMCE.executeCallback = function(i, p, n) {
  226. var r, st, dk = TinyMCE_DevKitPlugin;
  227. st = dk._start();
  228. dk._log('executeCallback', i, p, n);
  229. r = tinyMCE.__executeCallback(i, p, n);
  230. dk._end(st);
  231. return r;
  232. };
  233. tinyMCE.__execCommandCallback = tinyMCE.execCommandCallback;
  234. tinyMCE.execCommandCallback = function(i, p, n) {
  235. var r, st, dk = TinyMCE_DevKitPlugin;
  236. st = dk._start();
  237. dk._log('execCommandCallback', i, p, n);
  238. r = tinyMCE.__execCommandCallback(i, p, n);
  239. dk._end(st);
  240. return r;
  241. };
  242. tinyMCE.addPlugin("devkit", TinyMCE_DevKitPlugin);