OSDN Git Service

client is version0.4.25, fixed petanr.form on windowResize.
authoritozyun <itozyun@gmail.com>
Sun, 22 Apr 2012 20:47:55 +0000 (05:47 +0900)
committeritozyun <itozyun@gmail.com>
Sun, 22 Apr 2012 20:47:55 +0000 (05:47 +0900)
public/assets/common.js

index 0007b34..2b15166 100644 (file)
@@ -1020,6 +1020,7 @@ pettanr.view = ( function(){
                        h = jqWindow.height();\r
                currentApplication && currentApplication.resize( w, h );\r
                pettanr.overlay.onWindowResize( w, h );\r
+               pettanr.form.onWindowResize( w, h );\r
        }\r
 \r
        return {\r
@@ -1083,7 +1084,7 @@ pettanr.overlay = ( function(){
                windowW, windowH;\r
 \r
        function asyncResize(){\r
-               currentOverlay.resize( windowW, windowH);\r
+               currentOverlay.resize( windowW, windowH );\r
        }\r
        function onCloseClick( e){\r
                pettanr.overlay.hide();\r
@@ -1312,6 +1313,7 @@ pettanr.form = ( function(){
                currentID = null,\r
                currentItem = null,\r
                CLASSNAME_COMBOBOX_OPTION = 'combobox-option',\r
+               windowW, windowH,\r
                ELM_A_ORIGIN = ( function(){\r
                        var ret = document.createElement( 'a');\r
                        ret.href = '#';\r
@@ -1335,7 +1337,7 @@ pettanr.form = ( function(){
                        elmToggle.appendChild( document.createTextNode( '▼' ));\r
                        elmValue.appendChild( document.createTextNode( 'null' ));\r
                        return ret;\r
-               })()\r
+               })();\r
                \r
        var InputTextClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater ){\r
                validater = Type.isFunction( validater ) === true ? validater : null;\r
@@ -1654,6 +1656,15 @@ pettanr.form = ( function(){
                        currentCombobox.blur();\r
                        OptionControl.hide( currentCombobox );\r
                }\r
+               function updateWrapperPosition(){\r
+                       var position = pettanr.util.getAbsolutePosition( elm );\r
+                       \r
+                       ELM_OPTION_WRAPPER.style.cssText = [\r
+                                       'width:', elm.offsetWidth - 2, 'px;',\r
+                                       'left:', position.x, 'px;',\r
+                                       'top:', position.y + elm.offsetHeight, 'px;'\r
+                               ].join('');                     \r
+               }\r
                return {\r
                        show: function( _combobox, _optionList ){\r
                                if( currentItem !== _combobox || currentCombobox === _combobox ) return;\r
@@ -1665,23 +1676,15 @@ pettanr.form = ( function(){
                                \r
                                updateCurrrentOption( _combobox.value(), false );\r
                                \r
-                               var position = pettanr.util.getAbsolutePosition( elm ),\r
-                                       _option;\r
-                               \r
                                for( var i=0, l=optionList.length; i<l; ++i ){\r
                                        ELM_OPTION_WRAPPER.appendChild( optionList[ i ].elm );\r
                                }\r
                                \r
                                document.body.appendChild( ELM_OPTION_WRAPPER );\r
-                               \r
-                               ELM_OPTION_WRAPPER.style.cssText = [\r
-                                               'width:', elm.offsetWidth - 2, 'px;',\r
-                                               'left:', position.x, 'px;',\r
-                                               'top:', position.y + elm.offsetHeight, 'px;'\r
-                                       ].join('');\r
-                               \r
                                oldBodyMouseupHandler = document.body.onmouseup;\r
                                document.body.onmouseup = bodyMouseupHandler;\r
+                               \r
+                               updateWrapperPosition();\r
                        },\r
                        hide: function( _combobox ){\r
                                if( currentCombobox !== _combobox ) return;\r
@@ -1715,37 +1718,40 @@ pettanr.form = ( function(){
                                currentCombobox.value( currentOption.value );\r
                                currentCombobox.blur();\r
                                OptionControl.hide( currentCombobox );\r
+                       },\r
+                       onWindowResize: function( _w, _h ){\r
+                               setTimeout( updateWrapperPosition, 0 );\r
                        }\r
                }\r
        })();\r
        \r
-       var OptionClass = function( combobox, displayValue, value ){\r
-               var elm = document.createElement( 'li' ),\r
-                       a = document.createElement( 'a' ),\r
-                       isCurrent = undefined;\r
-               elm.appendChild( a );\r
-               a.appendChild( document.createTextNode( displayValue ));\r
-               elm.className = CLASSNAME_COMBOBOX_OPTION;\r
-               a.href = '#';\r
-               \r
-               a.onmousedown = onClick; // onclick では 選択ボックス 隠すように body に設定した onmouseup が先に動いてしまう!\r
-               function onClick(){\r
-                       OptionControl.update( combobox, value );\r
-                       OptionControl.hide( combobox );\r
-                       combobox.blur();\r
-                       return false;\r
-               }\r
-               this.elm = elm;\r
-               this.displayValue = displayValue;\r
-               this.value = value = value || displayValue;\r
-               this.current = function( _isCurrent ){\r
-                       if( Type.isBoolean( _isCurrent ) === true && isCurrent !== _isCurrent ){\r
-                               elm.className = CLASSNAME_COMBOBOX_OPTION + ( _isCurrent === true ? ' current-option' : '' );\r
-                               isCurrent = _isCurrent;\r
+               var OptionClass = function( combobox, displayValue, value ){\r
+                       var elm = document.createElement( 'li' ),\r
+                               a = document.createElement( 'a' ),\r
+                               isCurrent = undefined;\r
+                       elm.appendChild( a );\r
+                       a.appendChild( document.createTextNode( displayValue ));\r
+                       elm.className = CLASSNAME_COMBOBOX_OPTION;\r
+                       a.href = '#';\r
+                       \r
+                       a.onmousedown = onClick; // onclick では 選択ボックス 隠すように body に設定した onmouseup が先に動いてしまう!\r
+                       function onClick(){\r
+                               OptionControl.update( combobox, value );\r
+                               OptionControl.hide( combobox );\r
+                               combobox.blur();\r
+                               return false;\r
+                       }\r
+                       this.elm = elm;\r
+                       this.displayValue = displayValue;\r
+                       this.value = value = value || displayValue;\r
+                       this.current = function( _isCurrent ){\r
+                               if( Type.isBoolean( _isCurrent ) === true && isCurrent !== _isCurrent ){\r
+                                       elm.className = CLASSNAME_COMBOBOX_OPTION + ( _isCurrent === true ? ' current-option' : '' );\r
+                                       isCurrent = _isCurrent;\r
+                               }\r
+                               return !!isCurrent;\r
                        }\r
-                       return !!isCurrent;\r
                }\r
-       }\r
        \r
 \r
        function start( _currentItem ){\r
@@ -1841,6 +1847,11 @@ pettanr.form = ( function(){
                },\r
                createRadio: function(){\r
                        \r
+               },\r
+               onWindowResize: function( w, h ){\r
+                       windowW = w;\r
+                       windowH = h;\r
+                       currentItem instanceof ComboBoxClass && OptionControl.onWindowResize( w, h );\r
                }\r
        }\r
 })();\r