forked from EliasW/Calendar_DatePicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calendar_DatePicker.js
94 lines (81 loc) · 2.45 KB
/
Calendar_DatePicker.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
define( ["qlik", "jquery", "css!./style.css"],
function (qlik) {
return {
initialProperties : {
version : 1.0,
variableValue1 : "From (DD/MM/YYYY) ",
variableFrom : "",
variableValue2 : "To (DD/MM/YYYY) ",
variableTo : "",
},
definition : {
type : "items",
component : "accordion",
items : {
settings : {
uses : "settings",
items : {
variable : {
type : "items",
label : "Variable",
items : {
Variable1 : {
ref : "variableFrom",
label : "VariableFrom",
type : "string",
change : function(data) {
qlik.currApp().variable.create(data.variableFrom);
data.variableValue1.qStringExpression = '=' + data.variableFrom;
}
},
Variable2 : {
ref : "variableTo",
label : "VariableTo",
type : "string",
change : function(data) {
qlik.currApp().variable.create(data.variableTo);
data.variableValue2.qStringExpression = '=' + data.variableTo;
}
}
}
}
}
}
}
},
paint : function($element, layout) {
var html = "", t = this;
var availabeButton = document
html += '<input type="button" class="CalendarButton datepick" id="datepicker1" value="' + layout.variableValue1 + '" >';
html += '<input type="button" class="CalendarButton datepick" id="datepicker2" value="' + layout.variableValue2 + '" >';
$element.html(html);
$element.find('select, input').on('change', function(event) {
event.preventDefault();
var valFrom = document.getElementById('datepicker1').value;
qlik.currApp(t).variable.setContent(layout.variableFrom, valFrom);
layout.variableValue1 = valFrom;
})
$element.find('select, input').on('change', function(event) {
event.preventDefault();
var valTo = document.getElementById('datepicker2').value;
var valFrom = document.getElementById('datepicker1').value;
// if(valTo >= valFrom){
qlik.currApp(t).variable.setContent(layout.variableTo, valTo);
layout.variableValue2 = valTo;
/* }
else
{
var errTo = "dateError"
qlik.currApp(t).variable.setContent(layout.variableTo, errTo);
document.getElementById('datepicker2').value = errTo;
}
*/
})
$('.datepick').each(function(){
$(this).datepicker({
dateFormat: "dd/mm/yy"
});
});
}
};
});