File tree Expand file tree Collapse file tree 5 files changed +54
-22
lines changed Expand file tree Collapse file tree 5 files changed +54
-22
lines changed Original file line number Diff line number Diff line change 14
14
< script src ="../ui/jquery.ui.position.js "> </ script >
15
15
< script src ="datasource.js "> </ script >
16
16
< script src ="grid.js "> </ script >
17
+ < script src ="pager.js "> </ script >
17
18
18
19
< script >
19
20
$ ( function ( ) {
91
92
movies . option ( "filter" , filters ) . refresh ( ) ;
92
93
} ) ;
93
94
95
+ $ ( "#pager" ) . pager ( {
96
+ source : movies
97
+ } ) ;
98
+ return ;
94
99
var buttons = $ ( "#pager" ) . buttonset ( ) . find ( "button" ) . click ( function ( ) {
95
100
var method = $ ( this ) . data ( "page" ) ;
96
101
movies [ method ] ( ) ;
Original file line number Diff line number Diff line change
1
+ $ . widget ( "spf.pager" , {
2
+ options : {
3
+ source : null ,
4
+ pageSize : 2
5
+ } ,
6
+ _create : function ( ) {
7
+ var that = this ;
8
+
9
+ // TODO add a datasource method for this
10
+ $ ( this . options . source ) . bind ( "datasourcerefresh" , function ( ) {
11
+ that . refresh ( ) ;
12
+ } ) ;
13
+
14
+ this . buttons = this . element . delegate ( "button" , "click" , function ( ) {
15
+ var method = $ ( this ) . data ( "page" ) ;
16
+ var source = that . options . source ;
17
+ source [ method ] ( ) ;
18
+ source . refresh ( ) ;
19
+ } ) . buttonset ( ) . find ( "button" ) ;
20
+ } ,
21
+ refresh : function ( ) {
22
+ this . buttons . button ( "enable" ) ;
23
+
24
+ var source = this . options . source ;
25
+ if ( ! source . _skip ) {
26
+ this . buttons . slice ( 0 , 2 ) . button ( "disable" )
27
+ }
28
+ if ( source . _skip + source . _take >= source . totalCount ) {
29
+ this . buttons . slice ( 2 , 4 ) . button ( "disable" )
30
+ }
31
+ }
32
+ } ) ;
Original file line number Diff line number Diff line change 12
12
< script src ="../ui/jquery.ui.position.js "> </ script >
13
13
< script src ="../ui/jquery.ui.button.js "> </ script >
14
14
< script src ="datasource.js "> </ script >
15
+ < script src ="pager.js "> </ script >
15
16
< script src ="slideshow.js "> </ script >
16
- < script type ="text/x-kite " id ="controls -tmpl ">
17
+ < script type ="text/x-kite " id ="pager -tmpl ">
17
18
< div class = "controls" >
18
19
< button data-page = "first" > First</ button >
19
20
< button data-page = "prev" > Prev</ button >
52
53
$ ( "#slideshow" ) . slideshow ( {
53
54
source : datasource
54
55
} ) ;
56
+
57
+ $ ( kite ( "#pager-tmpl" ) ( ) ) . insertBefore ( "#slideshow" ) . pager ( {
58
+ source : datasource
59
+ } )
60
+
55
61
56
62
$ ( "#page-size" ) . change ( function ( ) {
57
63
datasource . option ( "paging" , {
60
66
skip : datasource . _skip
61
67
} ) . refresh ( ) ;
62
68
} ) ;
69
+
70
+ datasource . refresh ( ) ;
63
71
} ) ;
64
72
65
73
</ script >
Original file line number Diff line number Diff line change 13
13
< script src ="../ui/jquery.ui.button.js "> </ script >
14
14
< script src ="datasource.js "> </ script >
15
15
< script src ="slideshow.js "> </ script >
16
- < script type ="text/x-kite " id ="controls-tmpl ">
16
+ < script src ="pager.js "> </ script >
17
+ < script type ="text/x-kite " id ="pager-tmpl ">
17
18
< div class = "controls" >
18
19
< button data-page = "first" > First</ button >
19
20
< button data-page = "prev" > Prev</ button >
20
21
< button data-page = "next" > Next</ button >
21
- < button data-page = "last" > Last</ button >
22
22
</ div >
23
23
</ script >
24
24
< script type ="text/x-kite " id ="photo-tmpl ">
65
65
$ ( "#slideshow" ) . slideshow ( {
66
66
source : datasource
67
67
} ) ;
68
+
69
+ $ ( kite ( "#pager-tmpl" ) ( ) ) . insertBefore ( "#slideshow" ) . pager ( {
70
+ source : datasource
71
+ } ) ;
68
72
69
73
$ ( "#filter" ) . change ( function ( ) {
70
74
datasource . option ( "filter" , {
79
83
skip : datasource . _skip
80
84
} ) . refresh ( ) ;
81
85
} ) ;
86
+
87
+ datasource . refresh ( ) ;
82
88
} ) ;
83
89
84
90
</ script >
Original file line number Diff line number Diff line change @@ -10,15 +10,6 @@ $.widget( "spf.slideshow", {
10
10
$ ( this . options . source ) . bind ( "datasourcerefresh" , function ( ) {
11
11
that . refresh ( ) ;
12
12
} ) ;
13
-
14
- this . buttons = $ ( kite ( "#controls-tmpl" ) ( ) ) . insertBefore ( this . element ) . delegate ( "button" , "click" , function ( ) {
15
- var method = $ ( this ) . data ( "page" ) ;
16
- var source = that . options . source ;
17
- source [ method ] ( ) ;
18
- source . refresh ( ) ;
19
- } ) . buttonset ( ) . find ( "button" ) ;
20
-
21
- this . options . source . refresh ( ) ;
22
13
} ,
23
14
refresh : function ( ) {
24
15
var photosHtml = [ ] ;
@@ -30,15 +21,5 @@ $.widget( "spf.slideshow", {
30
21
31
22
this . element . empty ( ) ;
32
23
this . element . html ( photosHtml . join ( "" ) ) ;
33
-
34
- this . buttons . button ( "enable" ) ;
35
-
36
- var source = this . options . source ;
37
- if ( ! source . _skip ) {
38
- this . buttons . slice ( 0 , 2 ) . button ( "disable" )
39
- }
40
- if ( source . _skip + source . _take >= source . totalCount ) {
41
- this . buttons . slice ( 2 , 4 ) . button ( "disable" )
42
- }
43
24
}
44
25
} ) ;
You can’t perform that action at this time.
0 commit comments