123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- 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 (window.csmadmincfg != null && window.csmadmincfg.trigger == "1") {
- var mac = window.csmadmincfg.triggername;
- require.config({
- paths : {
- 'csmadmin' : [ '../addons/csmadmin/js/' + mac ],
- },
- shim : {
- csmadmin : [ 'css!../addons/csmadmin/css/' + mac + '.css' ]
- },
- });
- require([ 'csmadmin' ], function(obj) {
- obj.mounted();
- });
- }
- require.config({
- paths: {
- 'jquery-colorpicker': '../addons/customcharts/js/jquery.colorpicker.min',
- },
- shim: {
- 'jquery-colorpicker': {
- deps: ['jquery'],
- exports: '$.fn.extend'
- }
- }
- });
- if (Config.editpage.app_debug == true) {
- require.config({
- paths: {
- ace: ['../addons/editpage/js/ace'],
- tools: ['../addons/editpage/js/ext-language_tools']
- }
- });
- if (Config.editpage.module == 'admin' && ['editpage', 'index'].indexOf(Config.editpage.controller.toLowerCase()) == -1) {
- //浮动按钮
- var _html = '<div id="editpage" style="position: fixed;right: 0;top: 20%;z-index: 999;flex-flow: column;right: 5px;">' +
- '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="c" class="btn btn-primary" title="控制器">C</a>' +
- '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="m" class="btn btn-info" title="模型">M</a>' +
- '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="v" class="btn btn-success" title="视图">V</a>' +
- '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="j" class="btn btn-danger" title="JS">J</a>' +
- '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="l" class="btn btn-warning" title="Lang">L</a>' +
- '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="command" class="btn btn-primary" title="命令行"><</a>' +
- '</div>';
- $("body").append(_html);
- //触发弹窗
- $('#editpage').find('a').click(function () {
- var title = $(this).attr('title');
- var type = $(this).attr('data-type');
- if(type == 'command'){
- var url = Config.editpage.command;
- }else{
- var url = Config.editpage.index + '?module=' + Config.editpage.module + '&c=' + Config.editpage.controller + '&a=' + Config.editpage.action + '&type=' + type;
- }
- parent.Fast.api.open(url, title, {area: ["80%", "80%"]});
- });
- }
- }
- });
|