-
Notifications
You must be signed in to change notification settings - Fork 5
/
visual-editor-button.js
80 lines (80 loc) · 3.36 KB
/
visual-editor-button.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
(function(){
tinymce.create('tinymce.plugins.ATCouponPlugin', {
init: function(ed, url) {
ed.addButton('at_coupon_button', {
title: 'AT Coupon',
text: '[at_coupon]',
cmd: 'at_coupon_command',
/*image: url + '/img/at.png'*/
});
ed.addCommand('at_coupon_command', function() {
var win = ed.windowManager.open({
title: 'Coupon Properties',
body: [
{
type : 'listbox',
name : 'nxmerchants',
label : 'Merchant',
minWidth: 300,
values : nhymxu_at_coupon_get_tinymce_list('merchant'),
},
{
type : 'listbox',
name : 'nxcats',
label : 'Ngành hàng',
minWidth: 300,
values : nhymxu_at_coupon_get_tinymce_list('cat'),
},
{
type : 'listbox',
name : 'nxfilter',
label : 'Filter',
minWidth: 300,
values : [{text:'Tất cả', value:''}, {text:'Có mã giảm giá', value:'1'}, {text:'Không có mã giảm giá', value:'0'}],
},
],
buttons: [
{
text: "Ok",
subtype: "primary",
onclick: function() {
win.submit();
}
},
{
text: "Cancel",
onclick: function() {
win.close();
}
}
],
onsubmit: function(e){
var returnText = '';
if( e.data.nxmerchants.length > 0 ) {
returnText = '[atcoupon type="'+ e.data.nxmerchants +'"';
if( e.data.nxcats.length > 0 ) {
returnText = returnText + ' cat="' + e.data.nxcats + '"';
}
if( e.data.nxfilter.length > 0 ) {
returnText = returnText + ' coupon="' + e.data.nxfilter + '"';
}
returnText = returnText + ']';
ed.execCommand('mceInsertContent', 0, returnText);
} else {
alert('Không được bỏ trống mục Merchant');
}
}
});
});
},
getInfo: function() {
return {
longname : 'Nhymxu AT Coupon Generator',
author : 'Dũng Nguyễn',
authorurl : 'https://dungnt.net',
version : "0.2.0"
};
}
});
tinymce.PluginManager.add( 'at_coupon_button', tinymce.plugins.ATCouponPlugin );
})();