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.

256 lines
8.7 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. // This is a shared function that simulates a load action on a StatusBar.
  17. // It is reused by most of the example panels.
  18. var loadFn = function(btn, statusBar){
  19. btn = Ext.getCmp(btn);
  20. statusBar = Ext.getCmp(statusBar);
  21. btn.disable();
  22. statusBar.showBusy();
  23. (function(){
  24. statusBar.clearStatus({useDefaults:true});
  25. btn.enable();
  26. }).defer(2000);
  27. };
  28. /*
  29. * ================ Basic StatusBar example =======================
  30. */
  31. new Ext.Panel({
  32. title: 'Basic StatusBar',
  33. renderTo: 'basic',
  34. width: 550,
  35. height: 100,
  36. bodyStyle: 'padding:10px;',
  37. items:[{
  38. xtype: 'button',
  39. id: 'basic-button',
  40. text: 'Do Loading',
  41. handler: loadFn.createCallback('basic-button', 'basic-statusbar')
  42. }],
  43. bbar: new Ext.ux.StatusBar({
  44. id: 'basic-statusbar',
  45. // defaults to use when the status is cleared:
  46. defaultText: 'Default status text',
  47. //defaultIconCls: 'default-icon',
  48. // values to set initially:
  49. text: 'Ready',
  50. iconCls: 'x-status-valid',
  51. // any standard Toolbar items:
  52. items: [
  53. {
  54. text: 'Show Warning & Clear',
  55. handler: function (){
  56. var sb = Ext.getCmp('basic-statusbar');
  57. sb.setStatus({
  58. text: 'Oops!',
  59. iconCls: 'x-status-error',
  60. clear: true // auto-clear after a set interval
  61. });
  62. }
  63. },
  64. {
  65. text: 'Show Busy',
  66. handler: function (){
  67. var sb = Ext.getCmp('basic-statusbar');
  68. // Set the status bar to show that something is processing:
  69. sb.showBusy();
  70. }
  71. },
  72. {
  73. text: 'Clear status',
  74. handler: function (){
  75. var sb = Ext.getCmp('basic-statusbar');
  76. // once completed
  77. sb.clearStatus();
  78. }
  79. },
  80. '-',
  81. 'Plain Text'
  82. ]
  83. })
  84. });
  85. /*
  86. * ================ Right-aligned StatusBar example =======================
  87. */
  88. new Ext.Panel({
  89. title: 'Right-aligned StatusBar',
  90. renderTo: 'right-aligned',
  91. width: 550,
  92. height: 100,
  93. bodyStyle: 'padding:10px;',
  94. items:[{
  95. xtype: 'button',
  96. id: 'right-button',
  97. text: 'Do Loading',
  98. handler: loadFn.createCallback('right-button', 'right-statusbar')
  99. }],
  100. bbar: new Ext.ux.StatusBar({
  101. defaultText: 'Default status',
  102. id: 'right-statusbar',
  103. statusAlign: 'right', // the magic config
  104. items: [{
  105. text: 'A Button'
  106. }, '-', 'Plain Text', ' ', ' ']
  107. })
  108. });
  109. /*
  110. * ================ StatusBar Window example =======================
  111. */
  112. var win = new Ext.Window({
  113. title: 'StatusBar Window',
  114. width: 400,
  115. minWidth: 350,
  116. height: 150,
  117. modal: true,
  118. closeAction: 'hide',
  119. bodyStyle: 'padding:10px;',
  120. items:[{
  121. xtype: 'button',
  122. id: 'win-button',
  123. text: 'Do Loading',
  124. handler: loadFn.createCallback('win-button', 'win-statusbar')
  125. }],
  126. bbar: new Ext.ux.StatusBar({
  127. id: 'win-statusbar',
  128. defaultText: 'Ready',
  129. items: [{
  130. text: 'A Button'
  131. }, '-',
  132. new Date().format('n/d/Y'), ' ', ' ', '-', {
  133. xtype:'tbsplit',
  134. text:'Status Menu',
  135. menuAlign: 'br-tr?',
  136. menu: new Ext.menu.Menu({
  137. items: [{text: 'Item 1'}, {text: 'Item 2'}]
  138. })
  139. }]
  140. })
  141. });
  142. new Ext.Button({
  143. text: 'Show Window',
  144. renderTo: 'window',
  145. handler: function(){
  146. win.show();
  147. }
  148. });
  149. /*
  150. * ================ Ext Word Processor example =======================
  151. *
  152. * The StatusBar used in this example is completely standard. What is
  153. * customized are the styles and event handling to make the example a
  154. * lot more dynamic and application-oriented.
  155. *
  156. */
  157. // Create these explicitly so we can manipulate them later
  158. var wordCount = new Ext.Toolbar.TextItem('Words: 0');
  159. var charCount = new Ext.Toolbar.TextItem('Chars: 0');
  160. var clock = new Ext.Toolbar.TextItem('');
  161. new Ext.Panel({
  162. title: 'Ext Word Processor',
  163. renderTo: 'word-proc',
  164. width: 500,
  165. autoHeight: true,
  166. bodyStyle: 'padding:5px;',
  167. layout: 'fit',
  168. bbar: new Ext.ux.StatusBar({
  169. id: 'word-status',
  170. // These are just the standard toolbar TextItems we created above. They get
  171. // custom classes below in the render handler which is what gives them their
  172. // customized inset appearance.
  173. items: [wordCount, ' ', charCount, ' ', clock, ' ']
  174. }),
  175. items: {
  176. xtype: 'textarea',
  177. id: 'word-textarea',
  178. enableKeyEvents: true,
  179. grow: true,
  180. growMin: 100,
  181. growMax: 200,
  182. listeners: {
  183. // After each keypress update the word and character count text items
  184. 'keypress': {
  185. fn: function(t){
  186. var v = t.getValue(),
  187. wc = 0, cc = v.length ? v.length : 0;
  188. if(cc > 0){
  189. wc = v.match(/\b/g);
  190. wc = wc ? wc.length / 2 : 0;
  191. }
  192. Ext.fly(wordCount.getEl()).update('Words: '+wc);
  193. Ext.fly(charCount.getEl()).update('Chars: '+cc);
  194. },
  195. buffer: 1 // buffer to allow the value to update first
  196. }
  197. }
  198. },
  199. listeners: {
  200. render: {
  201. fn: function(){
  202. // Add a class to the parent TD of each text item so we can give them some custom inset box
  203. // styling. Also, since we are using a greedy spacer, we have to add a block level element
  204. // into each text TD in order to give them a fixed width (TextItems are spans). Insert a
  205. // spacer div into each TD using createChild() so that we can give it a width in CSS.
  206. Ext.fly(wordCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
  207. Ext.fly(charCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
  208. Ext.fly(clock.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
  209. // Kick off the clock timer that updates the clock el every second:
  210. Ext.TaskMgr.start({
  211. run: function(){
  212. Ext.fly(clock.getEl()).update(new Date().format('g:i:s A'));
  213. },
  214. interval: 1000
  215. });
  216. },
  217. delay: 100
  218. }
  219. }
  220. });
  221. // This sets up a fake auto-save function. It monitors keyboard activity and after no typing
  222. // has occurred for 1.5 seconds, it updates the status message to indicate that it's saving.
  223. // After a fake delay so that you can see the save activity it will update again to indicate
  224. // that the action succeeded.
  225. Ext.fly('word-textarea').on('keypress', function(){
  226. var sb = Ext.getCmp('word-status');
  227. sb.showBusy('Saving draft...');
  228. (function(){
  229. sb.setStatus({
  230. iconCls: 'x-status-saved',
  231. text: 'Draft auto-saved at ' + new Date().format('g:i:s A')
  232. });
  233. }).defer(4000);
  234. }, this, {buffer:1500});
  235. });