datatimepicker: don't open the popup before popupafterclose event is fired
authorMinkyu Kang <mk7.kang@samsung.com>
Mon, 28 Jan 2013 08:11:15 +0000 (17:11 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Mon, 28 Jan 2013 12:58:11 +0000 (21:58 +0900)
Because of event processing order,
block the open the popup before poupafterclose event is fired.
(N_SE-23027)

Change-Id: I0d95463d534c3ccb59f197b1be0bf6bea2c8ce43

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

index e05d218..f1e08b2 100644 (file)
 
                        var pat = target.jqmData( 'pat' ),
                                hour,
-                               text;
+                               text,
+                               self = this;
+
                        switch ( pat ) {
                        case 'H':
                        case 'HH':
                        if ( target.text() != text ) {
                                if ( target.hasClass("ui-datefield-selected") ) {
                                        target.addClass("out");
+                                       this._new_value = text;
 
                                        target.animationComplete( function () {
-                                               target.text( text );
+                                               target.text( self._new_value);
                                                target.addClass("in")
                                                        .removeClass("out");
 
                        this.ui = $('<div class="ui-datefield"></div>');
                        $(this.element).after( this.ui );
 
+                       this._popup_open = false;
                        this.ui.bind('vclick', function ( e ) {
                                obj._showDataSelector( obj, this, e.target );
                        });
                                $ctx,
                                $li,
                                i,
-                               newLeft = 10;
+                               newLeft = 10,
+                               self = this;
 
                        if ( !attr ) {
                                return;
                        if ( !field ) {
                                return;
                        }
+                       if ( this._popup_open ) {
+                               return;
+                       }
 
                        target.not('.ui-datefield-seperator').addClass('ui-datefield-selected');
 
                                $ctx.popupwindow( 'open',
                                                target.offset().left + ( target.width() / 2 ) + newLeft - window.pageXOffset ,
                                                target.offset().top + target.height() - window.pageYOffset );
+
+                               this._popup_open = true;
+
                                $div.bind('popupafterclose', function ( e ) {
                                        if ( obj._reflow ) {
                                                $(window).unbind("resize", obj._reflow);
                                                obj._reflow = null;
                                        }
+
+                                       if ( !( target.hasClass("in") || target.hasClass("out") ) ) {
+                                               target.removeClass("ui-datefield-selected");
+                                       }
+
                                        $div.unbind( 'popupafterclose' );
                                        $ul.unbind( 'vclick' );
                                        $(obj).unbind( 'update' );
                                        $ctx.popupwindow( 'destroy' );
                                        $div.remove();
+
+                                       self._popup_open = false;
                                });
 
                                $(obj).bind( 'update', function ( e, val ) {