vendor/assets/javascripts/webshims/shims/combos/17.js in webshims-rails-1.10.10 vs vendor/assets/javascripts/webshims/shims/combos/17.js in webshims-rails-1.10.11

- old
+ new

@@ -147,12 +147,12 @@ if(set !== false){ $.prop(elem, 'value', set); } else { webshims.error('INVALID_STATE_ERR: DOM Exception 11'); } - } else { - valueAsNumberDescriptor.prop._supset && valueAsNumberDescriptor.prop._supset.apply(elem, arguments); + } else if(valueAsNumberDescriptor.prop._supset) { + valueAsNumberDescriptor.prop._supset.apply(elem, arguments); } } } }); @@ -275,11 +275,11 @@ // }; var typeProtos = { number: { - mismatch: function(val){ + bad: function(val){ return !(isNumber(val)); }, step: 1, //stepBase: 0, 0 = default stepScaleFactor: 1, @@ -294,19 +294,19 @@ range: { minDefault: 0, maxDefault: 100 }, color: { - mismatch: (function(){ + bad: (function(){ var cReg = /^\u0023[a-f0-9]{6}$/; return function(val){ return (!val || val.length != 7 || !(cReg.test(val))); }; })() }, date: { - mismatch: function(val){ + bad: function(val){ if(!val || !val.split || !(/\d$/.test(val))){return true;} var i; var valA = val.split(/\u002D/); if(valA.length !== 3){return true;} var ret = false; @@ -327,18 +327,18 @@ }, step: 1, //stepBase: 0, 0 = default stepScaleFactor: 86400000, asDate: function(val, _noMismatch){ - if(!_noMismatch && this.mismatch(val)){ + if(!_noMismatch && this.bad(val)){ return null; } return new Date(this.asNumber(val, true)); }, asNumber: function(str, _noMismatch){ var ret = nan; - if(_noMismatch || !this.mismatch(str)){ + if(_noMismatch || !this.bad(str)){ str = str.split(/\u002D/); ret = Date.UTC(str[0], str[1] - 1, str[2]); } return ret; }, @@ -351,11 +351,11 @@ }, /* * ToDO: WEEK */ // week: { -// mismatch: function(val){ +// bad: function(val){ // if(!val || !val.split){return true;} // var valA = val.split('-W'); // var ret = true; // if(valA.length == 2 && valA[0].length > 3 && valA.length == 2){ // ret = this.dateToString(setWeek(valA[0], valA[1])) != val; @@ -365,11 +365,11 @@ // step: 1, // stepScaleFactor: 604800000, // stepBase: -259200000, // asDate: function(str, _noMismatch){ // var ret = null; -// if(_noMismatch || !this.mismatch(str)){ +// if(_noMismatch || !this.bad(str)){ // ret = str.split('-W'); // ret = setWeek(ret[0], ret[1]); // } // return ret; // }, @@ -398,11 +398,11 @@ // numberToString: function(num){ // return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false; // } // }, time: { - mismatch: function(val, _getParsed){ + bad: function(val, _getParsed){ if(!val || !val.split || !(/\d$/.test(val))){return true;} val = val.split(/\u003A/); if(val.length < 2 || val.length > 3){return true;} var ret = false, sFraction; @@ -443,11 +443,11 @@ val = new Date(this.asNumber(val)); return (isNaN(val)) ? null : val; }, asNumber: function(val){ var ret = nan; - val = this.mismatch(val, true); + val = this.bad(val, true); if(val !== true){ ret = Date.UTC('1970', 0, 1, val[0][0], val[0][1], val[0][2] || 0); if(val[1]){ ret += val[1]; } @@ -471,23 +471,23 @@ return false; } } }, month: { - mismatch: function(val){ - return typeProtos.date.mismatch(val+'-01'); + bad: function(val){ + return typeProtos.date.bad(val+'-01'); }, step: 1, stepScaleFactor: false, //stepBase: 0, 0 = default asDate: function(val){ return new Date(typeProtos.date.asNumber(val+'-01')); }, asNumber: function(val){ //1970-01 var ret = nan; - if(val && !this.mismatch(val)){ + if(val && !this.bad(val)){ val = val.split(/\u002D/); val[0] = (val[0] * 1) - 1970; val[1] = (val[1] * 1) - 1; ret = (val[0] * 12) + val[1]; } @@ -517,50 +517,50 @@ } else { return false; } } } -// ,'datetime-local': { -// mismatch: function(val, _getParsed){ -// if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;} -// val = val.split(/\u0054/); -// return ( typeProtos.date.mismatch(val[0]) || typeProtos.time.mismatch(val[1], _getParsed) ); -// }, -// noAsDate: true, -// asDate: function(val){ -// val = new Date(this.asNumber(val)); -// -// return (isNaN(val)) ? null : val; -// }, -// asNumber: function(val){ -// var ret = nan; -// var time = this.mismatch(val, true); -// if(time !== true){ -// val = val.split(/\u0054/)[0].split(/\u002D/); -// -// ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0); -// if(time[1]){ -// ret += time[1]; -// } -// } -// return ret; -// }, -// dateToString: function(date, _getParsed){ -// return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed); -// } -// } + ,'datetime-local': { + bad: function(val, _getParsed){ + if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;} + val = val.split(/\u0054/); + return ( typeProtos.date.bad(val[0]) || typeProtos.time.bad(val[1], _getParsed) ); + }, + noAsDate: true, + asDate: function(val){ + val = new Date(this.asNumber(val)); + + return (isNaN(val)) ? null : val; + }, + asNumber: function(val){ + var ret = nan; + var time = this.bad(val, true); + if(time !== true){ + val = val.split(/\u0054/)[0].split(/\u002D/); + + ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0); + if(time[1]){ + ret += time[1]; + } + } + return ret; + }, + dateToString: function(date, _getParsed){ + return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed); + } + } }; - if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month')){ + if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month') || !supportsType('datetime-local')){ typeProtos.range = $.extend({}, typeProtos.number, typeProtos.range); typeProtos.time = $.extend({}, typeProtos.date, typeProtos.time); typeProtos.month = $.extend({}, typeProtos.date, typeProtos.month); -// typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']); + typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']); } - //'datetime-local' - ['number', 'month', 'range', 'date', 'time', 'color'].forEach(function(type){ + // + ['number', 'month', 'range', 'date', 'time', 'color', 'datetime-local'].forEach(function(type){ if(typeBugs || !supportsType(type)){ webshims.addInputType(type, typeProtos[type]); } }); @@ -1087,14 +1087,25 @@ })(window.webshims ? webshims.$ : jQuery); webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){ "use strict"; var curCfg; var formcfg = webshims.formcfg; - + var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; var stopPropagation = function(e){ e.stopImmediatePropagation(); }; + var getMonthOptions = (function(){ + var str; + return function(){ + if(!str){ + str = ('<option></option>')+$.map(monthDigits, function(val){ + return '<option>'+val+'</option>'; + }).join(''); + } + return str; + }; + })(); 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; @@ -1102,22 +1113,30 @@ curCfg.patterns[name+'Obj'] = obj; } }; var splitInputs = { date: { - _create: function(){ + _create: function(opts){ var obj = { - splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" />')[0], $('<input type="text" class="mm" inputmode="numeric" maxlength="2" size="2" />')[0], $('<input type="text" class="dd ws-spin" inputmode="numeric" maxlength="2" size="2" />')[0]] + splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" />')[0]] }; + if(opts.monthSelect){ + obj.splits.push($('<select class="mm">'+getMonthOptions()+'</select>')[0]); + } else { + obj.splits.push($('<input type="text" class="mm" inputmode="numeric" maxlength="2" size="2" />')[0]); + } + obj.splits.push($('<input type="text" class="dd ws-spin" inputmode="numeric" maxlength="2" size="2" />')[0]); + + obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]]; return obj; }, sort: function(element){ createFormat('d'); var i = 0; var seperators = $('.ws-input-seperator', element).html(curCfg.dFormat); - var inputs = $('input', element); + var inputs = $('input, select', element); $.each(curCfg.patterns.dObj, function(name, value){ var input = inputs.filter('.'+ name); if(input[0]){ input.appendTo(element); @@ -1131,21 +1150,27 @@ }, month: { _create: function(opts){ var obj = { - splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0], $('<input type="text" class="mm ws-spin" />')[0]] + splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0]] }; - if(opts.onlyMonthDigits){ - $(obj.splits[1]).attr({inputmode: 'numeric', size: 2, maxlength: 2}); + if(opts.monthSelect){ + obj.splits.push($('<select class="mm ws-spin">'+getMonthOptions()+'</select>')[0]); + } else { + obj.splits.push($('<input type="text" class="mm ws-spin" />')[0]); + if(opts.onlyMonthDigits){ + $(obj.splits[1]).attr({inputmode: 'numeric', size: 2, maxlength: 2}); + } } + obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]]; return obj; }, sort: function(element){ var seperator = $('.ws-input-seperator', element).html(curCfg.dFormat); - var mm = $('input.mm', element); + var mm = $('input.mm, select.mm', element); var action; if(curCfg.date.showMonthAfterYear){ mm.appendTo(element); action = 'insertBefore'; } else { @@ -1155,19 +1180,24 @@ seperator[action](mm); } } }; - var nowDate = new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 ); + var nowDate = new Date(new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 )); + nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime() var steps = { number: { step: 1 }, // week: { // step: 1, // start: new Date(nowDate) // }, + 'datetime-local': { + step: 60, + start: new Date(nowDate).getTime() + }, time: { step: 60 }, month: { step: 1, @@ -1199,11 +1229,10 @@ return val.length == 1 ? '0'+val : val; }; (function(){ - var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; formcfg.de = $.extend(true, { numberFormat: { ",": ".", ".": "," @@ -1249,10 +1278,11 @@ timeSigns: ":. ", dFormat: "/", patterns: { d: "mm/dd/yy" }, + meridian: ['AM', 'PM'], month: { currentText: 'This month' }, date: { "closeText": "Done", @@ -1302,16 +1332,22 @@ langCfg.date.monthkeys[name.toLowerCase()] = strNum; }; langCfg.date.monthkeys = {}; langCfg.date.monthDigits = monthDigits; langCfg.numberSigns += '-'; + if(langCfg.meridian){ + langCfg.timeSigns += langCfg.meridian[0] + langCfg.meridian[1]; + } $.each(langCfg.date.monthNames, create); $.each(langCfg.date.monthNamesShort, create); } if(!langCfg.colorSigns){ langCfg.colorSigns = '#abcdefABCDEF'; } + if(!langCfg['datetime-localSigns']){ + langCfg['datetime-localSigns'] = langCfg.dateSigns+langCfg.timeSigns; + } }; var triggerLocaleChange = function(){ processLangCFG(curCfg); $(document).triggerHandler('wslocalechange'); }; @@ -1364,15 +1400,35 @@ var formatVal = { number: function(val){ return (val+'').replace(/\,/g, '').replace(/\./, curCfg.numberFormat['.']); }, time: function(val){ + var fVal; + if(val && curCfg.meridian){ + val = val.split(':'); + fVal = (val[0] * 1); + if(fVal && fVal >= 12){ + val[0] = addZero(fVal - 12+''); + fVal = 1; + + } else { + fVal = 0; + } + val = $.trim(val.join(':')) + ' '+ curCfg.meridian[fVal]; + } return val; }, - week: function(val){ + 'datetime-local': function(val, o){ + var fVal = $.trim(val || '').split('T'); + if(fVal.length == 2){ + val = this.date(fVal[0], o) +' '+this.time(fVal[1], o); + } return val; }, +// week: function(val){ +// return val; +// }, //todo empty val for month/split month: function(val, options){ var names; var p = val.split('-'); if(p[0] && p[1]){ @@ -1421,11 +1477,36 @@ return (val+'').replace(curCfg.numberFormat[','], '').replace(curCfg.numberFormat['.'], '.'); }, // week: function(val){ // return val; // }, + 'datetime-local': function(val, o){ + var tmp; + var fVal = $.trim(val || '').split(/\s+/); + if(fVal.length == 2){ + if(fVal[0].indexOf(':') != -1 && fVal[1].indexOf(':') == -1){ + tmp = fVal[1]; + fVal[1] = fVal[0]; + fVal[0] = tmp; + } + val = this.date(fVal[0], o) +'T'+ this.time(fVal[1], o); + } + return val; + }, time: function(val){ + var fVal; + if(val && curCfg.meridian){ + if(val.indexOf(curCfg.meridian[1]) != -1){ + val = val.split(':'); + fVal = (val[0] * 1); + if(!isNaN(fVal)){ + val[0] = fVal + 12; + } + val = val.join(':'); + } + val = $.trim(val.replace(curCfg.meridian[0], '').replace(curCfg.meridian[1], '')); + } return val; }, month: function(val, opts, noCorrect){ var p = (!opts.splitInput) ? val.trim().split(/[\.\s-\/\\]+/) : val; @@ -1522,12 +1603,20 @@ }, asValue: function(val){ var type = (typeof val == 'object') ? 'valueAsDate' : 'valueAsNumber'; return input.prop(type, val).prop('value'); }, - isValid: function(val){ - return input.prop('value', val).is(':valid') && input.prop('value') == val; + isValid: function(val, attrs){ + if(attrs && (attrs.nodeName || attrs.jquery)){ + attrs = { + min: $(attrs).prop('min') || '', + max: $(attrs).prop('max') || '', + step: $(attrs).prop('step') || 'any' + }; + } + attrs = $.extend({step: 'any', min: '', max: ''}, attrs || {}); + return input.attr(attrs).prop('value', val).is(':valid') && input.prop('value') == val; } }; } return types[type]; }; @@ -1548,10 +1637,13 @@ this.options.containerElements.push(this.buttonWrapper[0]); o.mirrorValidity = o.mirrorValidity && this.orig && Modernizr.formvalidation && !webshims.bugs.bustedValidity; if(o.splitInput && this._addSplitInputs){ + if(o.monthSelect){ + this.element.addClass('ws-month-select'); + } this._addSplitInputs(); } else { this.inputElements = this.element; } @@ -1799,11 +1891,11 @@ if(e.type == 'input'){ if($.prop(this, 'value').length === $.prop(this, 'maxLength')){ try { $(this) .next() - .next('input') + .next('input, select') .each(select) ; } catch(er){} } } else if(!e.shiftKey && !e.crtlKey && e.keyCode == 9 && (isStopped === true || (isStopped && !$.prop(this, 'value')))){ @@ -1877,11 +1969,11 @@ step[delta > 0 ? 'stepUp' : 'stepDown'](); e.preventDefault(); } }; spinEvents.keydown = function(e){ - if(o.list || e.isDefaultPrevented() || $.attr(this, 'list')){return;} + if(o.list || e.isDefaultPrevented() || (e.altKey && e.keyCode == 40) || $.attr(this, 'list')){return;} var stepped = true; var code = e.keyCode; if (code == 38) { step.stepUp(); } else if (code == 40) { @@ -2000,11 +2092,11 @@ options[$.prop(this, 'value')] = $.prop(this, 'label'); }); return [options, datalist.data('label')]; }, list: function(val){ - if(this.type == 'number' || this.type == 'time'){ + if(this.type == 'number'){ this.element.attr('list', $.attr(this.orig, 'list')); } this.options.list = val; this._propertyChange('list'); }, @@ -2083,11 +2175,11 @@ createOpts: ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'value', 'required'], _addSplitInputs: function(){ if(!this.inputElements){ var create = splitInputs[this.type]._create(this.options); this.splits = create.splits; - this.inputElements = $(create.elements).prependTo(this.element).filter('input'); + this.inputElements = $(create.elements).prependTo(this.element).filter('input, select'); } }, getRelNumber: function(rel){ var start = steps[this.type].start || 0; @@ -2109,15 +2201,15 @@ }, reorderInputs: function(){ if(splitInputs[this.type]){ var element = this.element; - splitInputs[this.type].sort(element); + splitInputs[this.type].sort(element, this.options); setTimeout(function(){ var data = webshims.data(element); if(data && data.shadowData){ - data.shadowData.shadowFocusElement = element.find('input')[0] || element[0]; + data.shadowData.shadowFocusElement = element.find('input, select')[0] || element[0]; } }, 9); } }, value: function(val, force){ @@ -2216,12 +2308,25 @@ noAutoCallback: true, css: 'jpicker/jpicker.css', options: options }); + webshims.inlinePopover = { + _create: function(){ + this.element = $('<div class="ws-inline-picker"><div class="ws-po-box" /></div>').data('wspopover', this); + this.contentElement = $('.ws-po-box', this.element); + this.element.insertAfter(this.options.prepareFor); + }, + show: $.noop, + hide: $.noop, + preventBlur: $.noop, + isVisible: true + }; + picker._genericSetFocus = function(element, _noFocus){ element = $(element || this.activeButton); + if(!this.popover.openedByFocus && !_noFocus){ var that = this; var setFocus = function(noTrigger){ clearTimeout(that.timer); that.timer = setTimeout(function(){ @@ -2242,16 +2347,18 @@ changeInput: function(val, popover, data){ picker._actions.cancel(val, popover, data); data.setChange(val); }, cancel: function(val, popover, data){ - popover.stopOpen = true; - data.element.getShadowFocusElement().focus(); - setTimeout(function(){ - popover.stopOpen = false; - }, 9); - popover.hide(); + if(!data.options.inlinePicker){ + popover.stopOpen = true; + data.element.getShadowFocusElement().focus(); + setTimeout(function(){ + popover.stopOpen = false; + }, 9); + popover.hide(); + } } }; picker.commonInit = function(data, popover){ @@ -2260,42 +2367,45 @@ popover.isDirty = true; popover.element.on('updatepickercontent pickerchange', function(){ tabbable = false; }); - popover.contentElement.on({ - keydown: function(e){ - if(e.keyCode == 9){ - if(!tabbable){ - tabbable = $('input:not(:disabled), [tabindex="0"]:not(:disabled)', this).filter(':visible'); - } - var index = tabbable.index(e.target); - if(e.shiftKey && index <= 0){ - tabbable.last().focus(); + + if(!data.options.inlinePicker){ + popover.contentElement.on({ + keydown: function(e){ + if(e.keyCode == 9){ + if(!tabbable){ + tabbable = $('input:not(:disabled), [tabindex="0"]:not(:disabled)', this).filter(':visible'); + } + var index = tabbable.index(e.target); + if(e.shiftKey && index <= 0){ + tabbable.last().focus(); + return false; + } + if(!e.shiftKey && index >= tabbable.length - 1){ + tabbable.first().focus(); + return false; + } + } else if(e.keyCode == 27){ + data.element.getShadowFocusElement().focus(); + popover.hide(); return false; } - if(!e.shiftKey && index >= tabbable.length - 1){ - tabbable.first().focus(); - return false; - } - } else if(e.keyCode == 27){ - data.element.getShadowFocusElement().focus(); - popover.hide(); - return false; } - } - }); + }); + } data._propertyChange = (function(){ var timer; var update = function(){ if(popover.isVisible){ popover.element.triggerHandler('updatepickercontent'); } }; return function(prop){ - if(prop == 'value'){return;} + if(prop == 'value' && !data.options.inlinePicker){return;} popover.isDirty = true; if(popover.isVisible){ clearTimeout(timer); timer = setTimeout(update, 9); } @@ -2328,31 +2438,47 @@ }; picker._common = function(data){ var options = data.options; - var popover = webshims.objectCreate(webshims.wsPopover, {}, {prepareFor: data.element, position: options.widgetPosition}); + var popover = webshims.objectCreate(options.inlinePicker ? webshims.inlinePopover : webshims.wsPopover, {}, {prepareFor: options.inlinePicker ? data.buttonWrapper : data.element, position: options.widgetPosition}); var opener = $('<button type="button" class="ws-popover-opener"><span /></button>').appendTo(data.buttonWrapper); var showPickerContent = function(){ (picker[data.type].showPickerContent || picker.showPickerContent)(data, popover); }; var show = function(){ var type = loadPicker(data.type, 'DOM'); - if(!options.disabled && !options.readonly && !popover.isVisible){ + if(!options.disabled && !options.readonly && (options.inlinePicker || !popover.isVisible)){ webshims.ready(type, showPickerContent); popover.show(data.element); } }; + var open = function(){ + if((options.inlinePicker || popover.isVisible) && popover.activeElement){ + popover.openedByFocus = false; + popover.activeElement.focus(); + } + show(); + }; + options.containerElements.push(popover.element[0]); if(data.type != 'color'){ + if(options.yearButtons){ + options.startView = 2; + } if(!options.startView){ options.startView = 0; } + + if(data.type == 'time'){ + options.minView = 3; + options.startView = 3; + } if(!options.minView){ options.minView = 0; } if(options.startView < options.minView){ options.startView = options.minView; @@ -2378,10 +2504,13 @@ }, focusout: function(){ if(popover.activeElement){ popover.activeElement.removeClass('ws-focus'); } + if(options.inlinePicker){ + popover.openedByFocus = true; + } } }) ; labelWidth(popover.element.children('div.ws-po-outerbox').attr({role: 'group'}), options.labels, true); @@ -2393,77 +2522,87 @@ if(options.disabled){ opener.prop({disabled: true}); } - opener - .on({ - mousedown: function(){ - stopPropagation.apply(this, arguments); - popover.preventBlur(); - }, - click: function(){ - if(popover.isVisible && popover.activeElement){ - popover.openedByFocus = false; - popover.activeElement.focus(); - } - show(); - }, - focus: function(){ - popover.preventBlur(); - } - }) - ; - (function(){ - var mouseFocus = false; - var resetMouseFocus = function(){ - mouseFocus = false; - }; - data.inputElements.on({ - focus: function(){ - if(!popover.stopOpen && (options.buttonOnly || options.openOnFocus || (mouseFocus && options.openOnMouseFocus))){ - popover.openedByFocus = options.buttonOnly ? false : !options.noInput; - show(); - } else { + opener.on({click: open}); + + if(options.inlinePicker){ + popover.openedByFocus = true; + } else { + opener + .on({ + mousedown: function(){ + stopPropagation.apply(this, arguments); popover.preventBlur(); + }, + focus: function(){ + popover.preventBlur(); } - }, - mousedown: function(){ - mouseFocus = true; - setTimeout(resetMouseFocus, 9); - if(options.buttonOnly && popover.isVisible && popover.activeElement){ - popover.openedByFocus = false; - setTimeout(function(){ + }) + ; + + (function(){ + var mouseFocus = false; + var resetMouseFocus = function(){ + mouseFocus = false; + }; + data.inputElements.on({ + keydown: function(e){ + if(e.keyCode == 40 && e.altKey){ + open(); + } + }, + focus: function(){ + if(!popover.stopOpen && (options.buttonOnly || options.openOnFocus || (mouseFocus && options.openOnMouseFocus))){ + popover.openedByFocus = options.buttonOnly ? false : !options.noInput; + show(); + } else { + popover.preventBlur(); + } + }, + mousedown: function(){ + mouseFocus = true; + setTimeout(resetMouseFocus, 9); + if(options.buttonOnly && popover.isVisible && popover.activeElement){ popover.openedByFocus = false; - popover.activeElement.focus(); - }, 4); + setTimeout(function(){ + popover.openedByFocus = false; + popover.activeElement.focus(); + }, 4); + } + if(data.element.is(':focus')){ + popover.openedByFocus = options.buttonOnly ? false : !options.noInput; + show(); + } + popover.preventBlur(); } - if(data.element.is(':focus')){ - popover.openedByFocus = options.buttonOnly ? false : !options.noInput; - show(); - } - popover.preventBlur(); - } - }); - })(); + }); + })(); + } + data.popover = popover; data.opener = opener; $(data.orig).on('remove', function(e){ if(!e.originalEvent){ setTimeout(function(){ opener.remove(); popover.element.remove(); }, 4); } }); - + if(options.inlinePicker){ + show(); + } loadPicker(data.type, 'WINDOWLOAD'); }; picker.month = picker._common; picker.date = picker._common; + picker.time = picker._common; + picker['datetime-local'] = picker._common; // picker.week = picker._common; picker.color = function(data){ var ret = picker._common.apply(this, arguments); var alpha = $(data.orig).data('alphacontrol'); var colorIndicator = data.opener @@ -2643,10 +2782,13 @@ optsName = copyAttrs[i].replace(/^data\-/, ''); if(optsName == 'placeholder' || !opts[optsName]){ opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName]; } } + if(opts.monthSelect){ + opts.onlyMonthDigits = true; + } if(opts.onlyMonthDigits){ opts.formatMonthNames = 'monthDigits'; } data.shim = inputTypes[type]._create(opts); @@ -2748,14 +2890,17 @@ return data; } }); } - var isStupid = navigator.userAgent.indexOf('MSIE 10.0') != -1 && navigator.userAgent.indexOf('Touch') == -1; - ['number', 'time', 'month', 'date', 'color'].forEach(function(name){ + var isStupid = modernizrInputTypes.number && navigator.userAgent.indexOf('Touch') == -1 && (/MSIE 1[0|1]\.\d/.test(navigator.userAgent) || /Trident\/7\.0/.test(navigator.userAgent)); + ['number', 'time', 'month', 'date', 'color', 'datetime-local'].forEach(function(name){ if(!modernizrInputTypes[name] || options.replaceUI || (name == 'number' && isStupid)){ extendType(name, { _create: function(opts, set){ + if(opts.monthSelect){ + opts.splitInput = true; + } if(opts.splitInput && !splitInputs[name]){ webshims.warn('splitInput not supported for '+ name); opts.splitInput = false; } var markup = opts.splitInput ?