Export 0.1.45
[framework/web/web-ui-fw.git] / src / widgets / controlbar / js / jquery.mobile.tizen.controlbar.js
index 24fb0f8..7c5348c 100755 (executable)
                                iconpos = $navbtns.filter( ":jqmData(icon)" ).length ?
                                                                                this.options.iconpos : undefined,
                                theme = $.mobile.listview.prototype.options.theme,      /* Get current theme */
-                               style = $controlbar.attr( "data-style" );
+                               style = $controlbar.attr( "data-style" ),
+                               ww = window.innerWidth || $( window ).width(),
+                               wh = window.innerHeight || $( window ).height(),
+                               isLandscape;
+
+                       isLandscape = ww > wh && ( ww - wh );
+
+                       if ( isLandscape ) {
+                               $controlbar.removeClass( "ui-portrait-controlbar" ).addClass( "ui-landscape-controlbar" );
+                       } else {
+                               $controlbar.removeClass( "ui-landscape-controlbar" ).addClass( "ui-portrait-controlbar" );
+                       }
 
                        if ( style === "left" || style === "right" ) {
                                $controlbar
                        });
 
                        $( document ).bind( "pageshow", function ( e, ui ) {
-                               var controlbar_filter = $( ".ui-page" ).find( ":jqmData(role='footer')" ).eq( 0 ).find( ":jqmData(role='controlbar')" ),
+                               var controlbar_filter = $( ".ui-page-active" ).find( ":jqmData(role='footer')" ).eq( 0 ).find( ":jqmData(role='controlbar')" ),
+                                       element_width = 0,
                                        element_count = controlbar_filter.find( 'li' ).length;
 
                                if ( controlbar_filter.find(".ui-btn-active").length == 0 ) {
                                                .css( "width", controlbar_filter.width() )
                                                .css( "height", controlbar_filter.height() );
                                }
+
+                               if ( controlbar_filter.length ) {
+                                       element_width = Math.floor( controlbar_filter.outerWidth() / element_count );
+                                       controlbar_filter.find("li:last").width( controlbar_filter.outerWidth() - element_width * ( element_count - 1 ) );
+                               }
+                       });
+
+                       $( window ).bind( "resize", function ( e ) {
+                               var controlbar_filter = $( ".ui-page-active" ).find( ":jqmData(role='footer')" ).eq( 0 ).find( ":jqmData(role='controlbar')" ),
+                                       element_width = 0,
+                                       element_count = controlbar_filter.find( 'li' ).length;
+
+                               if ( controlbar_filter.length ) {
+                                       element_width = Math.floor( controlbar_filter.outerWidth() / element_count );
+                                       controlbar_filter.find("li:last").width( controlbar_filter.outerWidth() - element_width * ( element_count - 1 ) );
+                               }
                        });
+
+                       this._bindControlbarEvents();
+               },
+
+               _bindControlbarEvents: function () {
+                       var $controlbar = this.element;
+
+                       $( window ).bind( "orientationchange", function ( e, ui ) {
+                               ww = window.innerWidth || $( window ).width();
+                               wh = window.innerHeight || $( window ).height();
+
+                               isLandscape = ww > wh && ( ww - wh );
+
+                               if ( isLandscape ) {
+                                       $controlbar.removeClass( "ui-portrait-controlbar" ).addClass( "ui-landscape-controlbar" );
+                               } else {
+                                       $controlbar.removeClass( "ui-landscape-controlbar" ).addClass( "ui-portrait-controlbar" );
+                               }
+                       })
+
                },
 
                _setDisabled: function ( value, cnt ) {