1/* JavaScript function to create cellbg toolbar in DokuwKki */ 2/* see http:// for more info */ 3 4var plugin_cellbg_colors = { 5 6 "Yellow": "yellow", 7 "Red": "red", 8 "Orange": "orange", 9 "Salmon": "salmon", 10 "Pink": "pink", 11 "Plum": "plum", 12 "Purple": "purple", 13 "Fuchsia": "fuchsia", 14 "Silver": "silver", 15 "Aqua": "aqua", 16 "Teal": "teal", 17 "Cornflower": "#6495ed", 18 "Sky Blue": "skyblue", 19 "Aquamarine": "aquamarine", 20 "Pale Green": "palegreen", 21 "Lime": "lime", 22 "Green": "green", 23 "Olive": "olive" 24 //"Yellow": "#ffff00", 25 //"Red": "#ff0000", 26 //"Orange": "#ffa500", 27 //"Salmon": "#fa8072", 28 //"Pink": "#ffc0cb", 29 //"Plum": "#dda0dd", 30 //"Purple": "#800080", 31 //"Fuchsia": "#ff00ff", 32 //"Silver": "#c0c0c0", 33 //"Aqua": "#00ffff", 34 //"Teal": "#008080", 35 //"Cornflower": "#6495ed", 36 //"Sky Blue": "#87ceeb", 37 //"Aquamarine": "#7fffd4", 38 //"Pale Green": "#98fb98", 39 //"Lime": "#00ff00", 40 //"Green": "#008000", 41 //"Olive": "#808000" 42 43}; 44 45function plugin_cellbg_make_color_button(name, value) { 46 47 var btn = document.createElement('button'); 48 49 btn.className = 'pickerbutton'; 50 btn.value = ''; 51 btn.title = name; 52 btn.style.height = '2em'; 53 btn.style.padding = '1em'; 54 btn.style.backgroundColor = value; 55 56 var open = "@" + value + ":"; 57 eval("btn.onclick = function(){ insertAtCarret( '" 58 + jsEscape('wiki__text') + "','" 59 + jsEscape(open) + "','" 60 + "'); return false; } " 61 ); 62 63 return(btn); 64 65} 66 67function plugin_cellbg_toolbar_picker() { 68 69 if (!document.getElementById('spell__action')) return; 70 71 var toolbar = document.getElementById('tool__bar'); 72 if (!toolbar) return; 73 74 // Create the picker button 75 var p_id = 'picker_plugin_cellbg'; // picker id that we're creating 76 var p_ico = document.createElement('img'); 77 p_ico.src = DOKU_BASE + 'lib/plugins/cellbg/images/cellbg.png'; 78 var p_btn = document.createElement('button'); 79 p_btn.className = 'toolbutton'; 80 p_btn.title = 'Cell background'; 81 p_btn.appendChild(p_ico); 82 eval("p_btn.onclick = function() { showPicker('" 83 + p_id + "',this); return false; }"); 84 85 // Create the picker <div> 86 var picker = document.createElement('div'); 87 picker.className = 'picker'; 88 picker.id = p_id; 89 picker.style.position = 'absolute'; 90 picker.style.display = 'none'; 91 92 // Add a button to the picker <div> for each of the colors 93 for( var color in plugin_cellbg_colors ) { 94 var btn = plugin_cellbg_make_color_button(color, 95 plugin_cellbg_colors[color]); 96 picker.appendChild(btn); 97 } 98 if (typeof user_cellbg_colors != 'undefined') { 99 for( var color in user_cellbg_colors ) { 100 var btn = plugin_cellbg_make_color_button(color, 101 user_cellbg_colors[color]); 102 picker.appendChild(btn); 103 } 104 } 105 106 var body = document.getElementsByTagName('body')[0]; 107 body.appendChild(picker); // attach the picker <div> to the page body 108 toolbar.appendChild(p_btn); // attach the picker button to the toolbar 109} 110jQuery(plugin_cellbg_toolbar_picker); 111 112//Setup VIM: ex: et ts=2 sw=2 enc=utf-8 : 113