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.

118 lines
3.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. /**
  16. * @class Ext.ux.ProgressBarPager
  17. * @extends Object
  18. * Plugin (ptype = 'tabclosemenu') for displaying a progressbar inside of a paging toolbar instead of plain text
  19. *
  20. * @ptype progressbarpager
  21. * @constructor
  22. * Create a new ItemSelector
  23. * @param {Object} config Configuration options
  24. * @xtype itemselector
  25. */
  26. Ext.ux.ProgressBarPager = Ext.extend(Object, {
  27. <div id="cfg-Ext.ux.ProgressBarPager-progBarWidth"></div>/**
  28. * @cfg {Integer} progBarWidth
  29. * <p>The default progress bar width. Default is 225.</p>
  30. */
  31. progBarWidth : 225,
  32. <div id="cfg-Ext.ux.ProgressBarPager-defaultText"></div>/**
  33. * @cfg {String} defaultText
  34. * <p>The text to display while the store is loading. Default is 'Loading...'</p>
  35. */
  36. defaultText : 'Loading...',
  37. <div id="cfg-Ext.ux.ProgressBarPager-defaultAnimCfg"></div>/**
  38. * @cfg {Object} defaultAnimCfg
  39. * <p>A {@link Ext.Fx Ext.Fx} configuration object. Default is { duration : 1, easing : 'bounceOut' }.</p>
  40. */
  41. defaultAnimCfg : {
  42. duration : 1,
  43. easing : 'bounceOut'
  44. },
  45. constructor : function(config) {
  46. if (config) {
  47. Ext.apply(this, config);
  48. }
  49. },
  50. //public
  51. init : function (parent) {
  52. if(parent.displayInfo){
  53. this.parent = parent;
  54. var ind = parent.items.indexOf(parent.displayItem);
  55. parent.remove(parent.displayItem, true);
  56. this.progressBar = new Ext.ProgressBar({
  57. text : this.defaultText,
  58. width : this.progBarWidth,
  59. animate : this.defaultAnimCfg
  60. });
  61. parent.displayItem = this.progressBar;
  62. parent.add(parent.displayItem);
  63. parent.doLayout();
  64. Ext.apply(parent, this.parentOverrides);
  65. this.progressBar.on('render', function(pb) {
  66. pb.mon(pb.getEl().applyStyles('cursor:pointer'), 'click', this.handleProgressBarClick, this);
  67. }, this, {single: true});
  68. }
  69. },
  70. // private
  71. // This method handles the click for the progress bar
  72. handleProgressBarClick : function(e){
  73. var parent = this.parent,
  74. displayItem = parent.displayItem,
  75. box = this.progressBar.getBox(),
  76. xy = e.getXY(),
  77. position = xy[0]-box.x,
  78. pages = Math.ceil(parent.store.getTotalCount()/parent.pageSize),
  79. newpage = Math.ceil(position/(displayItem.width/pages));
  80. parent.changePage(newpage);
  81. },
  82. // private, overriddes
  83. parentOverrides : {
  84. // private
  85. // This method updates the information via the progress bar.
  86. updateInfo : function(){
  87. if(this.displayItem){
  88. var count = this.store.getCount(),
  89. pgData = this.getPageData(),
  90. pageNum = this.readPage(pgData),
  91. msg = count == 0 ?
  92. this.emptyMsg :
  93. String.format(
  94. this.displayMsg,
  95. this.cursor+1, this.cursor+count, this.store.getTotalCount()
  96. );
  97. pageNum = pgData.activePage; ;
  98. var pct = pageNum / pgData.pages;
  99. this.displayItem.updateProgress(pct, msg, this.animate || this.defaultAnimConfig);
  100. }
  101. }
  102. }
  103. });
  104. Ext.preg('progressbarpager', Ext.ux.ProgressBarPager);
  105. </pre>
  106. </body>
  107. </html>