2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 05:06:35 +00:00

Responsive iOS 6 Theme - ios6.js needs to be added in the config.

added Android support
http://forum.fhem.de/index.php/topic,23406.msg166953.html#msg166953

git-svn-id: https://svn.fhem.de/fhem/trunk@8686 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
blackcatsandy 2015-06-04 12:03:48 +00:00
parent 95fa5dec43
commit bd5aa07d1b
2 changed files with 625 additions and 574 deletions

View File

@ -2,8 +2,7 @@
/* by Sandra Ohmayer */ /* by Sandra Ohmayer */
/* http://www.animeschatten.net */ /* http://www.animeschatten.net */
/* jQuery is required*/ /* jQuery is required*/
$(document).ready(function() {
$( document ).ready(function() {
/* /*
/* Style Config /* Style Config
*/ */
@ -14,35 +13,31 @@ $( document ).ready(function() {
var switchtomobilemode = 376; var switchtomobilemode = 376;
var hdrheight = 44; var hdrheight = 44;
var inputpadding = 251; var inputpadding = 251;
/* /*
/* Functions /* Functions
*/ */
// Set style height and width // Set style height and width
var recalculateStyleHeight = function() { var recalculateStyleHeight = function() {
var height = window.innerHeight; var height = window.innerHeight;
$("#menu").height(height-hdrheight); $("#menu").height(height - hdrheight);
$("#content").height(height-hdrheight); $("#content").height(height - hdrheight);
$("#right").height(height-hdrheight); $("#right").height(height - hdrheight);
}; };
var recalculateStyleWithMenu = function() { var recalculateStyleWithMenu = function() {
var width = $("body").width(); var width = $("body").width();
$("body").removeClass("hideMenu"); $("body").removeClass("hideMenu");
if (switchtomobilemode > width) { if (switchtomobilemode > width) {
$("#menu").width(width); $("#menu").width(width);
$("#content").width(0); $("#content").width(0);
$("#right").width(0); $("#right").width(0);
$("#content").hide() $("#content").hide()
$("#right").hide(); $("#right").hide();
$("#hdr input").width(width-inputpadding+menuwidth-logowidth); $("#hdr input").width(width - inputpadding + menuwidth - logowidth);
} else { } else {
$("#menu").width(menuwidth); $("#menu").width(menuwidth);
$("#content").width(width-menuwidth-paddingwidth-1); $("#content").width(width - menuwidth - paddingwidth - 1);
$("#right").width(width-menuwidth-paddingwidth-1); $("#right").width(width - menuwidth - paddingwidth - 1);
$("#hdr input").width(width-inputpadding); $("#hdr input").width(width - inputpadding);
$("#content").show() $("#content").show()
$("#right").show(); $("#right").show();
} }
@ -50,23 +45,19 @@ $( document ).ready(function() {
var recalculateStyleWithoutMenu = function() { var recalculateStyleWithoutMenu = function() {
var width = $("body").width(); var width = $("body").width();
$("body").addClass("hideMenu"); $("body").addClass("hideMenu");
if (switchtomobilemode > width) { if (switchtomobilemode > width) {
$("#hdr input").width(width-inputpadding+menuwidth-logowidth); $("#hdr input").width(width - inputpadding + menuwidth - logowidth);
$("#content").width(width-mobilepaddingwidth); $("#content").width(width - mobilepaddingwidth);
$("#right").width(width-mobilepaddingwidth); $("#right").width(width - mobilepaddingwidth);
} else { } else {
$("#hdr input").width(width-inputpadding); $("#hdr input").width(width - inputpadding);
$("#content").width(width-paddingwidth); $("#content").width(width - paddingwidth);
$("#right").width(width-paddingwidth); $("#right").width(width - paddingwidth);
} }
$("#menu").width(0); $("#menu").width(0);
$("#content").show() $("#content").show()
$("#right").show(); $("#right").show();
}; };
// Show / Hide menu // Show / Hide menu
var toggleMenuOnFHEMIcon = function() { var toggleMenuOnFHEMIcon = function() {
if ($("body").hasClass("hideMenu")) { if ($("body").hasClass("hideMenu")) {
@ -75,27 +66,38 @@ $( document ).ready(function() {
recalculateStyleWithoutMenu(); recalculateStyleWithoutMenu();
} }
}; };
/* /*
/* DOM manipulation /* DOM manipulation
*/ */
// init viewport // init viewport
$('meta[name="viewport"]').attr('content', 'width=device-width, user-scalable=0, initial-scale=1.0'); $('head').append('<meta name="viewport" content=width=device-width, user-scalable=0, initial-scale=1.0/>');
var ismobile = (/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(navigator.userAgent.toLowerCase()));
var istablet = (/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()));
var isAndroid = function() {
return navigator.userAgent.match(/Android/i);
};
if (ismobile) {
$("body").addClass("isMobile");
if (isAndroid()) {
$("body").addClass("isAndroidPhone");
}
} else if(istablet) {
if (isAndroid()) {
$("body").addClass("isAndroidTablet");
}
}
// init height and width // init height and width
recalculateStyleHeight(); recalculateStyleHeight();
// hide menu // hide menu
if($("body").width() < window.innerHeight) { if ($("body").width() < window.innerHeight) {
recalculateStyleWithoutMenu(); recalculateStyleWithoutMenu();
} else { } else {
recalculateStyleWithMenu(); recalculateStyleWithMenu();
} }
// Logo - add toggle link // Logo - add toggle link
var parentLink = $("#logo").parent("a"); var parentLink = $("#logo").parent("a");
if (typeof(parentLink.attr("href")) == "undefined") { if (typeof(parentLink.attr("href")) == "undefined") {
@ -104,15 +106,13 @@ $( document ).ready(function() {
parentLink.attr("href", "#"); parentLink.attr("href", "#");
} }
$("#logo").click(toggleMenuOnFHEMIcon); $("#logo").click(toggleMenuOnFHEMIcon);
/* /*
/* Event Handlers /* Event Handlers
*/ */
// Resize // Resize
$(window).resize(function() { $(window).resize(function() {
recalculateStyleHeight(); recalculateStyleHeight();
if($("body").width() < window.innerHeight) { if ($("body").width() < window.innerHeight) {
recalculateStyleWithoutMenu(); recalculateStyleWithoutMenu();
} else { } else {
recalculateStyleWithMenu(); recalculateStyleWithMenu();
@ -121,16 +121,15 @@ $( document ).ready(function() {
$(window).bind('orientationchange', function(event) { $(window).bind('orientationchange', function(event) {
//alert("orientationchange width: "+window.innerWidth+" height: "+window.innerHeight); //alert("orientationchange width: "+window.innerWidth+" height: "+window.innerHeight);
recalculateStyleHeight(); recalculateStyleHeight();
if($("body").width() < window.innerHeight) { if ($("body").width() < window.innerHeight) {
recalculateStyleWithoutMenu(); recalculateStyleWithoutMenu();
} else { } else {
recalculateStyleWithMenu(); recalculateStyleWithMenu();
} }
}); });
// Touch - Color picker // Touch - Color picker
$(document).on('touchstart', function (e) { $(document).on('touchstart', function(e) {
var container = $("#colorpicker"); var container = $("#colorpicker");
if (!container.is(e.target) // if the target of the click isn't the container... if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0 // ... nor a descendant of the container && container.has(e.target).length === 0 // ... nor a descendant of the container
&& !$("input").is(e.target) && container.length > 0) // ... is not an input && !$("input").is(e.target) && container.length > 0) // ... is not an input
@ -138,5 +137,4 @@ $( document ).ready(function() {
container.remove(); container.remove();
} }
}); });
}); });

File diff suppressed because it is too large Load Diff