-
Notifications
You must be signed in to change notification settings - Fork 1
/
summernote-floats-bs.js
81 lines (79 loc) · 2.07 KB
/
summernote-floats-bs.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
72
73
74
75
76
77
78
79
80
81
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require('jquery'));
} else {
factory(window.jQuery);
}
}(function ($) {
var ui = $.summernote.ui;
var dom = $.summernote.dom;
var floatBSPlugin = function (context) {
var self = this;
var options = context.options;
var lang = options.langInfo;
var editable = context.layoutInfo.editable;
context.memo('button.floatBSLeft', function () {
return ui.button({
contents: '<span class="note-icon-align-left"></span>',
tooltip: lang.floatBS.floatLeft,
click: function(event) {
var $img=$(editable.data('target'));
$img.removeClass('pull-right pull-left').addClass('pull-left');
context.invoke('editor.afterCommand');
}
}).render();
});
context.memo('button.floatBSRight', function () {
return ui.button({
contents: '<span class="note-icon-align-right"></span>',
tooltip: lang.floatBS.floatRight,
click: function(event) {
var $img=$(editable.data('target'));
$img.removeClass('pull-right pull-left').addClass('pull-right');
context.invoke('editor.afterCommand');
}
}).render();
});
context.memo('button.floatBSNone', function () {
return ui.button({
contents: '<span class="note-icon-align-justify"></span>',
tooltip: lang.floatBS.floatNone,
click: function(event) {
var $img=$(editable.data('target'));
$img.removeClass('pull-right pull-left');
context.invoke('editor.afterCommand');
}
}).render();
});
};
$.extend(true, $.summernote, {
plugins: {
floatBS: floatBSPlugin
},
options: {
popover: {
floatBS: [
['floatBS', ['floatBSLeft', 'floatBSRight', 'floatBSNo']]
]
}
},
lang: {
'en-US':{
floatBS:{
floatLeft:'Float Left',
floatRight:'Float Right',
floatNone:'Float None',
}
},
'es-ES':{
floatBS:{
floatLeft:'Flotar a la izquierda',
floatRight:'Flotar a la derecha',
floatNone:'No flotar',
}
}
}
});
}));