agenda-libre-ruby/public/webshims/1.15.8/shims/combos/17.js

2 lines
50 KiB
JavaScript
Raw Normal View History

webshims.register("form-number-date-api",function(a,b){"use strict";b.addInputType||b.error("you can not call forms-ext feature after calling forms feature. call both at once instead: $.webshims.polyfill('forms forms-ext')"),b.getStep||(b.getStep=function(b,c){var e=a.attr(b,"step");return"any"===e?e:(c=c||g(b),d[c]&&d[c].step?(e=o.number.asNumber(e),(!isNaN(e)&&e>0?e:d[c].step)*(d[c].stepScaleFactor||1)):e)}),b.addMinMaxNumberToCache||(b.addMinMaxNumberToCache=function(a,b,c){a+"AsNumber"in c||(c[a+"AsNumber"]=d[c.type].asNumber(b.attr(a)),isNaN(c[a+"AsNumber"])&&a+"Default"in d[c.type]&&(c[a+"AsNumber"]=d[c.type][a+"Default"]))});var c=parseInt("NaN",10),d=b.inputTypes,e=function(a){return"number"==typeof a||a&&a==1*a},f=function(b){return a('<input type="'+b+'" />').prop("type")===b},g=function(a){return(a.getAttribute("type")||"").toLowerCase()},h=function(a){return a&&!isNaN(1*a)},i=b.addMinMaxNumberToCache,j=function(a,b){a=""+a,b-=a.length;for(var c=0;b>c;c++)a="0"+a;return a},k=1e-7,l=b.bugs.bustedValidity;b.addValidityRule("stepMismatch",function(a,c,e,f){if(""===c)return!1;if("type"in e||(e.type=g(a[0])),"week"==e.type)return!1;var h,j,l=(f||{}).stepMismatch||!1;if(d[e.type]&&d[e.type].step){if("step"in e||(e.step=b.getStep(a[0],e.type)),"any"==e.step)return!1;if("valueAsNumber"in e||(e.valueAsNumber=d[e.type].asNumber(c)),isNaN(e.valueAsNumber))return!1;i("min",a,e),h=e.minAsNumber,isNaN(h)&&(j=a.prop("defaultValue"))&&(h=d[e.type].asNumber(j)),isNaN(h)&&(h=d[e.type].stepBase||0),l=Math.abs((e.valueAsNumber-h)%e.step),l=!(k>=l||Math.abs(l-e.step)<=k)}return l}),[{name:"rangeOverflow",attr:"max",factor:1},{name:"rangeUnderflow",attr:"min",factor:-1}].forEach(function(a){b.addValidityRule(a.name,function(b,c,e,f){var h=(f||{})[a.name]||!1;if(""===c)return h;if("type"in e||(e.type=g(b[0])),d[e.type]&&d[e.type].asNumber){if("valueAsNumber"in e||(e.valueAsNumber=d[e.type].asNumber(c)),isNaN(e.valueAsNumber))return!1;if(i(a.attr,b,e),isNaN(e[a.attr+"AsNumber"]))return h;h=e[a.attr+"AsNumber"]*a.factor<e.valueAsNumber*a.factor-k}return h})}),b.reflectProperties(["input"],["max","min","step"]);var m=b.defineNodeNameProperty("input","valueAsNumber",{prop:{get:function(){var b=this,e=g(b),f=d[e]&&d[e].asNumber?d[e].asNumber(a.prop(b,"value")):m.prop._supget&&m.prop._supget.apply(b,arguments);return null==f&&(f=c),f},set:function(c){var e=this,f=g(e);if(d[f]&&d[f].numberToString){if(isNaN(c))return void a.prop(e,"value","");var h=d[f].numberToString(c);h!==!1?a.prop(e,"value",h):b.error("INVALID_STATE_ERR: DOM Exception 11")}else m.prop._supset&&m.prop._supset.apply(e,arguments)}}}),n=b.defineNodeNameProperty("input","valueAsDate",{prop:{get:function(){var b=this,c=g(b);return d[c]&&d[c].asDate&&!d[c].noAsDate?d[c].asDate(a.prop(b,"value")):n.prop._supget&&n.prop._supget.call(b)||null},set:function(c){var e=this,f=g(e);if(!d[f]||!d[f].dateToString||d[f].noAsDate)return n.prop._supset&&n.prop._supset.apply(e,arguments)||null;if(null===c)return a.prop(e,"value",""),"";var h=d[f].dateToString(c);return h!==!1?(a.prop(e,"value",h),h):void b.error("INVALID_STATE_ERR: DOM Exception 11")}}});a.each({stepUp:1,stepDown:-1},function(c,e){var f=b.defineNodeNameProperty("input",c,{prop:{value:function(c){var h,i,j,l,m,n,o,p=g(this);if(!d[p]||!d[p].asNumber){if(f.prop&&f.prop._supvalue)return f.prop._supvalue.apply(this,arguments);throw b.info("no step method for type: "+p),"invalid state error"}if(m={type:p},c||(c=1,b.warn("you should always use a factor for stepUp/stepDown")),c*=e,h=b.getStep(this,p),"any"==h)throw b.info("step is 'any' can't apply stepUp/stepDown"),"invalid state error";return b.addMinMaxNumberToCache("min",a(this),m),b.addMinMaxNumberToCache("max",a(this),m),i=a.prop(this,"valueAsNumber"),c>0&&!isNaN(m.minAsNumber)&&(isNaN(i)||m.minAsNumber>i)?void a.prop(this,"valueAsNumber",m.minAsNumber):0>c&&!isNaN(m.maxAsNumber)&&(isNaN(i)||m.maxAsNumber<i)?void a.prop(this,"valueAsNumber",m.maxAsNumber):(isNaN(i)&&(i=0),n=m.minAsNumber,isNaN(n)&&(o=a.prop(this,"defaultValue"))&&(n=d[p].asNumber(o)),n||(n=0),h*=c,i=1*(i+h).
},parseValue:function(b){var c=this.inputElements.map(function(){return a.prop(this,"value")}).get();return this.options.splitInput||(c=c[0]),e[this.type](c,this.options,b)},formatValue:function(a,b){return d[this.type](a,b===!1?!1:this.options)},createOpts:["readonly","title","disabled","tabindex","placeholder","defaultValue","value","required"],placeholder:function(b){var c=this.options;c.placeholder=b;var d=b;f[this.type]&&(d=f[this.type](b,this.options)),c.splitInput&&"object"==typeof d?a.each(this.splits,function(b,c){a.nodeName(c,"select")?a(c).children("option:first-child").text(d[b]):a.prop(c,"placeholder",d[b])}):this.element.prop("placeholder",d)},list:function(b){"number"==this.type&&this.element.attr("list",a.attr(this.orig,"list")),this.options.list=b,this._propertyChange("list")},_propertyChange:a.noop,tabindex:function(b){this.options.tabindex=b,this.inputElements.prop("tabindex",this.options.tabindex),a("button",this.buttonWrapper).prop("tabindex",this.options.tabindex)},title:function(b){!b&&this.orig&&null==a.attr(this.orig,"title")&&(b=null),this.options.title=b,null==b?this.inputElements.removeAttr("title"):this.inputElements.prop("title",this.options.title)}};["defaultValue","value"].forEach(function(a){var b="format"+a;j[a]=function(c,d){(!this._init||d||c!==this.options[a]||this.options[b]!=this.element.prop(a))&&(this.options[b]=this.formatValue(c),this.element.prop(a,this.options[b]),this.options[a]=c,this._propertyChange(a),this.mirrorValidity())}}),["readonly","disabled"].forEach(function(b){var c="disabled"==b;j[b]=function(d,e){var f=this.options;f[b]==e&&this._init||(f[b]=!!e,!c&&f.buttonOnly?this.inputElements.attr({"aria-readonly":f[b]}):this.inputElements.prop(b,f[b]),this.buttonWrapper[f[b]?"addClass":"removeClass"]("ws-"+b),c&&a("button",this.buttonWrapper).prop("disabled",f[b]))}});var k=a.extend({},j,{_create:function(){var c=this.options,d=h(c.type);this.elemHelper=a('<input type="'+c.type+'" />'),this.asNumber=d.asNumber,this.asValue=d.asValue,this.isValid=d.isValid,this.asDate=d.asDate,j._create.apply(this,arguments),this._init=!1,this.buttonWrapper.html('<span unselectable="on" class="step-controls"><span class="step-up step-control"></span><span class="step-down step-control"></span></span>'),"number"==this.type&&this.inputElements.attr("inputmode","numeric"),(!c.max&&"number"==typeof c.relMax||!c.min&&"number"==typeof c.relMin)&&b.error("relMax/relMin are not supported anymore calculate at set it your own."),this.options.relDefaultValue&&b.warn("relDefaultValue was removed use startValue instead!"),this._init=!0},createOpts:["step","min","max","readonly","title","disabled","tabindex","placeholder","defaultValue","value","required"],_addSplitInputs:function(){if(!this.inputElements){var b=q[this.type]._create(this.options);this.splits=b.splits,this.inputElements=a(b.elements).prependTo(this.element).filter("input, select")}},addZero:v,_setStartInRange:function(){var a=this.options.startValue&&this.asNumber(this.options.startValue)||t[this.type].start||0;!isNaN(this.minAsNumber)&&a<this.minAsNumber?a=this.minAsNumber:!isNaN(this.maxAsNumber)&&a>this.maxAsNumber&&(a=this.maxAsNumber);try{this.elemHelper.prop("valueAsNumber",a)}catch(c){b.warn("valueAsNumber set: "+c)}this.options.defValue=this.elemHelper.prop("value")},reorderInputs:function(){if(q[this.type]){var a=this.element.attr("dir",g.date.isRTL?"rtl":"ltr");q[this.type].sort(a,this.options),setTimeout(function(){var c=b.data(a);c&&c.shadowData&&(c.shadowData.shadowFocusElement=a.find("input, select")[0]||a[0])},9)}},step:function(a){var b=t[this.type];this.options.step=a,this.elemHelper.prop("step",c(a,b.step)),this.mirrorValidity()},_beforeValue:function(a){this.valueAsNumber=this.asNumber(a),this.options.value=a,isNaN(this.valueAsNumber)||!isNaN(this.minAsNumber)&&this.valueAsNumber<this.minAsNumber||!isNaN(this.maxAsNumber)&&this.valueAsNumber>this.maxAsNumber?this._setStartInRange():(this.elemHelper.prop("value",a),this.options.defValue="")},toFixed:function(a,b){var c=this.options;return!c.toFixed||"number"!=c.type||!