Permalink
Browse files

compiled version

  • Loading branch information...
2 parents 3573834 + 9961868 commit abaddbe0888c4985fe3ae9fc01fe0873bf614efc @aFarkas committed Mar 19, 2013
Showing with 49,028 additions and 61 deletions.
  1. +21 −25 grunt.js → Gruntfile.js
  2. +5 −2 build/build.html
  3. +2 −8 demos/demos/webforms/3-webforms-widgets.html
  4. +16 −16 demos/js-webshim/dev/polyfiller.js
  5. +3,266 −0 demos/js-webshim/dev/shims/combos/10.js
  6. +2,275 −0 demos/js-webshim/dev/shims/combos/11.js
  7. +1,955 −0 demos/js-webshim/dev/shims/combos/12.js
  8. +1,449 −0 demos/js-webshim/dev/shims/combos/13.js
  9. +2,102 −0 demos/js-webshim/dev/shims/combos/14.js
  10. +4,243 −0 demos/js-webshim/dev/shims/combos/15.js
  11. +5,381 −0 demos/js-webshim/dev/shims/combos/16.js
  12. +2,785 −0 demos/js-webshim/dev/shims/combos/17.js
  13. +3,588 −0 demos/js-webshim/dev/shims/combos/18.js
  14. +3,828 −0 demos/js-webshim/dev/shims/combos/19.js
  15. +3,322 −0 demos/js-webshim/dev/shims/combos/20.js
  16. +2,031 −0 demos/js-webshim/dev/shims/combos/21.js
  17. +966 −0 demos/js-webshim/dev/shims/combos/22.js
  18. +1,138 −0 demos/js-webshim/dev/shims/combos/23.js
  19. +3,680 −0 demos/js-webshim/dev/shims/combos/7.js
  20. +3,046 −0 demos/js-webshim/dev/shims/combos/8.js
  21. +3,901 −0 demos/js-webshim/dev/shims/combos/9.js
  22. +0 −1 demos/js-webshim/dev/shims/track.js
  23. +1 −1 demos/js-webshim/minified/extras/custom-validity.js
  24. +1 −1 demos/js-webshim/minified/extras/modernizr-custom.js
  25. +1 −1 demos/js-webshim/minified/extras/mousepress.js
  26. +1 −1 demos/js-webshim/minified/polyfiller.js
  27. +1 −1 demos/js-webshim/minified/shims/FlashCanvas/canvas2png.js
  28. +1 −1 demos/js-webshim/minified/shims/FlashCanvas/flashcanvas.js
  29. +1 −1 demos/js-webshim/minified/shims/FlashCanvasPro/canvas2png.js
  30. +1 −1 demos/js-webshim/minified/shims/FlashCanvasPro/flashcanvas.js
  31. +1 −1 demos/js-webshim/minified/shims/combos/1.js
  32. +2 −0 demos/js-webshim/minified/shims/combos/10.js
  33. +2 −0 demos/js-webshim/minified/shims/combos/11.js
  34. +1 −0 demos/js-webshim/minified/shims/combos/12.js
  35. +1 −0 demos/js-webshim/minified/shims/combos/13.js
  36. +1 −0 demos/js-webshim/minified/shims/combos/14.js
  37. +3 −0 demos/js-webshim/minified/shims/combos/15.js
  38. +3 −0 demos/js-webshim/minified/shims/combos/16.js
  39. +2 −0 demos/js-webshim/minified/shims/combos/17.js
  40. +2 −0 demos/js-webshim/minified/shims/combos/18.js
  41. +2 −0 demos/js-webshim/minified/shims/combos/19.js
Sorry, we could not display the entire diff because it was too big.
View
46 grunt.js → Gruntfile.js
@@ -11,9 +11,8 @@ module.exports = function(grunt){
},
//concat is changed through webshimscombos
concat: {},
- //copy and min are changed through cfgcopymin
+ //copy and uglify are changed through cfgcopymin
copy: {},
- min: {},
cssmin: getFiles('src', 'demos/js-webshim/minified', '**/*.css'),
uglify: {
codegen: {ascii_only: true}
@@ -25,22 +24,20 @@ module.exports = function(grunt){
});
grunt.registerTask('webshimscombos', 'create combos from polyfiller.js.', function() {
+ var phantomjs = require('phantomjs');
var done = this.async();
var combos = {};
- grunt.utils.spawn({
- cmd: 'phantomjs',
+ grunt.util.spawn({
+ cmd: phantomjs.path,
args: [
- // PhantomJS options.
- '--config={}',
// The main script file.
'build/combobuild.js',
- // The temporary file used for communications.
- '',
// The QUnit helper file to be injected.
'build/build.html'
]
},
function(err, result, code) {
+ result = result.toString();
if(!err && result.indexOf && result.indexOf('done') == -1){
try {
@@ -58,14 +55,6 @@ module.exports = function(grunt){
grunt.verbose.or.writeln();
grunt.log.write('Running PhantomJS...').error();
if (code === 127) {
- grunt.log.errorlns(
- 'In order for this task to work properly, PhantomJS must be ' +
- 'installed and in the system PATH (if you can run "phantomjs" at' +
- ' the command line, this task should work). Unfortunately, ' +
- 'PhantomJS cannot be installed automatically via npm or grunt. ' +
- 'See the grunt FAQ for PhantomJS installation instructions: ' +
- 'https://github.com/gruntjs/grunt/blob/master/docs/faq.md'
- );
grunt.warn('PhantomJS not found.');
} else {
result.split('\n').forEach(grunt.log.error, grunt.log);
@@ -84,29 +73,36 @@ module.exports = function(grunt){
for(var i in files){
file = files[i];
- if(grunt.file.isMatch('*.*', file)){
+ if(grunt.file.isFile(file)){
minPath = path.join('demos/js-webshim/minified', i);
- if(grunt.file.isMatch('*.js', file)){
- minTask[minPath] = file;
+ if(/\.js$/.test(file)){
+ minTask[minPath] = [file];
found = true;
}
- copyTask[minPath] = file;
- copyTask[path.join('demos/js-webshim/dev', i)] = file;
+ copyTask[minPath] = [file];
+ copyTask[path.join('demos/js-webshim/dev', i)] = [file];
}
}
if(!found){
minTask[path.join('demos/js-webshim/minified', 'polyfiller.js')] = path.join('src', 'polyfiller.js');
}
- grunt.config('min', minTask);
- grunt.config('copy', copyTask);
+ var uglifyCfg = grunt.config('uglify');
+ var copyCfg = grunt.config('copy');
+ uglifyCfg.dist = { 'files': minTask };
+ copyCfg.dist = { 'files': copyTask };
+ grunt.config('uglify', uglifyCfg);
+ grunt.config('copy', copyCfg);
});
// Default task.
+ grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-css');
- grunt.registerTask('default', 'webshimscombos concat cfgcopymin copy cssmin min');
+ grunt.registerTask('default', ['webshimscombos', 'concat', 'cfgcopymin', 'copy', 'cssmin', 'uglify']);
- grunt.registerTask('css', 'cfgcopymin copy');
+ grunt.registerTask('css', ['cfgcopymin', 'copy']);
View
7 build/build.html
@@ -21,21 +21,24 @@
<script src="../src/polyfiller.js"></script>
<script>
- (function($){
+ (function($, r){
var combos = {};
var makeFile = function(file){
return 'src/shims/'+file+'.js';
};
$.each($.webshims.c, function(c, srces){
combos['src/shims/combos/'+c+'.js'] = $.map(srces, makeFile);
});
+ if(r.console){
+ r.console.log(combos);
+ }
combos = JSON.stringify(combos);
$('textarea').val(combos);
setTimeout(function(){
alert(combos);
}, 0);
- })(jQuery);
+ })(jQuery, this);
</script>
</body>
View
10 demos/demos/webforms/3-webforms-widgets.html
@@ -52,14 +52,8 @@
<script src="../../js-webshim/minified/extras/mousepress.js"></script>
<script src="../../js-webshim/minified/extras/modernizr-custom.js"></script>
- <script src="../../../src/polyfiller.js"></script>
- <script>
- $.webshims.debug = 'noCombo';
- </script>
-
- <!--
-
- -->
+ <script src="../../js-webshim/minified/polyfiller.js"></script>
+
<script class="example">
View
32 demos/js-webshim/dev/polyfiller.js
@@ -844,7 +844,7 @@
}
return ('swfmini' in window);
},
- c: [2, 1]
+ c: [16, 7, 2, 8, 1, 12, 19, 23]
});
modules.swfmini.test();
@@ -855,14 +855,14 @@
// webshims lib uses a of http://github.com/kriskowal/es5-shim/ to implement
addPolyfill('es5', {
test: !!(Modernizr.ES5 && Function.prototype.bind),
- c: []
+ c: [14, 18, 19, 20]
});
addPolyfill('dom-extend', {
f: DOMSUPPORT,
noAutoCallback: true,
d: ['es5'],
- c: [2, 3, 4]
+ c: [16, 7, 2, 15, 3, 8, 4, 9, 10, 14, 19, 20]
});
@@ -872,7 +872,7 @@
test: Modernizr.localstorage && 'sessionStorage' in window && 'JSON' in window,
d: ['swfmini'],
noAutoCallback: true,
- c: [],
+ c: [14],
nM: 'localstorage'
});
//>json-storage
@@ -887,7 +887,7 @@
// ,confirmText: ''
},
d: ['json-storage'],
- c: [],
+ c: [21],
nM: 'geolocation'
});
//>
@@ -1012,7 +1012,7 @@
// replaceValidationUI: false
},
methodNames: ['setCustomValidity','checkValidity'],
- c: [2, 1, 3],
+ c: [16, 7, 2, 8, 1, 15, 3],
nM: 'input'
});
@@ -1033,7 +1033,7 @@
return Modernizr[formvalidation] && !bustedValidity;
},
d: ['form-core', DOMSUPPORT],
- c: []
+ c: [16, 15]
});
addPolyfill('form-message', {
@@ -1042,7 +1042,7 @@
return !( formOptions.customMessages || !Modernizr[formvalidation] || bugs.validationMessage || bustedValidity || !modules[formExtend].test(toLoad) );
},
d: [DOMSUPPORT],
- c: [3, 4]
+ c: [16, 7, 15, 3, 8, 4]
});
addPolyfill('form-number-date-api', {
@@ -1063,14 +1063,14 @@
},
methodNames: ['stepUp', 'stepDown'],
d: ['forms', DOMSUPPORT],
- c: [6, 5],
+ c: [6, 5, 18, 17],
nM: 'input inputtypes'
});
$.webshims.loader.addModule('range-ui', {
options: {},
noAutoCallback: true,
- c: [6, 5]
+ c: [6, 5, 9, 10, 18, 17, 11]
});
addPolyfill('form-number-date-ui', {
@@ -1089,7 +1089,7 @@
}
// ,replaceUI: false
},
- c: [6, 5]
+ c: [6, 5, 9, 10, 18, 17, 11]
});
addPolyfill('form-datalist', {
@@ -1098,7 +1098,7 @@
return modernizrInputAttrs.list && !formOptions.customDatalist;
},
d: ['form-core', DOMSUPPORT],
- c: [6, 2]
+ c: [16, 7, 6, 2, 9, 15]
});
})();
//>
@@ -1116,7 +1116,7 @@
// animate: false,
text: 'Details'
},
- c: []
+ c: [21, 22]
});
//>
@@ -1149,7 +1149,7 @@
},
methodNames: ['play', 'pause', 'canPlayType', 'mediaLoad:load'],
d: ['swfmini'],
- c: [2, 1],
+ c: [16, 7, 2, 8, 1, 12, 13, 19, 20, 23],
nM: 'audio video texttrackapi'
});
addPolyfill('mediaelement-swf', {
@@ -1166,7 +1166,7 @@
test: function(){
return this.options.player == 'jwplayer' ? true : swfTest.apply(this, arguments);
},
- c: []
+ c: [21, 19, 20]
});
bugs.track = (Modernizr.track && (!Modernizr.texttrackapi || typeof (document.createElement('track').track || {}).mode != 'string'));
@@ -1181,7 +1181,7 @@
},
d: ['mediaelement', DOMSUPPORT],
methodNames: ['addTextTrack'],
- c: [],
+ c: [21, 12, 13, 22],
nM: 'texttrackapi'
});
View
3,266 demos/js-webshim/dev/shims/combos/10.js
3,266 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2,275 demos/js-webshim/dev/shims/combos/11.js
@@ -0,0 +1,2275 @@
+(function($){
+
+ var id = 0;
+ var isNumber = function(string){
+ return (typeof string == 'number' || (string && string == string * 1));
+ };
+ var retDefault = function(val, def){
+ if(!(typeof val == 'number' || (val && val == val * 1))){
+ return def;
+ }
+ return val * 1;
+ };
+ var createOpts = ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex'];
+ var rangeProto = {
+ _create: function(){
+ var i;
+
+
+ this.element.addClass('ws-range').attr({role: 'slider'}).html('<span class="ws-range-min" /><span class="ws-range-rail"><span class="ws-range-thumb" /></span>');
+ this.trail = $('.ws-range-rail', this.element);
+ this.range = $('.ws-range-min', this.element);
+ this.thumb = $('.ws-range-thumb', this.trail);
+
+ this.updateMetrics();
+
+ this.orig = this.options.orig;
+
+ for(i = 0; i < createOpts.length; i++){
+ this[createOpts[i]](this.options[createOpts[i]]);
+ }
+ this.value = this._value;
+ this.value(this.options.value);
+ this.initDataList();
+ this.element.data('rangeUi', this);
+ this.addBindings();
+ this._init = true;
+ },
+ value: $.noop,
+ _value: function(val, _noNormalize, animate){
+ var left, posDif;
+ var o = this.options;
+ var oVal = val;
+ var thumbStyle = {};
+ var rangeStyle = {};
+ if(!_noNormalize && parseFloat(val, 10) != val){
+ val = o.min + ((o.max - o.min) / 2);
+ }
+
+ if(!_noNormalize){
+ val = this.normalizeVal(val);
+ }
+ left = 100 * ((val - o.min) / (o.max - o.min));
+
+ this.options.value = val;
+ this.thumb.stop();
+ this.range.stop();
+
+ rangeStyle[this.dirs.width] = left+'%';
+ if(this.vertical){
+ left = Math.abs(left - 100);
+ }
+ thumbStyle[this.dirs.left] = left+'%';
+
+
+ if(!animate){
+ this.thumb.css(thumbStyle);
+ this.range.css(rangeStyle);
+ } else {
+ if(typeof animate != 'object'){
+ animate = {};
+ posDif = Math.abs(left - parseInt(this.thumb[0].style[this.dirs.left] || 50, 10));
+ animate.duration = Math.max(Math.min(999, posDif * 5), 99);
+ }
+ this.thumb.animate(thumbStyle, animate);
+ this.range.animate(rangeStyle, animate);
+ }
+ if(this.orig && (oVal != val || (!this._init && this.orig.value != val)) ){
+ this.options._change(val);
+ }
+ this.element.attr({
+ 'aria-valuenow': this.options.value,
+ 'aria-valuetext': this.options.textValue ? this.options.textValue(this.options.value) : this.options.options[this.options.value] || this.options.value
+ });
+ },
+ initDataList: function(){
+ if(this.orig){
+ var listTimer;
+ var that = this;
+ var updateList = function(){
+ $(that.orig)
+ .jProp('list')
+ .off('updateDatalist', updateList)
+ .on('updateDatalist', updateList)
+ ;
+ clearTimeout(listTimer);
+ listTimer = setTimeout(function(){
+ if(that.list){
+ that.list();
+ }
+ }, 9);
+
+ };
+
+ $(this.orig).on('listdatalistchange', updateList);
+ this.list();
+ }
+ },
+ list: function(opts){
+ var o = this.options;
+ var min = o.min;
+ var max = o.max;
+ var trail = this.trail;
+ var that = this;
+
+ this.element.attr({'aria-valuetext': o.options[o.value] || o.value});
+ $('.ws-range-ticks', trail).remove();
+
+
+ $(this.orig).jProp('list').find('option').each(function(){
+ o.options[$.prop(this, 'value')] = $.prop(this, 'label');
+ });
+
+ $.each(o.options, function(val, label){
+ if(!isNumber(val) || val < min || val > max){return;}
+ var left = 100 * ((val - min) / (max - min));
+ var title = o.showLabels ? ' title="'+ label +'"' : '';
+ if(that.vertical){
+ left = Math.abs(left - 100);
+ }
+ trail.append('<span class="ws-range-ticks"'+ title +' style="'+(that.dirs.left)+': '+left+'%;" />');
+ });
+ },
+ readonly: function(val){
+ val = !!val;
+ this.options.readonly = val;
+ this.element.attr('aria-readonly', ''+val);
+ },
+ disabled: function(val){
+ val = !!val;
+ this.options.disabled = val;
+ if(val){
+ this.element.attr({tabindex: -1, 'aria-disabled': 'true'});
+ } else {
+ this.element.attr({tabindex: this.options.tabindex, 'aria-disabled': 'false'});
+ }
+ },
+ tabindex: function(val){
+ this.options.tabindex = val;
+ if(!this.options.disabled){
+ this.element.attr({tabindex: val});
+ }
+ },
+ title: function(val){
+ this.element.prop('title', val);
+ },
+ min: function(val){
+ this.options.min = retDefault(val, 0);
+ this.value(this.options.value, true);
+ },
+ max: function(val){
+ this.options.max = retDefault(val, 100);
+ this.value(this.options.value, true);
+ },
+ step: function(val){
+ this.options.step = val == 'any' ? 'any' : retDefault(val, 1);
+ this.value(this.options.value);
+ },
+
+ normalizeVal: function(val){
+ var valModStep, alignValue, step;
+ var o = this.options;
+
+ if(val <= o.min){
+ val = o.min;
+ } else if(val >= o.max) {
+ val = o.max;
+ } else if(o.step != 'any'){
+ step = o.step;
+ valModStep = (val - o.min) % step;
+ alignValue = val - valModStep;
+
+ if ( Math.abs(valModStep) * 2 >= step ) {
+ alignValue += ( valModStep > 0 ) ? step : ( -step );
+ }
+ val = alignValue.toFixed(5) * 1;
+ }
+ return val;
+ },
+ doStep: function(factor, animate){
+ var step = retDefault(this.options.step, 1);
+ if(this.options.step == 'any'){
+ step = Math.min(step, (this.options.max - this.options.min) / 10);
+ }
+ this.value( this.options.value + (step * factor), false, animate );
+
+ },
+
+ getStepedValueFromPos: function(pos){
+ var val, valModStep, alignValue, step;
+
+ if(pos <= 0){
+ val = this.options[this.dirs.min];
+ } else if(pos > 100) {
+ val = this.options[this.dirs.max];
+ } else {
+ if(this.vertical){
+ pos = Math.abs(pos - 100);
+ }
+ val = ((this.options.max - this.options.min) * (pos / 100)) + this.options.min;
+ step = this.options.step;
+ if(step != 'any'){
+ valModStep = (val - this.options.min) % step;
+ alignValue = val - valModStep;
+
+ if ( Math.abs(valModStep) * 2 >= step ) {
+ alignValue += ( valModStep > 0 ) ? step : ( -step );
+ }
+ val = ((alignValue).toFixed(5)) * 1;
+
+ }
+ }
+
+ return val;
+ },
+ addBindings: function(){
+ var leftOffset, widgetUnits, hasFocus;
+ var that = this;
+ var o = this.options;
+
+ var eventTimer = (function(){
+ var events = {};
+ return {
+ init: function(name, curVal, fn){
+ if(!events[name]){
+ events[name] = {fn: fn};
+ if(that.orig){
+ $(that.orig).on(name, function(){
+ events[name].val = $.prop(that.orig, 'value');
+ });
+ }
+
+ }
+ events[name].val = curVal;
+ },
+ call: function(name, val){
+ if(events[name].val != val){
+ clearTimeout(events[name].timer);
+ events[name].val = val;
+ events[name].timer = setTimeout(function(){
+ events[name].fn(val, that);
+ }, 0);
+ }
+ }
+ };
+ })();
+
+ var setValueFromPos = function(e, animate){
+
+ var val = that.getStepedValueFromPos((e[that.dirs.mouse] - leftOffset) * widgetUnits);
+ if(val != o.value){
+ that.value(val, false, animate);
+ eventTimer.call('input', val);
+ }
+ };
+
+ var remove = function(e){
+ if(e && e.type == 'mouseup'){
+ eventTimer.call('input', o.value);
+ eventTimer.call('change', o.value);
+ }
+ that.element.removeClass('ws-active');
+ $(document).off('mousemove', setValueFromPos).off('mouseup', remove);
+ };
+ var add = function(e){
+ e.preventDefault();
+ $(document).off('mousemove', setValueFromPos).off('mouseup', remove);
+ if(!o.readonly && !o.disabled){
+ leftOffset = that.element.focus().addClass('ws-active').offset();
+ widgetUnits = that.element[that.dirs.width]();
+ if(!widgetUnits || !leftOffset){return;}
+ leftOffset = leftOffset[that.dirs.pos];
+ widgetUnits = 100 / (widgetUnits - ((that.thumb[that.dirs.outerWidth]() || 2) / 2));
+ setValueFromPos(e, o.animate);
+ $(document)
+ .on({
+ mouseup: remove,
+ mousemove: setValueFromPos
+ })
+ ;
+ e.stopPropagation();
+ }
+ };
+ var elementEvts = {
+ mousedown: add,
+ focus: function(e){
+ if(!o.disabled){
+ eventTimer.init('input', o.value);
+ eventTimer.init('change', o.value);
+ that.element.addClass('ws-focus');
+ }
+ hasFocus = true;
+ },
+ blur: function(e){
+ that.element.removeClass('ws-focus ws-active');
+ hasFocus = false;
+ eventTimer.init('input', o.value);
+ eventTimer.call('change', o.value);
+ },
+ keyup: function(){
+ that.element.removeClass('ws-active');
+ eventTimer.call('input', o.value);
+ eventTimer.call('change', o.value);
+ },
+
+ keydown: function(e){
+ var step = true;
+ var code = e.keyCode;
+ if(!o.readonly && !o.disabled){
+ if (code == 39 || code == 38) {
+ that.doStep(1);
+ } else if (code == 37 || code == 40) {
+ that.doStep(-1);
+ } else if (code == 33) {
+ that.doStep(10, o.animate);
+ } else if (code == 34) {
+ that.doStep(-10, o.animate);
+ } else if (code == 36) {
+ that.value(that.options.max, false, o.animate);
+ } else if (code == 35) {
+ that.value(that.options.min, false, o.animate);
+ } else {
+ step = false;
+ }
+ if (step) {
+ that.element.addClass('ws-active');
+ eventTimer.call('input', o.value);
+ e.preventDefault();
+ }
+ }
+ }
+ };
+
+ eventTimer.init('input', o.value, this.options.input);
+ eventTimer.init('change', o.value, this.options.change);
+
+ elementEvts[$.fn.mwheelIntent ? 'mwheelIntent' : 'mousewheel'] = function(e, delta){
+ if(delta && hasFocus && !o.readonly && !o.disabled){
+ that.doStep(delta);
+ e.preventDefault();
+ eventTimer.call('input', o.value);
+ }
+ };
+ this.element.on(elementEvts);
+ this.thumb.on({
+ mousedown: add
+ });
+ },
+ updateMetrics: function(){
+ var width = this.element.innerWidth();
+ this.vertical = (width && this.element.innerHeight() - width > 10);
+
+ this.dirs = this.vertical ?
+ {mouse: 'pageY', pos: 'top', min: 'max', max: 'min', left: 'top', width: 'height', outerWidth: 'outerHeight'} :
+ {mouse: 'pageX', pos: 'left', min: 'min', max: 'max', left: 'left', width: 'width', outerWidth: 'outerWidth'}
+ ;
+ this.element
+ [this.vertical ? 'addClass' : 'removeClass']('vertical-range')
+ [this.vertical ? 'addClass' : 'removeClass']('horizontal-range')
+ ;
+ }
+ };
+
+ $.fn.rangeUI = function(opts){
+ opts = $.extend({readonly: false, disabled: false, tabindex: 0, min: 0, step: 1, max: 100, value: 50, input: $.noop, change: $.noop, _change: $.noop, showLabels: true}, opts);
+ return this.each(function(){
+ $.webshims.objectCreate(rangeProto, {
+ element: {
+ value: $(this)
+ }
+ }, opts);
+ });
+ };
+ jQuery.webshims.isReady('range-ui', true);
+})(jQuery);
+jQuery.webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
+ "use strict";
+ var curCfg;
+ var formcfg = $.webshims.formcfg;
+ var stopPropagation = function(e){
+ e.stopImmediatePropagation(e);
+ };
+ var labelWidth = (function(){
+ var getId = function(){
+ return webshims.getID(this);
+ };
+ return function(element, labels, noFocus){
+ $(element).attr({'aria-labelledby': labels.map(getId).get().join(' ')});
+ if(!noFocus){
+ labels.on('click', function(e){
+ element.focus();
+ e.preventDefault();
+ return false;
+ });
+ }
+ };
+ })();
+ var addZero = function(val){
+ if(!val){return "";}
+ val = val+'';
+ return val.length == 1 ? '0'+val : val;
+ };
+
+
+ (function(){
+
+
+ formcfg.de = {
+ numberFormat: {
+ ",": ".",
+ ".": ","
+ },
+ timeSigns: ":. ",
+ numberSigns: ',',
+ dateSigns: '.',
+ dFormat: ".",
+ patterns: {
+ d: "dd.mm.yy"
+ },
+ month: {
+ currentText: 'Aktueller Monat'
+ },
+ date: {
+ close: 'schließen',
+ clear: 'Löschen',
+ prevText: 'Zurück',
+ nextText: 'Vor',
+ currentText: 'Heute',
+ monthNames: ['Januar','Februar','März','April','Mai','Juni',
+ 'Juli','August','September','Oktober','November','Dezember'],
+ monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
+ 'Jul','Aug','Sep','Okt','Nov','Dez'],
+ dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
+ dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
+ dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
+ weekHeader: 'KW',
+ firstDay: 1,
+ isRTL: false,
+ showMonthAfterYear: false,
+ yearSuffix: ''
+ }
+ };
+
+ formcfg.en = {
+ numberFormat: {
+ ".": ".",
+ ",": ","
+ },
+ numberSigns: '.',
+ dateSigns: '/',
+ timeSigns: ":. ",
+ dFormat: "/",
+ patterns: {
+ d: "mm/dd/yy"
+ },
+ month: {
+ currentText: 'This month'
+ },
+ date: {
+ "closeText": "Done",
+ clear: 'Clear',
+ "prevText": "Prev",
+ "nextText": "Next",
+ "currentText": "Today",
+ "monthNames": ["January","February","March","April","May","June","July","August","September","October","November","December"],
+ "monthNamesShort": ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],
+ "dayNames": ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
+ "dayNamesShort": ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],
+ "dayNamesMin": ["Su","Mo","Tu","We","Th","Fr","Sa"],
+ "weekHeader": "Wk",
+ "firstDay": 0,
+ "isRTL": false,
+ "showMonthAfterYear": false,
+ "yearSuffix": ""
+ }
+ };
+
+ formcfg['en-US'] = formcfg['en-US'] || formcfg['en'];
+ formcfg[''] = formcfg[''] || formcfg['en-US'];
+ curCfg = formcfg[''];
+
+ var createMonthKeys = function(langCfg){
+ if(!langCfg.date.monthkeys){
+ var create = function(i, name){
+ var strNum;
+ var num = i + 1;
+ strNum = (num < 10) ? '0'+num : ''+num;
+
+ langCfg.date.monthkeys[num] = strNum;
+ langCfg.date.monthkeys[name] = strNum;
+ };
+ langCfg.date.monthkeys = {};
+ $.each(langCfg.date.monthNames, create);
+ $.each(langCfg.date.monthNamesShort, create);
+ }
+ };
+
+ createMonthKeys(curCfg);
+ $.webshims.ready('dom-extend', function(){
+ $.webshims.activeLang({
+ register: 'form-core',
+ callback: function(){
+ $.each(arguments, function(i, val){
+ if(formcfg[val]){
+ curCfg = formcfg[val];
+ createMonthKeys(curCfg);
+ $(document).triggerHandler('wslocalechange');
+ return false;
+ }
+ });
+ }
+ });
+ });
+ })();
+
+
+
+ (function(){
+
+
+ var mousePress = function(e){
+ $(this)[e.type == 'mousepressstart' ? 'addClass' : 'removeClass']('mousepress-ui');
+ };
+
+ var retDefault = function(val, def){
+ if(!(typeof val == 'number' || (val && val == val * 1))){
+ return def;
+ }
+ return val * 1;
+ };
+
+ var createOpts = ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'value'];
+
+ var createFormat = function(name){
+ if(!curCfg.patterns[name+'Obj']){
+ var obj = {};
+ $.each(curCfg.patterns[name].split(curCfg[name+'Format']), function(i, name){
+ obj[name] = i;
+ });
+ curCfg.patterns[name+'Obj'] = obj;
+ }
+ };
+
+ var formatVal = {
+ number: function(val){
+ return (val+'').replace(/\,/g, '').replace(/\./, curCfg.numberFormat['.']);
+ },
+ time: function(val){
+ return val;
+ },
+ month: function(val, options){
+ var names;
+ var p = val.split('-');
+ if(p[0] && p[1]){
+ names = curCfg.date[options.monthNames] || curCfg.date.monthNames;
+ p[1] = names[(p[1] * 1) - 1];
+ if(p[1]){
+ val = curCfg.date.showMonthAfterYear ? p.join(' ') : p[1]+' '+p[0];
+ }
+ }
+ return val;
+ },
+ date: function(val){
+ var p = (val+'').split('-');
+ if(p[2] && p[1] && p[0]){
+ val = curCfg.patterns.d.replace('yy', p[0] || '');
+ val = val.replace('mm', p[1] || '');
+ val = val.replace('dd', p[2] || '');
+ }
+
+ return val;
+ }
+ };
+
+ var parseVal = {
+ number: function(val){
+ return (val+'').replace(curCfg.numberFormat[','], '').replace(curCfg.numberFormat['.'], '.');
+ },
+ time: function(val){
+ return val;
+ },
+ month: function(val){
+ var p = val.trim().split(/[\s-\/\\]+/);
+ if(p.length == 2){
+ p[0] = curCfg.date.monthkeys[p[0]] || p[0];
+ p[1] = curCfg.date.monthkeys[p[1]] || p[1];
+ if(p[1].length == 2){
+ val = p[0]+'-'+p[1];
+ } else if(p[0].length == 2){
+ val = p[1]+'-'+p[0];
+ }
+ }
+ return val;
+ },
+ date: function(val){
+ createFormat('d');
+ var i;
+ var obj = curCfg.patterns.dObj;
+ val = val.split(curCfg.dFormat);
+ return val.length == 3 ? ([addZero(val[obj.yy]), addZero(val[obj.mm]), addZero(val[obj.dd])]).join('-') : '';
+ }
+ };
+
+ var steps = {
+ number: {
+ step: 1
+ },
+ time: {
+ step: 60
+ },
+ month: {
+ step: 1,
+ start: new Date()
+ },
+ date: {
+ step: 1,
+ start: new Date()
+ }
+ };
+
+ var createAsNumber = (function(){
+ var types = {};
+ return function(type){
+ var input;
+ if(!types[type]){
+ input = $('<input type="'+type+'" />');
+ types[type] = function(val){
+ var type = (typeof val == 'object') ? 'valueAsDate' : 'value';
+ return input.prop(type, val).prop('valueAsNumber');
+ };
+ }
+ return types[type];
+ };
+ })();
+
+ steps.range = steps.number;
+
+
+ var spinBtnProto = {
+ _create: function(){
+ var i;
+ this.type = this.options.type;
+ this.orig = this.options.orig;
+ this.elemHelper = $('<input type="'+ this.type+'" />');
+ this.asNumber = createAsNumber(this.type);
+ this.buttonWrapper = $('<span class="input-buttons '+this.type+'-input-buttons"><span unselectable="on" class="step-controls"><span class="step-up"></span><span class="step-down"></span></span></span>')
+ .insertAfter(this.element)
+ ;
+
+ this.options.containerElements.push(this.buttonWrapper[0]);
+
+ if(typeof steps[this.type].start == 'object'){
+ steps[this.type].start = this.asNumber(steps[this.type].start);
+ }
+
+
+
+ for(i = 0; i < createOpts.length; i++){
+ this[createOpts[i]](this.options[createOpts[i]]);
+ }
+ var elem = this.element.attr('autocomplete', 'off').data('wsspinner', this);
+ this.addBindings();
+ this._init = true;
+ },
+ parseValue: function(val){
+ return parseVal[this.type](val);
+ },
+ formatValue: function(val){
+ return formatVal[this.type](val, this.options);
+ },
+ placeholder: function(val){
+ var hintValue;
+ this.options.placeholder = val;
+ if(this.type == 'date'){
+ hintValue = (val || '').split('-');
+ if(hintValue.length == 3){
+ this.options.placeholder = curCfg.patterns.d.replace('yy', hintValue[0]).replace('mm', hintValue[1]).replace('dd', hintValue[2]);
+ }
+ }
+ this.element.prop('placeholder', this.options.placeholder);
+ },
+
+ addZero: addZero,
+ _setStartInRange: function(){
+ var start = steps[this.type].start || 0;
+ if(this.options.relDefaultValue){
+ start += this.options.relDefaultValue;
+ }
+ if(!isNaN(this.minAsNumber) && start < this.minAsNumber){
+ start = this.minAsNumber;
+ } else if(!isNaN(this.maxAsNumber) && start > this.maxAsNumber){
+ start = this.maxAsNumber;
+ }
+ this.elemHelper.prop('valueAsNumber', start).prop('value');
+ this.options.defValue = this.elemHelper.prop('value');
+
+ },
+ value: function(val){
+ this.valueAsNumber = this.asNumber(val);
+ this.options.value = val;
+ if(isNaN(this.valueAsNumber)){
+ this._setStartInRange();
+ } else {
+ this.elemHelper.prop('value', val);
+ this.options.defValue = "";
+ }
+
+ this.element.prop('value', formatVal[this.type](val, this.options));
+ this._propertyChange('value');
+ },
+ initDataList: function(){
+ var listTimer;
+ var that = this;
+ var updateList = function(){
+ $(that.orig)
+ .jProp('list')
+ .off('updateDatalist', updateList)
+ .on('updateDatalist', updateList)
+ ;
+ clearTimeout(listTimer);
+ listTimer = setTimeout(function(){
+ if(that.list){
+ that.list();
+ }
+ }, 9);
+
+ };
+
+ $(this.orig).onTrigger('listdatalistchange', updateList);
+ },
+ getOptions: function(){
+ var options = {};
+ var datalist = $(this.orig).jProp('list');
+ datalist.find('option').each(function(){
+ options[$.prop(this, 'value')] = $.prop(this, 'label');
+ });
+ return [options, datalist.data('label')];
+ },
+ list: function(val){
+ if(this.type == 'number' || this.type == 'time'){
+ this.element.attr('list', $.attr(this.orig, 'list'));
+ }
+ this.options.list = val;
+ this._propertyChange('list');
+ },
+ _propertyChange: $.noop,
+ tabindex: function(val){
+ this.options.tabindex = val;
+ this.element.prop('tabindex', this.options.tabindex);
+ },
+ title: function(val){
+ this.options.title = val;
+ this.element.prop('tabindex', this.options.title);
+ },
+
+ min: function(val){
+ this.elemHelper.prop('min', val);
+ this.minAsNumber = this.asNumber(val);
+ if(this.valueAsNumber != null && isNaN(this.valueAsNumber)){
+ this._setStartInRange();
+ }
+ this.options.min = val;
+ this._propertyChange('min');
+ },
+ max: function(val){
+ this.elemHelper.prop('max', val);
+ this.maxAsNumber = this.asNumber(val);
+ if(this.valueAsNumber != null && isNaN(this.valueAsNumber)){
+ this._setStartInRange();
+ }
+ this.options.max = val;
+ this._propertyChange('max');
+ },
+ step: function(val){
+ var defStep = steps[this.type];
+ this.options.step = val;
+ this.elemHelper.prop('step', retDefault(val, defStep.step));
+ },
+ addBindings: function(){
+ var isFocused;
+
+ var that = this;
+ var o = this.options;
+
+ var eventTimer = (function(){
+ var events = {};
+ return {
+ init: function(name, curVal, fn){
+ if(!events[name]){
+ events[name] = {fn: fn};
+ $(that.orig).on(name, function(){
+ events[name].val = $.prop(that.orig, 'value');
+ });
+ }
+ events[name].val = curVal;
+ },
+ call: function(name, val){
+ if(events[name] && events[name].val != val){
+ clearTimeout(events[name].timer);
+ events[name].val = val;
+ events[name].timer = setTimeout(function(){
+ events[name].fn(val, that);
+ }, 0);
+ }
+ }
+ };
+ })();
+
+ var step = {};
+
+ var preventBlur = function(e){
+ if(preventBlur.prevent){
+ e.preventDefault();
+ that.element.focus();
+ e.stopImmediatePropagation();
+ return true;
+ }
+ };
+ var elementEvts = {
+ blur: function(e){
+ if(!preventBlur(e) && !o.disabled && !o.readonly){
+ eventTimer.call('input', $.prop(that.orig, 'value'));
+ eventTimer.call('change', $.prop(that.orig, 'value'));
+ if(!preventBlur.prevent){
+ isFocused = false;
+ }
+ }
+ },
+ focus: function(){
+ eventTimer.init('input', $.prop(that.orig, 'value'), that.options.input);
+ eventTimer.init('change', $.prop(that.orig, 'value'), that.options.change);
+ isFocused = true;
+ },
+ change: function(){
+ var val = parseVal[that.type]($.prop(this, 'value'));
+ $.prop(that.orig, 'value', val);
+ eventTimer.call('input', val);
+ eventTimer.call('change', val);
+ },
+ keydown: function(e){
+ if(e.isDefaultPrevented()){return;}
+ var stepped = true;
+ var code = e.keyCode;
+ if (code == 38) {
+ step.stepUp();
+ } else if (code == 40) {
+ step.stepDown();
+ } else {
+ stepped = false;
+ }
+ if(stepped){
+ e.preventDefault();
+ }
+ },
+ keypress: function(e){
+ if(e.isDefaultPrevented()){return;}
+ var chr;
+ var stepped = true;
+ var code = e.keyCode;
+ if(!e.ctrlKey && !e.metaKey && curCfg[that.type+'Signs']){
+ chr = String.fromCharCode(e.charCode == null ? code : e.charCode);
+ stepped = !(chr < " " || (curCfg[that.type+'Signs']+'0123456789').indexOf(chr) > -1);
+ } else {
+ stepped = false;
+ }
+ if(stepped){
+ e.preventDefault();
+ }
+ }
+ };
+ var mouseDownInit = function(){
+ if(!o.disabled && !isFocused){
+ that.element[0].focus();
+ }
+ preventBlur.set();
+
+ return false;
+ };
+
+ preventBlur.set = (function(){
+ var timer;
+ var reset = function(){
+ preventBlur.prevent = false;
+ };
+ return function(){
+ clearTimeout(timer);
+ preventBlur.prevent = true;
+ setTimeout(reset, 9);
+ };
+ })();
+
+ ['stepUp', 'stepDown'].forEach(function(name){
+ step[name] = function(factor){
+ if(!o.disabled && !o.readonly){
+ if(!isFocused){
+ mouseDownInit();
+ }
+ var ret = false;
+ if (!factor) {
+ factor = 1;
+ }
+ try {
+ that.elemHelper[name](factor);
+ ret = that.elemHelper.prop('value');
+ that.value(ret);
+ eventTimer.call('input', ret);
+ } catch (er) {}
+ return ret;
+ }
+ };
+ });
+
+
+ this.buttonWrapper.on('mousedown', mouseDownInit);
+
+ this.setInput = function(value){
+ that.value(value);
+ eventTimer.call('input', value);
+ };
+ this.setChange = function(value){
+ that.setInput(value);
+ eventTimer.call('change', value);
+ };
+ elementEvts[$.fn.mwheelIntent ? 'mwheelIntent' : 'mousewheel'] = function(e, delta){
+ if(delta && isFocused && !o.disabled){
+ step[delta > 0 ? 'stepUp' : 'stepDown']();
+ e.preventDefault();
+ }
+ };
+ this.element.on(elementEvts);
+
+ $(document).on('wslocalechange',function(){
+ that.value(that.options.value);
+ });
+
+ $('.step-up', this.buttonWrapper)
+ .on({
+ 'mousepressstart mousepressend': mousePress,
+ 'mousedown mousepress': function(e){
+ step.stepUp();
+ }
+ })
+ ;
+ $('.step-down', this.buttonWrapper)
+ .on({
+ 'mousepressstart mousepressend': mousePress,
+ 'mousedown mousepress': function(e){
+ step.stepDown();
+ }
+ })
+ ;
+
+ }
+ };
+
+ ['readonly', 'disabled'].forEach(function(name){
+ spinBtnProto[name] = function(val){
+ if(this.options[name] != val || !this._init){
+ this.options[name] = !!val;
+ if(name == 'readonly' && this.options.noInput){
+ this.element
+ .prop(name, true)
+ .attr({'aria-readonly': this.options[name]})
+ ;
+ } else {
+ this.element.prop(name, this.options[name]);
+ }
+ this.buttonWrapper[this.options[name] ? 'addClass' : 'removeClass']('ws-'+name);
+ }
+ };
+ });
+
+
+ $.fn.spinbtnUI = function(opts){
+ opts = $.extend({
+ monthNames: 'monthNames',
+ size: 1,
+ startView: 0
+ }, opts);
+ return this.each(function(){
+ $.webshims.objectCreate(spinBtnProto, {
+ element: {
+ value: $(this)
+ }
+ }, opts);
+ });
+ };
+ })();
+
+ (function(){
+ var picker = {};
+ var disable = {
+
+ };
+
+ var getDateArray = function(date){
+ var ret = [date.getFullYear(), addZero(date.getMonth() + 1), addZero(date.getDate())];
+ ret.month = ret[0]+'-'+ret[1];
+ ret.date = ret[0]+'-'+ret[1]+'-'+ret[2];
+ return ret;
+ };
+ var today = getDateArray(new Date());
+
+ var _setFocus = function(element, _noFocus){
+ element = $(element || this.activeButton);
+ this.activeButton.attr({tabindex: '-1', 'aria-selected': 'false'});
+ this.activeButton = element.attr({tabindex: '0', 'aria-selected': 'true'});
+ this.index = this.buttons.index(this.activeButton[0]);
+
+
+ clearTimeout(this.timer);
+
+ if(!this.popover.openedByFocus && !_noFocus){
+ this.popover.activateElement(element);
+ this.timer = setTimeout(function(){
+ element[0].focus();
+ }, this.popover.isVisible ? 20 : 99);
+ }
+
+ };
+
+ var _initialFocus = function(){
+ var sel;
+ if(this.popover.navedInitFocus){
+ sel = this.popover.navedInitFocus.sel || this.popover.navedInitFocus;
+ if((!this.activeButton || !this.activeButton[0]) && this.buttons[sel]){
+ this.activeButton = this.buttons[sel]();
+ } else if(sel){
+ this.activeButton = $(sel, this.element);
+ }
+
+ if(!this.activeButton[0] && this.popover.navedInitFocus.alt){
+ this.activeButton = this.buttons[this.popover.navedInitFocus.alt]();
+ }
+ }
+
+
+ if(!this.activeButton || !this.activeButton[0]){
+ this.activeButton = this.buttons.filter('.checked-value');
+ }
+
+ if(!this.activeButton[0]){
+ this.activeButton = this.buttons.filter('.this-value');
+ }
+ if(!this.activeButton[0]){
+ this.activeButton = this.buttons.eq(0);
+ }
+
+ this.setFocus(this.activeButton, this.opts.noFocus);
+ };
+
+
+ webshims.ListBox = function (element, popover, opts){
+ this.element = $('ul', element);
+ this.popover = popover;
+ this.opts = opts || {};
+ this.buttons = $('button:not(:disabled)', this.element);
+
+
+ this.ons(this);
+ this._initialFocus();
+ };
+
+ webshims.ListBox.prototype = {
+ setFocus: _setFocus,
+ _initialFocus: _initialFocus,
+ prev: function(){
+ var index = this.index - 1;
+ if(index < 0){
+ if(this.opts.prev){
+ this.popover.navedInitFocus = 'last';
+ this.popover.actionFn(this.opts.prev);
+ this.popover.navedInitFocus = false;
+ }
+ } else {
+ this.setFocus(this.buttons.eq(index));
+ }
+ },
+ next: function(){
+ var index = this.index + 1;
+ if(index >= this.buttons.length){
+ if(this.opts.next){
+ this.popover.navedInitFocus = 'first';
+ this.popover.actionFn(this.opts.next);
+ this.popover.navedInitFocus = false;
+ }
+ } else {
+ this.setFocus(this.buttons.eq(index));
+ }
+ },
+ ons: function(that){
+ this.element
+ .on({
+ 'keydown': function(e){
+ var handled;
+ var key = e.keyCode;
+ if(e.ctrlKey){return;}
+ if(key == 36 || key == 33){
+ that.setFocus(that.buttons.eq(0));
+ handled = true;
+ } else if(key == 34 || key == 35){
+ that.setFocus(that.buttons.eq(that.buttons.length - 1));
+ handled = true;
+ } else if(key == 38 || key == 37){
+ that.prev();
+ handled = true;
+ } else if(key == 40 || key == 39){
+ that.next();
+ handled = true;
+ }
+ if(handled){
+ return false;
+ }
+ }
+ })
+ ;
+ }
+ };
+
+ webshims.Grid = function (element, popover, opts){
+ this.element = $('tbody', element);
+ this.popover = popover;
+ this.opts = opts || {};
+ this.buttons = $('button:not(:disabled,.othermonth)', this.element);
+
+ this.ons(this);
+
+ this._initialFocus();
+ };
+
+
+
+ webshims.Grid.prototype = {
+ setFocus: _setFocus,
+ _initialFocus: _initialFocus,
+
+ first: function(){
+ this.setFocus(this.buttons.eq(0));
+ },
+ last: function(){
+ this.setFocus(this.buttons.eq(this.buttons.length - 1));
+ },
+ upPage: function(){
+ $('.ws-picker-header > button:not(:disabled)', this.popover.element).trigger('click');
+ },
+ downPage: function(){
+ this.activeButton.filter(':not([data-action="changeInput"])').trigger('click');
+ },
+ ons: function(that){
+ this.element
+ .on({
+ 'keydown': function(e){
+ var handled;
+ var key = e.keyCode;
+
+ if(e.shiftKey){return;}
+
+ if((e.ctrlKey && key == 40)){
+ handled = 'downPage';
+ } else if((e.ctrlKey && key == 38)){
+ handled = 'upPage';
+ } else if(key == 33 || (e.ctrlKey && key == 37)){
+ handled = 'prevPage';
+ } else if(key == 34 || (e.ctrlKey && key == 39)){
+ handled = 'nextPage';
+ } else if(e.keyCode == 36 || e.keyCode == 33){
+ handled = 'first';
+ } else if(e.keyCode == 35){
+ handled = 'last';
+ } else if(e.keyCode == 38){
+ handled = 'up';
+ } else if(e.keyCode == 37){
+ handled = 'prev';
+ } else if(e.keyCode == 40){
+ handled = 'down';
+ } else if(e.keyCode == 39){
+ handled = 'next';
+ }
+ if(handled){
+ that[handled]();
+ return false;
+ }
+ }
+ })
+ ;
+ }
+ };
+ $.each({
+ prevPage: {get: 'last', action: 'prev'},
+ nextPage: {get: 'first', action: 'next'}
+ }, function(name, val){
+ webshims.Grid.prototype[name] = function(){
+ if(this.opts[val.action]){
+ this.popover.navedInitFocus = {
+ sel: 'button[data-id="'+ this.activeButton.attr('data-id') +'"]:not(:disabled,.othermonth)',
+ alt: val.get
+ };
+ this.popover.actionFn(this.opts[val.action]);
+ this.popover.navedInitFocus = false;
+ }
+ };
+ });
+
+ $.each({
+ up: {traverse: 'prevAll', get: 'last', action: 'prev', reverse: true},
+ down: {traverse: 'nextAll', get: 'first', action: 'next'}
+ }, function(name, val){
+ webshims.Grid.prototype[name] = function(){
+ var cellIndex = this.activeButton.closest('td').prop('cellIndex');
+ var sel = 'td:nth-child('+(cellIndex + 1)+') button:not(:disabled,.othermonth)';
+ var button = this.activeButton.closest('tr')[val.traverse]();
+
+ if(val.reverse){
+ button = $(button.get().reverse());
+ }
+ button = button.find(sel)[val.get]();
+ if(cellIndex == null){
+ webshims.warn("cellIndex not implemented. abort keynav");
+ return;
+ }
+ if(!button[0]){
+ if(this.opts[val.action]){
+ this.popover.navedInitFocus = sel+':'+val.get;
+ this.popover.actionFn(this.opts[val.action]);
+ this.popover.navedInitFocus = false;
+ }
+ } else {
+ this.setFocus(button.eq(0));
+ }
+ };
+ });
+
+ $.each({
+ prev: {traverse: 'prevAll',get: 'last', reverse: true},
+ next: {traverse: 'nextAll', get: 'first'}
+ }, function(name, val){
+ webshims.Grid.prototype[name] = function(){
+ var sel = 'button:not(:disabled,.othermonth)';
+ var button = this.activeButton.closest('td')[val.traverse]('td');
+ if(val.reverse){
+ button = $(button.get().reverse());
+ }
+ button = button.find(sel)[val.get]();
+ if(!button[0]){
+ button = this.activeButton.closest('tr')[val.traverse]('tr');
+ if(val.reverse){
+ button = $(button.get().reverse());
+ }
+ button = button.find(sel)[val.get]();
+ }
+
+ if(!button[0]){
+ if(this.opts[name]){
+ this.popover.navedInitFocus = val.get;
+ this.popover.actionFn(this.opts[name]);
+ this.popover.navedInitFocus = false;
+
+ }
+ } else {
+ this.setFocus(button.eq(0));
+ }
+ };
+ });
+
+ picker.getWeek = function(date){
+ var onejan = new Date(date.getFullYear(),0,1);
+ return Math.ceil((((date - onejan) / 86400000) + onejan.getDay()+1)/7);
+ };
+ picker.getYearList = function(value, data){
+ var j, i, val, disabled, lis, prevDisabled, nextDisabled, classStr, classArray;
+
+ value = value[0] * 1;
+
+ var size = data.options.size;
+ var xth = value % (12 * size);
+ var start = value - xth;
+ var max = data.options.max.split('-');
+ var min = data.options.min.split('-');
+ var currentValue = data.options.value.split('-');
+ var enabled = 0;
+ var str = '';
+ var rowNum = 0;
+ for(j = 0; j < size; j++){
+ if(j){
+ start += 12;
+ } else {
+ prevDisabled = picker.isInRange([start-1], max, min) ? {'data-action': 'setYearList','value': start-1} : false;
+ }
+
+ str += '<div class="year-list picker-list ws-index-'+ j +'"><div class="ws-picker-header"><h3>'+ start +' - '+(start + 11)+'</h3></div>';
+ lis = [];
+ for(i = 0; i < 12; i++){
+ val = start + i ;
+ classArray = [];
+ if( !picker.isInRange([val], max, min) ){
+ disabled = ' disabled=""';
+ } else {
+ disabled = '';
+ enabled++;
+ }
+
+
+ if(val == today[0]){
+ classArray.push('this-value');
+ }
+
+ if(currentValue[0] == val){
+ classArray.push('checked-value');
+ }
+
+ classStr = classArray.length ? ' class="'+ (classArray.join(' ')) +'"' : '';
+
+ if(i && !(i % 3)){
+ rowNum++;
+ lis.push('</tr><tr class="ws-row-'+ rowNum +'">');
+ }
+ 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>');
+ }
+ if(j == size - 1){
+ nextDisabled = picker.isInRange([val+1], max, min) ? {'data-action': 'setYearList','value': val+1} : false;
+ }
+ str += '<table role="grid" aria-label="'+ start +' - '+(start + 11)+'"><tbody><tr class="ws-row-0">'+ (lis.join(''))+ '</tr></tbody></table></div>';
+ }
+
+ return {
+ enabled: enabled,
+ main: str,
+ next: nextDisabled,
+ prev: prevDisabled,
+ type: 'Grid'
+ };
+ };
+
+
+ picker.getMonthList = function(value, data){
+
+ var j, i, name, val, disabled, lis, fullyDisabled, prevDisabled, nextDisabled, classStr, classArray;
+ var o = data.options;
+ var size = o.size;
+ var max = o.max.split('-');
+ var min = o.min.split('-');
+ var currentValue = o.value.split('-');
+ var enabled = 0;
+ var rowNum = 0;
+ var str = '';
+
+ value = value[0] - Math.floor((size - 1) / 2);
+ for(j = 0; j < size; j++){
+ if(j){
+ value++;
+ } else {
+ prevDisabled = picker.isInRange([value-1], max, min) ? {'data-action': 'setMonthList','value': value-1} : false;
+ }
+ if(j == size - 1){
+ nextDisabled = picker.isInRange([value+1], max, min) ? {'data-action': 'setMonthList','value': value+1} : false;
+ }
+ lis = [];
+
+ if( !picker.isInRange([value, '01'], max, min) && !picker.isInRange([value, '12'], max, min)){
+ disabled = ' disabled=""';
+ fullyDisabled = true;
+ } else {
+ fullyDisabled = false;
+ disabled = '';
+ }
+
+ if(o.minView >= 1){
+ disabled = ' disabled=""';
+ }
+
+ str += '<div class="month-list picker-list ws-index-'+ j +'"><div class="ws-picker-header">';
+
+ str += o.selectNav ?
+ '<select data-action="setMonthList">'+ picker.createYearSelect(value, max, min).join('') +'</select>' :
+ '<button data-action="setYearList"'+disabled+' value="'+ value +'" tabindex="-1">'+ value +'</button>';
+ str += '</div>';
+
+ for(i = 0; i < 12; i++){
+ val = curCfg.date.monthkeys[i+1];
+ name = (curCfg.date[o.monthNames] || curCfg.date.monthNames)[i];
+ classArray = [];
+ if(fullyDisabled || !picker.isInRange([value, val], max, min) ){
+ disabled = ' disabled=""';
+ } else {
+ disabled = '';
+ enabled++;
+ }
+
+ if(value == today[0] && today[1] == val){
+ classArray.push('this-value');
+ }
+
+ if(currentValue[0] == value && currentValue[1] == val){
+ classArray.push('checked-value');
+ }
+
+ classStr = (classArray.length) ? ' class="'+ (classArray.join(' ')) +'"' : '';
+ if(i && !(i % 3)){
+ rowNum++;
+ lis.push('</tr><tr class="ws-row-'+ rowNum +'">');
+ }
+ 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">'+name+'</button></td>');
+
+ }
+
+ str += '<table role="grid" aria-label="'+value+'"><tbody><tr class="ws-row-0">'+ (lis.join(''))+ '</tr></tbody></table></div>';
+ }
+
+ return {
+ enabled: enabled,
+ main: str,
+ prev: prevDisabled,
+ next: nextDisabled,
+ type: 'Grid'
+ };
+ };
+
+
+ picker.getDayList = function(value, data){
+
+ var j, i, k, day, nDay, name, val, disabled, lis, prevDisabled, nextDisabled, addTr, week, rowNum;
+
+ var lastMotnh, curMonth, otherMonth, dateArray, monthName, buttonStr, date2, classArray;
+ var o = data.options;
+ var size = o.size;
+ var max = o.max.split('-');
+ var min = o.min.split('-');
+ var currentValue = o.value.split('-');
+ var monthNames = curCfg.date[o.monthNames] || curCfg.date.monthNames;
+ var enabled = 0;
+ var str = [];
+ var date = new Date(value[0], value[1] - 1, 1);
+
+ date.setMonth(date.getMonth() - Math.floor((size - 1) / 2));
+
+ for(j = 0; j < size; j++){
+ lastMotnh = date.getMonth();
+ rowNum = 0;
+ if(!j){
+ date2 = new Date(date.getTime());
+ date2.setDate(-1);
+ dateArray = getDateArray(date2);
+ prevDisabled = picker.isInRange(dateArray, max, min) ? {'data-action': 'setDayList','value': dateArray[0]+'-'+dateArray[1]} : false;
+ }
+
+ dateArray = getDateArray(date);
+
+ str.push('<div class="day-list picker-list ws-index-'+ j +'"><div class="ws-picker-header">');
+ if( o.selectNav ){
+ monthName = ['<select data-action="setDayList" tabindex="0">'+ picker.createMonthSelect(dateArray, max, min, monthNames).join('') +'</select>', '<select data-action="setDayList" tabindex="0">'+ picker.createYearSelect(dateArray[0], max, min, '-'+dateArray[1]).join('') +'</select>'];
+ if(curCfg.date.showMonthAfterYear){
+ monthName.reverse();
+ }
+ str.push( monthName.join(' ') );
+ }
+
+ monthName = [monthNames[(dateArray[1] * 1) - 1], dateArray[0]];
+ if(curCfg.date.showMonthAfterYear){
+ monthName.reverse();
+ }
+
+ if(!data.options.selectNav) {
+ str.push(
+ '<button data-action="setMonthList"'+ (o.minView >= 2 ? ' disabled="" ' : '') +' value="'+ dateArray.date +'" tabindex="-1">'+ monthName.join(' ') +'</button>'
+ );
+ }
+
+
+ str.push('</div><table role="grid" aria-label="'+ monthName.join(' ') +'"><thead><tr>');
+
+ if(data.options.showWeek){
+ str.push('<th class="week-header">'+ curCfg.date.weekHeader +'</th>');
+ }
+ for(k = curCfg.date.firstDay; k < curCfg.date.dayNamesShort.length; k++){
+ str.push('<th class="day-'+ k +'"><abbr title="'+ curCfg.date.dayNames[k] +'">'+ curCfg.date.dayNamesShort[k] +'</abbr></th>');
+ }
+ k = curCfg.date.firstDay;
+ while(k--){
+ str.push('<th class="day-'+ k +'"><abbr title="'+ curCfg.date.dayNames[k] +'">'+ curCfg.date.dayNamesShort[k] +'</abbr></th>');
+ }
+ str.push('</tr></thead><tbody><tr class="ws-row-0">');
+
+ if(data.options.showWeek) {
+ week = picker.getWeek(date);
+ str.push('<td class="week-cell">'+ week +'</td>');
+ }
+
+ for (i = 0; i < 99; i++) {
+ addTr = (i && !(i % 7));
+ curMonth = date.getMonth();
+ otherMonth = lastMotnh != curMonth;
+ day = date.getDay();
+ classArray = [];
+
+ if(addTr && otherMonth ){
+ str.push('</tr>');
+ break;
+ }
+ if(addTr){
+ rowNum++;
+ str.push('</tr><tr class="ws-row-'+ rowNum +'">');
+ if(data.options.showWeek) {
+ week++;
+ str.push('<td class="week-cell">'+ week +'</td>');
+ }
+ }
+
+ if(!i){
+
+ if(day != curCfg.date.firstDay){
+ nDay = day - curCfg.date.firstDay;
+ if(nDay < 0){
+ nDay += 7;
+ }
+ date.setDate(date.getDate() - nDay);
+ day = date.getDay();
+ curMonth = date.getMonth();
+ otherMonth = lastMotnh != curMonth;
+ }
+ }
+
+ dateArray = getDateArray(date);
+ buttonStr = '<td role="presentation" class="day-'+ day +'"><button data-id="day-'+ date.getDate() +'" role="gridcell" data-action="changeInput" value="'+ (dateArray.join('-')) +'"';
+
+ if(otherMonth){
+ classArray.push('othermonth');
+ } else {
+ classArray.push('day-'+date.getDate());
+ }
+
+ if(dateArray[0] == today[0] && today[1] == dateArray[1] && today[2] == dateArray[2]){
+ classArray.push('this-value');
+ }
+
+ if(currentValue[0] == dateArray[0] && dateArray[1] == currentValue[1] && dateArray[2] == currentValue[2]){
+ classArray.push('checked-value');
+ }
+
+ if(classArray.length){
+ buttonStr += ' class="'+ classArray.join(' ') +'"';
+ }
+
+ if(!picker.isInRange(dateArray, max, min) || (data.options.disableDays && $.inArray(day, data.options.disableDays) != -1)){
+ buttonStr += ' disabled=""';
+ }
+
+ str.push(buttonStr+' tabindex="-1">'+ date.getDate() +'</button></td>');
+
+ date.setDate(date.getDate() + 1);
+ }
+ str.push('</tbody></table></div>');
+ if(j == size - 1){
+ dateArray = getDateArray(date);
+ dateArray[2] = 1;
+ nextDisabled = picker.isInRange(dateArray, max, min) ? {'data-action': 'setDayList','value': dateArray.date} : false;
+ }
+ }
+
+
+ return {
+ enabled: 9,
+ main: str.join(''),
+ prev: prevDisabled,
+ next: nextDisabled,
+ type: 'Grid'
+ };
+ };
+
+ picker.isInRange = function(values, max, min){
+ var i;
+ var ret = true;
+ for(i = 0; i < values.length; i++){
+
+ if(min[i] && min[i] > values[i]){
+ ret = false;
+ break;
+ } else if( !(min[i] && min[i] == values[i]) ){
+ break;
+ }
+ }
+ if(ret){
+ for(i = 0; i < values.length; i++){
+
+ if((max[i] && max[i] < values[i])){
+ ret = false;
+ break;
+ } else if( !(max[i] && max[i] == values[i]) ){
+ break;
+ }
+ }
+ }
+ return ret;
+ };
+
+ picker.createMonthSelect = function(value, max, min, monthNames){
+ if(!monthNames){
+ monthNames = curCfg.date.monthNames;
+ }
+
+ var selected;
+ var i = 0;
+ var options = [];
+ var tempVal = value[1]-1;
+ for(; i < monthNames.length; i++){
+ selected = tempVal == i ? ' selected=""' : '';
+ if(selected || picker.isInRange([value[0], i+1], max, min)){
+ options.push('<option value="'+ value[0]+'-'+addZero(i+1) + '"'+selected+'>'+ monthNames[i] +'</option>');
+ }
+ }
+ return options;
+ };
+
+ picker.createYearSelect = function(value, max, min, valueAdd){
+
+ var temp;
+ var goUp = true;
+ var goDown = true;
+ var options = ['<option selected="">'+ value + '</option>'];
+ var i = 0;
+ if(!valueAdd){
+ valueAdd = '';
+ }
+ while(i < 8 && (goUp || goDown)){
+ i++;
+ temp = value-i;
+ if(goUp && picker.isInRange([temp], max, min)){
+ options.unshift('<option value="'+ (temp+valueAdd) +'">'+ temp +'</option>');
+ } else {
+ goUp = false;
+ }
+ temp = value + i;
+ if(goDown && picker.isInRange([temp], max, min)){
+ options.push('<option value="'+ (temp+valueAdd) +'">'+ temp +'</option>');
+ } else {
+ goDown = false;
+ }
+ }
+ return options;
+ };
+
+ var actions = {
+ changeInput: function(val, popover, data){
+ data.element.focus();
+ popover.hide();
+ data.setChange(val);
+ }
+ };
+
+ (function(){
+ var retNames = function(name){
+ return 'get'+name+'List';
+ };
+ var retSetNames = function(name){
+ return 'set'+name+'List';
+ };
+ var stops = {
+ date: 'Day',
+ week: 'Day',
+ month: 'Month'
+ };
+
+ $.each({'setYearList' : ['Year', 'Month', 'Day'], 'setMonthList': ['Month', 'Day'], 'setDayList': ['Day']}, function(setName, names){
+ var getNames = names.map(retNames);
+ var setNames = names.map(retSetNames);
+ actions[setName] = function(val, popover, data, startAt){
+ val = ''+val;
+ var o = data.options;
+ var values = val.split('-');
+ if(!startAt){
+ startAt = 0;
+ }
+ $.each(getNames, function(i, item){
+ if(i >= startAt){
+ var content = picker[item](values, data);
+
+ if( values.length < 2 || content.enabled > 1 || stops[data.type] === names[i]){
+ popover.element
+ .attr({'data-currentview': setNames[i]})
+ .addClass('ws-size-'+o.size)
+ .data('pickercontent', {
+ data: data,
+ content: content,
+ values: values
+ })
+ ;
+ popover.bodyElement.html(content.main);
+ if(content.prev){
+ popover.prevElement
+ .attr(content.prev)
+ .prop({disabled: false})
+ ;
+ } else {
+ popover.prevElement
+ .removeAttr('data-action')
+ .prop({disabled: true})
+ ;
+ }
+ if(content.next){
+ popover.nextElement
+ .attr(content.next)
+ .prop({disabled: false})
+ ;
+ } else {
+ popover.nextElement
+ .removeAttr('data-action')
+ .prop({disabled: true})
+ ;
+ }
+ if(webshims[content.type]){
+ new webshims[content.type](popover.bodyElement.children(), popover, content);
+ }
+ popover.element.trigger('pickerchange');
+ return false;
+ }
+ }
+ });
+ };
+ });
+ })();
+
+ picker.commonInit = function(data, popover){
+ var actionfn = function(e){
+ popover.actionFn({
+ 'data-action': $.attr(this, 'data-action'),
+ value: $(this).val() || $.attr(this, 'value')
+ });
+ return false;
+ };
+ var id = new Date().getTime();
+ var generateList = function(o, max, min){
+ var options = [];
+ var label = '';
+ var labelId = '';
+ o.options = data.getOptions() || {};
+ $('div.ws-options', popover.contentElement).remove();
+ $.each(o.options[0], function(val, label){
+ var disabled = picker.isInRange(val.split('-'), o.maxS, o.minS) ?
+ '' :
+ ' disabled="" '
+ options.push('<li role="presentation"><button value="'+ val +'" '+disabled+' data-action="changeInput" tabindex="-1" role="option">'+ (label || data.formatValue(val)) +'</button></li>');
+ });
+ if(options.length){
+ id++;
+ if(o.options[1]){
+ labelId = 'datalist-'+id;
+ label = '<h5 id="'+labelId+'">'+ o.options[1] +'</h5>';
+ labelId = ' aria-labelledbyid="'+ labelId +'" ';
+ }
+ new webshims.ListBox($('<div class="ws-options">'+label+'<ul role="listbox" '+ labelId +'>'+ options.join('') +'</div>').insertAfter(popover.bodyElement)[0], popover, {noFocus: true});
+ }
+ };
+ var updateContent = function(){
+ if(popover.isDirty){