mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
fhemweb_colorpicker.js: use loadScript to load jscolor
Color.pm: don't use FHEM_colorpickerInit/$data{FWEXT}{colorpicker}{SCRIPT} git-svn-id: https://svn.fhem.de/fhem/trunk@7516 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fa12df2a36
commit
02273ef79f
@ -11,13 +11,13 @@ use vars qw($FW_ME);
|
|||||||
sub
|
sub
|
||||||
Color_Initialize()
|
Color_Initialize()
|
||||||
{
|
{
|
||||||
FHEM_colorpickerInit();
|
#FHEM_colorpickerInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
FHEM_colorpickerInit()
|
FHEM_colorpickerInit()
|
||||||
{
|
{
|
||||||
$data{FWEXT}{colorpicker}{SCRIPT} = "/jscolor/jscolor.js";
|
#$data{FWEXT}{colorpicker}{SCRIPT} = "/jscolor/jscolor.js";
|
||||||
}
|
}
|
||||||
|
|
||||||
my %dim_values = (
|
my %dim_values = (
|
||||||
|
@ -59,25 +59,26 @@ FW_colorpickerCreate(elName, devName, vArr, currVal, set, params, cmd)
|
|||||||
|
|
||||||
var inp = $(newEl).find("[type=text]");
|
var inp = $(newEl).find("[type=text]");
|
||||||
|
|
||||||
var myPicker = new jscolor.color(inp.get(0),
|
loadScript("jscolor/jscolor.js",
|
||||||
|
function() {
|
||||||
|
var myPicker = new jscolor.color(inp.get(0),
|
||||||
{pickerMode:'RGB',pickerFaceColor:'transparent',pickerFace:3,pickerBorder:0,pickerInsetColor:'red'});
|
{pickerMode:'RGB',pickerFaceColor:'transparent',pickerFace:3,pickerBorder:0,pickerInsetColor:'red'});
|
||||||
inp.get(0).color = myPicker;
|
inp.get(0).color = myPicker;
|
||||||
|
|
||||||
if( currVal ) {
|
if( elName )
|
||||||
if( currVal.length > 6 ) currVal = currVal.slice(0,6);
|
$(inp).attr("name", elName);
|
||||||
myPicker.fromString(currVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( elName )
|
if( cmd )
|
||||||
$(inp).attr("name", elName);
|
$(newEl).change(function(arg) { cmd( myPicker.toString() ) });
|
||||||
|
else
|
||||||
|
$(newEl).change(function(arg) { $(inp).attr("value", myPicker.toString() ) });
|
||||||
|
|
||||||
if( cmd )
|
newEl.setValueFn = function(arg){ if( arg.length > 6 ) arg = arg.slice(0,6);
|
||||||
$(newEl).change(function(arg) { cmd( myPicker.toString() ) });
|
myPicker.fromString(arg); };
|
||||||
else
|
|
||||||
$(newEl).change(function(arg) { $(inp).attr("value", myPicker.toString() ) });
|
|
||||||
|
|
||||||
newEl.setValueFn = function(arg){ if( arg.length > 6 ) arg = arg.slice(0,6);
|
if( currVal )
|
||||||
myPicker.fromString(arg); };
|
newEl.setValueFn(currVal);
|
||||||
|
});
|
||||||
|
|
||||||
return newEl;
|
return newEl;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user