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.

148 lines
5.1 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. MultiLangDemo = function() {
  8. // get the selected language code parameter from url (if exists)
  9. var params = Ext.urlDecode(window.location.search.substring(1));
  10. Ext.form.Field.prototype.msgTarget = 'side';
  11. return {
  12. init: function() {
  13. Ext.QuickTips.init();
  14. /* Language chooser combobox */
  15. var store = new Ext.data.ArrayStore({
  16. fields: ['code', 'language', 'charset'],
  17. data : Ext.exampledata.languages // from languages.js
  18. });
  19. var combo = new Ext.form.ComboBox({
  20. renderTo: 'languages',
  21. store: store,
  22. displayField:'language',
  23. typeAhead: true,
  24. mode: 'local',
  25. triggerAction: 'all',
  26. emptyText: 'Select a language...',
  27. selectOnFocus: true,
  28. onSelect: function(record) {
  29. window.location.search = Ext.urlEncode({"lang":record.get("code"),"charset":record.get("charset")});
  30. }
  31. });
  32. if (params.lang) {
  33. // check if there's really a language with that language code
  34. record = store.data.find(function(item, key){
  35. if (item.data.code == params.lang) {
  36. return true;
  37. }
  38. return false;
  39. });
  40. // if language was found in store assign it as current value in combobox
  41. if (record) {
  42. combo.setValue(record.data.language);
  43. }
  44. }
  45. if (params.lang) {
  46. var url = String.format("../../src/locale/ext-lang-{0}.js", params.lang);
  47. Ext.Ajax.request({
  48. url: url,
  49. success: this.onSuccess,
  50. failure: this.onFailure,
  51. scope: this
  52. });
  53. } else {
  54. this.setupDemo();
  55. }
  56. },
  57. onSuccess: function(response, opts) {
  58. eval(response.responseText);
  59. this.setupDemo();
  60. },
  61. onFailure: function() {
  62. Ext.Msg.alert('Failure', 'Failed to load locale file.');
  63. this.setupDemo();
  64. },
  65. setupDemo: function() {
  66. /* Email field */
  67. var emailfield = new Ext.FormPanel({
  68. renderTo: 'emailfield',
  69. labelWidth: 100, // label settings here cascade unless overridden
  70. frame: true,
  71. title: 'Email Field',
  72. bodyStyle: 'padding:5px 5px 0',
  73. width: 360,
  74. defaults: {width: 220},
  75. defaultType: 'textfield',
  76. items: [{
  77. fieldLabel: 'Email',
  78. name: 'email',
  79. vtype: 'email'
  80. }]
  81. });
  82. /* Datepicker */
  83. var datefield = new Ext.FormPanel({
  84. renderTo: 'datefield',
  85. labelWidth: 100, // label settings here cascade unless overridden
  86. frame: true,
  87. title: 'Datepicker',
  88. bodyStyle: 'padding:5px 5px 0',
  89. width: 360,
  90. defaults: {width: 220},
  91. defaultType: 'datefield',
  92. items: [{
  93. fieldLabel: 'Date',
  94. name: 'date'
  95. }]
  96. });
  97. // shorthand alias
  98. var fm = Ext.form, Ed = Ext.grid.GridEditor;
  99. var monthArray = Date.monthNames.map(function (e) { return [e]; });
  100. var ds = new Ext.data.Store({
  101. proxy: new Ext.ux.data.PagingMemoryProxy(monthArray),
  102. reader: new Ext.data.ArrayReader({}, [
  103. {name: 'month'}
  104. ])
  105. });
  106. var cm = new Ext.grid.ColumnModel([{
  107. header: "Months of the year",
  108. dataIndex: 'month',
  109. editor: new Ed(new fm.TextField({
  110. allowBlank: false
  111. })),
  112. width: 240,
  113. defaultSortable: true
  114. }]);
  115. var grid = new Ext.grid.GridPanel({
  116. renderTo: 'grid',
  117. width: 360,
  118. height: 203,
  119. title:'Month Browser',
  120. store: ds,
  121. cm: cm,
  122. sm: new Ext.grid.RowSelectionModel({selectRow:Ext.emptyFn}),
  123. bbar: new Ext.PagingToolbar({
  124. pageSize: 6,
  125. store: ds,
  126. displayInfo: true
  127. })
  128. });
  129. // trigger the data store load
  130. ds.load({params:{start:0, limit:6}});
  131. }
  132. };
  133. }();
  134. Ext.onReady(MultiLangDemo.init, MultiLangDemo);