1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2024-12-12 03:16:16 +01:00
LocalCDN-Firefox-Chrome-Brave/resources/jeditable.js/2.0.19/jquery.jeditable.min.jsm

3 lines
12 KiB
JavaScript
Raw Normal View History

2020-11-14 09:28:04 +01:00
/*! jquery-jeditable https://github.com/NicolasCARPi/jquery_jeditable#readme */
!function($){"use strict";$.fn.editableAriaShim=function(){return this.attr({role:"button",tabindex:0}),this},$.fn.editable=function(target,options){if("disable"!==target)if("enable"!==target){if("destroy"!==target){var settings=$.extend({},$.fn.editable.defaults,{target:target},options),plugin=$.editable.types[settings.type].plugin||function(){},submit=$.editable.types[settings.type].submit||function(){},buttons=$.editable.types[settings.type].buttons||$.editable.types.defaults.buttons,content=$.editable.types[settings.type].content||$.editable.types.defaults.content,element=$.editable.types[settings.type].element||$.editable.types.defaults.element,reset=$.editable.types[settings.type].reset||$.editable.types.defaults.reset,destroy=$.editable.types[settings.type].destroy||$.editable.types.defaults.destroy,callback=settings.callback||function(){},intercept=settings.intercept||function(s){return s},onedit=settings.onedit||function(){},onsubmit=settings.onsubmit||function(){},onreset=settings.onreset||function(){},onerror=settings.onerror||reset;settings.before;return settings.tooltip&&$(this).attr("title",settings.tooltip),this.each(function(){var self=this;$(this).data("event.editable",settings.event),$.trim($(this).html())||$(this).html(settings.placeholder),"destroy"!==target?($(this).on(settings.event,function(e){if(!0!==$(this).data("disabled.editable")&&9!==e.which&&!self.editing&&!1!==onedit.apply(this,[settings,self,e])){if(settings.before&&jQuery.isFunction(settings.before))settings.before(e);else if(settings.before&&!jQuery.isFunction(settings.before))throw"The 'before' option needs to be provided as a function!";e.preventDefault(),e.stopPropagation(),settings.tooltip&&$(self).removeAttr("title"),$(this).html().toLowerCase().replace(/(;|"|\/)/g,"")===settings.placeholder.toLowerCase().replace(/(;|"|\/)/g,"")&&$(this).html(""),self.editing=!0,self.revert=$(self).text(),$(self).html("");var form=$("<form />");settings.cssclass&&("inherit"===settings.cssclass?form.attr("class",$(self).attr("class")):form.attr("class",settings.cssclass)),settings.style&&("inherit"===settings.style?(form.attr("style",$(self).attr("style")),form.css("display",$(self).css("display"))):form.attr("style",settings.style)),settings.label&&form.append("<label>"+settings.label+"</label>"),settings.formid&&form.attr("id",settings.formid);var input_content,t,input=element.apply(form,[settings,self]);settings.inputcssclass&&("inherit"===settings.inputcssclass?input.attr("class",$(self).attr("class")):input.attr("class",settings.inputcssclass));var isSubmitting=!1;if(settings.loadurl){t=self.setTimeout(function(){input.disabled=!0},100),$(self).html(settings.loadtext);var loaddata={};loaddata[settings.id]=self.id,$.isFunction(settings.loaddata)?$.extend(loaddata,settings.loaddata.apply(self,[self.revert,settings])):$.extend(loaddata,settings.loaddata),$.ajax({type:settings.loadtype,url:settings.loadurl,data:loaddata,async:!1,cache:!1,success:function(result){self.clearTimeout(t),input_content=result,input.disabled=!1}})}else settings.data?(input_content=settings.data,$.isFunction(settings.data)&&(input_content=settings.data.apply(self,[self.revert,settings]))):input_content=self.revert;if(content.apply(form,[input_content,settings,self]),input.attr("name",settings.name),"none"!==settings.width){var adj_width=settings.width-(input.outerWidth(!0)-settings.width);input.width(adj_width)}buttons.apply(form,[settings,self]),settings.showfn&&$.isFunction(settings.showfn)&&form.hide(),$(self).html(""),$(self).append(form),settings.showfn&&$.isFunction(settings.showfn)&&settings.showfn(form),plugin.apply(form,[settings,self]),form.find(":input:visible:enabled:first").trigger("focus"),settings.select&&input.select(),$(this).on("keydown",function(e){27===e.which?(e.preventDefault(),reset.apply(form,[settings,self])):13==e.which&&e.shiftKey&&(e.preventDefault(),form.trigger("submit"))}),"cancel"===settings.onblur?input.on("blur",function(e){t=self.setTimeout(function(){reset.apply(form,[settings,self])},500)}):"submit"===settings.onblur?input.on("blur",fun