Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbbd2e2b40 | ||
|
|
5e3f54c0dd | ||
|
|
b510cc86b9 | ||
|
|
dc8967d116 | ||
|
|
3e983bc6d2 | ||
|
|
fe5b56a9c2 | ||
|
|
e03afb2436 | ||
|
|
93789de24d | ||
|
|
a55709c990 | ||
|
|
9275da7cfc | ||
|
|
717d7f8594 | ||
|
|
85fa502f2c | ||
|
|
565f730945 | ||
|
|
c54078cb23 | ||
|
|
c2e64bc989 | ||
|
|
42b6d07a6b | ||
|
|
28210f5cbb | ||
|
|
6099e5176d | ||
|
|
76cdd53091 | ||
|
|
a3a5de1cde | ||
|
|
9a21e591d3 |
+1
-2
@@ -1,4 +1,3 @@
|
||||
node_modules
|
||||
test/instrumented/
|
||||
*.nupkg
|
||||
*.orig
|
||||
*.nupkg
|
||||
@@ -1,16 +1,6 @@
|
||||
X-editable changelog
|
||||
=============================
|
||||
|
||||
Version 1.5.3 Nov 9, 2015
|
||||
----------------------------
|
||||
Working through various PRs to ultimately move dev to master
|
||||
|
||||
Version 1.5.2 wip
|
||||
----------------------------
|
||||
[bug #433] typeaheadjs with showbuttons: false (vitalets)
|
||||
[bug #266] `escape` option not work for select/checklist items (vitalets)
|
||||
[bug #261] select2 disappears in IE when dropdown clicked (vitalets)
|
||||
|
||||
|
||||
Version 1.5.1 Nov 4, 2013
|
||||
----------------------------
|
||||
|
||||
+5
-7
@@ -2,22 +2,20 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>x-editable</id>
|
||||
<version>1.5.3</version>
|
||||
<version>1.5.1</version>
|
||||
<authors>Vitaliy Potapov</authors>
|
||||
<owners>Vitaliy Potapov</owners>
|
||||
<licenseUrl>https://github.com/vitalets/x-editable/blob/master/LICENSE-MIT</licenseUrl>
|
||||
<projectUrl>http://github.com/vitalets/x-editable</projectUrl>
|
||||
<projectUrl>http://vitalets.github.com/x-editable</projectUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery</description>
|
||||
<releaseNotes>Date and select2 minor fixes</releaseNotes>
|
||||
<copyright>Copyright 2012-2015</copyright>
|
||||
<copyright>Copyright 2012-2013</copyright>
|
||||
<tags>edit-in-place editable click-to-edit bootstrap jquery</tags>
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="dist\*" target="\" />
|
||||
<file src="dist\**\*.js" target="content\Scripts" />
|
||||
<file src="dist\**" target="content\Content" exclude="**\*.js;**\*.txt;**\*.md;**\*-MIT" />
|
||||
<file src="dist\**" target="\" />
|
||||
</files>
|
||||
</package>
|
||||
</package>
|
||||
@@ -1,21 +1,21 @@
|
||||
# X-editable
|
||||
|
||||
In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery.
|
||||
|
||||
PLEASE SUBMIT ALL PULL REQUESTS TO THE 'dev' BRANCH!
|
||||
|
||||
## 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
|
||||
|
||||
## Issue Tracker
|
||||
Please report all issues here: https://github.com/vitalets/x-editable/issues
|
||||
|
||||
## Documentation
|
||||
**http://vitalets.github.io/x-editable**
|
||||
|
||||
## Project Status
|
||||
Actively maintained
|
||||
|
||||
## How to get it
|
||||
|
||||
### Manual download
|
||||
|
||||
+2
-15
@@ -1,18 +1,5 @@
|
||||
{
|
||||
"name": "x-editable",
|
||||
"main": [
|
||||
"./dist/bootstrap3-editable/css/bootstrap-editable.css",
|
||||
"./dist/bootstrap3-editable/js/bootstrap-editable.min.js",
|
||||
|
||||
"./dist/bootstrap-editable/css/bootstrap-editable.css",
|
||||
"./dist/bootstrap-editable/js/bootstrap-editable.min.js",
|
||||
|
||||
"./dist/jqueryui-editable/css/jqueryui-editable.css",
|
||||
"./dist/jqueryui-editable/js/jqueryui-editable.min.js",
|
||||
|
||||
"./dist/jquery-editable/css/jquery-editable.css",
|
||||
"./dist/jquery-editable/js/jquery-editable-poshytip.min.js"
|
||||
],
|
||||
"ignore": [
|
||||
"CHANGELOG.txt",
|
||||
"Gruntfile.js",
|
||||
@@ -27,6 +14,6 @@
|
||||
"test"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.6"
|
||||
}
|
||||
"jquery": "~1.11"
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vitalets/x-editable",
|
||||
"description": "In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery.",
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.1",
|
||||
"homepage": "http://github.com/vitalets/x-editable",
|
||||
"authors": [
|
||||
{
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
},
|
||||
"require-dev": {
|
||||
"grunt": "~0.4.0"
|
||||
"grunt": "~0.3.11",
|
||||
"grunt-contrib": "0.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
-10
@@ -1,16 +1,6 @@
|
||||
X-editable changelog
|
||||
=============================
|
||||
|
||||
Version 1.5.3 Nov 9, 2015
|
||||
----------------------------
|
||||
Working through various PRs to ultimately move dev to master
|
||||
|
||||
Version 1.5.2 wip
|
||||
----------------------------
|
||||
[bug #433] typeaheadjs with showbuttons: false (vitalets)
|
||||
[bug #266] `escape` option not work for select/checklist items (vitalets)
|
||||
[bug #261] select2 disappears in IE when dropdown clicked (vitalets)
|
||||
|
||||
|
||||
Version 1.5.1 Nov 4, 2013
|
||||
----------------------------
|
||||
|
||||
Vendored
+1
-7
@@ -2,12 +2,6 @@
|
||||
|
||||
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
|
||||
**http://vitalets.github.io/x-editable/demo.html**
|
||||
|
||||
@@ -127,4 +121,4 @@ Result will appear in `dist` directory.
|
||||
|
||||
## License
|
||||
Copyright (c) 2012 Vitaliy Potapov
|
||||
Licensed under the MIT license.
|
||||
Licensed under the MIT license.
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*! X-editable - v1.5.3
|
||||
/*! X-editable - v1.5.1
|
||||
* 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) 2013 Vitaliy Potapov; Licensed MIT */
|
||||
.editableform {
|
||||
margin-bottom: 0; /* overwrites bootstrap margin */
|
||||
}
|
||||
|
||||
+19
-46
@@ -1,7 +1,7 @@
|
||||
/*! X-editable - v1.5.3
|
||||
/*! X-editable - v1.5.1
|
||||
* 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) 2013 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.
|
||||
@@ -222,7 +222,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
|
||||
//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)) {
|
||||
if (!this.options.savenochange && this.input.value2str(newValue) == this.input.value2str(this.value)) {
|
||||
/*jslint eqeq: false*/
|
||||
/**
|
||||
Fired when value not changed but form is submitted. Requires savenochange = false.
|
||||
@@ -530,10 +530,9 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
/**
|
||||
Success callback. Called when value successfully sent on server and **response status = 200**.
|
||||
Usefull to work with json response. For example, if your backend response can be <code>{success: true}</code>
|
||||
or `{success: false, msg: "server error"}` you can check it inside this callback.
|
||||
or <code>{success: false, msg: "server error"}</code> 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
|
||||
(useful when server changes value).
|
||||
If it returns **object like** <code>{newValue: <something>}</code> - it overwrites value, submitted by user.
|
||||
Otherwise newValue simply rendered into element.
|
||||
|
||||
@property success
|
||||
@@ -957,23 +956,17 @@ Applied as jQuery method.
|
||||
'.bootstrap-wysihtml5-insert-image-modal',
|
||||
'.bootstrap-wysihtml5-insert-link-modal'
|
||||
];
|
||||
|
||||
// select2 has extra body click in IE
|
||||
// see: https://github.com/ivaynberg/select2/issues/1058
|
||||
if ($('.select2-drop-mask').is(':visible')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//check if element is detached. It occurs when clicking in bootstrap datepicker
|
||||
if (!$.contains(document.documentElement, e.target)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//for some reason FF 20 generates extra event (click) in select2 widget with e.target = document
|
||||
//we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199
|
||||
//Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec
|
||||
if($target.is(document)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//if click inside one of exclude classes --> no nothing
|
||||
@@ -1047,7 +1040,7 @@ Applied as jQuery method.
|
||||
.on({
|
||||
save: $.proxy(this.save, this), //click on submit button (value changed)
|
||||
nochange: $.proxy(function(){ this.hide('nochange'); }, this), //click on submit button (value NOT changed)
|
||||
cancel: $.proxy(function(){ this.hide('cancel'); }, this), //click on cancel button
|
||||
cancel: $.proxy(function(){ this.hide('cancel'); }, this), //click on calcel button
|
||||
show: $.proxy(function() {
|
||||
if(this.delayedHide) {
|
||||
this.hide(this.delayedHide.reason);
|
||||
@@ -2830,15 +2823,8 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
|
||||
If **function**, it should return data in format above (since 1.4.0).
|
||||
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only):
|
||||
@example
|
||||
[
|
||||
{text: "group1", children: [
|
||||
{value: 1, text: "text1"},
|
||||
{value: 2, text: "text2"}
|
||||
]},
|
||||
...
|
||||
]
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only).
|
||||
`[{text: "group1", children: [{value: 1, text: "text1"}, {value: 2, text: "text2"}]}, ...]`
|
||||
|
||||
|
||||
@property source
|
||||
@@ -2863,7 +2849,7 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
**/
|
||||
sourceError: 'Error when loading list',
|
||||
/**
|
||||
if `true` and source is **string url** - results will be cached for fields with the same source.
|
||||
if <code>true</code> and source is **string url** - results will be cached for fields with the same source.
|
||||
Usefull for editable column in grid to prevent extra requests.
|
||||
|
||||
@property sourceCache
|
||||
@@ -2874,18 +2860,12 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
sourceCache: true,
|
||||
/**
|
||||
Additional ajax options to be used in $.ajax() when loading list from server.
|
||||
Useful to send extra parameters or change request method.
|
||||
Useful to send extra parameters (`data` key) or change request method (`type` key).
|
||||
|
||||
@property sourceOptions
|
||||
@type object|function
|
||||
@default null
|
||||
@since 1.5.0
|
||||
@example
|
||||
sourceOptions: {
|
||||
data: {param: 123},
|
||||
type: 'post'
|
||||
}
|
||||
|
||||
**/
|
||||
sourceOptions: null
|
||||
});
|
||||
@@ -2930,9 +2910,7 @@ $(function(){
|
||||
activate: function() {
|
||||
if(this.$input.is(':visible')) {
|
||||
this.$input.focus();
|
||||
if (this.$input.is('input,textarea') && !this.$input.is('[type="checkbox"],[type="range"]')) {
|
||||
$.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
|
||||
}
|
||||
$.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
|
||||
if(this.toggleClear) {
|
||||
this.toggleClear();
|
||||
}
|
||||
@@ -3176,7 +3154,6 @@ $(function(){
|
||||
$.extend(Select.prototype, {
|
||||
renderList: function() {
|
||||
this.$input.empty();
|
||||
var escape = this.options.escape;
|
||||
|
||||
var fillItems = function($el, data) {
|
||||
var attr;
|
||||
@@ -3191,9 +3168,7 @@ $(function(){
|
||||
if(data[i].disabled) {
|
||||
attr.disabled = true;
|
||||
}
|
||||
var $option = $('<option>', attr);
|
||||
$option[escape ? 'text' : 'html'](data[i].text);
|
||||
$el.append($option);
|
||||
$el.append($('<option>', attr).text(data[i].text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3288,14 +3263,12 @@ $(function(){
|
||||
$label = $('<label>').append($('<input>', {
|
||||
type: 'checkbox',
|
||||
value: this.sourceData[i].value
|
||||
}));
|
||||
var $option = $('<span>');
|
||||
$option[this.options.escape ? 'text' : 'html'](' '+this.sourceData[i].text);
|
||||
$label.append($option);
|
||||
|
||||
}))
|
||||
.append($('<span>').text(' '+this.sourceData[i].text));
|
||||
|
||||
$('<div>').append($label).appendTo(this.$tpl);
|
||||
}
|
||||
|
||||
|
||||
this.$input = this.$tpl.find('input[type="checkbox"]');
|
||||
this.setClass();
|
||||
},
|
||||
|
||||
+5
-5
File diff suppressed because one or more lines are too long
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*! X-editable - v1.5.3
|
||||
/*! X-editable - v1.5.1
|
||||
* 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) 2013 Vitaliy Potapov; Licensed MIT */
|
||||
.editableform {
|
||||
margin-bottom: 0; /* overwrites bootstrap margin */
|
||||
}
|
||||
|
||||
+21
-48
@@ -1,7 +1,7 @@
|
||||
/*! X-editable - v1.5.3
|
||||
/*! X-editable - v1.5.1
|
||||
* 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) 2013 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.
|
||||
@@ -222,7 +222,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
|
||||
//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)) {
|
||||
if (!this.options.savenochange && this.input.value2str(newValue) == this.input.value2str(this.value)) {
|
||||
/*jslint eqeq: false*/
|
||||
/**
|
||||
Fired when value not changed but form is submitted. Requires savenochange = false.
|
||||
@@ -530,10 +530,9 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
/**
|
||||
Success callback. Called when value successfully sent on server and **response status = 200**.
|
||||
Usefull to work with json response. For example, if your backend response can be <code>{success: true}</code>
|
||||
or `{success: false, msg: "server error"}` you can check it inside this callback.
|
||||
or <code>{success: false, msg: "server error"}</code> 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
|
||||
(useful when server changes value).
|
||||
If it returns **object like** <code>{newValue: <something>}</code> - it overwrites value, submitted by user.
|
||||
Otherwise newValue simply rendered into element.
|
||||
|
||||
@property success
|
||||
@@ -957,23 +956,17 @@ Applied as jQuery method.
|
||||
'.bootstrap-wysihtml5-insert-image-modal',
|
||||
'.bootstrap-wysihtml5-insert-link-modal'
|
||||
];
|
||||
|
||||
// select2 has extra body click in IE
|
||||
// see: https://github.com/ivaynberg/select2/issues/1058
|
||||
if ($('.select2-drop-mask').is(':visible')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//check if element is detached. It occurs when clicking in bootstrap datepicker
|
||||
if (!$.contains(document.documentElement, e.target)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//for some reason FF 20 generates extra event (click) in select2 widget with e.target = document
|
||||
//we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199
|
||||
//Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec
|
||||
if($target.is(document)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//if click inside one of exclude classes --> no nothing
|
||||
@@ -1047,7 +1040,7 @@ Applied as jQuery method.
|
||||
.on({
|
||||
save: $.proxy(this.save, this), //click on submit button (value changed)
|
||||
nochange: $.proxy(function(){ this.hide('nochange'); }, this), //click on submit button (value NOT changed)
|
||||
cancel: $.proxy(function(){ this.hide('cancel'); }, this), //click on cancel button
|
||||
cancel: $.proxy(function(){ this.hide('cancel'); }, this), //click on calcel button
|
||||
show: $.proxy(function() {
|
||||
if(this.delayedHide) {
|
||||
this.hide(this.delayedHide.reason);
|
||||
@@ -2830,15 +2823,8 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
|
||||
If **function**, it should return data in format above (since 1.4.0).
|
||||
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only):
|
||||
@example
|
||||
[
|
||||
{text: "group1", children: [
|
||||
{value: 1, text: "text1"},
|
||||
{value: 2, text: "text2"}
|
||||
]},
|
||||
...
|
||||
]
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only).
|
||||
`[{text: "group1", children: [{value: 1, text: "text1"}, {value: 2, text: "text2"}]}, ...]`
|
||||
|
||||
|
||||
@property source
|
||||
@@ -2863,7 +2849,7 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
**/
|
||||
sourceError: 'Error when loading list',
|
||||
/**
|
||||
if `true` and source is **string url** - results will be cached for fields with the same source.
|
||||
if <code>true</code> and source is **string url** - results will be cached for fields with the same source.
|
||||
Usefull for editable column in grid to prevent extra requests.
|
||||
|
||||
@property sourceCache
|
||||
@@ -2874,18 +2860,12 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
sourceCache: true,
|
||||
/**
|
||||
Additional ajax options to be used in $.ajax() when loading list from server.
|
||||
Useful to send extra parameters or change request method.
|
||||
Useful to send extra parameters (`data` key) or change request method (`type` key).
|
||||
|
||||
@property sourceOptions
|
||||
@type object|function
|
||||
@default null
|
||||
@since 1.5.0
|
||||
@example
|
||||
sourceOptions: {
|
||||
data: {param: 123},
|
||||
type: 'post'
|
||||
}
|
||||
|
||||
**/
|
||||
sourceOptions: null
|
||||
});
|
||||
@@ -2930,9 +2910,7 @@ $(function(){
|
||||
activate: function() {
|
||||
if(this.$input.is(':visible')) {
|
||||
this.$input.focus();
|
||||
if (this.$input.is('input,textarea') && !this.$input.is('[type="checkbox"],[type="range"]')) {
|
||||
$.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
|
||||
}
|
||||
$.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
|
||||
if(this.toggleClear) {
|
||||
this.toggleClear();
|
||||
}
|
||||
@@ -3176,7 +3154,6 @@ $(function(){
|
||||
$.extend(Select.prototype, {
|
||||
renderList: function() {
|
||||
this.$input.empty();
|
||||
var escape = this.options.escape;
|
||||
|
||||
var fillItems = function($el, data) {
|
||||
var attr;
|
||||
@@ -3191,9 +3168,7 @@ $(function(){
|
||||
if(data[i].disabled) {
|
||||
attr.disabled = true;
|
||||
}
|
||||
var $option = $('<option>', attr);
|
||||
$option[escape ? 'text' : 'html'](data[i].text);
|
||||
$el.append($option);
|
||||
$el.append($('<option>', attr).text(data[i].text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3288,14 +3263,12 @@ $(function(){
|
||||
$label = $('<label>').append($('<input>', {
|
||||
type: 'checkbox',
|
||||
value: this.sourceData[i].value
|
||||
}));
|
||||
var $option = $('<span>');
|
||||
$option[this.options.escape ? 'text' : 'html'](' '+this.sourceData[i].text);
|
||||
$label.append($option);
|
||||
|
||||
}))
|
||||
.append($('<span>').text(' '+this.sourceData[i].text));
|
||||
|
||||
$('<div>').append($label).appendTo(this.$tpl);
|
||||
}
|
||||
|
||||
|
||||
this.$input = this.$tpl.find('input[type="checkbox"]');
|
||||
this.setClass();
|
||||
},
|
||||
@@ -4445,7 +4418,7 @@ $(function(){
|
||||
//initial value, can be `new Date()`
|
||||
value: null,
|
||||
minYear: 1970,
|
||||
maxYear: 2015,
|
||||
maxYear: new Date().getFullYear(),
|
||||
yearDescending: true,
|
||||
minuteStep: 5,
|
||||
secondStep: 1,
|
||||
@@ -6831,4 +6804,4 @@ Automatically shown in inline mode.
|
||||
|
||||
$.fn.editabletypes.datetimefield = DateTimeField;
|
||||
|
||||
}(window.jQuery));
|
||||
}(window.jQuery));
|
||||
|
||||
+5
-5
File diff suppressed because one or more lines are too long
+1
-21
@@ -42,22 +42,6 @@ $(function(){
|
||||
this.renderClear();
|
||||
this.setClass();
|
||||
this.setAttr('placeholder');
|
||||
|
||||
// need to set kewdown handler before apply typeahead
|
||||
// for correct autosubmit
|
||||
this.isAutosubmit = false;
|
||||
var that = this;
|
||||
this.$input.on('keydown', function (e) {
|
||||
if (!that.isAutosubmit) {
|
||||
return;
|
||||
}
|
||||
var $dropdown = that.$input.closest('.editable-input').find('.tt-dropdown-menu');
|
||||
if (!$dropdown.is(':visible') && e.which === 13) {
|
||||
that.$input.closest('form').submit();
|
||||
}
|
||||
});
|
||||
|
||||
// apply typeaheadjs
|
||||
this.$input.typeahead(this.options.typeahead);
|
||||
|
||||
// copy `input-sm | input-lg` classes to placeholder input
|
||||
@@ -69,11 +53,7 @@ $(function(){
|
||||
this.$input.siblings('input.tt-hint').addClass('input-lg');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
autosubmit: function() {
|
||||
this.isAutosubmit = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Constructor.defaults = $.extend({}, $.fn.editabletypes.list.defaults, {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*! X-editable - v1.5.3
|
||||
/*! X-editable - v1.5.1
|
||||
* 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) 2013 Vitaliy Potapov; Licensed MIT */
|
||||
.editableform {
|
||||
margin-bottom: 0; /* overwrites bootstrap margin */
|
||||
}
|
||||
|
||||
+19
-46
@@ -1,7 +1,7 @@
|
||||
/*! X-editable - v1.5.3
|
||||
/*! X-editable - v1.5.1
|
||||
* 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) 2013 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.
|
||||
@@ -222,7 +222,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
|
||||
//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)) {
|
||||
if (!this.options.savenochange && this.input.value2str(newValue) == this.input.value2str(this.value)) {
|
||||
/*jslint eqeq: false*/
|
||||
/**
|
||||
Fired when value not changed but form is submitted. Requires savenochange = false.
|
||||
@@ -530,10 +530,9 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
/**
|
||||
Success callback. Called when value successfully sent on server and **response status = 200**.
|
||||
Usefull to work with json response. For example, if your backend response can be <code>{success: true}</code>
|
||||
or `{success: false, msg: "server error"}` you can check it inside this callback.
|
||||
or <code>{success: false, msg: "server error"}</code> 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
|
||||
(useful when server changes value).
|
||||
If it returns **object like** <code>{newValue: <something>}</code> - it overwrites value, submitted by user.
|
||||
Otherwise newValue simply rendered into element.
|
||||
|
||||
@property success
|
||||
@@ -957,23 +956,17 @@ Applied as jQuery method.
|
||||
'.bootstrap-wysihtml5-insert-image-modal',
|
||||
'.bootstrap-wysihtml5-insert-link-modal'
|
||||
];
|
||||
|
||||
// select2 has extra body click in IE
|
||||
// see: https://github.com/ivaynberg/select2/issues/1058
|
||||
if ($('.select2-drop-mask').is(':visible')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//check if element is detached. It occurs when clicking in bootstrap datepicker
|
||||
if (!$.contains(document.documentElement, e.target)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//for some reason FF 20 generates extra event (click) in select2 widget with e.target = document
|
||||
//we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199
|
||||
//Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec
|
||||
if($target.is(document)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//if click inside one of exclude classes --> no nothing
|
||||
@@ -1047,7 +1040,7 @@ Applied as jQuery method.
|
||||
.on({
|
||||
save: $.proxy(this.save, this), //click on submit button (value changed)
|
||||
nochange: $.proxy(function(){ this.hide('nochange'); }, this), //click on submit button (value NOT changed)
|
||||
cancel: $.proxy(function(){ this.hide('cancel'); }, this), //click on cancel button
|
||||
cancel: $.proxy(function(){ this.hide('cancel'); }, this), //click on calcel button
|
||||
show: $.proxy(function() {
|
||||
if(this.delayedHide) {
|
||||
this.hide(this.delayedHide.reason);
|
||||
@@ -2830,15 +2823,8 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
|
||||
If **function**, it should return data in format above (since 1.4.0).
|
||||
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only):
|
||||
@example
|
||||
[
|
||||
{text: "group1", children: [
|
||||
{value: 1, text: "text1"},
|
||||
{value: 2, text: "text2"}
|
||||
]},
|
||||
...
|
||||
]
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only).
|
||||
`[{text: "group1", children: [{value: 1, text: "text1"}, {value: 2, text: "text2"}]}, ...]`
|
||||
|
||||
|
||||
@property source
|
||||
@@ -2863,7 +2849,7 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
**/
|
||||
sourceError: 'Error when loading list',
|
||||
/**
|
||||
if `true` and source is **string url** - results will be cached for fields with the same source.
|
||||
if <code>true</code> and source is **string url** - results will be cached for fields with the same source.
|
||||
Usefull for editable column in grid to prevent extra requests.
|
||||
|
||||
@property sourceCache
|
||||
@@ -2874,18 +2860,12 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
sourceCache: true,
|
||||
/**
|
||||
Additional ajax options to be used in $.ajax() when loading list from server.
|
||||
Useful to send extra parameters or change request method.
|
||||
Useful to send extra parameters (`data` key) or change request method (`type` key).
|
||||
|
||||
@property sourceOptions
|
||||
@type object|function
|
||||
@default null
|
||||
@since 1.5.0
|
||||
@example
|
||||
sourceOptions: {
|
||||
data: {param: 123},
|
||||
type: 'post'
|
||||
}
|
||||
|
||||
**/
|
||||
sourceOptions: null
|
||||
});
|
||||
@@ -2930,9 +2910,7 @@ $(function(){
|
||||
activate: function() {
|
||||
if(this.$input.is(':visible')) {
|
||||
this.$input.focus();
|
||||
if (this.$input.is('input,textarea') && !this.$input.is('[type="checkbox"],[type="range"]')) {
|
||||
$.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
|
||||
}
|
||||
$.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
|
||||
if(this.toggleClear) {
|
||||
this.toggleClear();
|
||||
}
|
||||
@@ -3176,7 +3154,6 @@ $(function(){
|
||||
$.extend(Select.prototype, {
|
||||
renderList: function() {
|
||||
this.$input.empty();
|
||||
var escape = this.options.escape;
|
||||
|
||||
var fillItems = function($el, data) {
|
||||
var attr;
|
||||
@@ -3191,9 +3168,7 @@ $(function(){
|
||||
if(data[i].disabled) {
|
||||
attr.disabled = true;
|
||||
}
|
||||
var $option = $('<option>', attr);
|
||||
$option[escape ? 'text' : 'html'](data[i].text);
|
||||
$el.append($option);
|
||||
$el.append($('<option>', attr).text(data[i].text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3288,14 +3263,12 @@ $(function(){
|
||||
$label = $('<label>').append($('<input>', {
|
||||
type: 'checkbox',
|
||||
value: this.sourceData[i].value
|
||||
}));
|
||||
var $option = $('<span>');
|
||||
$option[this.options.escape ? 'text' : 'html'](' '+this.sourceData[i].text);
|
||||
$label.append($option);
|
||||
|
||||
}))
|
||||
.append($('<span>').text(' '+this.sourceData[i].text));
|
||||
|
||||
$('<div>').append($label).appendTo(this.$tpl);
|
||||
}
|
||||
|
||||
|
||||
this.$input = this.$tpl.find('input[type="checkbox"]');
|
||||
this.setClass();
|
||||
},
|
||||
|
||||
+4
-4
File diff suppressed because one or more lines are too long
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*! X-editable - v1.5.3
|
||||
/*! X-editable - v1.5.1
|
||||
* 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) 2013 Vitaliy Potapov; Licensed MIT */
|
||||
.editableform {
|
||||
margin-bottom: 0; /* overwrites bootstrap margin */
|
||||
}
|
||||
|
||||
+19
-46
@@ -1,7 +1,7 @@
|
||||
/*! X-editable - v1.5.3
|
||||
/*! X-editable - v1.5.1
|
||||
* 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) 2013 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.
|
||||
@@ -222,7 +222,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
|
||||
//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)) {
|
||||
if (!this.options.savenochange && this.input.value2str(newValue) == this.input.value2str(this.value)) {
|
||||
/*jslint eqeq: false*/
|
||||
/**
|
||||
Fired when value not changed but form is submitted. Requires savenochange = false.
|
||||
@@ -530,10 +530,9 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
/**
|
||||
Success callback. Called when value successfully sent on server and **response status = 200**.
|
||||
Usefull to work with json response. For example, if your backend response can be <code>{success: true}</code>
|
||||
or `{success: false, msg: "server error"}` you can check it inside this callback.
|
||||
or <code>{success: false, msg: "server error"}</code> 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
|
||||
(useful when server changes value).
|
||||
If it returns **object like** <code>{newValue: <something>}</code> - it overwrites value, submitted by user.
|
||||
Otherwise newValue simply rendered into element.
|
||||
|
||||
@property success
|
||||
@@ -957,23 +956,17 @@ Applied as jQuery method.
|
||||
'.bootstrap-wysihtml5-insert-image-modal',
|
||||
'.bootstrap-wysihtml5-insert-link-modal'
|
||||
];
|
||||
|
||||
// select2 has extra body click in IE
|
||||
// see: https://github.com/ivaynberg/select2/issues/1058
|
||||
if ($('.select2-drop-mask').is(':visible')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//check if element is detached. It occurs when clicking in bootstrap datepicker
|
||||
if (!$.contains(document.documentElement, e.target)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//for some reason FF 20 generates extra event (click) in select2 widget with e.target = document
|
||||
//we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199
|
||||
//Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec
|
||||
if($target.is(document)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//if click inside one of exclude classes --> no nothing
|
||||
@@ -1047,7 +1040,7 @@ Applied as jQuery method.
|
||||
.on({
|
||||
save: $.proxy(this.save, this), //click on submit button (value changed)
|
||||
nochange: $.proxy(function(){ this.hide('nochange'); }, this), //click on submit button (value NOT changed)
|
||||
cancel: $.proxy(function(){ this.hide('cancel'); }, this), //click on cancel button
|
||||
cancel: $.proxy(function(){ this.hide('cancel'); }, this), //click on calcel button
|
||||
show: $.proxy(function() {
|
||||
if(this.delayedHide) {
|
||||
this.hide(this.delayedHide.reason);
|
||||
@@ -2830,15 +2823,8 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
|
||||
If **function**, it should return data in format above (since 1.4.0).
|
||||
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only):
|
||||
@example
|
||||
[
|
||||
{text: "group1", children: [
|
||||
{value: 1, text: "text1"},
|
||||
{value: 2, text: "text2"}
|
||||
]},
|
||||
...
|
||||
]
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only).
|
||||
`[{text: "group1", children: [{value: 1, text: "text1"}, {value: 2, text: "text2"}]}, ...]`
|
||||
|
||||
|
||||
@property source
|
||||
@@ -2863,7 +2849,7 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
**/
|
||||
sourceError: 'Error when loading list',
|
||||
/**
|
||||
if `true` and source is **string url** - results will be cached for fields with the same source.
|
||||
if <code>true</code> and source is **string url** - results will be cached for fields with the same source.
|
||||
Usefull for editable column in grid to prevent extra requests.
|
||||
|
||||
@property sourceCache
|
||||
@@ -2874,18 +2860,12 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
sourceCache: true,
|
||||
/**
|
||||
Additional ajax options to be used in $.ajax() when loading list from server.
|
||||
Useful to send extra parameters or change request method.
|
||||
Useful to send extra parameters (`data` key) or change request method (`type` key).
|
||||
|
||||
@property sourceOptions
|
||||
@type object|function
|
||||
@default null
|
||||
@since 1.5.0
|
||||
@example
|
||||
sourceOptions: {
|
||||
data: {param: 123},
|
||||
type: 'post'
|
||||
}
|
||||
|
||||
**/
|
||||
sourceOptions: null
|
||||
});
|
||||
@@ -2930,9 +2910,7 @@ $(function(){
|
||||
activate: function() {
|
||||
if(this.$input.is(':visible')) {
|
||||
this.$input.focus();
|
||||
if (this.$input.is('input,textarea') && !this.$input.is('[type="checkbox"],[type="range"]')) {
|
||||
$.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
|
||||
}
|
||||
$.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
|
||||
if(this.toggleClear) {
|
||||
this.toggleClear();
|
||||
}
|
||||
@@ -3176,7 +3154,6 @@ $(function(){
|
||||
$.extend(Select.prototype, {
|
||||
renderList: function() {
|
||||
this.$input.empty();
|
||||
var escape = this.options.escape;
|
||||
|
||||
var fillItems = function($el, data) {
|
||||
var attr;
|
||||
@@ -3191,9 +3168,7 @@ $(function(){
|
||||
if(data[i].disabled) {
|
||||
attr.disabled = true;
|
||||
}
|
||||
var $option = $('<option>', attr);
|
||||
$option[escape ? 'text' : 'html'](data[i].text);
|
||||
$el.append($option);
|
||||
$el.append($('<option>', attr).text(data[i].text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3288,14 +3263,12 @@ $(function(){
|
||||
$label = $('<label>').append($('<input>', {
|
||||
type: 'checkbox',
|
||||
value: this.sourceData[i].value
|
||||
}));
|
||||
var $option = $('<span>');
|
||||
$option[this.options.escape ? 'text' : 'html'](' '+this.sourceData[i].text);
|
||||
$label.append($option);
|
||||
|
||||
}))
|
||||
.append($('<span>').text(' '+this.sourceData[i].text));
|
||||
|
||||
$('<div>').append($label).appendTo(this.$tpl);
|
||||
}
|
||||
|
||||
|
||||
this.$input = this.$tpl.find('input[type="checkbox"]');
|
||||
this.setClass();
|
||||
},
|
||||
|
||||
+4
-4
File diff suppressed because one or more lines are too long
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "X-editable",
|
||||
"title": "X-editable",
|
||||
"description": "In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery",
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.1",
|
||||
"homepage": "http://github.com/vitalets/x-editable",
|
||||
"author": {
|
||||
"name": "Vitaliy Potapov",
|
||||
|
||||
@@ -50,7 +50,7 @@ Applied as jQuery method.
|
||||
//close all on escape
|
||||
$(document).on('keyup.editable', function (e) {
|
||||
if (e.which === 27) {
|
||||
$('.editable-open').editableContainer('hide', 'cancel');
|
||||
$('.editable-open').editableContainer('hide');
|
||||
//todo: return focus on element
|
||||
}
|
||||
});
|
||||
@@ -66,23 +66,17 @@ Applied as jQuery method.
|
||||
'.bootstrap-wysihtml5-insert-image-modal',
|
||||
'.bootstrap-wysihtml5-insert-link-modal'
|
||||
];
|
||||
|
||||
// select2 has extra body click in IE
|
||||
// see: https://github.com/ivaynberg/select2/issues/1058
|
||||
if ($('.select2-drop-mask').is(':visible')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//check if element is detached. It occurs when clicking in bootstrap datepicker
|
||||
if (!$.contains(document.documentElement, e.target)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//for some reason FF 20 generates extra event (click) in select2 widget with e.target = document
|
||||
//we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199
|
||||
//Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec
|
||||
if($target.is(document)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
//if click inside one of exclude classes --> no nothing
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
setCursorPosition: function(elem, pos) {
|
||||
if (elem.setSelectionRange) {
|
||||
try { elem.setSelectionRange(pos, pos); } catch (e) {}
|
||||
elem.setSelectionRange(pos, pos);
|
||||
} else if (elem.createTextRange) {
|
||||
var range = elem.createTextRange();
|
||||
range.collapse(true);
|
||||
|
||||
@@ -218,7 +218,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
|
||||
//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)) {
|
||||
if (!this.options.savenochange && this.input.value2str(newValue) == this.input.value2str(this.value)) {
|
||||
/*jslint eqeq: false*/
|
||||
/**
|
||||
Fired when value not changed but form is submitted. Requires savenochange = false.
|
||||
@@ -526,10 +526,9 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
/**
|
||||
Success callback. Called when value successfully sent on server and **response status = 200**.
|
||||
Usefull to work with json response. For example, if your backend response can be <code>{success: true}</code>
|
||||
or `{success: false, msg: "server error"}` you can check it inside this callback.
|
||||
or <code>{success: false, msg: "server error"}</code> 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
|
||||
(useful when server changes value).
|
||||
If it returns **object like** <code>{newValue: <something>}</code> - it overwrites value, submitted by user.
|
||||
Otherwise newValue simply rendered into element.
|
||||
|
||||
@property success
|
||||
|
||||
@@ -146,7 +146,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).closest(selector);
|
||||
var $target = $(e.target);
|
||||
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
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
Slider, based on the Slider plugin by Stefan Petre (http://www.eyecon.ro/bootstrap-slider).
|
||||
|
||||
Make sure to include the plugin's code before using this editor.
|
||||
|
||||
@class slider
|
||||
@extends text
|
||||
@since 1.5.0
|
||||
@final
|
||||
**/
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
var Constructor = function (options) {
|
||||
this.init('slider', options, Constructor.defaults);
|
||||
};
|
||||
|
||||
$.fn.editableutils.inherit(Constructor, $.fn.editabletypes.text);
|
||||
|
||||
$.extend(Constructor.prototype, {
|
||||
render: function() {
|
||||
// need to set kewdown handler before apply slider
|
||||
// for correct autosubmit
|
||||
this.isAutosubmit = false;
|
||||
var that = this;
|
||||
this.$input.on('keydown', function (e) {
|
||||
if (!that.isAutosubmit) {
|
||||
return;
|
||||
}
|
||||
if (e.which === 13) {
|
||||
that.$input.closest('form').submit();
|
||||
}
|
||||
});
|
||||
|
||||
// apply slider
|
||||
this.$input.slider(this.options.slider);
|
||||
},
|
||||
|
||||
value2input: function(value) {
|
||||
// make sure it's a number
|
||||
if(typeof value!='number')
|
||||
value=Number(value);
|
||||
if(isNaN(value))
|
||||
value=0;
|
||||
|
||||
this.$input.val(value);
|
||||
this.$input.slider('setValue', value);
|
||||
},
|
||||
|
||||
autosubmit: function() {
|
||||
this.isAutosubmit = true;
|
||||
}
|
||||
});
|
||||
|
||||
Constructor.defaults = $.extend({}, $.fn.editabletypes.list.defaults, {
|
||||
/**
|
||||
@property tpl
|
||||
@default <input type="text">
|
||||
**/
|
||||
tpl:'<input type="text">',
|
||||
/**
|
||||
**/
|
||||
slider: null,
|
||||
});
|
||||
|
||||
$.fn.editabletypes.slider = Constructor;
|
||||
|
||||
}(window.jQuery));
|
||||
@@ -42,22 +42,6 @@ $(function(){
|
||||
this.renderClear();
|
||||
this.setClass();
|
||||
this.setAttr('placeholder');
|
||||
|
||||
// need to set kewdown handler before apply typeahead
|
||||
// for correct autosubmit
|
||||
this.isAutosubmit = false;
|
||||
var that = this;
|
||||
this.$input.on('keydown', function (e) {
|
||||
if (!that.isAutosubmit) {
|
||||
return;
|
||||
}
|
||||
var $dropdown = that.$input.closest('.editable-input').find('.tt-dropdown-menu');
|
||||
if (!$dropdown.is(':visible') && e.which === 13) {
|
||||
that.$input.closest('form').submit();
|
||||
}
|
||||
});
|
||||
|
||||
// apply typeaheadjs
|
||||
this.$input.typeahead(this.options.typeahead);
|
||||
|
||||
// copy `input-sm | input-lg` classes to placeholder input
|
||||
@@ -69,11 +53,7 @@ $(function(){
|
||||
this.$input.siblings('input.tt-hint').addClass('input-lg');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
autosubmit: function() {
|
||||
this.isAutosubmit = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Constructor.defaults = $.extend({}, $.fn.editabletypes.list.defaults, {
|
||||
|
||||
@@ -74,7 +74,7 @@ To create your own input you can inherit from this class.
|
||||
@returns {string}
|
||||
**/
|
||||
value2str: function(value) {
|
||||
return String(value);
|
||||
return value;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,14 +43,12 @@ $(function(){
|
||||
$label = $('<label>').append($('<input>', {
|
||||
type: 'checkbox',
|
||||
value: this.sourceData[i].value
|
||||
}));
|
||||
var $option = $('<span>');
|
||||
$option[this.options.escape ? 'text' : 'html'](' '+this.sourceData[i].text);
|
||||
$label.append($option);
|
||||
|
||||
}))
|
||||
.append($('<span>').text(' '+this.sourceData[i].text));
|
||||
|
||||
$('<div>').append($label).appendTo(this.$tpl);
|
||||
}
|
||||
|
||||
|
||||
this.$input = this.$tpl.find('input[type="checkbox"]');
|
||||
this.setClass();
|
||||
},
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/**
|
||||
* Combodate - 1.1.0
|
||||
* Combodate - 1.0.5
|
||||
* 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.
|
||||
@@ -28,31 +28,28 @@
|
||||
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 = $('<span class="combodate"></span>').html(this.getTemplate());
|
||||
|
||||
|
||||
this.initCombos();
|
||||
|
||||
// internal momentjs instance
|
||||
this.datetime = null;
|
||||
|
||||
//update original input on change
|
||||
|
||||
//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
|
||||
@@ -62,30 +59,28 @@
|
||||
}
|
||||
}
|
||||
}, 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 <select> elements
|
||||
*/
|
||||
Replace tokens in template with <select> 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+'}');
|
||||
});
|
||||
|
||||
@@ -96,17 +91,16 @@
|
||||
$.each(this.map, function(k, v) {
|
||||
v = v[0];
|
||||
var token = v.length > 1 ? v.substring(1, 2) : v;
|
||||
|
||||
tpl = tpl.replace('{'+token+'}', '<select class="'+k+' '+customClass +'"'+
|
||||
(inputDisabled ? ' disabled="disabled"' : '')+'></select>');
|
||||
});
|
||||
|
||||
tpl = tpl.replace('{'+token+'}', '<select class="'+k+'"></select>');
|
||||
});
|
||||
|
||||
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);
|
||||
@@ -118,8 +112,8 @@
|
||||
},
|
||||
|
||||
/*
|
||||
Fill combo with items
|
||||
*/
|
||||
Fill combo with items
|
||||
*/
|
||||
fillCombo: function(k) {
|
||||
var $combo = this['$'+k];
|
||||
if (!$combo) {
|
||||
@@ -127,7 +121,7 @@
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
||||
@@ -140,28 +134,24 @@
|
||||
},
|
||||
|
||||
/*
|
||||
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
|
||||
if (moment.localeData) {
|
||||
relTime = moment.localeData()._relativeTime;
|
||||
} else {
|
||||
relTime = moment.relativeTime || moment.langData()._relativeTime;
|
||||
}
|
||||
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;
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
@@ -187,26 +177,20 @@
|
||||
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,
|
||||
longNamesNum = this.options.template.indexOf('MMMMMM') !== -1,
|
||||
shortNamesNum = this.options.template.indexOf('MMMMM') !== -1,
|
||||
var items = this.fillCommon('M'), name, i,
|
||||
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 (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) {
|
||||
if(longNames) {
|
||||
//see https://github.com/timrwood/momentjs.com/pull/36
|
||||
name = moment().date(1).month(i).format('MMMM');
|
||||
} else if(shortNames) {
|
||||
@@ -217,27 +201,27 @@
|
||||
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
|
||||
*/
|
||||
@@ -246,16 +230,16 @@
|
||||
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
|
||||
*/
|
||||
@@ -266,10 +250,10 @@
|
||||
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
|
||||
*/
|
||||
@@ -280,103 +264,85 @@
|
||||
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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
var def = k === 'day' ? 1 : 0;
|
||||
|
||||
values[k] = that['$'+k] ? parseInt(that['$'+k].val(), 10) : def;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// parse in strict mode (third param `true`)
|
||||
var dt = typeof value === 'string' ? moment(value, this.options.format, true) : moment(value),
|
||||
|
||||
var dt = typeof value === 'string' ? moment(value, this.options.format) : moment(value),
|
||||
that = this,
|
||||
values = {};
|
||||
|
||||
|
||||
//function to find nearest value in select options
|
||||
function getNearest($select, value) {
|
||||
var delta = {};
|
||||
@@ -385,23 +351,23 @@
|
||||
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) {
|
||||
@@ -414,21 +380,21 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
@@ -437,14 +403,11 @@
|
||||
if (this.options.smartDays) {
|
||||
this.fillCombo('day');
|
||||
}
|
||||
|
||||
this.$element.val(dt.format(this.options.format)).change();
|
||||
this.datetime = dt;
|
||||
} else {
|
||||
this.datetime = null;
|
||||
|
||||
this.$element.val(dt.format(this.options.format)).change();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
highlight combos if date is invalid
|
||||
*/
|
||||
@@ -455,29 +418,29 @@
|
||||
} 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 ) {
|
||||
@@ -487,8 +450,8 @@
|
||||
//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'),
|
||||
@@ -500,25 +463,24 @@
|
||||
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: 2015,
|
||||
maxYear: (new Date().getFullYear()),
|
||||
yearDescending: true,
|
||||
minuteStep: 5,
|
||||
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));
|
||||
}(window.jQuery));
|
||||
|
||||
+4
-17
@@ -283,15 +283,8 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
|
||||
If **function**, it should return data in format above (since 1.4.0).
|
||||
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only):
|
||||
@example
|
||||
[
|
||||
{text: "group1", children: [
|
||||
{value: 1, text: "text1"},
|
||||
{value: 2, text: "text2"}
|
||||
]},
|
||||
...
|
||||
]
|
||||
Since 1.4.1 key `children` supported to render OPTGROUP (for **select** input only).
|
||||
`[{text: "group1", children: [{value: 1, text: "text1"}, {value: 2, text: "text2"}]}, ...]`
|
||||
|
||||
|
||||
@property source
|
||||
@@ -316,7 +309,7 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
**/
|
||||
sourceError: 'Error when loading list',
|
||||
/**
|
||||
if `true` and source is **string url** - results will be cached for fields with the same source.
|
||||
if <code>true</code> and source is **string url** - results will be cached for fields with the same source.
|
||||
Usefull for editable column in grid to prevent extra requests.
|
||||
|
||||
@property sourceCache
|
||||
@@ -327,18 +320,12 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
sourceCache: true,
|
||||
/**
|
||||
Additional ajax options to be used in $.ajax() when loading list from server.
|
||||
Useful to send extra parameters or change request method.
|
||||
Useful to send extra parameters (`data` key) or change request method (`type` key).
|
||||
|
||||
@property sourceOptions
|
||||
@type object|function
|
||||
@default null
|
||||
@since 1.5.0
|
||||
@example
|
||||
sourceOptions: {
|
||||
data: {param: 123},
|
||||
type: 'post'
|
||||
}
|
||||
|
||||
**/
|
||||
sourceOptions: null
|
||||
});
|
||||
|
||||
@@ -31,7 +31,6 @@ $(function(){
|
||||
$.extend(Select.prototype, {
|
||||
renderList: function() {
|
||||
this.$input.empty();
|
||||
var escape = this.options.escape;
|
||||
|
||||
var fillItems = function($el, data) {
|
||||
var attr;
|
||||
@@ -46,9 +45,7 @@ $(function(){
|
||||
if(data[i].disabled) {
|
||||
attr.disabled = true;
|
||||
}
|
||||
var $option = $('<option>', attr);
|
||||
$option[escape ? 'text' : 'html'](data[i].text);
|
||||
$el.append($option);
|
||||
$el.append($('<option>', attr).text(data[i].text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
-4
@@ -293,10 +293,6 @@ $(function(){
|
||||
return source;
|
||||
},
|
||||
|
||||
activate: function() {
|
||||
this.$input.select2('open');
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
if(this.$input) {
|
||||
if(this.$input.data('select2')) {
|
||||
|
||||
+29
-33
@@ -17,7 +17,7 @@ $(function(){
|
||||
**/
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
|
||||
var Text = function (options) {
|
||||
this.init('text', options, Text.defaults);
|
||||
};
|
||||
@@ -30,21 +30,17 @@ $(function(){
|
||||
this.setClass();
|
||||
this.setAttr('placeholder');
|
||||
},
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
$.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) {
|
||||
@@ -55,21 +51,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
|
||||
@@ -78,57 +74,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 <input type="text">
|
||||
**/
|
||||
**/
|
||||
tpl: '<input type="text">',
|
||||
/**
|
||||
Placeholder attribute of input. Shown when input is empty.
|
||||
|
||||
@property placeholder
|
||||
@property placeholder
|
||||
@type string
|
||||
@default 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
|
||||
});
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<div id="qunit-fixture1" style="margin: 100px"></div>
|
||||
<div id="qunit-fixture1"></div>
|
||||
<div id="async-fixture" style="padding-left:300px"></div>
|
||||
<script src="libs/qunit/qunit-1.12.0.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -73,31 +73,5 @@ $(function () {
|
||||
var p = tip(e);
|
||||
equal(p.find('input[type="checkbox"]:checked').length, 1, 'checked count ok');
|
||||
});
|
||||
|
||||
test("`escape` option", function () {
|
||||
var t = '<b>hello</b>',
|
||||
esc = '<b>hello</b>',
|
||||
e = $('<a href="#" data-type="checklist"></a>').appendTo('#qunit-fixture').editable({
|
||||
source: [{value: 'a', text: esc}],
|
||||
value: ['a'],
|
||||
escape: true
|
||||
}),
|
||||
e1 = $('<a href="#" data-type="checklist"></a>').appendTo('#qunit-fixture').editable({
|
||||
source: [{value: 'a', text: esc}],
|
||||
value: ['a'],
|
||||
escape: false
|
||||
});
|
||||
|
||||
equal(e.text(), esc, 'html escaped');
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
equal($.trim(p.find('label > span').eq(0).text()), esc, 'option escaped');
|
||||
e.remove();
|
||||
|
||||
equal(e1.text(), t, 'html not escaped');
|
||||
e1.click();
|
||||
var p1 = tip(e1);
|
||||
equal($.trim(p1.find('label > span').eq(0).text()), t, 'option not escaped');
|
||||
});
|
||||
|
||||
});
|
||||
+6
-16
@@ -793,29 +793,19 @@ $(function () {
|
||||
});
|
||||
|
||||
test("`escape` option", function () {
|
||||
var t = '<b>hello</b>',
|
||||
esc = '<b>hello</b>',
|
||||
e = $('<a href="#" data-type="select"></a>').appendTo('#qunit-fixture').editable({
|
||||
source: [{value: 'a', text: esc}],
|
||||
var e = $('<a href="#" data-type="select"></a>').appendTo('#qunit-fixture').editable({
|
||||
source: [{value: 'a', text: '<b>hello</b>'}],
|
||||
value: 'a',
|
||||
escape: true
|
||||
}),
|
||||
e1 = $('<a href="#" data-type="select"></a>').appendTo('#qunit-fixture').editable({
|
||||
source: [{value: 'a', text: esc}],
|
||||
source: [{value: 'a', text: '<b>hello</b>'}],
|
||||
value: 'a',
|
||||
escape: false
|
||||
});
|
||||
|
||||
equal(e.text(), esc, 'text equals, html escaped');
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
equal(p.find('select').find('option').eq(0).text(), esc, 'option escaped');
|
||||
e.remove();
|
||||
|
||||
equal(e1.text(), t, 'html not escaped');
|
||||
e1.click();
|
||||
var p1 = tip(e1);
|
||||
equal(p1.find('select').find('option').eq(0).text(), t, 'option not escaped');
|
||||
|
||||
equal(e.html(), '<b>hello</b>', 'html escaped');
|
||||
equal(e1.html(), '<b>hello</b>', 'html not escaped');
|
||||
});
|
||||
|
||||
asyncTest("sourceOptions", function () {
|
||||
|
||||
+2
-16
@@ -576,20 +576,6 @@ $(function () {
|
||||
ok(p.find('input').length, 'input exists');
|
||||
equal(p.find('input').val(), 'qwe', 'default text not set as element not empty');
|
||||
});
|
||||
|
||||
test("should able to submit a value which changed 0 to ''(empty string)", function () {
|
||||
var e = $('<a href="#" data-name="text1"></a>').appendTo('#qunit-fixture').editable({
|
||||
value: '0'
|
||||
});
|
||||
|
||||
//empty text
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
equal(p.find('input').val(), '0', 'text value is 0 ok');
|
||||
p.find('input').val('');
|
||||
p.find('form').submit();
|
||||
e.click();
|
||||
equal(p.find('input').val(), '', 'text changed to \'\' ok');
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
@@ -30,8 +30,8 @@ $(function () {
|
||||
equal(e.data().editable.value, v, 'initial value ok');
|
||||
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
var $input = p.find('input.tt-query');
|
||||
var p = tip(e),
|
||||
$input = p.find('input.tt-query');
|
||||
|
||||
ok(p.is(':visible'), 'popup visible');
|
||||
ok($input.length, 'input exists');
|
||||
@@ -62,38 +62,5 @@ $(function () {
|
||||
}, timeout);
|
||||
});
|
||||
|
||||
test("autosubmit ", function () {
|
||||
var v = 'ru',
|
||||
e = $('<a href="#" data-name="text1" data-type="typeaheadjs"></a>').appendTo(sfx).editable({
|
||||
value: v,
|
||||
showbuttons: false,
|
||||
typeahead: {
|
||||
name: 'country',
|
||||
local: [
|
||||
{value: 'ru', tokens: ['Russia']},
|
||||
{value: 'gb', tokens: ['Great Britain']},
|
||||
{value: 'us', tokens: ['United States']}
|
||||
],
|
||||
template: function(item) {
|
||||
return item.tokens[0] + ' (' + item.value + ')';
|
||||
}
|
||||
}
|
||||
}),
|
||||
newText = 'abc';
|
||||
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
var $input = p.find('input.tt-query');
|
||||
|
||||
// simutale <enter>
|
||||
var ev = jQuery.Event("keydown");
|
||||
ev.which = 13;
|
||||
$input.val(newText).trigger(ev);
|
||||
|
||||
ok(!p.is(':visible'), 'popup closed');
|
||||
equal(e.data('editable').value, newText, 'new text saved to value');
|
||||
equal(e.text(), newText, 'new text shown');
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user