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
This commit is contained in:
Matt Pass
2013-04-15 16:18:59 +01:00
parent ed9b9881b6
commit 2c6bcacb25

View File

@@ -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 = '<div id="picker" class="picker"></div><br><br><input type="text" id="color" name="color" value="#123456" style="border: 0; width: 70px; padding-left: 5px"><input type="button" onClick="top.ICEcoder.insertColorValue()" value="insert &gt;" style="background: #888; color: #fff; height: 18px; width: 70px; border: 0; margin-left: 5px; cursor: pointer">';
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;