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.

603 lines
18 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.onReady(function(){
  16. var items = [];
  17. Ext.QuickTips.init();
  18. //=============================================================
  19. // Layout grid toggle button
  20. //=============================================================
  21. // items.push({
  22. // xtype: 'panel',
  23. // border: false,
  24. // width: 120,
  25. // x: 50, y: 20,
  26. // items: {
  27. // xtype: 'button',
  28. // text: 'Toggle Layout Grid',
  29. // handler: function(){
  30. // Ext.getBody().toggleClass('x-layout-grid');
  31. // }
  32. // }
  33. // });
  34. //=============================================================
  35. // Panel / Window
  36. //=============================================================
  37. items.push({
  38. xtype: 'panel',
  39. width: 150,
  40. height: 150,
  41. title: 'Basic Panel',
  42. bodyStyle: {padding: '5px'},
  43. html: 'Some content',
  44. collapsible: true,
  45. x: 50, y: 100
  46. });
  47. items.push({
  48. xtype: 'panel',
  49. width: 150,
  50. height: 150,
  51. title: 'Masked Panel',
  52. x: 210, y: 100,
  53. bodyStyle: {padding: '5px'},
  54. html: 'Some content',
  55. collapsible: true,
  56. listeners: {
  57. 'render': function(p){
  58. p.body.mask('Loading...');
  59. },
  60. delay: 50
  61. }
  62. });
  63. items.push({
  64. xtype: 'panel',
  65. width: 150,
  66. height: 150,
  67. title: 'Framed Panel',
  68. html: 'Some content',
  69. frame: true,
  70. collapsible: true,
  71. x: 370, y: 100
  72. });
  73. new Ext.Window({
  74. width: 150,
  75. height: 150,
  76. title: 'Window',
  77. bodyStyle: {padding: '5px'},
  78. html: 'Click Submit for Confirmation Msg.',
  79. collapsible: true,
  80. closable: false,
  81. draggable: false,
  82. shadow: false,
  83. resizable: false,
  84. x: 530, y: 100,
  85. tbar: [{
  86. text: 'Toolbar'
  87. }],
  88. buttons: [{
  89. text: 'Submit',
  90. id: 'message_box',
  91. cls: 'x-icon-btn',
  92. iconCls: 'x-icon-btn-ok',
  93. handler: function(){
  94. Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?');
  95. }
  96. }]
  97. }).show();
  98. //=============================================================
  99. // Toolbar / Menu
  100. //=============================================================
  101. var menu = new Ext.menu.Menu({
  102. items: [{
  103. text: 'Menu item'
  104. },{
  105. text: 'Check 1',
  106. checked: true
  107. },{
  108. text: 'Check 2',
  109. checked: false
  110. }, '-', {
  111. text: 'Option 1',
  112. checked: true,
  113. group: 'opts'
  114. },{
  115. text: 'Option 2',
  116. checked: false,
  117. group: 'opts'
  118. }, '-', {
  119. text: 'Sub-items',
  120. menu: new Ext.menu.Menu({
  121. items: [{text: 'Item 1'},{text: 'Item 2'}]
  122. })
  123. }]
  124. });
  125. items.push({
  126. xtype: 'panel',
  127. width: 450,
  128. height: 150,
  129. title: 'Basic Panel With Toolbars',
  130. x: 690, y: 100,
  131. tbar: ['Toolbar & Menus', ' ', '-', {
  132. text: 'Button'
  133. },{
  134. text: 'Menu Button',
  135. id: 'menu-btn',
  136. menu: menu
  137. },{
  138. xtype: 'tbsplit',
  139. text: 'Split Button',
  140. menu: new Ext.menu.Menu({
  141. items: [{text: 'Item 1'},{text: 'Item 2'}]
  142. })
  143. },{
  144. xtype: 'button',
  145. enableToggle: true,
  146. pressed: true,
  147. text: 'Toggle Button'
  148. }],
  149. bbar: [{
  150. text: 'Bottom Bar'
  151. }]
  152. });
  153. //=============================================================
  154. // Form widgets
  155. //=============================================================
  156. items.push({
  157. xtype: 'form',
  158. id: 'form-widgets',
  159. title: 'Form Widgets',
  160. width: 630,
  161. height: 700,
  162. frame: true,
  163. x: 50, y: 260,
  164. tools: [
  165. {id:'toggle'},{id:'close'},{id:'minimize'},{id:'maximize'},{id:'restore'},{id:'gear'},{id:'pin'},
  166. {id:'unpin'},{id:'right'},{id:'left'},{id:'up'},{id:'down'},{id:'refresh'},{id:'minus'},{id:'plus'},
  167. {id:'help'},{id:'search'},{id:'save'},{id:'print'}
  168. ],
  169. bodyStyle: {
  170. padding: '10px 20px'
  171. },
  172. defaults: {
  173. anchor: '98%',
  174. msgTarget: 'side',
  175. allowBlank: false
  176. },
  177. items: [{
  178. xtype: 'label',
  179. text: 'Plain Label'
  180. },{
  181. fieldLabel: 'TextField',
  182. xtype: 'textfield',
  183. emptyText: 'Enter a value',
  184. itemCls: 'x-form-required'
  185. },{
  186. fieldLabel: 'ComboBox',
  187. xtype: 'combo',
  188. store: ['Foo', 'Bar'],
  189. itemCls: 'x-form-required',
  190. resizable: true
  191. },{
  192. fieldLabel: 'DateField',
  193. itemCls: 'x-form-required',
  194. xtype: 'datefield'
  195. },{
  196. fieldLabel: 'TimeField',
  197. itemCls: 'x-form-required',
  198. xtype: 'timefield'
  199. },{
  200. fieldLabel: 'NumberField',
  201. emptyText: '(This field is optional)',
  202. allowBlank: true,
  203. xtype: 'numberfield'
  204. },{
  205. fieldLabel: 'TextArea',
  206. //msgTarget: 'under',
  207. itemCls: 'x-form-required',
  208. xtype: 'textarea',
  209. cls: 'x-form-valid',
  210. value: 'This field is hard-coded to have the "valid" style (it will require some code changes to add/remove this style dynamically)'
  211. },{
  212. fieldLabel: 'Checkboxes',
  213. xtype: 'checkboxgroup',
  214. columns: [100,100],
  215. items: [{boxLabel: 'Foo', checked: true},{boxLabel: 'Bar'}]
  216. },{
  217. fieldLabel: 'Radios',
  218. xtype: 'radiogroup',
  219. columns: [100,100],
  220. items: [{boxLabel: 'Foo', checked: true, name: 'radios'},{boxLabel: 'Bar', name: 'radios'}]
  221. },{
  222. hideLabel: true,
  223. xtype: 'htmleditor',
  224. value: 'Mouse over toolbar for tooltips.<br /><br />The HTMLEditor IFrame requires a refresh between a stylesheet switch to get accurate colors.',
  225. height: 110,
  226. handler: function(){
  227. Ext.get('styleswitcher').on('click', function(e){
  228. Ext.getCmp('form-widgets').getForm().reset();
  229. });
  230. }
  231. },{
  232. title: 'Plain Fieldset',
  233. xtype: 'fieldset',
  234. height: 50
  235. },{
  236. title: 'Collapsible Fieldset',
  237. xtype: 'fieldset',
  238. collapsible: true,
  239. height: 50
  240. },{
  241. title: 'Checkbox Fieldset',
  242. xtype: 'fieldset',
  243. checkboxToggle: true,
  244. height: 50
  245. }],
  246. buttons: [{
  247. text:'Toggle Enabled',
  248. cls: 'x-icon-btn',
  249. iconCls: 'x-icon-btn-toggle',
  250. handler: function(){
  251. Ext.getCmp('form-widgets').getForm().items.each(function(ctl){
  252. ctl.setDisabled(!ctl.disabled);
  253. });
  254. }
  255. },{
  256. text: 'Reset Form',
  257. cls: 'x-icon-btn',
  258. iconCls: 'x-icon-btn-reset',
  259. handler: function(){
  260. Ext.getCmp('form-widgets').getForm().reset();
  261. }
  262. },{
  263. text:'Validate',
  264. cls: 'x-icon-btn',
  265. iconCls: 'x-icon-btn-ok',
  266. handler: function(){
  267. Ext.getCmp('form-widgets').getForm().isValid();
  268. }
  269. }]
  270. });
  271. //=============================================================
  272. // BorderLayout
  273. //=============================================================
  274. items.push({
  275. xtype: 'panel',
  276. width: 450,
  277. height: 350,
  278. title: 'BorderLayout Panel',
  279. x: 690, y: 260,
  280. layout: 'border',
  281. defaults: {
  282. collapsible: true,
  283. split: true
  284. },
  285. items: [{
  286. title: 'North',
  287. region: 'north',
  288. html: 'North',
  289. ctitle: 'North',
  290. margins: '5 5 0 5',
  291. height: 70
  292. },{
  293. title: 'South',
  294. region: 'south',
  295. html: 'South',
  296. collapseMode: 'mini',
  297. margins: '0 5 5 5',
  298. height: 70
  299. },{
  300. title: 'West',
  301. region: 'west',
  302. html: 'West',
  303. collapseMode: 'mini',
  304. margins: '0 0 0 5',
  305. width: 100
  306. },{
  307. title: 'East',
  308. region: 'east',
  309. html: 'East',
  310. margins: '0 5 0 0',
  311. width: 100
  312. },{
  313. title: 'Center',
  314. region: 'center',
  315. collapsible: false,
  316. html: 'Center'
  317. }]
  318. });
  319. //=============================================================
  320. // Grid
  321. //=============================================================
  322. var myData = [
  323. ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
  324. ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
  325. ['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am'],
  326. ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
  327. ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
  328. ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
  329. ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
  330. ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
  331. ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
  332. ['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'9/1 12:00am']
  333. ];
  334. var store = new Ext.data.SimpleStore({
  335. fields: [
  336. {name: 'company'},
  337. {name: 'price', type: 'float'},
  338. {name: 'change', type: 'float'},
  339. {name: 'pctChange', type: 'float'},
  340. {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
  341. ],
  342. sortInfo: {
  343. field: 'company', direction: 'ASC'
  344. }
  345. });
  346. var pagingBar = new Ext.PagingToolbar({
  347. pageSize: 5,
  348. store: store,
  349. displayInfo: true,
  350. displayMsg: 'Displaying topics {0} - {1} of {2}'
  351. });
  352. store.loadData(myData);
  353. items.push({
  354. xtype: 'grid',
  355. store: store,
  356. columns: [
  357. {id:'company',header: "Company", width: 160, sortable: true, dataIndex: 'company'},
  358. {header: "Price", width: 75, sortable: true, renderer: 'usMoney', dataIndex: 'price'},
  359. {header: "Change", width: 75, sortable: true, dataIndex: 'change'},
  360. {header: "% Change", width: 75, sortable: true, dataIndex: 'pctChange'},
  361. {header: "Last Updated", width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
  362. ],
  363. stripeRows: true,
  364. autoExpandColumn: 'company',
  365. loadMask: true,
  366. height: 200,
  367. width: 450,
  368. x: 690, y: 620,
  369. title:'GridPanel',
  370. bbar: pagingBar,
  371. tbar: [
  372. { text: 'Toolbar' },'->',
  373. new Ext.form.TwinTriggerField({
  374. xtype: 'twintriggerfield',
  375. trigger1Class: 'x-form-clear-trigger',
  376. trigger2Class: 'x-form-search-trigger'
  377. })
  378. ]
  379. });
  380. //=============================================================
  381. // ListView
  382. //=============================================================
  383. var listView = new Ext.list.ListView({
  384. store: store,
  385. multiSelect: true,
  386. emptyText: 'No images to display',
  387. reserveScrollOffset: true,
  388. columns: [
  389. {id:'company',header: "Company", width: .5, sortable: true, dataIndex: 'company'},
  390. {header: "Price", width: .25, sortable: true, tpl: '{price:usMoney}', dataIndex: 'price'},
  391. {header: "Change", width: .25, sortable: true, dataIndex: 'change'}
  392. ]
  393. });
  394. items.push({
  395. xtype:'panel',
  396. id:'images-view',
  397. width:250,
  398. height:182,
  399. x: 430, y: 1130,
  400. collapsible:false,
  401. layout:'fit',
  402. title:'Simple ListView', // <i>(0 items selected)</i>
  403. items: listView
  404. });
  405. //=============================================================
  406. // Accordion / Tree
  407. //=============================================================
  408. var tree = new Ext.tree.TreePanel({
  409. title: 'TreePanel',
  410. autoScroll: true,
  411. enableDD: true
  412. });
  413. var root = new Ext.tree.TreeNode({
  414. text: 'Root Node',
  415. expanded: true
  416. });
  417. tree.setRootNode(root);
  418. root.appendChild(new Ext.tree.TreeNode({text: 'Item 1'}));
  419. root.appendChild(new Ext.tree.TreeNode({text: 'Item 2'}));
  420. var node = new Ext.tree.TreeNode({text: 'Folder'});
  421. node.appendChild(new Ext.tree.TreeNode({text: 'Item 3'}));
  422. root.appendChild(node);
  423. var accConfig = {
  424. title: 'Accordion and TreePanel',
  425. layout: 'accordion',
  426. x: 690, y: 830,
  427. width: 450,
  428. height: 240,
  429. bodyStyle: {
  430. 'background-color': '#eee'
  431. },
  432. defaults: {
  433. border: false
  434. },
  435. items: [tree, {
  436. title: 'Item 2',
  437. html: 'Some content'
  438. },{
  439. title: 'Item 3',
  440. html: 'Some content'
  441. }]
  442. }
  443. items.push(accConfig);
  444. //=============================================================
  445. // Tabs
  446. //=============================================================
  447. var tabCfg = {
  448. xtype: 'tabpanel',
  449. activeTab: 0,
  450. width: 310,
  451. height: 150,
  452. defaults: {
  453. bodyStyle: 'padding:10px;'
  454. },
  455. items: [{
  456. title: 'Tab 1',
  457. html: 'Free-standing tab panel'
  458. },{
  459. title: 'Tab 2',
  460. closable: true
  461. },{
  462. title: 'Tab 3',
  463. closable: true
  464. }]
  465. };
  466. items.push(Ext.applyIf({
  467. x: 50, y: 970,
  468. enableTabScroll: true,
  469. items: [{
  470. title: 'Tab 1',
  471. html: 'Tab panel for display in a border layout'
  472. },{
  473. title: 'Tab 2',
  474. closable: true
  475. },{
  476. title: 'Tab 3',
  477. closable: true
  478. },{
  479. title: 'Tab 4',
  480. closable: true
  481. },{
  482. title: 'Tab 5',
  483. closable: true
  484. },{
  485. title: 'Tab 6',
  486. closable: true
  487. },{
  488. title: 'Tab 7',
  489. closable: true
  490. }] // enable 4 through 7 to see tab scrolling
  491. }, tabCfg));
  492. items.push(Ext.apply({
  493. plain: true,
  494. x: 370, y: 970
  495. }, tabCfg));
  496. //=============================================================
  497. // DatePicker
  498. //=============================================================
  499. items.push({
  500. xtype: 'panel',
  501. border: false,
  502. width: 180,
  503. x: 50, y: 1130,
  504. items: {
  505. xtype: 'datepicker'
  506. }
  507. });
  508. //=============================================================
  509. // Resizable
  510. //=============================================================
  511. var rszEl = Ext.DomHelper.append(Ext.getBody(), {
  512. style: 'background: transparent;', html: '<div style="padding:20px;">Resizable handles</div>'
  513. }, true);
  514. rszEl.position('absolute', 1, 240, 1130);
  515. rszEl.setSize(180, 180);
  516. new Ext.Resizable(rszEl, {
  517. handles: 'all',
  518. pinned: true
  519. });
  520. //=============================================================
  521. // ProgressBar / Slider
  522. //=============================================================
  523. items.push({
  524. xtype: 'panel',
  525. title: 'ProgressBar / Slider',
  526. x: 690, y: 1080,
  527. width: 450,
  528. height: 200,
  529. bodyStyle: {padding: '15px'},
  530. items: [{
  531. xtype: 'progress',
  532. value: .5,
  533. text: 'Progress text...'
  534. },{
  535. xtype: 'slider',
  536. value: 50
  537. },{
  538. xtype: 'slider',
  539. vertical: true,
  540. value: 50,
  541. height: 100
  542. }]
  543. });
  544. //=============================================================
  545. // Render everything!
  546. //=============================================================
  547. new Ext.Viewport({
  548. layout: 'absolute',
  549. //cls: 'x-layout-grid',
  550. autoScroll: true,
  551. items: items
  552. });
  553. Ext.getCmp('menu-btn').showMenu();
  554. //=============================================================
  555. // Stylesheet Switcher
  556. //=============================================================
  557. Ext.get('styleswitcher_select').on('change',function(e,select){
  558. var name = select[select.selectedIndex].value;
  559. setActiveStyleSheet(name);
  560. });
  561. var cookie = readCookie("style");
  562. var title = cookie ? cookie : getPreferredStyleSheet();
  563. Ext.get('styleswitcher_select').dom.value=title;
  564. });