forked from kindsoft/kindeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolbar.js
60 lines (53 loc) · 1.63 KB
/
toolbar.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
var items = [
'source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
'superscript', '|', 'selectall', '/',
'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image',
'flash', 'media', 'table', 'hr', 'emoticons', 'link', 'unlink', '|', 'about'
];
var list = [];
K.each(items, function(i, name) {
if (name == '|') {
list.push('<span class="ke-inline-block ke-separator"></span>');
} else if (name == '/') {
list.push('<br />');
} else {
list.push('<span class="ke-inline-block ke-outline" unselectable="on" data-name="' + name + '" title="' + name + '">');
list.push('<span class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-' + name + '" unselectable="on"></span></span>');
}
});
var toolbar = K.toolbar({
src : 'div#toolbar',
width : '100%',
html : list.join(''),
click : function(e, name) {
alert(name);
}
});
K('#enable').bind('click', function(e) {
if (toolbar) {
toolbar.disableAll(false);
}
});
K('#disable').bind('click', function(e) {
if (toolbar) {
toolbar.disableAll(true);
}
});
K('#toggle').bind('click', function(e) {
if (toolbar) {
toolbar.disableAll();
}
});
K('#select').bind('click', function(e) {
if (toolbar) {
toolbar.select('bold');
}
});
K('#unselect').bind('click', function(e) {
if (toolbar) {
toolbar.unselect('bold');
}
});