]> err.no Git - scalable-opengroupware.org/blob - UI/WebServerResources/HTMLInputElement.js
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1009 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / WebServerResources / HTMLInputElement.js
1 HTMLInputElement.prototype._replicate = function() {
2   if (this.replica) {
3     this.replica.value = this.value;
4     var onReplicaChangeEvent = document.createEvent("Event");
5     onReplicaChangeEvent.initEvent("change", true, true);
6     this.replica.dispatchEvent(onReplicaChangeEvent);
7   }
8 }
9
10 HTMLInputElement.prototype.assignReplica = function(otherInput) {
11   if (!this._onChangeBound) {
12     this.addEventListener("change", this._replicate, false);
13     this._onChangeBound = true;
14   }
15   this.replica = otherInput;
16 }
17
18 HTMLInputElement.prototype.valueAsDate = function () {
19   return this.value.asDate();
20 }
21
22 HTMLInputElement.prototype.setValueAsDate = function(dateValue) {
23   if (!this.dateSeparator)
24     this._detectDateSeparator();
25   this.value = dateValue.stringWithSeparator(this.dateSeparator);
26 }
27
28 HTMLInputElement.prototype.updateShadowValue = function () {
29   this.setAttribute("shadow-value", this.value);
30 }
31
32 HTMLInputElement.prototype._detectDateSeparator = function() {
33   var date = this.value.split("/");
34   if (date.length == 3)
35     this.dateSeparator = "/";
36   else
37     this.dateSeparator = "-";
38 }
39
40 HTMLInputElement.prototype.valueAsShortDateString = function() {
41   var dateStr = '';
42
43   if (!this.dateSeparator)
44     this._detectDateSeparator();
45
46   var date = this.value.split(this.dateSeparator);
47   if (this.dateSeparator == '/')
48     dateStr += date[2] + date[1] + date[0];
49   else
50     dateStr += date[0] + date[1] + date[2];
51
52   return dateStr;
53 }
54
55 /* "select" is part of the inputs so it's included here */
56 HTMLSelectElement.prototype._replicate = function() {
57   if (this.replica) {
58     this.replica.value = this.value;
59     var onReplicaChangeEvent = document.createEvent("Event");
60     onReplicaChangeEvent.initEvent("change", true, true);
61     this.replica.dispatchEvent(onReplicaChangeEvent);
62   }
63 }
64
65 HTMLSelectElement.prototype.assignReplica = function(otherSelect) {
66   if (!this._onChangeBound) {
67     this.addEventListener("change", this._replicate, false);
68     this._onChangeBound = true;
69   }
70   this.replica = otherSelect;
71 }
72
73 HTMLSelectElement.prototype.updateShadowValue = function () {
74   this.setAttribute("shadow-value", this.value);
75 }