From 09358eaaf6a5636cf6fdbe4f96f9d29e2bba90b3 Mon Sep 17 00:00:00 2001 From: Micha Date: Tue, 29 Jul 2025 16:11:16 +0200 Subject: [PATCH] v25.0.7: Fix distribution file dependencies and production click handler issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Major Fix - Production Distribution Dependencies - Fix missing click handlers in production by ensuring proper dependency management - Add select2 to Gruntfile.js common inputs to include it in built distribution - Resolve 'this.$input.select2 is not a function' error in production builds - Update demo to include select2 and bootstrap-datepicker as separate dependencies when using built files ## Dependencies & Usage - Built distribution files now include select2 input type in bootstrap-editable.min.js - Users must include select2 and bootstrap-datepicker separately when using built files: - import 'select2' and 'select2/dist/css/select2.min.css' - import 'bootstrap-datepicker' and 'bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css' - This matches standard JavaScript library dependency patterns ## Technical Details - Root cause: JavaScript cascade failure when select2 dependency was missing - Missing select2 prevented entire x-editable initialization, breaking click handlers - Now both webpack source build and Grunt distribution include same input types - Maintains backward compatibility while fixing production deployment issues ## Fixes Production Issues - ✅ Click handlers now properly attach in production - ✅ Form submission logic works correctly - ✅ All input types functional (text, select, select2, date, etc.) - ✅ Proper event binding and library initialization - ✅ No more 'Unknown type: select2' errors --- Gruntfile.js | 3 +- demo/demo.js | 9 +- dist/240c0c6464de0b4bf116.png | Bin 0 -> 509 bytes dist/56d4c7ce2d3591a02107.gif | Bin 0 -> 1849 bytes .../css/bootstrap-editable.css | 2 +- .../js/bootstrap-editable.js | 363 +++++++++++++++++- .../js/bootstrap-editable.min.js | 4 +- package.json | 2 +- 8 files changed, 375 insertions(+), 8 deletions(-) create mode 100644 dist/240c0c6464de0b4bf116.png create mode 100644 dist/56d4c7ce2d3591a02107.gif diff --git a/Gruntfile.js b/Gruntfile.js index 7cc1ce8..98b0b61 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -34,7 +34,8 @@ function getFiles() { inputs+'list.js', inputs+'text.js', inputs+'textarea.js', - inputs+'select.js', + inputs+'select.js', + inputs+'select2/select2.js', inputs+'checklist.js', inputs+'html5types.js' ]; diff --git a/demo/demo.js b/demo/demo.js index 900fd36..dbf8543 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -12,8 +12,13 @@ import "bootstrap-datepicker"; import "bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css"; -// Import the editable functionality (attaches to jQuery.fn) - using webpack source build -require("../src/bootstrap5-editable.js"); +// Import the editable functionality (attaches to jQuery.fn) - using built distribution +// When using built files, you need to include select2 separately for select2 inputs +import "select2"; +import "select2/dist/css/select2.min.css"; +import '../dist/bootstrap5-editable/js/bootstrap-editable.min.js' +import '../dist/bootstrap5-editable/css/bootstrap-editable.css' + $.fn.editable.defaults.mode = 'inline'; $(function() { diff --git a/dist/240c0c6464de0b4bf116.png b/dist/240c0c6464de0b4bf116.png new file mode 100644 index 0000000000000000000000000000000000000000..580b52a5be8a644f826def0c7ed6a13f90c0915c GIT binary patch literal 509 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4u6ByT*@`3|I*lDyqr82-2SpV<%OaTa()76WMy zFm^kcZ3hx8D{xE)(qO#|GLJ6IVqjoo^>lFzk+^JnVSiR|B17B9``_m-NuMxfR?C!* zh07MrSo)3sr09zP_wDzlhX=fPF>UDu=?vANf(w(JrZ%)>D41|8J9+Zugm01epVrPx zINBDzitE|2b$6T`9`!DJFmdU=eKrTz=_*cb3=s8r9VQ%8yxBf7d%v=5Nxh^7ZP6=ia-yr`GWA z@1JRG_RM@X%BIyHqImbIN_g6wl?zIFvhME$`)4a}gbAnqdolZft=%U7gPsvQH z#I2z#?2;8wgCxj?;QX|b^2DN42FH~Aq*MjZ+{Ezopr E0Crl)MgRZ+ literal 0 HcmV?d00001 diff --git a/dist/56d4c7ce2d3591a02107.gif b/dist/56d4c7ce2d3591a02107.gif new file mode 100644 index 0000000000000000000000000000000000000000..5b33f7e54f4e55b6b8774d86d96895db9af044b4 GIT binary patch literal 1849 zcma*odr(tX9tZI2z31lM+(&YVk%mZ}5P~KlG2s=WSbGzm0!x7^P##Mnh7t-jP!X0Q zk_SQ}Po-L1tlDK;6l?(>v)e5ZBQx4|Y-Q?nr@Px3?9h(3ZWr3^tj=`TP57gKr87N$ zp2wWee1GRRCwo_xahnw)5cxNPJbCg2L6DV|6`#+yw6v6!mDS$f9-JvFD^n;GQ&UrZ zzh5jCkByB101O60U0q#p_1BM>Cv-vP?&s4@g_((4_1L=L$(a91)0=J91Gas#R{McE znYG^9*0A5YZ>#;~+Wkn(W5B0^yELIYLP!K}mB~<)AM@1&nqekynuaEGqPrzoH|KodRXJy)%+w_fu3nE5>@Bd_b zqC$EQ;{c`T&?EsNO|igL9gC7Ygxv?aQUEXMq?~>wg{EyW;VcJ37CUF#HjrT=KQO_* zS>M9yydXk18D(+QDJ1>r);Lav_uYKp$T?4vr{Q$lTo&pKv^?(>L-)G2*lwH!Ah7k? z7oH<8h-(KTKt5V6$8gF)C7Io&P5=SjTh)=zV=E2EUhQZP##L8S{d%UK>>+y82>+FV+#^BzW7u3F)Bb>=lYQ%%j`F>ASe zo*cw@V#u6T`A2He;70mR(V&iV&-7{qP~=SRf&jm9-T{*ZeZ}$rd0#6c&fLG^xJcf5 z+p<`wJYgW+_s*V{uI$nMB;%8`S_3>PfGOj3Rq}@Cx^+j?rk92fANSFDBYnOqQ>Vdj z)(|$AhP4t&Lb=Gvo2#3Gl%9<=Gv`Mz?Po@P4iLF!x}GUWJICDlFk-hS^Whyh7x~VH z@0vD1>HYD4&e+~yzS*-sFR{9`{QEEZO1zg7>R&7cHts-6j!xHVdA8eI+ZlVzd%`es zJT@$#GX(gvCJ1oJN%yLBK}{V=V;seo;!w|Yte!W1%5qLNFWqvZW>h&IiH+oPT=b@E zPhGzv5=(Un*X>v`>%8h_nj^NdYcE6NHS_ifkCV$*D)Tqrbu`s;<=t<4 zAHNqNV?6(g<1PY-w@#I-WYFViz?9TrkMr)u0g`O`u|>T;k|2sV*YF^punvT;$SuTy{j3Gv)yqD!R_CF>yR)MzmmYS5v+~R zXAdD%ng9?df;wd8GxR#%3O+gz};Vo;)sK%Bj-q>Oq%R7JU-KD?vYu>#2UjaDo z&8$>5xW~?KPD_#XFToU1hIb*VOMidUr6iYiO0N|i-7s`T8!cFT`rN!^1Pt78J93i6 z5HI1wIM$94m{3SLDvISDe6$ZG1;eq_D9RTaaC>=cO{@Bs>$IlPCPJJ$h$)-3vzNUQ6OsN#_zWxey!_9%hxwH2_dEJi=yY|1c7nDm2_Lm!Cof8-R_+9UkS zcBE(o47yE)oMR(Q=dp1a2wTX5KvvGyLqlWTa7V&!A*|w|)ax~1_~aJ0=_Lilg*0iQk7#ZD EAHN$8j{pDw literal 0 HcmV?d00001 diff --git a/dist/bootstrap5-editable/css/bootstrap-editable.css b/dist/bootstrap5-editable/css/bootstrap-editable.css index 89300b2..be27dbd 100644 --- a/dist/bootstrap5-editable/css/bootstrap-editable.css +++ b/dist/bootstrap5-editable/css/bootstrap-editable.css @@ -1,4 +1,4 @@ -/*! X-editable Bootstrap 5 - v25.0.6 +/*! X-editable Bootstrap 5 - v25.0.7 * A maintained fork of x-editable for Bootstrap 5 support. * https://git.24unix.net/tracer/x-editable * Copyright (c) 2025 Micha Espey; Licensed MIT */ diff --git a/dist/bootstrap5-editable/js/bootstrap-editable.js b/dist/bootstrap5-editable/js/bootstrap-editable.js index e2e6660..df448dc 100644 --- a/dist/bootstrap5-editable/js/bootstrap-editable.js +++ b/dist/bootstrap5-editable/js/bootstrap-editable.js @@ -1,4 +1,4 @@ -/*! X-editable Bootstrap 5 - v25.0.6 +/*! X-editable Bootstrap 5 - v25.0.7 * A maintained fork of x-editable for Bootstrap 5 support. * https://git.24unix.net/tracer/x-editable * Copyright (c) 2025 Micha Espey; Licensed MIT */ @@ -3227,6 +3227,367 @@ $(function(){ }(window.jQuery)); +/** +Select2 input. Based on amazing work of Igor Vaynberg https://github.com/ivaynberg/select2. +Please see [original select2 docs](http://ivaynberg.github.com/select2) for detailed description and options. + +You should manually download and include select2 distributive: + + + + +To make it **bootstrap-styled** you can use css from [here](https://github.com/t0m/select2-bootstrap-css): + + + +**Note:** currently `autotext` feature does not work for select2 with `ajax` remote source. +You need initially put both `data-value` and element's text youself: + + Text1 + + +@class select2 +@extends abstractinput +@since 1.4.1 +@final +@example + + +**/ +(function ($) { + "use strict"; + + var Constructor = function (options) { + this.init('select2', options, Constructor.defaults); + + options.select2 = options.select2 || {}; + + this.sourceData = null; + + //placeholder + if(options.placeholder) { + options.select2.placeholder = options.placeholder; + } + + //if not `tags` mode, use source + if(!options.select2.tags && options.source) { + var source = options.source; + //if source is function, call it (once!) + if (typeof (options.source) === 'function') { + source = options.source.call(options.scope); + } + + if (typeof source === 'string') { + options.select2.ajax = options.select2.ajax || {}; + //some default ajax params + if(!options.select2.ajax.data) { + options.select2.ajax.data = function(term) {return { query:term };}; + } + if(!options.select2.ajax.results) { + options.select2.ajax.results = function(data) { return {results:data };}; + } + options.select2.ajax.url = source; + } else { + //check format and convert x-editable format to select2 format (if needed) + this.sourceData = this.convertSource(source); + options.select2.data = this.sourceData; + } + } + + //overriding objects in config (as by default jQuery extend() is not recursive) + this.options.select2 = $.extend({}, Constructor.defaults.select2, options.select2); + + //detect whether it is multi-valued + this.isMultiple = this.options.select2.tags || this.options.select2.multiple; + this.isRemote = ('ajax' in this.options.select2); + + //store function returning ID of item + //should be here as used inautotext for local source + this.idFunc = this.options.select2.id; + if (typeof(this.idFunc) !== "function") { + var idKey = this.idFunc || 'id'; + this.idFunc = function (e) { return e[idKey]; }; + } + + //store function that renders text in select2 + this.formatSelection = this.options.select2.formatSelection; + if (typeof(this.formatSelection) !== "function") { + this.formatSelection = function (e) { return e.text; }; + } + }; + + $.fn.editableutils.inherit(Constructor, $.fn.editabletypes.abstractinput); + + $.extend(Constructor.prototype, { + render: function() { + this.setClass(); + + //can not apply select2 here as it calls initSelection + //over input that does not have correct value yet. + //apply select2 only in value2input + //this.$input.select2(this.options.select2); + + //when data is loaded via ajax, we need to know when it's done to populate listData + if(this.isRemote) { + //listen to loaded event to populate data + this.$input.on('select2-loaded', $.proxy(function(e) { + this.sourceData = e.items.results; + }, this)); + } + + //trigger resize of editableform to re-position container in multi-valued mode + if(this.isMultiple) { + this.$input.on('change', function() { + $(this).closest('form').parent().triggerHandler('resize'); + }); + } + + // Fix for Select2 v4.1.0 - manually update value when selection is made + // This fixes the issue where select2:select event fires but the value doesn't update + this.$input.on('select2:select', function(e) { + if (e.params && e.params.data && e.params.data.id !== undefined) { + $(this).val(e.params.data.id); + $(this).trigger('change.select2'); + } + }); + }, + + value2html: function(value, element) { + var text = '', data, + that = this; + + if(this.options.select2.tags) { //in tags mode just assign value + data = value; + //data = $.fn.editableutils.itemsByValue(value, this.options.select2.tags, this.idFunc); + } else if(this.sourceData) { + data = $.fn.editableutils.itemsByValue(value, this.sourceData, this.idFunc); + } else { + //can not get list of possible values + //(e.g. autotext for select2 with ajax source) + } + + //data may be array (when multiple values allowed) + if(Array.isArray(data)) { + //collect selected data and show with separator + text = []; + $.each(data, function(k, v){ + text.push(v && typeof v === 'object' ? that.formatSelection(v) : v); + }); + } else if(data) { + text = that.formatSelection(data); + } + + text = Array.isArray(text) ? text.join(this.options.viewseparator) : text; + + //$(element).text(text); + Constructor.superclass.value2html.call(this, text, element); + }, + + html2value: function(html) { + return this.options.select2.tags ? this.str2value(html, this.options.viewseparator) : null; + }, + + value2input: function(value) { + // if value array => join it anyway + if(Array.isArray(value)) { + value = value.join(this.getSeparator()); + } + + //for remote source just set value, text is updated by initSelection + if(!this.$input.data('select2')) { + this.$input.val(value); + this.$input.select2(this.options.select2); + } else { + //Use select2's proper API to set the value instead of just the hidden input + // Try Select2 v4 API - first set the value, then trigger change + this.$input.val(value); + this.$input.trigger('change.select2'); + //second argument needed to separate initial change from user's click (for autosubmit) + this.$input.trigger('change', true); + } + + // if defined remote source AND no multiple mode AND no user's initSelection provided --> + // we should somehow get text for provided id. + // The solution is to use element's text as text for that id (exclude empty) + if(this.isRemote && !this.isMultiple && !this.options.select2.initSelection) { + // customId and customText are methods to extract `id` and `text` from data object + // we can use this workaround only if user did not define these methods + // otherwise we cant construct data object + var customId = this.options.select2.id, + customText = this.options.select2.formatSelection; + + if(!customId && !customText) { + var $el = $(this.options.scope); + if (!$el.data('editable').isEmpty) { + var data = {id: value, text: $el.text()}; + this.$input.select2('data', data); + } + } + } + }, + + input2value: function() { + return this.$input.select2('val'); + }, + + str2value: function(str, separator) { + if(typeof str !== 'string' || !this.isMultiple) { + return str; + } + + separator = separator || this.getSeparator(); + + var val, i, l; + + if (str === null || str.length < 1) { + return null; + } + val = str.split(separator); + for (i = 0, l = val.length; i < l; i = i + 1) { + val[i] = val[i].trim(); + } + + return val; + }, + + autosubmit: function() { + this.$input.on('change', function(e, isInitial){ + if(!isInitial) { + $(this).closest('form').submit(); + } + }); + }, + + getSeparator: function() { + return this.options.select2.separator || $.fn.select2.defaults.separator; + }, + + /* + Converts source from x-editable format: {value: 1, text: "1"} to + select2 format: {id: 1, text: "1"} + */ + convertSource: function(source) { + if(Array.isArray(source) && source.length && source[0].value !== undefined) { + for(var i = 0; i + **/ + tpl:'', + /** + Configuration of select2. [Full list of options](http://ivaynberg.github.com/select2). + + @property select2 + @type object + @default null + **/ + select2: null, + /** + Placeholder attribute of select + + @property placeholder + @type string + @default null + **/ + placeholder: null, + /** + Source data for select. It will be assigned to select2 `data` property and kept here just for convenience. + Please note, that format is different from simple `select` input: use 'id' instead of 'value'. + E.g. `[{id: 1, text: "text1"}, {id: 2, text: "text2"}, ...]`. + + @property source + @type array|string|function + @default null + **/ + source: null, + /** + Separator used to display tags. + + @property viewseparator + @type string + @default ', ' + **/ + viewseparator: ', ' + }); + + $.fn.editabletypes.select2 = Constructor; + +}(window.jQuery)); + /** List of checkboxes. Internally value stored as javascript array of values. diff --git a/dist/bootstrap5-editable/js/bootstrap-editable.min.js b/dist/bootstrap5-editable/js/bootstrap-editable.min.js index 2be39d6..41b2163 100644 --- a/dist/bootstrap5-editable/js/bootstrap-editable.min.js +++ b/dist/bootstrap5-editable/js/bootstrap-editable.min.js @@ -1,5 +1,5 @@ -/*! X-editable Bootstrap 5 - v25.0.6 +/*! X-editable Bootstrap 5 - v25.0.7 * A maintained fork of x-editable for Bootstrap 5 support. * https://git.24unix.net/tracer/x-editable * Copyright (c) 2025 Micha Espey; Licensed MIT */ -(o=>{function s(t,e){this.options=o.extend({},o.fn.editableform.defaults,e),this.$div=o(t),this.options.scope||(this.options.scope=this)}s.prototype={constructor:s,initInput:function(){this.input=this.options.input,this.value=this.input.str2value(this.options.value),this.input.prerender()},initTemplate:function(){this.$form=o(o.fn.editableform.template)},initButtons:function(){var t=this.$form.find(".editable-buttons");t.append(o.fn.editableform.buttons),"bottom"===this.options.showbuttons&&t.addClass("editable-buttons-bottom")},render:function(){this.$loading=o(o.fn.editableform.loading),this.$div.empty().append(this.$loading),this.initTemplate(),this.options.showbuttons?this.initButtons():this.$form.find(".editable-buttons").remove(),this.showLoading(),this.isSaving=!1,this.$div.triggerHandler("rendering"),this.initInput(),this.$form.find("div.editable-input").append(this.input.$tpl),this.$div.append(this.$form),o.when(this.input.render()).then(o.proxy(function(){var t;this.options.showbuttons||this.input.autosubmit(),this.$form.find(".editable-cancel").click(o.proxy(this.cancel,this)),this.input.error?(this.error(this.input.error),this.$form.find(".editable-submit").attr("disabled",!0),this.input.$input.attr("disabled",!0),this.$form.submit(function(t){t.preventDefault()})):(this.error(!1),this.input.$input.removeAttr("disabled"),this.$form.find(".editable-submit").removeAttr("disabled"),t=null==this.value||""===this.value?this.options.defaultValue:this.value,this.input.value2input(t),this.$form.submit(o.proxy(this.submit,this))),this.$div.triggerHandler("rendered"),this.showForm(),this.input.postrender&&this.input.postrender()},this))},cancel:function(){this.$div.triggerHandler("cancel")},showLoading:function(){var t,e;this.$form?(t=this.$form.outerWidth(),e=this.$form.outerHeight(),t&&this.$loading.width(t),e&&this.$loading.height(e),this.$form.hide()):(t=this.$loading.parent().width())&&this.$loading.width(t),this.$loading.show()},showForm:function(t){this.$loading.hide(),this.$form.show(),!1!==t&&this.input.activate(),this.$div.triggerHandler("show")},error:function(t){var e=this.$form.find(".control-group"),i=this.$form.find(".editable-error-block");if(!1===t)e.removeClass(o.fn.editableform.errorGroupClass),i.removeClass(o.fn.editableform.errorBlockClass).empty().hide();else{if(t){for(var n=(""+t).split("\n"),s=0;s").text(n[s]).html();t=n.join("
")}e.addClass(o.fn.editableform.errorGroupClass),i.addClass(o.fn.editableform.errorBlockClass).html(t).show()}},submit:function(t){t.stopPropagation(),t.preventDefault();var i,n=this.input.input2value(),t=this.validate(n);if("object"===o.type(t)&&void 0!==t.newValue){if(n=t.newValue,this.input.value2input(n),"string"==typeof t.msg)return this.error(t.msg),void this.showForm()}else if(t)return this.error(t),void this.showForm();this.options.savenochange||this.input.value2str(n)!=this.input.value2str(this.value)?(i=this.input.value2submit(n),this.isSaving=!0,o.when(this.save(i)).done(o.proxy(function(t){this.isSaving=!1;var e="function"==typeof this.options.success?this.options.success.call(this.options.scope,t,n):null;!1===e?(this.error(!1),this.showForm(!1)):"string"==typeof e?(this.error(e),this.showForm()):(e&&"object"==typeof e&&e.hasOwnProperty("newValue")&&(n=e.newValue),this.error(!1),this.value=n,this.$div.triggerHandler("save",{newValue:n,submitValue:i,response:t}))},this)).fail(o.proxy(function(t){this.isSaving=!1,t="function"==typeof this.options.error?this.options.error.call(this.options.scope,t,n):"string"==typeof t?t:t.responseText||t.statusText||"Unknown error!",this.error(t),this.showForm()},this))):this.$div.triggerHandler("nochange")},save:function(t){this.options.pk=o.fn.editableutils.tryParseJson(this.options.pk,!0);var e="function"==typeof this.options.pk?this.options.pk.call(this.options.scope):this.options.pk;if(!!("function"==typeof this.options.url||this.options.url&&("always"===this.options.send||"auto"===this.options.send&&null!=e)))return this.showLoading(),t={name:this.options.name||"",value:t,pk:e},"function"==typeof this.options.params?t=this.options.params.call(this.options.scope,t):(this.options.params=o.fn.editableutils.tryParseJson(this.options.params,!0),o.extend(t,this.options.params)),"function"==typeof this.options.url?this.options.url.call(this.options.scope,t):o.ajax(o.extend({url:this.options.url,data:t,type:"POST"},this.options.ajaxOptions))},validate:function(t){if(void 0===t&&(t=this.value),"function"==typeof this.options.validate)return this.options.validate.call(this.options.scope,t)},option:function(t,e){t in this.options&&(this.options[t]=e),"value"===t&&this.setValue(e)},setValue:function(t,e){this.value=e?this.input.str2value(t):t,this.$form&&this.$form.is(":visible")&&this.input.value2input(this.value)}},o.fn.editableform=function(i){var n=arguments;return this.each(function(){var t=o(this),e=t.data("editableform");e||t.data("editableform",e=new s(this,"object"==typeof i&&i)),"string"==typeof i&&e[i].apply(e,Array.prototype.slice.call(n,1))})},o.fn.editableform.Constructor=s,o.fn.editableform.defaults={type:"text",url:null,params:null,name:null,pk:null,value:null,defaultValue:null,send:"auto",validate:null,success:null,error:null,ajaxOptions:null,showbuttons:!0,scope:null,savenochange:!1},o.fn.editableform.template='
',o.fn.editableform.loading='
',o.fn.editableform.buttons='',o.fn.editableform.errorGroupClass=null,o.fn.editableform.errorBlockClass="editable-error",o.fn.editableform.engine="jquery"})(window.jQuery),(l=>{l.fn.editableutils={inherit:function(t,e){function i(){}i.prototype=e.prototype,t.prototype=new i,(t.prototype.constructor=t).superclass=e.prototype},setCursorPosition:function(t,e){t.setSelectionRange?t.setSelectionRange(e,e):t.createTextRange&&((t=t.createTextRange()).collapse(!0),t.moveEnd("character",e),t.moveStart("character",e),t.select())},tryParseJson:function(t,e){if("string"==typeof t&&t.length&&t.match(/^[\{\[].*[\}\]]$/))if(e)try{t=new Function("return "+t)()}catch(t){}finally{return t}else t=new Function("return "+t)();return t},sliceObj:function(t,e,i){var n,s,o={};if(Array.isArray(e)&&e.length)for(var a=0;a").text(t).html()},itemsByValue:function(n,t,s){var e,o,a,r;return t&&null!==n?("function"!=typeof s&&(e=s||"value",s=function(t){return t[e]}),o=Array.isArray(n),a=[],r=this,l.each(t,function(t,e){var i;e.children?a=a.concat(r.itemsByValue(n,e.children,s)):o?l.grep(n,function(t){return t==(e&&"object"==typeof e?s(e):e)}).length&&a.push(e):(i=e&&"object"==typeof e?s(e):e,n==i&&a.push(e))}),a):[]},createInput:function(t){var e,i=t.type;return"date"===i&&("inline"===t.mode?l.fn.editabletypes.datefield?i="datefield":l.fn.editabletypes.dateuifield&&(i="dateuifield"):l.fn.editabletypes.date?i="date":l.fn.editabletypes.dateui&&(i="dateui"),"date"!==i||l.fn.editabletypes.date||(i="combodate")),"wysihtml5"!==(i="datetime"===i&&"inline"===t.mode?"datetimefield":i)||l.fn.editabletypes[i]||(i="textarea"),"function"==typeof l.fn.editabletypes[i]?new(e=l.fn.editabletypes[i])(this.sliceObj(t,this.objectKeys(e.defaults))):(l.error("Unknown type: "+i),!1)},supportsTransitions:function(){var t=(document.body||document.documentElement).style,e=["Moz","Webkit","Khtml","O","ms"];if("string"==typeof t[i="transition"])return!0;for(var i=i.charAt(0).toUpperCase()+i.substr(1),n=0;n{function l(t,e){this.init(t,e)}function p(t,e){this.init(t,e)}l.prototype={containerName:null,containerDataName:null,innerCss:null,containerClass:"editable-container editable-popup",defaults:{},init:function(t,e){this.$element=r(t),this.options=r.extend({},r.fn.editableContainer.defaults,e),this.splitOptions(),this.formOptions.scope=this.$element[0],this.initContainer(),this.delayedHide=!1,this.$element.on("destroyed",r.proxy(function(){this.destroy()},this)),r(document).data("editable-handlers-attached")||(r(document).on("keyup.editable",function(t){27===t.which&&r(".editable-open").editableContainer("hide","cancel")}),r(document).on("click.editable",function(t){var e,i=r(t.target),n=[".editable-container",".ui-datepicker-header",".datepicker",".modal-backdrop",".bootstrap-wysihtml5-insert-image-modal",".bootstrap-wysihtml5-insert-link-modal"];if(!r(".select2-drop-mask").is(":visible")&&r.contains(document.documentElement,t.target)&&!i.is(document)){for(e=0;e"),(this.tip().is(this.innerCss)?this.tip():this.tip().find(this.innerCss)).append(this.$form),this.renderForm()},hide:function(t){this.tip()&&this.tip().is(":visible")&&this.$element.hasClass("editable-open")&&(this.$form.data("editableform").isSaving?this.delayedHide={reason:t}:(this.delayedHide=!1,this.$element.removeClass("editable-open"),this.innerHide(),this.$element.triggerHandler("hidden",t||"manual")))},innerShow:function(){},innerHide:function(){},toggle:function(t){this.container()&&this.tip()&&this.tip().is(":visible")?this.hide():this.show(t)},setPosition:function(){},save:function(t,e){this.$element.triggerHandler("save",e),this.hide("save")},option:function(t,e){this.options[t]=e,t in this.containerOptions?(this.containerOptions[t]=e,this.setContainerOption(t,e)):(this.formOptions[t]=e,this.$form&&this.$form.editableform("option",t,e))},setContainerOption:function(t,e){this.call("option",t,e)},destroy:function(){this.hide(),this.innerDestroy(),this.$element.off("destroyed"),this.$element.removeData("editableContainer")},innerDestroy:function(){},closeOthers:function(n){r(".editable-open").each(function(t,e){var i;e===n||r(e).find(n).length||(i=(e=r(e)).data("editableContainer"))&&("cancel"===i.options.onblur?e.data("editableContainer").hide("onblur"):"submit"===i.options.onblur&&e.data("editableContainer").tip().find("form").submit())})},activate:function(){this.tip&&this.tip().is(":visible")&&this.$form&&this.$form.data("editableform").input.activate()}},r.fn.editableContainer=function(o){var a=arguments;return this.each(function(){var t=r(this),e="editableContainer",i=t.data(e),n="object"==typeof o&&o,s="inline"===n.mode?p:l;i||t.data(e,i=new s(this,n)),"string"==typeof o&&i[o].apply(i,Array.prototype.slice.call(a,1))})},r.fn.editableContainer.Popup=l,r.fn.editableContainer.Inline=p,r.fn.editableContainer.defaults={value:null,placement:"top",autohide:!0,onblur:"cancel",anim:!1,mode:"popup"},jQuery.event.special.destroyed={remove:function(t){t.handler&&t.handler()}}})(window.jQuery),(t=>{t.extend(t.fn.editableContainer.Inline.prototype,t.fn.editableContainer.Popup.prototype,{containerName:"editableform",innerCss:".editable-inline",containerClass:"editable-container editable-inline",initContainer:function(){this.$tip=t(""),this.options.anim||(this.options.anim=0)},splitOptions:function(){this.containerOptions={},this.formOptions=this.options},tip:function(){return this.$tip},innerShow:function(){this.$element.hide(),this.tip().insertAfter(this.$element).show()},innerHide:function(){this.$tip.hide(this.options.anim,t.proxy(function(){this.$element.show(),this.innerDestroy()},this))},innerDestroy:function(){this.tip()&&this.tip().empty().remove()}})})(window.jQuery),(u=>{function h(t,e){this.$element=u(t),this.options=u.extend({},u.fn.editable.defaults,e,u.fn.editableutils.getConfigData(this.$element)),this.options.selector?this.initLive():this.init(),this.options.highlight&&!u.fn.editableutils.supportsTransitions()&&(this.options.highlight=!1)}h.prototype={constructor:h,init:function(){var t,e=!1;if(this.options.name=this.options.name||this.$element.attr("id"),this.options.scope=this.$element[0],this.input=u.fn.editableutils.createInput(this.options),this.input){switch(this.type=this.input.type,null==this.options.value?(this.value=this.input.html2value(this.$element.html().trim()),e=!0):(this.options.value=u.fn.editableutils.tryParseJson(this.options.value,!0),"string"==typeof this.options.value?this.value=this.input.str2value(this.options.value):this.value=this.options.value),this.$element.addClass("editable"),"textarea"===this.input.type&&this.$element.addClass("editable-pre-wrapped"),"manual"!==this.options.toggle?(this.$element.addClass("editable-click"),this.$element.on(this.options.toggle+".editable",u.proxy(function(t){this.options.disabled||t.preventDefault(),"mouseenter"===this.options.toggle?this.show():(t="click"!==this.options.toggle,this.toggle(t))},this))):this.$element.attr("tabindex",-1),"function"==typeof this.options.display&&(this.options.autotext="always"),this.options.autotext){case"always":t=!0;break;case"auto":t=!this.$element.text().trim().length&&null!=this.value&&!e;break;default:t=!1}u.when(!t||this.render()).then(u.proxy(function(){this.options.disabled?this.disable():this.enable(),this.$element.triggerHandler("init",this)},this))}},initLive:function(){var t=this.options.selector;this.options.selector=!1,this.options.autotext="never",this.$element.on(this.options.toggle+".editable",t,u.proxy(function(t){var e=u(t.target);e.data("editable")||(e.hasClass(this.options.emptyclass)&&e.empty(),e.editable(this.options).trigger(t))},this))},render:function(t){if(!1!==this.options.display)return this.input.value2htmlFinal?this.input.value2html(this.value,this.$element[0],this.options.display,t):"function"==typeof this.options.display?this.options.display.call(this.$element[0],this.value,t):this.input.value2html(this.value,this.$element[0])},enable:function(){this.options.disabled=!1,this.$element.removeClass("editable-disabled"),this.handleEmpty(this.isEmpty),"manual"!==this.options.toggle&&"-1"===this.$element.attr("tabindex")&&this.$element.removeAttr("tabindex")},disable:function(){this.options.disabled=!0,this.hide(),this.$element.addClass("editable-disabled"),this.handleEmpty(this.isEmpty),this.$element.attr("tabindex",-1)},toggleDisabled:function(){this.options.disabled?this.enable():this.disable()},option:function(t,e){if(t&&"object"==typeof t)u.each(t,u.proxy(function(t,e){this.option(t.triim(),e)},this));else{if(this.options[t]=e,"disabled"===t)return e?this.disable():this.enable();"value"===t&&this.setValue(e),this.container&&this.container.option(t,e),this.input.option&&this.input.option(t,e)}},handleEmpty:function(t){!1!==this.options.display&&(void 0!==t?this.isEmpty=t:"function"==typeof this.input.isEmpty?this.isEmpty=this.input.isEmpty(this.$element):this.isEmpty=""===this.$element.html().trim(),this.options.disabled?this.isEmpty&&(this.$element.empty(),this.options.emptyclass)&&this.$element.removeClass(this.options.emptyclass):this.isEmpty?(this.$element.html(this.options.emptytext),this.options.emptyclass&&this.$element.addClass(this.options.emptyclass)):this.options.emptyclass&&this.$element.removeClass(this.options.emptyclass))},show:function(t){if(!this.options.disabled){if(this.container){if(this.container.tip().is(":visible"))return}else{var e=u.extend({},this.options,{value:this.value,input:this.input});this.$element.editableContainer(e),this.$element.on("save.internal",u.proxy(this.save,this)),this.container=this.$element.data("editableContainer")}this.container.show(t)}},hide:function(){this.container&&this.container.hide()},toggle:function(t){this.container&&this.container.tip().is(":visible")?this.hide():this.show(t)},save:function(t,e){var i,n;this.options.unsavedclass&&("function"==typeof this.options.url||!1===this.options.display||void 0!==e.response||this.options.savenochange&&this.input.value2str(this.value)!==this.input.value2str(e.newValue)?this.$element.removeClass(this.options.unsavedclass):this.$element.addClass(this.options.unsavedclass)),this.options.highlight&&(i=this.$element,n=i.css("background-color"),i.css("background-color",this.options.highlight),setTimeout(function(){"transparent"===n&&(n=""),i.css("background-color",n),i.addClass("editable-bg-transition"),setTimeout(function(){i.removeClass("editable-bg-transition")},1700)},10)),this.setValue(e.newValue,!1,e.response)},validate:function(){if("function"==typeof this.options.validate)return this.options.validate.call(this,this.value)},setValue:function(t,e,i){this.value=e?this.input.str2value(t):t,this.container&&this.container.option("value",this.value),u.when(this.render(i)).then(u.proxy(function(){this.handleEmpty()},this))},activate:function(){this.container&&this.container.activate()},destroy:function(){this.disable(),this.container&&this.container.destroy(),this.input.destroy(),"manual"!==this.options.toggle&&(this.$element.removeClass("editable-click"),this.$element.off(this.options.toggle+".editable")),this.$element.off("save.internal"),this.$element.removeClass("editable editable-open editable-disabled"),this.$element.removeData("editable")}},u.fn.editable=function(n){var i={},s=arguments,o="editable";switch(n){case"validate":return this.each(function(){var t,e=u(this).data(o);e&&(t=e.validate())&&(i[e.options.name]=t)}),i;case"getValue":return 2===arguments.length&&!0===arguments[1]?i=this.eq(0).data(o).value:this.each(function(){var t=u(this).data(o);t&&null!=t.value&&(i[t.options.name]=t.input.value2submit(t.value))}),i;case"submit":var t,e,a,r=arguments[1]||{},l=this,p=this.editable("validate");return u.isEmptyObject(p)?(a={},1===l.length?(e={name:(t=l.data("editable")).options.name||"",value:t.input.value2submit(t.value),pk:"function"==typeof t.options.pk?t.options.pk.call(t.options.scope):t.options.pk},"function"==typeof t.options.params?e=t.options.params.call(t.options.scope,e):(t.options.params=u.fn.editableutils.tryParseJson(t.options.params,!0),u.extend(e,t.options.params)),a={url:t.options.url,data:e,type:"POST"},r.success=r.success||t.options.success,r.error=r.error||t.options.error):(e=this.editable("getValue"),a={url:r.url,data:e,type:"POST"}),a.success="function"==typeof r.success?function(t){r.success.call(l,t,r)}:u.noop,a.error="function"==typeof r.error?function(){r.error.apply(l,arguments)}:u.noop,r.ajaxOptions&&u.extend(a,r.ajaxOptions),r.data&&u.extend(a.data,r.data),u.ajax(a)):"function"==typeof r.error&&r.error.call(l,p),this}return this.each(function(){var t=u(this),e=t.data(o),i="object"==typeof n&&n;i&&i.selector?e=new h(this,i):(e||t.data(o,e=new h(this,i)),"string"==typeof n&&e[n].apply(e,Array.prototype.slice.call(s,1)))})},u.fn.editable.defaults={type:"text",disabled:!1,toggle:"click",emptytext:"Empty",autotext:"auto",value:null,display:null,emptyclass:"editable-empty",unsavedclass:"editable-unsaved",selector:null,highlight:"#FFFF80"}})(window.jQuery),(n=>{function t(){}n.fn.editabletypes={},t.prototype={init:function(t,e,i){this.type=t,this.options=n.extend({},i,e)},prerender:function(){this.$tpl=n(this.options.tpl),this.$input=this.$tpl,this.$clear=null,this.error=null},render:function(){},value2html:function(t,e){n(e)[this.options.escape?"text":"html"](t.trim())},html2value:function(t){return n("
").html(t).text()},value2str:function(t){return t},str2value:function(t){return t},value2submit:function(t){return t},value2input:function(t){this.$input.val(t)},input2value:function(){return this.$input.val()},activate:function(){this.$input.is(":visible")&&this.$input.focus()},clear:function(){this.$input.val(null)},escape:function(t){return n("
").text(t).html()},autosubmit:function(){},destroy:function(){},setClass:function(){this.options.inputclass&&this.$input.addClass(this.options.inputclass)},setAttr:function(t){null!=this.options[t]&&this.$input.attr(t,this.options[t])},option:function(t,e){this.options[t]=e}},t.defaults={tpl:"",inputclass:null,escape:!0,scope:null,showbuttons:!0},n.extend(n.fn.editabletypes,{abstractinput:t})})(window.jQuery),(r=>{function t(t){}r.fn.editableutils.inherit(t,r.fn.editabletypes.abstractinput),r.extend(t.prototype,{render:function(){var t=r.Deferred();return this.error=null,this.onSourceReady(function(){this.renderList(),t.resolve()},function(){this.error=this.options.sourceError,t.resolve()}),t.promise()},html2value:function(t){return null},value2html:function(t,e,i,n){function s(){"function"==typeof i?i.call(e,t,this.sourceData,n):this.value2htmlFinal(t,e),o.resolve()}var o=r.Deferred();return null===t?s.call(this):this.onSourceReady(s,function(){o.resolve()}),o.promise()},onSourceReady:function(e,i){var t;if("function"==typeof this.options.source?(t=this.options.source.call(this.options.scope),this.sourceData=null):t=this.options.source,this.options.sourceCache&&Array.isArray(this.sourceData))e.call(this);else{try{t=r.fn.editableutils.tryParseJson(t,!1)}catch(t){return void i.call(this)}if("string"==typeof t){if(this.options.sourceCache){var n,s=t;if(r(document).data(s)||r(document).data(s,{}),!1===(n=r(document).data(s)).loading&&n.sourceData)return this.sourceData=n.sourceData,this.doPrepend(),void e.call(this);if(!0===n.loading)return n.callbacks.push(r.proxy(function(){this.sourceData=n.sourceData,this.doPrepend(),e.call(this)},this)),void n.err_callbacks.push(r.proxy(i,this));n.loading=!0,n.callbacks=[],n.err_callbacks=[]}s=r.extend({url:t,type:"get",cache:!1,dataType:"json",success:r.proxy(function(t){n&&(n.loading=!1),this.sourceData=this.makeArray(t),Array.isArray(this.sourceData)?(n&&(n.sourceData=this.sourceData,r.each(n.callbacks,function(){this.call()})),this.doPrepend(),e.call(this)):(i.call(this),n&&r.each(n.err_callbacks,function(){this.call()}))},this),error:r.proxy(function(){i.call(this),n&&(n.loading=!1,r.each(n.err_callbacks,function(){this.call()}))},this)},this.options.sourceOptions);r.ajax(s)}else this.sourceData=this.makeArray(t),(Array.isArray(this.sourceData)?(this.doPrepend(),e):i).call(this)}},doPrepend:function(){null!=this.options.prepend&&(Array.isArray(this.prependData)||("function"==typeof this.options.prepend&&(this.options.prepend=this.options.prepend.call(this.options.scope)),this.options.prepend=r.fn.editableutils.tryParseJson(this.options.prepend,!0),"string"==typeof this.options.prepend&&(this.options.prepend={"":this.options.prepend}),this.prependData=this.makeArray(this.options.prepend)),Array.isArray(this.prependData))&&Array.isArray(this.sourceData)&&(this.sourceData=this.prependData.concat(this.sourceData))},renderList:function(){},value2htmlFinal:function(t,e){},makeArray:function(t){var i,n,e,s=[];if(!t||"string"==typeof t)return null;if(Array.isArray(t))for(var o=function(t,e){if(n={value:t,text:e},2<=i++)return!1},a=0;a{function e(t){this.init("text",t,e.defaults)}i.fn.editableutils.inherit(e,i.fn.editabletypes.abstractinput),i.extend(e.prototype,{render:function(){this.renderClear(),this.setClass(),this.setAttr("placeholder")},activate:function(){this.$input.is(":visible")&&(this.$input.focus(),i.fn.editableutils.setCursorPosition(this.$input.get(0),this.$input.val().length),this.toggleClear)&&this.toggleClear()},renderClear:function(){this.options.clear&&(this.$clear=i(''),this.$input.after(this.$clear).css("padding-right",24).keyup(i.proxy(function(t){var e;~i.inArray(t.keyCode,[40,38,9,13,27])||(clearTimeout(this.t),(e=this).t=setTimeout(function(){e.toggleClear(t)},100))},this)).parent().css("position","relative"),this.$clear.click(i.proxy(this.clear,this)))},postrender:function(){},toggleClear:function(t){var e,i;this.$clear&&(e=this.$input.val().length,i=this.$clear.is(":visible"),e&&!i&&this.$clear.show(),!e)&&i&&this.$clear.hide()},clear:function(){this.$clear.hide(),this.$input.val("").focus()}}),e.defaults=i.extend({},i.fn.editabletypes.abstractinput.defaults,{tpl:'',placeholder:null,clear:!0}),i.fn.editabletypes.text=e})(window.jQuery),(e=>{function i(t){this.init("textarea",t,i.defaults)}e.fn.editableutils.inherit(i,e.fn.editabletypes.abstractinput),e.extend(i.prototype,{render:function(){this.setClass(),this.setAttr("placeholder"),this.setAttr("rows"),this.$input.keydown(function(t){t.ctrlKey&&13===t.which&&e(this).closest("form").submit()})},activate:function(){e.fn.editabletypes.text.prototype.activate.call(this)}}),i.defaults=e.extend({},e.fn.editabletypes.abstractinput.defaults,{tpl:"",inputclass:"input-large",placeholder:null,rows:7}),e.fn.editabletypes.textarea=i})(window.jQuery),(o=>{function e(t){this.init("select",t,e.defaults)}o.fn.editableutils.inherit(e,o.fn.editabletypes.list),o.extend(e.prototype,{renderList:function(){this.$input.empty();var s=function(t,e){var i;if(Array.isArray(e))for(var n=0;n",i),e[n].children))):(i.value=e[n].value,e[n].disabled&&(i.disabled=!0),t.append(o("