diff --git a/src/html/assets/javascripts/releases/4.0.2/tbx.js b/src/html/assets/javascripts/releases/4.0.2/tbx.js index b72070f93..37e1f3a95 100644 --- a/src/html/assets/javascripts/releases/4.0.2/tbx.js +++ b/src/html/assets/javascripts/releases/4.0.2/tbx.js @@ -86,7 +86,7 @@ window.Modernizr = (function( window, document, undefined ) { }; } else { - hasOwnProp = function (object, property) { + hasOwnProp = function (object, property) { return ((property in object) && is(object.constructor.prototype[property], 'undefined')); }; } @@ -208,7 +208,7 @@ window.Modernizr = (function( window, document, undefined ) { } - return Modernizr; + return Modernizr; }; @@ -1963,11 +1963,19 @@ Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0));}; (function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.css(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery); /* /x-editable/bootstrap-editable/js/bootstrap-editable.js */ +<<<<<<< HEAD /*! X-editable - v1.3.0 * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * http://github.com/vitalets/x-editable * Copyright (c) 2012 Vitaliy Potapov; Licensed MIT */ +======= +/*! X-editable - v1.3.0 +* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery +* http://github.com/vitalets/x-editable +* Copyright (c) 2012 Vitaliy Potapov; Licensed MIT */ + +>>>>>>> ba9cada... Proposed fix for #1576 - photos sorting behaviour consistent for Gallery, Album and Tag views /** 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. @@ -2000,13 +2008,13 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. this.input = new TypeConstructor(typeOptions); } else { $.error('Unknown type: '+ this.options.type); - return; - } + return; + } - this.value = this.input.str2value(this.options.value); + this.value = this.input.str2value(this.options.value); }, initTemplate: function() { - this.$form = $($.fn.editableform.template); + this.$form = $($.fn.editableform.template); }, initButtons: function() { this.$form.find('.editable-buttons').append($.fn.editableform.buttons); @@ -2015,25 +2023,25 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. Renders editableform @method render - **/ + **/ render: function() { - this.$loading = $($.fn.editableform.loading); + this.$loading = $($.fn.editableform.loading); this.$div.empty().append(this.$loading); this.showLoading(); - + //init form template and buttons - this.initTemplate(); + this.initTemplate(); if(this.options.showbuttons) { this.initButtons(); } else { this.$form.find('.editable-buttons').remove(); } - /** + /** Fired when rendering starts - @event rendering + @event rendering @param {Object} event event object - **/ + **/ this.$div.triggerHandler('rendering'); //render input @@ -2044,17 +2052,17 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. //automatically submit inputs when no buttons shown if(!this.options.showbuttons) { - this.input.autosubmit(); + this.input.autosubmit(); } - + //"clear" link if(this.input.$clear) { - this.$form.find('div.editable-input').append($('
').append(this.input.$clear)); - } + this.$form.find('div.editable-input').append($('
').append(this.input.$clear)); + } //append form to container this.$div.append(this.$form); - + //attach 'cancel' handler this.$form.find('.editable-cancel').click($.proxy(this.cancel, this)); @@ -2073,28 +2081,28 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. this.$form.submit($.proxy(this.submit, this)); } - /** + /** Fired when form is rendered @event rendered @param {Object} event event object - **/ - this.$div.triggerHandler('rendered'); + **/ + this.$div.triggerHandler('rendered'); this.showForm(); }, this)); }, - cancel: function() { - /** + cancel: function() { + /** Fired when form was cancelled by user - @event cancel + @event cancel @param {Object} event event object - **/ + **/ this.$div.triggerHandler('cancel'); }, showLoading: function() { var w; if(this.$form) { - //set loading size equal to form + //set loading size equal to form this.$loading.width(this.$form.outerWidth()); this.$loading.height(this.$form.outerHeight()); this.$form.hide(); @@ -2105,20 +2113,20 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. this.$loading.width(w); } } - this.$loading.show(); + this.$loading.show(); }, showForm: function(activate) { this.$loading.hide(); this.$form.show(); if(activate !== false) { - this.input.activate(); + this.input.activate(); } - /** + /** Fired when form is shown - @event show + @event show @param {Object} event event object - **/ + **/ this.$div.triggerHandler('show'); }, @@ -2128,7 +2136,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. if(msg === false) { $group.removeClass($.fn.editableform.errorGroupClass); - $block.removeClass($.fn.editableform.errorBlockClass).empty().hide(); + $block.removeClass($.fn.editableform.errorBlockClass).empty().hide(); } else { $group.addClass($.fn.editableform.errorGroupClass); $block.addClass($.fn.editableform.errorBlockClass).text(msg).show(); @@ -2138,7 +2146,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. submit: function(e) { e.stopPropagation(); e.preventDefault(); - + var error, newValue = this.input.input2value(); //get new value from input @@ -2147,52 +2155,52 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. this.error(error); this.showForm(); return; - } - + } + //if value not changed --> trigger 'nochange' event and return /*jslint eqeq: true*/ if (!this.options.savenochange && this.input.value2str(newValue) == this.input.value2str(this.value)) { - /*jslint eqeq: false*/ - /** + /*jslint eqeq: false*/ + /** Fired when value not changed but form is submitted. Requires savenochange = false. - @event nochange + @event nochange @param {Object} event event object - **/ - this.$div.triggerHandler('nochange'); + **/ + this.$div.triggerHandler('nochange'); return; - } + } //sending data to server $.when(this.save(newValue)) .done($.proxy(function(response) { //run success callback var res = typeof this.options.success === 'function' ? this.options.success.call(this.options.scope, response, newValue) : null; - + //if success callback returns false --> keep form open and do not activate input if(res === false) { this.error(false); this.showForm(false); return; - } - - //if success callback returns string --> keep form open, show error and activate input + } + + //if success callback returns string --> keep form open, show error and activate input if(typeof res === 'string') { this.error(res); this.showForm(); return; - } - + } + //if success callback returns object like {newValue: } --> use that value instead of submitted if(res && typeof res === 'object' && res.hasOwnProperty('newValue')) { newValue = res.newValue; - } + } //clear error message - this.error(false); + this.error(false); this.value = newValue; - /** + /** Fired when form is submitted - @event save + @event save @param {Object} event event object @param {Object} params additional params @param {mixed} params.newValue submitted value @@ -2201,23 +2209,23 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. @example $('#form-div').on('save'), function(e, params){ if(params.newValue === 'username') {...} - }); - **/ + }); + **/ this.$div.triggerHandler('save', {newValue: newValue, response: response}); }, this)) .fail($.proxy(function(xhr) { - this.error(typeof xhr === 'string' ? xhr : xhr.responseText || xhr.statusText || 'Unknown error!'); - this.showForm(); + this.error(typeof xhr === 'string' ? xhr : xhr.responseText || xhr.statusText || 'Unknown error!'); + this.showForm(); }, this)); }, save: function(newValue) { //convert value for submitting to server var submitValue = this.input.value2submit(newValue); - - //try parse composite pk defined as json string in data-pk - this.options.pk = $.fn.editableutils.tryParseJson(this.options.pk, true); - + + //try parse composite pk defined as json string in data-pk + this.options.pk = $.fn.editableutils.tryParseJson(this.options.pk, true); + var pk = (typeof this.options.pk === 'function') ? this.options.pk.call(this.options.scope) : this.options.pk, send = !!(typeof this.options.url === 'function' || (this.options.url && ((this.options.send === 'always') || (this.options.send === 'auto' && pk)))), params; @@ -2229,21 +2237,21 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. params = { name: this.options.name || '', value: submitValue, - pk: pk + pk: pk }; //additional params if(typeof this.options.params === 'function') { - params = this.options.params.call(this.options.scope, params); + params = this.options.params.call(this.options.scope, params); } else { //try parse json in single quotes (from data-params attribute) - this.options.params = $.fn.editableutils.tryParseJson(this.options.params, true); + this.options.params = $.fn.editableutils.tryParseJson(this.options.params, true); $.extend(params, this.options.params); } if(typeof this.options.url === 'function') { //user's function return this.options.url.call(this.options.scope, params); - } else { + } else { //send ajax to server and return deferred object return $.ajax($.extend({ url : this.options.url, @@ -2252,7 +2260,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. }, this.options.ajaxOptions)); } } - }, + }, validate: function (value) { if (value === undefined) { @@ -2276,7 +2284,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. } else { this.value = value; } - } + } }; /* @@ -2293,26 +2301,26 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. }); //to display form you should call 'render' method - $form.editableform('render'); + $form.editableform('render'); */ $.fn.editableform = function (option) { var args = arguments; return this.each(function () { - var $this = $(this), - data = $this.data('editableform'), - options = typeof option === 'object' && option; + var $this = $(this), + data = $this.data('editableform'), + options = typeof option === 'object' && option; if (!data) { $this.data('editableform', (data = new EditableForm(this, options))); } - if (typeof option === 'string') { //call method + if (typeof option === 'string') { //call method data[option].apply(data, Array.prototype.slice.call(args, 1)); - } + } }); }; //keep link to constructor to allow inheritance - $.fn.editableform.Constructor = EditableForm; + $.fn.editableform.Constructor = EditableForm; //defaults $.fn.editableform.defaults = { @@ -2321,16 +2329,16 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. /** Type of input. Can be text|textarea|select|date|checklist - @property type + @property type @type string @default 'text' **/ type: 'text', /** - Url for submit, e.g. '/post' + Url for submit, e.g. '/post' If function - it will be called instead of ajax. Function can return deferred object to run fail/done callbacks. - @property url + @property url @type string|function @default null @example @@ -2341,11 +2349,11 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. } else { someModel.set(params.name, params.value); //save data in some js model } - } - **/ + } + **/ url:null, /** - Additional params for submit. If defined as object - it is **appended** to original ajax data (pk, name and value). + Additional params for submit. If defined as object - it is **appended** to original ajax data (pk, name and value). If defined as function - returned object **overwrites** original ajax data. @example params: function(params) { @@ -2354,50 +2362,50 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. return params; } - @property params + @property params @type object|function @default null - **/ + **/ params:null, /** Name of field. Will be submitted on server. Can be taken from id attribute - @property name + @property name @type string @default null - **/ + **/ name: null, /** Primary key of editable object (e.g. record id in database). For composite keys use object, e.g. {id: 1, lang: 'en'}. Can be calculated dynamically via function. - @property pk + @property pk @type string|object|function @default null - **/ + **/ pk: null, /** Initial value. If not defined - will be taken from element's content. For __select__ type should be defined (as it is ID of shown text). - @property value + @property value @type string|object @default null - **/ + **/ value: null, /** Strategy for sending data on server. Can be auto|always|never. When 'auto' data will be sent on server only if pk defined, otherwise new value will be stored in element. - @property send + @property send @type string @default 'auto' - **/ - send: 'auto', + **/ + send: 'auto', /** Function for client-side validation. If returns string - means validation not passed and string showed as error. - @property validate + @property validate @type function @default null @example @@ -2406,81 +2414,81 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. return 'This field is required'; } } - **/ + **/ validate: null, /** - Success callback. Called when value successfully sent on server and **response status = 200**. + Success callback. Called when value successfully sent on server and **response status = 200**. Useful to work with json response. For example, if your backend response can be {success: true} - or {success: false, msg: "server error"} you can check it inside this callback. - If it returns **string** - means error occured and string is shown as error message. - If it returns **object like** {newValue: <something>} - it overwrites value, submitted by user. + or {success: false, msg: "server error"} you can check it inside this callback. + If it returns **string** - means error occured and string is shown as error message. + If it returns **object like** {newValue: <something>} - it overwrites value, submitted by user. Otherwise newValue simply rendered into element. - - @property success + + @property success @type function @default null @example success: function(response, newValue) { if(!response.success) return response.msg; } - **/ + **/ success: null, /** Additional options for ajax request. List of values: http://api.jquery.com/jQuery.ajax - @property ajaxOptions + @property ajaxOptions @type object @default null - @since 1.1.1 - **/ + @since 1.1.1 + **/ ajaxOptions: null, /** - Whether to show buttons or not. + Whether to show buttons or not. Form without buttons can be auto-submitted by input or by onblur = 'submit'. - @example + @example ajaxOptions: { method: 'PUT', dataType: 'xml' } - @property showbuttons + @property showbuttons @type boolean @default true @since 1.1.1 - **/ + **/ showbuttons: true, /** - Scope for callback methods (success, validate). - If null means editableform instance itself. + Scope for callback methods (success, validate). + If null means editableform instance itself. - @property scope + @property scope @type DOMElement|object @default null @since 1.2.0 @private - **/ + **/ scope: null, /** Whether to save or cancel value when it was not changed but form was submitted - @property savenochange + @property savenochange @type boolean @default false @since 1.2.0 **/ - savenochange: false - }; + savenochange: false + }; /* Note: following params could redefined in engine: bootstrap or jqueryui: Classes 'control-group' and 'editable-error-block' must always present! - */ + */ $.fn.editableform.template = '
'+ - '
' + + '
' + '
'+ - '
' + - '
' + + '
' + + '
' + '
'; //loading div @@ -2488,10 +2496,10 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. //buttons $.fn.editableform.buttons = ''+ - ''; + ''; //error class attached to control-group - $.fn.editableform.errorGroupClass = null; + $.fn.editableform.errorGroupClass = null; //error class attached to editable-error-block $.fn.editableform.errorBlockClass = 'editable-error'; @@ -2504,7 +2512,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. $.fn.editableutils = { /** * classic JS inheritance function - */ + */ inherit: function (Child, Parent) { var F = function() { }; F.prototype = Parent.prototype; @@ -2516,7 +2524,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. /** * set caret position in input * see http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area - */ + */ setCursorPosition: function(elem, pos) { if (elem.setSelectionRange) { elem.setSelectionRange(pos, pos); @@ -2601,7 +2609,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. objectKeys: function(o) { if (Object.keys) { - return Object.keys(o); + return Object.keys(o); } else { if (o !== Object(o)) { throw new TypeError('Object.keys called on a non-object'); @@ -2616,15 +2624,21 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc. } }, - + /** method to escape html. **/ escape: function(str) { return $('
').text(str).html(); +<<<<<<< HEAD } }; }(window.jQuery)); +======= + } + }; +}(window.jQuery)); +>>>>>>> ba9cada... Proposed fix for #1576 - photos sorting behaviour consistent for Gallery, Album and Tag views /** Attaches stand-alone container with editable-form to HTML element. Element is used only for positioning, value is not stored anywhere.
This method applied internally in $().editable(). You should subscribe on it's events (save / cancel) to get profit of it.
@@ -2647,40 +2661,40 @@ Applied as jQuery method. init: function(element, options) { this.$element = $(element); //todo: what is in priority: data or js? - this.options = $.extend({}, $.fn.editableContainer.defaults, $.fn.editableutils.getConfigData(this.$element), options); + this.options = $.extend({}, $.fn.editableContainer.defaults, $.fn.editableutils.getConfigData(this.$element), options); this.splitOptions(); this.initContainer(); //bind 'destroyed' listener to destroy container when element is removed from dom this.$element.on('destroyed', $.proxy(function(){ this.destroy(); - }, this)); - + }, this)); + //attach document handlers (once) if(!$(document).data('editable-handlers-attached')) { //close all on escape $(document).on('keyup.editable', function (e) { if (e.which === 27) { $('.editable-open').editableContainer('hide'); - //todo: return focus on element + //todo: return focus on element } }); //close containers when click outside $(document).on('click.editable', function(e) { var $target = $(e.target); - - //if click inside some editableContainer --> no nothing - if($target.is('.editable-container') || $target.parents('.editable-container').length || $target.parents('.ui-datepicker-header').length) { + + //if click inside some editableContainer --> no nothing + if($target.is('.editable-container') || $target.parents('.editable-container').length || $target.parents('.ui-datepicker-header').length) { return; } else { //close all open containers (except one) EditableContainer.prototype.closeOthers(e.target); } }); - + $(document).data('editable-handlers-attached', true); - } + } }, //split options on containerOptions and formOptions @@ -2693,10 +2707,10 @@ Applied as jQuery method. this.containerOptions[k] = this.options[k]; } else { this.formOptions[k] = this.options[k]; - } + } } }, - + initContainer: function(){ this.call(this.containerOptions); }, @@ -2712,78 +2726,78 @@ Applied as jQuery method. show: $.proxy(this.setPosition, this), //re-position container every time form is shown (occurs each time after loading state) rendering: $.proxy(this.setPosition, this), //this allows to place container correctly when loading shown rendered: $.proxy(function(){ - /** + /** Fired when container is shown and form is rendered (for select will wait for loading dropdown options) - - @event shown + + @event shown @param {Object} event event object @example $('#username').on('shown', function() { var $tip = $(this).data('editableContainer').tip(); $tip.find('input').val('overwriting value of input..'); - }); - **/ + }); + **/ this.$element.triggerHandler('shown'); - }, this) + }, this) }); return this.$form; - }, + }, /* Returns jquery object of container @method tip() - */ + */ tip: function() { return this.container().$tip; }, container: function() { - return this.$element.data(this.containerName); + return this.$element.data(this.containerName); }, call: function() { - this.$element[this.containerName].apply(this.$element, arguments); + this.$element[this.containerName].apply(this.$element, arguments); }, /** Shows container with form @method show() @param {boolean} closeAll Whether to close all other editable containers when showing this one. Default true. - **/ + **/ show: function (closeAll) { this.$element.addClass('editable-open'); if(closeAll !== false) { //close all open containers (except this) - this.closeOthers(this.$element[0]); + this.closeOthers(this.$element[0]); } - + this.innerShow(); }, - + /* internal show method. To be overwritten in child classes */ innerShow: function () { - this.call('show'); + this.call('show'); this.tip().addClass('editable-container'); this.initForm(); - this.tip().find(this.innerCss).empty().append(this.$form); - this.$form.editableform('render'); + this.tip().find(this.innerCss).empty().append(this.$form); + this.$form.editableform('render'); }, /** Hides container with form @method hide() @param {string} reason Reason caused hiding. Can be save|cancel|onblur|nochange|undefined (=manual) - **/ + **/ hide: function(reason) { if(!this.tip() || !this.tip().is(':visible') || !this.$element.hasClass('editable-open')) { return; } - this.$element.removeClass('editable-open'); + this.$element.removeClass('editable-open'); this.innerHide(); - /** + /** Fired when container was hidden. It occurs on both save or cancel. - @event hidden + @event hidden @param {object} event event object @param {string} reason Reason caused hiding. Can be save|cancel|onblur|nochange|undefined (=manual) @example @@ -2791,44 +2805,44 @@ Applied as jQuery method. if(reason === 'save' || reason === 'cancel') { //auto-open next editable $(this).closest('tr').next().find('.editable').editable('show'); - } - }); - **/ - this.$element.triggerHandler('hidden', reason); + } + }); + **/ + this.$element.triggerHandler('hidden', reason); }, - + /* internal hide method. To be overwritten in child classes */ innerHide: function () { - this.call('hide'); - }, - + this.call('hide'); + }, + /** Toggles container visibility (show / hide) @method toggle() @param {boolean} closeAll Whether to close all other editable containers when showing this one. Default true. - **/ + **/ toggle: function(closeAll) { if(this.tip && this.tip().is(':visible')) { this.hide(); } else { this.show(closeAll); - } + } }, /* Updates the position of container when content changed. @method setPosition() - */ + */ setPosition: function() { //tbd in child class }, save: function(e, params) { this.hide('save'); - /** + /** Fired when new value was submitted. You can use $(this).data('editableContainer') inside handler to access to editableContainer instance - - @event save + + @event save @param {Object} event event object @param {Object} params additional params @param {mixed} params.newValue submitted value @@ -2840,33 +2854,33 @@ Applied as jQuery method. if(params.response && params.response.success) { alert('value: ' + params.newValue + ' with pk: ' + pk + ' saved!'); } else { - alert('error!'); - } + alert('error!'); + } }); - **/ + **/ this.$element.triggerHandler('save', params); }, /** Sets new option - + @method option(key, value) - @param {string} key - @param {mixed} value - **/ + @param {string} key + @param {mixed} value + **/ option: function(key, value) { this.options[key] = value; if(key in this.containerOptions) { this.containerOptions[key] = value; - this.setContainerOption(key, value); + this.setContainerOption(key, value); } else { this.formOptions[key] = value; if(this.$form) { - this.$form.editableform('option', key, value); + this.$form.editableform('option', key, value); } } }, - + setContainerOption: function(key, value) { this.call('option', key, value); }, @@ -2874,13 +2888,13 @@ Applied as jQuery method. /** Destroys the container instance @method destroy() - **/ + **/ destroy: function() { this.call('destroy'); }, - + /* - Closes other containers except one related to passed element. + Closes other containers except one related to passed element. Other containers can be cancelled or submitted (depends on onblur option) */ closeOthers: function(element) { @@ -2890,14 +2904,14 @@ Applied as jQuery method. return; } - //otherwise cancel or submit all open containers + //otherwise cancel or submit all open containers var $el = $(el), ec = $el.data('editableContainer'); if(!ec) { - return; + return; } - + if(ec.options.onblur === 'cancel') { $el.data('editableContainer').hide('onblur'); } else if(ec.options.onblur === 'submit') { @@ -2906,22 +2920,22 @@ Applied as jQuery method. }); }, - + /** Activates input of visible container (e.g. set focus) @method activate() - **/ + **/ activate: function() { if(this.tip && this.tip().is(':visible') && this.$form) { - this.$form.data('editableform').input.activate(); + this.$form.data('editableform').input.activate(); } - } + } }; /** jQuery method to initialize editableContainer. - + @method $().editableContainer(options) @params {Object} options @example @@ -2931,24 +2945,24 @@ Applied as jQuery method. pk: 1, value: 'hello' }); - **/ + **/ $.fn.editableContainer = function (option) { var args = arguments; return this.each(function () { var $this = $(this), - dataKey = 'editableContainer', - data = $this.data(dataKey), + dataKey = 'editableContainer', + data = $this.data(dataKey), options = typeof option === 'object' && option; if (!data) { $this.data(dataKey, (data = new EditableContainer(this, options))); } - if (typeof option === 'string') { //call method + if (typeof option === 'string') { //call method data[option].apply(data, Array.prototype.slice.call(args, 1)); - } + } }); - }; + }; //store constructor $.fn.editableContainer.Constructor = EditableContainer; @@ -2958,42 +2972,42 @@ Applied as jQuery method. /** Initial value of form input - @property value + @property value @type mixed @default null @private - **/ + **/ value: null, /** Placement of container relative to element. Can be top|right|bottom|left. Not used for inline container. - @property placement + @property placement @type string @default 'top' - **/ + **/ placement: 'top', /** Whether to hide container on save/cancel. - @property autohide + @property autohide @type boolean @default true - @private - **/ + @private + **/ autohide: true, /** - Action when user clicks outside the container. Can be cancel|submit|ignore. - Setting ignore allows to have several containers open. + Action when user clicks outside the container. Can be cancel|submit|ignore. + Setting ignore allows to have several containers open. - @property onblur + @property onblur @type string @default 'cancel' @since 1.1.1 - **/ + **/ onblur: 'cancel' }; - /* + /* * workaround to have 'destroyed' event to destroy popover when element is destroyed * see http://stackoverflow.com/questions/2200494/jquery-trigger-event-when-an-element-is-removed-from-the-dom */ @@ -3003,7 +3017,7 @@ Applied as jQuery method. o.handler(); } } - }; + }; }(window.jQuery)); @@ -3017,27 +3031,27 @@ Makes editable any HTML element on the page. Applied as jQuery method. var Editable = function (element, options) { this.$element = $(element); - this.options = $.extend({}, $.fn.editable.defaults, $.fn.editableutils.getConfigData(this.$element), options); + this.options = $.extend({}, $.fn.editable.defaults, $.fn.editableutils.getConfigData(this.$element), options); this.init(); }; Editable.prototype = { - constructor: Editable, + constructor: Editable, init: function () { - var TypeConstructor, - isValueByText = false, - doAutotext, + var TypeConstructor, + isValueByText = false, + doAutotext, finalize; //editableContainer must be defined if(!$.fn.editableContainer) { $.error('You must define $.fn.editableContainer via including corresponding file (e.g. editable-popover.js)'); return; - } - + } + //name this.options.name = this.options.name || this.$element.attr('id'); - + //create input of specified type. Input will be used for converting value, not in form if(typeof $.fn.editabletypes[this.options.type] === 'function') { TypeConstructor = $.fn.editabletypes[this.options.type]; @@ -3045,8 +3059,8 @@ Makes editable any HTML element on the page. Applied as jQuery method. this.input = new TypeConstructor(this.typeOptions); } else { $.error('Unknown type: '+ this.options.type); - return; - } + return; + } //set value from settings or by element's text if (this.options.value === undefined || this.options.value === null) { @@ -3055,42 +3069,42 @@ Makes editable any HTML element on the page. Applied as jQuery method. } else { /* value can be string when received from 'data-value' attribute - for complext objects value can be set as json string in data-value attribute, + for complext objects value can be set as json string in data-value attribute, e.g. data-value="{city: 'Moscow', street: 'Lenina'}" */ - this.options.value = $.fn.editableutils.tryParseJson(this.options.value, true); + this.options.value = $.fn.editableutils.tryParseJson(this.options.value, true); if(typeof this.options.value === 'string') { this.value = this.input.str2value(this.options.value); } else { this.value = this.options.value; } } - + //add 'editable' class to every editable element this.$element.addClass('editable'); - + //attach handler activating editable. In disabled mode it just prevent default action (useful for links) if(this.options.toggle !== 'manual') { this.$element.addClass('editable-click'); this.$element.on(this.options.toggle + '.editable', $.proxy(function(e){ - + e.preventDefault(); //stop propagation not required anymore because in document click handler it checks event target //e.stopPropagation(); - + if(this.options.toggle === 'mouseenter') { //for hover only show container - this.show(); + this.show(); } else { //when toggle='click' we should not close all other containers as they will be closed automatically in document click listener var closeAll = (this.options.toggle !== 'click'); this.toggle(closeAll); - } + } }, this)); } else { this.$element.attr('tabindex', -1); //do not stop focus on element when toggled manually } - + //check conditions for autotext: //if value was generated by text or value is empty, no sense to run autotext doAutotext = !isValueByText && this.value !== null && this.value !== undefined; @@ -3099,16 +3113,16 @@ Makes editable any HTML element on the page. Applied as jQuery method. if(this.options.disabled) { this.disable(); } else { - this.enable(); + this.enable(); } - /** + /** Fired when element was initialized by editable method. - - @event init + + @event init @param {Object} event event object @param {Object} editable editable instance @since 1.2.0 - **/ + **/ this.$element.triggerHandler('init', this); }, this)); }, @@ -3118,7 +3132,7 @@ Makes editable any HTML element on the page. Applied as jQuery method. Can call custom display method from options. Can return deferred object. @method render() - */ + */ render: function() { //do not display anything if(this.options.display === false) { @@ -3126,77 +3140,77 @@ Makes editable any HTML element on the page. Applied as jQuery method. } //if it is input with source, we pass callback in third param to be called when source is loaded if(this.input.options.hasOwnProperty('source')) { - return this.input.value2html(this.value, this.$element[0], this.options.display); - //if display method defined --> use it + return this.input.value2html(this.value, this.$element[0], this.options.display); + //if display method defined --> use it } else if(typeof this.options.display === 'function') { return this.options.display.call(this.$element[0], this.value); - //else use input's original value2html() method + //else use input's original value2html() method } else { - return this.input.value2html(this.value, this.$element[0]); + return this.input.value2html(this.value, this.$element[0]); } }, - + /** Enables editable @method enable() - **/ + **/ enable: function() { this.options.disabled = false; this.$element.removeClass('editable-disabled'); this.handleEmpty(); if(this.options.toggle !== 'manual') { - if(this.$element.attr('tabindex') === '-1') { - this.$element.removeAttr('tabindex'); + if(this.$element.attr('tabindex') === '-1') { + this.$element.removeAttr('tabindex'); } } }, - + /** Disables editable @method disable() - **/ + **/ disable: function() { - this.options.disabled = true; - this.hide(); + this.options.disabled = true; + this.hide(); this.$element.addClass('editable-disabled'); this.handleEmpty(); //do not stop focus on this element - this.$element.attr('tabindex', -1); + this.$element.attr('tabindex', -1); }, - + /** Toggles enabled / disabled state of editable element @method toggleDisabled() - **/ + **/ toggleDisabled: function() { if(this.options.disabled) { this.enable(); - } else { - this.disable(); + } else { + this.disable(); } - }, - + }, + /** Sets new option - + @method option(key, value) @param {string|object} key option name or object with several options @param {mixed} value option new value @example $('.editable').editable('option', 'pk', 2); - **/ + **/ option: function(key, value) { //set option(s) by object if(key && typeof key === 'object') { $.each(key, $.proxy(function(k, v){ - this.option($.trim(k), v); - }, this)); + this.option($.trim(k), v); + }, this)); return; } - //set option by string - this.options[key] = value; - + //set option by string + this.options[key] = value; + //disabled if(key === 'disabled') { if(value) { @@ -3205,19 +3219,19 @@ Makes editable any HTML element on the page. Applied as jQuery method. this.enable(); } return; - } - + } + //value if(key === 'value') { this.setValue(value); } - - //transfer new option to container! + + //transfer new option to container! if(this.container) { - this.container.option(key, value); + this.container.option(key, value); } - }, - + }, + /* * set emptytext if element is empty (reverse: remove emptytext if needed) */ @@ -3226,7 +3240,7 @@ Makes editable any HTML element on the page. Applied as jQuery method. if(this.options.display === false) { return; } - + var emptyClass = 'editable-empty'; //emptytext shown only for enabled if(!this.options.disabled) { @@ -3242,18 +3256,18 @@ Makes editable any HTML element on the page. Applied as jQuery method. this.$element.removeClass(emptyClass); } } - }, - + }, + /** Shows container with form @method show() @param {boolean} closeAll Whether to close all other editable containers when showing this one. Default true. - **/ + **/ show: function (closeAll) { if(this.options.disabled) { return; } - + //init editableContainer: popover, tooltip, inline, etc.. if(!this.container) { var containerOptions = $.extend({}, this.options, { @@ -3261,30 +3275,30 @@ Makes editable any HTML element on the page. Applied as jQuery method. }); this.$element.editableContainer(containerOptions); this.$element.on("save.internal", $.proxy(this.save, this)); - this.container = this.$element.data('editableContainer'); + this.container = this.$element.data('editableContainer'); } else if(this.container.tip().is(':visible')) { return; - } - + } + //show container this.container.show(closeAll); }, - + /** Hides container with form @method hide() - **/ - hide: function () { - if(this.container) { + **/ + hide: function () { + if(this.container) { this.container.hide(); } }, - + /** Toggles container visibility (show / hide) @method toggle() @param {boolean} closeAll Whether to close all other editable containers when showing this one. Default true. - **/ + **/ toggle: function(closeAll) { if(this.container && this.container.tip().is(':visible')) { this.hide(); @@ -3292,25 +3306,25 @@ Makes editable any HTML element on the page. Applied as jQuery method. this.show(closeAll); } }, - + /* * called when form was submitted - */ + */ save: function(e, params) { - //if url is not user's function and value was not sent to server and value changed --> mark element with unsaved css. - if(typeof this.options.url !== 'function' && this.options.display !== false && params.response === undefined && this.input.value2str(this.value) !== this.input.value2str(params.newValue)) { + //if url is not user's function and value was not sent to server and value changed --> mark element with unsaved css. + if(typeof this.options.url !== 'function' && this.options.display !== false && params.response === undefined && this.input.value2str(this.value) !== this.input.value2str(params.newValue)) { this.$element.addClass('editable-unsaved'); } else { this.$element.removeClass('editable-unsaved'); } - + // this.hide(); this.setValue(params.newValue); - - /** + + /** Fired when new value was submitted. You can use $(this).data('editable') to access to editable instance - - @event save + + @event save @param {Object} event event object @param {Object} params additional params @param {mixed} params.newValue submitted value @@ -3322,11 +3336,11 @@ Makes editable any HTML element on the page. Applied as jQuery method. if(params.response && params.response.success) { alert('value: ' + params.newValue + ' with pk: ' + pk + ' saved!'); } else { - alert('error!'); - } + alert('error!'); + } }); **/ - //event itself is triggered by editableContainer. Description here is only for documentation + //event itself is triggered by editableContainer. Description here is only for documentation }, validate: function () { @@ -3334,13 +3348,13 @@ Makes editable any HTML element on the page. Applied as jQuery method. return this.options.validate.call(this, this.value); } }, - + /** Sets new value of editable @method setValue(value, convertStr) - @param {mixed} value new value + @param {mixed} value new value @param {boolean} convertStr whether to convert value from string to internal format - **/ + **/ setValue: function(value, convertStr) { if(convertStr) { this.value = this.input.str2value(value); @@ -3355,14 +3369,14 @@ Makes editable any HTML element on the page. Applied as jQuery method. this.handleEmpty(); }, this)); }, - + /** Activates input of visible container (e.g. set focus) @method activate() - **/ + **/ activate: function() { if(this.container) { - this.container.activate(); + this.container.activate(); } } }; @@ -3372,7 +3386,7 @@ Makes editable any HTML element on the page. Applied as jQuery method. /** jQuery method to initialize editable element. - + @method $().editable(options) @params {Object} options @example @@ -3381,14 +3395,14 @@ Makes editable any HTML element on the page. Applied as jQuery method. url: '/post', pk: 1 }); - **/ + **/ $.fn.editable = function (option) { //special API methods returning non-jquery object var result = {}, args = arguments, datakey = 'editable'; switch (option) { /** Runs client-side validation for all matched editables - + @method validate() @returns {Object} validation errors map @example @@ -3398,7 +3412,7 @@ Makes editable any HTML element on the page. Applied as jQuery method. username: "username is required", fullname: "fullname should be minimum 3 letters length" } - **/ + **/ case 'validate': this.each(function () { var $this = $(this), data = $this.data(datakey), error; @@ -3419,7 +3433,7 @@ Makes editable any HTML element on the page. Applied as jQuery method. username: "superuser", fullname: "John" } - **/ + **/ case 'getValue': this.each(function () { var $this = $(this), data = $this.data(datakey); @@ -3429,20 +3443,20 @@ Makes editable any HTML element on the page. Applied as jQuery method. }); return result; - /** - This method collects values from several editable elements and submit them all to server. - Internally it runs client-side validation for all fields and submits only in case of success. + /** + This method collects values from several editable elements and submit them all to server. + Internally it runs client-side validation for all fields and submits only in case of success. See creating new records for details. - + @method submit(options) - @param {object} options - @param {object} options.url url to submit data + @param {object} options + @param {object} options.url url to submit data @param {object} options.data additional data to submit - @param {object} options.ajaxOptions additional ajax options - @param {function} options.error(obj) error handler + @param {object} options.ajaxOptions additional ajax options + @param {function} options.error(obj) error handler @param {function} options.success(obj,config) success handler @returns {Object} jQuery object - **/ + **/ case 'submit': //collects value, validate and submit to server for creating new record var config = arguments[1] || {}, $elems = this, @@ -3450,21 +3464,21 @@ Makes editable any HTML element on the page. Applied as jQuery method. values; if($.isEmptyObject(errors)) { - values = this.editable('getValue'); + values = this.editable('getValue'); if(config.data) { $.extend(values, config.data); - } - + } + $.ajax($.extend({ - url: config.url, - data: values, - type: 'POST' + url: config.url, + data: values, + type: 'POST' }, config.ajaxOptions)) .success(function(response) { //successful response 200 OK if(typeof config.success === 'function') { config.success.call($elems, response, config); - } + } }) .error(function(){ //ajax error if(typeof config.error === 'function') { @@ -3481,90 +3495,90 @@ Makes editable any HTML element on the page. Applied as jQuery method. //return jquery object return this.each(function () { - var $this = $(this), - data = $this.data(datakey), + var $this = $(this), + data = $this.data(datakey), options = typeof option === 'object' && option; if (!data) { $this.data(datakey, (data = new Editable(this, options))); } - if (typeof option === 'string') { //call method + if (typeof option === 'string') { //call method data[option].apply(data, Array.prototype.slice.call(args, 1)); - } + } }); - }; - + }; + $.fn.editable.defaults = { /** Type of input. Can be text|textarea|select|date|checklist and more - @property type + @property type @type string @default 'text' **/ - type: 'text', + type: 'text', /** Sets disabled state of editable - @property disabled + @property disabled @type boolean @default false - **/ + **/ disabled: false, /** - How to toggle editable. Can be click|dblclick|mouseenter|manual. - When set to manual you should manually call show/hide methods of editable. - **Note**: if you call show or toggle inside **click** handler of some DOM element, + How to toggle editable. Can be click|dblclick|mouseenter|manual. + When set to manual you should manually call show/hide methods of editable. + **Note**: if you call show or toggle inside **click** handler of some DOM element, you need to apply e.stopPropagation() because containers are being closed on any click on document. - + @example $('#edit-button').click(function(e) { e.stopPropagation(); $('#username').editable('toggle'); }); - @property toggle + @property toggle @type string @default 'click' - **/ + **/ toggle: 'click', /** Text shown when element is empty. - @property emptytext + @property emptytext @type string @default 'Empty' - **/ + **/ emptytext: 'Empty', /** Allows to automatically set element's text based on it's value. Can be auto|always|never. Useful for select and date. - For example, if dropdown list is {1: 'a', 2: 'b'} and element's value set to 1, it's html will be automatically set to 'a'. - auto - text will be automatically set only if element is empty. + For example, if dropdown list is {1: 'a', 2: 'b'} and element's value set to 1, it's html will be automatically set to 'a'. + auto - text will be automatically set only if element is empty. always|never - always(never) try to set element's text. - @property autotext + @property autotext @type string @default 'auto' - **/ - autotext: 'auto', + **/ + autotext: 'auto', /** Initial value of input. Taken from data-value or element's text. - @property value + @property value @type mixed @default element's text **/ value: null, /** - Callback to perform custom displaying of value in element's text. - If null, default input's value2html() will be called. - If false, no displaying methods will be called, element's text will no change. - Runs under element's scope. + Callback to perform custom displaying of value in element's text. + If null, default input's value2html() will be called. + If false, no displaying methods will be called, element's text will no change. + Runs under element's scope. Second parameter __sourceData__ is passed for inputs with source (select, checklist). - - @property display + + @property display @type function|boolean @default null @since 1.2.0 @@ -3573,10 +3587,10 @@ Makes editable any HTML element on the page. Applied as jQuery method. var escapedValue = $('
').text(value).html(); $(this).html(''+escapedValue+''); } - **/ + **/ display: null }; - + }(window.jQuery)); /** @@ -3590,177 +3604,177 @@ To create your own input you can inherit from this class. //types $.fn.editabletypes = {}; - + var AbstractInput = function () { }; AbstractInput.prototype = { /** Initializes input - - @method init() + + @method init() **/ init: function(type, options, defaults) { this.type = type; - this.options = $.extend({}, defaults, options); + this.options = $.extend({}, defaults, options); this.$input = null; this.$clear = null; this.error = null; }, - + /** Renders input from tpl. Can return jQuery deferred object. - - @method render() - **/ + + @method render() + **/ render: function() { this.$input = $(this.options.tpl); if(this.options.inputclass) { - this.$input.addClass(this.options.inputclass); + this.$input.addClass(this.options.inputclass); } - + if (this.options.placeholder) { this.$input.attr('placeholder', this.options.placeholder); - } - }, + } + }, /** - Sets element's html by value. - - @method value2html(value, element) + Sets element's html by value. + + @method value2html(value, element) @param {mixed} value @param {DOMElement} element - **/ + **/ value2html: function(value, element) { $(element).text(value); }, - + /** Converts element's html to value - - @method html2value(html) + + @method html2value(html) @param {string} html @returns {mixed} - **/ + **/ html2value: function(html) { return $('
').html(html).text(); }, - + /** Converts value to string (for internal compare). For submitting to server used value2submit(). - - @method value2str(value) + + @method value2str(value) @param {mixed} value @returns {string} - **/ + **/ value2str: function(value) { return value; - }, - + }, + /** Converts string received from server into value. - - @method str2value(str) + + @method str2value(str) @param {string} str @returns {mixed} - **/ + **/ str2value: function(str) { return str; - }, - + }, + /** Converts value for submitting to server - - @method value2submit(value) + + @method value2submit(value) @param {mixed} value @returns {mixed} - **/ + **/ value2submit: function(value) { return value; - }, - + }, + /** Sets value of input. - - @method value2input(value) + + @method value2input(value) @param {mixed} value - **/ + **/ value2input: function(value) { this.$input.val(value); }, - + /** Returns value of input. Value can be object (e.g. datepicker) - - @method input2value() - **/ - input2value: function() { + + @method input2value() + **/ + input2value: function() { return this.$input.val(); - }, + }, /** Activates input. For text it sets focus. - - @method activate() - **/ + + @method activate() + **/ activate: function() { if(this.$input.is(':visible')) { this.$input.focus(); } }, - + /** Creates input. - - @method clear() - **/ + + @method clear() + **/ clear: function() { this.$input.val(null); }, - + /** method to escape html. **/ escape: function(str) { return $('
').text(str).html(); }, - + /** attach handler to automatically submit form when value changed (useful when buttons not shown) - **/ + **/ autosubmit: function() { - + } }; - - AbstractInput.defaults = { + + AbstractInput.defaults = { /** HTML template of input. Normally you should not change it. - @property tpl + @property tpl @type string @default '' - **/ + **/ tpl: '', /** CSS class automatically applied to input - - @property inputclass + + @property inputclass @type string @default input-medium - **/ + **/ inputclass: 'input-medium', /** Name attribute of input - @property name + @property name @type string @default null - **/ + **/ name: null }; - + $.extend($.fn.editabletypes, {abstractinput: AbstractInput}); - + }(window.jQuery)); /** @@ -3772,7 +3786,7 @@ List - abstract class for inputs that have source option loaded from js array or (function ($) { var List = function (options) { - + }; $.fn.editableutils.inherit(List, $.fn.editabletypes.abstractinput); @@ -3798,13 +3812,13 @@ List - abstract class for inputs that have source option loaded from js array or html2value: function (html) { return null; //can't set value by text }, - + value2html: function (value, element, display) { var deferred = $.Deferred(); this.onSourceReady(function () { if(typeof display === 'function') { //custom display method - display.call(element, value, this.sourceData); + display.call(element, value, this.sourceData); } else { this.value2htmlFinal(value, element); } @@ -3815,7 +3829,7 @@ List - abstract class for inputs that have source option loaded from js array or }); return deferred.promise(); - }, + }, // ------------- additional functions ------------ @@ -3823,7 +3837,7 @@ List - abstract class for inputs that have source option loaded from js array or //if allready loaded just call success if($.isArray(this.sourceData)) { success.call(this); - return; + return; } // try parse json in single quotes (for double quotes jquery does automatically) @@ -3866,7 +3880,7 @@ List - abstract class for inputs that have source option loaded from js array or cache.err_callbacks = []; } } - + //loading sourceData from server $.ajax({ url: this.options.source, @@ -3899,7 +3913,7 @@ List - abstract class for inputs that have source option loaded from js array or if(cache) { cache.loading = false; //run error callbacks for other fields - $.each(cache.err_callbacks, function () { this.call(); }); + $.each(cache.err_callbacks, function () { this.call(); }); } }, this) }); @@ -3907,7 +3921,7 @@ List - abstract class for inputs that have source option loaded from js array or this.sourceData = this.makeArray(this.options.source); if($.isArray(this.sourceData)) { this.doPrepend(); - success.call(this); + success.call(this); } else { error.call(this); } @@ -3916,15 +3930,15 @@ List - abstract class for inputs that have source option loaded from js array or doPrepend: function () { if(this.options.prepend === null || this.options.prepend === undefined) { - return; + return; } - + if(!$.isArray(this.prependData)) { //try parse json in single quotes this.options.prepend = $.fn.editableutils.tryParseJson(this.options.prepend, true); if (typeof this.options.prepend === 'string') { this.options.prepend = {'': this.options.prepend}; - } + } this.prependData = this.makeArray(this.options.prepend); } @@ -3939,13 +3953,13 @@ List - abstract class for inputs that have source option loaded from js array or renderList: function() { // this method should be overwritten in child class }, - + /* set element's html by value */ value2htmlFinal: function(value, element) { // this method should be overwritten in child class - }, + }, /** * convert data to array suitable for sourceData, e.g. [{value: 1, text: 'abc'}, {...}] @@ -3953,7 +3967,7 @@ List - abstract class for inputs that have source option loaded from js array or makeArray: function(data) { var count, obj, result = [], iterateEl; if(!data || typeof data === 'string') { - return null; + return null; } if($.isArray(data)) { //array @@ -3963,86 +3977,86 @@ List - abstract class for inputs that have source option loaded from js array or return false;// exit each if object has more than one value } }; - + for(var i = 0; i < data.length; i++) { if(typeof data[i] === 'object') { count = 0; $.each(data[i], iterateEl); if(count === 1) { - result.push(obj); + result.push(obj); } else if(count > 1 && data[i].hasOwnProperty('value') && data[i].hasOwnProperty('text')) { result.push(data[i]); } else { //data contains incorrect objects } } else { - result.push({value: data[i], text: data[i]}); + result.push({value: data[i], text: data[i]}); } } } else { //object $.each(data, function (k, v) { result.push({value: k, text: v}); - }); + }); } return result; }, - + //search for item by particular value itemByVal: function(val) { if($.isArray(this.sourceData)) { for(var i=0; i[{value: 1, text: "text"}, {...}]
- For compability it also supports format {value1: "text1", value2: "text2" ...} but it does not guarantee elements order. + For compability it also supports format {value1: "text1", value2: "text2" ...} but it does not guarantee elements order. If source is **string**, results will be cached for fields with the same source and name. See also sourceCache option. - - @property source + + @property source @type string|array|object @default null - **/ - source:null, + **/ + source:null, /** Data automatically prepended to the beginning of dropdown list. - - @property prepend + + @property prepend @type string|array|object @default false - **/ + **/ prepend:false, /** Error message when list cannot be loaded (e.g. ajax error) - - @property sourceError + + @property sourceError @type string @default Error when loading list - **/ + **/ sourceError: 'Error when loading list', /** - if true and source is **string url** - results will be cached for fields with the same source and name. + if true and source is **string url** - results will be cached for fields with the same source and name. Usefull for editable grids. - - @property sourceCache + + @property sourceCache @type boolean @default true @since 1.2.0 - **/ + **/ sourceCache: true }); - $.fn.editabletypes.list = List; + $.fn.editabletypes.list = List; }(window.jQuery)); /** @@ -4075,22 +4089,22 @@ $(function(){ this.$input.focus(); $.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length); } - } + } }); Text.defaults = $.extend({}, $.fn.editabletypes.abstractinput.defaults, { /** - @property tpl + @property tpl @default - **/ + **/ tpl: '', /** Placeholder attribute of input. Shown when input is empty. - @property placeholder + @property placeholder @type string @default null - **/ + **/ placeholder: null }); @@ -4155,39 +4169,39 @@ $(function(){ for (var i = 0; i < lines.length; i++) { lines[i] = $('
').html(lines[i]).text(); } - return lines.join("\n"); - }, + return lines.join("\n"); + }, activate: function() { if(this.$input.is(':visible')) { $.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length); this.$input.focus(); } - } + } }); Textarea.defaults = $.extend({}, $.fn.editabletypes.abstractinput.defaults, { /** - @property tpl + @property tpl @default - **/ + **/ tpl:'', /** - @property inputclass + @property inputclass @default input-large - **/ + **/ inputclass: 'input-large', /** Placeholder attribute of input. Shown when input is empty. - @property placeholder + @property placeholder @type string @default null - **/ - placeholder: null + **/ + placeholder: null }); - $.fn.editabletypes.textarea = Textarea; + $.fn.editabletypes.textarea = Textarea; }(window.jQuery)); @@ -4202,7 +4216,7 @@ Select (dropdown)