"use strict"; FW_version["f18.js"] = "$Id$"; // TODO: hierMenu+Pin,SVGcolors,floorplan // Known bugs: AbsSize is wrong for ColorSlider var f18_attr={}, f18_sd, f18_icon={}, f18_room, f18_grid=20, f18_margin=10; var f18_small = (screen.width < 480 || screen.height < 480); $(window).resize(f18_resize); $(document).ready(function(){ f18_room = $("div#content").attr("room"); f18_sd = $("body").attr("data-styleData"); if(f18_sd) { eval("f18_sd="+f18_sd); if(!f18_sd) f18_sd = {}; f18_attr = f18_sd.f18; if(f18_attr) delete(f18_attr.cols); // fix the past } else { f18_sd = {}; } if(!f18_sd.f18) { 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; } var 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)"/>'); // Needed for moving this label var szc = $("[data-name=svgZoomControl]"); if($(szc).length) $(szc).before("
"); $(".SVGlabel[data-name]").each(function(){ $(this).attr("data-name", "Room_"+f18_room+"_"+$(this).attr("data-name")); }); f18_menu(); f18_tables(); f18_svgSetCols(); if(typeof svgCallback != "undefined") svgCallback.f18 = f18_svgSetCols; $("[data-name]").each(function(){ f18_setPos(this) }); f18_setWrapColumns(); f18_setFixedInput(); }); 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("hidden") }); $("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_getAttr("hideLogo") ? "none" : "block"); if(f18_getAttr("Pinned.menu")) { $("body").addClass("pinnedMenu"); $("#menu").removeClass("hidden"); $("#content").css("left", (parseInt($("div#menu").width())+2*f18_margin)+"px"); } else { $("body").removeClass("pinnedMenu"); $("#content").css("left", f18_margin); } 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(); }); }); 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%20list" || FW_urlParams.cmd == "style%20select") $("div.fileList").each(function(){ f18_addPinToStyleDiv(this) }); if(FW_urlParams.cmd == "style%20select") f18_special(); else if(f18_getAttr("showDragger")) $("[data-name]").each(function(){ f18_addDragger(this) }); } function f18_special() { var row, room='all', appendTo; var attr = function(attrName, inRoom) { if(inRoom && room != "all") { var val = f18_attr["Room."+room+"."+attrName]; if(val != undefined) return val; } return f18_attr[attrName]; }; var setAttr = function(attrName, attrVal, inRoom) { if(inRoom && room != "all") attrName = "Room."+room+"."+attrName; f18_setAttr(attrName, attrVal); }; var addRow = function(name, desc, val) { $(appendTo) .append(""+ ""+ "
"+desc+"
"+ (val ? "
"+val+"
" : '')+ ""); }; var addHider = function(name, inRoom, desc, fn) { addRow(name, desc, ""); $(appendTo+" tr.ar_"+name+" input") .prop("checked", attr(name, inRoom)) .click(function(){ var c = $(this).is(":checked"); setAttr(name, c, inRoom); if(fn) fn(c); }); }; var addColorChooser = function(name, desc) { addRow(name, desc, "
"); FW_replaceWidget(appendTo+" tr.ar_"+name+" div.col2 div.cp", name, ["colorpicker","RGB"], attr("cols."+name, true), name, "rgb", undefined, function(value) { setAttr("cols."+name, value, true); f18_setCss(name); }); }; // call drawspecial after got the roomlist... var f18_drawSpecial = function() { var roomHash={}; var cleanRoom = function(){ for(var k in f18_attr) { var m = k.match(/^room\.([^.]*)\..*/); if(m && !roomHash[m[1]]) delete f18_attr[k]; } }; row = 0; $("div#content tr.f18").remove(); $("div#content > table").append(""); $("tr#f18rs").append("
f18 special
"); $("tr#f18rs").append("
"); appendTo = "table#f18ts"; addHider("rightMenu", false, "MenuBtn right
on small screen",f18_resize); addHider("savePinChanges", false, "Save pin changes"); addHider("showDragger", false, "Dragging active", function(c){ if(c) { if($(".ui-draggable").length) { $(".ui-draggable").draggable("enable"); $(".dragMove,.dragSize,.dragReset").show(); } else { $("div.fileList").each(function(){ f18_addDragger(this) }); } } else { $(".dragMove,.dragSize,.dragReset").hide(); $(".ui-draggable").draggable("disable"); } }); addHider("snapToGrid", false, "Snap to grid", function(c){ $(".ui-draggable").draggable("option", "grid", c ? [f18_grid,f18_grid] : [1,1]); }); addRow("editStyle", "Additional CSS"); $(appendTo+" tr.ar_editStyle a").click(function(){ $('body').append( '