12.06.2016, 21:28
(This post was last modified: 12.06.2016, 21:34 by Erwin van der Zwart.)
Hi,
Thanks Mark for pointing that out!
Use _H_iPad and _V_iPad as suffix iPad pages
use _H_iPho and _V_iPho as suffix for iPhone pages
use _H_Desk and _V_Desk as suffix for all other devices
Then the code will be like this:
BR,
Erwin
Thanks Mark for pointing that out!
Use _H_iPad and _V_iPad as suffix iPad pages
use _H_iPho and _V_iPho as suffix for iPhone pages
use _H_Desk and _V_Desk as suffix for all other devices
Then the code will be like this:
Code:
$(function(){
var isIpad = navigator.userAgent.match(/iPad/i) != null;
var isIphone = navigator.userAgent.match(/iPhone/i) != null;
function OrientationChange(orientation){
var currentplan_name = planStore[currentPlanId].name;
var firstChars = currentplan_name.substr(0, (currentplan_name.length - 7));
var lastChars = currentplan_name.substr(currentplan_name.length - 7);
var newPlanName = 'Not Found'
if ((lastChars == '_V_iPad' || lastChars == '_V_iPho' || lastChars == '_V_Desk') && orientation == '_H_iPad'){
var newPlanName = firstChars + '_H_iPad'
}
if ((lastChars == '_V_iPad' || lastChars == '_V_iPho' || lastChars == '_V_Desk') && orientation == '_H_iPho'){
var newPlanName = firstChars + '_H_iPho'
}
if ((lastChars == '_V_iPad' || lastChars == '_V_iPho' || lastChars == '_V_Desk') && orientation == '_H_Desk'){
var newPlanName = firstChars + '_H_Desk'
}
if ((lastChars == '_H_iPad' || lastChars == '_H_iPho' || lastChars == '_H_Desk') && orientation == '_V_iPad'){
var newPlanName = firstChars + '_V_iPad'
}
if ((lastChars == '_H_iPad' || lastChars == '_H_iPho' || lastChars == '_H_Desk') && orientation == '_V_iPho'){
var newPlanName = firstChars + '_V_iPho'
}
if ((lastChars == '_H_iPad' || lastChars == '_H_iPho' || lastChars == '_H_Desk') && orientation == '_V_Desk'){
var newPlanName = firstChars + '_V_Desk'
}
if (newPlanName != 'Not Found'){
for (var key in planStore) {
// skip loop if the property is from prototype
if (!planStore.hasOwnProperty(key)) continue;
var obj = planStore[key];
for (var prop in obj) {
// skip loop if the property is from prototype
if(!obj.hasOwnProperty(prop)) continue;
//console.log(prop + " = " + obj[prop]);
if (obj.name == newPlanName){
showPlan(obj.id);
}
}
}
}
}
function doOnOrientationChange(){
switch(window.orientation)
{
case -90:
case 90:
if (isIpad == true){
OrientationChange('_H_iPad')
} else if (isIphone == true){
OrientationChange('_H_iPho')
} else {
OrientationChange('_H_Desk')
}
break;
default:
if (isIpad == true){
OrientationChange('_V_iPad')
} else if (isIphone == true){
OrientationChange('_V_iPho')
} else {
OrientationChange('_V_Desk')
}
break;
}
}
window.addEventListener('orientationchange', doOnOrientationChange);
// Initial execution if needed
doOnOrientationChange();
});
BR,
Erwin