addons.js
6.4 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
define([], function () {
require(['../addons/bootstrapcontextmenu/js/bootstrap-contextmenu'], function (undefined) {
if (Config.controllername == 'index' && Config.actionname == 'index') {
$("body").append(
'<div id="context-menu">' +
'<ul class="dropdown-menu" role="menu">' +
'<li><a tabindex="-1" data-operate="refresh"><i class="fa fa-refresh fa-fw"></i>刷新</a></li>' +
'<li><a tabindex="-1" data-operate="refreshTable"><i class="fa fa-table fa-fw"></i>刷新表格</a></li>' +
'<li><a tabindex="-1" data-operate="close"><i class="fa fa-close fa-fw"></i>关闭</a></li>' +
'<li><a tabindex="-1" data-operate="closeOther"><i class="fa fa-window-close-o fa-fw"></i>关闭其他</a></li>' +
'<li class="divider"></li>' +
'<li><a tabindex="-1" data-operate="closeAll"><i class="fa fa-power-off fa-fw"></i>关闭全部</a></li>' +
'</ul>' +
'</div>');
$(".nav-addtabs").contextmenu({
target: "#context-menu",
scopes: 'li[role=presentation]',
onItem: function (e, event) {
var $element = $(event.target);
var tab_id = e.attr('id');
var id = tab_id.substr('tab_'.length);
var con_id = 'con_' + id;
switch ($element.data('operate')) {
case 'refresh':
$("#" + con_id + " iframe").attr('src', function (i, val) {
return val;
});
break;
case 'refreshTable':
try {
if ($("#" + con_id + " iframe").contents().find(".btn-refresh").size() > 0) {
$("#" + con_id + " iframe")[0].contentWindow.$(".btn-refresh").trigger("click");
}
} catch (e) {
}
break;
case 'close':
if (e.find(".close-tab").length > 0) {
e.find(".close-tab").click();
}
break;
case 'closeOther':
e.parent().find("li[role='presentation']").each(function () {
if ($(this).attr('id') == tab_id) {
return;
}
if ($(this).find(".close-tab").length > 0) {
$(this).find(".close-tab").click();
}
});
break;
case 'closeAll':
e.parent().find("li[role='presentation']").each(function () {
if ($(this).find(".close-tab").length > 0) {
$(this).find(".close-tab").click();
}
});
break;
default:
break;
}
}
});
}
$(document).on('click', function () { // iframe内点击 隐藏菜单
try {
top.window.$(".nav-addtabs").contextmenu("closemenu");
} catch (e) {
}
});
});
if (Config.modulename === 'index' && Config.controllername === 'user' && ['login', 'register'].indexOf(Config.actionname) > -1 && $("#register-form,#login-form").length > 0 && $(".social-login").length == 0) {
$("#register-form,#login-form").append(Config.third.loginhtml || '');
}
window.UEDITOR_HOME_URL = Config.__CDN__ + "/assets/addons/ueditor/";
require.config({
paths: {
'ueditor.config': '../addons/ueditor/ueditor.config',
'ueditor': '../addons/ueditor/ueditor.all.min',
'ueditor.zh': '../addons/ueditor/i18n/zh-cn/zh-cn',
'zeroclipboard': '../addons/ueditor/third-party/zeroclipboard/ZeroClipboard.min',
},
shim: {
'ueditor': {
deps: ['zeroclipboard', 'ueditor.config'],
exports: 'UE',
init: function (ZeroClipboard) {
//导出到全局变量,供ueditor使用
window.ZeroClipboard = ZeroClipboard;
},
},
'ueditor.zh': ['ueditor']
}
});
require(['form', 'upload'], function (Form, Upload) {
var _bindevent = Form.events.bindevent;
Form.events.bindevent = function (form) {
_bindevent.apply(this, [form]);
try {
//绑定editor事件
require(['ueditor', 'ueditor.zh'], function (UE, undefined) {
UE.list = [];
window.UEDITOR_CONFIG['uploadService'] = function (context, editor) {
return {
Upload: () => { return Upload },
Fast: () => { return Fast },
}
};
$(Config.ueditor.classname || '.editor', form).each(function () {
var id = $(this).attr("id");
var name = $(this).attr("name");
$(this).removeClass('form-control');
UE.list[id] = UE.getEditor(id, {
allowDivTransToP: false, //阻止div自动转p标签
initialFrameWidth: '100%',
initialFrameHeight: 320,
autoFloatEnabled: false,
baiduMapAk: Config.ueditor.baiduMapAk || '', //百度地图api密钥(ak)
// autoHeightEnabled: true, //自动高度
zIndex: 90,
xssFilterRules: false,
outputXssFilter: false,
inputXssFilter: false,
catchRemoteImageEnable: true,
imageAllowFiles: '',//允许上传的图片格式,编辑器默认[".png", ".jpg", ".jpeg", ".gif", ".bmp"]
});
UE.list[id].addListener("contentChange", function () {
$('#' + id).val(this.getContent());
$('textarea[name="' + name + '"]').val(this.getContent());
})
});
})
} catch (e) {
console.log('绑定editor事件', e)
}
}
});
});