forked from dr4Ke/cellbg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
71 lines (60 loc) · 2.16 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* JavaScript function to create cellbg toolbar in DokuwKki */
/* see https://www.dokuwiki.org/devel:toolbar for more info */
function createCellbgPicker(id, props, edid) {
// create the wrapping div
var $picker = jQuery(document.createElement('div'));
$picker.addClass('picker a11y');
$picker.attr('id', id).css('position', 'absolute');
function $makebutton(title, colorValue) {
var $btn = jQuery(document.createElement('button'))
.addClass('pickerbutton cellbg').attr('title', title)
.attr('aria-controls', edid);
if (colorValue == 'RGB')
{
$btn.text(colorValue)
.addClass('custom')
.bind('click', bind(tb_format, $btn[0], props, edid));
}
else
{
var insertColorValue = "@" + colorValue + ":";
$btn.css('backgroundColor', colorValue)
.bind('click', bind(pickerInsert, insertColorValue, edid));
}
$btn.appendTo($picker);
return $btn;
}
$makebutton('custom', 'RGB');
jQuery.each(props.colorlist, function (key, item) {
if (!props.colorlist.hasOwnProperty(key)) {
return;
}
$makebutton(key, item);
});
jQuery('body').append($picker);
// we have to return a DOM object (for compatibility reasons)
return $picker[0];
}
/**
* Add button action for color picker buttons and create color picker element
*
* @param jQuery btn Button element to add the action to
* @param array props Associative array of button properties
* @param string edid ID of the editor textarea
* @return boolean If button should be appended
* @author Pavel Kochman <[email protected]>
*/
function addBtnActionCellbgPicker($btn, props, edid) {
var pickerid = 'picker_plugin_cellbg'; // picker id that we're creating
var picker = createCellbgPicker(pickerid, props, edid);
$btn.click(
function(e) {
pickerToggle(pickerid, $btn);
e.preventDefault();
return '';
}
);
$btn.attr('aria-haspopup', 'true');
return pickerid;
}
//Setup VIM: ex: et ts=2 sw=2 enc=utf-8 :