diff --git a/dist/README.md b/dist/README.md index b26fdcf5..d2be4b91 100644 --- a/dist/README.md +++ b/dist/README.md @@ -1,19 +1,25 @@ # X-editable - In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery. -## Project status -Unfortunately, **project is currently frozen**, as I don't have enough time for it. -You could try use it as is, but there may be some bugs with newer versions of dependend libraries (e.g. bootstrap). -I would really appreciate if someone take care of it.. See [#610](https://github.com/vitalets/x-editable/issues/610). -Vitalets. - -## Live demo +## Live Demo **http://vitalets.github.io/x-editable/demo.html** +## Pull Requests +Please submit all Pull Requests to the `develop` branch: https://github.com/vitalets/x-editable/tree/develop +More details are in [CONTRIBUTING.md](/CONTRIBUTING.md). + +## Issue Tracker +Please report all issues here: https://github.com/vitalets/x-editable/issues + +## User Support +Unfortunately, due to this project being supported by volunteers we cannot provide user support at this time. Please try a site like Stack Overflow: http://stackoverflow.com/questions/tagged/x-editable + ## Documentation **http://vitalets.github.io/x-editable** +## Project Status +Actively Maintained + ## How to get it ### Manual download @@ -26,25 +32,25 @@ bower install x-editable ### CDN Bootstrap 3 build: -````js +````html ```` Bootstrap 2 build: -````js +````html ```` jQuery UI build: -````js +````html ```` jQuery only build: -````js +````html ```` @@ -53,78 +59,12 @@ jQuery only build: ## Reporting issues Please **provide jsFiddle** when creating issues! It's really saves much time. Use these as template: -1. [jsFiddle Bootstrap 3](http://jsfiddle.net/xBB5x/2265/) +1. [jsFiddle Bootstrap 3](http://jsfiddle.net/xBB5x/15155/) 2. [jsFiddle Bootstrap 2](http://jsfiddle.net/xBB5x/1817/) 3. [jsFiddle jQuery-ui](http://jsfiddle.net/xBB5x/2511/) 4. [jsFiddle jQuery](http://jsfiddle.net/xBB5x/197) Your feedback is very appreciated! -## Contribution -A few steps how to start contributing. -Assuming you have [Node.js](http://nodejs.org/) already installed. - -1.Fork *X-editable* on github and clone it to your local mashine: -```` -git clone https://github.com//x-editable.git -b dev -```` -2.Install *grunt-cli* globally (if not yet): -```` -npm i -g grunt-cli -```` -3.Install dependencies: -```` -cd x-editable -npm i -```` -4.Make your changes: -```` -vim editable-form.js -```` -5.Write some tests for your changes: -```` -vim /test/unit/*.js -```` -6.Run tests in cli: -```` -grunt test -```` -or directly in browser: -```` -grunt server -```` -and open http://127.0.0.1:8000/test -By default test run on bootstrap 3 popup version, but you can test any other build: - -* bootstrap 3 - * popup: http://127.0.0.1:8000/test/?f=bootstrap3&c=popup - * inline: http://127.0.0.1:8000/test/?f=bootstrap3&c=inline -* bootstrap 2 - * popup: http://127.0.0.1:8000/test/?f=bootstrap2&c=popup - * inline: http://127.0.0.1:8000/test/?f=bootstrap2&c=inline -* jquery-ui - * popup: http://127.0.0.1:8000/test/?f=jqueryui&c=popup - * inline: http://127.0.0.1:8000/test/?f=jqueryui&c=inline -* jquery + poshytip - * popup: http://127.0.0.1:8000/test/?f=plain&c=popup - * inline: http://127.0.0.1:8000/test/?f=plain&c=inline - -7.Commit and push back on github: -```` -git add . -git commit -m'refactor editable form, fix #123' -git push origin -```` -8.Make pull request on github (to `dev` branch). - -Thanks for your support! - -### Local build -To build x-editable locally please run: -```` -grunt build -```` -Result will appear in `dist` directory. - ## License Copyright (c) 2012 Vitaliy Potapov Licensed under the MIT license. diff --git a/dist/bootstrap-editable/css/bootstrap-editable.css b/dist/bootstrap-editable/css/bootstrap-editable.css index ff7ea50f..467605a7 100644 --- a/dist/bootstrap-editable/css/bootstrap-editable.css +++ b/dist/bootstrap-editable/css/bootstrap-editable.css @@ -1,7 +1,7 @@ /*! X-editable - v1.5.3 * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * http://github.com/vitalets/x-editable -* Copyright (c) 2015 Vitaliy Potapov; Licensed MIT */ +* Copyright (c) 2018 Vitaliy Potapov; Licensed MIT */ .editableform { margin-bottom: 0; /* overwrites bootstrap margin */ } @@ -12,6 +12,16 @@ line-height: 20px; /* overwriting bootstrap line-height. See #133 */ } +/* + BS3 fix: stop css from breaking when the form is inside a popup and inside a form with the class .form-horizontal + See: https://github.com/vitalets/x-editable/issues/682 +*/ +.form-horizontal .editable-popup .editableform .form-group { + margin-left:0; + margin-right:0; +} + + /* BS3 width:1005 for inputs breaks editable form in popup See: https://github.com/vitalets/x-editable/issues/393 @@ -145,6 +155,7 @@ .editable-pre-wrapped { white-space: pre-wrap; } + .editable-container.editable-popup { max-width: none !important; /* without this rule poshytip/tooltip does not stretch */ } diff --git a/dist/bootstrap-editable/js/bootstrap-editable.js b/dist/bootstrap-editable/js/bootstrap-editable.js index 5aab86a5..d0bdae61 100644 --- a/dist/bootstrap-editable/js/bootstrap-editable.js +++ b/dist/bootstrap-editable/js/bootstrap-editable.js @@ -1,7 +1,7 @@ /*! X-editable - v1.5.3 * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * http://github.com/vitalets/x-editable -* Copyright (c) 2015 Vitaliy Potapov; Licensed MIT */ +* Copyright (c) 2018 Vitaliy Potapov; Licensed MIT */ /** Form with single input element, two buttons and two states: normal/loading. Applied as jQuery method to DIV tag (not to form tag!). This is because form can be in loading state when spinner shown. @@ -664,7 +664,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. */ setCursorPosition: function(elem, pos) { if (elem.setSelectionRange) { - elem.setSelectionRange(pos, pos); + try { elem.setSelectionRange(pos, pos); } catch (e) {} } else if (elem.createTextRange) { var range = elem.createTextRange(); range.collapse(true); @@ -736,7 +736,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. */ getConfigData: function($element) { var data = {}; - $.each($element.data(), function(k, v) { + $.each($element[0].dataset, function(k, v) { if(typeof v !== 'object' || (v && typeof v === 'object' && (v.constructor === Object || v.constructor === Array))) { data[k] = v; } @@ -941,7 +941,7 @@ Applied as jQuery method. //close all on escape $(document).on('keyup.editable', function (e) { if (e.which === 27) { - $('.editable-open').editableContainer('hide'); + $('.editable-open').editableContainer('hide', 'cancel'); //todo: return focus on element } }); @@ -1613,7 +1613,7 @@ Makes editable any HTML element on the page. Applied as jQuery method. this.options.autotext = 'never'; //listen toggle events this.$element.on(this.options.toggle + '.editable', selector, $.proxy(function(e){ - var $target = $(e.target); + var $target = $(e.target).closest(selector); if(!$target.data('editable')) { //if delegated element initially empty, we need to clear it's text (that was manually set to `empty` by user) //see https://github.com/vitalets/x-editable/issues/137 @@ -2400,7 +2400,7 @@ To create your own input you can inherit from this class. @returns {string} **/ value2str: function(value) { - return value; + return String(value); }, /** @@ -2913,7 +2913,7 @@ $(function(){ **/ (function ($) { "use strict"; - + var Text = function (options) { this.init('text', options, Text.defaults); }; @@ -2925,21 +2925,22 @@ $(function(){ this.renderClear(); this.setClass(); this.setAttr('placeholder'); - this.setAttr('maxlength'); }, - + activate: function() { if(this.$input.is(':visible')) { this.$input.focus(); +// if (this.$input.is('input,textarea') && !this.$input.is('[type="checkbox"],[type="range"],[type="number"],[type="email"]')) { if (this.$input.is('input,textarea') && !this.$input.is('[type="checkbox"],[type="range"]')) { $.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length); } + if(this.toggleClear) { this.toggleClear(); } } }, - + //render clear button renderClear: function() { if (this.options.clear) { @@ -2950,21 +2951,21 @@ $(function(){ //arrows, enter, tab, etc if(~$.inArray(e.keyCode, [40,38,9,13,27])) { return; - } + } clearTimeout(this.t); var that = this; this.t = setTimeout(function() { that.toggleClear(e); }, 100); - + }, this)) .parent().css('position', 'relative'); - - this.$clear.click($.proxy(this.clear, this)); - } + + this.$clear.click($.proxy(this.clear, this)); + } }, - + postrender: function() { /* //now `clear` is positioned via css @@ -2973,66 +2974,57 @@ $(function(){ // var h = this.$input.outerHeight(true) || 20, var h = this.$clear.parent().height(), delta = (h - this.$clear.height()) / 2; - + //this.$clear.css({bottom: delta, right: delta}); } - */ + */ }, - + //show / hide clear button toggleClear: function(e) { if(!this.$clear) { return; } - + var len = this.$input.val().length, visible = this.$clear.is(':visible'); - + if(len && !visible) { this.$clear.show(); - } - + } + if(!len && visible) { this.$clear.hide(); - } + } }, - + clear: function() { this.$clear.hide(); this.$input.val('').focus(); - } + } }); Text.defaults = $.extend({}, $.fn.editabletypes.abstractinput.defaults, { /** - @property tpl + @property tpl @default - **/ + **/ tpl: '', /** Placeholder attribute of input. Shown when input is empty. - @property placeholder - @type string - @default null - **/ - placeholder: null, - - /** - maxlength attribute of input. - - @property placeholder + @property placeholder @type string @default null **/ - maxlength: null, - + placeholder: null, + /** - Whether to show `clear` button - - @property clear + Whether to show `clear` button + + @property clear @type boolean - @default true + @default true **/ clear: true }); @@ -3072,8 +3064,7 @@ $(function(){ render: function () { this.setClass(); this.setAttr('placeholder'); - this.setAttr('rows'); - this.setAttr('maxlength'); + this.setAttr('rows'); //ctrl + enter this.$input.keydown(function (e) { @@ -3140,16 +3131,6 @@ $(function(){ @default null **/ placeholder: null, - - /** - maxlength attribute of input. - - @property placeholder - @type string - @default null - **/ - - maxlength: null, /** Number of rows in textarea @@ -3732,7 +3713,7 @@ $(function(){ options.select2 = options.select2 || {}; this.sourceData = null; - + //placeholder if(options.placeholder) { options.select2.placeholder = options.placeholder; @@ -3937,9 +3918,15 @@ $(function(){ return source; }, + activate: function() { + this.$input.select2('open'); + }, + destroy: function() { - if(this.$input.data('select2')) { - this.$input.select2('destroy'); + if(this.$input) { + if(this.$input.data('select2')) { + this.$input.select2('destroy'); + } } } @@ -3992,22 +3979,22 @@ $(function(){ }(window.jQuery)); /** -* Combodate - 1.0.5 +* Combodate - 1.1.0 * Dropdown date and time picker. * Converts text input into dropdowns to pick day, month, year, hour, minute and second. * Uses momentjs as datetime library http://momentjs.com. -* For i18n include corresponding file from https://github.com/timrwood/moment/tree/master/lang +* For i18n include corresponding file from https://github.com/timrwood/moment/tree/master/lang * * Confusion at noon and midnight - see http://en.wikipedia.org/wiki/12-hour_clock#Confusion_at_noon_and_midnight -* In combodate: +* In combodate: * 12:00 pm --> 12:00 (24-h format, midday) * 12:00 am --> 00:00 (24-h format, midnight, start of day) -* +* * Differs from momentjs parse rules: * 00:00 pm, 12:00 pm --> 12:00 (24-h format, day not change) * 00:00 am, 12:00 am --> 00:00 (24-h format, day not change) -* -* +* +* * Author: Vitaliy Potapov * Project page: http://github.com/vitalets/combodate * Copyright (c) 2012 Vitaliy Potapov. Released under MIT License. @@ -4021,28 +4008,31 @@ $(function(){ return; } this.options = $.extend({}, $.fn.combodate.defaults, options, this.$element.data()); - this.init(); + this.init(); }; Combodate.prototype = { - constructor: Combodate, + constructor: Combodate, init: function () { this.map = { //key regexp moment.method - day: ['D', 'date'], - month: ['M', 'month'], - year: ['Y', 'year'], + day: ['D', 'date'], + month: ['M', 'month'], + year: ['Y', 'year'], hour: ['[Hh]', 'hours'], - minute: ['m', 'minutes'], + minute: ['m', 'minutes'], second: ['s', 'seconds'], - ampm: ['[Aa]', ''] + ampm: ['[Aa]', ''] }; - + this.$widget = $('').html(this.getTemplate()); - + this.initCombos(); - - //update original input on change + + // internal momentjs instance + this.datetime = null; + + //update original input on change this.$widget.on('change', 'select', $.proxy(function(e) { this.$element.val(this.getValue()).change(); // update days count if month or year changes @@ -4052,28 +4042,30 @@ $(function(){ } } }, this)); - + this.$widget.find('select').css('width', 'auto'); - - // hide original input and insert widget + + // hide original input and insert widget this.$element.hide().after(this.$widget); - + // set initial value this.setValue(this.$element.val() || this.options.value); }, - + /* - Replace tokens in template with elements + */ getTemplate: function() { var tpl = this.options.template; + var inputDisabled = this.$element.prop('disabled'); + var customClass = this.options.customClass; //first pass $.each(this.map, function(k, v) { - v = v[0]; + v = v[0]; var r = new RegExp(v+'+'), token = v.length > 1 ? v.substring(1, 2) : v; - + tpl = tpl.replace(r, '{'+token+'}'); }); @@ -4084,16 +4076,17 @@ $(function(){ $.each(this.map, function(k, v) { v = v[0]; var token = v.length > 1 ? v.substring(1, 2) : v; - - tpl = tpl.replace('{'+token+'}', ''); - }); + + tpl = tpl.replace('{'+token+'}', ''); + }); return tpl; }, - + /* - Initialize combos that presents in template - */ + Initialize combos that presents in template + */ initCombos: function() { for (var k in this.map) { var $c = this.$widget.find('.'+k); @@ -4105,8 +4098,8 @@ $(function(){ }, /* - Fill combo with items - */ + Fill combo with items + */ fillCombo: function(k) { var $combo = this['$'+k]; if (!$combo) { @@ -4114,7 +4107,7 @@ $(function(){ } // define method name to fill items, e.g `fillDays` - var f = 'fill' + k.charAt(0).toUpperCase() + k.slice(1); + var f = 'fill' + k.charAt(0).toUpperCase() + k.slice(1); var items = this[f](); var value = $combo.val(); @@ -4127,24 +4120,28 @@ $(function(){ }, /* - Initialize items of combos. Handles `firstItem` option + Initialize items of combos. Handles `firstItem` option */ fillCommon: function(key) { var values = [], relTime; - + if(this.options.firstItem === 'name') { //need both to support moment ver < 2 and >= 2 - relTime = moment.relativeTime || moment.langData()._relativeTime; + if (moment.localeData) { + relTime = moment.localeData()._relativeTime; + } else { + relTime = moment.relativeTime || moment.langData()._relativeTime; + } var header = typeof relTime[key] === 'function' ? relTime[key](1, true, key, false) : relTime[key]; - //take last entry (see momentjs lang files structure) - header = header.split(' ').reverse()[0]; + //take last entry (see momentjs lang files structure) + header = header.split(' ').reverse()[0]; values.push(['', header]); } else if(this.options.firstItem === 'empty') { values.push(['', '']); } return values; - }, + }, /* @@ -4170,20 +4167,26 @@ $(function(){ name = twoDigit ? this.leadZero(i) : i; items.push([i, name]); } - return items; + return items; }, - + /* fill month */ fillMonth: function() { - var items = this.fillCommon('M'), name, i, + var items = this.fillCommon('M'), name, i, + longNamesNum = this.options.template.indexOf('MMMMMM') !== -1, + shortNamesNum = this.options.template.indexOf('MMMMM') !== -1, longNames = this.options.template.indexOf('MMMM') !== -1, shortNames = this.options.template.indexOf('MMM') !== -1, twoDigit = this.options.template.indexOf('MM') !== -1; - + for(i=0; i<=11; i++) { - if(longNames) { + if (longNamesNum) { + name = moment().date(1).month(i).format('MM - MMMM'); + } else if (shortNamesNum) { + name = moment().date(1).month(i).format('MM - MMM'); + } else if(longNames) { //see https://github.com/timrwood/momentjs.com/pull/36 name = moment().date(1).month(i).format('MMMM'); } else if(shortNames) { @@ -4194,27 +4197,27 @@ $(function(){ name = i+1; } items.push([i, name]); - } + } return items; - }, - + }, + /* fill year */ fillYear: function() { - var items = [], name, i, + var items = [], name, i, longNames = this.options.template.indexOf('YYYY') !== -1; - + for(i=this.options.maxYear; i>=this.options.minYear; i--) { name = longNames ? i : (i+'').substring(2); items[this.options.yearDescending ? 'push' : 'unshift']([i, name]); } - + items = this.fillCommon('y').concat(items); - - return items; - }, - + + return items; + }, + /* fill hour */ @@ -4223,16 +4226,16 @@ $(function(){ h12 = this.options.template.indexOf('h') !== -1, h24 = this.options.template.indexOf('H') !== -1, twoDigit = this.options.template.toLowerCase().indexOf('hh') !== -1, - min = h12 ? 1 : 0, + min = h12 ? 1 : 0, max = h12 ? 12 : 23; - + for(i=min; i<=max; i++) { name = twoDigit ? this.leadZero(i) : i; items.push([i, name]); - } - return items; - }, - + } + return items; + }, + /* fill minute */ @@ -4243,10 +4246,10 @@ $(function(){ for(i=0; i<=59; i+= this.options.minuteStep) { name = twoDigit ? this.leadZero(i) : i; items.push([i, name]); - } - return items; - }, - + } + return items; + }, + /* fill second */ @@ -4257,85 +4260,103 @@ $(function(){ for(i=0; i<=59; i+= this.options.secondStep) { name = twoDigit ? this.leadZero(i) : i; items.push([i, name]); - } - return items; - }, - + } + return items; + }, + /* fill ampm */ fillAmpm: function() { var ampmL = this.options.template.indexOf('a') !== -1, - ampmU = this.options.template.indexOf('A') !== -1, + ampmU = this.options.template.indexOf('A') !== -1, items = [ ['am', ampmL ? 'am' : 'AM'], ['pm', ampmL ? 'pm' : 'PM'] ]; - return items; - }, + return items; + }, /* - Returns current date value from combos. + Returns current date value from combos. If format not specified - `options.format` used. If format = `null` - Moment object returned. */ getValue: function(format) { - var dt, values = {}, + var dt, values = {}, that = this, notSelected = false; - - //getting selected values + + //getting selected values $.each(this.map, function(k, v) { if(k === 'ampm') { return; } - var def = k === 'day' ? 1 : 0; - - values[k] = that['$'+k] ? parseInt(that['$'+k].val(), 10) : def; - + + // if combo exists, use it's value, otherwise use default + if (that['$'+k]) { + values[k] = parseInt(that['$'+k].val(), 10); + } else { + var defaultValue; + if (that.datetime) { + defaultValue = that.datetime[v[1]](); + } else { + defaultValue = k === 'day' ? 1 : 0; + } + values[k] = defaultValue; + } + if(isNaN(values[k])) { notSelected = true; - return false; + return false; } }); - + //if at least one visible combo not selected - return empty string if(notSelected) { return ''; } - - //convert hours 12h --> 24h + + //convert hours 12h --> 24h if(this.$ampm) { //12:00 pm --> 12:00 (24-h format, midday), 12:00 am --> 00:00 (24-h format, midnight, start of day) if(values.hour === 12) { - values.hour = this.$ampm.val() === 'am' ? 0 : 12; + values.hour = this.$ampm.val() === 'am' ? 0 : 12; } else { values.hour = this.$ampm.val() === 'am' ? values.hour : values.hour+12; } - } - - dt = moment([values.year, values.month, values.day, values.hour, values.minute, values.second]); - + } + + dt = moment([ + values.year, + values.month, + values.day, + values.hour, + values.minute, + values.second + ]); + //highlight invalid date this.highlight(dt); - + format = format === undefined ? this.options.format : format; if(format === null) { - return dt.isValid() ? dt : null; + return dt.isValid() ? dt : null; } else { - return dt.isValid() ? dt.format(format) : ''; - } + return dt.isValid() ? dt.format(format) : ''; + } }, - + setValue: function(value) { if(!value) { return; } - - var dt = typeof value === 'string' ? moment(value, this.options.format) : moment(value), + + // parse in strict mode (third param `true`) + var dt = typeof value === 'string' ? moment(value, this.options.format, true) : moment(value), that = this, values = {}; - + //function to find nearest value in select options function getNearest($select, value) { var delta = {}; @@ -4344,23 +4365,23 @@ $(function(){ distance; if(optValue === '') return; - distance = Math.abs(optValue - value); + distance = Math.abs(optValue - value); if(typeof delta.distance === 'undefined' || distance < delta.distance) { delta = {value: optValue, distance: distance}; - } - }); + } + }); return delta.value; - } - + } + if(dt.isValid()) { //read values from date object $.each(this.map, function(k, v) { if(k === 'ampm') { - return; + return; } values[k] = dt[v[1]](); }); - + if(this.$ampm) { //12:00 pm --> 12:00 (24-h format, midday), 12:00 am --> 00:00 (24-h format, midnight, start of day) if(values.hour >= 12) { @@ -4373,21 +4394,21 @@ $(function(){ if(values.hour === 0) { values.hour = 12; } - } + } } - + $.each(values, function(k, v) { //call val() for each existing combo, e.g. this.$hour.val() if(that['$'+k]) { - + if(k === 'minute' && that.options.minuteStep > 1 && that.options.roundTime) { v = getNearest(that['$'+k], v); } - + if(k === 'second' && that.options.secondStep > 1 && that.options.roundTime) { v = getNearest(that['$'+k], v); - } - + } + that['$'+k].val(v); } }); @@ -4396,11 +4417,14 @@ $(function(){ if (this.options.smartDays) { this.fillCombo('day'); } - - this.$element.val(dt.format(this.options.format)).change(); + + this.$element.val(dt.format(this.options.format)).change(); + this.datetime = dt; + } else { + this.datetime = null; } }, - + /* highlight combos if date is invalid */ @@ -4411,29 +4435,29 @@ $(function(){ } else { //store original border color if(!this.borderColor) { - this.borderColor = this.$widget.find('select').css('border-color'); + this.borderColor = this.$widget.find('select').css('border-color'); } this.$widget.find('select').css('border-color', 'red'); - } + } } else { if(this.options.errorClass) { this.$widget.removeClass(this.options.errorClass); } else { this.$widget.find('select').css('border-color', this.borderColor); - } + } } }, - + leadZero: function(v) { - return v <= 9 ? '0' + v : v; + return v <= 9 ? '0' + v : v; }, - + destroy: function() { this.$widget.remove(); this.$element.removeData('combodate').show(); } - - //todo: clear method + + //todo: clear method }; $.fn.combodate = function ( option ) { @@ -4443,8 +4467,8 @@ $(function(){ //getValue returns date as string / object (not jQuery object) if(option === 'getValue' && this.length && (d = this.eq(0).data('combodate'))) { return d.getValue.apply(d, args); - } - + } + return this.each(function () { var $this = $(this), data = $this.data('combodate'), @@ -4456,15 +4480,15 @@ $(function(){ data[option].apply(data, args); } }); - }; - + }; + $.fn.combodate.defaults = { //in this format value stored in original input - format: 'DD-MM-YYYY HH:mm', + format: 'DD-MM-YYYY HH:mm', //in this format items in dropdowns are displayed template: 'D / MMM / YYYY H : mm', - //initial value, can be `new Date()` - value: null, + //initial value, can be `new Date()` + value: null, minYear: 1970, maxYear: new Date().getFullYear(), yearDescending: true, @@ -4472,11 +4496,13 @@ $(function(){ secondStep: 1, firstItem: 'empty', //'name', 'empty', 'none' errorClass: null, + customClass: '', roundTime: true, // whether to round minutes and seconds if step > 1 smartDays: false // whether days in combo depend on selected month: 31, 30, 28 }; }(window.jQuery)); + /** Combodate input - dropdown date and time picker. Based on [combodate](http://vitalets.github.com/combodate) plugin (included). To use it you should manually include [momentjs](http://momentjs.com). @@ -4506,7 +4532,7 @@ $(function(){ template: 'D / MMMM / YYYY', combodate: { minYear: 2000, - maxYear: 2015, + maxYear: new Date().getFullYear(), minuteStep: 1 } } @@ -6385,7 +6411,7 @@ $(function(){ /** Bootstrap datefield input - modification for inline mode. -Shows normal and binds popup datepicker. +Shows normal and binds popup datepicker. Automatically shown in inline mode. @class datefield @@ -6395,63 +6421,63 @@ Automatically shown in inline mode. **/ (function ($) { "use strict"; - + var DateField = function (options) { this.init('datefield', options, DateField.defaults); this.initPicker(options, DateField.defaults); }; - $.fn.editableutils.inherit(DateField, $.fn.editabletypes.date); - + $.fn.editableutils.inherit(DateField, $.fn.editabletypes.date); + $.extend(DateField.prototype, { render: function () { this.$input = this.$tpl.find('input'); this.setClass(); this.setAttr('placeholder'); - - //bootstrap-datepicker is set `bdateicker` to exclude conflict with jQuery UI one. (in date.js) - this.$tpl.bdatepicker(this.options.datepicker); - + + //bootstrap-datepicker is set `bdateicker` to exclude conflict with jQuery UI one. (in date.js) + this.$input.bdatepicker(this.options.datepicker); + //need to disable original event handlers this.$input.off('focus keydown'); - + //update value of datepicker this.$input.keyup($.proxy(function(){ this.$tpl.removeData('date'); this.$tpl.bdatepicker('update'); }, this)); - - }, - + + }, + value2input: function(value) { this.$input.val(value ? this.dpg.formatDate(value, this.parsedViewFormat, this.options.datepicker.language) : ''); this.$tpl.bdatepicker('update'); }, - - input2value: function() { + + input2value: function() { return this.html2value(this.$input.val()); - }, - + }, + activate: function() { $.fn.editabletypes.text.prototype.activate.call(this); }, - + autosubmit: function() { - //reset autosubmit to empty + //reset autosubmit to empty } }); - + DateField.defaults = $.extend({}, $.fn.editabletypes.date.defaults, { /** - @property tpl - **/ + @property tpl + **/ tpl:'
', /** - @property inputclass + @property inputclass @default 'input-small' - **/ + **/ inputclass: 'input-small', - + /* datepicker config */ datepicker: { weekStart: 0, @@ -6460,10 +6486,11 @@ Automatically shown in inline mode. autoclose: true } }); - + $.fn.editabletypes.datefield = DateField; }(window.jQuery)); + /** Bootstrap-datetimepicker. Based on [smalot bootstrap-datetimepicker plugin](https://github.com/smalot/bootstrap-datetimepicker). @@ -7052,4 +7079,4 @@ $(function(){ $.fn.editabletypes.typeahead = Constructor; -}(window.jQuery)); +}(window.jQuery)); \ No newline at end of file diff --git a/dist/bootstrap-editable/js/bootstrap-editable.min.js b/dist/bootstrap-editable/js/bootstrap-editable.min.js index 300c3ac9..b5ca8d7f 100644 --- a/dist/bootstrap-editable/js/bootstrap-editable.min.js +++ b/dist/bootstrap-editable/js/bootstrap-editable.min.js @@ -1,7 +1,7 @@ /*! X-editable - v1.5.3 * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * http://github.com/vitalets/x-editable -* Copyright (c) 2015 Vitaliy Potapov; Licensed MIT */ -!function(a){"use strict";var b=function(b,c){this.options=a.extend({},a.fn.editableform.defaults,c),this.$div=a(b),this.options.scope||(this.options.scope=this)};b.prototype={constructor:b,initInput:function(){this.input=this.options.input,this.value=this.input.str2value(this.options.value),this.input.prerender()},initTemplate:function(){this.$form=a(a.fn.editableform.template)},initButtons:function(){var b=this.$form.find(".editable-buttons");b.append(a.fn.editableform.buttons),"bottom"===this.options.showbuttons&&b.addClass("editable-buttons-bottom")},render:function(){this.$loading=a(a.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),a.when(this.input.render()).then(a.proxy(function(){if(this.options.showbuttons||this.input.autosubmit(),this.$form.find(".editable-cancel").click(a.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(a){a.preventDefault()});else{this.error(!1),this.input.$input.removeAttr("disabled"),this.$form.find(".editable-submit").removeAttr("disabled");var b=null===this.value||void 0===this.value||""===this.value?this.options.defaultValue:this.value;this.input.value2input(b),this.$form.submit(a.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 a,b;this.$form?(a=this.$form.outerWidth(),b=this.$form.outerHeight(),a&&this.$loading.width(a),b&&this.$loading.height(b),this.$form.hide()):(a=this.$loading.parent().width(),a&&this.$loading.width(a)),this.$loading.show()},showForm:function(a){this.$loading.hide(),this.$form.show(),a!==!1&&this.input.activate(),this.$div.triggerHandler("show")},error:function(b){var c,d=this.$form.find(".control-group"),e=this.$form.find(".editable-error-block");if(b===!1)d.removeClass(a.fn.editableform.errorGroupClass),e.removeClass(a.fn.editableform.errorBlockClass).empty().hide();else{if(b){c=(""+b).split("\n");for(var f=0;f").text(c[f]).html();b=c.join("
")}d.addClass(a.fn.editableform.errorGroupClass),e.addClass(a.fn.editableform.errorBlockClass).html(b).show()}},submit:function(b){b.stopPropagation(),b.preventDefault();var c=this.input.input2value(),d=this.validate(c);if("object"===a.type(d)&&void 0!==d.newValue){if(c=d.newValue,this.input.value2input(c),"string"==typeof d.msg)return this.error(d.msg),void this.showForm()}else if(d)return this.error(d),void this.showForm();if(!this.options.savenochange&&this.input.value2str(c)===this.input.value2str(this.value))return void this.$div.triggerHandler("nochange");var e=this.input.value2submit(c);this.isSaving=!0,a.when(this.save(e)).done(a.proxy(function(a){this.isSaving=!1;var b="function"==typeof this.options.success?this.options.success.call(this.options.scope,a,c):null;return b===!1?(this.error(!1),void this.showForm(!1)):"string"==typeof b?(this.error(b),void this.showForm()):(b&&"object"==typeof b&&b.hasOwnProperty("newValue")&&(c=b.newValue),this.error(!1),this.value=c,void this.$div.triggerHandler("save",{newValue:c,submitValue:e,response:a}))},this)).fail(a.proxy(function(a){this.isSaving=!1;var b;b="function"==typeof this.options.error?this.options.error.call(this.options.scope,a,c):"string"==typeof a?a:a.responseText||a.statusText||"Unknown error!",this.error(b),this.showForm()},this))},save:function(b){this.options.pk=a.fn.editableutils.tryParseJson(this.options.pk,!0);var c,d="function"==typeof this.options.pk?this.options.pk.call(this.options.scope):this.options.pk,e=!!("function"==typeof this.options.url||this.options.url&&("always"===this.options.send||"auto"===this.options.send&&null!==d&&void 0!==d));return e?(this.showLoading(),c={name:this.options.name||"",value:b,pk:d},"function"==typeof this.options.params?c=this.options.params.call(this.options.scope,c):(this.options.params=a.fn.editableutils.tryParseJson(this.options.params,!0),a.extend(c,this.options.params)),"function"==typeof this.options.url?this.options.url.call(this.options.scope,c):a.ajax(a.extend({url:this.options.url,data:c,type:"POST"},this.options.ajaxOptions))):void 0},validate:function(a){return void 0===a&&(a=this.value),"function"==typeof this.options.validate?this.options.validate.call(this.options.scope,a):void 0},option:function(a,b){a in this.options&&(this.options[a]=b),"value"===a&&this.setValue(b)},setValue:function(a,b){b?this.value=this.input.str2value(a):this.value=a,this.$form&&this.$form.is(":visible")&&this.input.value2input(this.value)}},a.fn.editableform=function(c){var d=arguments;return this.each(function(){var e=a(this),f=e.data("editableform"),g="object"==typeof c&&c;f||e.data("editableform",f=new b(this,g)),"string"==typeof c&&f[c].apply(f,Array.prototype.slice.call(d,1))})},a.fn.editableform.Constructor=b,a.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},a.fn.editableform.template='
',a.fn.editableform.loading='
',a.fn.editableform.buttons='',a.fn.editableform.errorGroupClass=null,a.fn.editableform.errorBlockClass="editable-error",a.fn.editableform.engine="jquery"}(window.jQuery),function(a){"use strict";a.fn.editableutils={inherit:function(a,b){var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a,a.superclass=b.prototype},setCursorPosition:function(a,b){if(a.setSelectionRange)a.setSelectionRange(b,b);else if(a.createTextRange){var c=a.createTextRange();c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",b),c.select()}},tryParseJson:function(a,b){if("string"==typeof a&&a.length&&a.match(/^[\{\[].*[\}\]]$/))if(b)try{a=new Function("return "+a)()}catch(c){}finally{return a}else a=new Function("return "+a)();return a},sliceObj:function(b,c,d){var e,f,g={};if(!a.isArray(c)||!c.length)return g;for(var h=0;h").text(b).html()},itemsByValue:function(b,c,d){if(!c||null===b)return[];if("function"!=typeof d){var e=d||"value";d=function(a){return a[e]}}var f=a.isArray(b),g=[],h=this;return a.each(c,function(c,e){if(e.children)g=g.concat(h.itemsByValue(b,e.children,d));else if(f)a.grep(b,function(a){return a==(e&&"object"==typeof e?d(e):e)}).length&&g.push(e);else{var i=e&&"object"==typeof e?d(e):e;b==i&&g.push(e)}}),g},createInput:function(b){var c,d,e,f=b.type;return"date"===f&&("inline"===b.mode?a.fn.editabletypes.datefield?f="datefield":a.fn.editabletypes.dateuifield&&(f="dateuifield"):a.fn.editabletypes.date?f="date":a.fn.editabletypes.dateui&&(f="dateui"),"date"!==f||a.fn.editabletypes.date||(f="combodate")),"datetime"===f&&"inline"===b.mode&&(f="datetimefield"),"wysihtml5"!==f||a.fn.editabletypes[f]||(f="textarea"),"function"==typeof a.fn.editabletypes[f]?(c=a.fn.editabletypes[f],d=this.sliceObj(b,this.objectKeys(c.defaults)),e=new c(d)):(a.error("Unknown type: "+f),!1)},supportsTransitions:function(){var a=document.body||document.documentElement,b=a.style,c="transition",d=["Moz","Webkit","Khtml","O","ms"];if("string"==typeof b[c])return!0;c=c.charAt(0).toUpperCase()+c.substr(1);for(var e=0;e"),this.tip().is(this.innerCss)?this.tip().append(this.$form):this.tip().find(this.innerCss).append(this.$form),this.renderForm()},hide:function(a){if(this.tip()&&this.tip().is(":visible")&&this.$element.hasClass("editable-open")){if(this.$form.data("editableform").isSaving)return void(this.delayedHide={reason:a});this.delayedHide=!1,this.$element.removeClass("editable-open"),this.innerHide(),this.$element.triggerHandler("hidden",a||"manual")}},innerShow:function(){},innerHide:function(){},toggle:function(a){this.container()&&this.tip()&&this.tip().is(":visible")?this.hide():this.show(a)},setPosition:function(){},save:function(a,b){this.$element.triggerHandler("save",b),this.hide("save")},option:function(a,b){this.options[a]=b,a in this.containerOptions?(this.containerOptions[a]=b,this.setContainerOption(a,b)):(this.formOptions[a]=b,this.$form&&this.$form.editableform("option",a,b))},setContainerOption:function(a,b){this.call("option",a,b)},destroy:function(){this.hide(),this.innerDestroy(),this.$element.off("destroyed"),this.$element.removeData("editableContainer")},innerDestroy:function(){},closeOthers:function(b){a(".editable-open").each(function(c,d){if(d!==b&&!a(d).find(b).length){var e=a(d),f=e.data("editableContainer");f&&("cancel"===f.options.onblur?e.data("editableContainer").hide("onblur"):"submit"===f.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()}},a.fn.editableContainer=function(d){var e=arguments;return this.each(function(){var f=a(this),g="editableContainer",h=f.data(g),i="object"==typeof d&&d,j="inline"===i.mode?c:b;h||f.data(g,h=new j(this,i)),"string"==typeof d&&h[d].apply(h,Array.prototype.slice.call(e,1))})},a.fn.editableContainer.Popup=b,a.fn.editableContainer.Inline=c,a.fn.editableContainer.defaults={value:null,placement:"top",autohide:!0,onblur:"cancel",anim:!1,mode:"popup"},jQuery.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(window.jQuery),function(a){"use strict";a.extend(a.fn.editableContainer.Inline.prototype,a.fn.editableContainer.Popup.prototype,{containerName:"editableform",innerCss:".editable-inline",containerClass:"editable-container editable-inline",initContainer:function(){this.$tip=a(""),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,a.proxy(function(){this.$element.show(),this.innerDestroy()},this))},innerDestroy:function(){this.tip()&&this.tip().empty().remove()}})}(window.jQuery),function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.editable.defaults,c,a.fn.editableutils.getConfigData(this.$element)),this.options.selector?this.initLive():this.init(),this.options.highlight&&!a.fn.editableutils.supportsTransitions()&&(this.options.highlight=!1)};b.prototype={constructor:b,init:function(){var b,c=!1;if(this.options.name=this.options.name||this.$element.attr("id"),this.options.scope=this.$element[0],this.input=a.fn.editableutils.createInput(this.options),this.input){switch(void 0===this.options.value||null===this.options.value?(this.value=this.input.html2value(a.trim(this.$element.html())),c=!0):(this.options.value=a.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",a.proxy(function(a){if(this.options.disabled||a.preventDefault(),"mouseenter"===this.options.toggle)this.show();else{var b="click"!==this.options.toggle;this.toggle(b)}},this))):this.$element.attr("tabindex",-1),"function"==typeof this.options.display&&(this.options.autotext="always"),this.options.autotext){case"always":b=!0;break;case"auto":b=!a.trim(this.$element.text()).length&&null!==this.value&&void 0!==this.value&&!c;break;default:b=!1}a.when(b?this.render():!0).then(a.proxy(function(){this.options.disabled?this.disable():this.enable(),this.$element.triggerHandler("init",this)},this))}},initLive:function(){var b=this.options.selector;this.options.selector=!1,this.options.autotext="never",this.$element.on(this.options.toggle+".editable",b,a.proxy(function(b){var c=a(b.target);c.data("editable")||(c.hasClass(this.options.emptyclass)&&c.empty(),c.editable(this.options).trigger(b))},this))},render:function(a){return this.options.display!==!1?this.input.value2htmlFinal?this.input.value2html(this.value,this.$element[0],this.options.display,a):"function"==typeof this.options.display?this.options.display.call(this.$element[0],this.value,a):this.input.value2html(this.value,this.$element[0]):void 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(b,c){return b&&"object"==typeof b?void a.each(b,a.proxy(function(b,c){this.option(a.trim(b),c)},this)):(this.options[b]=c,"disabled"===b?c?this.disable():this.enable():("value"===b&&this.setValue(c),this.container&&this.container.option(b,c),void(this.input.option&&this.input.option(b,c))))},handleEmpty:function(b){this.options.display!==!1&&(void 0!==b?this.isEmpty=b:"function"==typeof this.input.isEmpty?this.isEmpty=this.input.isEmpty(this.$element):this.isEmpty=""===a.trim(this.$element.html()),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(b){if(!this.options.disabled){if(this.container){if(this.container.tip().is(":visible"))return}else{var c=a.extend({},this.options,{value:this.value,input:this.input});this.$element.editableContainer(c),this.$element.on("save.internal",a.proxy(this.save,this)),this.container=this.$element.data("editableContainer")}this.container.show(b)}},hide:function(){this.container&&this.container.hide()},toggle:function(a){this.container&&this.container.tip().is(":visible")?this.hide():this.show(a)},save:function(a,b){if(this.options.unsavedclass){var c=!1;c=c||"function"==typeof this.options.url,c=c||this.options.display===!1,c=c||void 0!==b.response,c=c||this.options.savenochange&&this.input.value2str(this.value)!==this.input.value2str(b.newValue),c?this.$element.removeClass(this.options.unsavedclass):this.$element.addClass(this.options.unsavedclass)}if(this.options.highlight){var d=this.$element,e=d.css("background-color");d.css("background-color",this.options.highlight),setTimeout(function(){"transparent"===e&&(e=""),d.css("background-color",e),d.addClass("editable-bg-transition"),setTimeout(function(){d.removeClass("editable-bg-transition")},1700)},10)}this.setValue(b.newValue,!1,b.response)},validate:function(){return"function"==typeof this.options.validate?this.options.validate.call(this,this.value):void 0},setValue:function(b,c,d){c?this.value=this.input.str2value(b):this.value=b,this.container&&this.container.option("value",this.value),a.when(this.render(d)).then(a.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")}},a.fn.editable=function(c){var d={},e=arguments,f="editable";switch(c){case"validate":return this.each(function(){var b,c=a(this),e=c.data(f);e&&(b=e.validate())&&(d[e.options.name]=b)}),d;case"getValue":return 2===arguments.length&&arguments[1]===!0?d=this.eq(0).data(f).value:this.each(function(){var b=a(this),c=b.data(f);c&&void 0!==c.value&&null!==c.value&&(d[c.options.name]=c.input.value2submit(c.value))}),d;case"submit":var g=arguments[1]||{},h=this,i=this.editable("validate");if(a.isEmptyObject(i)){var j={};if(1===h.length){var k=h.data("editable"),l={name:k.options.name||"",value:k.input.value2submit(k.value),pk:"function"==typeof k.options.pk?k.options.pk.call(k.options.scope):k.options.pk};"function"==typeof k.options.params?l=k.options.params.call(k.options.scope,l):(k.options.params=a.fn.editableutils.tryParseJson(k.options.params,!0),a.extend(l,k.options.params)),j={url:k.options.url,data:l,type:"POST"},g.success=g.success||k.options.success,g.error=g.error||k.options.error}else{var m=this.editable("getValue");j={url:g.url,data:m,type:"POST"}}j.success="function"==typeof g.success?function(a){g.success.call(h,a,g)}:a.noop,j.error="function"==typeof g.error?function(){g.error.apply(h,arguments)}:a.noop,g.ajaxOptions&&a.extend(j,g.ajaxOptions),g.data&&a.extend(j.data,g.data),a.ajax(j)}else"function"==typeof g.error&&g.error.call(h,i);return this}return this.each(function(){var d=a(this),g=d.data(f),h="object"==typeof c&&c;return h&&h.selector?void(g=new b(this,h)):(g||d.data(f,g=new b(this,h)),void("string"==typeof c&&g[c].apply(g,Array.prototype.slice.call(e,1))))})},a.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),function(a){"use strict";a.fn.editabletypes={};var b=function(){};b.prototype={init:function(b,c,d){this.type=b,this.options=a.extend({},d,c)},prerender:function(){this.$tpl=a(this.options.tpl),this.$input=this.$tpl,this.$clear=null,this.error=null},render:function(){},value2html:function(b,c){a(c)[this.options.escape?"text":"html"](a.trim(b))},html2value:function(b){return a("
").html(b).text()},value2str:function(a){return a},str2value:function(a){return a},value2submit:function(a){return a},value2input:function(a){this.$input.val(a)},input2value:function(){return this.$input.val()},activate:function(){this.$input.is(":visible")&&this.$input.focus()},clear:function(){this.$input.val(null)},escape:function(b){return a("
").text(b).html()},autosubmit:function(){},destroy:function(){},setClass:function(){this.options.inputclass&&this.$input.addClass(this.options.inputclass)},setAttr:function(a){void 0!==this.options[a]&&null!==this.options[a]&&this.$input.attr(a,this.options[a])},option:function(a,b){this.options[a]=b}},b.defaults={tpl:"",inputclass:null,escape:!0,scope:null,showbuttons:!0},a.extend(a.fn.editabletypes,{abstractinput:b})}(window.jQuery),function(a){"use strict";var b=function(a){};a.fn.editableutils.inherit(b,a.fn.editabletypes.abstractinput),a.extend(b.prototype,{render:function(){var b=a.Deferred();return this.error=null,this.onSourceReady(function(){this.renderList(),b.resolve()},function(){this.error=this.options.sourceError,b.resolve()}),b.promise()},html2value:function(a){return null},value2html:function(b,c,d,e){var f=a.Deferred(),g=function(){"function"==typeof d?d.call(c,b,this.sourceData,e):this.value2htmlFinal(b,c),f.resolve()};return null===b?g.call(this):this.onSourceReady(g,function(){f.resolve()}),f.promise()},onSourceReady:function(b,c){var d;if(a.isFunction(this.options.source)?(d=this.options.source.call(this.options.scope),this.sourceData=null):d=this.options.source,this.options.sourceCache&&a.isArray(this.sourceData))return void b.call(this);try{d=a.fn.editableutils.tryParseJson(d,!1)}catch(e){return void c.call(this)}if("string"==typeof d){if(this.options.sourceCache){var f,g=d;if(a(document).data(g)||a(document).data(g,{}),f=a(document).data(g),f.loading===!1&&f.sourceData)return this.sourceData=f.sourceData,this.doPrepend(),void b.call(this);if(f.loading===!0)return f.callbacks.push(a.proxy(function(){this.sourceData=f.sourceData,this.doPrepend(),b.call(this)},this)),void f.err_callbacks.push(a.proxy(c,this));f.loading=!0,f.callbacks=[],f.err_callbacks=[]}var h=a.extend({url:d,type:"get",cache:!1,dataType:"json",success:a.proxy(function(d){f&&(f.loading=!1),this.sourceData=this.makeArray(d),a.isArray(this.sourceData)?(f&&(f.sourceData=this.sourceData,a.each(f.callbacks,function(){this.call()})),this.doPrepend(),b.call(this)):(c.call(this),f&&a.each(f.err_callbacks,function(){this.call()}))},this),error:a.proxy(function(){c.call(this),f&&(f.loading=!1,a.each(f.err_callbacks,function(){this.call()}))},this)},this.options.sourceOptions);a.ajax(h)}else this.sourceData=this.makeArray(d),a.isArray(this.sourceData)?(this.doPrepend(),b.call(this)):c.call(this)},doPrepend:function(){null!==this.options.prepend&&void 0!==this.options.prepend&&(a.isArray(this.prependData)||(a.isFunction(this.options.prepend)&&(this.options.prepend=this.options.prepend.call(this.options.scope)),this.options.prepend=a.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)),a.isArray(this.prependData)&&a.isArray(this.sourceData)&&(this.sourceData=this.prependData.concat(this.sourceData)))},renderList:function(){},value2htmlFinal:function(a,b){},makeArray:function(b){var c,d,e,f,g=[];if(!b||"string"==typeof b)return null;if(a.isArray(b)){f=function(a,b){return d={value:a,text:b},c++>=2?!1:void 0};for(var h=0;h1&&(e.children&&(e.children=this.makeArray(e.children)),g.push(e))):g.push({value:e,text:e})}else a.each(b,function(a,b){g.push({value:a,text:b})});return g},option:function(a,b){this.options[a]=b,"source"===a&&(this.sourceData=null),"prepend"===a&&(this.prependData=null)}}),b.defaults=a.extend({},a.fn.editabletypes.abstractinput.defaults,{source:null,prepend:!1,sourceError:"Error when loading list",sourceCache:!0,sourceOptions:null}),a.fn.editabletypes.list=b}(window.jQuery),function(a){"use strict";var b=function(a){this.init("text",a,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.abstractinput),a.extend(b.prototype,{render:function(){this.renderClear(),this.setClass(),this.setAttr("placeholder")},activate:function(){this.$input.is(":visible")&&(this.$input.focus(),this.$input.is("input,textarea")&&!this.$input.is('[type="checkbox"],[type="range"]')&&a.fn.editableutils.setCursorPosition(this.$input.get(0),this.$input.val().length),this.toggleClear&&this.toggleClear())},renderClear:function(){this.options.clear&&(this.$clear=a(''),this.$input.after(this.$clear).css("padding-right",24).keyup(a.proxy(function(b){if(!~a.inArray(b.keyCode,[40,38,9,13,27])){clearTimeout(this.t);var c=this;this.t=setTimeout(function(){c.toggleClear(b)},100)}},this)).parent().css("position","relative"),this.$clear.click(a.proxy(this.clear,this)))},postrender:function(){},toggleClear:function(a){if(this.$clear){var b=this.$input.val().length,c=this.$clear.is(":visible");b&&!c&&this.$clear.show(),!b&&c&&this.$clear.hide()}},clear:function(){this.$clear.hide(),this.$input.val("").focus()}}),b.defaults=a.extend({},a.fn.editabletypes.abstractinput.defaults,{tpl:'',placeholder:null,clear:!0}),a.fn.editabletypes.text=b}(window.jQuery),function(a){"use strict";var b=function(a){this.init("textarea",a,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.abstractinput),a.extend(b.prototype,{render:function(){this.setClass(),this.setAttr("placeholder"),this.setAttr("rows"),this.$input.keydown(function(b){b.ctrlKey&&13===b.which&&a(this).closest("form").submit()})},activate:function(){a.fn.editabletypes.text.prototype.activate.call(this)}}),b.defaults=a.extend({},a.fn.editabletypes.abstractinput.defaults,{tpl:"",inputclass:"input-large",placeholder:null,rows:7}),a.fn.editabletypes.textarea=b}(window.jQuery),function(a){"use strict";var b=function(a){this.init("select",a,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.list),a.extend(b.prototype,{renderList:function(){this.$input.empty();var b=this.options.escape,c=function(d,e){var f;if(a.isArray(e))for(var g=0;g",f),e[g].children));else{f.value=e[g].value,e[g].disabled&&(f.disabled=!0);var h=a("