Make WordPress Core

Ticket #3788: 3788.3.diff

File 3788.3.diff, 53.9 KB (added by rob1n, 18 years ago)

My latest patch

  • wp-includes/js/tinymce/plugins/directionality/editor_plugin.js

     
    11/**
    2  * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $
     2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
    33 *
    44 * @author Moxiecode
    55 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
     
    1414                        longname : 'Directionality',
    1515                        author : 'Moxiecode Systems AB',
    1616                        authorurl : 'http://tinymce.moxiecode.com',
    17                         infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
     17                        infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',
    1818                        version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
    1919                };
    2020        },
  • wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js

     
    11/**
    2  * $Id: editor_plugin_src.js 172 2007-01-09 11:37:11Z spocke $
     2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
    33 *
    44 * Moxiecode DHTML Windows script.
    55 *
     
    1515                        longname : 'Inline Popups',
    1616                        author : 'Moxiecode Systems AB',
    1717                        authorurl : 'http://tinymce.moxiecode.com',
    18                         infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',
     18                        infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',
    1919                        version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
    2020                };
    2121        }
     
    2626// Patch openWindow, closeWindow TinyMCE functions
    2727
    2828TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow;
     29TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
    2930
    3031TinyMCE_Engine.prototype.openWindow = function(template, args) {
    3132        // Does the caller support inline
     
    5253        if (!(height = parseInt(template['height'])))
    5354                height = 200;
    5455
     56        if (!(minWidth = parseInt(template['minWidth'])))
     57                minWidth = 100;
     58
     59        if (!(minHeight = parseInt(template['minHeight'])))
     60                minHeight = 100;
     61
    5562        resizable = (args && args['resizable']) ? args['resizable'] : "no";
    5663        scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
    5764
     
    7683        pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2));
    7784        pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2));
    7885
    79         url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; // WordPress cache buster
    80 
    81         mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop);
     86        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 );
    8287};
    8388
    84 TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
    85 
    8689TinyMCE_Engine.prototype.closeWindow = function(win) {
    87         if (mcWindows.selectedWindow != null)
    88                 mcWindows.selectedWindow.close();
    89         else
     90        var gotit = false, n, w;
     91        for (n in mcWindows.windows) {
     92                w = mcWindows.windows[n];
     93                if (typeof(w) == 'function') continue;
     94                if (win.name == w.id + '_iframe') {
     95                        w.close();
     96                        gotit = true;
     97                }
     98        }
     99        if (!gotit)
    90100                this.orgCloseWindow(win);
     101
     102        tinyMCE.selectedInstance.getWin().focus();
    91103};
    92104
    93105TinyMCE_Engine.prototype.setWindowTitle = function(win_ref, title) {
     
    135147
    136148        this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
    137149
     150        this.addEvent(window, "resize", mcWindows.eventDispatcher);
     151        this.addEvent(document, "scroll", mcWindows.eventDispatcher);
     152
    138153        this.doc = document;
    139154};
    140155
     156TinyMCE_Windows.prototype.getBounds = function() {
     157        if (!this.bounds) {
     158                var vp = tinyMCE.getViewPort(window);
     159                var top, left, bottom, right, docEl = this.doc.documentElement;
     160
     161                top    = vp.top;
     162                left   = vp.left;
     163                bottom = vp.height + top - 2;
     164                right  = vp.width  + left - 22; // TODO this number is platform dependant
     165                // x1, y1, x2, y2
     166                this.bounds = [left, top, right, bottom];
     167        }
     168        return this.bounds;
     169};
     170
     171TinyMCE_Windows.prototype.clampBoxPosition = function(x, y, w, h, minW, minH) {
     172        var bounds = this.getBounds();
     173
     174        x = Math.max(bounds[0], Math.min(bounds[2], x + w) - w);
     175        y = Math.max(bounds[1], Math.min(bounds[3], y + h) - h);
     176
     177        return this.clampBoxSize(x, y, w, h, minW, minH);
     178};
     179
     180TinyMCE_Windows.prototype.clampBoxSize = function(x, y, w, h, minW, minH) {
     181        var bounds = this.getBounds();
     182
     183        return [
     184                x, y,
     185                Math.max(minW, Math.min(bounds[2], x + w) - x),
     186                Math.max(minH, Math.min(bounds[3], y + h) - y)
     187        ];
     188};
     189
    141190TinyMCE_Windows.prototype.getParam = function(name, default_value) {
    142191        var value = null;
    143192
     
    186235                case "focus":
    187236                        mcWindows.selectedWindow.onFocus(e);
    188237                        break;
     238                case "scroll":
     239                case "resize":
     240                        if (mcWindows.clampUpdateTimeout)
     241                                clearTimeout(mcWindows.clampUpdateTimeout);
     242                        mcWindows.clampEventType = e.type;
     243                        mcWindows.clampUpdateTimeout =
     244                                setTimeout(function () {mcWindows.updateClamping()}, 100);
     245                        break;
    189246        }
    190247};
    191248
     249TinyMCE_Windows.prototype.updateClamping = function () {
     250        var clamp, oversize, etype = mcWindows.clampEventType;
     251
     252        this.bounds = null; // Recalc window bounds on resize/scroll
     253        this.clampUpdateTimeout = null;
     254
     255        for (var n in this.windows) {
     256                win = this.windows[n];
     257                if (typeof(win) == 'function' || ! win.winElement) continue;
     258
     259                clamp = mcWindows.clampBoxPosition(
     260                        win.left, win.top,
     261                        win.winElement.scrollWidth,
     262                        win.winElement.scrollHeight,
     263                        win.features.minWidth,
     264                        win.features.minHeight
     265                );
     266                oversize = (
     267                        clamp[2] != win.winElement.scrollWidth ||
     268                        clamp[3] != win.winElement.scrollHeight
     269                ) ? true : false;
     270
     271                if (!oversize || win.features.resizable == "yes" || etype != "scroll")
     272                        win.moveTo(clamp[0], clamp[1]);
     273                if (oversize && win.features.resizable == "yes")
     274                        win.resizeTo(clamp[2], clamp[3]);
     275        }
     276};
     277
    192278TinyMCE_Windows.prototype.addEvent = function(obj, name, handler) {
    193279        if (this.isMSIE)
    194280                obj.attachEvent("on" + name, handler);
    195281        else
    196                 obj.addEventListener(name, handler, true);
     282                obj.addEventListener(name, handler, false);
    197283};
    198284
    199285TinyMCE_Windows.prototype.cancelEvent = function(e) {
     
    217303        options['top'] = "10";
    218304        options['width'] = "300";
    219305        options['height'] = "300";
     306        options['minwidth'] = "100";
     307        options['minheight'] = "100";
    220308        options['resizable'] = "yes";
    221309        options['minimizable'] = "yes";
    222310        options['maximizable'] = "yes";
     
    240328        options['top'] = parseInt(options['top']);
    241329        options['width'] = parseInt(options['width']);
    242330        options['height'] = parseInt(options['height']);
     331        options['minWidth'] = parseInt(options['minwidth']);
     332        options['minHeight'] = parseInt(options['minheight']);
    243333
    244334        return options;
    245335};
     
    253343
    254344        features = this.parseFeatures(features);
    255345
     346        // Clamp specified dimensions
     347        var clamp = mcWindows.clampBoxPosition(
     348                features['left'], features['top'],
     349                features['width'], features['height'],
     350                features['minWidth'], features['minHeight']
     351        );
     352
     353        features['left'] = clamp[0];
     354        features['top'] = clamp[1];
     355
     356        if (features['resizable'] == "yes") {
     357                features['width'] = clamp[2];
     358                features['height'] = clamp[3];
     359        }
     360
    256361        // Create div
    257362        id = "mcWindow_" + name;
    258363        win.deltaHeight = 18;
     
    285390        html += '<html>';
    286391        html += '<head>';
    287392        html += '<title>Wrapper iframe</title>';
     393        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>';
    288394        html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
    289395        html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />';
    290         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>';
    291396        html += '</head>';
    292397        html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
    293398
     
    297402        html += '  onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';
    298403        html += '    <div class="mceWindowHeadTools">';
    299404        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>';
    300 //      html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"></a>';
    301 //      html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
     405        if (features['resizable'] == "yes" && features['maximizable'] == "yes")
     406                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>';
     407        // html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
    302408        html += '    </div>';
    303409        html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
    304410        html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe" scrolling="' + features['scrollbars'] + '"></iframe></div>';
     
    447553        div.setAttribute("width", width);
    448554        div.setAttribute("height", (height));
    449555        div.style.position = "absolute";
     556
    450557        div.style.left = left + "px";
    451558        div.style.top = top + "px";
    452559        div.style.width = width + "px";
     
    473580        iframe.setAttribute("topMargin", "0");
    474581        iframe.setAttribute("width", iframeWidth);
    475582        iframe.setAttribute("height", iframeHeight);
    476 //      iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
     583        // iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
    477584        // iframe.setAttribute("allowtransparency", "false");
    478585        iframe.setAttribute("scrolling", "no");
    479586        iframe.style.width = iframeWidth + "px";
     
    522629};
    523630
    524631TinyMCE_Window.prototype.maximize = function() {
    525        
     632        if (this.restoreSize) {
     633                this.moveTo(this.restoreSize[0], this.restoreSize[1]);
     634                this.resizeTo(this.restoreSize[2], this.restoreSize[3]);
     635                this.updateClamping();
     636                this.restoreSize = null;
     637        } else {
     638                var bounds = mcWindows.getBounds();
     639                this.restoreSize = [
     640                        this.left, this.top,
     641                        this.winElement.scrollWidth,
     642                        this.winElement.scrollHeight
     643                ];
     644                this.moveTo(bounds[0], bounds[1]);
     645                this.resizeTo(
     646                        bounds[2] - bounds[0],
     647                        bounds[3] - bounds[1]
     648                );
     649        }
    526650};
    527651
    528652TinyMCE_Window.prototype.startResize = function() {
     
    552676
    553677        mcWindows.windows = mcWindowsNew;
    554678
    555 //      alert(mcWindows.doc.getElementById(this.id + "_iframe"));
     679        // alert(mcWindows.doc.getElementById(this.id + "_iframe"));
    556680
    557681        var e = mcWindows.doc.getElementById(this.id + "_iframe");
    558682        e.parentNode.removeChild(e);
     
    561685        e.parentNode.removeChild(e);
    562686
    563687        mcWindows.setDocumentLock(false);
    564 
     688       
    565689        tinyMCE.selectedInstance.getWin().focus(); // WordPress: focus on the editor after closing a popup
    566690};
    567691
    568692TinyMCE_Window.prototype.onMouseMove = function(e) {
    569         var scrollX = 0;//this.doc.body.scrollLeft;
    570         var scrollY = 0;//this.doc.body.scrollTop;
    571 
     693        var clamp;
    572694        // Calculate real X, Y
    573695        var dx = e.screenX - mcWindows.mouseDownScreenX;
    574696        var dy = e.screenY - mcWindows.mouseDownScreenY;
    575697
    576698        switch (mcWindows.action) {
    577699                case "resize":
    578                         width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);
    579                         height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);
     700                        clamp = mcWindows.clampBoxSize(
     701                                this.left, this.top,
     702                                mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX),
     703                                mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY),
     704                                this.features.minWidth, this.features.minHeight
     705                        );
    580706
    581                         width = width < 100 ? 100 : width;
    582                         height = height < 100 ? 100 : height;
     707                        this.resizeTo(clamp[2], clamp[3]);
    583708
    584                         this.wrapperIFrameElement.style.width = (width+2) + 'px';
    585                         this.wrapperIFrameElement.style.height = (height+2) + 'px';
    586                         this.wrapperIFrameElement.width = width+2;
    587                         this.wrapperIFrameElement.height = height+2;
    588                         this.winElement.style.width = width + 'px';
    589                         this.winElement.style.height = height + 'px';
    590 
    591                         height = height - this.deltaHeight;
    592 
    593                         this.containerElement.style.width = width + 'px';
    594                         this.iframeElement.style.width = width + 'px';
    595                         this.iframeElement.style.height = height + 'px';
    596                         this.bodyElement.style.width = width + 'px';
    597                         this.bodyElement.style.height = height + 'px';
    598                         this.headElement.style.width = width + 'px';
    599                         //this.statusElement.style.width = width + 'px';
    600 
    601709                        mcWindows.cancelEvent(e);
    602710                        break;
    603711
    604712                case "move":
    605713                        this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
    606714                        this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
    607                         this.winElement.style.left = this.left + "px";
    608                         this.winElement.style.top = this.top + "px";
     715                        this.updateClamping();
    609716
    610717                        mcWindows.cancelEvent(e);
    611718                        break;
    612719        }
    613720};
    614721
     722TinyMCE_Window.prototype.moveTo = function (x, y) {
     723        this.left = x;
     724        this.top = y;
     725
     726        this.winElement.style.left = this.left + "px";
     727        this.winElement.style.top = this.top + "px";
     728};
     729
     730TinyMCE_Window.prototype.resizeTo = function (width, height) {
     731        this.wrapperIFrameElement.style.width = (width+2) + 'px';
     732        this.wrapperIFrameElement.style.height = (height+2) + 'px';
     733        this.wrapperIFrameElement.width = width+2;
     734        this.wrapperIFrameElement.height = height+2;
     735        this.winElement.style.width = width + 'px';
     736        this.winElement.style.height = height + 'px';
     737
     738        height = height - this.deltaHeight;
     739
     740        this.containerElement.style.width = width + 'px';
     741        this.iframeElement.style.width = width + 'px';
     742        this.iframeElement.style.height = height + 'px';
     743        this.bodyElement.style.width = width + 'px';
     744        this.bodyElement.style.height = height + 'px';
     745        this.headElement.style.width = width + 'px';
     746        //this.statusElement.style.width = width + 'px';
     747};
     748
     749TinyMCE_Window.prototype.updateClamping = function () {
     750        var clamp, oversize;
     751
     752        clamp = mcWindows.clampBoxPosition(
     753                this.left, this.top,
     754                this.winElement.scrollWidth,
     755                this.winElement.scrollHeight,
     756                this.features.minWidth, this.features.minHeight
     757        );
     758        oversize = (
     759                clamp[2] != this.winElement.scrollWidth ||
     760                clamp[3] != this.winElement.scrollHeight
     761        ) ? true : false;
     762
     763        this.moveTo(clamp[0], clamp[1]);
     764        if (this.features.resizable == "yes" && oversize)
     765                this.resizeTo(clamp[2], clamp[3]);
     766};
     767
    615768function debug(msg) {
    616769        document.getElementById('debug').value += msg + "\n";
    617770}
     
    639792TinyMCE_Window.prototype.onMouseDown = function(e) {
    640793        var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
    641794
    642         var scrollX = 0;//this.doc.body.scrollLeft;
    643         var scrollY = 0;//this.doc.body.scrollTop;
    644 
    645795        mcWindows.mouseDownScreenX = e.screenX;
    646796        mcWindows.mouseDownScreenY = e.screenY;
    647797        mcWindows.mouseDownLayerX = this.left;
  • wp-includes/js/tinymce/plugins/autosave/editor_plugin.js

     
    11/**
    2  * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $
     2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
    33 *
    44 * @author Moxiecode
    55 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
     
    1414                        longname : 'Auto save',
    1515                        author : 'Moxiecode Systems AB',
    1616                        authorurl : 'http://tinymce.moxiecode.com',
    17                         infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',
     17                        infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
    1818                        version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
    1919                };
    2020        },
  • wp-includes/js/tinymce/plugins/paste/editor_plugin.js

     
    11/**
    2  * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $
     2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
    33 *
    44 * @author Moxiecode
    55 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
     
    1414                        longname : 'Paste text/word',
    1515                        author : 'Moxiecode Systems AB',
    1616                        authorurl : 'http://tinymce.moxiecode.com',
    17                         infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',
     17                        infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',
    1818                        version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
    1919                };
    2020        },
     
    2424                        tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent);
    2525        },
    2626
     27        handleEvent : function(e) {
     28                // Force paste dialog if non IE browser
     29                if (!tinyMCE.isRealIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false) && e.ctrlKey && e.keyCode == 86 && e.type == "keydown") {
     30                        window.setTimeout('tinyMCE.selectedInstance.execCommand("mcePasteText",true)', 1);
     31                        return tinyMCE.cancelEvent(e);
     32                }
     33
     34                return true;
     35        },
     36
    2737        getControlHTML : function(cn) {
    2838                switch (cn) {
    2939                        case "pastetext":
  • wp-includes/js/tinymce/tiny_mce.js

     
    55        var ua;
    66
    77        this.majorVersion = "2";
    8         this.minorVersion = "0.9";
    9         this.releaseDate = "2007-01-09";
     8        this.minorVersion = "1.0";
     9        this.releaseDate = "2007-02-13";
    1010
    1111        this.instances = new Array();
    1212        this.switchClassCache = new Array();
     
    186186                this._def("custom_shortcuts", true);
    187187                this._def("convert_on_click", false);
    188188                this._def("content_css", '');
    189                 this._def("fix_list_elements", false);
     189                this._def("fix_list_elements", true);
    190190                this._def("fix_table_elements", false);
    191191                this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml');
    192192                this._def("hidden_tab_class", '');
     
    241241                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';
    242242                this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i");
    243243                this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
    244                 this.uniqueURL = 'javascript:TINYMCE_UNIQUEURL();'; // Make unique URL non real URL
     244                this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL
    245245                this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
    246246                this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance');
    247247
     
    740740                                tinyMCE.removeMCEControl(value);
    741741                                return;
    742742
     743                        case "mceToggleEditor":
     744                                var inst = tinyMCE.getInstanceById(value), pe, te;
     745
     746                                if (inst) {
     747                                        pe = document.getElementById(inst.editorId + '_parent');
     748                                        te = inst.oldTargetElement;
     749
     750                                        if (typeof(inst.enabled) == 'undefined')
     751                                                inst.enabled = true;
     752
     753                                        inst.enabled = !inst.enabled;
     754
     755                                        if (!inst.enabled) {
     756                                                pe.style.display = 'none';
     757                                                te.value = inst.getHTML();
     758                                                te.style.display = inst.oldTargetDisplay;
     759                                                tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst);
     760                                        } else {
     761                                                pe.style.display = 'block';
     762                                                te.style.display = 'none';
     763                                                inst.setHTML(te.value);
     764                                                inst.useCSS = false;
     765                                                tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst);
     766                                        }
     767                                } else
     768                                        tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
     769
     770                                return;
     771
    743772                        case "mceResetDesignMode":
    744773                                // Resets the designmode state of the editors in Gecko
    745774                                if (!tinyMCE.isIE) {
     
    961990                // Fix for bug #957681
    962991                //inst.getDoc().designMode = inst.getDoc().designMode;
    963992
    964                 // Setup element references
    965                 var parentElm = inst.targetDoc.getElementById(inst.editorId + '_parent');
    966                 inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
    967 
    968993                tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst);
    969994                tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
    970995
     
    14451470                        h += '</a></span>';
    14461471                } else {
    14471472                        if (tinyMCE.isRealIE)
    1448                                 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
     1473                                h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
    14491474                        else
    1450                                 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
     1475                                h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton">';
    14511476
    14521477                        h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';
    14531478                        h += '<img src="' + img + '" title="{$' + lang + '}" /></a>';
     
    16931718        },
    16941719
    16951720        triggerNodeChange : function(focus, setup_content) {
    1696                 var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false;
     1721                var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false, st;
    16971722
    16981723                if (tinyMCE.selectedInstance) {
    16991724                        inst = tinyMCE.selectedInstance;
     
    17051730                        inst.lastTriggerEl = elm;*/
    17061731
    17071732                        editorId = inst.editorId;
    1708                         selectedText = inst.selection.getSelectedText();
     1733                        st = inst.selection.getSelectedText();
    17091734
    17101735                        if (tinyMCE.settings.auto_resize)
    17111736                                inst.resizeToContent();
     
    17161741                        inst.switchSettings();
    17171742
    17181743                        if (tinyMCE.selectedElement)
    1719                                 anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
     1744                                anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 0);
    17201745
    17211746                        if (tinyMCE.settings['custom_undo_redo']) {
    17221747                                undoIndex = inst.undoRedo.undoIndex;
     
    21802205        },
    21812206
    21822207        getCSSClasses : function(editor_id, doc) {
    2183                 var output = new Array();
     2208                var inst = tinyMCE.getInstanceById(editor_id);
    21842209
    21852210                // Is cached, use that
    2186                 if (typeof(tinyMCE.cssClasses) != "undefined")
    2187                         return tinyMCE.cssClasses;
     2211                if (inst && inst.cssClasses.length > 0)
     2212                        return inst.cssClasses;
    21882213
    21892214                if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") {
    21902215                        var instance;
     
    22422267                                                                        var cssClass = rule.substring(rule.indexOf('.') + 1);
    22432268                                                                        var addClass = true;
    22442269
    2245                                                                         for (var p=0; p<output.length && addClass; p++) {
    2246                                                                                 if (output[p] == cssClass)
     2270                                                                        for (var p=0; p<inst.cssClasses.length && addClass; p++) {
     2271                                                                                if (inst.cssClasses[p] == cssClass)
    22472272                                                                                        addClass = false;
    22482273                                                                        }
    22492274
    22502275                                                                        if (addClass)
    2251                                                                                 output[output.length] = cssClass;
     2276                                                                                inst.cssClasses[inst.cssClasses.length] = cssClass;
    22522277                                                                }
    22532278                                                        }
    22542279                                                }
     
    22572282                        }
    22582283                }
    22592284
    2260                 // Cache em
    2261                 if (output.length > 0)
    2262                         tinyMCE.cssClasses = output;
    2263 
    2264                 return output;
     2285                return inst.cssClasses;
    22652286        },
    22662287
    22672288        regexpReplace : function(in_str, reg_exp, replace_str, opts) {
     
    22892310        },
    22902311
    22912312        getControlHTML : function(c) {
    2292                 var i, l, n, o, v;
     2313                var i, l, n, o, v, rtl = tinyMCE.getLang('lang_dir') == 'rtl';
    22932314
    22942315                l = tinyMCE.plugins;
    22952316                for (n in l) {
    22962317                        o = l[n];
    22972318
    2298                         if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
     2319                        if (o.getControlHTML && (v = o.getControlHTML(c)) != '') {
     2320                                if (rtl)
     2321                                        return '<span dir="rtl">' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + '</span>';
     2322
    22992323                                return tinyMCE.replaceVar(v, "pluginurl", o.baseURL);
     2324                        }
    23002325                }
    23012326
    23022327                o = tinyMCE.themes[tinyMCE.settings['theme']];
    2303                 if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
     2328                if (o.getControlHTML && (v = o.getControlHTML(c)) != '') {
     2329                        if (rtl)
     2330                                return '<span dir="rtl">' + v + '</span>';
     2331
    23042332                        return v;
     2333                }
    23052334
    23062335                return '';
    23072336        },
     
    24332462        this.hasMouseMoved = false;
    24342463        this.foreColor = this.backColor = "#999999";
    24352464        this.data = {};
     2465        this.cssClasses = [];
    24362466
    24372467        this.cleanup.init({
    24382468                valid_elements : s.valid_elements,
     
    28652895                                if (tinyMCE.isGecko && this.getSel().isCollapsed) {
    28662896                                        focusElm = tinyMCE.getParentElement(focusElm, 'A');
    28672897
    2868                                         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
     2898                                        if (focusElm)
    28692899                                                this.selection.selectNode(focusElm, false);
    28702900                                }
    28712901
     
    36903720                                hc = '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>';
    36913721                        } else {
    36923722                                hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />';
     3723                                this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
    36933724                                this.oldTargetElement.style.display = "none";
    36943725                        }
    36953726
     
    37153746                        // Just hide the textarea element
    37163747                        this.oldTargetElement = replace_element;
    37173748
    3718                         if (!tinyMCE.settings['debug'])
     3749                        if (!tinyMCE.settings['debug']) {
     3750                                this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
    37193751                                this.oldTargetElement.style.display = "none";
     3752                        }
    37203753
    37213754                        // Output HTML and set editable
    37223755                        if (tinyMCE.isGecko) {
     
    37903823                if (tinyMCE.isIE)
    37913824                        window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1);
    37923825
     3826                // Setup element references
     3827                var parentElm = this.targetDoc.getElementById(this.editorId + '_parent');
     3828                this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
     3829
    37933830                tinyMCE.setupContent(this.editorId, true);
    37943831
    37953832                return true;
     
    48654902                if (r.forceAttribs && (t = r.forceAttribs[an]))
    48664903                        av = t;
    48674904
    4868                 if (os && av.length != 0 && this.settings.url_converter.length != 0 && /^(src|href|longdesc)$/.test(an))
     4905                if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an))
    48694906                        av = this._urlConverter(this, n, av);
    48704907
    48714908                if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av))
     
    51865223
    51875224        // Convert all strong/em to b/i in Gecko
    51885225        if (tinyMCE.isGecko) {
    5189                 h = h.replace(/<strong/gi, '<b');
    5190                 h = h.replace(/<em(\/?)/gi, '<i');
    5191                 h = h.replace(/<em /gi, '<i');
     5226                h = h.replace(/<embed([^>]*)>/gi, '<tmpembed$1>');
     5227                h = h.replace(/<em([^>]*)>/gi, '<i$1>');
     5228                h = h.replace(/<tmpembed([^>]*)>/gi, '<embed$1>');
     5229                h = h.replace(/<strong([^>]*)>/gi, '<b$1>');
    51925230                h = h.replace(/<\/strong>/gi, '</b>');
    51935231                h = h.replace(/<\/em>/gi, '</i>');
    51945232        }
     
    55035541        };
    55045542};
    55055543
     5544TinyMCE_Engine.prototype.getStyle = function(n, na, d) {
     5545        if (!n)
     5546                return false;
     5547
     5548        // Gecko
     5549        if (tinyMCE.isGecko && n.ownerDocument.defaultView) {
     5550                try {
     5551                        return n.ownerDocument.defaultView.getComputedStyle(n, null).getPropertyValue(na);
     5552                } catch (n) {
     5553                        // Old safari might fail
     5554                        return null;
     5555                }
     5556        }
     5557
     5558        // Camelcase it, if needed
     5559        na = na.replace(/-(\D)/g, function(a, b){
     5560                return b.toUpperCase();
     5561        });
     5562
     5563        // IE & Opera
     5564        if (n.currentStyle)
     5565                return n.currentStyle[na];
     5566
     5567        return false;
     5568};
     5569
    55065570/* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */
    55075571
    55085572TinyMCE_Engine.prototype.parseURL = function(url_str) {
     
    71327196        },
    71337197
    71347198        show : function() {
    7135                 this.getElement().style.display = 'block';
    7136                 this.updateBlocker();
     7199                var el = this.getElement();
     7200
     7201                if (el) {
     7202                        el.style.display = 'block';
     7203                        this.updateBlocker();
     7204                }
    71377205        },
    71387206
    71397207        hide : function() {
    7140                 this.getElement().style.display = 'none';
    7141                 this.updateBlocker();
     7208                var el = this.getElement();
     7209
     7210                if (el) {
     7211                        el.style.display = 'none';
     7212                        this.updateBlocker();
     7213                }
    71427214        },
    71437215
    71447216        isVisible : function() {
  • wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js

     
    1 function init() {
    2         if (tinyMCE.isMSIE)
    3                 tinyMCEPopup.resizeToInnerSize();
    4 }
     1var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false;
    52
    6 function selectColor() {
    7         var color = document.getElementById("selectedColorBox").value;
    8 
    9         tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color);
    10         tinyMCEPopup.close();
    11 }
    12 
    13 function showColor(color) {
    14         document.getElementById("selectedColor").style.backgroundColor = color;
    15         document.getElementById("selectedColorBox").value = color;
    16 }
    17 
    183var colors = new Array(
    194        "#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033",
    205        "#330066","#330099","#3300cc","#3300ff","#660000","#660033","#660066","#660099",
     
    4530        "#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff"
    4631);
    4732
     33var named = {
     34        '#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige',
     35        '#FFE4C4':'Bisque','#000000':'Black','#FFEBCD':'BlanchedAlmond','#0000FF':'Blue','#8A2BE2':'BlueViolet','#A52A2A':'Brown',
     36        '#DEB887':'BurlyWood','#5F9EA0':'CadetBlue','#7FFF00':'Chartreuse','#D2691E':'Chocolate','#FF7F50':'Coral','#6495ED':'CornflowerBlue',
     37        '#FFF8DC':'Cornsilk','#DC143C':'Crimson','#00FFFF':'Cyan','#00008B':'DarkBlue','#008B8B':'DarkCyan','#B8860B':'DarkGoldenRod',
     38        '#A9A9A9':'DarkGray','#A9A9A9':'DarkGrey','#006400':'DarkGreen','#BDB76B':'DarkKhaki','#8B008B':'DarkMagenta','#556B2F':'DarkOliveGreen',
     39        '#FF8C00':'Darkorange','#9932CC':'DarkOrchid','#8B0000':'DarkRed','#E9967A':'DarkSalmon','#8FBC8F':'DarkSeaGreen','#483D8B':'DarkSlateBlue',
     40        '#2F4F4F':'DarkSlateGray','#2F4F4F':'DarkSlateGrey','#00CED1':'DarkTurquoise','#9400D3':'DarkViolet','#FF1493':'DeepPink','#00BFFF':'DeepSkyBlue',
     41        '#696969':'DimGray','#696969':'DimGrey','#1E90FF':'DodgerBlue','#B22222':'FireBrick','#FFFAF0':'FloralWhite','#228B22':'ForestGreen',
     42        '#FF00FF':'Fuchsia','#DCDCDC':'Gainsboro','#F8F8FF':'GhostWhite','#FFD700':'Gold','#DAA520':'GoldenRod','#808080':'Gray','#808080':'Grey',
     43        '#008000':'Green','#ADFF2F':'GreenYellow','#F0FFF0':'HoneyDew','#FF69B4':'HotPink','#CD5C5C':'IndianRed','#4B0082':'Indigo','#FFFFF0':'Ivory',
     44        '#F0E68C':'Khaki','#E6E6FA':'Lavender','#FFF0F5':'LavenderBlush','#7CFC00':'LawnGreen','#FFFACD':'LemonChiffon','#ADD8E6':'LightBlue',
     45        '#F08080':'LightCoral','#E0FFFF':'LightCyan','#FAFAD2':'LightGoldenRodYellow','#D3D3D3':'LightGray','#D3D3D3':'LightGrey','#90EE90':'LightGreen',
     46        '#FFB6C1':'LightPink','#FFA07A':'LightSalmon','#20B2AA':'LightSeaGreen','#87CEFA':'LightSkyBlue','#778899':'LightSlateGray','#778899':'LightSlateGrey',
     47        '#B0C4DE':'LightSteelBlue','#FFFFE0':'LightYellow','#00FF00':'Lime','#32CD32':'LimeGreen','#FAF0E6':'Linen','#FF00FF':'Magenta','#800000':'Maroon',
     48        '#66CDAA':'MediumAquaMarine','#0000CD':'MediumBlue','#BA55D3':'MediumOrchid','#9370D8':'MediumPurple','#3CB371':'MediumSeaGreen','#7B68EE':'MediumSlateBlue',
     49        '#00FA9A':'MediumSpringGreen','#48D1CC':'MediumTurquoise','#C71585':'MediumVioletRed','#191970':'MidnightBlue','#F5FFFA':'MintCream','#FFE4E1':'MistyRose','#FFE4B5':'Moccasin',
     50        '#FFDEAD':'NavajoWhite','#000080':'Navy','#FDF5E6':'OldLace','#808000':'Olive','#6B8E23':'OliveDrab','#FFA500':'Orange','#FF4500':'OrangeRed','#DA70D6':'Orchid',
     51        '#EEE8AA':'PaleGoldenRod','#98FB98':'PaleGreen','#AFEEEE':'PaleTurquoise','#D87093':'PaleVioletRed','#FFEFD5':'PapayaWhip','#FFDAB9':'PeachPuff',
     52        '#CD853F':'Peru','#FFC0CB':'Pink','#DDA0DD':'Plum','#B0E0E6':'PowderBlue','#800080':'Purple','#FF0000':'Red','#BC8F8F':'RosyBrown','#4169E1':'RoyalBlue',
     53        '#8B4513':'SaddleBrown','#FA8072':'Salmon','#F4A460':'SandyBrown','#2E8B57':'SeaGreen','#FFF5EE':'SeaShell','#A0522D':'Sienna','#C0C0C0':'Silver',
     54        '#87CEEB':'SkyBlue','#6A5ACD':'SlateBlue','#708090':'SlateGray','#708090':'SlateGrey','#FFFAFA':'Snow','#00FF7F':'SpringGreen',
     55        '#4682B4':'SteelBlue','#D2B48C':'Tan','#008080':'Teal','#D8BFD8':'Thistle','#FF6347':'Tomato','#40E0D0':'Turquoise','#EE82EE':'Violet',
     56        '#F5DEB3':'Wheat','#FFFFFF':'White','#F5F5F5':'WhiteSmoke','#FFFF00':'Yellow','#9ACD32':'YellowGreen'
     57};
     58
     59function init() {
     60        var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color'));
     61
     62        if (tinyMCE.isMSIE)
     63                tinyMCEPopup.resizeToInnerSize();
     64
     65        generatePicker();
     66
     67        if (inputColor) {
     68                changeFinalColor(inputColor);
     69
     70                col = convertHexToRGB(inputColor);
     71
     72                if (col)
     73                        updateLight(col.r, col.g, col.b);
     74        }
     75}
     76
     77function insertAction() {
     78        var color = document.getElementById("color").value;
     79
     80        tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color);
     81        tinyMCEPopup.close();
     82}
     83
     84function showColor(color, name) {
     85        if (name)
     86                document.getElementById("colorname").innerHTML = name;
     87
     88        document.getElementById("preview").style.backgroundColor = color;
     89        document.getElementById("color").value = color;
     90}
     91
    4892function convertRGBToHex(col) {
    4993        var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
    5094
     95        if (!col)
     96                return col;
     97
    5198        var rgb = col.replace(re, "$1,$2,$3").split(',');
    5299        if (rgb.length == 3) {
    53100                r = parseInt(rgb[0]).toString(16);
     
    72119                g = parseInt(col.substring(2, 4), 16);
    73120                b = parseInt(col.substring(4, 6), 16);
    74121
    75                 return "rgb(" + r + "," + g + "," + b + ")";
     122                return {r : r, g : g, b : b};
    76123        }
    77124
    78         return col;
     125        return null;
    79126}
    80127
    81 function renderColorMap() {
    82         var html = "";
    83         var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color'));
     128function generatePicker() {
     129        var el = document.getElementById('light'), h = '', i;
    84130
    85         html += '<table border="0" cellspacing="1" cellpadding="0">'
     131        for (i = 0; i < detail; i++){
     132                h += '<div id="gs'+i+'" style="background-color:#000000; width:15px; height:3px; border-style:none; border-width:0px;"'
     133                + ' onclick="changeFinalColor(this.style.backgroundColor)"'
     134                + ' onmousedown="isMouseDown = true; return false;"'
     135                + ' onmouseup="isMouseDown = false;"'
     136                + ' onmousemove="if (isMouseDown && isMouseOver) changeFinalColor(this.style.backgroundColor); return false;"'
     137                + ' onmouseover="isMouseOver = true;"'
     138                + ' onmouseout="isMouseOver = false;"'
     139                + '></div>';
     140        }
     141
     142        el.innerHTML = h;
     143}
     144
     145function generateWebColors() {
     146        var el = document.getElementById('webcolors'), h = '', i;
     147
     148        if (el.className == 'generated')
     149                return;
     150
     151        h += '<table border="0" cellspacing="1" cellpadding="0">'
    86152                + '<tr>';
    87         for (var i=0; i<colors.length; i++) {
    88                 html += '<td bgcolor="' + colors[i] + '">'
     153
     154        for (i=0; i<colors.length; i++) {
     155                h += '<td bgcolor="' + colors[i] + '">'
    89156                        + '<a href="javascript:selectColor();" onfocus="showColor(\'' + colors[i] +  '\');" onmouseover="showColor(\'' + colors[i] +  '\');">'
    90157                        + '<img border="0" src="images/spacer.gif" width="10" height="10" title="' + colors[i] +  '" alt="' + colors[i] +  '" /></a></td>';
    91158                if ((i+1) % 18 == 0)
    92                         html += '</tr><tr>';
     159                        h += '</tr><tr>';
    93160        }
    94         html += '<tr><td colspan="18">'
    95                 + '<table width="100%" border="0" cellspacing="0" cellpadding="0">'
    96                 + '<tr><td>'
    97                 + '<img id="selectedColor" style="background-color:' + tinyMCE.getWindowArg('input_color') + '" border="0" src="images/spacer.gif" width="80" height="16" />'
    98                 + '</td><td align="right">'
    99                 + '<input id="selectedColorBox" name="selectedColorBox" type="text" size="7" maxlength="7" style="width:65px" value="' + inputColor + '" />'
    100                 + '</td></tr>'
    101                 + '</table>'
    102                 + '<div style="float: left"><input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" style="margin-top:3px" onclick="selectColor();"></div>'
    103                 + '<div style="float: right"><input type="button" name="cancel" value="{$lang_cancel}" style="margin-top:3px" onclick="tinyMCEPopup.close();" id="cancel" /></div>'
    104                 + '</td></tr>'
    105                 + '</table>';
    106161
    107         document.write(html);
    108 }
    109  No newline at end of file
     162        h += '</table>';
     163
     164        el.innerHTML = h;
     165        el.className = 'generated';
     166}
     167
     168function generateNamedColors() {
     169        var el = document.getElementById('namedcolors'), h = '', n, v, i = 0;
     170
     171        if (el.className == 'generated')
     172                return;
     173
     174        for (n in named) {
     175                v = named[n];
     176                h += '<a href="javascript:selectColor();" onmouseover="showColor(\'' + n +  '\',\'' + v + '\');" style="background-color: ' + n + '"><!-- IE --></a>'
     177        }
     178
     179        el.innerHTML = h;
     180        el.className = 'generated';
     181}
     182
     183function selectColor() {
     184        var color = document.getElementById("color").value;
     185
     186        if(window.opener)
     187                window.opener.tinyMCE.execInstanceCommand(tinyMCE.getWindowArg('editor_id'),tinyMCE.getWindowArg('command'),false,color);
     188
     189        window.close();
     190}
     191
     192function dechex(n) {
     193        return strhex.charAt(Math.floor(n / 16)) + strhex.charAt(n % 16);
     194}
     195
     196function computeColor(e) {
     197        var x, y, partWidth, partDetail, imHeight, r, g, b, coef, i, finalCoef, finalR, finalG, finalB;
     198
     199        x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0);
     200        y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0);
     201
     202        partWidth = document.getElementById('colorpicker').width / 6;
     203        partDetail = detail / 2;
     204        imHeight = document.getElementById('colorpicker').height;
     205
     206        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;
     207        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);
     208        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);
     209
     210        coef = (imHeight - y) / imHeight;
     211        r = 128 + (r - 128) * coef;
     212        g = 128 + (g - 128) * coef;
     213        b = 128 + (b - 128) * coef;
     214
     215        changeFinalColor('#' + dechex(r) + dechex(g) + dechex(b));
     216        updateLight(r, g, b);
     217}
     218
     219function updateLight(r, g, b) {
     220        var i, partDetail = detail / 2, finalCoef, finalR, finalG, finalB, color;
     221
     222        for (i=0; i<detail; i++) {
     223                if ((i>=0) && (i<partDetail)) {
     224                        finalCoef = i / partDetail;
     225                        finalR = dechex(255 - (255 - r) * finalCoef);
     226                        finalG = dechex(255 - (255 - g) * finalCoef);
     227                        finalB = dechex(255 - (255 - b) * finalCoef);
     228                } else {
     229                        finalCoef = 2 - i / partDetail;
     230                        finalR = dechex(r * finalCoef);
     231                        finalG = dechex(g * finalCoef);
     232                        finalB = dechex(b * finalCoef);
     233                }
     234
     235                color = finalR + finalG + finalB;
     236
     237                document.getElementById('gs' + i).style.backgroundColor = '#'+color;
     238        }
     239}
     240
     241function changeFinalColor(color) {
     242        if (color.indexOf('#') == -1)
     243                color = convertRGBToHex(color);
     244
     245        document.getElementById('preview').style.backgroundColor = color;
     246        document.getElementById('color').value = color;
     247}
     248
     249window.focus();
     250 No newline at end of file
  • wp-includes/js/tinymce/themes/advanced/jscripts/link.js

     
    5757        var title = document.forms[0].linktitle.value;
    5858        var style_class = document.forms[0].styleSelect ? document.forms[0].styleSelect.value : "";
    5959        var dummy;
    60 
    61         // Make anchors absolute
     60       
     61        // WordPress: Make anchors absolute;
    6262        if (href.charAt(0) == '#')
    6363                href = tinyMCE.settings['document_base_url'] + href;
    6464
  • wp-includes/js/tinymce/themes/advanced/color_picker.htm

     
    22<head>
    33        <title>{$lang_theme_colorpicker_title}</title>
    44        <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
     5        <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
    56        <script language="javascript" type="text/javascript" src="jscripts/color_picker.js"></script>
     7        <link href="css/colorpicker.css" rel="stylesheet" type="text/css" />
    68        <base target="_self" />
    79</head>
    8 <body onload="tinyMCEPopup.executeOnLoad('init();');" style="margin: 3px; display: none">
    9         <div align="center">
    10            <script language="javascript" type="text/javascript">renderColorMap();</script>
     10<body onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
     11        <div class="tabs">
     12                <ul>
     13                        <li id="picker_tab" class="current"><span><a href="javascript:mcTabs.displayTab('picker_tab','picker_panel');" onmousedown="return false;">{$lang_color_picker_tab}</a></span></li>
     14                        <li id="rgb_tab"><span><a href="#" onclick="generateWebColors();mcTabs.displayTab('rgb_tab','rgb_panel');" onmousedown="return false;">{$lang_web_colors_tab}</a></span></li>
     15                        <li id="named_tab"><span><a  href="#" onclick="generateNamedColors();javascript:mcTabs.displayTab('named_tab','named_panel');" onmousedown="return false;">{$lang_named_colors_tab}</a></span></li>
     16                </ul>
    1117        </div>
     18
     19        <div class="panel_wrapper">
     20                <div id="picker_panel" class="panel current">
     21                        <fieldset>
     22                                <legend>{$lang_color_picker}</legend>
     23                                <div id="picker">
     24                                        <img id="colorpicker" src="images/colors.jpg" onclick="computeColor(event)" onmousedown="isMouseDown = true;return false;" onmouseup="isMouseDown = false;" onmousemove="if (isMouseDown && isMouseOver) computeColor(event); return false;" onmouseover="isMouseOver=true;" onmouseout="isMouseOver=false;" />
     25
     26                                        <div id="light">
     27                                                <!-- Will be filled with divs -->
     28                                        </div>
     29
     30                                        <br style="clear: both" />
     31                                </div>
     32                        </fieldset>
     33                </div>
     34
     35                <div id="rgb_panel" class="panel">
     36                        <fieldset>
     37                                <legend>{$lang_web_colors}</legend>
     38                                <div id="webcolors">
     39                                        <!-- Gets filled with web safe colors-->
     40                                </div>
     41
     42                                <br style="clear: both" />
     43                        </fieldset>
     44                </div>
     45
     46                <div id="named_panel" class="panel">
     47                        <fieldset>
     48                                <legend>{$lang_named_colors}</legend>
     49                                <div id="namedcolors">
     50                                        <!-- Gets filled with named colors-->
     51                                </div>
     52
     53                                <br style="clear: both" />
     54
     55                                <div id="colornamecontainer">
     56                                        {$lang_color_name} <span id="colorname"></span>
     57                                </div>
     58                        </fieldset>
     59                </div>
     60        </div>
     61
     62        <div class="mceActionPanel">
     63                <div style="float: left">
     64                        <input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" onclick="insertAction();" />
     65                </div>
     66
     67                <div id="preview"></div>
     68
     69                <div id="previewblock">
     70                        <label for="color">{$lang_color}</label> <input id="color" type="text" size="8" maxlength="8" class="text" />
     71                </div>
     72        </div>
    1273</body>
    1374</html>
  • wp-includes/js/tinymce/themes/advanced/langs/en.js

     
    7878not_set : '-- Not set --',
    7979close : 'Close',
    8080toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X',
    81 invalid_data : 'Error: Invalid values entered, these are marked in red.'
     81invalid_data : 'Error: Invalid values entered, these are marked in red.',
     82more_colors : 'More colors',
     83color_picker_tab : 'Picker',
     84color_picker : 'Color picker',
     85web_colors_tab : 'Web safe',
     86web_colors : 'Web safe colors',
     87named_colors_tab : 'Named',
     88named_colors : 'Named colors',
     89color : 'Color:',
     90color_name : 'Name:'
    8291});
  • wp-includes/js/tinymce/themes/advanced/css/editor_ui.css

     
    1111.mceToolbarTop, .mceToolbarBottom {background: #F0F0EE; line-height: 1px; font-size: 1px;}
    1212.mceToolbarTop {border-bottom: 1px solid #cccccc; padding-bottom: 1px;}
    1313.mceToolbarBottom {border-top: 1px solid #cccccc;}
    14 .mceToolbarContainer {position: relative; left: 0; top: 0; display: block;}
     14.mceToolbarContainer {display: block; position: relative; left: 0; top: 0; width: 100%;}
    1515.mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {height: 20px;}
    1616.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;}
    1717.mceStatusbarTop {border-bottom: 1px solid #cccccc;}
     
    4949
    5050/* Menu */
    5151
    52 .mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 100; background-color: white; border: 1px solid gray; font-weight: normal;}
     52.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 1000; background-color: white; border: 1px solid gray; font-weight: normal;}
    5353.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;}
    5454.mceMenu a:hover {background-color: #B6BDD2; color: black; text-decoration: none !important;}
    5555.mceMenu span {padding-left: 10px; padding-right: 10px; display: block; line-height: 20px;}
     
    6161span.mceMenuCheckItem {padding-left: 20px;}
    6262span.mceMenuLine {display: block; position: absolute; left: 0; top: -1px; background-color: #F5F4F2; width: 30px; height: 1px; overflow: hidden; padding-left: 0; padding-right: 0;}
    6363.mceColors table, .mceColors td {margin: 0; padding: 2px;}
    64 a.mceMoreColors {width: 130px; margin: 0; padding: 0; margin-left: 3px; margin-bottom: 3px; text-align: center; border: 1px solid white;}
     64a.mceMoreColors {width: auto; padding: 0; margin: 0 3px 3px 3px; text-align: center; border: 1px solid white; text-decoration: none !important;}
    6565.mceColorPreview {position: absolute; overflow:hidden; left: 0; top: 0; margin-left: 3px; margin-top: 15px; width: 16px; height: 4px; background-color: red;}
    6666a.mceMoreColors:hover {border: 1px solid #0A246A;}
    6767.mceColors td a {width: 9px; height: 9px; overflow: hidden; border: 1px solid #808080;}
     
    7777* html .mceSelectList {margin-top: 2px;}
    7878* html span.mceMenuButton, * html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;}
    7979* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {position: relative; top: 1px;}
    80 * html a.mceMoreColors {width: 132px;}
     80* html a.mceMoreColors {width: auto;}
    8181* html .mceColors td a {width: 10px; height: 10px;}
    8282* html .mceColorPreview {margin-left: 2px; margin-top: 14px;}
    8383
     
    9292*:first-child+html .mceSelectList {margin-top: 2px;}
    9393*:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;}
    9494*:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative; top: 1px;}
    95 *:first-child+html a.mceMoreColors {width: 132px;}
     95*:first-child+html a.mceMoreColors {width: 137px;}
    9696*:first-child+html .mceColors td a {width: 10px; height: 10px;}
    9797*:first-child+html .mceColorPreview {margin: 0; padding-left: 4px; margin-top: 14px; width: 14px;}
  • wp-includes/js/tinymce/themes/advanced/editor_template.js

     
    11/**
    2  * $Id: editor_template_src.js 166 2007-01-05 10:31:50Z spocke $
     2 * $Id: editor_template_src.js 218 2007-02-13 11:08:01Z spocke $
    33 *
    44 * @author Moxiecode
    55 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
     
    4343                ['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
    4444                ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
    4545                ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true],
     46                ['forecolorpicker', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolorpicker', true],
    4647                ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true],
     48                ['backcolorpicker', 'backcolor.gif', 'lang_theme_backcolor_desc', 'backcolorpicker', true],
    4749                ['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
    4850                ['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
    4951                ['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'],
     
    356358
    357359                                return false;
    358360
     361                        case "forecolorpicker":
     362                                this._pickColor(editor_id, 'forecolor');
     363                                return true;
     364
    359365                        case "forecolorMenu":
    360366                                TinyMCE_AdvancedTheme._hideMenus(editor_id);
    361367
     
    420426
    421427                                ml.show();
    422428                        return true;
     429       
     430                        case "backcolorpicker":
     431                                this._pickColor(editor_id, 'HiliteColor');
     432                                return true;
    423433
    424434                        case "mceColorPicker":
    425435                                if (user_interface) {
    426                                         var template = new Array();
    427                                         var inputColor = value['document'].getElementById(value['element_id']).value;
     436                                        var template = [];
     437       
     438                                        if (!value['callback'] && !value['color'])
     439                                                value['color'] = value['document'].getElementById(value['element_id']).value;
    428440
    429441                                        template['file'] = 'color_picker.htm';
    430                                         template['width'] = 220;
    431                                         template['height'] = 190;
     442                                        template['width'] = 380;
     443                                        template['height'] = 250;
    432444                                        template['close_previous'] = "no";
    433445
    434446                                        template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0);
     
    438450                                                value['store_selection'] = true;
    439451
    440452                                        tinyMCE.lastColorPickerValue = value;
    441                                         tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor});
     453                                        tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : value['color']});
    442454                                } else {
    443                                         var savedVal = tinyMCE.lastColorPickerValue;
    444                                         var elm = savedVal['document'].getElementById(savedVal['element_id']);
     455                                        var savedVal = tinyMCE.lastColorPickerValue, elm;
     456
     457                                        if (savedVal['callback']) {
     458                                                savedVal['callback'](value);
     459                                                return true;
     460                                        }
     461
     462                                        elm = savedVal['document'].getElementById(savedVal['element_id']);
    445463                                        elm.value = value;
    446464
    447465                                        if (elm.onchange != null && elm.onchange != '')
     
    599617                                // Setup template html
    600618                                template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width_style};height:{$height_style}"><tbody>';
    601619
    602                                 if (toolbarLocation == "top") {
    603                                         template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
    604                                 }
     620                                if (toolbarLocation == "top")
     621                                        template['html'] += '<tr><td dir="ltr" class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
    605622
    606623                                if (statusbarLocation == "top") {
    607624                                        template['html'] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>';
     
    610627
    611628                                template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';
    612629
    613                                 if (toolbarLocation == "bottom") {
    614                                         template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
    615                                 }
     630                                if (toolbarLocation == "bottom")
     631                                        template['html'] += '<tr><td dir="ltr" class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
    616632
    617633                                // External toolbar changes
    618634                                if (toolbarLocation == "external") {
     
    738754        },
    739755
    740756        removeInstance : function(inst) {
    741                 var fcm = new TinyMCE_Layer(inst.editorId + '_fcMenu');
     757                new TinyMCE_Layer(inst.editorId + '_fcMenu').remove();
     758                new TinyMCE_Layer(inst.editorId + '_bcMenu').remove();
     759        },
    742760
    743                 fcm.remove();
     761        hideInstance : function(inst) {
     762                TinyMCE_AdvancedTheme._hideMenus(inst.editorId);
    744763        },
    745764
    746765        _handleMenuEvent : function(e) {
     
    13781397                }
    13791398
    13801399                h += '</tr></table>';
    1381                 /*
    1382                 h += '<a href="" class="mceMoreColors">More colors</a>';
    1383                 */
    13841400
     1401                if (tinyMCE.getParam("theme_advanced_more_colors", true))
     1402                        h += '<a href="#" onclick="TinyMCE_AdvancedTheme._pickColor(\'' + id + '\',\'' + cm + '\');" class="mceMoreColors">' + tinyMCE.getLang('lang_more_colors') + '</a>';
     1403
    13851404                return h;
    13861405        },
    13871406
     1407        _pickColor : function(id, cm) {
     1408                var inputColor, inst = tinyMCE.selectedInstance;
     1409
     1410                if (cm == 'forecolor' && inst)
     1411                        inputColor = inst.foreColor;
     1412
     1413                if ((cm == 'backcolor' || cm == 'HiliteColor') && inst)
     1414                        inputColor = inst.backColor;
     1415
     1416                tinyMCE.execCommand('mceColorPicker', true, {color : inputColor, callback : function(c) {
     1417                        tinyMCE.execInstanceCommand(id, cm, false, c);
     1418                }});
     1419        },
     1420
    13881421        _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
    13891422                tinyMCE.execCommand('mceBeginUndoLevel');
    13901423