Ticket #3788: tiny.diff

File tiny.diff, 50.2 KB (added by andy, 6 years ago)

My turn.

Line 
1Index: plugins/directionality/editor_plugin.js
2===================================================================
3--- plugins/directionality/editor_plugin.js     (revision 5248)
4+++ plugins/directionality/editor_plugin.js     (working copy)
5@@ -1,5 +1,5 @@
6 /**
7- * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $
8+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
9  *
10  * @author Moxiecode
11  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
12@@ -14,7 +14,7 @@
13                        longname : 'Directionality',
14                        author : 'Moxiecode Systems AB',
15                        authorurl : 'http://tinymce.moxiecode.com',
16-                       infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
17+                       infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',
18                        version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
19                };
20        },
21Index: plugins/inlinepopups/editor_plugin.js
22===================================================================
23--- plugins/inlinepopups/editor_plugin.js       (revision 5248)
24+++ plugins/inlinepopups/editor_plugin.js       (working copy)
25@@ -1,5 +1,5 @@
26 /**
27- * $Id: editor_plugin_src.js 172 2007-01-09 11:37:11Z spocke $
28+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
29  *
30  * Moxiecode DHTML Windows script.
31  *
32@@ -15,7 +15,7 @@
33                        longname : 'Inline Popups',
34                        author : 'Moxiecode Systems AB',
35                        authorurl : 'http://tinymce.moxiecode.com',
36-                       infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',
37+                       infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',
38                        version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
39                };
40        }
41@@ -26,6 +26,7 @@
42 // Patch openWindow, closeWindow TinyMCE functions
43 
44 TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow;
45+TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
46 
47 TinyMCE_Engine.prototype.openWindow = function(template, args) {
48        // Does the caller support inline
49@@ -52,6 +53,12 @@
50        if (!(height = parseInt(template['height'])))
51                height = 200;
52 
53+       if (!(minWidth = parseInt(template['minWidth'])))
54+               minWidth = 100;
55+
56+       if (!(minHeight = parseInt(template['minHeight'])))
57+               minHeight = 100;
58+
59        resizable = (args && args['resizable']) ? args['resizable'] : "no";
60        scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
61 
62@@ -78,16 +85,23 @@
63 
64        url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; // WordPress cache buster
65 
66-       mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop);
67+       mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop + ",minWidth=" + minWidth + ",minHeight=" + minHeight );
68 };
69 
70-TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
71-
72 TinyMCE_Engine.prototype.closeWindow = function(win) {
73-       if (mcWindows.selectedWindow != null)
74-               mcWindows.selectedWindow.close();
75-       else
76+       var gotit = false, n, w;
77+       for (n in mcWindows.windows) {
78+               w = mcWindows.windows[n];
79+               if (typeof(w) == 'function') continue;
80+               if (win.name == w.id + '_iframe') {
81+                       w.close();
82+                       gotit = true;
83+               }
84+       }
85+       if (!gotit)
86                this.orgCloseWindow(win);
87+
88+       tinyMCE.selectedInstance.getWin().focus();
89 };
90 
91 TinyMCE_Engine.prototype.setWindowTitle = function(win_ref, title) {
92@@ -135,9 +149,46 @@
93 
94        this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
95 
96+       this.addEvent(window, "resize", mcWindows.eventDispatcher);
97+       this.addEvent(document, "scroll", mcWindows.eventDispatcher);
98+
99        this.doc = document;
100 };
101 
102+TinyMCE_Windows.prototype.getBounds = function() {
103+       if (!this.bounds) {
104+               var vp = tinyMCE.getViewPort(window);
105+               var top, left, bottom, right, docEl = this.doc.documentElement;
106+
107+               top    = vp.top;
108+               left   = vp.left;
109+               bottom = vp.height + top - 2;
110+               right  = vp.width  + left - 22; // TODO this number is platform dependant
111+               // x1, y1, x2, y2
112+               this.bounds = [left, top, right, bottom];
113+       }
114+       return this.bounds;
115+};
116+
117+TinyMCE_Windows.prototype.clampBoxPosition = function(x, y, w, h, minW, minH) {
118+       var bounds = this.getBounds();
119+
120+       x = Math.max(bounds[0], Math.min(bounds[2], x + w) - w);
121+       y = Math.max(bounds[1], Math.min(bounds[3], y + h) - h);
122+
123+       return this.clampBoxSize(x, y, w, h, minW, minH);
124+};
125+
126+TinyMCE_Windows.prototype.clampBoxSize = function(x, y, w, h, minW, minH) {
127+       var bounds = this.getBounds();
128+
129+       return [
130+               x, y,
131+               Math.max(minW, Math.min(bounds[2], x + w) - x),
132+               Math.max(minH, Math.min(bounds[3], y + h) - y)
133+       ];
134+};
135+
136 TinyMCE_Windows.prototype.getParam = function(name, default_value) {
137        var value = null;
138 
139@@ -186,14 +237,51 @@
140                case "focus":
141                        mcWindows.selectedWindow.onFocus(e);
142                        break;
143+               case "scroll":
144+               case "resize":
145+                       if (mcWindows.clampUpdateTimeout)
146+                               clearTimeout(mcWindows.clampUpdateTimeout);
147+                       mcWindows.clampEventType = e.type;
148+                       mcWindows.clampUpdateTimeout =
149+                               setTimeout(function () {mcWindows.updateClamping()}, 100);
150+                       break;
151        }
152 };
153 
154+TinyMCE_Windows.prototype.updateClamping = function () {
155+       var clamp, oversize, etype = mcWindows.clampEventType;
156+
157+       this.bounds = null; // Recalc window bounds on resize/scroll
158+       this.clampUpdateTimeout = null;
159+
160+       for (var n in this.windows) {
161+               win = this.windows[n];
162+               if (typeof(win) == 'function' || ! win.winElement) continue;
163+
164+               clamp = mcWindows.clampBoxPosition(
165+                       win.left, win.top,
166+                       win.winElement.scrollWidth,
167+                       win.winElement.scrollHeight,
168+                       win.features.minWidth,
169+                       win.features.minHeight
170+               );
171+               oversize = (
172+                       clamp[2] != win.winElement.scrollWidth ||
173+                       clamp[3] != win.winElement.scrollHeight
174+               ) ? true : false;
175+
176+               if (!oversize || win.features.resizable == "yes" || etype != "scroll")
177+                       win.moveTo(clamp[0], clamp[1]);
178+               if (oversize && win.features.resizable == "yes")
179+                       win.resizeTo(clamp[2], clamp[3]);
180+       }
181+};
182+
183 TinyMCE_Windows.prototype.addEvent = function(obj, name, handler) {
184        if (this.isMSIE)
185                obj.attachEvent("on" + name, handler);
186        else
187-               obj.addEventListener(name, handler, true);
188+               obj.addEventListener(name, handler, false);
189 };
190 
191 TinyMCE_Windows.prototype.cancelEvent = function(e) {
192@@ -217,6 +305,8 @@
193        options['top'] = "10";
194        options['width'] = "300";
195        options['height'] = "300";
196+       options['minwidth'] = "100";
197+       options['minheight'] = "100";
198        options['resizable'] = "yes";
199        options['minimizable'] = "yes";
200        options['maximizable'] = "yes";
201@@ -240,6 +330,8 @@
202        options['top'] = parseInt(options['top']);
203        options['width'] = parseInt(options['width']);
204        options['height'] = parseInt(options['height']);
205+       options['minWidth'] = parseInt(options['minwidth']);
206+       options['minHeight'] = parseInt(options['minheight']);
207 
208        return options;
209 };
210@@ -253,6 +345,21 @@
211 
212        features = this.parseFeatures(features);
213 
214+       // Clamp specified dimensions
215+       var clamp = mcWindows.clampBoxPosition(
216+               features['left'], features['top'],
217+               features['width'], features['height'],
218+               features['minWidth'], features['minHeight']
219+       );
220+
221+       features['left'] = clamp[0];
222+       features['top'] = clamp[1];
223+
224+       if (features['resizable'] == "yes") {
225+               features['width'] = clamp[2];
226+               features['height'] = clamp[3];
227+       }
228+
229        // Create div
230        id = "mcWindow_" + name;
231        win.deltaHeight = 18;
232@@ -285,9 +392,9 @@
233        html += '<html>';
234        html += '<head>';
235        html += '<title>Wrapper iframe</title>';
236+       if (this.isMac) html += '<style type="text/css">.mceWindowTitle{float:none;margin:0;width:100%;text-align:center;}.mceWindowClose{float:none;position:absolute;left:0px;top:0px;}</style>';
237        html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
238        html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />';
239-       if ( this.isMac ) html += '<style type="text/css">.mceWindowTitle{float:none;margin:0;text-align:center;}.mceWindowClose{float:none;position:absolute;left:0px;top:0px;}</style>';
240        html += '</head>';
241        html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
242 
243@@ -297,8 +404,9 @@
244        html += '  onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';
245        html += '    <div class="mceWindowHeadTools">';
246        html += '      <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" target="_self" onmousedown="return false;" class="mceWindowClose"><img border="0" src="' + imgPath + '/window_close.gif" /></a>';
247-//     html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"></a>';
248-//     html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
249+       if (features['resizable'] == "yes" && features['maximizable'] == "yes")
250+               html += '      <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"><img border="0" src="' + imgPath + '/window_maximize.gif" /></a>';
251+       // html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
252        html += '    </div>';
253        html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
254        html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe" scrolling="' + features['scrollbars'] + '"></iframe></div>';
255@@ -447,6 +555,7 @@
256        div.setAttribute("width", width);
257        div.setAttribute("height", (height));
258        div.style.position = "absolute";
259+
260        div.style.left = left + "px";
261        div.style.top = top + "px";
262        div.style.width = width + "px";
263@@ -473,7 +582,7 @@
264        iframe.setAttribute("topMargin", "0");
265        iframe.setAttribute("width", iframeWidth);
266        iframe.setAttribute("height", iframeHeight);
267-//     iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
268+       // iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
269        // iframe.setAttribute("allowtransparency", "false");
270        iframe.setAttribute("scrolling", "no");
271        iframe.style.width = iframeWidth + "px";
272@@ -522,7 +631,24 @@
273 };
274 
275 TinyMCE_Window.prototype.maximize = function() {
276-       
277+       if (this.restoreSize) {
278+               this.moveTo(this.restoreSize[0], this.restoreSize[1]);
279+               this.resizeTo(this.restoreSize[2], this.restoreSize[3]);
280+               this.updateClamping();
281+               this.restoreSize = null;
282+       } else {
283+               var bounds = mcWindows.getBounds();
284+               this.restoreSize = [
285+                       this.left, this.top,
286+                       this.winElement.scrollWidth,
287+                       this.winElement.scrollHeight
288+               ];
289+               this.moveTo(bounds[0], bounds[1]);
290+               this.resizeTo(
291+                       bounds[2] - bounds[0],
292+                       bounds[3] - bounds[1]
293+               );
294+       }
295 };
296 
297 TinyMCE_Window.prototype.startResize = function() {
298@@ -552,7 +678,7 @@
299 
300        mcWindows.windows = mcWindowsNew;
301 
302-//     alert(mcWindows.doc.getElementById(this.id + "_iframe"));
303+       // alert(mcWindows.doc.getElementById(this.id + "_iframe"));
304 
305        var e = mcWindows.doc.getElementById(this.id + "_iframe");
306        e.parentNode.removeChild(e);
307@@ -561,57 +687,84 @@
308        e.parentNode.removeChild(e);
309 
310        mcWindows.setDocumentLock(false);
311-
312-       tinyMCE.selectedInstance.getWin().focus(); // WordPress: focus on the editor after closing a popup
313 };
314 
315 TinyMCE_Window.prototype.onMouseMove = function(e) {
316-       var scrollX = 0;//this.doc.body.scrollLeft;
317-       var scrollY = 0;//this.doc.body.scrollTop;
318-
319+       var clamp;
320        // Calculate real X, Y
321        var dx = e.screenX - mcWindows.mouseDownScreenX;
322        var dy = e.screenY - mcWindows.mouseDownScreenY;
323 
324        switch (mcWindows.action) {
325                case "resize":
326-                       width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);
327-                       height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);
328+                       clamp = mcWindows.clampBoxSize(
329+                               this.left, this.top,
330+                               mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX),
331+                               mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY),
332+                               this.features.minWidth, this.features.minHeight
333+                       );
334 
335-                       width = width < 100 ? 100 : width;
336-                       height = height < 100 ? 100 : height;
337+                       this.resizeTo(clamp[2], clamp[3]);
338 
339-                       this.wrapperIFrameElement.style.width = (width+2) + 'px';
340-                       this.wrapperIFrameElement.style.height = (height+2) + 'px';
341-                       this.wrapperIFrameElement.width = width+2;
342-                       this.wrapperIFrameElement.height = height+2;
343-                       this.winElement.style.width = width + 'px';
344-                       this.winElement.style.height = height + 'px';
345-
346-                       height = height - this.deltaHeight;
347-
348-                       this.containerElement.style.width = width + 'px';
349-                       this.iframeElement.style.width = width + 'px';
350-                       this.iframeElement.style.height = height + 'px';
351-                       this.bodyElement.style.width = width + 'px';
352-                       this.bodyElement.style.height = height + 'px';
353-                       this.headElement.style.width = width + 'px';
354-                       //this.statusElement.style.width = width + 'px';
355-
356                        mcWindows.cancelEvent(e);
357                        break;
358 
359                case "move":
360                        this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
361                        this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
362-                       this.winElement.style.left = this.left + "px";
363-                       this.winElement.style.top = this.top + "px";
364+                       this.updateClamping();
365 
366                        mcWindows.cancelEvent(e);
367                        break;
368        }
369 };
370 
371+TinyMCE_Window.prototype.moveTo = function (x, y) {
372+       this.left = x;
373+       this.top = y;
374+
375+       this.winElement.style.left = this.left + "px";
376+       this.winElement.style.top = this.top + "px";
377+};
378+
379+TinyMCE_Window.prototype.resizeTo = function (width, height) {
380+       this.wrapperIFrameElement.style.width = (width+2) + 'px';
381+       this.wrapperIFrameElement.style.height = (height+2) + 'px';
382+       this.wrapperIFrameElement.width = width+2;
383+       this.wrapperIFrameElement.height = height+2;
384+       this.winElement.style.width = width + 'px';
385+       this.winElement.style.height = height + 'px';
386+
387+       height = height - this.deltaHeight;
388+
389+       this.containerElement.style.width = width + 'px';
390+       this.iframeElement.style.width = width + 'px';
391+       this.iframeElement.style.height = height + 'px';
392+       this.bodyElement.style.width = width + 'px';
393+       this.bodyElement.style.height = height + 'px';
394+       this.headElement.style.width = width + 'px';
395+       //this.statusElement.style.width = width + 'px';
396+};
397+
398+TinyMCE_Window.prototype.updateClamping = function () {
399+       var clamp, oversize;
400+
401+       clamp = mcWindows.clampBoxPosition(
402+               this.left, this.top,
403+               this.winElement.scrollWidth,
404+               this.winElement.scrollHeight,
405+               this.features.minWidth, this.features.minHeight
406+       );
407+       oversize = (
408+               clamp[2] != this.winElement.scrollWidth ||
409+               clamp[3] != this.winElement.scrollHeight
410+       ) ? true : false;
411+
412+       this.moveTo(clamp[0], clamp[1]);
413+       if (this.features.resizable == "yes" && oversize)
414+               this.resizeTo(clamp[2], clamp[3]);
415+};
416+
417 function debug(msg) {
418        document.getElementById('debug').value += msg + "\n";
419 }
420@@ -639,9 +792,6 @@
421 TinyMCE_Window.prototype.onMouseDown = function(e) {
422        var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
423 
424-       var scrollX = 0;//this.doc.body.scrollLeft;
425-       var scrollY = 0;//this.doc.body.scrollTop;
426-
427        mcWindows.mouseDownScreenX = e.screenX;
428        mcWindows.mouseDownScreenY = e.screenY;
429        mcWindows.mouseDownLayerX = this.left;
430Index: plugins/autosave/editor_plugin.js
431===================================================================
432--- plugins/autosave/editor_plugin.js   (revision 5248)
433+++ plugins/autosave/editor_plugin.js   (working copy)
434@@ -1,5 +1,5 @@
435 /**
436- * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $
437+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
438  *
439  * @author Moxiecode
440  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
441@@ -14,7 +14,7 @@
442                        longname : 'Auto save',
443                        author : 'Moxiecode Systems AB',
444                        authorurl : 'http://tinymce.moxiecode.com',
445-                       infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',
446+                       infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
447                        version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
448                };
449        },
450Index: plugins/paste/editor_plugin.js
451===================================================================
452--- plugins/paste/editor_plugin.js      (revision 5248)
453+++ plugins/paste/editor_plugin.js      (working copy)
454@@ -1,5 +1,5 @@
455 /**
456- * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $
457+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
458  *
459  * @author Moxiecode
460  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
461@@ -14,7 +14,7 @@
462                        longname : 'Paste text/word',
463                        author : 'Moxiecode Systems AB',
464                        authorurl : 'http://tinymce.moxiecode.com',
465-                       infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',
466+                       infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',
467                        version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
468                };
469        },
470@@ -24,6 +24,16 @@
471                        tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent);
472        },
473 
474+       handleEvent : function(e) {
475+               // Force paste dialog if non IE browser
476+               if (!tinyMCE.isRealIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false) && e.ctrlKey && e.keyCode == 86 && e.type == "keydown") {
477+                       window.setTimeout('tinyMCE.selectedInstance.execCommand("mcePasteText",true)', 1);
478+                       return tinyMCE.cancelEvent(e);
479+               }
480+
481+               return true;
482+       },
483+
484        getControlHTML : function(cn) {
485                switch (cn) {
486                        case "pastetext":
487Index: tiny_mce.js
488===================================================================
489--- tiny_mce.js (revision 5248)
490+++ tiny_mce.js (working copy)
491@@ -5,8 +5,8 @@
492        var ua;
493 
494        this.majorVersion = "2";
495-       this.minorVersion = "0.9";
496-       this.releaseDate = "2007-01-09";
497+       this.minorVersion = "1.0";
498+       this.releaseDate = "2007-02-13";
499 
500        this.instances = new Array();
501        this.switchClassCache = new Array();
502@@ -186,7 +186,7 @@
503                this._def("custom_shortcuts", true);
504                this._def("convert_on_click", false);
505                this._def("content_css", '');
506-               this._def("fix_list_elements", false);
507+               this._def("fix_list_elements", true);
508                this._def("fix_table_elements", false);
509                this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml');
510                this._def("hidden_tab_class", '');
511@@ -241,7 +241,7 @@
512                this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';
513                this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i");
514                this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
515-               this.uniqueURL = 'javascript:TINYMCE_UNIQUEURL();'; // Make unique URL non real URL
516+               this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL
517                this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
518                this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance');
519 
520@@ -740,6 +740,35 @@
521                                tinyMCE.removeMCEControl(value);
522                                return;
523 
524+                       case "mceToggleEditor":
525+                               var inst = tinyMCE.getInstanceById(value), pe, te;
526+
527+                               if (inst) {
528+                                       pe = document.getElementById(inst.editorId + '_parent');
529+                                       te = inst.oldTargetElement;
530+
531+                                       if (typeof(inst.enabled) == 'undefined')
532+                                               inst.enabled = true;
533+
534+                                       inst.enabled = !inst.enabled;
535+
536+                                       if (!inst.enabled) {
537+                                               pe.style.display = 'none';
538+                                               te.value = inst.getHTML();
539+                                               te.style.display = inst.oldTargetDisplay;
540+                                               tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst);
541+                                       } else {
542+                                               pe.style.display = 'block';
543+                                               te.style.display = 'none';
544+                                               inst.setHTML(te.value);
545+                                               inst.useCSS = false;
546+                                               tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst);
547+                                       }
548+                               } else
549+                                       tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
550+
551+                               return;
552+
553                        case "mceResetDesignMode":
554                                // Resets the designmode state of the editors in Gecko
555                                if (!tinyMCE.isIE) {
556@@ -961,10 +990,6 @@
557                // Fix for bug #957681
558                //inst.getDoc().designMode = inst.getDoc().designMode;
559 
560-               // Setup element references
561-               var parentElm = inst.targetDoc.getElementById(inst.editorId + '_parent');
562-               inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
563-
564                tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst);
565                tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
566 
567@@ -1445,9 +1470,9 @@
568                        h += '</a></span>';
569                } else {
570                        if (tinyMCE.isRealIE)
571-                               h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
572+                               h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
573                        else
574-                               h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
575+                               h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton">';
576 
577                        h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';
578                        h += '<img src="' + img + '" title="{$' + lang + '}" /></a>';
579@@ -1693,7 +1718,7 @@
580        },
581 
582        triggerNodeChange : function(focus, setup_content) {
583-               var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false;
584+               var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false, st;
585 
586                if (tinyMCE.selectedInstance) {
587                        inst = tinyMCE.selectedInstance;
588@@ -1705,7 +1730,7 @@
589                        inst.lastTriggerEl = elm;*/
590 
591                        editorId = inst.editorId;
592-                       selectedText = inst.selection.getSelectedText();
593+                       st = inst.selection.getSelectedText();
594 
595                        if (tinyMCE.settings.auto_resize)
596                                inst.resizeToContent();
597@@ -1716,7 +1741,7 @@
598                        inst.switchSettings();
599 
600                        if (tinyMCE.selectedElement)
601-                               anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
602+                               anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 0);
603 
604                        if (tinyMCE.settings['custom_undo_redo']) {
605                                undoIndex = inst.undoRedo.undoIndex;
606@@ -2180,11 +2205,11 @@
607        },
608 
609        getCSSClasses : function(editor_id, doc) {
610-               var output = new Array();
611+               var inst = tinyMCE.getInstanceById(editor_id);
612 
613                // Is cached, use that
614-               if (typeof(tinyMCE.cssClasses) != "undefined")
615-                       return tinyMCE.cssClasses;
616+               if (inst && inst.cssClasses.length > 0)
617+                       return inst.cssClasses;
618 
619                if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") {
620                        var instance;
621@@ -2242,13 +2267,13 @@
622                                                                        var cssClass = rule.substring(rule.indexOf('.') + 1);
623                                                                        var addClass = true;
624 
625-                                                                       for (var p=0; p<output.length && addClass; p++) {
626-                                                                               if (output[p] == cssClass)
627+                                                                       for (var p=0; p<inst.cssClasses.length && addClass; p++) {
628+                                                                               if (inst.cssClasses[p] == cssClass)
629                                                                                        addClass = false;
630                                                                        }
631 
632                                                                        if (addClass)
633-                                                                               output[output.length] = cssClass;
634+                                                                               inst.cssClasses[inst.cssClasses.length] = cssClass;
635                                                                }
636                                                        }
637                                                }
638@@ -2257,11 +2282,7 @@
639                        }
640                }
641 
642-               // Cache em
643-               if (output.length > 0)
644-                       tinyMCE.cssClasses = output;
645-
646-               return output;
647+               return inst.cssClasses;
648        },
649 
650        regexpReplace : function(in_str, reg_exp, replace_str, opts) {
651@@ -2289,19 +2310,27 @@
652        },
653 
654        getControlHTML : function(c) {
655-               var i, l, n, o, v;
656+               var i, l, n, o, v, rtl = tinyMCE.getLang('lang_dir') == 'rtl';
657 
658                l = tinyMCE.plugins;
659                for (n in l) {
660                        o = l[n];
661 
662-                       if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
663+                       if (o.getControlHTML && (v = o.getControlHTML(c)) != '') {
664+                               if (rtl)
665+                                       return '<span dir="rtl">' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + '</span>';
666+
667                                return tinyMCE.replaceVar(v, "pluginurl", o.baseURL);
668+                       }
669                }
670 
671                o = tinyMCE.themes[tinyMCE.settings['theme']];
672-               if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
673+               if (o.getControlHTML && (v = o.getControlHTML(c)) != '') {
674+                       if (rtl)
675+                               return '<span dir="rtl">' + v + '</span>';
676+
677                        return v;
678+               }
679 
680                return '';
681        },
682@@ -2433,6 +2462,7 @@
683        this.hasMouseMoved = false;
684        this.foreColor = this.backColor = "#999999";
685        this.data = {};
686+       this.cssClasses = [];
687 
688        this.cleanup.init({
689                valid_elements : s.valid_elements,
690@@ -2865,7 +2895,7 @@
691                                if (tinyMCE.isGecko && this.getSel().isCollapsed) {
692                                        focusElm = tinyMCE.getParentElement(focusElm, 'A');
693 
694-                                       if (focusElm && this.getRng(0).endOffset > 0 && this.getRng(0).endOffset != focusElm.innerHTML.length) // WordPress mod to prevent unlinking if caret at start/end of link
695+                                       if (focusElm)
696                                                this.selection.selectNode(focusElm, false);
697                                }
698 
699@@ -3690,6 +3720,7 @@
700                                hc = '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>';
701                        } else {
702                                hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />';
703+                               this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
704                                this.oldTargetElement.style.display = "none";
705                        }
706 
707@@ -3715,8 +3746,10 @@
708                        // Just hide the textarea element
709                        this.oldTargetElement = replace_element;
710 
711-                       if (!tinyMCE.settings['debug'])
712+                       if (!tinyMCE.settings['debug']) {
713+                               this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
714                                this.oldTargetElement.style.display = "none";
715+                       }
716 
717                        // Output HTML and set editable
718                        if (tinyMCE.isGecko) {
719@@ -3790,6 +3823,10 @@
720                if (tinyMCE.isIE)
721                        window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1);
722 
723+               // Setup element references
724+               var parentElm = this.targetDoc.getElementById(this.editorId + '_parent');
725+               this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
726+
727                tinyMCE.setupContent(this.editorId, true);
728 
729                return true;
730@@ -4865,7 +4902,7 @@
731                if (r.forceAttribs && (t = r.forceAttribs[an]))
732                        av = t;
733 
734-               if (os && av.length != 0 && this.settings.url_converter.length != 0 && /^(src|href|longdesc)$/.test(an))
735+               if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an))
736                        av = this._urlConverter(this, n, av);
737 
738                if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av))
739@@ -5186,9 +5223,10 @@
740 
741        // Convert all strong/em to b/i in Gecko
742        if (tinyMCE.isGecko) {
743-               h = h.replace(/<strong/gi, '<b');
744-               h = h.replace(/<em(\/?)/gi, '<i');
745-               h = h.replace(/<em /gi, '<i');
746+               h = h.replace(/<embed([^>]*)>/gi, '<tmpembed$1>');
747+               h = h.replace(/<em([^>]*)>/gi, '<i$1>');
748+               h = h.replace(/<tmpembed([^>]*)>/gi, '<embed$1>');
749+               h = h.replace(/<strong([^>]*)>/gi, '<b$1>');
750                h = h.replace(/<\/strong>/gi, '</b>');
751                h = h.replace(/<\/em>/gi, '</i>');
752        }
753@@ -5503,6 +5541,32 @@
754        };
755 };
756 
757+TinyMCE_Engine.prototype.getStyle = function(n, na, d) {
758+       if (!n)
759+               return false;
760+
761+       // Gecko
762+       if (tinyMCE.isGecko && n.ownerDocument.defaultView) {
763+               try {
764+                       return n.ownerDocument.defaultView.getComputedStyle(n, null).getPropertyValue(na);
765+               } catch (n) {
766+                       // Old safari might fail
767+                       return null;
768+               }
769+       }
770+
771+       // Camelcase it, if needed
772+       na = na.replace(/-(\D)/g, function(a, b){
773+               return b.toUpperCase();
774+       });
775+
776+       // IE & Opera
777+       if (n.currentStyle)
778+               return n.currentStyle[na];
779+
780+       return false;
781+};
782+
783 /* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */
784 
785 TinyMCE_Engine.prototype.parseURL = function(url_str) {
786@@ -7132,13 +7196,21 @@
787        },
788 
789        show : function() {
790-               this.getElement().style.display = 'block';
791-               this.updateBlocker();
792+               var el = this.getElement();
793+
794+               if (el) {
795+                       el.style.display = 'block';
796+                       this.updateBlocker();
797+               }
798        },
799 
800        hide : function() {
801-               this.getElement().style.display = 'none';
802-               this.updateBlocker();
803+               var el = this.getElement();
804+
805+               if (el) {
806+                       el.style.display = 'none';
807+                       this.updateBlocker();
808+               }
809        },
810 
811        isVisible : function() {
812Index: themes/advanced/jscripts/color_picker.js
813===================================================================
814--- themes/advanced/jscripts/color_picker.js    (revision 5248)
815+++ themes/advanced/jscripts/color_picker.js    (working copy)
816@@ -1,20 +1,5 @@
817-function init() {
818-       if (tinyMCE.isMSIE)
819-               tinyMCEPopup.resizeToInnerSize();
820-}
821+var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false;
822 
823-function selectColor() {
824-       var color = document.getElementById("selectedColorBox").value;
825-
826-       tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color);
827-       tinyMCEPopup.close();
828-}
829-
830-function showColor(color) {
831-       document.getElementById("selectedColor").style.backgroundColor = color;
832-       document.getElementById("selectedColorBox").value = color;
833-}
834-
835 var colors = new Array(
836        "#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033",
837        "#330066","#330099","#3300cc","#3300ff","#660000","#660033","#660066","#660099",
838@@ -45,9 +30,71 @@
839        "#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff"
840 );
841 
842+var named = {
843+       '#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige',
844+       '#FFE4C4':'Bisque','#000000':'Black','#FFEBCD':'BlanchedAlmond','#0000FF':'Blue','#8A2BE2':'BlueViolet','#A52A2A':'Brown',
845+       '#DEB887':'BurlyWood','#5F9EA0':'CadetBlue','#7FFF00':'Chartreuse','#D2691E':'Chocolate','#FF7F50':'Coral','#6495ED':'CornflowerBlue',
846+       '#FFF8DC':'Cornsilk','#DC143C':'Crimson','#00FFFF':'Cyan','#00008B':'DarkBlue','#008B8B':'DarkCyan','#B8860B':'DarkGoldenRod',
847+       '#A9A9A9':'DarkGray','#A9A9A9':'DarkGrey','#006400':'DarkGreen','#BDB76B':'DarkKhaki','#8B008B':'DarkMagenta','#556B2F':'DarkOliveGreen',
848+       '#FF8C00':'Darkorange','#9932CC':'DarkOrchid','#8B0000':'DarkRed','#E9967A':'DarkSalmon','#8FBC8F':'DarkSeaGreen','#483D8B':'DarkSlateBlue',
849+       '#2F4F4F':'DarkSlateGray','#2F4F4F':'DarkSlateGrey','#00CED1':'DarkTurquoise','#9400D3':'DarkViolet','#FF1493':'DeepPink','#00BFFF':'DeepSkyBlue',
850+       '#696969':'DimGray','#696969':'DimGrey','#1E90FF':'DodgerBlue','#B22222':'FireBrick','#FFFAF0':'FloralWhite','#228B22':'ForestGreen',
851+       '#FF00FF':'Fuchsia','#DCDCDC':'Gainsboro','#F8F8FF':'GhostWhite','#FFD700':'Gold','#DAA520':'GoldenRod','#808080':'Gray','#808080':'Grey',
852+       '#008000':'Green','#ADFF2F':'GreenYellow','#F0FFF0':'HoneyDew','#FF69B4':'HotPink','#CD5C5C':'IndianRed','#4B0082':'Indigo','#FFFFF0':'Ivory',
853+       '#F0E68C':'Khaki','#E6E6FA':'Lavender','#FFF0F5':'LavenderBlush','#7CFC00':'LawnGreen','#FFFACD':'LemonChiffon','#ADD8E6':'LightBlue',
854+       '#F08080':'LightCoral','#E0FFFF':'LightCyan','#FAFAD2':'LightGoldenRodYellow','#D3D3D3':'LightGray','#D3D3D3':'LightGrey','#90EE90':'LightGreen',
855+       '#FFB6C1':'LightPink','#FFA07A':'LightSalmon','#20B2AA':'LightSeaGreen','#87CEFA':'LightSkyBlue','#778899':'LightSlateGray','#778899':'LightSlateGrey',
856+       '#B0C4DE':'LightSteelBlue','#FFFFE0':'LightYellow','#00FF00':'Lime','#32CD32':'LimeGreen','#FAF0E6':'Linen','#FF00FF':'Magenta','#800000':'Maroon',
857+       '#66CDAA':'MediumAquaMarine','#0000CD':'MediumBlue','#BA55D3':'MediumOrchid','#9370D8':'MediumPurple','#3CB371':'MediumSeaGreen','#7B68EE':'MediumSlateBlue',
858+       '#00FA9A':'MediumSpringGreen','#48D1CC':'MediumTurquoise','#C71585':'MediumVioletRed','#191970':'MidnightBlue','#F5FFFA':'MintCream','#FFE4E1':'MistyRose','#FFE4B5':'Moccasin',
859+       '#FFDEAD':'NavajoWhite','#000080':'Navy','#FDF5E6':'OldLace','#808000':'Olive','#6B8E23':'OliveDrab','#FFA500':'Orange','#FF4500':'OrangeRed','#DA70D6':'Orchid',
860+       '#EEE8AA':'PaleGoldenRod','#98FB98':'PaleGreen','#AFEEEE':'PaleTurquoise','#D87093':'PaleVioletRed','#FFEFD5':'PapayaWhip','#FFDAB9':'PeachPuff',
861+       '#CD853F':'Peru','#FFC0CB':'Pink','#DDA0DD':'Plum','#B0E0E6':'PowderBlue','#800080':'Purple','#FF0000':'Red','#BC8F8F':'RosyBrown','#4169E1':'RoyalBlue',
862+       '#8B4513':'SaddleBrown','#FA8072':'Salmon','#F4A460':'SandyBrown','#2E8B57':'SeaGreen','#FFF5EE':'SeaShell','#A0522D':'Sienna','#C0C0C0':'Silver',
863+       '#87CEEB':'SkyBlue','#6A5ACD':'SlateBlue','#708090':'SlateGray','#708090':'SlateGrey','#FFFAFA':'Snow','#00FF7F':'SpringGreen',
864+       '#4682B4':'SteelBlue','#D2B48C':'Tan','#008080':'Teal','#D8BFD8':'Thistle','#FF6347':'Tomato','#40E0D0':'Turquoise','#EE82EE':'Violet',
865+       '#F5DEB3':'Wheat','#FFFFFF':'White','#F5F5F5':'WhiteSmoke','#FFFF00':'Yellow','#9ACD32':'YellowGreen'
866+};
867+
868+function init() {
869+       var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color'));
870+
871+       if (tinyMCE.isMSIE)
872+               tinyMCEPopup.resizeToInnerSize();
873+
874+       generatePicker();
875+
876+       if (inputColor) {
877+               changeFinalColor(inputColor);
878+
879+               col = convertHexToRGB(inputColor);
880+
881+               if (col)
882+                       updateLight(col.r, col.g, col.b);
883+       }
884+}
885+
886+function insertAction() {
887+       var color = document.getElementById("color").value;
888+
889+       tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color);
890+       tinyMCEPopup.close();
891+}
892+
893+function showColor(color, name) {
894+       if (name)
895+               document.getElementById("colorname").innerHTML = name;
896+
897+       document.getElementById("preview").style.backgroundColor = color;
898+       document.getElementById("color").value = color;
899+}
900+
901 function convertRGBToHex(col) {
902        var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
903 
904+       if (!col)
905+               return col;
906+
907        var rgb = col.replace(re, "$1,$2,$3").split(',');
908        if (rgb.length == 3) {
909                r = parseInt(rgb[0]).toString(16);
910@@ -72,37 +119,131 @@
911                g = parseInt(col.substring(2, 4), 16);
912                b = parseInt(col.substring(4, 6), 16);
913 
914-               return "rgb(" + r + "," + g + "," + b + ")";
915+               return {r : r, g : g, b : b};
916        }
917 
918-       return col;
919+       return null;
920 }
921 
922-function renderColorMap() {
923-       var html = "";
924-       var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color'));
925+function generatePicker() {
926+       var el = document.getElementById('light'), h = '', i;
927 
928-       html += '<table border="0" cellspacing="1" cellpadding="0">'
929+       for (i = 0; i < detail; i++){
930+               h += '<div id="gs'+i+'" style="background-color:#000000; width:15px; height:3px; border-style:none; border-width:0px;"'
931+               + ' onclick="changeFinalColor(this.style.backgroundColor)"'
932+               + ' onmousedown="isMouseDown = true; return false;"'
933+               + ' onmouseup="isMouseDown = false;"'
934+               + ' onmousemove="if (isMouseDown && isMouseOver) changeFinalColor(this.style.backgroundColor); return false;"'
935+               + ' onmouseover="isMouseOver = true;"'
936+               + ' onmouseout="isMouseOver = false;"'
937+               + '></div>';
938+       }
939+
940+       el.innerHTML = h;
941+}
942+
943+function generateWebColors() {
944+       var el = document.getElementById('webcolors'), h = '', i;
945+
946+       if (el.className == 'generated')
947+               return;
948+
949+       h += '<table border="0" cellspacing="1" cellpadding="0">'
950                + '<tr>';
951-       for (var i=0; i<colors.length; i++) {
952-               html += '<td bgcolor="' + colors[i] + '">'
953+
954+       for (i=0; i<colors.length; i++) {
955+               h += '<td bgcolor="' + colors[i] + '">'
956                        + '<a href="javascript:selectColor();" onfocus="showColor(\'' + colors[i] +  '\');" onmouseover="showColor(\'' + colors[i] +  '\');">'
957                        + '<img border="0" src="images/spacer.gif" width="10" height="10" title="' + colors[i] +  '" alt="' + colors[i] +  '" /></a></td>';
958                if ((i+1) % 18 == 0)
959-                       html += '</tr><tr>';
960+                       h += '</tr><tr>';
961        }
962-       html += '<tr><td colspan="18">'
963-               + '<table width="100%" border="0" cellspacing="0" cellpadding="0">'
964-               + '<tr><td>'
965-               + '<img id="selectedColor" style="background-color:' + tinyMCE.getWindowArg('input_color') + '" border="0" src="images/spacer.gif" width="80" height="16" />'
966-               + '</td><td align="right">'
967-               + '<input id="selectedColorBox" name="selectedColorBox" type="text" size="7" maxlength="7" style="width:65px" value="' + inputColor + '" />'
968-               + '</td></tr>'
969-               + '</table>'
970-               + '<div style="float: left"><input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" style="margin-top:3px" onclick="selectColor();"></div>'
971-               + '<div style="float: right"><input type="button" name="cancel" value="{$lang_cancel}" style="margin-top:3px" onclick="tinyMCEPopup.close();" id="cancel" /></div>'
972-               + '</td></tr>'
973-               + '</table>';
974 
975-       document.write(html);
976-}
977\ No newline at end of file
978+       h += '</table>';
979+
980+       el.innerHTML = h;
981+       el.className = 'generated';
982+}
983+
984+function generateNamedColors() {
985+       var el = document.getElementById('namedcolors'), h = '', n, v, i = 0;
986+
987+       if (el.className == 'generated')
988+               return;
989+
990+       for (n in named) {
991+               v = named[n];
992+               h += '<a href="javascript:selectColor();" onmouseover="showColor(\'' + n +  '\',\'' + v + '\');" style="background-color: ' + n + '"><!-- IE --></a>'
993+       }
994+
995+       el.innerHTML = h;
996+       el.className = 'generated';
997+}
998+
999+function selectColor() {
1000+       var color = document.getElementById("color").value;
1001+
1002+       if(window.opener)
1003+               window.opener.tinyMCE.execInstanceCommand(tinyMCE.getWindowArg('editor_id'),tinyMCE.getWindowArg('command'),false,color);
1004+
1005+       window.close();
1006+}
1007+
1008+function dechex(n) {
1009+       return strhex.charAt(Math.floor(n / 16)) + strhex.charAt(n % 16);
1010+}
1011+
1012+function computeColor(e) {
1013+       var x, y, partWidth, partDetail, imHeight, r, g, b, coef, i, finalCoef, finalR, finalG, finalB;
1014+
1015+       x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0);
1016+       y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0);
1017+
1018+       partWidth = document.getElementById('colorpicker').width / 6;
1019+       partDetail = detail / 2;
1020+       imHeight = document.getElementById('colorpicker').height;
1021+
1022+       r = (x >= 0)*(x < partWidth)*255 + (x >= partWidth)*(x < 2*partWidth)*(2*255 - x * 255 / partWidth) + (x >= 4*partWidth)*(x < 5*partWidth)*(-4*255 + x * 255 / partWidth) + (x >= 5*partWidth)*(x < 6*partWidth)*255;
1023+       g = (x >= 0)*(x < partWidth)*(x * 255 / partWidth) + (x >= partWidth)*(x < 3*partWidth)*255     + (x >= 3*partWidth)*(x < 4*partWidth)*(4*255 - x * 255 / partWidth);
1024+       b = (x >= 2*partWidth)*(x < 3*partWidth)*(-2*255 + x * 255 / partWidth) + (x >= 3*partWidth)*(x < 5*partWidth)*255 + (x >= 5*partWidth)*(x < 6*partWidth)*(6*255 - x * 255 / partWidth);
1025+
1026+       coef = (imHeight - y) / imHeight;
1027+       r = 128 + (r - 128) * coef;
1028+       g = 128 + (g - 128) * coef;
1029+       b = 128 + (b - 128) * coef;
1030+
1031+       changeFinalColor('#' + dechex(r) + dechex(g) + dechex(b));
1032+       updateLight(r, g, b);
1033+}
1034+
1035+function updateLight(r, g, b) {
1036+       var i, partDetail = detail / 2, finalCoef, finalR, finalG, finalB, color;
1037+
1038+       for (i=0; i<detail; i++) {
1039+               if ((i>=0) && (i<partDetail)) {
1040+                       finalCoef = i / partDetail;
1041+                       finalR = dechex(255 - (255 - r) * finalCoef);
1042+                       finalG = dechex(255 - (255 - g) * finalCoef);
1043+                       finalB = dechex(255 - (255 - b) * finalCoef);
1044+               } else {
1045+                       finalCoef = 2 - i / partDetail;
1046+                       finalR = dechex(r * finalCoef);
1047+                       finalG = dechex(g * finalCoef);
1048+                       finalB = dechex(b * finalCoef);
1049+               }
1050+
1051+               color = finalR + finalG + finalB;
1052+
1053+               document.getElementById('gs' + i).style.backgroundColor = '#'+color;
1054+       }
1055+}
1056+
1057+function changeFinalColor(color) {
1058+       if (color.indexOf('#') == -1)
1059+               color = convertRGBToHex(color);
1060+
1061+       document.getElementById('preview').style.backgroundColor = color;
1062+       document.getElementById('color').value = color;
1063+}
1064+
1065+window.focus();
1066\ No newline at end of file
1067Index: themes/advanced/jscripts/link.js
1068===================================================================
1069--- themes/advanced/jscripts/link.js    (revision 5248)
1070+++ themes/advanced/jscripts/link.js    (working copy)
1071@@ -27,6 +27,7 @@
1072 
1073        document.forms[0].href.value = tinyMCE.getWindowArg('href') || 'http://';
1074        document.forms[0].href.select();
1075+       document.forms[0].href.focus();
1076        document.forms[0].linktitle.value = tinyMCE.getWindowArg('title');
1077        document.forms[0].insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true);
1078 
1079@@ -57,8 +58,8 @@
1080        var title = document.forms[0].linktitle.value;
1081        var style_class = document.forms[0].styleSelect ? document.forms[0].styleSelect.value : "";
1082        var dummy;
1083-
1084-       // Make anchors absolute
1085+       
1086+       // WordPress: Make anchors absolute;
1087        if (href.charAt(0) == '#')
1088                href = tinyMCE.settings['document_base_url'] + href;
1089 
1090Index: themes/advanced/langs/en.js
1091===================================================================
1092--- themes/advanced/langs/en.js (revision 5248)
1093+++ themes/advanced/langs/en.js (working copy)
1094@@ -78,5 +78,14 @@
1095 not_set : '-- Not set --',
1096 close : 'Close',
1097 toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X',
1098-invalid_data : 'Error: Invalid values entered, these are marked in red.'
1099+invalid_data : 'Error: Invalid values entered, these are marked in red.',
1100+more_colors : 'More colors',
1101+color_picker_tab : 'Picker',
1102+color_picker : 'Color picker',
1103+web_colors_tab : 'Web safe',
1104+web_colors : 'Web safe colors',
1105+named_colors_tab : 'Named',
1106+named_colors : 'Named colors',
1107+color : 'Color:',
1108+color_name : 'Name:'
1109 });
1110Index: themes/advanced/css/editor_ui.css
1111===================================================================
1112--- themes/advanced/css/editor_ui.css   (revision 5248)
1113+++ themes/advanced/css/editor_ui.css   (working copy)
1114@@ -11,7 +11,7 @@
1115 .mceToolbarTop, .mceToolbarBottom {background: #F0F0EE; line-height: 1px; font-size: 1px;}
1116 .mceToolbarTop {border-bottom: 1px solid #cccccc; padding-bottom: 1px;}
1117 .mceToolbarBottom {border-top: 1px solid #cccccc;}
1118-.mceToolbarContainer {position: relative; left: 0; top: 0; display: block;}
1119+.mceToolbarContainer {display: block; position: relative; left: 0; top: 0; width: 100%;}
1120 .mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {height: 20px;}
1121 .mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; padding: 2px; line-height: 16px; overflow: visible;}
1122 .mceStatusbarTop {border-bottom: 1px solid #cccccc;}
1123@@ -49,7 +49,7 @@
1124 
1125 /* Menu */
1126 
1127-.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 100; background-color: white; border: 1px solid gray; font-weight: normal;}
1128+.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 1000; background-color: white; border: 1px solid gray; font-weight: normal;}
1129 .mceMenu a, .mceMenuTitle, .mceMenuDisabled {display: block; width: 100%; text-decoration: none; background-color: white; font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 11px; line-height: 20px; color: black;}
1130 .mceMenu a:hover {background-color: #B6BDD2; color: black; text-decoration: none !important;}
1131 .mceMenu span {padding-left: 10px; padding-right: 10px; display: block; line-height: 20px;}
1132@@ -61,7 +61,7 @@
1133 span.mceMenuCheckItem {padding-left: 20px;}
1134 span.mceMenuLine {display: block; position: absolute; left: 0; top: -1px; background-color: #F5F4F2; width: 30px; height: 1px; overflow: hidden; padding-left: 0; padding-right: 0;}
1135 .mceColors table, .mceColors td {margin: 0; padding: 2px;}
1136-a.mceMoreColors {width: 130px; margin: 0; padding: 0; margin-left: 3px; margin-bottom: 3px; text-align: center; border: 1px solid white;}
1137+a.mceMoreColors {width: auto; padding: 0; margin: 0 3px 3px 3px; text-align: center; border: 1px solid white; text-decoration: none !important;}
1138 .mceColorPreview {position: absolute; overflow:hidden; left: 0; top: 0; margin-left: 3px; margin-top: 15px; width: 16px; height: 4px; background-color: red;}
1139 a.mceMoreColors:hover {border: 1px solid #0A246A;}
1140 .mceColors td a {width: 9px; height: 9px; overflow: hidden; border: 1px solid #808080;}
1141@@ -77,7 +77,7 @@
1142 * html .mceSelectList {margin-top: 2px;}
1143 * html span.mceMenuButton, * html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;}
1144 * html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {position: relative; top: 1px;}
1145-* html a.mceMoreColors {width: 132px;}
1146+* html a.mceMoreColors {width: auto;}
1147 * html .mceColors td a {width: 10px; height: 10px;}
1148 * html .mceColorPreview {margin-left: 2px; margin-top: 14px;}
1149 
1150@@ -92,6 +92,6 @@
1151 *:first-child+html .mceSelectList {margin-top: 2px;}
1152 *:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;}
1153 *:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative; top: 1px;}
1154-*:first-child+html a.mceMoreColors {width: 132px;}
1155+*:first-child+html a.mceMoreColors {width: 137px;}
1156 *:first-child+html .mceColors td a {width: 10px; height: 10px;}
1157 *:first-child+html .mceColorPreview {margin: 0; padding-left: 4px; margin-top: 14px; width: 14px;}
1158Index: themes/advanced/editor_template.js
1159===================================================================
1160--- themes/advanced/editor_template.js  (revision 5248)
1161+++ themes/advanced/editor_template.js  (working copy)
1162@@ -1,5 +1,5 @@
1163 /**
1164- * $Id: editor_template_src.js 166 2007-01-05 10:31:50Z spocke $
1165+ * $Id: editor_template_src.js 218 2007-02-13 11:08:01Z spocke $
1166  *
1167  * @author Moxiecode
1168  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
1169@@ -43,7 +43,9 @@
1170                ['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
1171                ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
1172                ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true],
1173+               ['forecolorpicker', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolorpicker', true],
1174                ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true],
1175+               ['backcolorpicker', 'backcolor.gif', 'lang_theme_backcolor_desc', 'backcolorpicker', true],
1176                ['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
1177                ['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
1178                ['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'],
1179@@ -356,6 +358,10 @@
1180 
1181                                return false;
1182 
1183+                       case "forecolorpicker":
1184+                               this._pickColor(editor_id, 'forecolor');
1185+                               return true;
1186+
1187                        case "forecolorMenu":
1188                                TinyMCE_AdvancedTheme._hideMenus(editor_id);
1189 
1190@@ -420,15 +426,21 @@
1191 
1192                                ml.show();
1193                        return true;
1194+       
1195+                       case "backcolorpicker":
1196+                               this._pickColor(editor_id, 'HiliteColor');
1197+                               return true;
1198 
1199                        case "mceColorPicker":
1200                                if (user_interface) {
1201-                                       var template = new Array();
1202-                                       var inputColor = value['document'].getElementById(value['element_id']).value;
1203+                                       var template = [];
1204+       
1205+                                       if (!value['callback'] && !value['color'])
1206+                                               value['color'] = value['document'].getElementById(value['element_id']).value;
1207 
1208                                        template['file'] = 'color_picker.htm';
1209-                                       template['width'] = 220;
1210-                                       template['height'] = 190;
1211+                                       template['width'] = 380;
1212+                                       template['height'] = 250;
1213                                        template['close_previous'] = "no";
1214 
1215                                        template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0);
1216@@ -438,10 +450,16 @@
1217                                                value['store_selection'] = true;
1218 
1219                                        tinyMCE.lastColorPickerValue = value;
1220-                                       tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor});
1221+                                       tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : value['color']});
1222                                } else {
1223-                                       var savedVal = tinyMCE.lastColorPickerValue;
1224-                                       var elm = savedVal['document'].getElementById(savedVal['element_id']);
1225+                                       var savedVal = tinyMCE.lastColorPickerValue, elm;
1226+
1227+                                       if (savedVal['callback']) {
1228+                                               savedVal['callback'](value);
1229+                                               return true;
1230+                                       }
1231+
1232+                                       elm = savedVal['document'].getElementById(savedVal['element_id']);
1233                                        elm.value = value;
1234 
1235                                        if (elm.onchange != null && elm.onchange != '')
1236@@ -599,9 +617,8 @@
1237                                // Setup template html
1238                                template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width_style};height:{$height_style}"><tbody>';
1239 
1240-                               if (toolbarLocation == "top") {
1241-                                       template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
1242-                               }
1243+                               if (toolbarLocation == "top")
1244+                                       template['html'] += '<tr><td dir="ltr" class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
1245 
1246                                if (statusbarLocation == "top") {
1247                                        template['html'] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>';
1248@@ -610,9 +627,8 @@
1249 
1250                                template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';
1251 
1252-                               if (toolbarLocation == "bottom") {
1253-                                       template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
1254-                               }
1255+                               if (toolbarLocation == "bottom")
1256+                                       template['html'] += '<tr><td dir="ltr" class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
1257 
1258                                // External toolbar changes
1259                                if (toolbarLocation == "external") {
1260@@ -738,9 +754,12 @@
1261        },
1262 
1263        removeInstance : function(inst) {
1264-               var fcm = new TinyMCE_Layer(inst.editorId + '_fcMenu');
1265+               new TinyMCE_Layer(inst.editorId + '_fcMenu').remove();
1266+               new TinyMCE_Layer(inst.editorId + '_bcMenu').remove();
1267+       },
1268 
1269-               fcm.remove();
1270+       hideInstance : function(inst) {
1271+               TinyMCE_AdvancedTheme._hideMenus(inst.editorId);
1272        },
1273 
1274        _handleMenuEvent : function(e) {
1275@@ -1378,13 +1397,27 @@
1276                }
1277 
1278                h += '</tr></table>';
1279-               /*
1280-               h += '<a href="" class="mceMoreColors">More colors</a>';
1281-               */
1282 
1283+               if (tinyMCE.getParam("theme_advanced_more_colors", true))
1284+                       h += '<a href="#" onclick="TinyMCE_AdvancedTheme._pickColor(\'' + id + '\',\'' + cm + '\');" class="mceMoreColors">' + tinyMCE.getLang('lang_more_colors') + '</a>';
1285+
1286                return h;
1287        },
1288 
1289+       _pickColor : function(id, cm) {
1290+               var inputColor, inst = tinyMCE.selectedInstance;
1291+
1292+               if (cm == 'forecolor' && inst)
1293+                       inputColor = inst.foreColor;
1294+
1295+               if ((cm == 'backcolor' || cm == 'HiliteColor') && inst)
1296+                       inputColor = inst.backColor;
1297+
1298+               tinyMCE.execCommand('mceColorPicker', true, {color : inputColor, callback : function(c) {
1299+                       tinyMCE.execInstanceCommand(id, cm, false, c);
1300+               }});
1301+       },
1302+
1303        _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
1304                tinyMCE.execCommand('mceBeginUndoLevel');
1305