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.

337 lines
13 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. // turn on validation errors beside the field globally
  10. Ext.form.Field.prototype.msgTarget = 'side';
  11. /*====================================================================
  12. * Individual checkbox/radio examples
  13. *====================================================================*/
  14. // Using checkbox/radio groups will generally be easier and more flexible than
  15. // using individual checkbox and radio controls, but this shows that you can
  16. // certainly do so if you only need a single control, or if you want to control
  17. // exactly where each check/radio goes within your layout.
  18. var individual = [{
  19. bodyStyle: 'padding-right:5px;',
  20. items: {
  21. xtype: 'fieldset',
  22. title: 'Individual Checkboxes',
  23. autoHeight: true,
  24. defaultType: 'checkbox', // each item will be a checkbox
  25. items: [{
  26. xtype: 'textfield',
  27. name: 'txt-test1',
  28. fieldLabel: 'Alignment Test'
  29. }, {
  30. fieldLabel: 'Favorite Animals',
  31. boxLabel: 'Dog',
  32. name: 'fav-animal-dog'
  33. }, {
  34. fieldLabel: '',
  35. labelSeparator: '',
  36. boxLabel: 'Cat',
  37. name: 'fav-animal-cat'
  38. }, {
  39. checked: true,
  40. fieldLabel: '',
  41. labelSeparator: '',
  42. boxLabel: 'Monkey',
  43. name: 'fav-animal-monkey'
  44. }]
  45. }
  46. }, {
  47. bodyStyle: 'padding-left:5px;',
  48. items: {
  49. xtype: 'fieldset',
  50. title: 'Individual Radios',
  51. autoHeight: true,
  52. defaultType: 'radio', // each item will be a radio button
  53. items: [{
  54. xtype: 'textfield',
  55. name: 'txt-test2',
  56. fieldLabel: 'Alignment Test'
  57. }, {
  58. checked: true,
  59. fieldLabel: 'Favorite Color',
  60. boxLabel: 'Red',
  61. name: 'fav-color',
  62. inputValue: 'red'
  63. }, {
  64. fieldLabel: '',
  65. labelSeparator: '',
  66. boxLabel: 'Blue',
  67. name: 'fav-color',
  68. inputValue: 'blue'
  69. }, {
  70. fieldLabel: '',
  71. labelSeparator: '',
  72. boxLabel: 'Green',
  73. name: 'fav-color',
  74. inputValue: 'green'
  75. }]
  76. }
  77. }];
  78. /*====================================================================
  79. * CheckGroup example
  80. *====================================================================*/
  81. var checkGroup = {
  82. xtype: 'fieldset',
  83. title: 'Checkbox Groups (initially collapsed)',
  84. autoHeight: true,
  85. layout: 'form',
  86. collapsed: true, // initially collapse the group
  87. collapsible: true,
  88. items: [{
  89. xtype: 'textfield',
  90. name: 'txt-test3',
  91. fieldLabel: 'Alignment Test',
  92. anchor: '95%'
  93. },{
  94. // Use the default, automatic layout to distribute the controls evenly
  95. // across a single row
  96. xtype: 'checkboxgroup',
  97. fieldLabel: 'Auto Layout',
  98. items: [
  99. {boxLabel: 'Item 1', name: 'cb-auto-1'},
  100. {boxLabel: 'Item 2', name: 'cb-auto-2', checked: true},
  101. {boxLabel: 'Item 3', name: 'cb-auto-3'},
  102. {boxLabel: 'Item 4', name: 'cb-auto-4'},
  103. {boxLabel: 'Item 5', name: 'cb-auto-5'}
  104. ]
  105. },{
  106. xtype: 'checkboxgroup',
  107. fieldLabel: 'Single Column',
  108. itemCls: 'x-check-group-alt',
  109. // Put all controls in a single column with width 100%
  110. columns: 1,
  111. items: [
  112. {boxLabel: 'Item 1', name: 'cb-col-1'},
  113. {boxLabel: 'Item 2', name: 'cb-col-2', checked: true},
  114. {boxLabel: 'Item 3', name: 'cb-col-3'}
  115. ]
  116. },{
  117. xtype: 'checkboxgroup',
  118. fieldLabel: 'Multi-Column (horizontal)',
  119. // Distribute controls across 3 even columns, filling each row
  120. // from left to right before starting the next row
  121. columns: 3,
  122. items: [
  123. {boxLabel: 'Item 1', name: 'cb-horiz-1'},
  124. {boxLabel: 'Item 2', name: 'cb-horiz-2', checked: true},
  125. {boxLabel: 'Item 3', name: 'cb-horiz-3'},
  126. {boxLabel: 'Item 4', name: 'cb-horiz-4'},
  127. {boxLabel: 'Item 5', name: 'cb-horiz-5'}
  128. ]
  129. },{
  130. xtype: 'checkboxgroup',
  131. fieldLabel: 'Multi-Column (vertical)',
  132. itemCls: 'x-check-group-alt',
  133. // Distribute controls across 3 even columns, filling each column
  134. // from top to bottom before starting the next column
  135. columns: 3,
  136. vertical: true,
  137. items: [
  138. {boxLabel: 'Item 1', name: 'cb-vert-1'},
  139. {boxLabel: 'Item 2', name: 'cb-vert-2', checked: true},
  140. {boxLabel: 'Item 3', name: 'cb-vert-3'},
  141. {boxLabel: 'Item 4', name: 'cb-vert-4'},
  142. {boxLabel: 'Item 5', name: 'cb-vert-5'}
  143. ]
  144. },{
  145. xtype: 'checkboxgroup',
  146. fieldLabel: 'Multi-Column<br />(custom widths)',
  147. // Specify exact column widths (could also include float values for %)
  148. columns: [100, 100],
  149. vertical: true,
  150. items: [
  151. {boxLabel: 'Item 1', name: 'cb-custwidth', inputValue: 1},
  152. {boxLabel: 'Item 2', name: 'cb-custwidth', inputValue: 2, checked: true},
  153. {boxLabel: 'Item 3', name: 'cb-custwidth', inputValue: 3},
  154. {boxLabel: 'Item 4', name: 'cb-custwidth', inputValue: 4},
  155. {boxLabel: 'Item 5', name: 'cb-custwidth', inputValue: 5}
  156. ]
  157. },{
  158. xtype: 'checkboxgroup',
  159. itemCls: 'x-check-group-alt',
  160. fieldLabel: 'Custom Layout<br />(w/ validation)',
  161. allowBlank: false,
  162. anchor: '95%',
  163. items: [{
  164. // You can pass sub-item arrays along with width/columnWidth configs
  165. // ColumnLayout-style for complete layout control. In this example we
  166. // only want one item in the middle column, which would not be possible
  167. // using the columns config. We also want to make sure that our headings
  168. // end up at the top of each column as expected.
  169. columnWidth: '.25',
  170. items: [
  171. {xtype: 'label', text: 'Heading 1', cls:'x-form-check-group-label', anchor:'-15'},
  172. {boxLabel: 'Item 1', name: 'cb-cust-1'},
  173. {boxLabel: 'Item 2', name: 'cb-cust-2'}
  174. ]
  175. },{
  176. columnWidth: '.5',
  177. items: [
  178. {xtype: 'label', text: 'Heading 2', cls:'x-form-check-group-label', anchor:'-15'},
  179. {boxLabel: 'A long item just for fun', name: 'cb-cust-3'}
  180. ]
  181. },{
  182. columnWidth: '.25',
  183. items: [
  184. {xtype: 'label', text: 'Heading 3', cls:'x-form-check-group-label', anchor:'-15'},
  185. {boxLabel: 'Item 4', name: 'cb-cust-4'},
  186. {boxLabel: 'Item 5', name: 'cb-cust-5'}
  187. ]
  188. }]
  189. }]
  190. };
  191. /*====================================================================
  192. * RadioGroup examples
  193. *====================================================================*/
  194. // NOTE: These radio examples use the exact same options as the checkbox ones
  195. // above, so the comments will not be repeated. Please see comments above for
  196. // additional explanation on some config options.
  197. var radioGroup = {
  198. xtype: 'fieldset',
  199. title: 'Radio Groups',
  200. autoHeight: true,
  201. items: [{
  202. xtype: 'textfield',
  203. name: 'txt-test4',
  204. fieldLabel: 'Alignment Test',
  205. anchor: '95%'
  206. },{
  207. xtype: 'radiogroup',
  208. fieldLabel: 'Auto Layout',
  209. items: [
  210. {boxLabel: 'Item 1', name: 'rb-auto', inputValue: 1},
  211. {boxLabel: 'Item 2', name: 'rb-auto', inputValue: 2, checked: true},
  212. {boxLabel: 'Item 3', name: 'rb-auto', inputValue: 3},
  213. {boxLabel: 'Item 4', name: 'rb-auto', inputValue: 4},
  214. {boxLabel: 'Item 5', name: 'rb-auto', inputValue: 5}
  215. ]
  216. },{
  217. xtype: 'radiogroup',
  218. fieldLabel: 'Single Column',
  219. itemCls: 'x-check-group-alt',
  220. columns: 1,
  221. items: [
  222. {boxLabel: 'Item 1', name: 'rb-col', inputValue: 1},
  223. {boxLabel: 'Item 2', name: 'rb-col', inputValue: 2, checked: true},
  224. {boxLabel: 'Item 3', name: 'rb-col', inputValue: 3}
  225. ]
  226. },{
  227. xtype: 'radiogroup',
  228. fieldLabel: 'Multi-Column<br />(horiz. auto-width)',
  229. columns: 3,
  230. items: [
  231. {boxLabel: 'Item 1', name: 'rb-horiz', inputValue: 1},
  232. {boxLabel: 'Item 2', name: 'rb-horiz', inputValue: 2, checked: true},
  233. {boxLabel: 'Item 3', name: 'rb-horiz', inputValue: 3},
  234. {boxLabel: 'Item 4', name: 'rb-horiz', inputValue: 4},
  235. {boxLabel: 'Item 5', name: 'rb-horiz', inputValue: 5}
  236. ]
  237. },{
  238. xtype: 'radiogroup',
  239. fieldLabel: 'Multi-Column<br />(vert. auto-width)',
  240. itemCls: 'x-check-group-alt',
  241. columns: 3,
  242. vertical: true,
  243. items: [
  244. {boxLabel: 'Item 1', name: 'rb-vert', inputValue: 1},
  245. {boxLabel: 'Item 2', name: 'rb-vert', inputValue: 2, checked: true},
  246. {boxLabel: 'Item 3', name: 'rb-vert', inputValue: 3},
  247. {boxLabel: 'Item 4', name: 'rb-vert', inputValue: 4},
  248. {boxLabel: 'Item 5', name: 'rb-vert', inputValue: 5}
  249. ]
  250. },{
  251. xtype: 'radiogroup',
  252. fieldLabel: 'Multi-Column<br />(custom widths)',
  253. columns: [100, 100],
  254. vertical: true,
  255. items: [
  256. {boxLabel: 'Item 1', name: 'rb-custwidth', inputValue: 1},
  257. {boxLabel: 'Item 2', name: 'rb-custwidth', inputValue: 2, checked: true},
  258. {boxLabel: 'Item 3', name: 'rb-custwidth', inputValue: 3},
  259. {boxLabel: 'Item 4', name: 'rb-custwidth', inputValue: 4},
  260. {boxLabel: 'Item 5', name: 'rb-custwidth', inputValue: 5}
  261. ]
  262. },{
  263. xtype: 'radiogroup',
  264. itemCls: 'x-check-group-alt',
  265. fieldLabel: 'Custom Layout<br />(w/ validation)',
  266. allowBlank: false,
  267. anchor: '95%',
  268. items: [{
  269. columnWidth: '.25',
  270. items: [
  271. {xtype: 'label', text: 'Heading 1', cls:'x-form-check-group-label', anchor:'-15'},
  272. {boxLabel: 'Item 1', name: 'rb-cust', inputValue: 1},
  273. {boxLabel: 'Item 2', name: 'rb-cust', inputValue: 2}
  274. ]
  275. },{
  276. columnWidth: '.5',
  277. items: [
  278. {xtype: 'label', text: 'Heading 2', cls:'x-form-check-group-label', anchor:'-15'},
  279. {boxLabel: 'A long item just for fun', name: 'rb-cust', inputValue: 3}
  280. ]
  281. },{
  282. columnWidth: '.25',
  283. items: [
  284. {xtype: 'label', text: 'Heading 3', cls:'x-form-check-group-label', anchor:'-15'},
  285. {boxLabel: 'Item 4', name: 'rb-cust', inputValue: 4},
  286. {boxLabel: 'Item 5', name: 'rb-cust', inputValue: 5}
  287. ]
  288. }]
  289. }]
  290. };
  291. // combine all that into one huge form
  292. var fp = new Ext.FormPanel({
  293. title: 'Check/Radio Groups Example',
  294. frame: true,
  295. labelWidth: 110,
  296. width: 600,
  297. renderTo:'form-ct',
  298. bodyStyle: 'padding:0 10px 0;',
  299. items: [
  300. {
  301. layout: 'column',
  302. border: false,
  303. // defaults are applied to all child items unless otherwise specified by child item
  304. defaults: {
  305. columnWidth: '.5',
  306. border: false
  307. },
  308. items: individual
  309. },
  310. checkGroup,
  311. radioGroup
  312. ],
  313. buttons: [{
  314. text: 'Save',
  315. handler: function(){
  316. if(fp.getForm().isValid()){
  317. Ext.Msg.alert('Submitted Values', 'The following will be sent to the server: <br />'+
  318. fp.getForm().getValues(true).replace(/&/g,', '));
  319. }
  320. }
  321. },{
  322. text: 'Reset',
  323. handler: function(){
  324. fp.getForm().reset();
  325. }
  326. }]
  327. });
  328. });