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.

267 lines
8.9 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. /*
  16. * Ext Core Library Examples 3.0 Beta
  17. * http://extjs.com/
  18. * Copyright(c) 2006-2009, Ext JS, LLC.
  19. *
  20. * The MIT License
  21. *
  22. * Permission is hereby granted, free of charge, to any person obtaining a copy
  23. * of this software and associated documentation files (the "Software"), to deal
  24. * in the Software without restriction, including without limitation the rights
  25. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26. * copies of the Software, and to permit persons to whom the Software is
  27. * furnished to do so, subject to the following conditions:
  28. *
  29. * The above copyright notice and this permission notice shall be included in
  30. * all copies or substantial portions of the Software.
  31. *
  32. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  33. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  34. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  35. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  36. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  37. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  38. * THE SOFTWARE.
  39. *
  40. */
  41. Ext.ns('Ext.ux');
  42. Ext.ux.Menu = Ext.extend(Ext.util.Observable, {
  43. direction: 'horizontal',
  44. delay: 0.2,
  45. autoWidth: true,
  46. transitionType: 'fade',
  47. transitionDuration: 0.3,
  48. animate: true,
  49. currentClass: 'current',
  50. constructor: function(elId, config) {
  51. config = config || {};
  52. Ext.apply(this, config);
  53. Ext.ux.Menu.superclass.constructor.call(this, config);
  54. this.addEvents(
  55. 'show',
  56. 'hide',
  57. 'click'
  58. );
  59. this.el = Ext.get(elId);
  60. this.initMarkup();
  61. this.initEvents();
  62. this.setCurrent();
  63. },
  64. initMarkup: function(){
  65. this.container = this.el.wrap({cls: 'ux-menu-container', style: 'z-index: ' + --Ext.ux.Menu.zSeed});
  66. this.items = this.el.select('li');
  67. this.el.addClass('ux-menu ux-menu-' + this.direction);
  68. this.el.select('>li').addClass('ux-menu-item-main');
  69. this.el.select('li:has(>ul)').addClass('ux-menu-item-parent').each(function(item) {
  70. item.down('a')
  71. .addClass('ux-menu-link-parent')
  72. .createChild({tag: 'span', cls: 'ux-menu-arrow'});
  73. });
  74. this.el.select('li:first-child>a').addClass('ux-menu-link-first');
  75. this.el.select('li:last-child>a').addClass('ux-menu-link-last');
  76. // create clear fixes for the floating stuff
  77. this.container.addClass('ux-menu-clearfix');
  78. // if autoWidth make every submenu as wide as its biggest child;
  79. if(this.autoWidth) {
  80. this.doAutoWidth();
  81. }
  82. var subs = this.el.select('ul');
  83. subs.addClass('ux-menu-sub');
  84. //ie6 and ie7/ie8 quirksmode need iframes behind the submenus
  85. if(Ext.isBorderBox || Ext.isIE7) {
  86. subs.each(function(item) {
  87. item.parent().createChild({tag: 'iframe', cls: 'ux-menu-ie-iframe'})
  88. .setWidth(item.getWidth())
  89. .setHeight(item.getHeight());
  90. });
  91. }
  92. subs.addClass('ux-menu-hidden');
  93. },
  94. initEvents: function() {
  95. this.showTask = new Ext.util.DelayedTask(this.showMenu, this);
  96. this.hideTask = new Ext.util.DelayedTask(function() {
  97. this.showTask.cancel();
  98. this.hideAll();
  99. this.fireEvent('hide');
  100. }, this);
  101. this.el.hover(function() {
  102. this.hideTask.cancel();
  103. }, function() {
  104. this.hideTask.delay(this.delay*1000);
  105. }, this);
  106. // for each item that has a submenu, create a mouseenter function that shows its submenu
  107. // delay 5 to make sure enter is fired after mouseover
  108. this.el.select('li.ux-menu-item-parent').on('mouseenter', this.onParentEnter, false, {me: this, delay: 5});
  109. // listen for mouseover events on items to hide other items submenus and remove hovers
  110. this.el.on('mouseover', function(ev, t) {
  111. this.manageSiblings(t);
  112. // if this item does not have a submenu, the showMenu task for a sibling could potentially still be fired, so cancel it
  113. if(!Ext.fly(t).hasClass('ux-menu-item-parent')) {
  114. this.showTask.cancel();
  115. }
  116. }, this, {delegate: 'li'});
  117. this.el.on('click', function(ev, t) {
  118. return this.fireEvent('click', ev, t, this);
  119. }, this, {delegate: 'a'})
  120. },
  121. onParentEnter: function(ev, link, o) {
  122. var item = Ext.get(this),
  123. me = o.me;
  124. // if this item is in a submenu and contains a submenu, check if the submenu is not still animating
  125. if(!item.hasClass('ux-menu-item-main') && item.parent('ul').hasActiveFx()) {
  126. item.parent('ul').stopFx(true);
  127. }
  128. // if submenu is already shown dont do anything
  129. if(!item.child('ul').hasClass('ux-menu-hidden')) {
  130. return;
  131. }
  132. me.showTask.delay(me.delay*1000, false, false, [item]);
  133. },
  134. showMenu : function(item) {
  135. var menu = item.child('ul'),
  136. x = y = 0;
  137. item.select('>a').addClass('ux-menu-link-hover');
  138. // some different configurations require different positioning
  139. if(this.direction == 'horizontal' && item.hasClass('ux-menu-item-main')) {
  140. y = item.getHeight()+1;
  141. }
  142. else {
  143. x = item.getWidth()+1;
  144. }
  145. // if its ie, force a repaint of the submenu
  146. if(Ext.isIE) {
  147. menu.select('ul').addClass('ux-menu-hidden');
  148. // ie bugs...
  149. if(Ext.isBorderBox || Ext.isIE7) {
  150. item.down('iframe').setStyle({left: x + 'px', top: y + 'px', display: 'block'});
  151. }
  152. }
  153. menu.setStyle({left: x + 'px', top: y + 'px'}).removeClass('ux-menu-hidden');
  154. if(this.animate) {
  155. switch(this.transitionType) {
  156. case 'slide':
  157. if(this.direction == 'horizontal' && item.hasClass('ux-menu-item-main')) {
  158. menu.slideIn('t', {
  159. duration: this.transitionDuration
  160. });
  161. }
  162. else {
  163. menu.slideIn('l', {
  164. duration: this.transitionDuration
  165. });
  166. }
  167. break;
  168. default:
  169. menu.setOpacity(0.001).fadeIn({
  170. duration: this.transitionDuration
  171. });
  172. break
  173. }
  174. }
  175. this.fireEvent('show', item, menu, this);
  176. },
  177. manageSiblings: function(item) {
  178. var item = Ext.get(item);
  179. item.parent().select('li.ux-menu-item-parent').each(function(child) {
  180. if(child.dom.id !== item.dom.id) {
  181. child.select('>a').removeClass('ux-menu-link-hover');
  182. child.select('ul').stopFx(false).addClass('ux-menu-hidden');
  183. if (Ext.isBorderBox || Ext.isIE7) {
  184. child.select('iframe').setStyle('display', 'none');
  185. }
  186. }
  187. });
  188. },
  189. hideAll: function() {
  190. this.manageSiblings(this.el);
  191. },
  192. setCurrent: function() {
  193. var els = this.el.query('.' + this.currentClass);
  194. if(!els.length) {
  195. return;
  196. }
  197. var item = Ext.get(els[els.length-1]).removeClass(this.currentClass).findParent('li', null, true);
  198. while(item && item.parent('.ux-menu')) {
  199. item.down('a').addClass(this.currentClass);
  200. item = item.parent('li');
  201. }
  202. },
  203. doAutoWidth: function() {
  204. var fixWidth = function(sub) {
  205. var widest = 0;
  206. var items = sub.select('>li');
  207. sub.setStyle({width: 3000 + 'px'});
  208. items.each(function(item) {
  209. widest = Math.max(widest, item.getWidth());
  210. });
  211. widest = Ext.isIE ? widest + 1 : widest;
  212. items.setWidth(widest + 'px');
  213. sub.setWidth(widest + 'px');
  214. }
  215. if(this.direction == 'vertical') {
  216. this.container.select('ul').each(fixWidth);
  217. }
  218. else {
  219. this.el.select('ul').each(fixWidth);
  220. }
  221. }
  222. });
  223. Ext.ux.Menu.zSeed = 10000;</pre>
  224. </body>
  225. </html>