21 Commits
Author SHA1 Message Date
MarQuis Knox bbbd2e2b40 Update README.md 2017-01-10 13:37:34 +01:00
MarQuis Knox 5e3f54c0dd UPDATED: README.md
Updated branch to submit Pull Requests
2017-01-10 13:35:55 +01:00
MarQuis Knox b510cc86b9 Update README.md 2016-12-20 18:31:11 +01:00
MarQuis Knox dc8967d116 Update README.md 2016-12-18 22:26:41 +01:00
lorvent 3e983bc6d2 Merge pull request #898 from wenzhixin/patch-1
fix #897: success is not defined bug
2016-05-08 09:54:23 -04:00
wenzhixin fe5b56a9c2 fix #897: success is not defined bug 2016-05-08 14:49:27 +08:00
lorvent e03afb2436 Merge pull request #876 from psaintlaurent/patch-1
Incorrect deferred implementation
2016-03-18 21:19:28 +05:30
Patrick St. laurent 93789de24d Typo in github editor 2016-03-11 12:35:35 -05:00
Patrick St. laurent a55709c990 Update bootstrap-editable.js 2016-03-11 12:33:08 -05:00
Patrick St. laurent 9275da7cfc Incorrect deferred implementation
This function creates a success object and a deferred object but the success object is never established as a handler for the deferred.  In practice this means that the display callback is never executed and values are never rendered.
2016-03-11 01:14:54 -05:00
lorvent 717d7f8594 Merge pull request #872 from AleksandrChernyavenko/master
default value for combodate.maxYear ( must be current year, not 2015 )
2016-03-02 01:03:55 +00:00
AleksandrChernyavenko 85fa502f2c default value for combodate.maxYear
Set default value  for combodate.maxYear to current year
2016-03-01 11:48:55 +02:00
lorvent 565f730945 Merge pull request #697 from tasarsu/patch-1
Bower jquery version change
2016-02-09 01:06:11 -05:00
lorvent c54078cb23 Merge pull request #859 from PerformanceHorizonGroup/add-slider-editor
added Slider editor extension
2016-02-05 05:04:40 -05:00
Georgi Kostov c2e64bc989 removed commented out code 2016-02-05 09:40:05 +02:00
lorvent 42b6d07a6b Merge pull request #849 from moradrouaguy/patch-1
Update bootstrap-editable.js
2016-02-04 13:48:15 -05:00
lorvent 28210f5cbb Merge pull request #690 from ma-si/patch-1
Update composer.json
2016-02-04 13:44:38 -05:00
Georgi Kostov 6099e5176d added Slider editor 2016-01-21 12:40:50 +02:00
moradrouaguy 76cdd53091 Update bootstrap-editable.js
I just put the current Year for the default maxDate (combodate).
2016-01-05 15:22:47 +00:00
tasarsu a3a5de1cde Bower jquery version change
x-editable doesnt work with jquery 2
2014-12-23 12:27:27 +02:00
MaSi 9a21e591d3 Update composer.json
Version update
2014-12-02 14:36:10 +01:00
47 changed files with 526 additions and 3757 deletions
+1 -3
View File
@@ -1,5 +1,3 @@
node_modules
test/instrumented/
*.nupkg
*.orig
/roadmap.txt
*.nupkg
-10
View File
@@ -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
----------------------------
-65
View File
@@ -1,65 +0,0 @@
## How to contribute
A few steps how to start contributing.
Assuming you have [Node.js](http://nodejs.org/) already installed.
1.Fork *X-editable* on github and clone it to your local machine:
````
git clone https://github.com/<your-github-name>/x-editable.git
````
2.Install *grunt-cli* globally (if not yet):
````
npm i -g grunt-cli
````
3.Install dependencies:
````
cd x-editable
npm i
````
4.Make your changes:
````
vim editable-form.js
````
5.Write some tests for your changes:
````
vim /test/unit/*.js
````
6.Run tests in cli:
````
grunt test
````
or directly in browser:
````
grunt server
````
and open http://127.0.0.1:8000/test
By default test run on bootstrap 3 popup version, but you can test any other build:
* bootstrap 3
* popup: http://127.0.0.1:8000/test/?f=bootstrap3&c=popup
* inline: http://127.0.0.1:8000/test/?f=bootstrap3&c=inline
* bootstrap 2
* popup: http://127.0.0.1:8000/test/?f=bootstrap2&c=popup
* inline: http://127.0.0.1:8000/test/?f=bootstrap2&c=inline
* jquery-ui
* popup: http://127.0.0.1:8000/test/?f=jqueryui&c=popup
* inline: http://127.0.0.1:8000/test/?f=jqueryui&c=inline
* jquery + poshytip
* popup: http://127.0.0.1:8000/test/?f=plain&c=popup
* inline: http://127.0.0.1:8000/test/?f=plain&c=inline
7.Commit and push back on github:
````
git add .
git commit -m'refactor editable form, fix #123'
git push origin
````
8.Make pull request on github (to `develop` branch).
Thanks for your support!
### Local build
To build x-editable locally please run:
````
grunt build
````
Result will appear in `dist` directory.
+5 -7
View File
@@ -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>
+81 -33
View File
@@ -1,27 +1,25 @@
# X-editable
In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery.
## Contents
* [Live Demo](#live-demo)
* [Installation](#installation)
* [Manual download](#manual-download)
* [Bower](#bower)
* [CDN](#cdn)
* [Getting Started](#getting-started)
* [Documentation](#documentation)
* [Issue Tracker](#issue-tracker)
* [Project Status](#project-status)
* [Contribution](#contribution)
* [Backers](#backers)
* [License](#license)
## Live Demo
Visit [X-editable demo](http://vitalets.github.io/x-editable/demo.html) to see all controls in action.
**http://vitalets.github.io/x-editable/demo.html**
## Installation
## 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
Use links on [X-editable home page](http://vitalets.github.io/x-editable).
Use **http://vitalets.github.io/x-editable** main page.
### Bower
````
@@ -53,31 +51,81 @@ jQuery only build:
<script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/jquery-editable/js/jquery-editable-poshytip.min.js"></script>
````
## Getting Started
How to start using X-editable is described on [X-editable website](http://vitalets.github.io/x-editable/docs.html).
## Documentation
Documentation on all available widgets and code samples can be found on [X-editable website](http://vitalets.github.io/x-editable/docs.html).
## Issue Tracker
Feel free to open [issues](https://github.com/vitalets/x-editable/issues).
Please include working code sample in issue body. To save the time use these jsFiddle templates:
1. [jsFiddle Bootstrap 3](http://jsfiddle.net/xBB5x/15155/)
## Reporting issues
Please **provide jsFiddle** when creating issues!
It's really saves much time. Use these as template:
1. [jsFiddle Bootstrap 3](http://jsfiddle.net/xBB5x/2265/)
2. [jsFiddle Bootstrap 2](http://jsfiddle.net/xBB5x/1817/)
3. [jsFiddle jQuery-ui](http://jsfiddle.net/xBB5x/2511/)
4. [jsFiddle jQuery](http://jsfiddle.net/xBB5x/197)
Your feedback is very appreciated!
## Project Status
Not actively maintained.
## Contribution
Please submit all Pull Requests to the **develop** branch. More details are in [CONTRIBUTING.md](/CONTRIBUTING.md).
A few steps how to start contributing.
Assuming you have [Node.js](http://nodejs.org/) already installed.
## Backers
[![Logo Flatlogic](https://user-images.githubusercontent.com/1473072/48839602-0edfda80-ed9d-11e8-9e2d-eb8d4828ddcb.png)](https://flatlogic.com/admin-dashboards)
1.Fork *X-editable* on github and clone it to your local mashine:
````
git clone https://github.com/<your-github-name>/x-editable.git -b dev
````
2.Install *grunt-cli* globally (if not yet):
````
npm i -g grunt-cli
````
3.Install dependencies:
````
cd x-editable
npm i
````
4.Make your changes:
````
vim editable-form.js
````
5.Write some tests for your changes:
````
vim /test/unit/*.js
````
6.Run tests in cli:
````
grunt test
````
or directly in browser:
````
grunt server
````
and open http://127.0.0.1:8000/test
By default test run on bootstrap 3 popup version, but you can test any other build:
Admin Dashboard Templates made with Vue, React and Angular by [Flatlogic](https://flatlogic.com/admin-dashboards).
* bootstrap 3
* popup: http://127.0.0.1:8000/test/?f=bootstrap3&c=popup
* inline: http://127.0.0.1:8000/test/?f=bootstrap3&c=inline
* bootstrap 2
* popup: http://127.0.0.1:8000/test/?f=bootstrap2&c=popup
* inline: http://127.0.0.1:8000/test/?f=bootstrap2&c=inline
* jquery-ui
* popup: http://127.0.0.1:8000/test/?f=jqueryui&c=popup
* inline: http://127.0.0.1:8000/test/?f=jqueryui&c=inline
* jquery + poshytip
* popup: http://127.0.0.1:8000/test/?f=plain&c=popup
* inline: http://127.0.0.1:8000/test/?f=plain&c=inline
7.Commit and push back on github:
````
git add .
git commit -m'refactor editable form, fix #123'
git push origin
````
8.Make pull request on github (to `dev` branch).
Thanks for your support!
### Local build
To build x-editable locally please run:
````
grunt build
````
Result will appear in `dist` directory.
## License
Copyright (c) 2012 Vitaliy Potapov
+2 -16
View File
@@ -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",
@@ -26,8 +13,7 @@
"src",
"test"
],
"license": "MIT",
"dependencies": {
"jquery": ">=1.6"
}
"jquery": "~1.11"
}
}
+3 -2
View File
@@ -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"
}
}
-10
View File
@@ -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
----------------------------
+1 -7
View File
@@ -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
View File
@@ -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 */
}
+24 -72
View File
@@ -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.
@@ -261,7 +261,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
}
//if success callback returns object like {newValue: <something>} --> use that value instead of submitted
//it is useful if you want to chnage value in url-function
//it is usefull if you want to chnage value in url-function
if(res && typeof res === 'object' && res.hasOwnProperty('newValue')) {
newValue = res.newValue;
}
@@ -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: &lt;something&gt;}` - it overwrites value, submitted by user
(useful when server changes value).
If it returns **object like** <code>{newValue: &lt;something&gt;}</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
});
@@ -2925,15 +2905,12 @@ $(function(){
this.renderClear();
this.setClass();
this.setAttr('placeholder');
this.setAttr('maxlength');
},
activate: function() {
if(this.$input.is(':visible')) {
this.$input.focus();
if (this.$input.is('input,textarea') && !this.$input.is('[type="checkbox"],[type="range"]')) {
$.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();
}
@@ -3017,16 +2994,7 @@ $(function(){
@default null
**/
placeholder: null,
/**
maxlength attribute of input.
@property placeholder
@type string
@default null
**/
maxlength: null,
/**
Whether to show `clear` button
@@ -3072,8 +3040,7 @@ $(function(){
render: function () {
this.setClass();
this.setAttr('placeholder');
this.setAttr('rows');
this.setAttr('maxlength');
this.setAttr('rows');
//ctrl + enter
this.$input.keydown(function (e) {
@@ -3140,16 +3107,6 @@ $(function(){
@default null
**/
placeholder: null,
/**
maxlength attribute of input.
@property placeholder
@type string
@default null
**/
maxlength: null,
/**
Number of rows in textarea
@@ -3197,7 +3154,6 @@ $(function(){
$.extend(Select.prototype, {
renderList: function() {
this.$input.empty();
var escape = this.options.escape;
var fillItems = function($el, data) {
var attr;
@@ -3212,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));
}
}
}
@@ -3309,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();
},
@@ -4466,7 +4418,7 @@ $(function(){
//initial value, can be `new Date()`
value: null,
minYear: 1970,
maxYear: new Date().getFullYear(),
maxYear: 2015,
yearDescending: true,
minuteStep: 5,
secondStep: 1,
@@ -7052,4 +7004,4 @@ $(function(){
$.fn.editabletypes.typeahead = Constructor;
}(window.jQuery));
}(window.jQuery));
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -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 */
}
+25 -63
View File
@@ -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 - 2016 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.
@@ -261,7 +261,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
}
//if success callback returns object like {newValue: <something>} --> use that value instead of submitted
//it is useful if you want to chnage value in url-function
//it is usefull if you want to chnage value in url-function
if(res && typeof res === 'object' && res.hasOwnProperty('newValue')) {
newValue = res.newValue;
}
@@ -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: &lt;something&gt;}` - it overwrites value, submitted by user
(useful when server changes value).
If it returns **object like** <code>{newValue: &lt;something&gt;}</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();
},
@@ -3727,24 +3700,13 @@ $(function(){
if (typeof source === 'string') {
options.select2.ajax = options.select2.ajax || {};
// default ajax params
if(!options.select2.ajax.dataType) {
options.select2.ajax.dataType = 'json';
}
//some default ajax params
if(!options.select2.ajax.data) {
options.select2.ajax.data = function(term) {
return {
query:term
};
};
options.select2.ajax.data = function(term) {return { query:term };};
}
if(!options.select2.ajax.processResults) {
options.select2.ajax.processResults = function(data) { return {results:data };};
if(!options.select2.ajax.results) {
options.select2.ajax.results = function(data) { return {results:data };};
}
options.select2.ajax.url = source;
} else {
//check format and convert x-editable format to select2 format (if needed)
@@ -4496,7 +4458,7 @@ $(function(){
template: 'D / MMMM / YYYY',
combodate: {
minYear: 2000,
maxYear: new Date().getFullYear(),
maxYear: 2015,
minuteStep: 1
}
}
File diff suppressed because one or more lines are too long
+1 -21
View File
@@ -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
View File
@@ -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 */
}
+23 -50
View File
@@ -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.
@@ -261,7 +261,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
}
//if success callback returns object like {newValue: <something>} --> use that value instead of submitted
//it is useful if you want to chnage value in url-function
//it is usefull if you want to chnage value in url-function
if(res && typeof res === 'object' && res.hasOwnProperty('newValue')) {
newValue = res.newValue;
}
@@ -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: &lt;something&gt;}` - it overwrites value, submitted by user
(useful when server changes value).
If it returns **object like** <code>{newValue: &lt;something&gt;}</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: new Date().getFullYear(),
maxYear: 2015,
yearDescending: true,
minuteStep: 5,
secondStep: 1,
@@ -4485,7 +4458,7 @@ $(function(){
template: 'D / MMMM / YYYY',
combodate: {
minYear: 2000,
maxYear: new Date().getFullYear(),
maxYear: 2015,
minuteStep: 1
}
}
@@ -5142,4 +5115,4 @@ Automatically shown in inline mode.
$.fn.editabletypes.dateuifield = DateUIField;
}(window.jQuery));
}(window.jQuery));
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -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 */
}
+23 -50
View File
@@ -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.
@@ -261,7 +261,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
}
//if success callback returns object like {newValue: <something>} --> use that value instead of submitted
//it is useful if you want to chnage value in url-function
//it is usefull if you want to chnage value in url-function
if(res && typeof res === 'object' && res.hasOwnProperty('newValue')) {
newValue = res.newValue;
}
@@ -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: &lt;something&gt;}` - it overwrites value, submitted by user
(useful when server changes value).
If it returns **object like** <code>{newValue: &lt;something&gt;}</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: new Date().getFullYear(),
maxYear: 2015,
yearDescending: true,
minuteStep: 5,
secondStep: 1,
@@ -4485,7 +4458,7 @@ $(function(){
template: 'D / MMMM / YYYY',
combodate: {
minYear: 2000,
maxYear: new Date().getFullYear(),
maxYear: 2015,
minuteStep: 1
}
}
@@ -5089,4 +5062,4 @@ Automatically shown in inline mode.
$.fn.editabletypes.dateuifield = DateUIField;
}(window.jQuery));
}(window.jQuery));
File diff suppressed because one or more lines are too long
-2893
View File
File diff suppressed because it is too large Load Diff
+15 -21
View File
@@ -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",
@@ -15,29 +15,23 @@
"bugs": {
"url": "https://github.com/vitalets/x-editable/issues"
},
"scripts": {
"precommit": "grunt jshint",
"prepush": "grunt jshint"
},
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-cli": "^1.3.2",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-connect": "~0.3.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-qunit": "~0.2.2",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-contrib-uglify": "~0.2.2",
"husky": "^0.14.3"
},
"keywords": [],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/vitalets/x-editable/blob/master/LICENSE-MIT"
}
]
],
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-qunit": "~0.2.2",
"grunt-contrib-connect": "~0.3.0",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-requirejs": "~0.4.1"
},
"keywords": []
}
+4 -10
View File
@@ -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
+2 -2
View File
@@ -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);
@@ -95,7 +95,7 @@
*/
getConfigData: function($element) {
var data = {};
$.each($element[0].dataset, function(k, v) {
$.each($element.data(), function(k, v) {
if(typeof v !== 'object' || (v && typeof v === 'object' && (v.constructor === Object || v.constructor === Array))) {
data[k] = v;
}
+4 -5
View File
@@ -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.
@@ -257,7 +257,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
}
//if success callback returns object like {newValue: <something>} --> use that value instead of submitted
//it is useful if you want to chnage value in url-function
//it is usefull if you want to chnage value in url-function
if(res && typeof res === 'object' && res.hasOwnProperty('newValue')) {
newValue = res.newValue;
}
@@ -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: &lt;something&gt;}` - it overwrites value, submitted by user
(useful when server changes value).
If it returns **object like** <code>{newValue: &lt;something&gt;}</code> - it overwrites value, submitted by user.
Otherwise newValue simply rendered into element.
@property success
+1 -1
View File
@@ -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
+68
View File
@@ -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));
+1 -21
View File
@@ -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, {
-3
View File
@@ -98,9 +98,6 @@ $(function(){
//e.g. '<img>', '<br>', '<p></p>'
return !$element.height() || !$element.width();
}
},
destroy:function (){
this.$input.data('wysihtml5').editor.destroy();
}
});
+1 -1
View File
@@ -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;
},
/**
+4 -6
View File
@@ -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 -1
View File
@@ -27,7 +27,7 @@ $(function(){
template: 'D / MMMM / YYYY',
combodate: {
minYear: 2000,
maxYear: new Date().getFullYear(),
maxYear: 2015,
minuteStep: 1
}
}
+130 -168
View File
@@ -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,23 +463,22 @@
data[option].apply(data, args);
}
});
};
};
$.fn.combodate.defaults = {
//in this format value stored in original input
format: 'DD-MM-YYYY HH:mm',
format: 'DD-MM-YYYY HH:mm',
//in this format items in dropdowns are displayed
template: 'D / MMM / YYYY H : mm',
//initial value, can be `new Date()`
value: null,
//initial value, can be `new Date()`
value: null,
minYear: 1970,
maxYear: new Date().getFullYear(),
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
};
+26 -26
View File
@@ -1,6 +1,6 @@
/**
Bootstrap datefield input - modification for inline mode.
Shows normal <input type="text"> and binds popup datepicker.
Shows normal <input type="text"> and binds popup datepicker.
Automatically shown in inline mode.
@class datefield
@@ -10,63 +10,63 @@ Automatically shown in inline mode.
**/
(function ($) {
"use strict";
var DateField = function (options) {
this.init('datefield', options, DateField.defaults);
this.initPicker(options, DateField.defaults);
};
$.fn.editableutils.inherit(DateField, $.fn.editabletypes.date);
$.fn.editableutils.inherit(DateField, $.fn.editabletypes.date);
$.extend(DateField.prototype, {
render: function () {
this.$input = this.$tpl.find('input');
this.setClass();
this.setAttr('placeholder');
//bootstrap-datepicker is set `bdateicker` to exclude conflict with jQuery UI one. (in date.js)
this.$input.bdatepicker(this.options.datepicker);
//bootstrap-datepicker is set `bdateicker` to exclude conflict with jQuery UI one. (in date.js)
this.$tpl.bdatepicker(this.options.datepicker);
//need to disable original event handlers
this.$input.off('focus keydown');
//update value of datepicker
this.$input.keyup($.proxy(function(){
this.$tpl.removeData('date');
this.$tpl.bdatepicker('update');
}, this));
},
},
value2input: function(value) {
this.$input.val(value ? this.dpg.formatDate(value, this.parsedViewFormat, this.options.datepicker.language) : '');
this.$tpl.bdatepicker('update');
},
input2value: function() {
input2value: function() {
return this.html2value(this.$input.val());
},
},
activate: function() {
$.fn.editabletypes.text.prototype.activate.call(this);
},
autosubmit: function() {
//reset autosubmit to empty
//reset autosubmit to empty
}
});
DateField.defaults = $.extend({}, $.fn.editabletypes.date.defaults, {
/**
@property tpl
**/
@property tpl
**/
tpl:'<div class="input-append date"><input type="text"/><span class="add-on"><i class="icon-th"></i></span></div>',
/**
@property inputclass
@property inputclass
@default 'input-small'
**/
**/
inputclass: 'input-small',
/* datepicker config */
datepicker: {
weekStart: 0,
@@ -75,7 +75,7 @@ Automatically shown in inline mode.
autoclose: true
}
});
$.fn.editabletypes.datefield = DateField;
}(window.jQuery));
}(window.jQuery));
+4 -17
View File
@@ -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
});
+1 -4
View File
@@ -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));
}
}
}
+6 -10
View File
@@ -88,7 +88,7 @@ $(function(){
options.select2 = options.select2 || {};
this.sourceData = null;
//placeholder
if(options.placeholder) {
options.select2.placeholder = options.placeholder;
@@ -293,16 +293,12 @@ $(function(){
return source;
},
activate: function() {
this.$input.select2('open');
},
destroy: function() {
if(this.$input) {
if(this.$input.data('select2')) {
this.$input.select2('destroy');
}
}
if(this.$input) {
if(this.$input.data('select2')) {
this.$input.select2('destroy');
}
}
}
});
+29 -33
View File
@@ -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
View File
@@ -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>
+1 -1
View File
@@ -67,7 +67,7 @@ $(function () {
});
// useful functions
// usefull functions
function tip(e) {
return e.data('editableContainer').tip();
-26
View File
@@ -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 = '&lt;b&gt;hello&lt;/b&gt;',
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');
});
});
+2 -5
View File
@@ -49,8 +49,7 @@
esc_v = $('<div>').text(v).html(),
e = $('<a href="#123" data-name="abc" data-value="123">qwe</a>').appendTo('#qunit-fixture').editable(),
e2 = $('<a href="#" id="a2">'+v+'</a>').appendTo('#qunit-fixture').editable(),
e3 = $('<a href="#" id="a3">'+esc_v+'</a>').appendTo('#qunit-fixture').editable(),
e4 = $('<a href="#" id="a4" data-value="null"></a>').appendTo('#qunit-fixture').editable();
e3 = $('<a href="#" id="a3">'+esc_v+'</a>').appendTo('#qunit-fixture').editable();
equal(e.data('editable').options.name, 'abc', 'name exists');
equal(e.data('editable').value, '123', 'value exists');
@@ -60,9 +59,7 @@
// equal(e2.data('editable').lastSavedValue, visible_v, 'lastSavedValue taken from text correctly');
equal(e3.data('editable').value, v, 'value taken from elem content correctly (escaped)');
// equal(e3.data('editable').lastSavedValue, v, 'lastSavedValue taken from text correctly (escaped)');
equal(e4.data('editable').value, "null", 'value "null" taken from elem\'s data-attribute "data-value" correctly');
// equal(e3.data('editable').lastSavedValue, v, 'lastSavedValue taken from text correctly (escaped)');
});
test("container's title and placement from json options", function () {
+6 -16
View File
@@ -793,29 +793,19 @@ $(function () {
});
test("`escape` option", function () {
var t = '<b>hello</b>',
esc = '&lt;b&gt;hello&lt;/b&gt;',
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(), '&lt;b&gt;hello&lt;/b&gt;', 'html escaped');
equal(e1.html(), '<b>hello</b>', 'html not escaped');
});
asyncTest("sourceOptions", function () {
+2 -16
View File
@@ -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');
});
});
});
+2 -35
View File
@@ -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');
});
});