File: bindings.js

package info (click to toggle)
virtuoso-opensource 6.1.4%2Bdfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 245,116 kB
  • sloc: ansic: 639,631; sql: 439,225; xml: 287,085; java: 61,048; sh: 38,723; cpp: 36,889; cs: 25,240; php: 12,562; yacc: 9,036; lex: 7,149; makefile: 6,093; jsp: 4,447; awk: 1,643; perl: 1,017; ruby: 1,003; python: 329
file content (56 lines) | stat: -rw-r--r-- 1,511 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 *  $Id: bindings.js,v 1.6.2.4 2010/04/06 16:46:11 source Exp $
 *
 *  This file is part of the OpenLink Software Ajax Toolkit (OAT) project.
 *
 *  Copyright (C) 2005-2010 OpenLink Software
 *
 *  See LICENSE file for details.
 */
/*
	OAT.Bindings.bindString(input,object,property)
	OAT.Bindings.bindBool(input,object,property)
	OAT.Bindings.bindSelect(input,object,property)
	OAT.Bindings.bindCombo(input,object,property)
	OAT.Bindings.bindColor(input,object,property)
*/

OAT.Bindings = {
	bindString:function(input,object,property) {
		var callback = function(event) {
			object[property] = $v(input);
		}
		OAT.Event.attach(input,"keyup",callback);
	},

	bindBool:function(input,object,property) {
		var callback = function(event) {
			object[property] = (input.checked ? "1" : "0");
		}
		OAT.Event.attach(input,"change",callback);
	},

	bindSelect:function(input,object,property) {
		var callback = function(event) {
			object[property] = $v(input);
		}
		OAT.Event.attach(input,"change",callback);
	},

	bindCombo:function(input,object,property) {
		var callback = function(event) {
			object[property] = $v(input);
		}
		input.onchange = callback;
	},

	bindColor:function(input,object,property) {
		var c = new OAT.Color();
		var callback = function(event) {
			var colorRef = function(color) { object[property] = color; input.style.backgroundColor = color;}
			var coords = OAT.Dom.position(input);
			c.pick(coords[0]-150,coords[1],colorRef);
		}
		OAT.Event.attach(input,"click",callback);
	}
}