Roo/bootstrap/Pagination.js
[roojs1] / Roo / bootstrap / Pagination.js
1 /*
2  * - LGPL
3  *
4  * column
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.Column
10  * @extends Roo.bootstrap.Component
11  * Bootstrap Column class
12  * @cfg {number} colspan  Number of columsn to span
13  * 
14  * @constructor
15  * Create a new Column
16  * @param {Object} config The config object
17  */
18
19 Roo.bootstrap.Pagination = function(config){
20     Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
21 };
22
23 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component,  {
24     
25     html: false,
26     cls: false,
27     size: false,
28     inverse: false,
29     from: 1,
30     to: 4,
31     align: false,
32     active: 1,
33     
34     getAutoCreate : function(){
35         cfg = {
36             tag: 'ul',
37             cls: 'pagination',
38             cn: []
39         }
40         if (this.inverse) {
41             cfg.cls += ' inverse'
42         }
43         if (this.html) {
44             cfg.html=this.html
45         }
46         if (this.cls) {
47             cfg.cls=this.cls
48         }
49         cfg.cn[0]={
50             tag: 'li',
51             cn: [
52                 {
53                     tag: 'a',
54                     href:'#',
55                     html: '«'
56                 }
57             ]
58         }
59         var from=this.from>0?this.from:1;
60         var to=this.to-from<=10?this.to:from+10;
61         var active=this.active>=from&&this.active<=to?this.active:null;
62         for (var i=from;i<=to;i++) {
63             cfg.cn.push(
64                 {
65                     tag: 'li',
66                     cn: [
67                         {
68                             tag: 'a',
69                             href: '#',
70                             cls: active===i?'active':'',
71                             html: i
72                         }
73                     ]
74                 }
75             )
76         }
77         
78         cfg.cn.push(
79             {
80                 tag: 'li',
81                 cn: [
82                     {
83                        tag: 'a',
84                        href: '#',
85                        html: '&raquo;'
86                     }
87                 ]
88             }
89         )
90         
91         return cfg;
92     }
93    
94 });
95
96  
97
98