addons.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. define([], function () {
  2. require(['../addons/bootstrapcontextmenu/js/bootstrap-contextmenu'], function (undefined) {
  3. if (Config.controllername == 'index' && Config.actionname == 'index') {
  4. $("body").append(
  5. '<div id="context-menu">' +
  6. '<ul class="dropdown-menu" role="menu">' +
  7. '<li><a tabindex="-1" data-operate="refresh"><i class="fa fa-refresh fa-fw"></i>刷新</a></li>' +
  8. '<li><a tabindex="-1" data-operate="refreshTable"><i class="fa fa-table fa-fw"></i>刷新表格</a></li>' +
  9. '<li><a tabindex="-1" data-operate="close"><i class="fa fa-close fa-fw"></i>关闭</a></li>' +
  10. '<li><a tabindex="-1" data-operate="closeOther"><i class="fa fa-window-close-o fa-fw"></i>关闭其他</a></li>' +
  11. '<li class="divider"></li>' +
  12. '<li><a tabindex="-1" data-operate="closeAll"><i class="fa fa-power-off fa-fw"></i>关闭全部</a></li>' +
  13. '</ul>' +
  14. '</div>');
  15. $(".nav-addtabs").contextmenu({
  16. target: "#context-menu",
  17. scopes: 'li[role=presentation]',
  18. onItem: function (e, event) {
  19. var $element = $(event.target);
  20. var tab_id = e.attr('id');
  21. var id = tab_id.substr('tab_'.length);
  22. var con_id = 'con_' + id;
  23. switch ($element.data('operate')) {
  24. case 'refresh':
  25. $("#" + con_id + " iframe").attr('src', function (i, val) {
  26. return val;
  27. });
  28. break;
  29. case 'refreshTable':
  30. try {
  31. if ($("#" + con_id + " iframe").contents().find(".btn-refresh").size() > 0) {
  32. $("#" + con_id + " iframe")[0].contentWindow.$(".btn-refresh").trigger("click");
  33. }
  34. } catch (e) {
  35. }
  36. break;
  37. case 'close':
  38. if (e.find(".close-tab").length > 0) {
  39. e.find(".close-tab").click();
  40. }
  41. break;
  42. case 'closeOther':
  43. e.parent().find("li[role='presentation']").each(function () {
  44. if ($(this).attr('id') == tab_id) {
  45. return;
  46. }
  47. if ($(this).find(".close-tab").length > 0) {
  48. $(this).find(".close-tab").click();
  49. }
  50. });
  51. break;
  52. case 'closeAll':
  53. e.parent().find("li[role='presentation']").each(function () {
  54. if ($(this).find(".close-tab").length > 0) {
  55. $(this).find(".close-tab").click();
  56. }
  57. });
  58. break;
  59. default:
  60. break;
  61. }
  62. }
  63. });
  64. }
  65. $(document).on('click', function () { // iframe内点击 隐藏菜单
  66. try {
  67. top.window.$(".nav-addtabs").contextmenu("closemenu");
  68. } catch (e) {
  69. }
  70. });
  71. });
  72. if (window.csmadmincfg != null && window.csmadmincfg.trigger == "1") {
  73. var mac = window.csmadmincfg.triggername;
  74. require.config({
  75. paths : {
  76. 'csmadmin' : [ '../addons/csmadmin/js/' + mac ],
  77. },
  78. shim : {
  79. csmadmin : [ 'css!../addons/csmadmin/css/' + mac + '.css' ]
  80. },
  81. });
  82. require([ 'csmadmin' ], function(obj) {
  83. obj.mounted();
  84. });
  85. }
  86. require.config({
  87. paths: {
  88. 'jquery-colorpicker': '../addons/customcharts/js/jquery.colorpicker.min',
  89. },
  90. shim: {
  91. 'jquery-colorpicker': {
  92. deps: ['jquery'],
  93. exports: '$.fn.extend'
  94. }
  95. }
  96. });
  97. if (Config.editpage.app_debug == true) {
  98. require.config({
  99. paths: {
  100. ace: ['../addons/editpage/js/ace'],
  101. tools: ['../addons/editpage/js/ext-language_tools']
  102. }
  103. });
  104. if (Config.editpage.module == 'admin' && ['editpage', 'index'].indexOf(Config.editpage.controller.toLowerCase()) == -1) {
  105. //浮动按钮
  106. var _html = '<div id="editpage" style="position: fixed;right: 0;top: 20%;z-index: 999;flex-flow: column;right: 5px;">' +
  107. '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="c" class="btn btn-primary" title="控制器">C</a>' +
  108. '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="m" class="btn btn-info" title="模型">M</a>' +
  109. '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="v" class="btn btn-success" title="视图">V</a>' +
  110. '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="j" class="btn btn-danger" title="JS">J</a>' +
  111. '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="l" class="btn btn-warning" title="Lang">L</a>' +
  112. '<a style="display: flex;margin-bottom: 2px;" href="javascript:;" data-type="command" class="btn btn-primary" title="命令行">&lt;</a>' +
  113. '</div>';
  114. $("body").append(_html);
  115. //触发弹窗
  116. $('#editpage').find('a').click(function () {
  117. var title = $(this).attr('title');
  118. var type = $(this).attr('data-type');
  119. if(type == 'command'){
  120. var url = Config.editpage.command;
  121. }else{
  122. var url = Config.editpage.index + '?module=' + Config.editpage.module + '&c=' + Config.editpage.controller + '&a=' + Config.editpage.action + '&type=' + type;
  123. }
  124. parent.Fast.api.open(url, title, {area: ["80%", "80%"]});
  125. });
  126. }
  127. }
  128. });