From ff47a1f7736ed0321c35ff41dea202bbb9aba29b Mon Sep 17 00:00:00 2001 From: Matthew Juhl <mjuhl24@gmail.com> Date: Fri, 30 Apr 2010 17:29:43 +0000 Subject: [PATCH] Temporarily use an updated copy of mobile.js from mobileunl repo to fix navigation issue since Brett won't be here until Monday. --- plugins/mobile_unl/mobile.js | 81 +++++++++++++++++++ .../views/mobile/pageshells/pageshell.php | 3 +- 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 plugins/mobile_unl/mobile.js diff --git a/plugins/mobile_unl/mobile.js b/plugins/mobile_unl/mobile.js new file mode 100644 index 00000000..4ff75d87 --- /dev/null +++ b/plugins/mobile_unl/mobile.js @@ -0,0 +1,81 @@ +window.onorientationchange = function() { + /*window.orientation returns a value that indicates whether iPhone is in portrait mode, landscape mode with the screen turned to the + left, or landscape mode with the screen turned to the right. */ + var orientation = window.orientation; + switch(orientation) { + case 0: + /* If in portrait mode, sets the body's class attribute to portrait. Consequently, all style definitions matching the body[class="portrait"] declaration + in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */ + //WDN.jQuery('body').addClass("portrait"); + WDN.jQuery('head meta[name=viewport]').attr('content', 'width = 320'); + document.body.setAttribute("class","popup portrait"); + break; + + case 90: + /* If in landscape mode with the screen turned to the left, sets the body's class attribute to landscapeLeft. In this case, all style definitions matching the + body[class="landscapeLeft"] declaration in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */ + WDN.jQuery('head meta[name=viewport]').attr('content', 'width = 480'); + document.body.setAttribute("class","popup landscapeLeft"); + break; + + case -90: + /* If in landscape mode with the screen turned to the right, sets the body's class attribute to landscapeRight. Here, all style definitions matching the + body[class="landscapeRight"] declaration in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */ + //WDN.jQuery('body').addClass("landscapeRight"); + WDN.jQuery('head meta[name=viewport]').attr('content', 'width = 480'); + document.body.setAttribute("class","popup landscapeRight"); + break; + } +} +/* TODO sniff hash values and display accordingly + * + * #navigation - parent navigation displayed + * #sec_nav[index] - secondary navigation displayed + * + */ +WDN.jQuery(document).ready(function() { + WDN.jQuery("#mobile_navigation ul").hide(); + WDN.jQuery("#mobile_navigation").css({'position' : 'absolute'}); + WDN.jQuery("#mobile_navigation h2").css({'display' : 'none'}); + if (WDN.jQuery('ul#mobile_breadcrumbs > li.parent_site > a').text().length > 5) { + var allText = WDN.jQuery('ul#mobile_breadcrumbs > li.parent_site > a').text(); + WDN.jQuery('ul#mobile_breadcrumbs > li.parent_site > a').text(allText.substr(0,5)+'...'); + } + if (WDN.jQuery('ul#mobile_breadcrumbs > li:last-child > a').text().length > 19) { + var allText = WDN.jQuery('ul#mobile_breadcrumbs > li:last-child > a').text(); + WDN.jQuery('ul#mobile_breadcrumbs > li:last-child > a').text(allText.substr(0,19)+'...'); + } + WDN.jQuery('#mobile_navigation ul:first').has('ul').addClass('parentNav'); + WDN.jQuery('#mobile_navigation > ul > li').has('ul').each(function(index) { + WDN.jQuery(this).children('ul').children('li:first').before('<li class="mainLink'+index+'"></li>'); + WDN.jQuery(this).children('a').clone().prependTo('li.mainLink'+index); + WDN.jQuery(this).children('a').replaceWith(WDN.jQuery(this).children('a').contents()); + WDN.jQuery(this).removeClass().addClass('nav'+index).children('ul').addClass('nav'+index); + WDN.jQuery(this).css({"background":"url('images/arrowForward.png') no-repeat right"}) + }); + WDN.jQuery("#mobile_navigation > ul > li > ul").insertAfter('#mobile_navigation ul:first'); + + WDN.jQuery('ul#mobile_breadcrumbs li:last-child a').click(function(event) { //show the navigation + event.preventDefault(); + if (WDN.jQuery('#mobile_navigation ul:first').css('display') === 'none') { + WDN.jQuery('#mobile_navigation h2').show(); + WDN.jQuery('#mobile_navigation ul:first').show(); + WDN.jQuery('#mobile_navigation ul[class^=nav]').hide(); + } else { + WDN.jQuery('#mobile_navigation ul:first').hide(); + WDN.jQuery('#mobile_navigation h2').hide(); + }; + + window.location.hash = 'navigation'; + return false; + }); + WDN.jQuery('#mobile_navigation > ul.parentNav > li').click(function() { //show the secondary navigation + secondaryNav = WDN.jQuery(this).attr('class'); + WDN.jQuery(this).parent('ul').hide(); + WDN.jQuery('#mobile_navigation ul.'+secondaryNav).show(); + window.location.hash = 'sec_'+secondaryNav; + }); + WDN.jQuery('#mobile_navigation > ul[class!=parentNav] > li').has('a').click(function(){ + window.location = WDN.jQuery(this).children('a').attr('href'); + }); +}) \ No newline at end of file diff --git a/plugins/mobile_unl/views/mobile/pageshells/pageshell.php b/plugins/mobile_unl/views/mobile/pageshells/pageshell.php index bd1dafd5..dc86efb9 100755 --- a/plugins/mobile_unl/views/mobile/pageshells/pageshell.php +++ b/plugins/mobile_unl/views/mobile/pageshells/pageshell.php @@ -38,9 +38,8 @@ $page = UNL_Templates::factory('Popup'); $page->doctitle = '<title>'.$vars['title'].'</title>'; $page->titlegraphic = '<h1><a href="'.$vars['config']->url.'" title="Planet Red Home">'.$vars['config']->sitename.'</a></h1>'; $page->head .= '<link rel="stylesheet" href="' . $vars['url'] .'_css/css.css?lastcache='.$vars['config']->lastcache.'>&viewtype=mobile&view=mobile" type="text/css" />'; - +$page->head .= '<script type="text/javascript" src="' . $vars['url'] . 'mod/mobile_unl/mobile.js"></script>'; $page->head .= <<<END -<script type="text/javascript" src="http://m.unl.edu/mobile.js"></script> <link media="only screen and (max-device-width: 480px)" href="http://m.unl.edu/mobile.css" type="text/css" rel="stylesheet" /> <link media="screen" href="http://m.unl.edu/mobile.css" type="text/css" rel="stylesheet" /> END; -- GitLab