Timepicker: timepicker is closed when orientationchange event fired
authorhjnim.kim <hjnim.kim@samsung.com>
Mon, 15 Apr 2013 07:13:44 +0000 (16:13 +0900)
committerYoumin Ha <youmin.ha@samsung.com>
Tue, 16 Apr 2013 04:34:17 +0000 (13:34 +0900)
timepicker is close when orientationchange event fired
( using global orientationchange event )
N_SE-34471

Change-Id: I1b33f41348ab773d23eae6253dcab15e8d891ec3

src/js/widgets/jquery.mobile.tizen.datetimepicker.js

index 41b704d..e4c9de7 100644 (file)
@@ -135,6 +135,8 @@ define( [ 'jquery.mobile.tizen.widgetex', 'jquery.mobile.tizen.popupwindow', 'jq
                        initSelector: "input[type='date'], input[type='datetime'], input[type='time'], :jqmData(role='datetimepicker')"
                },
 
+               container : null,
+
                _calendar: function () {
                        return window.Globalize.culture().calendars.standard;
                },
@@ -553,8 +555,30 @@ define( [ 'jquery.mobile.tizen.widgetex', 'jquery.mobile.tizen.popupwindow', 'jq
                        this.ui.bind('vclick', function ( e ) {
                                obj._showDataSelector( obj, this, e.target );
                        });
-               },
 
+                       $.extend( this, {
+                               _globalHandlers: [
+                                       {
+                                               src: $( window ),
+                                               handler: {
+                                                       orientationchange: $.proxy( this, "_orientationHandler" )
+                                               }
+                                       }
+                               ]
+                       });
+
+                       $.each( this._globalHandlers, function( idx, value ) {
+                               value.src.bind( value.handler );
+                       });
+               },
+               _orientationHandler: function() {
+                       var self = this;
+                       if( self._popup_open ) {
+                               self._popup_open = false;
+                               self.container.popupwindow( 'close' );
+                       }
+                       return false;
+               },
                _populateDataSelector: function ( field, pat ) {
                        var values,
                                numItems,
@@ -731,6 +755,7 @@ define( [ 'jquery.mobile.tizen.widgetex', 'jquery.mobile.tizen.popupwindow', 'jq
                                                target.offset().left + ( target.width() / 2 ) + newLeft - window.pageXOffset ,
                                                target.offset().top + target.height() - window.pageYOffset );
 
+                               this.container = $ctx;
                                this._popup_open = true;
 
                                $div.bind('popupafterclose', function ( e ) {