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.

250 lines
8.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.onReady(function(){
  8. Ext.QuickTips.init();
  9. // Menus can be prebuilt and passed by reference
  10. var dateMenu = new Ext.menu.DateMenu({
  11. handler: function(dp, date){
  12. Ext.example.msg('Date Selected', 'You chose {0}.', date.format('M j, Y'));
  13. }
  14. });
  15. var colorMenu = new Ext.menu.ColorMenu({
  16. handler: function(cm, color){
  17. Ext.example.msg('Color Selected', 'You chose {0}.', color);
  18. }
  19. });
  20. var store = new Ext.data.ArrayStore({
  21. fields: ['abbr', 'state'],
  22. data : Ext.exampledata.states // from states.js
  23. });
  24. var combo = new Ext.form.ComboBox({
  25. store: store,
  26. displayField: 'state',
  27. typeAhead: true,
  28. mode: 'local',
  29. triggerAction: 'all',
  30. emptyText: 'Select a state...',
  31. selectOnFocus: true,
  32. width: 135,
  33. getListParent: function() {
  34. return this.el.up('.x-menu');
  35. },
  36. iconCls: 'no-icon'
  37. });
  38. var menu = new Ext.menu.Menu({
  39. id: 'mainMenu',
  40. style: {
  41. overflow: 'visible' // For the Combo popup
  42. },
  43. items: [
  44. combo, // A Field in a Menu
  45. {
  46. text: 'I like Ext',
  47. checked: true, // when checked has a boolean value, it is assumed to be a CheckItem
  48. checkHandler: onItemCheck
  49. }, '-', {
  50. text: 'Radio Options',
  51. menu: { // <-- submenu by nested config object
  52. items: [
  53. // stick any markup in a menu
  54. '<b class="menu-title">Choose a Theme</b>',
  55. {
  56. text: 'Aero Glass',
  57. checked: true,
  58. group: 'theme',
  59. checkHandler: onItemCheck
  60. }, {
  61. text: 'Vista Black',
  62. checked: false,
  63. group: 'theme',
  64. checkHandler: onItemCheck
  65. }, {
  66. text: 'Gray Theme',
  67. checked: false,
  68. group: 'theme',
  69. checkHandler: onItemCheck
  70. }, {
  71. text: 'Default Theme',
  72. checked: false,
  73. group: 'theme',
  74. checkHandler: onItemCheck
  75. }
  76. ]
  77. }
  78. },{
  79. text: 'Choose a Date',
  80. iconCls: 'calendar',
  81. menu: dateMenu // <-- submenu by reference
  82. },{
  83. text: 'Choose a Color',
  84. menu: colorMenu // <-- submenu by reference
  85. }
  86. ]
  87. });
  88. var tb = new Ext.Toolbar();
  89. tb.render('toolbar');
  90. tb.add({
  91. text:'Button w/ Menu',
  92. iconCls: 'bmenu', // <-- icon
  93. menu: menu // assign menu by instance
  94. }, {
  95. text: 'Users',
  96. iconCls: 'user',
  97. menu: {
  98. xtype: 'menu',
  99. plain: true,
  100. items: {
  101. xtype: 'buttongroup',
  102. title: 'User options',
  103. autoWidth: true,
  104. columns: 2,
  105. defaults: {
  106. xtype: 'button',
  107. scale: 'large',
  108. width: '100%',
  109. iconAlign: 'left'
  110. },
  111. items: [{
  112. text: 'User<br/>manager',
  113. iconCls: 'edit'
  114. },{
  115. iconCls: 'add',
  116. width: 'auto',
  117. tooltip: 'Add user'
  118. },{
  119. colspan: 2,
  120. text: 'Import',
  121. scale: 'small'
  122. },{
  123. colspan: 2,
  124. text: 'Who is online?',
  125. scale: 'small'
  126. }]
  127. }
  128. }
  129. },
  130. new Ext.Toolbar.SplitButton({
  131. text: 'Split Button',
  132. handler: onButtonClick,
  133. tooltip: {text:'This is a an example QuickTip for a toolbar item', title:'Tip Title'},
  134. iconCls: 'blist',
  135. // Menus can be built/referenced by using nested menu config objects
  136. menu : {
  137. items: [{
  138. text: '<b>Bold</b>', handler: onItemClick
  139. }, {
  140. text: '<i>Italic</i>', handler: onItemClick
  141. }, {
  142. text: '<u>Underline</u>', handler: onItemClick
  143. }, '-', {
  144. text: 'Pick a Color',
  145. handler: onItemClick,
  146. menu: {
  147. items: [
  148. new Ext.ColorPalette({
  149. listeners: {
  150. select: function(cp, color){
  151. Ext.example.msg('Color Selected', 'You chose {0}.', color);
  152. }
  153. }
  154. }), '-',
  155. {
  156. text: 'More Colors...',
  157. handler: onItemClick
  158. }
  159. ]
  160. }
  161. }, {
  162. text: 'Extellent!',
  163. handler: onItemClick
  164. }]
  165. }
  166. }), '-', {
  167. text: 'Toggle Me',
  168. enableToggle: true,
  169. toggleHandler: onItemToggle,
  170. pressed: true
  171. });
  172. menu.addSeparator();
  173. // Menus have a rich api for
  174. // adding and removing elements dynamically
  175. var item = menu.add({
  176. text: 'Dynamically added Item'
  177. });
  178. // items support full Observable API
  179. item.on('click', onItemClick);
  180. // items can easily be looked up
  181. menu.add({
  182. text: 'Disabled Item',
  183. id: 'disableMe' // <-- Items can also have an id for easy lookup
  184. // disabled: true <-- allowed but for sake of example we use long way below
  185. });
  186. // access items by id or index
  187. menu.items.get('disableMe').disable();
  188. // They can also be referenced by id in or components
  189. tb.add('-', {
  190. icon: 'list-items.gif', // icons can also be specified inline
  191. cls: 'x-btn-icon',
  192. tooltip: '<b>Quick Tips</b><br/>Icon only button with tooltip'
  193. }, '-');
  194. var scrollMenu = new Ext.menu.Menu();
  195. for (var i = 0; i < 50; ++i){
  196. scrollMenu.add({
  197. text: 'Item ' + (i + 1)
  198. });
  199. }
  200. // scrollable menu
  201. tb.add({
  202. icon: 'preview.png',
  203. cls: 'x-btn-text-icon',
  204. text: 'Scrolling Menu',
  205. menu: scrollMenu
  206. });
  207. // add a combobox to the toolbar
  208. var combo = new Ext.form.ComboBox({
  209. store: store,
  210. displayField: 'state',
  211. typeAhead: true,
  212. mode: 'local',
  213. triggerAction: 'all',
  214. emptyText:'Select a state...',
  215. selectOnFocus:true,
  216. width:135
  217. });
  218. tb.addField(combo);
  219. tb.doLayout();
  220. // functions to display feedback
  221. function onButtonClick(btn){
  222. Ext.example.msg('Button Click','You clicked the "{0}" button.', btn.text);
  223. }
  224. function onItemClick(item){
  225. Ext.example.msg('Menu Click', 'You clicked the "{0}" menu item.', item.text);
  226. }
  227. function onItemCheck(item, checked){
  228. Ext.example.msg('Item Check', 'You {1} the "{0}" menu item.', item.text, checked ? 'checked' : 'unchecked');
  229. }
  230. function onItemToggle(item, pressed){
  231. Ext.example.msg('Button Toggled', 'Button "{0}" was toggled to {1}.', item.text, pressed);
  232. }
  233. });