2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 10:46:53 +00:00

fhemweb.js: add dialog in smallscreen mode for webCmd if hiddenroom=detail (Forum #49930)

git-svn-id: https://svn.fhem.de/fhem/trunk@10956 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2016-02-28 15:27:50 +00:00
parent 19fc038d05
commit 7eaa3bab8e
2 changed files with 45 additions and 5 deletions

View File

@ -196,9 +196,45 @@ FW_jqueryReadyFn()
});
});
FW_smallScreenCommands();
}
// Show the webCmd list in a dialog if: smallScreen & hiddenroom=detail & room
function
FW_smallScreenCommands()
{
if($("div#menu select").length == 0 || // not SmallScreen
$("div#content").attr("room") == undefined || // not room Overview
$("div#content div.col1 a").length > 0) // no hiddenroom=detail
return;
$("div#content div.col1").each(function(){
var tr = $(this).closest("tr");
if($(tr).find("> td").length <= 2)
return;
$(this).html("<a href='#'>"+$(this).html()+"</a>");
$(this).find("a").click(function(){
var t = $("<table></table>"), row=0;
$(tr).find("> td").each(function(){
$(t).append("<tr></tr>");
if(row++ == 0) {
$(t).find("tr:last").append($(this).find("a").html());
} else {
$(this).attr("data-orig", 1);
this.orig=$(this).parent();
$(t).find("tr:last").append($(this).detach());
}
});
FW_okDialog(t, this, function(){
$("#FW_okDialog [data-orig]").each(function(){
$(this).detach().appendTo(this.orig);
});
});
});
});
}
if(window.jQuery) {
$(document).ready(FW_jqueryReadyFn);
@ -282,16 +318,19 @@ FW_errmsg(txt, timeout)
}
function
FW_okDialog(txt, parent)
FW_okDialog(txt, parent, removeFn)
{
var div = $("<div id='FW_okDialog'>");
$(div).html(txt);
$("body").append(div);
var oldPos = $("body").scrollTop();
$(div).dialog({
dialogClass:"no-close", modal:true, width:"auto", closeOnEscape:true,
maxWidth:$(window).width()*0.9, maxHeight:$(window).height()*0.9,
buttons: [{text:"OK", click:function(){
$(this).dialog("close");
if(removeFn)
removeFn();
$(div).remove();
}}]
});
@ -304,6 +343,7 @@ FW_okDialog(txt, parent)
my: "left top", at: "right bottom",
of: parent, collision: "flipfit"
});
setTimeout(function(){$("body").scrollTop(oldPos);}, 1); // Not ideal.
}
function

View File

@ -61,14 +61,14 @@ button.dist { margin:5px; }
/* Landscape mode */
@media all and (orientation:landscape) {
div.col1 { width: 282px; }
div.col2 { width: 108px; }
div.col3 { width: 108px; height: 30px; }
div.col1 { width:282px; }
div.col2 { width:108px; }
div.col3 { width:100%; min-width:108px; height:30px; }
table.block input { text-align: center; }
table.block tr td:nth-child(3) { text-align: center; }
table.block div.slider { width: 108px; text-align: center; }
table.block div.slider { min-width: 108px; text-align: center; }
table.block slider { float: none; }
table.block select { text-align: center; }
}