From 2c6bcacb259e9b6a0c88440b0728053f62b3a3d0 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Mon, 15 Apr 2013 16:18:59 +0100 Subject: [PATCH] New functions to show color picker & insert value CSS color preview now clickable to show color picker, passing color value showColorPicker function shows Farbtastic picker and if we have a color passed as a param, it sets that Also new function added to insert color which actually replaces token value at current cursor position --- lib/ice-coder.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index b658fdc..f79387f 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -1224,12 +1224,33 @@ var ICEcoder = { newBlock.style.width = newBlock.style.height = "20px"; newBlock.style.zIndex = "1000"; newBlock.style.background = match ? match[0] : ''; + newBlock.style.cursor = "pointer"; + newBlock.onclick = function() {top.ICEcoder.showColorPicker(match[0])}; if (newBlock.style.backgroundColor=="") {newBlock.style.display = "none"}; top.document.getElementById('header').appendChild(newBlock); cM.addWidget(cM.getCursor(), top.document.getElementById('cssColor'), true); } }, + // Show color picker + showColorPicker: function(color) { + top.document.getElementById('blackMask').style.visibility = "visible"; + top.document.getElementById('mediaContainer').innerHTML = '


'; + farbtastic('picker','color'); + if (color) { + top.document.getElementById('picker').farbtastic.setColor(color); + } + }, + + // Insert new color value + insertColorValue: function(color) { + var cM, cursor; + + cM = ICEcoder.getcMInstance(); + cursor = cM.getTokenAt(cM.getCursor()); + cM.replaceRange(top.document.getElementById('color').value,{line:cM.getCursor().line,ch:cursor.start},{line:cM.getCursor().line,ch:cursor.end}); + }, + // Change opacity of the file manager icons fMIconVis: function(icon, vis) { var i;