|
From: <ma...@us...> - 2011-04-27 16:15:22
|
Revision: 318
http://openautomation.svn.sourceforge.net/openautomation/?rev=318&view=rev
Author: mayerch
Date: 2011-04-27 16:15:16 +0000 (Wed, 27 Apr 2011)
Log Message:
-----------
Created optional parameters for the switch to set the values for on and off
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-03-08 21:29:06 UTC (rev 317)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-04-27 16:15:16 UTC (rev 318)
@@ -296,6 +296,8 @@
'address' : address,
'mapping' : $p.attr('mapping'),
'styling' : $p.attr('styling'),
+ 'on_value' : $p.attr('on_value' ) || 1,
+ 'off_value' : $p.attr('off_value') || 0,
'type' : 'switch'
} ).bind( 'click', this.action );
for( var addr in address ) $actor.bind( addr, this.update );
@@ -305,18 +307,21 @@
update: function(e,d) {
var element = $(this);
var value = defaultUpdate( e, d, element );
- element.removeClass( value == 0 ? 'switchPressed' : 'switchUnpressed' );
- element.addClass( value == 0 ? 'switchUnpressed' : 'switchPressed' );
+ var off = element.data( 'off_value' );
+ element.removeClass( value == off ? 'switchPressed' : 'switchUnpressed' );
+ element.addClass( value == off ? 'switchUnpressed' : 'switchPressed' );
},
action: function() {
var data = $(this).data();
for( var addr in data.address )
{
if( data.address[addr][1] == true ) continue; // skip read only
- visu.write( addr.substr(1), transformEncode( data.address[addr][0], data.value == 0 ) );
+ visu.write( addr.substr(1), transformEncode( data.address[addr][0], data.value == data.off_value ? data.on_value : data.off_value ) );
}
},
attributes: {
+ on_value: { type: 'string' , required: false },
+ off_value: { type: 'string' , required: false },
pre: { type: 'string' , required: false },
post: { type: 'string' , required: false },
mapping: { type: 'mapping' , required: false },
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|