dev build 1.4.6
This commit is contained in:
dist
123
dist/jqueryui-editable/js/jqueryui-editable.js
vendored
123
dist/jqueryui-editable/js/jqueryui-editable.js
vendored
@ -107,7 +107,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
this.error(false);
|
||||
this.input.$input.removeAttr('disabled');
|
||||
this.$form.find('.editable-submit').removeAttr('disabled');
|
||||
this.input.value2input(this.value);
|
||||
var value = (this.value === null || this.value === undefined || this.value === '') ? this.options.defaultValue : this.value;
|
||||
this.input.value2input(value);
|
||||
//attach submit handler
|
||||
this.$form.submit($.proxy(this.submit, this));
|
||||
}
|
||||
@ -482,8 +483,17 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
**/
|
||||
value: null,
|
||||
/**
|
||||
Strategy for sending data on server. Can be <code>auto|always|never</code>.
|
||||
When 'auto' data will be sent on server only if pk defined, otherwise new value will be stored in element.
|
||||
Value that will be displayed in input if original field value is empty (`null|undefined|''`).
|
||||
|
||||
@property defaultValue
|
||||
@type string|object
|
||||
@default null
|
||||
@since 1.4.6
|
||||
**/
|
||||
defaultValue: null,
|
||||
/**
|
||||
Strategy for sending data on server. Can be `auto|always|never`.
|
||||
When 'auto' data will be sent on server **only if pk and url defined**, otherwise new value will be stored locally.
|
||||
|
||||
@property send
|
||||
@type string
|
||||
@ -772,7 +782,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
result.push(o);
|
||||
}
|
||||
} else {
|
||||
if(value == (o && typeof o === 'object' ? valueProp(o) : o)) {
|
||||
var itemValue = (o && (typeof o === 'object')) ? valueProp(o) : o;
|
||||
if(value == itemValue) {
|
||||
result.push(o);
|
||||
}
|
||||
}
|
||||
@ -1483,6 +1494,11 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
//add 'editable' class to every editable element
|
||||
this.$element.addClass('editable');
|
||||
|
||||
//specifically for "textarea" add class .editable-pre-wrapped to keep linebreaks
|
||||
if(this.input.type === 'textarea') {
|
||||
this.$element.addClass('editable-pre-wrapped');
|
||||
}
|
||||
|
||||
//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');
|
||||
@ -2038,6 +2054,14 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
data = $this.data(datakey),
|
||||
options = typeof option === 'object' && option;
|
||||
|
||||
//for delegated targets do not store `editable` object for element
|
||||
//it's allows several different selectors.
|
||||
//see: https://github.com/vitalets/x-editable/issues/312
|
||||
if(options && options.selector) {
|
||||
data = new Editable(this, options);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
$this.data(datakey, (data = new Editable(this, options)));
|
||||
}
|
||||
@ -2925,8 +2949,10 @@ $(function(){
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
value2html: function(value, element) {
|
||||
|
||||
//using `white-space: pre-wrap` solves \n <--> BR conversion very elegant!
|
||||
/*
|
||||
value2html: function(value, element) {
|
||||
var html = '', lines;
|
||||
if(value) {
|
||||
lines = value.split("\n");
|
||||
@ -2937,7 +2963,7 @@ $(function(){
|
||||
}
|
||||
$(element).html(html);
|
||||
},
|
||||
|
||||
|
||||
html2value: function(html) {
|
||||
if(!html) {
|
||||
return '';
|
||||
@ -2956,7 +2982,7 @@ $(function(){
|
||||
}
|
||||
return lines.join("\n");
|
||||
},
|
||||
|
||||
*/
|
||||
activate: function() {
|
||||
$.fn.editabletypes.text.prototype.activate.call(this);
|
||||
}
|
||||
@ -3254,6 +3280,7 @@ Following types are supported:
|
||||
* tel
|
||||
* number
|
||||
* range
|
||||
* time
|
||||
|
||||
Learn more about html5 inputs:
|
||||
http://www.w3.org/wiki/HTML5_form_additions
|
||||
@ -3438,7 +3465,30 @@ Range (inherit from number)
|
||||
inputclass: 'input-medium'
|
||||
});
|
||||
$.fn.editabletypes.range = Range;
|
||||
}(window.jQuery));
|
||||
}(window.jQuery));
|
||||
|
||||
/*
|
||||
Time
|
||||
*/
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
var Time = function (options) {
|
||||
this.init('time', options, Time.defaults);
|
||||
};
|
||||
//inherit from abstract, as inheritance from text gives selection error.
|
||||
$.fn.editableutils.inherit(Time, $.fn.editabletypes.abstractinput);
|
||||
$.extend(Time.prototype, {
|
||||
render: function() {
|
||||
this.setClass();
|
||||
}
|
||||
});
|
||||
Time.defaults = $.extend({}, $.fn.editabletypes.abstractinput.defaults, {
|
||||
tpl: '<input type="time">'
|
||||
});
|
||||
$.fn.editabletypes.time = Time;
|
||||
}(window.jQuery));
|
||||
|
||||
/**
|
||||
Select2 input. Based on amazing work of Igor Vaynberg https://github.com/ivaynberg/select2.
|
||||
Please see [original select2 docs](http://ivaynberg.github.com/select2) for detailed description and options.
|
||||
@ -3466,6 +3516,7 @@ You need initially put both `data-value` and element's text youself:
|
||||
<a href="#" id="country" data-type="select2" data-pk="1" data-value="ru" data-url="/post" data-title="Select country"></a>
|
||||
<script>
|
||||
$(function(){
|
||||
//local source
|
||||
$('#country').editable({
|
||||
source: [
|
||||
{id: 'gb', text: 'Great Britain'},
|
||||
@ -3476,6 +3527,42 @@ $(function(){
|
||||
multiple: true
|
||||
}
|
||||
});
|
||||
//remote source (simple)
|
||||
$('#country').editable({
|
||||
source: '/getCountries'
|
||||
});
|
||||
//remote source (advanced)
|
||||
$('#country').editable({
|
||||
select2: {
|
||||
placeholder: 'Select Country',
|
||||
allowClear: true,
|
||||
minimumInputLength: 3,
|
||||
id: function (item) {
|
||||
return item.CountryId;
|
||||
},
|
||||
ajax: {
|
||||
url: '/getCountries',
|
||||
dataType: 'json',
|
||||
data: function (term, page) {
|
||||
return { query: term };
|
||||
},
|
||||
results: function (data, page) {
|
||||
return { results: data };
|
||||
}
|
||||
},
|
||||
formatResult: function (item) {
|
||||
return item.CountryName;
|
||||
},
|
||||
formatSelection: function (item) {
|
||||
return item.CountryName;
|
||||
},
|
||||
initSelection: function (element, callback) {
|
||||
return $.get('/getCountryById', { query: element.val() }, function (data) {
|
||||
callback(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
**/
|
||||
@ -3572,6 +3659,7 @@ $(function(){
|
||||
|
||||
if(this.options.select2.tags) { //in tags mode just assign value
|
||||
data = value;
|
||||
//data = $.fn.editableutils.itemsByValue(value, this.options.select2.tags, this.idFunc);
|
||||
} else if(this.sourceData) {
|
||||
data = $.fn.editableutils.itemsByValue(value, this.sourceData, this.idFunc);
|
||||
} else {
|
||||
@ -4417,6 +4505,12 @@ Editableform based on jQuery UI
|
||||
splitOptions: function() {
|
||||
this.containerOptions = {};
|
||||
this.formOptions = {};
|
||||
|
||||
//check that jQueryUI build contains tooltip widget
|
||||
if(!$.ui[this.containerName]) {
|
||||
$.error('Please use jQueryUI with "tooltip" widget! http://jqueryui.com/download');
|
||||
return;
|
||||
}
|
||||
//defaults for tooltip
|
||||
var cDef = $.ui[this.containerName].prototype.options;
|
||||
for(var k in this.options) {
|
||||
@ -4445,8 +4539,15 @@ Editableform based on jQuery UI
|
||||
|
||||
this.call(this.containerOptions);
|
||||
|
||||
//disable standart triggering tooltip event
|
||||
this.container()._off(this.container().element, 'mouseover focusin');
|
||||
//disable standart triggering tooltip event
|
||||
//for some versions of jQueryUI it gives error:
|
||||
//TypeError: this.container(...)._off is not a function
|
||||
//see: https://github.com/vitalets/x-editable/issues/32
|
||||
if(this.container()._off) {
|
||||
this.container()._off(this.container().element, 'mouseover focusin');
|
||||
} else {
|
||||
$.error('this.container()._off is not a function. jQuery UI: ' + $.ui.version);
|
||||
}
|
||||
},
|
||||
|
||||
tip: function() {
|
||||
|
Reference in New Issue
Block a user