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.

108 lines
3.6 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. var toolbar = new Ext.Toolbar({
  9. renderTo: 'docbody',
  10. plugins : [
  11. new Ext.ux.ToolbarDroppable({
  12. createItem: function(data) {
  13. var record = data.draggedRecord;
  14. return new Ext.Button({
  15. text : record.get('company'),
  16. iconCls: record.get('change') > 0 ? 'money-up' : 'money-down',
  17. reorderable: true
  18. });
  19. }
  20. }),
  21. new Ext.ux.ToolbarReorderer({defaultReorderable: false})
  22. ],
  23. items: ['Drag items here:']
  24. });
  25. // sample static data for the store
  26. var myData = [
  27. [1, '3m Co',71.72,0.02,0.03,'9/1 12:00am'],
  28. [2, 'Alcoa',29.01,0.42,1.47,'9/1 12:00am'],
  29. [3, 'Altria Group',83.81,-0.28,0.34,'9/1 12:00am'],
  30. [4, 'American Express',52.55,0.01,0.02,'9/1 12:00am'],
  31. [5, 'Microsoft',25.84,-0.14,0.54,'9/1 12:00am'],
  32. [6, 'Pfizer Inc',27.96,-0.4,1.45,'9/1 12:00am'],
  33. [7, 'Coca-Cola',45.07,0.26,0.58,'9/1 12:00am'],
  34. [8, 'Home Depot.',34.64,0.35,1.02,'9/1 12:00am'],
  35. [9, 'Procter & Gamble',61.91,0.01,0.02,'9/1 12:00am'],
  36. [10, 'United Technologies',63.26,-0.55,0.88,'9/1 12:00am'],
  37. [11, 'Verizon Communications',35.57,0.39,1.11,'9/1 12:00am'],
  38. [12, 'Wal-Mart Stores',45.45,-0.73,1.63,'9/1 12:00am']
  39. ];
  40. // create the data store
  41. var store = new Ext.data.ArrayStore({
  42. fields: [
  43. {name: 'id'},
  44. {name: 'company'},
  45. {name: 'price', type: 'float'},
  46. {name: 'change', type: 'float'},
  47. {name: 'pctChange', type: 'float'},
  48. {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
  49. ]
  50. });
  51. store.loadData(myData);
  52. var dataview = new Ext.DataView({
  53. emptyText: 'No items to display',
  54. singleSelect: true,
  55. autoScroll: true,
  56. overClass: 'x-view-over',
  57. itemSelector: 'div.company',
  58. store: store,
  59. tpl: new Ext.XTemplate(
  60. '<tpl for=".">',
  61. '<div class="company">',
  62. '<h3>{company}</h3>',
  63. '<p class="{[values.change > 0 ? "up" : "down"]}">{[values.change > 0 ? "Up" : "Down"]} {pctChange} since {lastChange:date("d/m/Y")}',
  64. '</div>',
  65. '</tpl>'
  66. )
  67. });
  68. dataview.on('render', function(v) {
  69. dataview.dragZone = new Ext.dd.DragZone(v.getEl(), {
  70. getDragData: function(e) {
  71. var sourceEl = e.getTarget(v.itemSelector, 10);
  72. if (sourceEl) {
  73. d = sourceEl.cloneNode(true);
  74. d.id = Ext.id();
  75. return {
  76. ddel: d,
  77. sourceEl: sourceEl,
  78. repairXY: Ext.fly(sourceEl).getXY(),
  79. sourceStore: v.store,
  80. draggedRecord: v.getRecord(sourceEl)
  81. };
  82. }
  83. },
  84. getRepairXY: function() {
  85. return this.dragData.repairXY;
  86. }
  87. });
  88. });
  89. new Ext.Panel({
  90. renderTo: 'docbody',
  91. tbar : toolbar,
  92. border : true,
  93. width : 600,
  94. height : 400,
  95. layout : 'fit',
  96. items : dataview
  97. });
  98. });