2018-01-14 21:35:42 +00:00
"use strict" ;
FW _version [ "f18.js" ] = "$Id$" ;
2018-07-06 20:49:43 +00:00
// TODO: hierMenu+Pin,SVGcolors,floorplan
// Known bugs: AbsSize is wrong for ColorSlider
2018-09-09 13:43:37 +00:00
var f18 _attr = { } , f18 _sd , f18 _icon = { } , f18 _room , f18 _grid = 20 , f18 _margin = 10 ;
2018-01-07 13:22:51 +00:00
var f18 _small = ( screen . width < 480 || screen . height < 480 ) ;
$ ( window ) . resize ( f18 _resize ) ;
$ ( document ) . ready ( function ( ) {
2018-02-11 17:02:29 +00:00
f18 _room = $ ( "div#content" ) . attr ( "room" ) ;
2018-01-07 13:22:51 +00:00
f18 _sd = $ ( "body" ) . attr ( "data-styleData" ) ;
if ( f18 _sd ) {
eval ( "f18_sd=" + f18 _sd ) ;
if ( ! f18 _sd )
f18 _sd = { } ;
f18 _attr = f18 _sd . f18 ;
2018-05-10 08:22:42 +00:00
if ( f18 _attr )
delete ( f18 _attr . cols ) ; // fix the past
2018-01-15 12:18:01 +00:00
} else {
f18 _sd = { } ;
2018-01-07 13:22:51 +00:00
}
2018-01-15 12:18:01 +00:00
2018-05-10 08:22:42 +00:00
if ( ! f18 _sd . f18 ) {
2018-09-17 17:31:50 +00:00
f18 _attr = { "Pinned.menu" : "true" , "hidePin" : "true" } ;
2018-01-07 13:22:51 +00:00
f18 _resetCol ( ) ;
f18 _sd . f18 = f18 _attr ;
}
2018-01-14 21:38:49 +00:00
if ( typeof f18 _attr . savePinChanges == "undefined" )
f18 _attr . savePinChanges = true ;
2018-01-07 13:22:51 +00:00
2018-07-06 20:49:43 +00:00
f18 _setCss ( 'init' ) ;
2018-01-07 13:22:51 +00:00
2018-07-06 20:49:43 +00:00
var icon = FW _root + "/images/default/fhemicon_ios.png" ;
2018-01-07 13:22:51 +00:00
$ ( 'head' ) . append (
'<meta name="viewport" content="initial-scale=1.0,user-scalable=1">' +
'<meta name= "mobile-web-app-capable" content="yes">' +
'<meta name="apple-mobile-web-app-capable" content="yes">' +
'<link rel="apple-touch-icon" href="' + icon + '">' ) ;
2018-07-06 20:49:43 +00:00
if ( 'ontouchstart' in window )
$ ( "body" ) . addClass ( 'touch' ) ;
2018-01-07 13:31:54 +00:00
if ( f18 _small ) {
2018-01-07 13:22:51 +00:00
$ ( "body" ) . addClass ( 'small' ) ;
2018-01-07 13:31:54 +00:00
f18 _attr [ "Pinned.menu" ] = false ;
}
2018-01-07 13:22:51 +00:00
2018-11-08 10:30:28 +00:00
var f18 _aCol = "rgb(39, 135, 39)" ;
if ( $ ( "a" ) . length )
f18 _aCol = getComputedStyle ( $ ( "a" ) . get ( 0 ) , null ) . getPropertyValue ( 'color' ) ;
2018-10-07 16:45:18 +00:00
f18 _loadIcons ( ) ;
f18 _loadTouch ( ) ;
2018-01-14 21:35:42 +00:00
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)"/>' ) ;
2018-01-07 13:22:51 +00:00
2018-07-06 20:49:43 +00:00
// Needed for moving this label
var szc = $ ( "[data-name=svgZoomControl]" ) ;
if ( $ ( szc ) . length )
$ ( szc ) . before ( "<div class='SVGplot'></div>" ) ;
2018-08-25 19:14:34 +00:00
$ ( ".SVGlabel[data-name]" ) . each ( function ( ) {
$ ( this ) . attr ( "data-name" , "Room_" + f18 _room + "_" + $ ( this ) . attr ( "data-name" ) ) ;
} ) ;
2018-01-07 13:22:51 +00:00
f18 _menu ( ) ;
f18 _tables ( ) ;
2018-01-14 21:35:42 +00:00
if ( typeof svgCallback != "undefined" )
svgCallback . f18 = f18 _svgSetCols ;
2018-07-06 20:49:43 +00:00
$ ( "[data-name]" ) . each ( function ( ) { f18 _setPos ( this ) } ) ;
2018-08-03 09:40:57 +00:00
f18 _setWrapColumns ( ) ;
f18 _setFixedInput ( ) ;
2018-01-07 13:22:51 +00:00
} ) ;
function
f18 _menu ( )
{
2018-09-10 13:29:29 +00:00
$ ( "#menu" ) . toggleClass ( "hidden" , f18 _small || ! f18 _getAttr ( "Pinned.menu" ) ) ;
2018-01-15 22:30:38 +00:00
if ( $ ( "#menuScrollArea #menuBtn" ) . length )
return fixMenu ( ) ;
2019-04-04 20:22:10 +00:00
$ ( "<div id='textInput'></div>" ) . prependTo ( "div#menuScrollArea" )
. css ( { "background-image" : "url('" + f18 _icon . txInp + "')" , "cursor" : "pointer" } )
. click ( f18 _textInput ) ;
2018-01-07 13:22:51 +00:00
$ ( "<div id='menuBtn'></div>" ) . prependTo ( "div#menuScrollArea" )
2018-01-14 21:35:42 +00:00
. css ( { "background-image" : "url('" + f18 _icon . bars + "')" , "cursor" : "pointer" } )
2018-09-09 13:43:37 +00:00
. click ( function ( ) { $ ( "#menu" ) . toggleClass ( "hidden" ) } ) ;
2018-01-07 13:22:51 +00:00
$ ( "div#menu" ) . prepend ( "<div></div>" ) ;
f18 _addPin ( "div#menu > div:first" , "menu" , true , fixMenu , f18 _small ) ;
2019-04-04 20:22:10 +00:00
setTimeout ( function ( ) { $ ( "#menu,#content,#logo,#hdr,#menuBtn,#textInput" )
. addClass ( "animated" ) ; } , 10 ) ;
2018-01-07 13:22:51 +00:00
function
2018-01-15 22:30:38 +00:00
fixMenu ( )
{
2018-02-11 17:02:29 +00:00
$ ( "#menuScrollArea #logo" ) . css ( "display" ,
f18 _getAttr ( "hideLogo" ) ? "none" : "block" ) ;
if ( f18 _getAttr ( "Pinned.menu" ) ) {
2018-01-15 22:30:38 +00:00
$ ( "body" ) . addClass ( "pinnedMenu" ) ;
2018-09-09 13:43:37 +00:00
$ ( "#menu" ) . removeClass ( "hidden" ) ;
$ ( "#content" ) . css ( "left" ,
( parseInt ( $ ( "div#menu" ) . width ( ) ) + 2 * f18 _margin ) + "px" ) ;
2018-01-15 22:30:38 +00:00
2018-01-07 13:22:51 +00:00
} else {
2018-01-15 22:30:38 +00:00
$ ( "body" ) . removeClass ( "pinnedMenu" ) ;
2018-09-09 13:43:37 +00:00
$ ( "#content" ) . css ( "left" , f18 _margin ) ;
2018-01-07 13:22:51 +00:00
}
f18 _resize ( ) ;
}
}
function
f18 _tables ( )
{
2018-10-24 15:06:20 +00:00
// one-column roomoverview & readingsGroup
$ ( "div#content > table > tbody > tr > td > .devType:not(:first)" )
2018-01-07 13:22:51 +00:00
. css ( "margin-top" , "20px" ) ;
2018-10-24 15:06:20 +00:00
// multi-column roomoverview
2018-01-07 13:22:51 +00:00
$ ( "table.column tbody tr:not(:first-child) .devType" )
. css ( "margin-top" , "20px" ) ;
$ ( "#content .devType" ) . each ( function ( ) {
var el = this , grp = $ ( el ) . text ( ) ;
2018-02-11 17:02:29 +00:00
f18 _addPin ( el , "Room." + FW _urlParams . room + ".grp." + grp , true ,
2018-01-07 13:22:51 +00:00
function ( isFixed ) {
var ntr = $ ( el ) . closest ( "tr" ) . next ( "tr" ) ;
isFixed ? $ ( ntr ) . show ( ) : $ ( ntr ) . hide ( ) ;
} ) ;
2018-02-03 22:27:04 +00:00
} ) ;
2018-01-07 13:22:51 +00:00
if ( FW _urlParams . detail ) {
$ ( "div.makeTable > span" ) . each ( function ( ) {
var el = this , grp = $ ( el ) . text ( ) ;
var nel = $ ( "<div>" + grp + "</div>" ) ;
$ ( el ) . replaceWith ( nel ) ;
f18 _addPin ( nel , "detail." + grp , true ,
function ( isFixed ) {
var ntr = $ ( nel ) . next ( "table" ) ;
isFixed ? $ ( ntr ) . show ( ) : $ ( ntr ) . hide ( ) ;
} ) ;
} ) ;
}
2018-02-11 17:02:29 +00:00
if ( FW _urlParams . cmd == "style%20list" ||
2018-07-06 20:49:43 +00:00
FW _urlParams . cmd == "style%20select" )
2018-02-11 17:02:29 +00:00
$ ( "div.fileList" ) . each ( function ( ) { f18 _addPinToStyleDiv ( this ) } ) ;
2018-01-07 13:22:51 +00:00
2018-07-06 20:49:43 +00:00
if ( FW _urlParams . cmd == "style%20select" )
f18 _special ( ) ;
else if ( f18 _getAttr ( "showDragger" ) )
$ ( "[data-name]" ) . each ( function ( ) { f18 _addDragger ( this ) } ) ;
2018-02-11 17:02:29 +00:00
}
2018-01-07 13:22:51 +00:00
2018-02-11 17:02:29 +00:00
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 ] ;
} ;
2018-01-07 13:22:51 +00:00
2018-02-11 17:02:29 +00:00
var setAttr = function ( attrName , attrVal , inRoom )
{
if ( inRoom && room != "all" )
attrName = "Room." + room + "." + attrName ;
f18 _setAttr ( attrName , attrVal ) ;
} ;
2018-01-07 13:22:51 +00:00
2018-02-11 17:02:29 +00:00
var addRow = function ( name , desc , val )
{
$ ( appendTo )
. append ( "<tr class='ar_" + name + " " + ( ++ row % 2 ? "even" : "odd" ) + "'>" +
"<td " + ( val ? "" : "colspan='2'" ) + ">" +
"<div class='col1'>" + desc + "</div></td>" +
( val ? "<td><div class='col2'>" + val + "</div></div></td>" : '' ) +
"</tr>" ) ;
} ;
2018-01-14 21:35:42 +00:00
2018-02-11 17:02:29 +00:00
var addHider = function ( name , inRoom , desc , fn )
{
addRow ( name , desc , "<input type='checkbox'>" ) ;
$ ( appendTo + " tr.ar_" + name + " input" )
. prop ( "checked" , attr ( name , inRoom ) )
. click ( function ( ) {
var c = $ ( this ) . is ( ":checked" ) ;
setAttr ( name , c , inRoom ) ;
2018-07-06 20:49:43 +00:00
if ( fn )
fn ( c ) ;
2018-01-07 13:22:51 +00:00
} ) ;
2018-02-11 17:02:29 +00:00
} ;
var addColorChooser = function ( name , desc )
{
addRow ( name , desc , "<div class='cp'></div>" ) ;
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 ) ;
2018-02-03 22:27:04 +00:00
} ) ;
2018-02-11 17:02:29 +00:00
} ;
2018-01-14 21:35:42 +00:00
2018-07-06 20:49:43 +00:00
// call drawspecial after got the roomlist...
2018-02-11 17:02:29 +00:00
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 ] ;
}
2018-01-17 16:05:58 +00:00
} ;
2018-01-07 13:22:51 +00:00
2018-02-11 17:02:29 +00:00
row = 0 ;
$ ( "div#content tr.f18" ) . remove ( ) ;
$ ( "div#content > table" ) . append ( "<tr id='f18rs' class='f18'></tr>" ) ;
$ ( "tr#f18rs" ) . append ( "<div class='fileList f18colors'>f18 special</div>" ) ;
$ ( "tr#f18rs" ) . append ( "<table id='f18ts' class='block wide'></table>" ) ;
appendTo = "table#f18ts" ;
2018-08-03 09:40:57 +00:00
addHider ( "rightMenu" , false , "MenuBtn right<br>on small screen" , f18 _resize ) ;
2018-07-06 20:49:43 +00:00
addHider ( "savePinChanges" , false , "Save pin changes" ) ;
2018-02-11 17:02:29 +00:00
addHider ( "showDragger" , false , "Dragging active" , function ( c ) {
if ( c ) {
2018-07-06 20:49:43 +00:00
if ( $ ( ".ui-draggable" ) . length ) {
$ ( ".ui-draggable" ) . draggable ( "enable" ) ;
$ ( ".dragMove,.dragSize,.dragReset" ) . show ( ) ;
} else {
$ ( "div.fileList" ) . each ( function ( ) { f18 _addDragger ( this ) } ) ;
}
2018-02-11 17:02:29 +00:00
} else {
2018-07-06 20:49:43 +00:00
$ ( ".dragMove,.dragSize,.dragReset" ) . hide ( ) ;
$ ( ".ui-draggable" ) . draggable ( "disable" ) ;
2018-02-11 17:02:29 +00:00
}
} ) ;
2018-07-06 20:49:43 +00:00
addHider ( "snapToGrid" , false , "Snap to grid" , function ( c ) {
$ ( ".ui-draggable" ) . draggable ( "option" , "grid" ,
c ? [ f18 _grid , f18 _grid ] : [ 1 , 1 ] ) ;
} ) ;
2018-02-11 17:02:29 +00:00
addRow ( "editStyle" , "<a href='#'>Additional CSS</a>" ) ;
$ ( appendTo + " tr.ar_editStyle a" ) . click ( function ( ) {
$ ( 'body' ) . append (
'<div id="editdlg" style="display:none">' +
'<textarea id="f18_cssEd" rows="25" cols="60" style="width:99%"/>' +
'</div>' ) ;
$ ( "#f18_cssEd" ) . val ( $ ( "head #fhemweb_css" ) . html ( ) ) ;
$ ( '#editdlg' ) . dialog (
{ modal : true , closeOnEscape : true , width : $ ( window ) . width ( ) * 3 / 4 ,
height : $ ( window ) . height ( ) * 3 / 4 , title : $ ( this ) . text ( ) ,
close : function ( ) { $ ( '#editdlg' ) . remove ( ) ; } ,
buttons : [
{ text : "Cancel" , click : function ( ) { $ ( this ) . dialog ( 'close' ) } } ,
{ text : "OK" , click : function ( ) {
if ( ! $ ( "head #fhemweb_css" ) )
$ ( "head" ) . append ( "<style id='fhemweb_css'>\n</style>" ) ;
var txt = $ ( "#f18_cssEd" ) . val ( ) ;
$ ( "head #fhemweb_css" ) . html ( txt ) ;
var wn = $ ( "body" ) . attr ( "data-webName" ) ;
FW _cmd ( FW _root + "?cmd=attr " + wn + " Css " +
encodeURIComponent ( txt . replace ( /;/g , ";;" ) ) + "&XHR=1" ) ;
$ ( this ) . dialog ( 'close' ) ;
} } ]
} ) ;
} ) ;
$ ( "div#content > table" ) . append ( "<tr id='f18rr' class='f18'></tr>" ) ;
$ ( "tr#f18rr" ) . append ( "<div class='fileList f18colors'>" +
"f18: Room specific</div>" ) ;
$ ( "tr#f18rr" ) . append ( "<table id='f18tr' class='block wide'></table>" ) ;
appendTo = "table#f18tr" ;
2018-07-01 15:50:33 +00:00
addRow ( "room" , "Target <select><option>all</option></select>" ) ;
2018-02-17 19:52:00 +00:00
FW _cmd ( FW _root + "?cmd=jsonlist2 .* room&XHR=1" , function ( data ) {
var d ;
try { d = JSON . parse ( data ) ; } catch ( e ) { log ( data ) ; return FW _okDialog ( e ) ; }
2018-02-11 17:02:29 +00:00
for ( var i1 = 0 ; i1 < d . Results . length ; i1 ++ ) {
var rname = d . Results [ i1 ] . Attributes . room ;
if ( ! rname || rname == "hidden" )
continue ;
var rl = rname . split ( "," )
for ( var i2 = 0 ; i2 < rl . length ; i2 ++ )
roomHash [ rl [ i2 ] ] = true ;
}
cleanRoom ( ) ;
var rArr = Object . keys ( roomHash ) ; rArr . sort ( ) ;
$ ( appendTo + " tr.ar_room select" )
. html ( "<option>all</option><option>" +
rArr . join ( "</option><option>" ) +
"</option>" )
. change ( function ( e ) {
room = $ ( e . target ) . val ( ) ;
f18 _drawSpecial ( ) ;
} ) ;
$ ( "tr.ar_room select" ) . val ( room ) ;
} ) ;
addRow ( "reset" , "Preset colors: " +
"<a href='#'>default</a> " +
"<a href='#'>light</a> " +
"<a href='#'>dark</a> " +
( room == 'all' ? '' : "<a href='#'>like:all</a>" ) ) ;
$ ( appendTo + " tr.ar_reset a" ) . click ( function ( ) {
var txt = $ ( this ) . text ( ) ;
if ( txt == "like:all" ) {
delete ( roomHash [ room ] ) ;
cleanRoom ( ) ;
} else {
f18 _resetCol ( txt , room ) ;
if ( room == "all" )
f18 _setCss ( 'preset' ) ;
}
f18 _setAttr ( ) ;
f18 _drawSpecial ( ) ;
} ) ;
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 ) ;
var bgImg = attr ( "bgImg" , true ) ;
2018-07-01 15:50:33 +00:00
addRow ( "bgImg" , "<a href='#'>Background: <span>" +
2018-02-11 17:02:29 +00:00
( bgImg ? bgImg : "none" ) + "</span></a>" ) ;
$ ( appendTo + " tr.ar_bgImg a" ) . click ( function ( ) {
FW _cmd ( FW _root + '?cmd=' +
2018-02-12 18:16:55 +00:00
'{join("\\n",FW_fileList("$FW_icondir/background/.*.(jpg|png)"))}&XHR=1' ,
2018-02-11 17:02:29 +00:00
function ( data ) {
if ( data )
data += "none" ;
var imgList = data . split ( /\n/ ) ;
FW _okDialog ( "List of files in www/images/background:<br><ul>" +
"<a href='#'>" + imgList . join ( "</a><br><a href='#'>" ) + '</a></ul>' ) ;
$ ( "#FW_okDialog a" ) . click ( function ( ) {
var txt = $ ( this ) . text ( ) ;
setAttr ( "bgImg" , txt == 'none' ? undefined : txt , true ) ;
$ ( appendTo + " tr.ar_bgImg span" ) . html ( txt ) ;
f18 _setCss ( "bgImg" ) ;
} ) ;
2018-01-07 13:22:51 +00:00
} ) ;
2018-02-11 17:02:29 +00:00
2018-01-07 13:22:51 +00:00
} ) ;
2018-02-11 17:02:29 +00:00
addHider ( "hideLogo" , true , "Hide logo" , f18 _menu ) ;
addHider ( "hideInput" , true , "Hide input" , f18 _menu ) ;
2019-04-04 20:22:10 +00:00
addHider ( "hideTextInput" , true , "Hide text input" , f18 _menu ) ;
2019-08-27 08:36:02 +00:00
addHider ( "hideMenu" , true , "Hide menu" , f18 _menu ) ;
2018-02-11 17:02:29 +00:00
addHider ( "hidePin" , true , "Hide pin" , function ( c ) {
2018-07-06 20:49:43 +00:00
$ ( "div.pinHeader div.pin" ) . css ( "display" , c ? "none" : "block" ) ;
2018-02-11 17:02:29 +00:00
} ) ;
2018-09-09 13:43:37 +00:00
addHider ( "fixedInput" , false , "Fixed input and menu" , f18 _setFixedInput ) ;
2018-08-03 09:40:57 +00:00
addHider ( "wrapcolumns" , false , "Wrap columns<br>on small screen" ,
f18 _setWrapColumns ) ;
2018-02-11 17:02:29 +00:00
$ ( "div.f18colors" ) . css ( "margin-top" , "20px" ) ;
2018-07-06 20:49:43 +00:00
$ ( "tr.f18 div.fileList" ) . each ( function ( e ) { f18 _addPinToStyleDiv ( this ) } ) ;
if ( f18 _getAttr ( "showDragger" ) )
$ ( "div.fileList" ) . each ( function ( ) { f18 _addDragger ( this ) } ) ;
$ ( "[data-name]" ) . each ( function ( ) { f18 _setPos ( this ) } ) ;
2018-08-03 09:40:57 +00:00
f18 _setWrapColumns ( ) ;
2018-02-11 17:02:29 +00:00
} ;
loadScript ( "pgm2/fhemweb_colorpicker.js" , f18 _drawSpecial ) ;
2018-01-07 13:22:51 +00:00
}
2018-07-01 15:50:33 +00:00
function
f18 _setFixedInput ( )
{
2018-09-09 13:43:37 +00:00
// togleClass is true for undefined
$ ( "body" ) . toggleClass ( "fixedInput" , f18 _getAttr ( "fixedInput" ) ? true : false ) ;
2018-08-03 09:40:57 +00:00
f18 _resize ( ) ;
}
function
f18 _setWrapColumns ( )
{
$ ( "table.block" ) . toggleClass ( "wrapcolumns" , f18 _getAttr ( "wrapcolumns" ) ) ;
}
2018-02-11 17:02:29 +00:00
function
f18 _addPinToStyleDiv ( el )
{
var grp = $ ( el ) . text ( ) ;
f18 _addPin ( el , "style.list." + grp , true ,
function ( isFixed ) {
var ntr = $ ( el ) . next ( "table" ) ;
isFixed ? $ ( ntr ) . show ( ) : $ ( ntr ) . hide ( ) ;
} ) ;
}
2018-01-07 13:22:51 +00:00
function
f18 _resize ( )
{
var w = $ ( window ) . width ( ) ;
2018-08-26 12:24:57 +00:00
log ( "f18.js resize W:" + w + " S:" + screen . width ) ;
2018-02-11 17:02:29 +00:00
var hl = f18 _getAttr ( "hideLogo" ) ,
hi = f18 _getAttr ( "hideInput" ) ,
2019-08-27 08:36:02 +00:00
hm = f18 _getAttr ( "hideMenu" ) ,
pm = f18 _getAttr ( "Pinned.menu" ) || hm ,
2019-04-04 20:22:10 +00:00
rm = ( f18 _getAttr ( "rightMenu" ) && f18 _small ) ,
hti = f18 _getAttr ( "hideTextInput" ) ;
2018-01-07 13:22:51 +00:00
2018-07-15 14:08:15 +00:00
var left = 0 ;
left += hl ? 0 : 40 ;
left += pm ? 0 : 44 ;
2019-04-04 20:22:10 +00:00
left += hti ? 0 : 40 ;
var lleft = ( pm || hl ? 10 : 52 ) ;
2018-09-10 16:25:56 +00:00
$ ( "input.maininput" ) . css ( { width : ( w - left - ( FW _isiOS ? 36 : 24 ) ) + 'px' ,
2018-08-03 09:40:57 +00:00
"margin-left" : ( rm ? "0px" : "10px" ) ,
2018-07-15 14:08:15 +00:00
display : hi ? "none" : "block" } ) ;
2019-04-04 20:22:10 +00:00
$ ( "#menu,#content" ) . css ( "top" , ( hi && pm && hl && hti ) ? "10px" : "50px" ) ;
2018-07-17 20:39:42 +00:00
$ ( "#hdr" ) . css ( { left : ( rm ? 10 : left ) + 'px' } ) ;
2019-04-04 20:22:10 +00:00
$ ( "#textInput" ) . css ( { left : ( rm ? "auto" : ( left - 32 ) + "px" ) ,
right : ( rm ? ( lleft + 32 ) + "px" : "auto" ) ,
display : hti ? "none" : "block" } ) ;
2018-09-09 13:43:37 +00:00
$ ( "#menuBtn" ) . toggle ( ! pm || f18 _small ) ;
2018-07-17 20:39:42 +00:00
$ ( "#menuBtn" ) . css ( { left : ( rm ? "auto" : "10px" ) , right : ( rm ? "10px" : "auto" ) } ) ;
2018-08-03 09:40:57 +00:00
$ ( "#logo" ) . css ( { left : ( rm ? "auto" : lleft ) , right : ( rm ? "48px" : "auto" ) } ) ;
2019-08-27 08:36:02 +00:00
$ ( "#menu" ) . css ( { display : ( hm ? "none" : "block" ) } ) ;
2018-09-10 16:25:56 +00:00
if ( FW _isiOS )
$ ( "#logo,#menuBtn" ) . css ( { top : '12px' } ) ;
2018-01-07 13:22:51 +00:00
}
function
f18 _addPin ( el , name , defVal , fn , hidePin )
{
2018-02-11 17:02:29 +00:00
var init = f18 _getAttr ( "Pinned." + name ) ;
2018-01-07 13:22:51 +00:00
if ( init == undefined )
init = defVal ;
$ ( "<div class='pin'></div>" )
. appendTo ( el )
2018-01-14 21:35:42 +00:00
. css ( "background-image" , "url('" +
( init ? f18 _icon . pinIn : f18 _icon . pinOut ) + "')" ) ;
2018-02-03 22:27:04 +00:00
var f18 _name = name . replace ( /[^A-Z0-9]/ig , '_' ) ;
$ ( el )
. addClass ( "col_header pinHeader " + f18 _name )
. attr ( "data-name" , f18 _name ) ;
2018-01-07 13:22:51 +00:00
el = $ ( el ) . find ( "div.pin" ) ;
$ ( el )
. addClass ( init ? "pinIn" : "" )
. css ( "cursor" , "pointer" )
2018-02-11 17:02:29 +00:00
. css ( "display" , ( f18 _getAttr ( "hidePin" ) || hidePin ) ? "none" : "block" )
2018-01-07 13:22:51 +00:00
. click ( function ( ) {
var nextVal = ! $ ( el ) . hasClass ( "pinIn" ) ;
$ ( el ) . toggleClass ( "pinIn" ) ;
2018-01-14 21:35:42 +00:00
$ ( el ) . css ( "background-image" , "url('" +
( nextVal ? f18 _icon . pinIn : f18 _icon . pinOut ) + "')" )
2018-01-07 13:22:51 +00:00
f18 _setAttr ( "Pinned." + name , nextVal ) ;
fn ( nextVal ) ;
} ) ;
fn ( init ) ;
}
2018-07-06 20:49:43 +00:00
// el is the drag-handle, return the corresponding SVG/table etc
function
f18 _compEl ( el )
{
return $ ( el ) . hasClass ( "fileList" ) ? $ ( el ) . next ( "table" ) :
$ ( el ) . hasClass ( "SVGlabel" ) ? $ ( el ) . prev ( ".SVGplot" ) :
$ ( el ) . closest ( "tr" ) . next ( ) . find ( ">td>table" ) . first ( ) ;
}
2018-01-14 21:35:42 +00:00
function
2018-02-03 22:27:04 +00:00
f18 _addDragger ( el )
2018-01-14 21:35:42 +00:00
{
2018-07-20 09:51:50 +00:00
if ( f18 _small || FW _urlParams . detail )
2018-02-03 22:27:04 +00:00
return ;
2018-07-06 20:49:43 +00:00
if ( $ ( el ) . find ( ".dragger" ) . length )
return ;
var comp = f18 _compEl ( el ) ;
if ( $ ( comp ) . length == 0 )
return ;
f18 _convertToAbs ( ) ;
var ep = $ ( el ) . position ( ) ;
var cp = $ ( comp ) . position ( ) ;
2018-07-13 17:05:44 +00:00
var pl = parseInt ( $ ( el ) . css ( "padding-left" ) . replace ( "px" , "" ) ) ;
2018-02-03 22:27:04 +00:00
2018-07-06 20:49:43 +00:00
var grid = [ 1 , 1 ] ;
if ( f18 _getAttr ( "snapToGrid" ) )
grid = [ f18 _grid , f18 _grid ] ;
function
save ( )
{
var nep = $ ( el ) . position ( ) ;
f18 _setAttr ( "Pos." + $ ( el ) . attr ( "data-name" ) , {
left : nep . left , top : nep . top ,
width : $ ( comp ) . width ( ) , height : $ ( comp ) . height ( ) ,
oTop : cp . top - ep . top , oLeft : cp . left - ep . left
} ) ;
}
/////////////////////////////////////
// Position
2018-02-03 22:27:04 +00:00
$ ( "<div class='dragger dragMove'></div>" )
2018-01-14 21:35:42 +00:00
. appendTo ( el )
2018-02-03 22:27:04 +00:00
. css ( { "cursor" : "pointer" ,
"background-image" : "url('" + f18 _icon . arrows + "')" } )
$ ( el ) . draggable ( {
drag : function ( evt , ui ) {
2018-07-13 17:05:44 +00:00
$ ( comp ) . css ( { left : ui . position . left + cp . left - ep . left ,
2018-07-06 20:49:43 +00:00
top : ui . position . top + cp . top - ep . top } ) ;
2018-02-03 22:27:04 +00:00
} ,
2018-07-06 20:49:43 +00:00
stop : save , grid : grid
2018-02-03 22:27:04 +00:00
} ) ;
2018-07-06 20:49:43 +00:00
/////////////////////////////////////
// Size
var off = 20 ;
if ( ! $ ( el ) . hasClass ( "SVGlabel" ) ) {
$ ( "<div class='dragSize'></div>" )
. appendTo ( el )
. css ( { cursor : "pointer" , "background-image" : "url('" + f18 _icon . arrows + "')" ,
position : "absolute" , width : "16px" , height : "16px" ,
top : $ ( comp ) . height ( ) + 2 , left : $ ( comp ) . width ( ) - off , "z-index" : 1 } )
. draggable ( {
drag : function ( evt , ui ) {
2018-07-13 17:05:44 +00:00
$ ( el ) . css ( { width : ui . position . left + off } ) ;
2018-07-06 20:49:43 +00:00
$ ( comp ) . css ( { width : ui . position . left + off ,
height : ui . position . top } ) ;
} ,
stop : save , grid : grid
} ) ;
}
/////////////////////////////////////
// Reset _all_ elements on this page
2018-02-03 22:27:04 +00:00
$ ( "<div class='dragger dragReset'></div>" )
. appendTo ( el )
. css ( { "cursor" : "pointer" ,
"background-image" : "url('" + f18 _icon . ban + "')" } )
2018-07-06 20:49:43 +00:00
2018-02-03 22:27:04 +00:00
. click ( function ( ) {
2018-07-06 20:49:43 +00:00
function
delStyle ( e )
{
var style = $ ( e ) . attr ( "style" ) ;
$ ( e ) . attr ( "style" , style . replace ( /position:.*;/ , "" ) ) ; // hack
}
$ ( "[data-name]" ) . each ( function ( ) {
var el = this ;
var name = $ ( el ) . attr ( "data-name" ) ;
if ( ! f18 _getAttr ( "Pos." + name ) )
return ;
delete ( f18 _attr [ "Pos." + $ ( el ) . attr ( "data-name" ) ] ) ;
delStyle ( el ) ;
delStyle ( f18 _compEl ( el ) ) ;
$ ( el ) . draggable ( 'disable' ) ;
$ ( el ) . find ( ".dragMove,.dragSize,.dragReset" ) . hide ( ) ;
} ) ;
2018-02-03 22:27:04 +00:00
f18 _setAttr ( ) ;
} ) ;
}
2018-07-06 20:49:43 +00:00
function
f18 _applyGrid ( pos )
{
if ( ! f18 _getAttr ( "snapToGrid" ) )
return ;
pos . left = Math . floor ( ( pos . left + f18 _grid - 1 ) / f18 _grid ) * f18 _grid ;
pos . top = Math . floor ( ( pos . top + f18 _grid - 1 ) / f18 _grid ) * f18 _grid ;
pos . width = Math . floor ( ( pos . width + f18 _grid - 1 ) / f18 _grid ) * f18 _grid ;
pos . height = Math . floor ( ( pos . height + f18 _grid - 1 ) / f18 _grid ) * f18 _grid ;
}
//////////////////////////
// We use absolute positioning for all elements, if a user positioned
// an item, relative (the default one) else.
function
f18 _convertToAbs ( )
{
// Need two loops, else the sizes/positions are wrong
var sz = { } ;
$ ( "[data-name]" ) . each ( function ( ) {
var el = this ;
var name = $ ( el ) . attr ( "data-name" ) ;
if ( f18 _getAttr ( "Pos." + name ) )
return ;
var comp = f18 _compEl ( el ) ;
if ( $ ( comp ) . length == 0 )
return ;
sz [ name ] = { ep : $ ( el ) . position ( ) , cp : $ ( comp ) . position ( ) ,
w : $ ( comp ) . width ( ) , h : $ ( comp ) . height ( ) } ;
} ) ;
var needSave = false ;
$ ( "[data-name]" ) . each ( function ( ) {
var el = this ;
var name = $ ( el ) . attr ( "data-name" ) ;
if ( ! name || ! sz [ name ] )
return ;
needSave = true ;
var comp = f18 _compEl ( el ) ;
var ep = sz [ name ] . ep , cp = sz [ name ] . cp , w = sz [ name ] . w , h = sz [ name ] . h ;
var pos = {
left : ep . left , top : ep . top , width : w , height : h ,
oTop : cp . top - ep . top , oLeft : cp . left - ep . left
} ;
f18 _doSetPos ( el , comp , pos ) ;
f18 _setAttr ( "Pos." + name , pos , true ) ;
} ) ;
if ( needSave )
f18 _setAttr ( ) ;
}
2018-02-03 22:27:04 +00:00
function
f18 _setPos ( el )
{
2018-07-20 09:51:50 +00:00
if ( f18 _small || FW _urlParams . detail )
2018-02-03 22:27:04 +00:00
return ;
2018-07-06 20:49:43 +00:00
var comp = f18 _compEl ( el ) ;
if ( $ ( comp ) . length == 0 )
return ;
2018-02-03 22:27:04 +00:00
var name = $ ( el ) . attr ( "data-name" ) ;
2018-07-06 20:49:43 +00:00
var pos = f18 _getAttr ( "Pos." + name ) ;
if ( ! pos || ! pos . width )
2018-02-03 22:27:04 +00:00
return ;
2018-07-06 20:49:43 +00:00
f18 _doSetPos ( el , comp , pos ) ;
// correct position
var ds = $ ( el ) . find ( ".dragSize" ) ;
if ( $ ( ds ) . length )
$ ( ds ) . css ( { top : pos . height + 2 , left : pos . width - 20 } ) ;
2018-01-14 21:35:42 +00:00
}
2018-01-07 13:22:51 +00:00
2018-07-06 20:49:43 +00:00
function
f18 _doSetPos ( el , comp , pos )
{
f18 _applyGrid ( pos ) ;
$ ( el ) . css ( { position : "absolute" , left : pos . left , top : pos . top } ) ;
if ( ! $ ( el ) . hasClass ( "SVGlabel" ) ) {
2018-07-13 17:05:44 +00:00
var padding = parseInt ( $ ( el ) . css ( "padding-left" ) . replace ( "px" , "" ) ) ;
2018-07-06 20:49:43 +00:00
$ ( el ) . css ( { width : pos . width - padding } ) ;
}
$ ( comp ) . css ( { position : "absolute" ,
2018-07-13 17:05:44 +00:00
left : pos . left + pos . oLeft , top : pos . top + pos . oTop ,
width : pos . width , height : pos . height } ) ;
2018-07-06 20:49:43 +00:00
}
2018-02-11 17:02:29 +00:00
function
f18 _getAttr ( attrName )
{
if ( f18 _room != undefined ) {
var val = f18 _attr [ "Room." + f18 _room + "." + attrName ] ;
if ( val != undefined )
return val
}
return f18 _attr [ attrName ] ;
}
2018-01-07 13:22:51 +00:00
function
2018-07-06 20:49:43 +00:00
f18 _setAttr ( name , value , dontSave )
2018-01-07 13:22:51 +00:00
{
if ( name )
f18 _attr [ name ] = value ;
2018-02-11 17:02:29 +00:00
if ( name && value == undefined )
delete f18 _attr [ name ] ;
2018-01-14 21:35:42 +00:00
if ( name && name . indexOf ( "Pinned." ) == 0 && ! f18 _attr . savePinChanges )
return ;
2018-07-06 20:49:43 +00:00
if ( dontSave )
return ;
2018-02-11 17:02:29 +00:00
2018-01-07 13:22:51 +00:00
var wn = $ ( "body" ) . attr ( "data-webName" ) ;
FW _cmd ( FW _root + "?cmd=attr " + wn + " styleData " +
2018-02-11 17:02:29 +00:00
encodeURIComponent ( JSON . stringify ( f18 _sd , undefined , 1 ) ) + "&XHR=1" ) ;
2018-01-07 13:22:51 +00:00
}
function
2018-02-11 17:02:29 +00:00
f18 _resetCol ( name , room )
2018-01-07 13:22:51 +00:00
{
var cols = {
"default" : { bg : "FFFFE7" , fg : "000000" , link : "278727" ,
evenrow : "F8F8E0" , oddrow : "F0F0D8" , header : "E0E0C8" ,
menu : "D7FFFF" , sel : "A0FFFF" , inpBack : "FFFFFF" } ,
light : { bg : "F8F8F8" , fg : "465666" , link : "4C9ED9" ,
evenrow : "E8E8E8" , oddrow : "F0F0F0" , header : "DDDDDD" ,
menu : "EEEEEE" , sel : "CAC8CF" , inpBack : "FFFFFF" } ,
dark : { bg : "444444" , fg : "CCCCCC" , link : "FF9900" ,
evenrow : "333333" , oddrow : "111111" , header : "222222" ,
menu : "111111" , sel : "333333" , inpBack : "444444" }
} ;
2018-02-11 17:02:29 +00:00
var col = ( name ? cols [ name ] : cols [ "default" ] ) ;
var prefix = ( room && room != 'all' ? "Room." + room + ".cols." : "cols." ) ;
for ( var c in col )
f18 _attr [ prefix + c ] = col [ c ] ;
2018-01-07 13:22:51 +00:00
}
2018-01-14 21:35:42 +00:00
// Put all the colors into a head style tag, send background changes to FHEM
2018-01-07 13:22:51 +00:00
function
2018-01-14 21:35:42 +00:00
f18 _setCss ( why )
2018-01-07 13:22:51 +00:00
{
var style = "" ;
2018-02-11 17:02:29 +00:00
function col ( n ) { return f18 _getAttr ( "cols." + n , true ) } ;
2018-01-07 13:22:51 +00:00
function bg ( c ) { return "{ background:#" + c + "; fill:#" + c + "; }\n" }
function fg ( c ) { return "{ color:#" + c + "; }\n" }
2018-02-11 17:02:29 +00:00
style += ".col_fg, body, input, textarea " + fg ( col ( "fg" ) ) ;
2018-07-01 15:50:33 +00:00
style += ".col_bg, textarea, input, option " + bg ( col ( "bg" ) ) ;
2018-02-12 18:16:55 +00:00
style += ".col_link,a:not(.changed),.handle,.fhemlog,input[type=submit]," +
"select,div.ui-widget-content a " +
2018-02-11 17:02:29 +00:00
"{color:#" + col ( "link" ) + "!important; stroke:#" + col ( "link" ) + ";}\n" ;
style += "svg:not([fill]):not(.jssvg) { fill:#" + col ( "link" ) + "; }\n" ;
style += ".col_evenrow, table.block,div.block " + bg ( col ( "evenrow" ) ) ;
style += ".col_oddrow,table.block tr.odd,table.block tr.sel " +
bg ( col ( "oddrow" ) ) ;
style += ".col_header " + bg ( col ( "header" ) ) ;
style += ".col_menu, table.room " + bg ( col ( "menu" ) ) ;
style += ".col_sel, table.room tr.sel " + bg ( col ( "sel" ) ) ;
style += ".col_inpBack, input " + bg ( col ( "inpBack" ) ) ;
if ( col ( "bg" ) == "FFFFE7" ) // default
style += "div.pinHeader.menu {background:#" + col ( "sel" ) + ";}\n" ;
style += "div.ui-dialog-titlebar " + bg ( col ( "header" ) ) ;
style += "div.ui-widget-content " + bg ( col ( "bg" ) ) ;
style += "div.ui-widget-content, .ui-button-text " + fg ( col ( "fg" ) + "!important" ) ;
style += "div.ui-dialog { border:1px solid #" + col ( "link" ) + "; }" ;
style += "button.ui-button { background:#" + col ( "oddrow" ) + "!important; " +
"border:1px solid #" + col ( "link" ) + "!important; }\n" ;
2018-01-14 21:35:42 +00:00
2018-01-22 19:11:20 +00:00
if ( typeof DashboardDraggable != "undefined" ) {
var db = "#dashboard " ;
2018-02-11 17:02:29 +00:00
style += db + ".dashboard_widgetheader " + bg ( col ( "header" ) ) ;
style += db + ".dashboard_tabnav " + bg ( col ( "menu" ) + "!important" ) ;
style += db + ".ui-widget-header .ui-state-default " + bg ( col ( "menu" ) ) ;
style += db + ".ui-widget-header .ui-state-active " + bg ( col ( "sel" ) ) ;
style += db + ".ui-widget-header " + fg ( col ( "fg" ) + "!important;" ) ;
2018-01-22 19:11:20 +00:00
style += db + ".ui-widget-header li { border:none!important; }" ;
2018-02-11 17:02:29 +00:00
style += db + ".ui-widget-content a " + fg ( col ( "link" ) + "!important" ) ;
2018-01-22 19:11:20 +00:00
}
2018-02-11 17:02:29 +00:00
var bgImg = f18 _getAttr ( "bgImg" , true ) ;
if ( bgImg ) {
style += 'body { background-image: url(' + FW _root +
'/images/background/' + bgImg + ');}' ;
} else {
style += "body " + bg ( col ( "bg" ) ) ;
2018-01-14 21:35:42 +00:00
}
2018-01-07 13:22:51 +00:00
2018-02-11 17:02:29 +00:00
$ ( "head style#f18_css" ) . remove ( ) ;
2018-01-14 21:35:42 +00:00
style = "<style id='f18_css'>" + style + "</style>" ;
if ( $ ( "head style#fhemweb_css" ) . length )
$ ( "head style#fhemweb_css" ) . before ( style ) ;
else
$ ( "head" ) . append ( style ) ;
2018-02-03 18:01:01 +00:00
$ ( "head meta[name=theme-color]" ) . remove ( ) ;
2018-02-11 17:02:29 +00:00
$ ( "head" ) . append ( '<meta name="theme-color" content="#' + col ( "bg" ) + '">' ) ;
// Recolor the menu arrows. CSS does not apply to such SVGs :(
if ( why == 'init' || why == 'preset' || why == 'link' ) {
var a = $ ( "a" ) . get ( 0 ) ;
if ( window . getComputedStyle && a ) {
var col = getComputedStyle ( a , null ) . getPropertyValue ( 'color' ) ;
FW _arrowRight = FW _arrowRight . replace ( /rgb[^)]*\)/ , col ) ;
FW _arrowDown = FW _arrowDown . replace ( /rgb[^)]*\)/ , col ) ;
$ ( "div#menu table.room tr.menuTree > td > div > div" )
. css ( "background-image" , "url('" + FW _arrowRight + "')" ) ;
$ ( "div#menu table.room tr.menuTree.open > td > div > div" )
. css ( "background-image" , "url('" + FW _arrowDown + "')" ) ;
}
}
2018-01-07 13:22:51 +00:00
}
2018-01-14 21:35:42 +00:00
// SVG color tuning
2018-01-07 13:22:51 +00:00
function
2018-01-14 21:35:42 +00:00
f18 _svgSetCols ( svg )
2018-01-07 13:22:51 +00:00
{
2018-02-11 17:02:29 +00:00
function col ( n ) { return f18 _getAttr ( "cols." + n , true ) } ;
2019-12-23 20:12:15 +00:00
if ( ! svg || ! $ ( svg ) . attr ( "data-origin" ) )
2018-01-14 21:35:42 +00:00
return ;
var style = $ ( svg ) . find ( "> style" ) . first ( ) ;
var sTxt = $ ( style ) . text ( ) ;
2019-04-29 21:30:58 +00:00
sTxt = sTxt . replace ( /Times/ , "Arial; fill:#" + col ( "fg" ) ) ;
2018-01-14 21:35:42 +00:00
$ ( style ) . text ( sTxt ) ;
function
addCol ( c , d )
{
var r = "" ;
for ( var i1 = 0 ; i1 < 6 ; i1 += 2 ) {
var n = parseInt ( c . substr ( i1 , 2 ) , 16 ) ;
n += d ;
if ( n > 255 ) n = 255 ;
if ( n < 0 ) n = 0 ;
n = n . toString ( 16 ) ;
if ( n . length < 2 )
2018-02-03 18:01:01 +00:00
n = "0" + n ;
2018-01-14 21:35:42 +00:00
r += n ;
}
return r ;
}
2018-02-03 18:01:01 +00:00
// SVG background gradient: .css does not work in Firefox, has to use .attr
2018-01-14 21:35:42 +00:00
var stA = $ ( svg ) . find ( "> defs > #gr_bg" ) . children ( ) ;
2018-02-03 18:01:01 +00:00
var so = "; stop-opacity:1;" ;
2018-02-11 17:02:29 +00:00
$ ( stA [ 0 ] ) . attr ( "style" , "stop-color:#" + addCol ( col ( "bg" ) , 10 ) + so ) ;
$ ( stA [ 1 ] ) . attr ( "style" , "stop-color:#" + addCol ( col ( "bg" ) , - 10 ) + so ) ;
2018-01-07 13:22:51 +00:00
}
2018-01-14 21:35:42 +00:00
2018-10-07 16:45:18 +00:00
function
f18 _loadIcons ( )
{
2019-04-04 20:22:10 +00:00
// font-awesome: txInp:plus-square
2018-10-07 16:45:18 +00:00
var f18 _svgPrefix = 'data:image/svg+xml;utf8,<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path fill="gray" ' ;
2019-04-04 20:22:10 +00:00
f18 _icon . pinIn = f18 _svgPrefix + 'd="M896 1088q66 0 128-15v655q0 26-19 45t-45 19h-128q-26 0-45-19t-19-45v-655q62 15 128 15zm0-1088q212 0 362 150t150 362-150 362-362 150-362-150-150-362 150-362 362-150zm0 224q14 0 23-9t9-23-9-23-23-9q-146 0-249 103t-103 249q0 14 9 23t23 9 23-9 9-23q0-119 84.5-203.5t203.5-84.5z"/></svg>' ;
f18 _icon . bars = f18 _svgPrefix + 'd="M1664 1344v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm0-512v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm0-512v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45z"/></svg>' ;
f18 _icon . arrows = f18 _svgPrefix + 'd="M1792 896q0 26-19 45l-256 256q-19 19-45 19t-45-19-19-45v-128h-384v384h128q26 0 45 19t19 45-19 45l-256 256q-19 19-45 19t-45-19l-256-256q-19-19-19-45t19-45 45-19h128v-384h-384v128q0 26-19 45t-45 19-45-19l-256-256q-19-19-19-45t19-45l256-256q19-19 45-19t45 19 19 45v128h384v-384h-128q-26 0-45-19t-19-45 19-45l256-256q19-19 45-19t45 19l256 256q19 19 19 45t-19 45-45 19h-128v384h384v-128q0-26 19-45t45-19 45 19l256 256q19 19 19 45z"/></svg>' ;
f18 _icon . ban = f18 _svgPrefix + 'd="M1440 893q0-161-87-295l-754 753q137 89 297 89 111 0 211.5-43.5t173.5-116.5 116-174.5 43-212.5zm-999 299l755-754q-135-91-300-91-148 0-273 73t-198 199-73 274q0 162 89 299zm1223-299q0 157-61 300t-163.5 246-245 164-298.5 61-298.5-61-245-164-163.5-246-61-300 61-299.5 163.5-245.5 245-164 298.5-61 298.5 61 245 164 163.5 245.5 61 299.5z"/></svg>' ;
f18 _icon . txInp = f18 _svgPrefix + 'd="M 1302,839 V 939 c 0,19 -15,37 -36,37 H 993 v 277 c 0,19 -15,37 -36,37 H 856 c -20,0 -36,-15 -36,-37 V 977 H 546 c -20,0 -36,-15 -36,-37 V 839 c 0,-19 15,-37 36,-37 H 818 V 521 c 0,-19 15,-37 36,-37 h 97 c 20,0 36,15 36,37 V 798 H 1261 c 20,0 36,15 36,37 z M 1600,331 V 1447 c 0,83 -65,151 -148,151 H 360 C 277,1600 212,1532 212,1448 V 331 C 212,246 277,180 360,180 H 1450 c 81,0 147,66 147,151 z M 1450,1428 V 350 c 0,-8 -7,-17 -17,-17 H 379 c -9,0 -17,7 -17,17 V 1428 c 0,8 7,17 17,17 H 1431 c 9,0 17,-7 17,-17 z"/></svg>' ;
2018-10-07 16:45:18 +00:00
}
2018-02-03 22:27:04 +00:00
2019-04-04 20:22:10 +00:00
function
f18 _textInput ( )
{
var n = "FW_mainTextInput" ;
var aCM = typeof AddCodeMirror == 'function' ;
$ ( "body" ) . append (
2019-04-05 15:53:26 +00:00
'<div id="' + n + '">' +
'<textarea rows="20" cols="60" style="width:99%;' + ( aCM ? 'opacity:0;' : '' ) + '"/>' +
'</div>' ) ;
2019-04-04 20:22:10 +00:00
var ta = $ ( "#" + n + " textarea" ) ;
if ( aCM )
2019-04-06 10:15:42 +00:00
AddCodeMirror ( ta , function ( cm ) {
2019-04-05 15:53:26 +00:00
cm . on ( "change" , function ( ) { ta . val ( cm . getValue ( ) ) } ) ;
} ) ;
2019-04-04 20:22:10 +00:00
$ ( "#" + n ) . dialog ( {
dialogClass : "no-close" , modal : true , width : "auto" , closeOnEscape : true ,
maxWidth : $ ( window ) . width ( ) * 0.9 , maxHeight : $ ( window ) . height ( ) * 0.9 ,
buttons : [
{ text : "Execute" , click : function ( ) { FW _execRawDef ( ta . val ( ) ) } } ,
{ text : "Close" , click : function ( ) { $ ( this ) . remove ( ) ; } } ,
] ,
close : function ( ) { $ ( "#" + n ) . remove ( ) ; }
} ) ;
}
2018-02-03 22:27:04 +00:00
2018-10-07 16:45:18 +00:00
function
f18 _loadTouch ( )
{
2018-02-03 22:27:04 +00:00
/ * !
* jQuery UI Touch Punch 0.2 . 3
*
* Copyright 2011 - 2014 , Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses .
*
* Depends :
* jquery . ui . widget . js
* jquery . ui . mouse . js
* /
! function ( a ) { function f ( a , b ) { if ( ! ( a . originalEvent . touches . length > 1 ) ) { a . preventDefault ( ) ; var c = a . originalEvent . changedTouches [ 0 ] , d = document . createEvent ( "MouseEvents" ) ; d . initMouseEvent ( b , ! 0 , ! 0 , window , 1 , c . screenX , c . screenY , c . clientX , c . clientY , ! 1 , ! 1 , ! 1 , ! 1 , 0 , null ) , a . target . dispatchEvent ( d ) } } if ( a . support . touch = "ontouchend" in document , a . support . touch ) { var e , b = a . ui . mouse . prototype , c = b . _mouseInit , d = b . _mouseDestroy ; b . _touchStart = function ( a ) { var b = this ; ! e && b . _mouseCapture ( a . originalEvent . changedTouches [ 0 ] ) && ( e = ! 0 , b . _touchMoved = ! 1 , f ( a , "mouseover" ) , f ( a , "mousemove" ) , f ( a , "mousedown" ) ) } , b . _touchMove = function ( a ) { e && ( this . _touchMoved = ! 0 , f ( a , "mousemove" ) ) } , b . _touchEnd = function ( a ) { e && ( f ( a , "mouseup" ) , f ( a , "mouseout" ) , this . _touchMoved || f ( a , "click" ) , e = ! 1 ) } , b . _mouseInit = function ( ) { var b = this ; b . element . bind ( { touchstart : a . proxy ( b , "_touchStart" ) , touchmove : a . proxy ( b , "_touchMove" ) , touchend : a . proxy ( b , "_touchEnd" ) } ) , c . call ( b ) } , b . _mouseDestroy = function ( ) { var b = this ; b . element . unbind ( { touchstart : a . proxy ( b , "_touchStart" ) , touchmove : a . proxy ( b , "_touchMove" ) , touchend : a . proxy ( b , "_touchEnd" ) } ) , d . call ( b ) } } } ( jQuery ) ;
2018-10-07 16:45:18 +00:00
}