1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | Ext.ux.SlidingPager = Ext.extend(Ext.util.Observable, { |
---|
10 | init : function(pbar){ |
---|
11 | this.pagingBar = pbar; |
---|
12 | |
---|
13 | pbar.on('render', this.onRender, this); |
---|
14 | pbar.on('beforedestroy', this.onDestroy, this); |
---|
15 | }, |
---|
16 | |
---|
17 | onRender : function(pbar){ |
---|
18 | Ext.each(pbar.items.getRange(2,6), function(c){ |
---|
19 | c.hide(); |
---|
20 | }); |
---|
21 | var td = document.createElement("td"); |
---|
22 | pbar.tr.insertBefore(td, pbar.tr.childNodes[5]); |
---|
23 | |
---|
24 | td.style.padding = '0 5px'; |
---|
25 | |
---|
26 | this.slider = new Ext.Slider({ |
---|
27 | width: 114, |
---|
28 | minValue: 1, |
---|
29 | maxValue: 1, |
---|
30 | plugins:new Ext.ux.SliderTip({ |
---|
31 | bodyStyle:'padding:5px;', |
---|
32 | getText : function(s){ |
---|
33 | return String.format('Page <b>{0}</b> of <b>{1}</b>', s.value, s.maxValue); |
---|
34 | } |
---|
35 | }) |
---|
36 | }); |
---|
37 | this.slider.render(td); |
---|
38 | |
---|
39 | this.slider.on('changecomplete', function(s, v){ |
---|
40 | pbar.changePage(v); |
---|
41 | }); |
---|
42 | |
---|
43 | pbar.on('change', function(pb, data){ |
---|
44 | this.slider.maxValue = data.pages; |
---|
45 | this.slider.setValue(data.activePage); |
---|
46 | }, this); |
---|
47 | }, |
---|
48 | |
---|
49 | onDestroy : function(){ |
---|
50 | this.slider.destroy(); |
---|
51 | } |
---|
52 | }); |
---|