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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
define([
'summernote/core/list',
'summernote/core/dom',
'summernote/module/Button'
], function (list, dom, Button) {
/**
* @class module.Toolbar
*
* Toolbar
*/
var Toolbar = function () {
var button = new Button();
this.button = button; // ODOO: allow access for override
this.update = function ($toolbar, styleInfo) {
button.update($toolbar, styleInfo);
};
/**
* @param {Node} button
* @param {String} eventName
* @param {String} value
*/
this.updateRecentColor = function (buttonNode, eventName, value) {
button.updateRecentColor(buttonNode, eventName, value);
};
/**
* activate buttons exclude codeview
* @param {jQuery} $toolbar
*/
this.activate = function ($toolbar) {
$toolbar.find('button')
.not('button[data-event="codeview"]')
.removeClass('disabled');
};
/**
* deactivate buttons exclude codeview
* @param {jQuery} $toolbar
*/
this.deactivate = function ($toolbar) {
$toolbar.find('button')
.not('button[data-event="codeview"]')
.addClass('disabled');
};
/**
* @param {jQuery} $container
* @param {Boolean} [bFullscreen=false]
*/
this.updateFullscreen = function ($container, bFullscreen) {
var $btn = $container.find('button[data-event="fullscreen"]');
$btn.toggleClass('active', bFullscreen);
};
/**
* @param {jQuery} $container
* @param {Boolean} [isCodeview=false]
*/
this.updateCodeview = function ($container, isCodeview) {
var $btn = $container.find('button[data-event="codeview"]');
$btn.toggleClass('active', isCodeview);
if (isCodeview) {
this.deactivate($container);
} else {
this.activate($container);
}
};
/**
* get button in toolbar
*
* @param {jQuery} $editable
* @param {String} name
* @return {jQuery}
*/
this.get = function ($editable, name) {
var $toolbar = dom.makeLayoutInfo($editable).toolbar();
return $toolbar.find('[data-name=' + name + ']');
};
/**
* set button state
* @param {jQuery} $editable
* @param {String} name
* @param {Boolean} [isActive=true]
*/
this.setButtonState = function ($editable, name, isActive) {
isActive = (isActive === false) ? false : true;
var $button = this.get($editable, name);
$button.toggleClass('active', isActive);
};
};
return Toolbar;
});
|