webshims-rails 1.10.3 → 1.10.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/webshims-rails/version.rb +2 -2
- data/vendor/assets/javascripts/webshims/polyfiller.js +96 -73
- data/vendor/assets/javascripts/webshims/shims/color-picker.js +2415 -0
- data/vendor/assets/javascripts/webshims/shims/combos/1.js +248 -745
- data/vendor/assets/javascripts/webshims/shims/combos/10.js +771 -1206
- data/vendor/assets/javascripts/webshims/shims/combos/11.js +679 -1201
- data/vendor/assets/javascripts/webshims/shims/combos/12.js +46 -65
- data/vendor/assets/javascripts/webshims/shims/combos/13.js +45 -64
- data/vendor/assets/javascripts/webshims/shims/combos/14.js +94 -7
- data/vendor/assets/javascripts/webshims/shims/combos/15.js +557 -1189
- data/vendor/assets/javascripts/webshims/shims/combos/16.js +598 -1249
- data/vendor/assets/javascripts/webshims/shims/combos/17.js +697 -1208
- data/vendor/assets/javascripts/webshims/shims/combos/18.js +697 -1208
- data/vendor/assets/javascripts/webshims/shims/combos/19.js +145 -78
- data/vendor/assets/javascripts/webshims/shims/combos/2.js +472 -1280
- data/vendor/assets/javascripts/webshims/shims/combos/20.js +144 -77
- data/vendor/assets/javascripts/webshims/shims/combos/21.js +14 -15
- data/vendor/assets/javascripts/webshims/shims/combos/22.js +2 -2
- data/vendor/assets/javascripts/webshims/shims/combos/23.js +45 -64
- data/vendor/assets/javascripts/webshims/shims/combos/24.js +848 -0
- data/vendor/assets/javascripts/webshims/shims/combos/25.js +4373 -0
- data/vendor/assets/javascripts/webshims/shims/combos/26.js +1516 -0
- data/vendor/assets/javascripts/webshims/shims/combos/27.js +884 -0
- data/vendor/assets/javascripts/webshims/shims/combos/28.js +2067 -0
- data/vendor/assets/javascripts/webshims/shims/combos/29.js +1156 -0
- data/vendor/assets/javascripts/webshims/shims/combos/3.js +313 -700
- data/vendor/assets/javascripts/webshims/shims/combos/30.js +1868 -0
- data/vendor/assets/javascripts/webshims/shims/combos/31.js +1663 -0
- data/vendor/assets/javascripts/webshims/shims/combos/4.js +111 -20
- data/vendor/assets/javascripts/webshims/shims/combos/5.js +747 -1321
- data/vendor/assets/javascripts/webshims/shims/combos/6.js +837 -1809
- data/vendor/assets/javascripts/webshims/shims/combos/7.js +435 -1239
- data/vendor/assets/javascripts/webshims/shims/combos/8.js +360 -766
- data/vendor/assets/javascripts/webshims/shims/combos/9.js +843 -1676
- data/vendor/assets/javascripts/webshims/shims/details.js +1 -1
- data/vendor/assets/javascripts/webshims/shims/dom-extend.js +90 -3
- data/vendor/assets/javascripts/webshims/shims/filereader.js +386 -0
- data/vendor/assets/javascripts/webshims/shims/form-core.js +201 -680
- data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +418 -0
- data/vendor/assets/javascripts/webshims/shims/form-datalist.js +69 -467
- data/vendor/assets/javascripts/webshims/shims/form-message.js +21 -17
- data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +19 -82
- data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +17 -6
- data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +570 -1185
- data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +181 -28
- data/vendor/assets/javascripts/webshims/shims/form-validation.js +599 -0
- data/vendor/assets/javascripts/webshims/{extras/custom-validity.js → shims/form-validators.js} +33 -38
- data/vendor/assets/javascripts/webshims/shims/forms-picker.js +865 -0
- data/vendor/assets/javascripts/webshims/shims/geolocation.js +2 -2
- data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-de.txt +37 -34
- data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-en.txt +88 -48
- data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-lt.js +74 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/ChangeLog.txt +121 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/ReadMe.txt +47 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/AlphaBar.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/Bars.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/Maps.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/NoColor.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/Thumbs.db +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/bar-opacity.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/map-opacity.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/mappoint.gif +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/picker.gif +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/preview-opacity.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/rangearrows.gif +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/jpicker.css +257 -0
- data/vendor/assets/javascripts/webshims/shims/json-storage.js +4 -4
- data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +44 -63
- data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +10 -11
- data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +5 -3
- data/vendor/assets/javascripts/webshims/shims/range-ui.js +110 -17
- data/vendor/assets/javascripts/webshims/shims/styles/forms.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/styles/range-track.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +104 -21
- data/vendor/assets/javascripts/webshims/shims/styles/shim.css +90 -16
- data/vendor/assets/javascripts/webshims/shims/styles/vertical-range.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/swf/filereader.swf +0 -0
- data/vendor/assets/javascripts/webshims/shims/swfmini.js +1 -1
- data/vendor/assets/javascripts/webshims/shims/track-ui.js +35 -3
- data/vendor/assets/javascripts/webshims/shims/track.js +1 -1
- metadata +33 -3
data/vendor/assets/javascripts/webshims/{extras/custom-validity.js → shims/form-validators.js}
RENAMED
@@ -1,14 +1,11 @@
|
|
1
|
-
(function($, window, document, undefined){
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
};
|
10
|
-
}
|
11
|
-
var webshims = $.webshims;
|
1
|
+
webshims.register('form-validators', function($, webshims, window, document, undefined, options){
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
(function(){
|
5
|
+
if(webshims.refreshCustomValidityRules){
|
6
|
+
webshims.error("form-validators already included. please remove custom-validity.js");
|
7
|
+
}
|
8
|
+
|
12
9
|
var customValidityRules = {};
|
13
10
|
var formReady = false;
|
14
11
|
var blockCustom;
|
@@ -64,16 +61,10 @@
|
|
64
61
|
};
|
65
62
|
var testValidityRules = webshims.refreshCustomValidityRules;
|
66
63
|
|
67
|
-
webshims.ready('forms', function(){
|
68
|
-
|
64
|
+
webshims.ready('forms form-validation', function(){
|
65
|
+
|
69
66
|
|
70
|
-
var oldCustomValidity = $.fn.setCustomValidity
|
71
|
-
return this.each(function(){
|
72
|
-
if(this.setCustomValidity){
|
73
|
-
this.setCustomValidity(message);
|
74
|
-
}
|
75
|
-
});
|
76
|
-
};
|
67
|
+
var oldCustomValidity = $.fn.setCustomValidity;
|
77
68
|
|
78
69
|
|
79
70
|
$.fn.setCustomValidity = function(message){
|
@@ -83,21 +74,21 @@
|
|
83
74
|
return oldCustomValidity.apply(this, arguments);
|
84
75
|
};
|
85
76
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
77
|
+
setTimeout(function(){
|
78
|
+
webshims.addReady(function(context, selfElement){
|
79
|
+
initTest = true;
|
80
|
+
$('input, select, textarea', context).add(selfElement.filter('input, select, textarea')).each(function(){
|
81
|
+
testValidityRules(this);
|
82
|
+
});
|
83
|
+
initTest = false;
|
84
|
+
formReady = true;
|
93
85
|
});
|
94
|
-
|
95
|
-
});
|
96
|
-
$(document).bind('refreshCustomValidityRules', onEventTest);
|
86
|
+
$(document).on('refreshCustomValidityRules change', onEventTest);
|
87
|
+
}, 9);
|
97
88
|
|
98
89
|
});
|
99
90
|
|
100
|
-
})(
|
91
|
+
})();
|
101
92
|
|
102
93
|
/*
|
103
94
|
* adds support for HTML5 constraint validation
|
@@ -108,8 +99,8 @@
|
|
108
99
|
* - <input type="date" id="start" data-dependent-validation='{"from": "end", "prop": "max"}' /> <input type="date" id="end" data-dependent-validation='{"from": "start", "prop": "min"}' />
|
109
100
|
* - <input type="checkbox" id="check" /> <input data-dependent-validation='checkbox' />
|
110
101
|
*/
|
111
|
-
(function(
|
112
|
-
|
102
|
+
(function(){
|
103
|
+
|
113
104
|
var addCustomValidityRule = $.webshims.addCustomValidityRule;
|
114
105
|
addCustomValidityRule('partialPattern', function(elem, val){
|
115
106
|
if(!val || !elem.getAttribute('data-partial-pattern')){return;}
|
@@ -134,6 +125,7 @@
|
|
134
125
|
}
|
135
126
|
groupTimer[name] = setTimeout(function(){
|
136
127
|
checkboxes
|
128
|
+
.addClass('group-required')
|
137
129
|
.unbind('click.groupRequired')
|
138
130
|
.bind('click.groupRequired', function(){
|
139
131
|
checkboxes.filter('.group-required').each(function(){
|
@@ -176,7 +168,7 @@
|
|
176
168
|
var getGroupElements = function(elem) {
|
177
169
|
return $(elem.form[elem.name]).filter('[type="radio"]');
|
178
170
|
};
|
179
|
-
$.webshims.ready('form-
|
171
|
+
$.webshims.ready('form-validation', function(){
|
180
172
|
if($.webshims.modules){
|
181
173
|
getGroupElements = $.webshims.modules["form-core"].getGroupElements || getGroupElements;
|
182
174
|
}
|
@@ -198,6 +190,9 @@
|
|
198
190
|
val = !val;
|
199
191
|
}
|
200
192
|
$.prop( elem, data.prop, val);
|
193
|
+
if(e){
|
194
|
+
$(elem).getShadowElement().filter('.user-error, .user-success').trigger('refreshvalidityui');
|
195
|
+
}
|
201
196
|
};
|
202
197
|
|
203
198
|
if(!data._init || !data.masterElement){
|
@@ -235,9 +230,7 @@
|
|
235
230
|
} else {
|
236
231
|
$(data.masterElement).bind('change', function(){
|
237
232
|
$.webshims.refreshCustomValidityRules(elem);
|
238
|
-
|
239
|
-
$(elem).trigger('refreshvalidityui');
|
240
|
-
}
|
233
|
+
$(elem).getShadowElement().filter('.user-error, .user-success').trigger('refreshvalidityui');
|
241
234
|
});
|
242
235
|
}
|
243
236
|
}
|
@@ -250,4 +243,6 @@
|
|
250
243
|
}
|
251
244
|
|
252
245
|
}, 'The value of this field does not repeat the value of the other field');
|
253
|
-
})(
|
246
|
+
})();
|
247
|
+
|
248
|
+
});
|
@@ -0,0 +1,865 @@
|
|
1
|
+
webshims.register('forms-picker', function($, webshims, window, document, undefined, options){
|
2
|
+
"use strict";
|
3
|
+
var picker = webshims.picker;
|
4
|
+
var actions = picker._actions;
|
5
|
+
var moduleOpts = options;
|
6
|
+
|
7
|
+
var getDateArray = function(date){
|
8
|
+
var ret = [date.getFullYear(), moduleOpts.addZero(date.getMonth() + 1), moduleOpts.addZero(date.getDate())];
|
9
|
+
ret.month = ret[0]+'-'+ret[1];
|
10
|
+
ret.date = ret[0]+'-'+ret[1]+'-'+ret[2];
|
11
|
+
return ret;
|
12
|
+
};
|
13
|
+
var today = getDateArray(new Date());
|
14
|
+
|
15
|
+
|
16
|
+
var _setFocus = function(element, _noFocus){
|
17
|
+
|
18
|
+
element = $(element || this.activeButton);
|
19
|
+
this.activeButton.attr({tabindex: '-1', 'aria-selected': 'false'});
|
20
|
+
this.activeButton = element.attr({tabindex: '0', 'aria-selected': 'true'});
|
21
|
+
this.index = this.buttons.index(this.activeButton[0]);
|
22
|
+
|
23
|
+
clearTimeout(this.timer);
|
24
|
+
|
25
|
+
picker._genericSetFocus.apply(this, arguments);
|
26
|
+
|
27
|
+
};
|
28
|
+
|
29
|
+
var _initialFocus = function(){
|
30
|
+
var sel;
|
31
|
+
if(this.popover.navedInitFocus){
|
32
|
+
sel = this.popover.navedInitFocus.sel || this.popover.navedInitFocus;
|
33
|
+
if((!this.activeButton || !this.activeButton[0]) && this.buttons[sel]){
|
34
|
+
this.activeButton = this.buttons[sel]();
|
35
|
+
} else if(sel){
|
36
|
+
this.activeButton = $(sel, this.element);
|
37
|
+
}
|
38
|
+
|
39
|
+
if(!this.activeButton[0] && this.popover.navedInitFocus.alt){
|
40
|
+
this.activeButton = this.buttons[this.popover.navedInitFocus.alt]();
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
if(!this.activeButton || !this.activeButton[0]){
|
45
|
+
this.activeButton = this.buttons.filter('.checked-value');
|
46
|
+
}
|
47
|
+
|
48
|
+
if(!this.activeButton[0]){
|
49
|
+
this.activeButton = this.buttons.filter('.this-value');
|
50
|
+
}
|
51
|
+
if(!this.activeButton[0]){
|
52
|
+
this.activeButton = this.buttons.eq(0);
|
53
|
+
}
|
54
|
+
|
55
|
+
this.setFocus(this.activeButton, this.opts.noFocus);
|
56
|
+
};
|
57
|
+
var formcfg = webshims.formcfg;
|
58
|
+
var curCfg = formcfg[$.webshims.activeLang()] || formcfg[''];
|
59
|
+
$.webshims.activeLang({
|
60
|
+
register: 'form-core',
|
61
|
+
callback: function(){
|
62
|
+
$.each(arguments, function(i, val){
|
63
|
+
if(formcfg[val]){
|
64
|
+
curCfg = formcfg[val];
|
65
|
+
return false;
|
66
|
+
}
|
67
|
+
});
|
68
|
+
}
|
69
|
+
});
|
70
|
+
|
71
|
+
|
72
|
+
webshims.ListBox = function (element, popover, opts){
|
73
|
+
this.element = $('ul', element);
|
74
|
+
this.popover = popover;
|
75
|
+
this.opts = opts || {};
|
76
|
+
this.buttons = $('button:not(:disabled)', this.element);
|
77
|
+
|
78
|
+
|
79
|
+
this.ons(this);
|
80
|
+
this._initialFocus();
|
81
|
+
};
|
82
|
+
|
83
|
+
webshims.ListBox.prototype = {
|
84
|
+
setFocus: _setFocus,
|
85
|
+
_initialFocus: _initialFocus,
|
86
|
+
prev: function(){
|
87
|
+
var index = this.index - 1;
|
88
|
+
if(index < 0){
|
89
|
+
if(this.opts.prev){
|
90
|
+
this.popover.navedInitFocus = 'last';
|
91
|
+
this.popover.actionFn(this.opts.prev);
|
92
|
+
this.popover.navedInitFocus = false;
|
93
|
+
}
|
94
|
+
} else {
|
95
|
+
this.setFocus(this.buttons.eq(index));
|
96
|
+
}
|
97
|
+
},
|
98
|
+
next: function(){
|
99
|
+
var index = this.index + 1;
|
100
|
+
if(index >= this.buttons.length){
|
101
|
+
if(this.opts.next){
|
102
|
+
this.popover.navedInitFocus = 'first';
|
103
|
+
this.popover.actionFn(this.opts.next);
|
104
|
+
this.popover.navedInitFocus = false;
|
105
|
+
}
|
106
|
+
} else {
|
107
|
+
this.setFocus(this.buttons.eq(index));
|
108
|
+
}
|
109
|
+
},
|
110
|
+
ons: function(that){
|
111
|
+
this.element
|
112
|
+
.on({
|
113
|
+
'keydown': function(e){
|
114
|
+
var handled;
|
115
|
+
var key = e.keyCode;
|
116
|
+
if(e.ctrlKey){return;}
|
117
|
+
if(key == 36 || key == 33){
|
118
|
+
that.setFocus(that.buttons.eq(0));
|
119
|
+
handled = true;
|
120
|
+
} else if(key == 34 || key == 35){
|
121
|
+
that.setFocus(that.buttons.eq(that.buttons.length - 1));
|
122
|
+
handled = true;
|
123
|
+
} else if(key == 38 || key == 37){
|
124
|
+
that.prev();
|
125
|
+
handled = true;
|
126
|
+
} else if(key == 40 || key == 39){
|
127
|
+
that.next();
|
128
|
+
handled = true;
|
129
|
+
}
|
130
|
+
if(handled){
|
131
|
+
return false;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
})
|
135
|
+
;
|
136
|
+
}
|
137
|
+
};
|
138
|
+
|
139
|
+
webshims.Grid = function (element, popover, opts){
|
140
|
+
this.element = $('tbody', element);
|
141
|
+
this.popover = popover;
|
142
|
+
this.opts = opts || {};
|
143
|
+
this.buttons = $('button:not(:disabled,.othermonth)', this.element);
|
144
|
+
|
145
|
+
this.ons(this);
|
146
|
+
|
147
|
+
this._initialFocus();
|
148
|
+
if(this.popover.openedByFocus){
|
149
|
+
this.popover.activeElement = this.activeButton;
|
150
|
+
}
|
151
|
+
};
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
webshims.Grid.prototype = {
|
156
|
+
setFocus: _setFocus,
|
157
|
+
_initialFocus: _initialFocus,
|
158
|
+
|
159
|
+
first: function(){
|
160
|
+
this.setFocus(this.buttons.eq(0));
|
161
|
+
},
|
162
|
+
last: function(){
|
163
|
+
this.setFocus(this.buttons.eq(this.buttons.length - 1));
|
164
|
+
},
|
165
|
+
upPage: function(){
|
166
|
+
$('.ws-picker-header > button:not(:disabled)', this.popover.element).trigger('click');
|
167
|
+
},
|
168
|
+
downPage: function(){
|
169
|
+
this.activeButton.filter(':not([data-action="changeInput"])').trigger('click');
|
170
|
+
},
|
171
|
+
ons: function(that){
|
172
|
+
this.element
|
173
|
+
.on({
|
174
|
+
'keydown': function(e){
|
175
|
+
var handled;
|
176
|
+
var key = e.keyCode;
|
177
|
+
|
178
|
+
if(e.shiftKey){return;}
|
179
|
+
|
180
|
+
if((e.ctrlKey && key == 40)){
|
181
|
+
handled = 'downPage';
|
182
|
+
} else if((e.ctrlKey && key == 38)){
|
183
|
+
handled = 'upPage';
|
184
|
+
} else if(key == 33 || (e.ctrlKey && key == 37)){
|
185
|
+
handled = 'prevPage';
|
186
|
+
} else if(key == 34 || (e.ctrlKey && key == 39)){
|
187
|
+
handled = 'nextPage';
|
188
|
+
} else if(e.keyCode == 36 || e.keyCode == 33){
|
189
|
+
handled = 'first';
|
190
|
+
} else if(e.keyCode == 35){
|
191
|
+
handled = 'last';
|
192
|
+
} else if(e.keyCode == 38){
|
193
|
+
handled = 'up';
|
194
|
+
} else if(e.keyCode == 37){
|
195
|
+
handled = 'prev';
|
196
|
+
} else if(e.keyCode == 40){
|
197
|
+
handled = 'down';
|
198
|
+
} else if(e.keyCode == 39){
|
199
|
+
handled = 'next';
|
200
|
+
}
|
201
|
+
if(handled){
|
202
|
+
that[handled]();
|
203
|
+
return false;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
})
|
207
|
+
;
|
208
|
+
}
|
209
|
+
};
|
210
|
+
$.each({
|
211
|
+
prevPage: {get: 'last', action: 'prev'},
|
212
|
+
nextPage: {get: 'first', action: 'next'}
|
213
|
+
}, function(name, val){
|
214
|
+
webshims.Grid.prototype[name] = function(){
|
215
|
+
if(this.opts[val.action]){
|
216
|
+
this.popover.navedInitFocus = {
|
217
|
+
sel: 'button[data-id="'+ this.activeButton.attr('data-id') +'"]:not(:disabled,.othermonth)',
|
218
|
+
alt: val.get
|
219
|
+
};
|
220
|
+
this.popover.actionFn(this.opts[val.action]);
|
221
|
+
this.popover.navedInitFocus = false;
|
222
|
+
}
|
223
|
+
};
|
224
|
+
});
|
225
|
+
|
226
|
+
$.each({
|
227
|
+
up: {traverse: 'prevAll', get: 'last', action: 'prev', reverse: true},
|
228
|
+
down: {traverse: 'nextAll', get: 'first', action: 'next'}
|
229
|
+
}, function(name, val){
|
230
|
+
webshims.Grid.prototype[name] = function(){
|
231
|
+
var cellIndex = this.activeButton.closest('td').prop('cellIndex');
|
232
|
+
var sel = 'td:nth-child('+(cellIndex + 1)+') button:not(:disabled,.othermonth)';
|
233
|
+
var button = this.activeButton.closest('tr')[val.traverse]();
|
234
|
+
|
235
|
+
if(val.reverse){
|
236
|
+
button = $(button.get().reverse());
|
237
|
+
}
|
238
|
+
button = button.find(sel)[val.get]();
|
239
|
+
|
240
|
+
if(!button[0]){
|
241
|
+
if(this.opts[val.action]){
|
242
|
+
this.popover.navedInitFocus = sel+':'+val.get;
|
243
|
+
this.popover.actionFn(this.opts[val.action]);
|
244
|
+
this.popover.navedInitFocus = false;
|
245
|
+
}
|
246
|
+
} else {
|
247
|
+
this.setFocus(button.eq(0));
|
248
|
+
}
|
249
|
+
};
|
250
|
+
});
|
251
|
+
|
252
|
+
$.each({
|
253
|
+
prev: {traverse: 'prevAll',get: 'last', reverse: true},
|
254
|
+
next: {traverse: 'nextAll', get: 'first'}
|
255
|
+
}, function(name, val){
|
256
|
+
webshims.Grid.prototype[name] = function(){
|
257
|
+
var sel = 'button:not(:disabled,.othermonth)';
|
258
|
+
var button = this.activeButton.closest('td')[val.traverse]('td');
|
259
|
+
if(val.reverse){
|
260
|
+
button = $(button.get().reverse());
|
261
|
+
}
|
262
|
+
button = button.find(sel)[val.get]();
|
263
|
+
if(!button[0]){
|
264
|
+
button = this.activeButton.closest('tr')[val.traverse]('tr');
|
265
|
+
if(val.reverse){
|
266
|
+
button = $(button.get().reverse());
|
267
|
+
}
|
268
|
+
button = button.find(sel)[val.get]();
|
269
|
+
}
|
270
|
+
|
271
|
+
if(!button[0]){
|
272
|
+
if(this.opts[name]){
|
273
|
+
this.popover.navedInitFocus = val.get;
|
274
|
+
this.popover.actionFn(this.opts[name]);
|
275
|
+
this.popover.navedInitFocus = false;
|
276
|
+
}
|
277
|
+
} else {
|
278
|
+
this.setFocus(button.eq(0));
|
279
|
+
}
|
280
|
+
};
|
281
|
+
});
|
282
|
+
|
283
|
+
picker.getWeek = function(date){
|
284
|
+
var onejan = new Date(date.getFullYear(),0,1);
|
285
|
+
return Math.ceil((((date - onejan) / 86400000) + onejan.getDay()+1)/7);
|
286
|
+
};
|
287
|
+
picker.getYearList = function(value, data){
|
288
|
+
var j, i, val, disabled, lis, prevDisabled, nextDisabled, classStr, classArray, start;
|
289
|
+
|
290
|
+
|
291
|
+
var size = data.options.size;
|
292
|
+
var max = data.options.max.split('-');
|
293
|
+
var min = data.options.min.split('-');
|
294
|
+
var currentValue = data.options.value.split('-');
|
295
|
+
var xthCorrect = 0;
|
296
|
+
var enabled = 0;
|
297
|
+
var str = '';
|
298
|
+
var rowNum = 0;
|
299
|
+
|
300
|
+
if(data.options.useDecadeBase == 'max' && max[0]){
|
301
|
+
xthCorrect = 11 - (max[0] % 12);
|
302
|
+
} else if(data.options.useDecadeBase == 'min' && min[0]){
|
303
|
+
xthCorrect = 11 - (min[0] % 12);
|
304
|
+
}
|
305
|
+
|
306
|
+
value = value[0] * 1;
|
307
|
+
start = value - ((value + xthCorrect) % (12 * size));
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
for(j = 0; j < size; j++){
|
312
|
+
if(j){
|
313
|
+
start += 12;
|
314
|
+
} else {
|
315
|
+
prevDisabled = picker.isInRange([start-1], max, min) ? {'data-action': 'setYearList','value': start-1} : false;
|
316
|
+
}
|
317
|
+
|
318
|
+
str += '<div class="year-list picker-list ws-index-'+ j +'"><div class="ws-picker-header"><button disabled="disabled">'+ start +' – '+(start + 11)+'</button></div>';
|
319
|
+
lis = [];
|
320
|
+
for(i = 0; i < 12; i++){
|
321
|
+
val = start + i ;
|
322
|
+
classArray = [];
|
323
|
+
if( !picker.isInRange([val], max, min) ){
|
324
|
+
disabled = ' disabled=""';
|
325
|
+
} else {
|
326
|
+
disabled = '';
|
327
|
+
enabled++;
|
328
|
+
}
|
329
|
+
|
330
|
+
if(val == today[0]){
|
331
|
+
classArray.push('this-value');
|
332
|
+
}
|
333
|
+
|
334
|
+
if(currentValue[0] == val){
|
335
|
+
classArray.push('checked-value');
|
336
|
+
}
|
337
|
+
|
338
|
+
classStr = classArray.length ? ' class="'+ (classArray.join(' ')) +'"' : '';
|
339
|
+
|
340
|
+
if(i && !(i % 3)){
|
341
|
+
rowNum++;
|
342
|
+
lis.push('</tr><tr class="ws-row-'+ rowNum +'">');
|
343
|
+
}
|
344
|
+
lis.push('<td class="ws-item-'+ i +'" role="presentation"><button data-id="year-'+ i +'" type="button"'+ disabled + classStr +' data-action="setMonthList" value="'+val+'" tabindex="-1" role="gridcell">'+val+'</button></td>');
|
345
|
+
}
|
346
|
+
if(j == size - 1){
|
347
|
+
nextDisabled = picker.isInRange([val+1], max, min) ? {'data-action': 'setYearList','value': val+1} : false;
|
348
|
+
}
|
349
|
+
str += '<div class="picker-grid"><table role="grid" aria-label="'+ start +' – '+(start + 11)+'"><tbody><tr class="ws-row-0">'+ (lis.join(''))+ '</tr></tbody></table></div></div>';
|
350
|
+
}
|
351
|
+
|
352
|
+
return {
|
353
|
+
enabled: enabled,
|
354
|
+
main: str,
|
355
|
+
next: nextDisabled,
|
356
|
+
prev: prevDisabled,
|
357
|
+
type: 'Grid'
|
358
|
+
};
|
359
|
+
};
|
360
|
+
|
361
|
+
|
362
|
+
picker.getMonthList = function(value, data){
|
363
|
+
|
364
|
+
var j, i, name, val, disabled, lis, fullyDisabled, prevDisabled, nextDisabled, classStr, classArray;
|
365
|
+
var o = data.options;
|
366
|
+
var size = o.size;
|
367
|
+
var max = o.max.split('-');
|
368
|
+
var min = o.min.split('-');
|
369
|
+
var currentValue = o.value.split('-');
|
370
|
+
var enabled = 0;
|
371
|
+
var rowNum = 0;
|
372
|
+
var str = '';
|
373
|
+
|
374
|
+
value = value[0] - Math.floor((size - 1) / 2);
|
375
|
+
for(j = 0; j < size; j++){
|
376
|
+
if(j){
|
377
|
+
value++;
|
378
|
+
} else {
|
379
|
+
prevDisabled = picker.isInRange([value-1], max, min) ? {'data-action': 'setMonthList','value': value-1} : false;
|
380
|
+
}
|
381
|
+
if(j == size - 1){
|
382
|
+
nextDisabled = picker.isInRange([value+1], max, min) ? {'data-action': 'setMonthList','value': value+1} : false;
|
383
|
+
}
|
384
|
+
lis = [];
|
385
|
+
|
386
|
+
if( !picker.isInRange([value, '01'], max, min) && !picker.isInRange([value, '12'], max, min)){
|
387
|
+
disabled = ' disabled=""';
|
388
|
+
fullyDisabled = true;
|
389
|
+
} else {
|
390
|
+
fullyDisabled = false;
|
391
|
+
disabled = '';
|
392
|
+
}
|
393
|
+
|
394
|
+
if(o.minView >= 1){
|
395
|
+
disabled = ' disabled=""';
|
396
|
+
}
|
397
|
+
|
398
|
+
str += '<div class="month-list picker-list ws-index-'+ j +'"><div class="ws-picker-header">';
|
399
|
+
|
400
|
+
str += o.selectNav ?
|
401
|
+
'<select data-action="setMonthList" class="year-select">'+ picker.createYearSelect(value, max, min).join('') +'</select>' :
|
402
|
+
'<button data-action="setYearList"'+disabled+' value="'+ value +'" tabindex="-1">'+ value +'</button>';
|
403
|
+
str += '</div>';
|
404
|
+
|
405
|
+
for(i = 0; i < 12; i++){
|
406
|
+
val = curCfg.date.monthkeys[i+1];
|
407
|
+
name = (curCfg.date[o.monthNames] || curCfg.date.monthNames)[i];
|
408
|
+
classArray = [];
|
409
|
+
if(fullyDisabled || !picker.isInRange([value, val], max, min) ){
|
410
|
+
disabled = ' disabled=""';
|
411
|
+
} else {
|
412
|
+
disabled = '';
|
413
|
+
enabled++;
|
414
|
+
}
|
415
|
+
|
416
|
+
if(value == today[0] && today[1] == val){
|
417
|
+
classArray.push('this-value');
|
418
|
+
}
|
419
|
+
|
420
|
+
if(currentValue[0] == value && currentValue[1] == val){
|
421
|
+
classArray.push('checked-value');
|
422
|
+
}
|
423
|
+
|
424
|
+
classStr = (classArray.length) ? ' class="'+ (classArray.join(' ')) +'"' : '';
|
425
|
+
if(i && !(i % 3)){
|
426
|
+
rowNum++;
|
427
|
+
lis.push('</tr><tr class="ws-row-'+ rowNum +'">');
|
428
|
+
}
|
429
|
+
|
430
|
+
lis.push('<td class="ws-item-'+ i +'" role="presentation"><button data-id="month-'+ i +'" type="button"'+ disabled + classStr +' data-action="'+ (data.type == 'month' ? 'changeInput' : 'setDayList' ) +'" value="'+value+'-'+val+'" tabindex="-1" role="gridcell" aria-label="'+ curCfg.date.monthNames[i] +'">'+name+'</button></td>');
|
431
|
+
|
432
|
+
}
|
433
|
+
|
434
|
+
str += '<div class="picker-grid"><table role="grid" aria-label="'+value+'"><tbody><tr class="ws-row-0">'+ (lis.join(''))+ '</tr></tbody></table></div></div>';
|
435
|
+
}
|
436
|
+
|
437
|
+
return {
|
438
|
+
enabled: enabled,
|
439
|
+
main: str,
|
440
|
+
prev: prevDisabled,
|
441
|
+
next: nextDisabled,
|
442
|
+
type: 'Grid'
|
443
|
+
};
|
444
|
+
};
|
445
|
+
|
446
|
+
|
447
|
+
picker.getDayList = function(value, data){
|
448
|
+
|
449
|
+
var j, i, k, day, nDay, name, val, disabled, lis, prevDisabled, nextDisabled, addTr, week, rowNum;
|
450
|
+
|
451
|
+
var lastMotnh, curMonth, otherMonth, dateArray, monthName, fullMonthName, buttonStr, date2, classArray;
|
452
|
+
var o = data.options;
|
453
|
+
var size = o.size;
|
454
|
+
var max = o.max.split('-');
|
455
|
+
var min = o.min.split('-');
|
456
|
+
var currentValue = o.value.split('-');
|
457
|
+
var monthNames = curCfg.date[o.monthNamesHead] || curCfg.date[o.monthNames] || curCfg.date.monthNames;
|
458
|
+
var enabled = 0;
|
459
|
+
var str = [];
|
460
|
+
var date = new Date(value[0], value[1] - 1, 1);
|
461
|
+
|
462
|
+
date.setMonth(date.getMonth() - Math.floor((size - 1) / 2));
|
463
|
+
|
464
|
+
for(j = 0; j < size; j++){
|
465
|
+
date.setDate(1);
|
466
|
+
lastMotnh = date.getMonth();
|
467
|
+
rowNum = 0;
|
468
|
+
if(!j){
|
469
|
+
date2 = new Date(date.getTime());
|
470
|
+
date2.setDate(-1);
|
471
|
+
dateArray = getDateArray(date2);
|
472
|
+
prevDisabled = picker.isInRange(dateArray, max, min) ? {'data-action': 'setDayList','value': dateArray[0]+'-'+dateArray[1]} : false;
|
473
|
+
}
|
474
|
+
|
475
|
+
dateArray = getDateArray(date);
|
476
|
+
|
477
|
+
str.push('<div class="day-list picker-list ws-index-'+ j +'"><div class="ws-picker-header">');
|
478
|
+
if( o.selectNav ){
|
479
|
+
monthName = ['<select data-action="setDayList" class="month-select" tabindex="0">'+ picker.createMonthSelect(dateArray, max, min, monthNames).join('') +'</select>', '<select data-action="setDayList" class="year-select" tabindex="0">'+ picker.createYearSelect(dateArray[0], max, min, '-'+dateArray[1]).join('') +'</select>'];
|
480
|
+
if(curCfg.date.showMonthAfterYear){
|
481
|
+
monthName.reverse();
|
482
|
+
}
|
483
|
+
str.push( monthName.join(' ') );
|
484
|
+
}
|
485
|
+
|
486
|
+
fullMonthName = [curCfg.date.monthNames[(dateArray[1] * 1) - 1], dateArray[0]];
|
487
|
+
monthName = [monthNames[(dateArray[1] * 1) - 1], dateArray[0]];
|
488
|
+
if(curCfg.date.showMonthAfterYear){
|
489
|
+
monthName.reverse();
|
490
|
+
fullMonthName.reverse();
|
491
|
+
}
|
492
|
+
|
493
|
+
if(!data.options.selectNav) {
|
494
|
+
str.push(
|
495
|
+
'<button data-action="setMonthList"'+ (o.minView >= 2 ? ' disabled="" ' : '') +' value="'+ dateArray.date +'" tabindex="-1">'+ monthName.join(' ') +'</button>'
|
496
|
+
);
|
497
|
+
}
|
498
|
+
|
499
|
+
|
500
|
+
str.push('</div><div class="picker-grid"><table role="grid" aria-label="'+ fullMonthName.join(' ') +'"><thead><tr>');
|
501
|
+
|
502
|
+
if(data.options.showWeek){
|
503
|
+
str.push('<th class="week-header">'+ curCfg.date.weekHeader +'</th>');
|
504
|
+
}
|
505
|
+
for(k = curCfg.date.firstDay; k < curCfg.date.dayNamesShort.length; k++){
|
506
|
+
str.push('<th class="day-'+ k +'"><abbr title="'+ curCfg.date.dayNames[k] +'">'+ curCfg.date.dayNamesShort[k] +'</abbr></th>');
|
507
|
+
}
|
508
|
+
k = curCfg.date.firstDay;
|
509
|
+
while(k--){
|
510
|
+
str.push('<th class="day-'+ k +'"><abbr title="'+ curCfg.date.dayNames[k] +'">'+ curCfg.date.dayNamesShort[k] +'</abbr></th>');
|
511
|
+
}
|
512
|
+
str.push('</tr></thead><tbody><tr class="ws-row-0">');
|
513
|
+
|
514
|
+
if(data.options.showWeek) {
|
515
|
+
week = picker.getWeek(date);
|
516
|
+
str.push('<td class="week-cell">'+ week +'</td>');
|
517
|
+
}
|
518
|
+
|
519
|
+
for (i = 0; i < 99; i++) {
|
520
|
+
addTr = (i && !(i % 7));
|
521
|
+
curMonth = date.getMonth();
|
522
|
+
otherMonth = lastMotnh != curMonth;
|
523
|
+
day = date.getDay();
|
524
|
+
classArray = [];
|
525
|
+
|
526
|
+
if(addTr && otherMonth ){
|
527
|
+
str.push('</tr>');
|
528
|
+
break;
|
529
|
+
}
|
530
|
+
if(addTr){
|
531
|
+
rowNum++;
|
532
|
+
str.push('</tr><tr class="ws-row-'+ rowNum +'">');
|
533
|
+
if(data.options.showWeek) {
|
534
|
+
week++;
|
535
|
+
str.push('<td class="week-cell">'+ week +'</td>');
|
536
|
+
}
|
537
|
+
}
|
538
|
+
|
539
|
+
if(!i){
|
540
|
+
|
541
|
+
if(day != curCfg.date.firstDay){
|
542
|
+
nDay = day - curCfg.date.firstDay;
|
543
|
+
if(nDay < 0){
|
544
|
+
nDay += 7;
|
545
|
+
}
|
546
|
+
date.setDate(date.getDate() - nDay);
|
547
|
+
day = date.getDay();
|
548
|
+
curMonth = date.getMonth();
|
549
|
+
otherMonth = lastMotnh != curMonth;
|
550
|
+
}
|
551
|
+
}
|
552
|
+
|
553
|
+
dateArray = getDateArray(date);
|
554
|
+
buttonStr = '<td role="presentation" class="day-'+ day +'"><button data-id="day-'+ date.getDate() +'" role="gridcell" data-action="changeInput" value="'+ (dateArray.join('-')) +'"';
|
555
|
+
|
556
|
+
if(otherMonth){
|
557
|
+
classArray.push('othermonth');
|
558
|
+
} else {
|
559
|
+
classArray.push('day-'+date.getDate());
|
560
|
+
}
|
561
|
+
|
562
|
+
if(dateArray[0] == today[0] && today[1] == dateArray[1] && today[2] == dateArray[2]){
|
563
|
+
classArray.push('this-value');
|
564
|
+
}
|
565
|
+
|
566
|
+
if(currentValue[0] == dateArray[0] && dateArray[1] == currentValue[1] && dateArray[2] == currentValue[2]){
|
567
|
+
classArray.push('checked-value');
|
568
|
+
}
|
569
|
+
|
570
|
+
if(classArray.length){
|
571
|
+
buttonStr += ' class="'+ classArray.join(' ') +'"';
|
572
|
+
}
|
573
|
+
|
574
|
+
if(!picker.isInRange(dateArray, max, min) || (data.options.disableDays && $.inArray(day, data.options.disableDays) != -1)){
|
575
|
+
buttonStr += ' disabled=""';
|
576
|
+
}
|
577
|
+
|
578
|
+
str.push(buttonStr+' tabindex="-1">'+ date.getDate() +'</button></td>');
|
579
|
+
|
580
|
+
date.setDate(date.getDate() + 1);
|
581
|
+
}
|
582
|
+
str.push('</tbody></table></div></div>');
|
583
|
+
if(j == size - 1){
|
584
|
+
dateArray = getDateArray(date);
|
585
|
+
dateArray[2] = 1;
|
586
|
+
nextDisabled = picker.isInRange(dateArray, max, min) ? {'data-action': 'setDayList','value': dateArray.date} : false;
|
587
|
+
}
|
588
|
+
}
|
589
|
+
|
590
|
+
|
591
|
+
return {
|
592
|
+
enabled: 9,
|
593
|
+
main: str.join(''),
|
594
|
+
prev: prevDisabled,
|
595
|
+
next: nextDisabled,
|
596
|
+
type: 'Grid'
|
597
|
+
};
|
598
|
+
};
|
599
|
+
|
600
|
+
picker.isInRange = function(values, max, min){
|
601
|
+
var i;
|
602
|
+
var ret = true;
|
603
|
+
for(i = 0; i < values.length; i++){
|
604
|
+
|
605
|
+
if(min[i] && min[i] > values[i]){
|
606
|
+
ret = false;
|
607
|
+
break;
|
608
|
+
} else if( !(min[i] && min[i] == values[i]) ){
|
609
|
+
break;
|
610
|
+
}
|
611
|
+
}
|
612
|
+
if(ret){
|
613
|
+
for(i = 0; i < values.length; i++){
|
614
|
+
|
615
|
+
if((max[i] && max[i] < values[i])){
|
616
|
+
ret = false;
|
617
|
+
break;
|
618
|
+
} else if( !(max[i] && max[i] == values[i]) ){
|
619
|
+
break;
|
620
|
+
}
|
621
|
+
}
|
622
|
+
}
|
623
|
+
return ret;
|
624
|
+
};
|
625
|
+
|
626
|
+
picker.createMonthSelect = function(value, max, min, monthNames){
|
627
|
+
if(!monthNames){
|
628
|
+
monthNames = curCfg.date.monthNames;
|
629
|
+
}
|
630
|
+
|
631
|
+
var selected;
|
632
|
+
var i = 0;
|
633
|
+
var options = [];
|
634
|
+
var tempVal = value[1]-1;
|
635
|
+
for(; i < monthNames.length; i++){
|
636
|
+
selected = tempVal == i ? ' selected=""' : '';
|
637
|
+
if(selected || picker.isInRange([value[0], i+1], max, min)){
|
638
|
+
options.push('<option value="'+ value[0]+'-'+moduleOpts.addZero(i+1) + '"'+selected+'>'+ monthNames[i] +'</option>');
|
639
|
+
}
|
640
|
+
}
|
641
|
+
return options;
|
642
|
+
};
|
643
|
+
|
644
|
+
picker.createYearSelect = function(value, max, min, valueAdd){
|
645
|
+
|
646
|
+
var temp;
|
647
|
+
var goUp = true;
|
648
|
+
var goDown = true;
|
649
|
+
var options = ['<option selected="">'+ value + '</option>'];
|
650
|
+
var i = 0;
|
651
|
+
if(!valueAdd){
|
652
|
+
valueAdd = '';
|
653
|
+
}
|
654
|
+
while(i < 8 && (goUp || goDown)){
|
655
|
+
i++;
|
656
|
+
temp = value-i;
|
657
|
+
if(goUp && picker.isInRange([temp], max, min)){
|
658
|
+
options.unshift('<option value="'+ (temp+valueAdd) +'">'+ temp +'</option>');
|
659
|
+
} else {
|
660
|
+
goUp = false;
|
661
|
+
}
|
662
|
+
temp = value + i;
|
663
|
+
if(goDown && picker.isInRange([temp], max, min)){
|
664
|
+
options.push('<option value="'+ (temp+valueAdd) +'">'+ temp +'</option>');
|
665
|
+
} else {
|
666
|
+
goDown = false;
|
667
|
+
}
|
668
|
+
}
|
669
|
+
return options;
|
670
|
+
};
|
671
|
+
|
672
|
+
(function(){
|
673
|
+
var retNames = function(name){
|
674
|
+
return 'get'+name+'List';
|
675
|
+
};
|
676
|
+
var retSetNames = function(name){
|
677
|
+
return 'set'+name+'List';
|
678
|
+
};
|
679
|
+
var stops = {
|
680
|
+
date: 'Day',
|
681
|
+
week: 'Day',
|
682
|
+
month: 'Month'
|
683
|
+
};
|
684
|
+
|
685
|
+
$.each({'setYearList' : ['Year', 'Month', 'Day'], 'setMonthList': ['Month', 'Day'], 'setDayList': ['Day']}, function(setName, names){
|
686
|
+
var getNames = names.map(retNames);
|
687
|
+
var setNames = names.map(retSetNames);
|
688
|
+
actions[setName] = function(val, popover, data, startAt){
|
689
|
+
val = ''+val;
|
690
|
+
var o = data.options;
|
691
|
+
var values = val.split('-');
|
692
|
+
if(!startAt){
|
693
|
+
startAt = 0;
|
694
|
+
}
|
695
|
+
$.each(getNames, function(i, item){
|
696
|
+
if(i >= startAt){
|
697
|
+
var content = picker[item](values, data);
|
698
|
+
|
699
|
+
if( values.length < 2 || content.enabled > 1 || stops[data.type] === names[i]){
|
700
|
+
popover.element
|
701
|
+
.attr({'data-currentview': setNames[i]})
|
702
|
+
.addClass('ws-size-'+o.size)
|
703
|
+
.data('pickercontent', {
|
704
|
+
data: data,
|
705
|
+
content: content,
|
706
|
+
values: values
|
707
|
+
})
|
708
|
+
;
|
709
|
+
popover.bodyElement.html(content.main);
|
710
|
+
if(content.prev){
|
711
|
+
popover.prevElement
|
712
|
+
.attr(content.prev)
|
713
|
+
.prop({disabled: false})
|
714
|
+
;
|
715
|
+
} else {
|
716
|
+
popover.prevElement
|
717
|
+
.removeAttr('data-action')
|
718
|
+
.prop({disabled: true})
|
719
|
+
;
|
720
|
+
}
|
721
|
+
if(content.next){
|
722
|
+
popover.nextElement
|
723
|
+
.attr(content.next)
|
724
|
+
.prop({disabled: false})
|
725
|
+
;
|
726
|
+
} else {
|
727
|
+
popover.nextElement
|
728
|
+
.removeAttr('data-action')
|
729
|
+
.prop({disabled: true})
|
730
|
+
;
|
731
|
+
}
|
732
|
+
if(webshims[content.type]){
|
733
|
+
new webshims[content.type](popover.bodyElement.children(), popover, content);
|
734
|
+
}
|
735
|
+
popover.element.trigger('pickerchange');
|
736
|
+
return false;
|
737
|
+
}
|
738
|
+
}
|
739
|
+
});
|
740
|
+
};
|
741
|
+
});
|
742
|
+
})();
|
743
|
+
|
744
|
+
picker.showPickerContent = function(data, popover){
|
745
|
+
var options = data.options;
|
746
|
+
if(!data._popoverinit){
|
747
|
+
picker.commonInit(data, popover);
|
748
|
+
picker.commonDateInit(data, popover);
|
749
|
+
}
|
750
|
+
|
751
|
+
if(!data._popoverinit || options.restartView) {
|
752
|
+
actions.setYearList( options.defValue || options.value, popover, data, options.startView);
|
753
|
+
} else {
|
754
|
+
actions[popover.element.attr('data-currentview') || 'setYearList']( options.defValue || options.value, popover, data, 0);
|
755
|
+
}
|
756
|
+
data._popoverinit = true;
|
757
|
+
};
|
758
|
+
|
759
|
+
|
760
|
+
picker.commonDateInit = function(data, popover){
|
761
|
+
var actionfn = function(e){
|
762
|
+
if(!$(this).is('.othermonth') || $(this).css('cursor') == 'pointer'){
|
763
|
+
popover.actionFn({
|
764
|
+
'data-action': $.attr(this, 'data-action'),
|
765
|
+
value: $(this).val() || $.attr(this, 'value')
|
766
|
+
});
|
767
|
+
}
|
768
|
+
return false;
|
769
|
+
};
|
770
|
+
var id = new Date().getTime();
|
771
|
+
var generateList = function(o, max, min){
|
772
|
+
var options = [];
|
773
|
+
var label = '';
|
774
|
+
var labelId = '';
|
775
|
+
o.options = data.getOptions() || {};
|
776
|
+
$('div.ws-options', popover.contentElement).remove();
|
777
|
+
$.each(o.options[0], function(val, label){
|
778
|
+
var disabled = picker.isInRange(val.split('-'), o.maxS, o.minS) ?
|
779
|
+
'' :
|
780
|
+
' disabled="" '
|
781
|
+
;
|
782
|
+
options.push('<li role="presentation"><button value="'+ val +'" '+disabled+' data-action="changeInput" tabindex="-1" role="option">'+ (label || data.formatValue(val, false)) +'</button></li>');
|
783
|
+
});
|
784
|
+
if(options.length){
|
785
|
+
id++;
|
786
|
+
if(o.options[1]){
|
787
|
+
labelId = 'datalist-'+id;
|
788
|
+
label = '<h5 id="'+labelId+'">'+ o.options[1] +'</h5>';
|
789
|
+
labelId = ' aria-labelledbyid="'+ labelId +'" ';
|
790
|
+
}
|
791
|
+
new webshims.ListBox($('<div class="ws-options">'+label+'<ul role="listbox" '+ labelId +'>'+ options.join('') +'</div>').insertAfter(popover.bodyElement)[0], popover, {noFocus: true});
|
792
|
+
}
|
793
|
+
};
|
794
|
+
var updateContent = function(){
|
795
|
+
if(popover.isDirty){
|
796
|
+
var o = data.options;
|
797
|
+
o.maxS = o.max.split('-');
|
798
|
+
o.minS = o.min.split('-');
|
799
|
+
|
800
|
+
$('button', popover.buttonRow).each(function(){
|
801
|
+
var text;
|
802
|
+
if($(this).is('.ws-empty')){
|
803
|
+
text = curCfg.date.clear;
|
804
|
+
if(!text){
|
805
|
+
text = formcfg[''].date.clear || 'clear';
|
806
|
+
webshims.warn("could not get clear text from form cfg");
|
807
|
+
}
|
808
|
+
} else if($(this).is('.ws-current')){
|
809
|
+
text = (curCfg[data.type] || {}).currentText;
|
810
|
+
if(!text){
|
811
|
+
text = (formcfg[''][[data.type]] || {}).currentText || 'current';
|
812
|
+
webshims.warn("could not get currentText from form cfg");
|
813
|
+
}
|
814
|
+
$.prop(this, 'disabled', !picker.isInRange(today[data.type].split('-'), o.maxS, o.minS));
|
815
|
+
}
|
816
|
+
if(text){
|
817
|
+
$(this).text(text).attr({'aria-label': text});
|
818
|
+
if(webshims.assumeARIA){
|
819
|
+
$.attr(this, 'aria-label', text);
|
820
|
+
}
|
821
|
+
}
|
822
|
+
|
823
|
+
});
|
824
|
+
popover.nextElement.attr({'aria-label': curCfg.date.nextText});
|
825
|
+
$('> span', popover.nextElement).html(curCfg.date.nextText);
|
826
|
+
popover.prevElement.attr({'aria-label': curCfg.date.prevText});
|
827
|
+
$('> span', popover.prevElement).html(curCfg.date.prevText);
|
828
|
+
|
829
|
+
generateList(o, o.maxS, o.minS);
|
830
|
+
|
831
|
+
}
|
832
|
+
$('button.ws-empty', popover.buttonRow).prop('disabled', $.prop(data.orig, 'required'));
|
833
|
+
popover.isDirty = false;
|
834
|
+
};
|
835
|
+
|
836
|
+
popover.actionFn = function(obj){
|
837
|
+
if(actions[obj['data-action']]){
|
838
|
+
actions[obj['data-action']](obj.value, popover, data, 0);
|
839
|
+
} else {
|
840
|
+
webshims.warn('no action for '+ obj['data-action']);
|
841
|
+
}
|
842
|
+
};
|
843
|
+
|
844
|
+
popover.contentElement.html('<button class="ws-prev" tabindex="0"><span></span></button> <button class="ws-next" tabindex="0"><span></span></button><div class="ws-picker-body"></div><div class="ws-button-row"><button type="button" class="ws-current" data-action="changeInput" value="'+today[data.type]+'" tabindex="0"></button> <button type="button" data-action="changeInput" value="" class="ws-empty" tabindex="0"></button></div>');
|
845
|
+
popover.nextElement = $('button.ws-next', popover.contentElement);
|
846
|
+
popover.prevElement = $('button.ws-prev', popover.contentElement);
|
847
|
+
popover.bodyElement = $('div.ws-picker-body', popover.contentElement);
|
848
|
+
popover.buttonRow = $('div.ws-button-row', popover.contentElement);
|
849
|
+
popover.element.on('updatepickercontent', updateContent);
|
850
|
+
|
851
|
+
popover.contentElement
|
852
|
+
.on('click', 'button[data-action]', actionfn)
|
853
|
+
.on('change', 'select[data-action]', actionfn)
|
854
|
+
;
|
855
|
+
|
856
|
+
$(data.options.orig).on('input', function(){
|
857
|
+
var currentView;
|
858
|
+
if(data.options.updateOnInput && popover.isVisible && data.options.value && (currentView = popover.element.attr('data-currentview'))){
|
859
|
+
actions[currentView]( data.options.value , popover, data, 0);
|
860
|
+
}
|
861
|
+
});
|
862
|
+
$(document).onTrigger('wslocalechange', data._propertyChange);
|
863
|
+
};
|
864
|
+
|
865
|
+
});
|