|
20 | 20 | * limitations under the License.
|
21 | 21 | * ========================================================= */
|
22 | 22 |
|
| 23 | +/* |
| 24 | + * Improvement by CuGBabyBeaR @ 2013-09-12 |
| 25 | + * |
| 26 | + * Make it work in bootstrap v3 |
| 27 | + */ |
| 28 | + |
| 29 | + |
23 | 30 | !function( $ ) {
|
24 | 31 |
|
25 | 32 | function UTCDate(){
|
|
36 | 43 | var that = this;
|
37 | 44 |
|
38 | 45 | this.element = $(element);
|
| 46 | + |
39 | 47 | this.language = options.language || this.element.data('date-language') || "en";
|
40 | 48 | this.language = this.language in dates ? this.language : "en";
|
41 | 49 | this.isRTL = dates[this.language].rtl || false;
|
|
44 | 52 | this.isInline = false;
|
45 | 53 | this.isVisible = false;
|
46 | 54 | this.isInput = this.element.is('input');
|
47 |
| - this.component = this.element.is('.date') ? this.element.find('.add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar').parent() : false; |
48 |
| - this.componentReset = this.element.is('.date') ? this.element.find('.add-on .icon-remove').parent() : false; |
| 55 | + |
| 56 | + this.bootcssVer = this.isInput ? (this.element.is('.form-control') ? 3 : 2) : ( this.bootcssVer = this.element.is('.input-group') ? 3 : 2 ); |
| 57 | + |
| 58 | + this.component = this.element.is('.date') ? ( this.bootcssVer == 3 ? this.element.find('.input-group-addon .glyphicon-th, .input-group-addon .glyphicon-time, .input-group-addon .glyphicon-calendar').parent() : this.element.find('.add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar').parent()) : false; |
| 59 | + this.componentReset = this.element.is('.date') ? ( this.bootcssVer == 3 ? this.element.find('.input-group-addon .glyphicon-remove').parent() : this.element.find('.add-on .icon-remove').parent()): false; |
49 | 60 | this.hasInput = this.component && this.element.find('input').length;
|
50 | 61 | if (this.component && this.component.length === 0) {
|
51 | 62 | this.component = false;
|
|
54 | 65 | this.linkFormat = DPGlobal.parseFormat(options.linkFormat || this.element.data('link-format') || DPGlobal.getDefaultFormat(this.formatType, 'link'), this.formatType);
|
55 | 66 | this.minuteStep = options.minuteStep || this.element.data('minute-step') || 5;
|
56 | 67 | this.pickerPosition = options.pickerPosition || this.element.data('picker-position') || 'bottom-right';
|
57 |
| - this.showMeridian = options.showMeridian || this.element.data('show-meridian') || false; |
58 |
| - this.initialDate = options.initialDate || new Date(); |
| 68 | + this.showMeridian = options.showMeridian || this.element.data('show-meridian') || false; |
| 69 | + this.initialDate = options.initialDate || new Date(); |
| 70 | + |
| 71 | + |
59 | 72 |
|
60 | 73 | this._attachEvents();
|
61 | 74 |
|
|
128 | 141 | this.forceParse = this.element.data('date-force-parse');
|
129 | 142 | }
|
130 | 143 |
|
131 |
| - this.picker = $(DPGlobal.template) |
| 144 | + this.picker = $((this.bootcssVer == 3)? DPGlobal.templateV3 : DPGlobal.template) |
132 | 145 | .appendTo(this.isInline ? this.element : 'body')
|
133 | 146 | .on({
|
134 | 147 | click: $.proxy(this.click, this),
|
|
153 | 166 | }
|
154 | 167 | if (this.isRTL){
|
155 | 168 | this.picker.addClass('datetimepicker-rtl');
|
156 |
| - this.picker.find('.prev i, .next i') |
| 169 | + if (this.bootcssVer == 3) { |
| 170 | + this.picker.find('.prev span, .next span') |
| 171 | + .toggleClass('glyphicon-arrow-left glyphicon-arrow-right'); |
| 172 | + }else{ |
| 173 | + this.picker.find('.prev i, .next i') |
157 | 174 | .toggleClass('icon-arrow-left icon-arrow-right');
|
| 175 | + }; |
| 176 | + |
158 | 177 | }
|
159 | 178 | $(document).on('mousedown', function (e) {
|
160 | 179 | // Clicked outside the datetimepicker, hide it
|
|
1523 | 1542 | '<th class="next"><i class="icon-arrow-right"/></th>'+
|
1524 | 1543 | '</tr>'+
|
1525 | 1544 | '</thead>',
|
| 1545 | + headTemplateV3: '<thead>'+ |
| 1546 | + '<tr>'+ |
| 1547 | + '<th class="prev"><i class="glyphicon glyphicon-arrow-left"></i> </th>'+ |
| 1548 | + '<th colspan="5" class="switch"></th>'+ |
| 1549 | + '<th class="next"><i class="glyphicon glyphicon-arrow-right"></i> </th>'+ |
| 1550 | + '</tr>'+ |
| 1551 | + '</thead>', |
1526 | 1552 | contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
|
1527 | 1553 | footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
|
1528 | 1554 | };
|
|
1563 | 1589 | '</table>'+
|
1564 | 1590 | '</div>'+
|
1565 | 1591 | '</div>';
|
1566 |
| - |
| 1592 | + DPGlobal.templateV3 = '<div class="datetimepicker">'+ |
| 1593 | + '<div class="datetimepicker-minutes">'+ |
| 1594 | + '<table class=" table-condensed">'+ |
| 1595 | + DPGlobal.headTemplateV3+ |
| 1596 | + DPGlobal.contTemplate+ |
| 1597 | + DPGlobal.footTemplate+ |
| 1598 | + '</table>'+ |
| 1599 | + '</div>'+ |
| 1600 | + '<div class="datetimepicker-hours">'+ |
| 1601 | + '<table class=" table-condensed">'+ |
| 1602 | + DPGlobal.headTemplateV3+ |
| 1603 | + DPGlobal.contTemplate+ |
| 1604 | + DPGlobal.footTemplate+ |
| 1605 | + '</table>'+ |
| 1606 | + '</div>'+ |
| 1607 | + '<div class="datetimepicker-days">'+ |
| 1608 | + '<table class=" table-condensed">'+ |
| 1609 | + DPGlobal.headTemplateV3+ |
| 1610 | + '<tbody></tbody>'+ |
| 1611 | + DPGlobal.footTemplate+ |
| 1612 | + '</table>'+ |
| 1613 | + '</div>'+ |
| 1614 | + '<div class="datetimepicker-months">'+ |
| 1615 | + '<table class="table-condensed">'+ |
| 1616 | + DPGlobal.headTemplateV3+ |
| 1617 | + DPGlobal.contTemplate+ |
| 1618 | + DPGlobal.footTemplate+ |
| 1619 | + '</table>'+ |
| 1620 | + '</div>'+ |
| 1621 | + '<div class="datetimepicker-years">'+ |
| 1622 | + '<table class="table-condensed">'+ |
| 1623 | + DPGlobal.headTemplateV3+ |
| 1624 | + DPGlobal.contTemplate+ |
| 1625 | + DPGlobal.footTemplate+ |
| 1626 | + '</table>'+ |
| 1627 | + '</div>'+ |
| 1628 | + '</div>'; |
1567 | 1629 | $.fn.datetimepicker.DPGlobal = DPGlobal;
|
1568 | 1630 |
|
1569 | 1631 |
|
|
0 commit comments