|
440 | 440 | self.theDate.setTime( secs * 1000 );
|
441 | 441 | self._update();
|
442 | 442 | },
|
| 443 | + _orientChange: function(e) { |
| 444 | + var self = $(e.currentTarget).data('datebox'); |
| 445 | + o = self.options, |
| 446 | + inputOffset = self.focusedEl.offset(), |
| 447 | + pickWinHeight = self.pickerContent.outerHeight(), |
| 448 | + pickWinWidth = self.pickerContent.innerWidth(), |
| 449 | + pickWinTop = inputOffset.top + ( self.focusedEl.outerHeight() / 2 )- ( pickWinHeight / 2), |
| 450 | + pickWinLeft = inputOffset.left + ( self.focusedEl.outerWidth() / 2) - ( pickWinWidth / 2); |
| 451 | + |
| 452 | + e.stopPropagation(); |
| 453 | + if ( ! self.pickerContent.is(':visible') || o.useDialog === true ) { |
| 454 | + return false; // Not open, or in a dialog (let jQM do it) |
| 455 | + } else { |
| 456 | + // TOO FAR RIGHT TRAP |
| 457 | + if ( (pickWinLeft + pickWinWidth) > $(document).width() ) { |
| 458 | + pickWinLeft = $(document).width() - pickWinWidth - 1; |
| 459 | + } |
| 460 | + // TOO FAR LEFT TRAP |
| 461 | + if ( pickWinLeft < 0 ) { |
| 462 | + pickWinLeft = 0; |
| 463 | + } |
| 464 | + // Center popup on request - centered in document, not any containing div. |
| 465 | + if ( o.centerWindow ) { |
| 466 | + pickWinLeft = ( $(document).width() / 2 ) - ( pickWinWidth / 2 ); |
| 467 | + } |
| 468 | + |
| 469 | + if ( (pickWinHeight + pickWinTop) > $(document).height() ) { |
| 470 | + pickWinTop = $(document).height() - (pickWinHeight + 2); |
| 471 | + } |
| 472 | + if ( pickWinTop < 45 ) { pickWinTop = 45; } |
| 473 | + |
| 474 | + self.pickerContent.css({'top': pickWinTop, 'left': pickWinLeft}); |
| 475 | + } |
| 476 | + |
| 477 | + }, |
443 | 478 | _update: function() {
|
444 | 479 | // Update the display on date change
|
445 | 480 | var self = this,
|
|
1100 | 1135 | });
|
1101 | 1136 |
|
1102 | 1137 | // Bind the master handler.
|
1103 |
| - input.bind('datebox', self._dateboxHandler); |
| 1138 | + input.bind('datebox', self._dateboxHandler); |
1104 | 1139 |
|
1105 | 1140 | // Bind the close button on the DIALOG mode.
|
1106 | 1141 | pickPage.find( ".ui-header a").bind('vclick', function(e) {
|
|
1214 | 1249 | input.attr("readonly", true);
|
1215 | 1250 | }
|
1216 | 1251 |
|
| 1252 | + $(document).bind('orientationchange', function(e) { input.trigger('orientationchange'); }); |
| 1253 | + |
| 1254 | + input.bind('orientationchange', self._orientChange); |
| 1255 | + |
1217 | 1256 | //Throw dateboxinit event
|
1218 | 1257 | $( document ).trigger( "dateboxaftercreate" );
|
1219 | 1258 | },
|
|
0 commit comments