@@ -135,7 +135,7 @@ WT_DECLARE_WT_MEMBER
135135 }, 500 );
136136 });
137137
138- WT_DECLARE_WT_MEMBER (HideOverlay , Wt::JavaScriptFunction, " HideOverlay " , function()
138+ WT_DECLARE_WT_MEMBER (SetupHideOverlay , Wt::JavaScriptFunction, " SetupHideOverlay " , function()
139139{
140140 function hideverything (e)
141141 {
@@ -152,21 +152,8 @@ WT_DECLARE_WT_MEMBER(HideOverlay, Wt::JavaScriptFunction, "HideOverlay", functio
152152 // Scroll back to the top of the menu
153153 jel.scrollTop (0 );
154154
155- // I cant actually tell the differnce in smoothness between my version
156- // and jQueries version.
157155 var a = -jel.width () - 10 ;
158156 jel.animate ({left: a+' px' }, {queue: false , duration: 255 }, " linear" , function (){jel.hide ();});
159-
160- // var w = jel.width(), t0 = (new Date()).valueOf();
161- // ( function slideout()
162- // {
163- // var t = (new Date()).valueOf();
164- // var pos = -w*((t-t0)/250);
165- // el.style['left'] = pos + 'px';
166- // if( pos>-w )
167- // setTimeout(slideout,1);
168- // else jel.hidde();
169- // })()
170157 });
171158
172159 $(' .mobilePopupMenuOverlay' ).hide ();
@@ -668,7 +655,7 @@ PopupDivMenu::PopupDivMenu( Wt::WPushButton *menuParent,
668655 {
669656 addStyleClass ( " PopupDivMenuPhone" );
670657 LOAD_JAVASCRIPT (wApp, " PopupDiv.cpp" , " ShowPhone" , wtjsShowPhone);
671- LOAD_JAVASCRIPT (wApp, " PopupDiv.cpp" , " HideOverlay " , wtjsHideOverlay );
658+ LOAD_JAVASCRIPT (wApp, " PopupDiv.cpp" , " SetupHideOverlay " , wtjsSetupHideOverlay );
672659
673660 // Note: need to call this to reset the menus when a submenu is
674661 // selected/hidden. No need to call triggered(), as it will be hidden too.
@@ -702,48 +689,47 @@ PopupDivMenu::PopupDivMenu( Wt::WPushButton *menuParent,
702689 }// if( useNativeMenu )
703690#endif
704691
705- if ( menuParent )
692+ if ( m_mobile )
706693 {
707- if ( m_mobile)
708- {
709- switch ( m_type )
710- {
711- case AppLevelMenu:
712- menuParent->clicked ().connect ( this , &PopupDivMenu::showMobile );
713- break ;
714-
715- case TransientMenu:
716- menuParent->setMenu ( this );
717- break ;
718- }// switch( m_type )
719- }else
694+ if ( menuParent )
720695 {
696+ addPhoneBackItem ( nullptr );
697+ menuParent->clicked ().connect ( this , &PopupDivMenu::showMobile );
698+ }// if( menuParent )
699+ }else if ( menuParent )
700+ {
721701#if (USE_OSX_NATIVE_MENU)
722- if ( useNativeMenu && (menutype == AppLevelMenu) )
723- {
724- const string buttontxt = menuParent->text ().toUTF8 ();
725- if ( buttontxt.length () )
726- m_nsmenu = addOsxMenu ( this , buttontxt.c_str () );
727- } // AppLevelMenu
702+ if ( useNativeMenu && (menutype == AppLevelMenu) )
703+ {
704+ const string buttontxt = menuParent->text ().toUTF8 ();
705+ if ( buttontxt.length () )
706+ m_nsmenu = addOsxMenu ( this , buttontxt.c_str () );
707+ } // AppLevelMenu
728708#endif
729709
730710#if ( USING_ELECTRON_NATIVE_MENU )
731- if ( useNativeMenu && (menutype == AppLevelMenu) )
732- {
733- // Here we are adding a menu at the topof the window. "InterSpec", "View", "Tools", "Help"
734- // In Js, we should find the menu, and get a reference to it.
735- // app->doJavaScript( "console.log('Adding PopupDivMenu id=" + id() + " parentTxt=" + menuParent->text().toUTF8() + "');" );
736- app->doJavaScript ( " Wt.WT.FindElectronMenu('" + menuParent->text ().toUTF8 () + " ', '" + id () + " ');" );
737- m_hasElectronCounterpart = true ;
738- }
711+ if ( useNativeMenu && (menutype == AppLevelMenu) )
712+ {
713+ // Here we are adding a menu at the topof the window. "InterSpec", "View", "Tools", "Help"
714+ // In Js, we should find the menu, and get a reference to it.
715+ // app->doJavaScript( "console.log('Adding PopupDivMenu id=" + id() + " parentTxt=" + menuParent->text().toUTF8() + "');" );
716+ app->doJavaScript ( " Wt.WT.FindElectronMenu('" + menuParent->text ().toUTF8 () + " ', '" + id () + " ');" );
717+ m_hasElectronCounterpart = true ;
718+ }
739719#endif
740720
741- if ( !useNativeMenu && (menutype == AppLevelMenu) )
742- setupDesktopMenuStuff ();
743- else
744- menuParent->setMenu ( this );
745- } // if( m_mobile) / else
746- }else // if( menuParent )
721+ if ( !useNativeMenu && (menutype == AppLevelMenu) )
722+ {
723+ setupDesktopMenuStuff ();
724+ }else
725+ {
726+ menuParent->setMenu ( this );
727+
728+ const string js = " function(){Wt.WT.BringAboveDialogs('" + id () + " ');"
729+ " Wt.WT.AdjustTopPos('" + menuParent->id () + " ');}" ;
730+ menuParent->clicked ().connect ( js );
731+ }
732+ }else // if( m_mobile) / else if( menuParent )
747733 {
748734#if ( USING_ELECTRON_NATIVE_MENU )
749735 if ( m_hasElectronCounterpart && (menutype == AppLevelMenu) )
@@ -941,17 +927,16 @@ void PopupDivMenu::setHidden( bool hidden, const Wt::WAnimation &animation )
941927
942928void PopupDivMenu::showMobile ()
943929{
944- // Note/Hack: This is needed to check if clicked or mouseover. If clicked,
945- // calling popup() will somehow cause the popupmenu to not show.
946- // I know, weird huh.
947930 if ( m_menuParent )
948931 popup ( m_menuParent, Wt::Vertical );
949-
932+ else
933+ popup ( {0 ,0 } );
934+
950935 if ( m_mobile )
951936 {
952937 doJavaScript (" $('.mobilePopupMenuOverlay').show();" );
953938 doJavaScript ( " Wt.WT.ShowPhone('" + id () + " ');" );
954- doJavaScript ( " Wt.WT.HideOverlay ();" );
939+ doJavaScript ( " Wt.WT.SetupHideOverlay ();" );
955940 }// if( m_mobile )
956941}// void doShow()
957942
@@ -1008,6 +993,10 @@ void PopupDivMenu::undoParentHoveredOver()
1008993}// void undoParentHoveredOver()
1009994
1010995
996+ bool PopupDivMenu::isMobile () const
997+ {
998+ return m_mobile;
999+ }
10111000
10121001void PopupDivMenu::setupDesktopMenuStuff ()
10131002{
@@ -1307,7 +1296,7 @@ PopupDivMenuItem *PopupDivMenu::addPhoneBackItem( PopupDivMenu *parent )
13071296PopupDivMenu *PopupDivMenu::addPopupMenuItem ( const Wt::WString &text,
13081297 const std::string &iconPath )
13091298{
1310- PopupDivMenu *menu = new PopupDivMenu ( 0 , m_type );
1299+ PopupDivMenu *menu = new PopupDivMenu ( nullptr , m_type );
13111300
13121301 if ( m_mobile )
13131302 {
0 commit comments