vendor/assets/javascripts/webshims/shims/forms-picker.js in webshims-rails-1.13.0 vs vendor/assets/javascripts/webshims/shims/forms-picker.js in webshims-rails-1.14.1

- old
+ new

@@ -344,11 +344,11 @@ } str.push('<span class="'+ cName +'">'+ name.join(' ') +'</span>'); }); return str.join(''); }; - + var setJump = ('inputMode' in document.createElement('input')) || !((/ipad|iphone/i).test(navigator.userAgent)); var widgetProtos = { _addBindings: function(){ var isFocused; var that = this; @@ -494,10 +494,11 @@ }; })(), 'ws__input keydown keypress': (function(){ var timer; var isStopped = false; + var releaseTab = function(){ if (isStopped === true) { isStopped = 'semi'; timer = setTimeout(releaseTab, 250); } @@ -559,11 +560,11 @@ preventBlur.prevent = true; setTimeout(reset, 9); }; })(); - if(o.splitInput && o.jumpInputs == null){ + if(o.splitInput && setJump && o.jumpInputs == null){ o.jumpInputs = true; } this.buttonWrapper.on('mousedown', mouseDownInit); @@ -953,11 +954,11 @@ var currentValue = o.value.split('-'); var xthCorrect = 0; var enabled = 0; var str = ''; var rowNum = 0; - var triggerValueValidation = (data.orig && ('valuevalidation' in $.data(data.orig))); + var triggerValueValidation = (data.orig && ('validatevalue' in $.data(data.orig))); if(!data.options.useDecadeBase){ if(!max[0] && min[0]){ data.options.useDecadeBase = 'min'; } else if(max[0] && !min[0]){ @@ -986,11 +987,11 @@ str += '<div class="year-list picker-list ws-index-'+ j +'"><div class="ws-picker-header"><select data-action="setYearList" class="decade-select">'+ picker.createYearSelect(value, max, min, '', {start: start, step: 12 * size, label: start+' – '+(start + 11)}).join('') +'</select><button disabled="disabled"><span>'+ start +' – '+(start + 11)+'</span></button></div>'; lis = []; for(i = 0; i < 12; i++){ val = start + i ; classArray = []; - if( !picker.isInRange([val], max, min) || (triggerValueValidation && $(data.orig).triggerHandler('valuevalidation', [{value: val, valueAsDate: null, isPartial: [val]}]))){ + if( !picker.isInRange([val], max, min) || (triggerValueValidation && $(data.orig).triggerHandler('validatevalue', [{value: val, valueAsDate: null, isPartial: [val]}]))){ disabled = ' disabled=""'; } else { disabled = ''; enabled++; } @@ -1038,11 +1039,11 @@ var currentValue = o.value.split('-'); var enabled = 0; var rowNum = 0; var str = ''; var action = data.type == 'month' ? 'changeInput' : 'setDayList' ; - var triggerValueValidation = (data.orig && ('valuevalidation' in $.data(data.orig))); + var triggerValueValidation = (data.orig && ('validatevalue' in $.data(data.orig))); var isPartial = action != 'changeInput'; value = value[0] - Math.floor((size - 1) / 2); for(j = 0; j < size; j++){ if(j){ @@ -1073,11 +1074,11 @@ for(i = 0; i < 12; i++){ val = curCfg.date.monthkeys[i+1]; name = getMonthNameHTML(i); classArray = []; - if(!picker.isInRange([value, val], max, min) || (triggerValueValidation && $(data.orig).triggerHandler('valuevalidation', [{value: value+'-'+val, valueAsDate: data.asDate(value+'-'+val), isPartial: isPartial && [value, val]}]))){ + if(!picker.isInRange([value, val], max, min) || (triggerValueValidation && $(data.orig).triggerHandler('validatevalue', [{value: value+'-'+val, valueAsDate: data.asDate(value+'-'+val), isPartial: isPartial && [value, val]}]))){ disabled = ' disabled=""'; } else { disabled = ''; enabled++; } @@ -1127,11 +1128,11 @@ var currentValue = o.value.split('T')[0].split('-'); var dateCfg = curCfg.date; var str = []; var date = new Date(value[0], value[1] - 1, 1); var action = (data.type == 'datetime-local') ? 'setTimeList' : 'changeInput'; - var triggerValueValidation = (data.orig && ('valuevalidation' in $.data(data.orig))); + var triggerValueValidation = (data.orig && ('validatevalue' in $.data(data.orig))); var isPartial = action != 'changeInput'; date.setMonth(date.getMonth() - Math.floor((size - 1) / 2)); yearNext = [ (value[0] * 1) + 1, value[1] ]; @@ -1244,11 +1245,11 @@ if(classArray.length){ buttonStr += ' class="'+ classArray.join(' ') +'"'; } - if(!picker.isInRange(dateArray, max, min) || (triggerValueValidation && $(data.orig).triggerHandler('valuevalidation', [{value: dateArray.join('-'), valueAsDate: date, isPartial: isPartial && dateArray}]))){ + if(!picker.isInRange(dateArray, max, min) || (triggerValueValidation && $(data.orig).triggerHandler('validatevalue', [{value: dateArray.join('-'), valueAsDate: date, isPartial: isPartial && dateArray}]))){ buttonStr += ' disabled=""'; } str.push(buttonStr+' tabindex="-1">'+ date.getDate() +'</button></td>'); @@ -1281,16 +1282,17 @@ var label, tmpValue, iVal, hVal, valPrefix; var str = '<div class="time-list picker-list ws-index-0">'; var i = 0; var rowNum = 0; var len = 23; + var attrs = { min: $.prop(data.orig, 'min'), max: $.prop(data.orig, 'max'), step: $.prop(data.orig, 'step') }; - var triggerValueValidation = (data.orig && ('valuevalidation' in $.data(data.orig))); + var triggerValueValidation = (data.orig && ('validatevalue' in $.data(data.orig))); var gridLabel = ''; if(data.type == 'time'){ label = '<button type="button" disabled="">'+ $.trim($(data.orig).jProp('labels').text() || '').replace(/[\:\*]/g, '')+'</button>'; } else { @@ -1319,17 +1321,18 @@ rowNum++; str += '</tr><tr class="ws-row-'+ rowNum +'">'; } str += '<td role="presentation"><button role="gridcell" data-action="changeInput" value="'+ hVal +'" type="button" tabindex="-1"'; - if(!data.isValid(hVal, attrs) || (triggerValueValidation && $(data.orig).triggerHandler('valuevalidation', [{value: hVal, valueAsDate: data.asDate(hVal), partial: false}]))){ + if(!data.isValid(hVal, attrs) || (triggerValueValidation && $(data.orig).triggerHandler('validatevalue', [{value: hVal, valueAsDate: data.asDate(hVal), partial: false}]))){ str += ' disabled=""'; } if(value == iVal){ str += ' class="checked-value"'; } - str += '>'+ data.formatValue(iVal) +'</button></td>'; + + str += '>'+ webshims._format.time(iVal) +'</button></td>'; } str += '</tr></tbody></table></div></div>'; @@ -1559,10 +1562,10 @@ text = (formcfg[''][[data.type]] || {}).currentText || (curCfg.date || {}).currentText || 'current'; webshims.warn("could not get currentText from form cfg for "+data.type); } if(today[data.type] && data.type != 'time'){ - $.prop(this, 'disabled', (!picker.isInRange(today[data.type].split('-'), o.maxS, o.minS) || !!$(data.orig).triggerHandler('valuevalidation', [{value: today[data.type], valueAsDate: new Date(), isPartial: false}]))); + $.prop(this, 'disabled', (!picker.isInRange(today[data.type].split('-'), o.maxS, o.minS) || !!$(data.orig).triggerHandler('validatevalue', [{value: today[data.type], valueAsDate: new Date(), isPartial: false}]))); } } if(text){ $(this).text(text).attr({'aria-label': text}); }