]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/themes/advanced/js/color_picker.js
Wordpress 2.5.1
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / themes / advanced / js / color_picker.js
similarity index 93%
rename from wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js
rename to wp-includes/js/tinymce/themes/advanced/js/color_picker.js
index 6fe6b90395c146e7d6b35fdfef9604ac309f3bbf..db5ac254417e4768aecb5acebc0ef27b3891404c 100644 (file)
@@ -1,6 +1,8 @@
+tinyMCEPopup.requireLangPack();
+
 var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false;
 
-var colors = new Array(
+var colors = [
        "#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033",
        "#330066","#330099","#3300cc","#3300ff","#660000","#660033","#660066","#660099",
        "#6600cc","#6600ff","#990000","#990033","#990066","#990099","#9900cc","#9900ff",
@@ -28,7 +30,7 @@ var colors = new Array(
        "#66ff00","#66ff33","#66ff66","#66ff99","#66ffcc","#66ffff","#99ff00","#99ff33",
        "#99ff66","#99ff99","#99ffcc","#99ffff","#ccff00","#ccff33","#ccff66","#ccff99",
        "#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff"
-);
+];
 
 var named = {
        '#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige',
@@ -57,10 +59,9 @@ var named = {
 };
 
 function init() {
-       var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color'));
+       var inputColor = convertRGBToHex(tinyMCEPopup.getWindowArg('input_color'));
 
-       if (tinyMCE.isMSIE)
-               tinyMCEPopup.resizeToInnerSize();
+       tinyMCEPopup.resizeToInnerSize();
 
        generatePicker();
 
@@ -75,9 +76,13 @@ function init() {
 }
 
 function insertAction() {
-       var color = document.getElementById("color").value;
+       var color = document.getElementById("color").value, f = tinyMCEPopup.getWindowArg('func');
+
+       tinyMCEPopup.restoreSelection();
+
+       if (f)
+               f(color);
 
-       tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color);
        tinyMCEPopup.close();
 }
 
@@ -86,7 +91,7 @@ function showColor(color, name) {
                document.getElementById("colorname").innerHTML = name;
 
        document.getElementById("preview").style.backgroundColor = color;
-       document.getElementById("color").value = color;
+       document.getElementById("color").value = color.toLowerCase();
 }
 
 function convertRGBToHex(col) {
@@ -152,9 +157,9 @@ function generateWebColors() {
                + '<tr>';
 
        for (i=0; i<colors.length; i++) {
-               h += '<td bgcolor="' + colors[i] + '">'
-                       + '<a href="javascript:insertAction();" onfocus="showColor(\'' + colors[i] +  '\');" onmouseover="showColor(\'' + colors[i] +  '\');">'
-                       + '<img border="0" src="images/spacer.gif" width="10" height="10" title="' + colors[i] +  '" alt="' + colors[i] +  '" /></a></td>';
+               h += '<td bgcolor="' + colors[i] + '" width="10" height="10">'
+                       + '<a href="javascript:insertAction();" onfocus="showColor(\'' + colors[i] +  '\');" onmouseover="showColor(\'' + colors[i] +  '\');" style="display:block;width:10px;height:10px;overflow:hidden;">'
+                       + '</a></td>';
                if ((i+1) % 18 == 0)
                        h += '</tr><tr>';
        }
@@ -190,9 +195,9 @@ function computeColor(e) {
        x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0);
        y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0);
 
-       partWidth = document.getElementById('colorpicker').width / 6;
+       partWidth = document.getElementById('colors').width / 6;
        partDetail = detail / 2;
-       imHeight = document.getElementById('colorpicker').height;
+       imHeight = document.getElementById('colors').height;
 
        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;
        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);
@@ -237,4 +242,4 @@ function changeFinalColor(color) {
        document.getElementById('color').value = color;
 }
 
-window.focus();
\ No newline at end of file
+tinyMCEPopup.onInit.add(init);