summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/base/prado.js
blob: 3eded9279d0ed8de71215cc4169ea16a3581dc40 (plain)
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
57
58
59
60
61
62
63
64
65
Prado = Class.create();

Prado.version = '3.0a';

Prado.Button = Class.create();

Prado.Button.buttonFired = false;
Prado.Button.fireButton = function(event, target)
{
	if (!Prado.Button.buttonFired && event.keyCode == 13 && !(event.srcElement && (event.srcElement.tagName.toLowerCase() == "textarea")))
	{
		var defaultButton = document.getElementById ? document.getElementById(target) : document.all[target];
		if (defaultButton && typeof(defaultButton.click) != "undefined")
		{
			Prado.Button.buttonFired = true;
			defaultButton.click();
			event.cancelBubble = true;
			if (event.stopPropagation)
				event.stopPropagation();
			return false;
		}
	}
	return true;
}

Prado.TextBox = Class.create();

/**
 * Returns FALSE when the "Enter" key is pressed AND when onchange
 * property is defined. The onchange function is called. However, 
 * it does not call event listener functions.
 * @return boolean false if "Enter" and onchange property is defined, true otherwise.
 */
Prado.TextBox.handleReturnKey = function(ev)
{
	var kc = ev.keyCode != null ? ev.keyCode : ev.charCode;
	if(kc == Event.KEY_RETURN)
	{
		var target = Event.element(ev);
		if(target && isFunction(target.onchange))
		{
			target.onchange();
			Event.stop(ev);
			return false;
		}
	}
	return true;
}

/**
 * Creates a LinkButton and register the post back to the onclick event.
 */
/* to finish when doPostback changes
Prado.LinkButton = Class.create();
Prado.LinkButton.prototype =
{
	initialize : function(element, name)
	{
		Event.observe(element, 'click', function(e)
		{
			Prado.doPostback(element, name, '');
			Event.stop(e);
		});
	}
}*/