"use strict"; FW_version["f18.js"] = "$Id$"; // TODO: rewrite menu, dashboard, floorplan var f18_attr, f18_aCol, f18_sd, f18_isMobile, f18_icon={}, f18_move=false; var f18_small = (screen.width < 480 || screen.height < 480); $(window).resize(f18_resize); $(document).ready(function(){ f18_sd = $("body").attr("data-styleData"); if(f18_sd) { eval("f18_sd="+f18_sd); if(!f18_sd) f18_sd = {}; f18_attr = f18_sd.f18; } else { f18_sd = {}; } if(!f18_attr) { f18_attr = { "Pinned.menu":"true" }; f18_resetCol(); f18_sd.f18 = f18_attr; } if(typeof f18_attr.savePinChanges == "undefined") f18_attr.savePinChanges = true; f18_setCss('init'); var icon = FW_root+"/images/default/fhemicon_ios.png"; $('head').append( ''+ ''+ ''+ ''); if('ontouchstart' in window) $("body").addClass('touch'); if(f18_small) { $("body").addClass('small'); f18_attr["Pinned.menu"] = false; } if(f18_attr.rightMenu) $("body").addClass("rightMenu"); f18_aCol = getComputedStyle($("a").get(0),null).getPropertyValue('color'); for(var i in f18_icon) f18_icon[i] = f18_icon[i].replace('gray', f18_aCol); f18_icon.pinOut = f18_icon.pinIn .replace('/>',' transform="rotate(90,896,896)"/>'); f18_menu(); f18_tables(); f18_svgSetCols(); if(typeof svgCallback != "undefined") svgCallback.f18 = f18_svgSetCols; }); function f18_menu() { if($("#menuScrollArea #menuBtn").length) return fixMenu(); $("").prependTo("div#menuScrollArea") .css( {"background-image":"url('"+f18_icon.bars+"')", "cursor":"pointer" }) .click(function(){ $("#menu").toggleClass("visible") }); $("div#menu").prepend("
"); f18_addPin("div#menu > div:first", "menu", true, fixMenu, f18_small); setTimeout(function(){ $("#menu,#content,#logo,#hdr").addClass("animated"); }, 10); function fixMenu() { $("#menuScrollArea #logo").css("display", f18_attr.hideLogo?"none":"block"); if(f18_attr["Pinned.menu"]) { $("body").addClass("pinnedMenu"); $("#menu").removeClass("visible"); $("#content").css("left", (parseInt($("div#menu").width())+20)+"px"); } else { $("body").removeClass("pinnedMenu"); $("#content").css("left", ""); } f18_resize(); } } function f18_tables() { $("table.roomoverview > tbody > tr > td > .devType:not(:first)") .css("margin-top", "20px"); $("table.column tbody tr:not(:first-child) .devType") .css("margin-top", "20px"); $("#content .devType").each(function(){ var el = this, grp = $(el).text(); f18_addPin(el, "room."+FW_urlParams.room+".grp."+grp, true, function(isFixed){ var ntr = $(el).closest("tr").next("tr"); isFixed ? $(ntr).show() : $(ntr).hide(); }); f18_addMove(el, function(){ log("Hello") }); }); if(FW_urlParams.detail) { $("div.makeTable > span").each(function(){ var el = this, grp = $(el).text(); var nel = $("
"+grp+"
"); $(el).replaceWith(nel); f18_addPin(nel, "detail."+grp, true, function(isFixed){ var ntr = $(nel).next("table"); isFixed ? $(ntr).show() : $(ntr).hide(); }); }); } if(FW_urlParams.cmd == "style%20select") { var row=0; var addRow = function(name, desc, val) { $("table.f18colors") .append(""+ ""+ "
"+desc+"
"+ (val ? "
"+val+"
" : '')+ ""); }; var addHider = function(name, desc, fn, lVarName) { addRow(name, desc, ""); $("table.f18colors tr.ar_"+name+" input") .prop("checked", lVarName ? window[lVarName] : f18_attr[name]) .click(function(){ var c = $(this).is(":checked"); if(!lVarName) f18_setAttr(name, c); fn(c); }); }; var addColorChooser = function(name, desc) { addRow(name, desc, "
"); FW_replaceWidget("table.f18colors tr.ar_"+name+" div.col2 div.cp", name, ["colorpicker","RGB"], f18_attr.cols[name], name, "rgb", undefined, function(value) { f18_attr.cols[name] = value; f18_setAttr(); f18_setCss(name); }); }; $("div#content > table").append(""); $("tr.f18").append("
f18 special
"); $("div.f18colors").css("margin-top", "20px"); $("tr.f18").append("
"); var addColors = function() { $("table.f18colors") .append(""+ "
Preset colors: "+ "default "+ "light "+ "dark "+ "
"+ ""); $("table.f18colors tr.reset a").click(function(){ row = 0; $("table.f18colors").html(""); f18_resetCol($(this).text()); f18_setCss('preset'); f18_setAttr(); addColors(); }); addColorChooser("bg", "Background"); addColorChooser("fg", "Foreground"); addColorChooser("link", "Link"); addColorChooser("evenrow", "Even row"); addColorChooser("oddrow", "Odd row"); addColorChooser("header", "Header row"); addColorChooser("menu", "Menu"); addColorChooser("sel", "Menu:Selected"); addColorChooser("inpBack", "Input bg"); $("table.f18colors input").attr("size", 8); addRow("editStyle", "Additional CSS"); $("table.f18colors tr.ar_editStyle a").click(function(){ $('body').append( '