Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
4.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.ux.TabCloseMenu"></div>/**
  16. * @class Ext.ux.TabCloseMenu
  17. * @extends Object
  18. * Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs. Note that the menu respects
  19. * the closable configuration on the tab. As such, commands like remove others and remove all will not
  20. * remove items that are not closable.
  21. *
  22. * @constructor
  23. * @param {Object} config The configuration options
  24. * @ptype tabclosemenu
  25. */
  26. Ext.ux.TabCloseMenu = Ext.extend(Object, {
  27. <div id="cfg-Ext.ux.TabCloseMenu-closeTabText"></div>/**
  28. * @cfg {String} closeTabText
  29. * The text for closing the current tab. Defaults to <tt>'Close Tab'</tt>.
  30. */
  31. closeTabText: 'Close Tab',
  32. <div id="cfg-Ext.ux.TabCloseMenu-closeOtherTabsText"></div>/**
  33. * @cfg {String} closeOtherTabsText
  34. * The text for closing all tabs except the current one. Defaults to <tt>'Close Other Tabs'</tt>.
  35. */
  36. closeOtherTabsText: 'Close Other Tabs',
  37. <div id="cfg-Ext.ux.TabCloseMenu-showCloseAll"></div>/**
  38. * @cfg {Boolean} showCloseAll
  39. * Indicates whether to show the 'Close All' option. Defaults to <tt>true</tt>.
  40. */
  41. showCloseAll: true,
  42. <div id="cfg-Ext.ux.TabCloseMenu-closeAllTabsText"></div>/**
  43. * @cfg {String} closeAllTabsText
  44. * <p>The text for closing all tabs. Defaults to <tt>'Close All Tabs'</tt>.
  45. */
  46. closeAllTabsText: 'Close All Tabs',
  47. constructor : function(config){
  48. Ext.apply(this, config || {});
  49. },
  50. //public
  51. init : function(tabs){
  52. this.tabs = tabs;
  53. tabs.on({
  54. scope: this,
  55. contextmenu: this.onContextMenu,
  56. destroy: this.destroy
  57. });
  58. },
  59. destroy : function(){
  60. Ext.destroy(this.menu);
  61. delete this.menu;
  62. delete this.tabs;
  63. delete this.active;
  64. },
  65. // private
  66. onContextMenu : function(tabs, item, e){
  67. this.active = item;
  68. var m = this.createMenu(),
  69. disableAll = true,
  70. disableOthers = true,
  71. closeAll = m.getComponent('closeall');
  72. m.getComponent('close').setDisabled(!item.closable);
  73. tabs.items.each(function(){
  74. if(this.closable){
  75. disableAll = false;
  76. if(this != item){
  77. disableOthers = false;
  78. return false;
  79. }
  80. }
  81. });
  82. m.getComponent('closeothers').setDisabled(disableOthers);
  83. if(closeAll){
  84. closeAll.setDisabled(disableAll);
  85. }
  86. e.stopEvent();
  87. m.showAt(e.getPoint());
  88. },
  89. createMenu : function(){
  90. if(!this.menu){
  91. var items = [{
  92. itemId: 'close',
  93. text: this.closeTabText,
  94. scope: this,
  95. handler: this.onClose
  96. }];
  97. if(this.showCloseAll){
  98. items.push('-');
  99. }
  100. items.push({
  101. itemId: 'closeothers',
  102. text: this.closeOtherTabsText,
  103. scope: this,
  104. handler: this.onCloseOthers
  105. });
  106. if(this.showCloseAll){
  107. items.push({
  108. itemId: 'closeall',
  109. text: this.closeAllTabsText,
  110. scope: this,
  111. handler: this.onCloseAll
  112. });
  113. }
  114. this.menu = new Ext.menu.Menu({
  115. items: items
  116. });
  117. }
  118. return this.menu;
  119. },
  120. onClose : function(){
  121. this.tabs.remove(this.active);
  122. },
  123. onCloseOthers : function(){
  124. this.doClose(true);
  125. },
  126. onCloseAll : function(){
  127. this.doClose(false);
  128. },
  129. doClose : function(excludeActive){
  130. var items = [];
  131. this.tabs.items.each(function(item){
  132. if(item.closable){
  133. if(!excludeActive || item != this.active){
  134. items.push(item);
  135. }
  136. }
  137. }, this);
  138. Ext.each(items, function(item){
  139. this.tabs.remove(item);
  140. }, this);
  141. }
  142. });
  143. Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);</pre>
  144. </body>
  145. </html>