├── .gitignore
├── demos
├── robots.txt
├── json2.php
├── json.php
├── save.php
├── main.css
├── img
│ └── spinner.svg
├── css
│ ├── main.css
│ └── prism.css
├── js
│ ├── jquery.charcounter.js
│ ├── jquery.autogrowtextarea.js
│ ├── prism.js
│ └── jquery.maskedinput.js
├── index.js
└── index.html
├── .github
├── PULL_REQUEST_TEMPLATE.md
└── ISSUE_TEMPLATE.md
├── .dockerignore
├── FUNDING.yml
├── CONTRIBUTING.md
├── dist
├── jquery.jeditable.autogrow.min.js
├── jquery.jeditable.masked.min.js
├── jquery.jeditable.charcounter.min.js
├── jquery.jeditable.datepicker.min.js
├── jquery.jeditable.time.min.js
└── jquery.jeditable.min.js
├── tests
├── index.html
└── tests.js
├── LICENSE
├── Gruntfile.js
├── package.json
├── apache
└── 000-default.conf
├── src
├── jquery.jeditable.autogrow.js
├── jquery.jeditable.masked.js
├── jquery.jeditable.checkbox.js
├── jquery.jeditable.charcounter.js
├── jquery.jeditable.datepicker.js
├── jquery.jeditable.time.js
└── jquery.jeditable.js
├── Dockerfile
├── CHANGELOG.md
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | api
3 |
--------------------------------------------------------------------------------
/demos/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Allow: /
3 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Please make sure to target the "experimental" branch!
2 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | .git
2 | .gitignore
3 | node_modules
4 | README.md
5 | CHANGELOG.md
6 | CONTRIBUTING.md
7 | LICENSE
8 |
--------------------------------------------------------------------------------
/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 | liberapay: NicolasCARPi
3 | github: NicolasCARPi
4 |
--------------------------------------------------------------------------------
/demos/json2.php:
--------------------------------------------------------------------------------
1 | ");return settings.rows?textarea.attr("rows",settings.rows):textarea.height(settings.height),settings.cols?textarea.attr("cols",settings.cols):textarea.width(settings.width),$(this).append(textarea),textarea},plugin:function(settings,original){$("textarea",this).autoGrow()}})}(jQuery);
--------------------------------------------------------------------------------
/demos/main.css:
--------------------------------------------------------------------------------
1 | body {
2 | text-align: center;
3 | font-size: 120%;
4 | background-color: #eee;
5 | }
6 |
7 | .jumbotron {
8 | background-color: #fff;
9 | }
10 |
11 | .editable input[type=submit] {
12 | color: #F00;
13 | font-weight: bold;
14 | }
15 | .editable input[type=button] {
16 | color: #0F0;
17 | font-weight: bold;
18 | }
19 |
20 | .inline {
21 | display: inline;
22 | }
23 |
24 | h4 {
25 | text-align: left;
26 | }
27 |
28 | /* for the full example */
29 | label {
30 | margin-right: 5px;
31 | }
32 |
33 | .custom-class {
34 | font-size: 110%;
35 | }
36 |
--------------------------------------------------------------------------------
/dist/jquery.jeditable.masked.min.js:
--------------------------------------------------------------------------------
1 | /*! jquery-jeditable https://github.com/NicolasCARPi/jquery_jeditable#readme */
2 |
3 | "use strict";!function($){$.editable.addInputType("masked",{element:function(settings,original){var input=$(" ").attr({autocomplete:"off",list:settings.list,maxlength:settings.maxlength,pattern:settings.pattern,placeholder:settings.placeholder,tooltip:settings.tooltip,type:"text"}).mask(settings.mask);return"none"!==settings.width&&input.css("width",settings.width),"none"!==settings.height&&input.css("height",settings.height),settings.size&&input.attr("size",settings.size),settings.maxlength&&input.attr("maxlength",settings.maxlength),$(this).append(input),input}})}(jQuery);
--------------------------------------------------------------------------------
/dist/jquery.jeditable.charcounter.min.js:
--------------------------------------------------------------------------------
1 | /*! jquery-jeditable https://github.com/NicolasCARPi/jquery_jeditable#readme */
2 |
3 | "use strict";!function($){$.editable.addInputType("charcounter",{element:function(settings,original){var textarea=$("");return settings.rows?textarea.attr("rows",settings.rows):textarea.height(settings.height),settings.cols?textarea.attr("cols",settings.cols):textarea.width(settings.width),textarea.click(function(event){event.cancelBubble&&event.cancelBubble(),event.stopPropagation&&event.stopPropagation()}),$(this).append(textarea),textarea},plugin:function(settings,original){$("textarea",this).charCounter(settings.charcounter.characters,settings.charcounter)}})}(jQuery);
--------------------------------------------------------------------------------
/demos/img/spinner.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dist/jquery.jeditable.datepicker.min.js:
--------------------------------------------------------------------------------
1 | /*! jquery-jeditable https://github.com/NicolasCARPi/jquery_jeditable#readme */
2 |
3 | "use strict";!function($){$.editable.addInputType("datepicker",{element:function(settings,original){var input=$(" ");return settings.datepicker?input.datepicker(settings.datepicker):input.datepicker(),settings.datepicker.format&&input.datepicker("option","dateFormat",settings.datepicker.format),$(this).append(input),input},submit:function(settings,original){var dateFormatted,dateRaw=$("input",this).datepicker("getDate");dateFormatted=settings.datepicker.format?$.datepicker.formatDate(settings.datepicker.format,new Date(dateRaw)):dateRaw,$("input",this).val(dateFormatted)},plugin:function(settings,original){settings.onblur=null}})}(jQuery);
--------------------------------------------------------------------------------
/tests/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | jQuery jeditable tests
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2006 Mika Tuupola, Dylan Verheul, Nicolas CARPi
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Gruntfile.js
3 | *
4 | * Run 'grunt' in shell to minify javascript
5 | *
6 | */
7 | module.exports = function(grunt) {
8 |
9 | grunt.initConfig({
10 | pkg: grunt.file.readJSON('package.json'),
11 | uglify: {
12 | options: {
13 | banner: '/*! <%= pkg.name %> <%= pkg.homepage %> */\n',
14 | mangle: false
15 | },
16 | dist: {
17 | files: {
18 | 'dist/jquery.jeditable.min.js': 'src/jquery.jeditable.js',
19 | 'dist/jquery.jeditable.autogrow.min.js': 'src/jquery.jeditable.autogrow.js',
20 | 'dist/jquery.jeditable.charcounter.min.js': 'src/jquery.jeditable.charcounter.js',
21 | 'dist/jquery.jeditable.datepicker.min.js': 'src/jquery.jeditable.datepicker.js',
22 | 'dist/jquery.jeditable.masked.min.js': 'src/jquery.jeditable.masked.js',
23 | 'dist/jquery.jeditable.time.min.js': 'src/jquery.jeditable.time.js',
24 | }
25 | }
26 | }
27 | });
28 |
29 | grunt.loadNpmTasks('grunt-contrib-uglify-es');
30 | grunt.registerTask('default', 'uglify');
31 |
32 | };
33 |
--------------------------------------------------------------------------------
/demos/css/main.css:
--------------------------------------------------------------------------------
1 | body {
2 | text-align: center;
3 | font-size: 120%;
4 | background-color: #eee;
5 | }
6 |
7 | .jumbotron {
8 | background-color: #fff;
9 | }
10 |
11 | .card-title {
12 | font-weight: bold;
13 | }
14 |
15 | .card {
16 | border: 1px solid #ccc;
17 | border-radius: 5px;
18 | margin: 5px;
19 | }
20 |
21 | .example {
22 | border: 1px solid #ccc;
23 | border-radius: 5px;
24 | padding: 10px;
25 | background-color: #fff;
26 | }
27 |
28 | .custom-class input, button {
29 | margin-right: 10px;
30 | }
31 |
32 | .custom-class input {
33 | padding: 8px;
34 | border: 1px solid #ccc;
35 | border-radius: 5px;
36 | }
37 |
38 | .trigger:hover {
39 | cursor: pointer;
40 | }
41 |
42 | .editable input[type=submit] {
43 | color: #F00;
44 | font-weight: bold;
45 | }
46 | .editable input[type=button] {
47 | color: #0F0;
48 | font-weight: bold;
49 | }
50 |
51 | .inline {
52 | display: inline;
53 | }
54 |
55 | h4 {
56 | text-align: left;
57 | }
58 |
59 | /* for the full example */
60 | label {
61 | margin-right: 5px;
62 | }
63 |
--------------------------------------------------------------------------------
/dist/jquery.jeditable.time.min.js:
--------------------------------------------------------------------------------
1 | /*! jquery-jeditable https://github.com/NicolasCARPi/jquery_jeditable#readme */
2 |
3 | "use strict";!function($){$.editable.addInputType("time",{element:function(settings,original){for(var option,hourselect=$(' '),minselect=$(' '),hour=0;hour<=23;hour++)hour<10&&(hour="0"+hour),option=$(" ").val(hour).append(hour),hourselect.append(option);$(this).append(hourselect);for(var min=0;min<=45;min=parseInt(min,10)+15)min<10&&(min="0"+min),option=$(" ").val(min).append(min),minselect.append(option);$(this).append(minselect);var hidden=$(' ');return $(this).append(hidden),hidden},content:function(string,settings,original){var hour=parseInt(string.substr(0,2),10),min=parseInt(string.substr(3,2),10);$("#hour_",this).children().each(function(){hour===$(this).val()&&$(this).attr("selected","selected")}),$("#min_",this).children().each(function(){min===$(this).val()&&$(this).attr("selected","selected")})},submit:function(settings,original){var value=$("#hour_").val()+":"+$("#min_").val();$("input",this).val(value)}})}(jQuery);
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-jeditable",
3 | "version": "2.0.21",
4 | "description": "Edit in place plugin for jQuery",
5 | "main": "src/jquery.jeditable.js",
6 | "directories": {
7 | "test": "tests"
8 | },
9 | "dependencies": {
10 | "jquery": "^3.5.1"
11 | },
12 | "devDependencies": {
13 | "documentation": "^13.1.0",
14 | "grunt": "^1.3.0",
15 | "grunt-contrib-uglify-es": "^3.3.0",
16 | "lodash": "^4.17.20",
17 | "merge": "^2.1.0",
18 | "qunit": "^2.13.0"
19 | },
20 | "scripts": {
21 | "test": "firefox -new-tab tests/index.html"
22 | },
23 | "repository": {
24 | "type": "git",
25 | "url": "git+https://github.com/NicolasCARPi/jquery_jeditable.git"
26 | },
27 | "keywords": [
28 | "jquery",
29 | "edit",
30 | "in",
31 | "place",
32 | "jeditable",
33 | "plugin"
34 | ],
35 | "author": "Mika Tuupola ",
36 | "license": "MIT",
37 | "bugs": {
38 | "url": "https://github.com/NicolasCARPi/jquery_jeditable/issues"
39 | },
40 | "homepage": "https://github.com/NicolasCARPi/jquery_jeditable#readme"
41 | }
42 |
--------------------------------------------------------------------------------
/apache/000-default.conf:
--------------------------------------------------------------------------------
1 |
2 | ServerName jeditable.elabftw.net
3 |
4 | ServerAdmin webmaster@localhost
5 | DocumentRoot /var/www/html/demos
6 |
7 | ErrorLog ${APACHE_LOG_DIR}/error.log
8 | CustomLog ${APACHE_LOG_DIR}/access.log combined
9 |
10 | Header always set Strict-Transport-Security "max-age=63072000"
11 | Header always set X-xss-protection "0"
12 | Header always set X-content-type-options "nosniff"
13 | Header always set Content-Security-Policy "default-src 'self' data:; script-src 'self' https://ajax.googleapis.com https://code.jquery.com; connect-src 'self'; img-src 'self'; style-src 'self' 'unsafe-inline' https://code.jquery.com https://maxcdn.bootstrapcdn.com https://use.fontawesome.com; font-src 'self' data: https://use.fontawesome.com https://maxcdn.bootstrapcdn.com; object-src 'self'; base-uri 'none'; frame-ancestors 'none'"
14 | Header always set Referrer-policy "no-referrer"
15 | Header always set Feature-policy "autoplay 'none'; camera 'none'; document-domain 'none'; encrypted-media 'none'; fullscreen 'self'; geolocation 'none'; microphone 'none'; midi 'none'; payment 'none'; vr 'none'"
16 |
17 |
--------------------------------------------------------------------------------
/src/jquery.jeditable.autogrow.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file autogrow plugin for jquery-jeditable
3 | * @author Mika Tuupola, Nicolas CARPi
4 | * @copyright © 2008 Mika Tuupola, Nicolas CARPi
5 | * @home https://github.com/NicolasCARPi/jquery_jeditable
6 | * @licence MIT (see LICENCE file)
7 | * @name PluginAutogrow
8 | * @example Autogrow example:
9 | * $(".autogrow").editable("save.php", {
10 | * type : "autogrow",
11 | * submit : 'OK',
12 | * cancel : 'cancel'
13 | * });
14 | */
15 | 'use strict';
16 | (function ($) {
17 | $.editable.addInputType("autogrow", {
18 | element : function(settings, original) {
19 | var textarea = $("");
20 | if (settings.rows) {
21 | textarea.attr("rows", settings.rows);
22 | } else {
23 | textarea.height(settings.height);
24 | }
25 | if (settings.cols) {
26 | textarea.attr("cols", settings.cols);
27 | } else {
28 | textarea.width(settings.width);
29 | }
30 | $(this).append(textarea);
31 | return(textarea);
32 | },
33 | plugin : function(settings, original) {
34 | $("textarea", this).autoGrow();
35 | }
36 | });
37 | })(jQuery);
38 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # serve the demo page of jquery-jeditable
2 | # https://github.com/NicolasCARPi/jquery_jeditable
3 |
4 | # use apache + php
5 | FROM php:8.0-apache
6 |
7 | # select version or branch here
8 | ENV JEDITABLE_VERSION master
9 |
10 | LABEL org.label-schema.name="jquery-jeditable demo" \
11 | org.label-schema.description="Run Apache and php to serve jquery-jeditable demo page" \
12 | org.label-schema.url="https://jeditable.elabftw.net" \
13 | org.label-schema.vcs-url="https://github.com/NicolasCARPi/jquery_jeditable" \
14 | org.label-schema.version=$JEDITABLE_VERSION\
15 | org.label-schema.maintainer="nicolas.carpi@curie.fr" \
16 | org.label-schema.schema-version="1.0"
17 |
18 | # install npm
19 | ENV DEBIAN_FRONTEND=noninteractive
20 | RUN apt-get update && apt-get -y --no-install-recommends install gnupg \
21 | && curl -sL https://deb.nodesource.com/setup_14.x | bash - \
22 | && apt-get install -y nodejs \
23 | && npm install -g documentation \
24 | && rm -rf /var/lib/apt/lists/* \
25 | && a2enmod headers
26 |
27 | COPY . /var/www/html
28 | RUN ln -s /var/www/html/src /var/www/html/demos/src
29 | COPY ./apache/000-default.conf /etc/apache2/sites-enabled/000-default.conf
30 | COPY ./apache/php.ini /usr/local/etc/php/php.ini
31 |
32 | # generate api doc
33 | WORKDIR /var/www/html
34 | RUN documentation build src -f html -o demos/api
35 | EXPOSE 80
36 |
--------------------------------------------------------------------------------
/src/jquery.jeditable.masked.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Depends on Masked Input jQuery plugin by Josh Bush:
3 | * http://digitalbush.com/projects/masked-input-plugin
4 | *
5 | * @file masked input plugin for jquery-jeditable
6 | * @author Mika Tuupola, Nicolas CARPi
7 | * @home https://github.com/NicolasCARPi/jquery_jeditable
8 | * @licence MIT (see LICENCE file)
9 | * @copyright © 2007 Mika Tuupola, Nicolas CARPi
10 | * @name PluginMaskedInput
11 | */
12 | 'use strict';
13 | (function ($) {
14 | $.editable.addInputType('masked', {
15 | element : function(settings, original) {
16 | var input = $(' ').attr({
17 | autocomplete: 'off',
18 | list: settings.list,
19 | maxlength: settings.maxlength,
20 | pattern: settings.pattern,
21 | placeholder: settings.placeholder,
22 | tooltip: settings.tooltip,
23 | type: 'text'
24 | }).mask(settings.mask);
25 |
26 | if (settings.width !== 'none') {
27 | input.css('width', settings.width);
28 | }
29 |
30 | if (settings.height !== 'none') {
31 | input.css('height', settings.height);
32 | }
33 |
34 | if (settings.size) {
35 | input.attr('size', settings.size);
36 | }
37 |
38 | if (settings.maxlength) {
39 | input.attr('maxlength', settings.maxlength);
40 | }
41 |
42 | $(this).append(input);
43 | return(input);
44 | }
45 | });
46 | })(jQuery);
47 |
--------------------------------------------------------------------------------
/src/jquery.jeditable.checkbox.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file checkbox plugin for jquery-jeditable
3 | * @author Mika Tuupola, Nicolas CARPi
4 | * @home https://github.com/NicolasCARPi/jquery_jeditable
5 | * @licence MIT (see LICENCE file)
6 | * @name PluginCheckbox
7 | */
8 | 'use strict';
9 | (function ($) {
10 | $.editable.addInputType('checkbox', {
11 | element : function(settings, original) {
12 | var input = $(' ');
13 | $(this).append(input);
14 |
15 | $(input).bind('click', function() {
16 | if ($(input).val() === 'on') {
17 | $(input).val('off');
18 | $(input).removeAttr('checked');
19 | } else {
20 | $(input).val('on');
21 | $(input).attr('checked', 'checked');
22 | }
23 | });
24 |
25 | return(input);
26 | },
27 |
28 | content : function(string, settings, original) {
29 |
30 | var checked = (string === 'yes') ? 'on' : 'off';
31 | var input = $(':input:first', this);
32 |
33 | if (checked === 'on') {
34 | $(input).attr('checked', checked);
35 | } else {
36 | $(input).removeAttr('checked');
37 | }
38 |
39 | var value = $(input).is(':checked') ? 'on' : 'off';
40 | $(input).val(value);
41 | },
42 |
43 | submit: function (settings, original) {
44 | var value;
45 | var input = $(':input:first', this);
46 | if (input.is(':checked')) {
47 | value = '1';
48 | } else {
49 | value = '0';
50 | }
51 | $('input', this).val(value);
52 | }
53 | });
54 | })(jQuery);
55 |
--------------------------------------------------------------------------------
/src/jquery.jeditable.charcounter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Depends on Charcounter jQuery plugin by Tom Deater
3 | * http://www.tomdeater.com/jquery/character_counter/
4 | *
5 | * @file charcounter textarea plugin for jquery-jeditable
6 | * @author Mika Tuupola, Nicolas CARPi
7 | * @home https://github.com/NicolasCARPi/jquery_jeditable
8 | * @licence MIT (see LICENCE file)
9 | * @copyright © 2006 Mika Tuupola, Nicolas CARPi
10 | * @name PluginCharcounter
11 | * @example Charcounter example:
12 | * $(".charcounter").editable("save.php", {
13 | * type : "charcounter",
14 | * submit : 'OK',
15 | * charcounter : {
16 | * characters : 60
17 | * }
18 | * });
19 | */
20 | 'use strict';
21 | (function ($) {
22 | $.editable.addInputType("charcounter", {
23 | element : function(settings, original) {
24 | var textarea = $("");
25 | if (settings.rows) {
26 | textarea.attr("rows", settings.rows);
27 | } else {
28 | textarea.height(settings.height);
29 | }
30 | if (settings.cols) {
31 | textarea.attr("cols", settings.cols);
32 | } else {
33 | textarea.width(settings.width);
34 | }
35 |
36 | // stop bubbling and propagation to parent element
37 | textarea.click(function(event) {
38 | if (event.cancelBubble) {
39 | event.cancelBubble();
40 | }
41 | if (event.stopPropagation) {
42 | event.stopPropagation();
43 | }
44 | });
45 |
46 | $(this).append(textarea);
47 | return(textarea);
48 | },
49 | plugin : function(settings, original) {
50 | $("textarea", this).charCounter(settings.charcounter.characters, settings.charcounter);
51 | }
52 | });
53 | })(jQuery);
54 |
--------------------------------------------------------------------------------
/src/jquery.jeditable.datepicker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Depends on datepicker widget from jQuery-ui
3 | * https://jqueryui.com/datepicker/
4 | *
5 | * @file datepicker plugin for jquery-jeditable
6 | * @author Nicolas CARPi
7 | * @copyright © 2008 Mika Tuupola, Nicolas CARPi
8 | * @home https://github.com/NicolasCARPi/jquery_jeditable
9 | * @licence MIT (see LICENCE file)
10 | * @name PluginDatepicker
11 | * @example Datepicker example:
12 | * $(".date").editable("save.php", {
13 | * type : "datepicker",
14 | * submit : 'OK',
15 | * datepicker : {
16 | * format: "dd-mm-yy"
17 | * },
18 | * cancel : 'cancel',
19 | * });
20 | */
21 | 'use strict';
22 | (function ($) {
23 | $.editable.addInputType('datepicker', {
24 |
25 | element : function(settings, original) {
26 | var input = $(' ');
27 | if (settings.datepicker) {
28 | input.datepicker(settings.datepicker);
29 | } else {
30 | input.datepicker();
31 | }
32 |
33 | // get the date in the correct format
34 | if (settings.datepicker.format) {
35 | input.datepicker('option', 'dateFormat', settings.datepicker.format);
36 | }
37 |
38 | $(this).append(input);
39 | return(input);
40 | },
41 |
42 | submit: function (settings, original) {
43 | var dateRaw = $('input', this).datepicker('getDate');
44 | var dateFormatted;
45 |
46 | if (settings.datepicker.format) {
47 | dateFormatted = $.datepicker.formatDate(settings.datepicker.format, new Date(dateRaw));
48 | } else {
49 | dateFormatted = dateRaw;
50 | }
51 | $('input', this).val(dateFormatted);
52 | },
53 |
54 | plugin : function(settings, original) {
55 | // prevent disappearing of calendar
56 | settings.onblur = null;
57 | }
58 | });
59 | })(jQuery);
60 |
--------------------------------------------------------------------------------
/src/jquery.jeditable.time.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file timepicker plugin for jquery-jeditable
3 | * @author Mika Tuupola, Nicolas CARPi
4 | * @home https://github.com/NicolasCARPi/jquery_jeditable
5 | * @licence MIT (see LICENCE file)
6 | * @copyright © 2007 Mika Tuupola, Nicolas CARPi
7 | * @name PluginTimepicker
8 | */
9 | 'use strict';
10 | (function ($) {
11 | $.editable.addInputType('time', {
12 | /* Create input element. */
13 | element : function(settings, original) {
14 | /* Create and pulldowns for hours and minutes. Append them to */
15 | /* form which is accessible as variable this. */
16 | var hourselect = $(' ');
17 | var minselect = $(' ');
18 |
19 | var option;
20 |
21 | for (var hour=0; hour <= 23; hour++) {
22 | if (hour < 10) {
23 | hour = '0' + hour;
24 | }
25 | option = $(' ').val(hour).append(hour);
26 | hourselect.append(option);
27 | }
28 | $(this).append(hourselect);
29 |
30 | for (var min=0; min <= 45; min = parseInt(min, 10) + 15) {
31 | if (min < 10) {
32 | min = '0' + min;
33 | }
34 | option = $(' ').val(min).append(min);
35 | minselect.append(option);
36 | }
37 | $(this).append(minselect);
38 |
39 | /* Last create an hidden input. This is returned to plugin. It will */
40 | /* later hold the actual value which will be submitted to server. */
41 | var hidden = $(' ');
42 | $(this).append(hidden);
43 | return(hidden);
44 | },
45 | /* Set content / value of previously created input element. */
46 | content : function(string, settings, original) {
47 | /* Select correct hour and minute in pulldowns. */
48 | var hour = parseInt(string.substr(0,2), 10);
49 | var min = parseInt(string.substr(3,2), 10);
50 |
51 | $('#hour_', this).children().each(function() {
52 | if (hour === $(this).val()) {
53 | $(this).attr('selected', 'selected');
54 | }
55 | });
56 | $('#min_', this).children().each(function() {
57 | if (min === $(this).val()) {
58 | $(this).attr('selected', 'selected');
59 | }
60 | });
61 |
62 | },
63 | /* Call before submit hook. */
64 | submit: function (settings, original) {
65 | /* Take values from hour and minute pulldowns. Create string such as */
66 | /* 13:45 from them. Set value of the hidden input field to this string. */
67 | var value = $('#hour_').val() + ':' + $('#min_').val();
68 | $('input', this).val(value);
69 | }
70 | });
71 | })(jQuery);
72 |
--------------------------------------------------------------------------------
/demos/css/prism.css:
--------------------------------------------------------------------------------
1 | /* PrismJS 1.11.0
2 | http://prismjs.com/download.html?themes=prism&languages=clike+javascript */
3 | /**
4 | * prism.js default theme for JavaScript, CSS and HTML
5 | * Based on dabblet (http://dabblet.com)
6 | * @author Lea Verou
7 | */
8 |
9 | code[class*="language-"],
10 | pre[class*="language-"] {
11 | color: black;
12 | background: none;
13 | text-shadow: 0 1px white;
14 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
15 | text-align: left;
16 | white-space: pre;
17 | word-spacing: normal;
18 | word-break: normal;
19 | word-wrap: normal;
20 | line-height: 1.5;
21 |
22 | -moz-tab-size: 4;
23 | -o-tab-size: 4;
24 | tab-size: 4;
25 |
26 | -webkit-hyphens: none;
27 | -moz-hyphens: none;
28 | -ms-hyphens: none;
29 | hyphens: none;
30 | }
31 |
32 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
33 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
34 | text-shadow: none;
35 | background: #b3d4fc;
36 | }
37 |
38 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
39 | code[class*="language-"]::selection, code[class*="language-"] ::selection {
40 | text-shadow: none;
41 | background: #b3d4fc;
42 | }
43 |
44 | @media print {
45 | code[class*="language-"],
46 | pre[class*="language-"] {
47 | text-shadow: none;
48 | }
49 | }
50 |
51 | /* Code blocks */
52 | pre[class*="language-"] {
53 | padding: 1em;
54 | margin: .5em 0;
55 | overflow: auto;
56 | }
57 |
58 | :not(pre) > code[class*="language-"],
59 | pre[class*="language-"] {
60 | background: #f5f2f0;
61 | }
62 |
63 | /* Inline code */
64 | :not(pre) > code[class*="language-"] {
65 | padding: .1em;
66 | border-radius: .3em;
67 | white-space: normal;
68 | }
69 |
70 | .token.comment,
71 | .token.prolog,
72 | .token.doctype,
73 | .token.cdata {
74 | color: slategray;
75 | }
76 |
77 | .token.punctuation {
78 | color: #999;
79 | }
80 |
81 | .namespace {
82 | opacity: .7;
83 | }
84 |
85 | .token.property,
86 | .token.tag,
87 | .token.boolean,
88 | .token.number,
89 | .token.constant,
90 | .token.symbol,
91 | .token.deleted {
92 | color: #905;
93 | }
94 |
95 | .token.selector,
96 | .token.attr-name,
97 | .token.string,
98 | .token.char,
99 | .token.builtin,
100 | .token.inserted {
101 | color: #690;
102 | }
103 |
104 | .token.operator,
105 | .token.entity,
106 | .token.url,
107 | .language-css .token.string,
108 | .style .token.string {
109 | color: #a67f59;
110 | background: hsla(0, 0%, 100%, .5);
111 | }
112 |
113 | .token.atrule,
114 | .token.attr-value,
115 | .token.keyword {
116 | color: #07a;
117 | }
118 |
119 | .token.function {
120 | color: #DD4A68;
121 | }
122 |
123 | .token.regex,
124 | .token.important,
125 | .token.variable {
126 | color: #e90;
127 | }
128 |
129 | .token.important,
130 | .token.bold {
131 | font-weight: bold;
132 | }
133 | .token.italic {
134 | font-style: italic;
135 | }
136 |
137 | .token.entity {
138 | cursor: help;
139 | }
140 |
141 |
--------------------------------------------------------------------------------
/demos/js/jquery.charcounter.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @file Charcounter project: attaches a character counter to each textarea element in the jQuery object
4 | * @copyright © 2007 Tom Deater (http://www.tomdeater.com)
5 | * @licence MIT
6 | * @example Charcounter example:
7 | * $("#myTextArea").charCounter(max, settings);
8 | *
9 | */
10 | (function($) {
11 | $.fn.charCounter = function (max, settings) {
12 | max = max || 100;
13 | settings = $.extend({
14 | container: ' ',
15 | classname: 'charcounter',
16 | format: '(%1 characters remaining)',
17 | pulse: true,
18 | delay: 0
19 | }, settings);
20 |
21 | var p, timeout;
22 |
23 | function pulse(el, again) {
24 | if (p) {
25 | window.clearTimeout(p);
26 | p = null;
27 | }
28 | el.animate({ opacity: 0.1 }, 100, function () {
29 | $(this).animate({ opacity: 1.0 }, 100);
30 | });
31 | if (again) {
32 | p = window.setTimeout(function () { pulse(el); }, 200);
33 | }
34 | }
35 |
36 | function count(el, container) {
37 | el = $(el);
38 | if (el.val().length > max) {
39 | el.val(el.val().substring(0, max));
40 | if (settings.pulse && !p) {
41 | pulse(container, true);
42 | }
43 | }
44 | if (settings.delay > 0) {
45 | if (timeout) {
46 | window.clearTimeout(timeout);
47 | }
48 | timeout = window.setTimeout(function () {
49 | container.html(settings.format.replace(/%1/, (max - el.val().length)));
50 | }, settings.delay);
51 | } else {
52 | container.html(settings.format.replace(/%1/, (max - el.val().length)));
53 | }
54 | }
55 |
56 | return this.each(function () {
57 | var container = (!settings.container.match(/^<.+>$/)) ? $(settings.container) : $(settings.container)
58 | .insertAfter(this)
59 | .addClass(settings.classname);
60 |
61 | $(this)
62 | .bind('keydown', function () { count(this, container); })
63 | .bind('keypress', function () { count(this, container); })
64 | .bind('keyup', function () { count(this, container); })
65 | .bind('focus', function () { count(this, container); })
66 | .bind('mouseover', function () { count(this, container); })
67 | .bind('mouseout', function () { count(this, container); })
68 | .bind('paste', function () {
69 | var me = this;
70 | setTimeout(function () { count(me, container); }, 10);
71 | });
72 | if (this.addEventListener) {
73 | this.addEventListener('input', function () { count(this, container); }, false);
74 | }
75 | count(this, container);
76 | });
77 | };
78 |
79 | })(jQuery);
80 |
--------------------------------------------------------------------------------
/demos/js/jquery.autogrowtextarea.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ----------------------------------------------------------------------------
3 | * "THE BEER-WARE LICENSE" (Revision 42):
4 | * wrote this file. As long as you retain this notice you
5 | * can do whatever you want with this stuff. If we meet some day, and you think
6 | * this stuff is worth it, you can buy me a beer in return. Jevin O. Sewaruth
7 | * ----------------------------------------------------------------------------
8 | *
9 | * Autogrow Textarea Plugin Version v3.0
10 | * http://www.technoreply.com/autogrow-textarea-plugin-3-0
11 | *
12 | * THIS PLUGIN IS DELIVERD ON A PAY WHAT YOU WANT BASIS. IF THE PLUGIN WAS USEFUL TO YOU, PLEASE CONSIDER BUYING THE PLUGIN HERE :
13 | * https://sites.fastspring.com/technoreply/instant/autogrowtextareaplugin
14 | *
15 | * Date: October 15, 2012
16 | */
17 |
18 | jQuery.fn.autoGrow = function(options) {
19 | return this.each(function() {
20 | var settings = jQuery.extend({
21 | extraLine: true,
22 | }, options);
23 |
24 | var mirror;
25 |
26 | var createMirror = function(textarea) {
27 | jQuery(textarea).after('
');
28 | return jQuery(textarea).next('.autogrow-textarea-mirror')[0];
29 | };
30 |
31 | var sendContentToMirror = function (textarea) {
32 | mirror.innerHTML = String(textarea.value)
33 | .replace(/&/g, '&')
34 | .replace(/"/g, '"')
35 | .replace(/'/g, ''')
36 | .replace(//g, '>')
38 | .replace(/\n/g, ' ') +
39 | (settings.extraLine? '. .' : '')
40 | ;
41 |
42 | if (jQuery(textarea).height() !== jQuery(mirror).height())
43 | jQuery(textarea).height(jQuery(mirror).height());
44 | };
45 |
46 | var growTextarea = function() {
47 | sendContentToMirror(this);
48 | };
49 |
50 | // Create a mirror
51 | mirror = createMirror(this);
52 |
53 | // Style the mirror
54 | mirror.style.display = 'none';
55 | mirror.style.wordWrap = 'break-word';
56 | mirror.style.whiteSpace = 'pre-wrap';
57 | mirror.style.padding = jQuery(this).css('paddingTop') + ' ' +
58 | jQuery(this).css('paddingRight') + ' ' +
59 | jQuery(this).css('paddingBottom') + ' ' +
60 | jQuery(this).css('paddingLeft');
61 |
62 | mirror.style.borderStyle = jQuery(this).css('borderTopStyle') + ' ' +
63 | jQuery(this).css('borderRightStyle') + ' ' +
64 | jQuery(this).css('borderBottomStyle') + ' ' +
65 | jQuery(this).css('borderLeftStyle');
66 |
67 | mirror.style.borderWidth = jQuery(this).css('borderTopWidth') + ' ' +
68 | jQuery(this).css('borderRightWidth') + ' ' +
69 | jQuery(this).css('borderBottomWidth') + ' ' +
70 | jQuery(this).css('borderLeftWidth');
71 | mirror.style.width = jQuery(this).css('width');
72 | mirror.style.fontFamily = jQuery(this).css('font-family');
73 | mirror.style.fontSize = jQuery(this).css('font-size');
74 | mirror.style.lineHeight = jQuery(this).css('line-height');
75 | mirror.style.letterSpacing = jQuery(this).css('letter-spacing');
76 |
77 | // Style the textarea
78 | this.style.overflow = 'hidden';
79 | this.style.minHeight = this.rows+'em';
80 |
81 | // Bind the textarea's event
82 | this.onkeyup = growTextarea;
83 | this.onfocus = growTextarea;
84 |
85 | // Fire the event for text already present
86 | sendContentToMirror(this);
87 |
88 | });
89 | };
90 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 2.0.21
4 |
5 | * Fix tooltip getting overwritten (#241)
6 | * Update dev dependencies
7 |
8 | ## 2.0.20
9 |
10 | * Update dev dependencies
11 |
12 | ## 2.0.19
13 |
14 | * Fix warnings from jquery-migrate (#230) by Shaun Case
15 | * Upgrade dependencies
16 |
17 | ## 2.0.18
18 |
19 | * Upgrade dependencies
20 | * Formatting fix (remove tabs)
21 | * Add FUNDING.yml
22 | * Fix changelog (#218)
23 |
24 | ## 2.0.17
25 |
26 | * Upgrade jquery to 3.5.0 because of vulnerability in previous versions
27 |
28 | ## 2.0.16
29 |
30 | * Get text instead of html in callback result (#214)
31 | * Enable shift+enter to submit form (#216)
32 |
33 | ## 2.0.15
34 |
35 | * Remove deprecated .blur() calls and replace them with .on() (#211)
36 |
37 | ## 2.0.14
38 |
39 | * Remove deprecated jQuery functions and replace them by modern counterparts (#211)
40 |
41 | ## 2.0.13
42 |
43 | * Accept list of tuples as items for select element (#208 by @emjayko)
44 |
45 | ## 2.0.12
46 |
47 | * Wrap the plugins in functions for non-conflict mode (#205)
48 |
49 | ## 2.0.11
50 |
51 | * Use text() instead of html() for revert (#203)
52 |
53 | ## 2.0.10
54 |
55 | * Regenerate the minified files
56 |
57 | ## 2.0.9
58 |
59 | * Allow resubmiting if onsubmit or submit returns false (#201 by @RobdeT)
60 |
61 | ## 2.0.8
62 |
63 | * Update dependencies to fix security vulnerabilities (CVE-2019-11358, and in js-yaml)
64 |
65 | ## 2.0.7
66 |
67 | * Change isSubmitting back to false onComplete (#192)
68 | * Width/height now correctly taken into account for masked inputs (#189)
69 | * Pass event object to the before callback (#188)
70 |
71 | ## 2.0.6
72 |
73 | * Fix cancel when ESC is pressed (#177) by @thezoggy
74 | * Fix "main" entry of package.json (#181)
75 |
76 | ## 2.0.5
77 |
78 | * Sorting of select items is now an option (default is not sorted). by @nathanvda (#178)
79 |
80 | ## 2.0.3
81 |
82 | * Add ability to apply css to input element (#173)
83 |
84 | ## 2.0.2
85 |
86 | * Fix a bug where selected value will get added to the select options. by @eman1986 (#166)
87 |
88 | ## 2.0.1
89 |
90 | * Fix width setting to number, url and email (#163)
91 |
92 | ## 2.0.0
93 |
94 | * BREAKING: remove ajaxupload and old datepicker plugins (new datepicker added)
95 | * BREAKING: change the autogrow plugin for another one
96 | * Add datepicker plugin for jQuery-UI's datepicker
97 | * Add form param to onblur apply (#37)
98 | * Allow onblur function to cancel form if it returns false (#14)
99 | * Properly cleanup after destroy. by @Scottmitch (#125)
100 | * Return submitdata if it's a function. by @mkdgs (#109)
101 | * Add onedit example + doc. by @chriskeeble (#122)
102 | * Stop event propagation for charcounter. by @twashing (#86)
103 | * Add multiselect support. by @nicholasryan (#75)
104 | * Add html5 text attributes, email, number and url types. by @nfreear (#87)
105 | * Add maxlength to textarea too. by @estebistec (#68)
106 | * Add option to style buttons and add id to form. by @quocvu (#71)
107 | * Add intercept option useful for preprocessing data. by @randell (#66)
108 | * Pass the source event to the onedit hook. by @gfouquet (#104)
109 | * Return element to target function (#67)
110 | * Add 'before' option. by @bp323 (#113)
111 | * Fix issue with html encodable characters (#110)
112 | * Add checkbox type. by @oneslash and @pushpinderbagga (#52)
113 | * Correctly check if checkbox is checked
114 | * Select options are now sorted by value. by @jjwdesign (#97)
115 | * Add submitdata to callback. by @mikemeier (#64)
116 | * Adjust the width of the element to account for border/margin/padding
117 | * Fix loadtext not showing (#15)
118 | * Pass a response callback function to custom target function. by bshelton229. (#65)
119 | * Add showfn for jquery animations before displaying form (#46)
120 | * Remove extra loop. by @dgm (#45)
121 | * Better demo page showing more example
122 | * Add proper API documentation
123 | * Add usage documentation in README.md
124 | * Add Dockerfile to serve the demos
125 | * Add LICENSE file
126 |
127 | ## 1.8.0
128 |
129 | * A lot of cleanup in the repo after years of abandon
130 | * The demos folder now contains a page (index.html) with all the demo code
131 | * Removed Textile stuff
132 | * Removed SQLite from the demo
133 | * Add support for configuring size and maxlength. by @bonkowski (#32)
134 | * Set "cache" to false on loadurl. Fix issue with IE8. by @spikex (#33)
135 | * Add package.json for npm hosting
136 | * Remove eval to allow compilation with Closure & Fix for newer jQuery. by @flavour (#158)
137 | * Fix issue with width/height (#137)
138 | * Fix issue with selected in select element (#106)
139 | * Add label settings. by @tomasm- (#40)
140 |
141 | ## 1.7.3
142 |
143 | * Add support for "jQuery plugin repository": http://plugins.jquery.com/
144 |
145 | ## 1.7.2
146 |
147 | * Submit on change if input type select and no submit button defined ("gregpyp":http://github.com/gregpyp)
148 |
149 | ## 1.7.1
150 |
151 | * Namespace default event as click.editable ("Zangetsu":http://github.com/Zangetsu)
152 | * Trim whitespace when determining the selected value of pulldown ("binarylogic":http://github.com/binarylogic)
153 | * Make default settings publicly available ("lawrencepit":http://github.com/lawrencepit)
154 | * Allow ajax calls other than 'html', e.g. json and script calls. ("lawrencepit":http://github.com/lawrencepit)
155 | * Do not follow links if they are editable ("Darwin":http://github.com/darwin)
156 | * make JSLInt happy ("olleolleolle":http://github.com/olleolleolle)
157 |
158 | ## 1.7.0
159 |
160 | * Full control over jQuery AJAX options for those who want to tinker.
161 | * Fix problem with IE and placeholder with HTML tags.
162 | * Add $.editable('disable'), $.editable('enable') and $.editable('destroy')
163 | * Add onedit, onsubmit, onreset and onerror hooks.
164 | * Allow passing select options as JavaScript object.
165 | * Fix IE throwing error with textareas when width or height was set to 'none'.
166 |
167 | ## 1.6.2
168 |
169 | * Fix problems when xhtml is served application/xhtml+xml.
170 |
171 | ## 1.6.1
172 |
173 | * Submit method can now be POST (default) or PUT.
174 | * Fix form being submitted twice in some cases.
175 |
176 | ## 1.6.0
177 |
178 | * Onblur parameter can now be a function.
179 | * Support for any arbitrary event for triggering Jeditable
180 | * Submitting of form will be canceled if submit() method of custom input returns false.
181 | * Custom inputs now have access to reset() method.
182 |
--------------------------------------------------------------------------------
/tests/tests.js:
--------------------------------------------------------------------------------
1 | /* jquery-jeditable tests */
2 | var elem = $('#qunit-fixture');
3 |
4 | QUnit.test('Registration', function(assert) {
5 | assert.ok($.fn.editable, 'registered as a jQuery plugin');
6 | });
7 | QUnit.test('Chainability', function(assert) {
8 | assert.ok(elem.editable().addClass('testing'), 'can be chained');
9 | assert.ok(elem.hasClass('testing'), 'successfully chained');
10 | });
11 |
12 | QUnit.test('ARIA attributes', function(assert) {
13 | elem.editable().editableAriaShim();
14 | assert.ok(elem.is('[role="button"]'), 'added role');
15 | });
16 |
17 | QUnit.test('Enable/disable/destroy', function(assert) {
18 | elem.editable().editable('disable');
19 | assert.strictEqual(elem.data('disabled.editable'), true);
20 |
21 | elem.editable('enable');
22 | assert.ok(elem.data('event.editable'));
23 |
24 | elem.editable().editable('destroy');
25 | assert.notOk(elem.data('event.editable'));
26 | });
27 |
28 | QUnit.module('select-boxes');
29 | QUnit.test('Default: NOT Sorting select options', function(assert) {
30 | elem.append( 'Letter F ' );
31 |
32 | $.fn.editable.defaults.sortselectoptions = false;
33 |
34 | $('#select-tester').editable('http://bla', {
35 | type: 'select',
36 | data: {'E': 'Letter E', 'F': 'Letter F', 'D': 'Letter Disk'},
37 | selected: 'F'
38 | });
39 |
40 | assert.equal( $('#select-tester').attr('title'), 'Click to edit', 'Editable enabled: it sets the title' );
41 | $('#select-tester').click();
42 | assert.equal($('#select-tester form').length, 1, 'Clicking Editable adds inline form');
43 |
44 | var optionsList = [];
45 | $('#select-tester option').each(function(name, val) { optionsList.push(val.text); });
46 |
47 | assert.deepEqual(optionsList, ['Letter E', 'Letter F', 'Letter Disk'], 'Does not sort the given options-list');
48 | });
49 | QUnit.test('Default: Sorting select options', function(assert) {
50 | elem.append( 'Letter F ' );
51 |
52 | $.fn.editable.defaults.sortselectoptions = true;
53 |
54 | $('#select-sorted-tester').editable('http://bla', {
55 | type: 'select',
56 | data: {'E': 'Letter E', 'F': 'Letter F', 'D': 'Letter Disk'},
57 | selected: 'F'
58 | });
59 | assert.equal( $('#select-sorted-tester').attr('title'), 'Click to edit', 'Editable enabled: it sets the title' );
60 | $('#select-sorted-tester').click();
61 | assert.equal($('#select-sorted-tester form').length, 1, 'Clicking Editable adds inline form');
62 |
63 | var optionsList = [];
64 | $('#select-sorted-tester option').each(function(name, val) { optionsList.push(val.text); });
65 |
66 | assert.deepEqual(optionsList, ['Letter Disk', 'Letter E', 'Letter F'], 'It does sort the given options list');
67 | });
68 | QUnit.module('select-boxes input data');
69 | QUnit.test('List of tuples', function(assert) {
70 | elem.append(' ');
71 | var e = $('#select-tester', elem);
72 |
73 | var test_data = [['E', 'Letter E'], ['F', 'Letter F'], ['D', 'Letter Disk']];
74 | e.editable('http://bla', {
75 | type: 'select',
76 | data: test_data
77 | });
78 |
79 | e.click();
80 |
81 | var optionsList = [];
82 | e.find('option').each(function(name, val) { optionsList.push([val.value, val.text]); });
83 | assert.deepEqual(optionsList, test_data, 'Options keep sorted as defined in input');
84 | });
85 | QUnit.test('List of strings', function(assert) {
86 | elem.append(' ');
87 | var e = $('#select-tester', elem);
88 |
89 | var test_data = ['E', 'F', 'D'];
90 | var sort = Math.random() > 0.5;
91 | e.editable('http://bla', {
92 | type: 'select',
93 | data: test_data,
94 | sortselectoptions: sort
95 | });
96 |
97 | e.click();
98 |
99 | var optionsList = [];
100 | var expected_result = [['0', 'E'],['1', 'F'], ['2', 'D']];
101 | if (sort) {
102 | expected_result.sort(function(a, b) {return a[1] > b[1];});
103 | }
104 | e.find('option').each(function(name, val) { optionsList.push([val.value, val.text]); });
105 | assert.deepEqual(optionsList, expected_result, 'Options get auto assigned integer values in order of input and options are sorted by label based on sortselectoptions option');
106 | });
107 | QUnit.test('Object', function(assert) {
108 | elem.append(' ');
109 | var e = $('#select-tester', elem);
110 |
111 | var test_data = {'E': 'Letter E', 'F': 'Letter F', 'D': 'Letter Disk'};
112 | var sort = Math.random() > 0.5;
113 | e.editable('http://bla', {
114 | type: 'select',
115 | data: test_data,
116 | sortselectoptions: sort
117 | });
118 |
119 | e.click();
120 |
121 | var optionsList = [];
122 | var expected_result = [['E', 'Letter E'], ['F', 'Letter F'], ['D', 'Letter Disk']];
123 | if (sort) {
124 | expected_result.sort(function(a, b) {return a[1] > b[1];});
125 | }
126 | e.find('option').each(function(name, val) { optionsList.push([val.value, val.text]); });
127 | assert.deepEqual(optionsList, expected_result, 'Options are sorted either in order of object definition or by label depending on sortselectoptions option');
128 | });
129 | QUnit.module('select-boxes setting selected');
130 | QUnit.test('Explicitly setting a selected option', function(assert) {
131 | elem.append( 'Letter F ' );
132 |
133 | $.fn.editable.defaults.sortselectoptions = false;
134 |
135 | $('#selected-tester').editable('http://bla', {
136 | type: 'select',
137 | data: {'E': 'Letter E', 'F': 'Letter F', 'D': 'Letter Disk', 'selected': 'F'},
138 | });
139 |
140 | assert.equal( $( '#selected-tester').attr('title'), 'Click to edit', 'Editable enabled: it sets the title' );
141 | $('#selected-tester').click();
142 | assert.equal($('#selected-tester form select :selected').text(), 'Letter F', 'Sets the correct value as selected');
143 | });
144 | QUnit.test('Not setting a selected option', function(assert) {
145 | elem.append( 'Letter F ' );
146 |
147 | $.fn.editable.defaults.sortselectoptions = false;
148 |
149 | $('#selected-tester').editable('http://bla', {
150 | type: 'select',
151 | data: {'E': 'Letter E', 'F': 'Letter F', 'D': 'Letter Disk'},
152 | });
153 |
154 | assert.equal( $( '#selected-tester').attr('title'), 'Click to edit', 'Editable enabled: it sets the title' );
155 | $('#selected-tester').click();
156 | assert.equal($('#selected-tester form select :selected').text(), 'Letter E', 'Selects the first option as selected?');
157 | });
158 |
159 |
--------------------------------------------------------------------------------
/demos/index.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function() {
2 | // make all examples reachable with Tab key for accessibility
3 | $(".example").editableAriaShim();
4 |
5 | // hide all source code
6 | $('.source').hide();
7 | // to toggle the source
8 | $('.trigger').click(function() {
9 | var sourceDiv = $(this).next('.source');
10 |
11 | if (sourceDiv.is(':visible')) {
12 | $(this).html(" Show source code");
13 | } else {
14 | $(this).html(" Hide source code");
15 | }
16 |
17 | sourceDiv.toggle();
18 | });
19 |
20 | // BASIC MINIMAL EXAMPLE
21 | $(".editable-text").editable("save.php");
22 |
23 | // FULL EXAMPLE WITH PLENTY OF OPTIONS
24 | // custom submitted data fields
25 | var submitdata = {};
26 | submitdata['slow'] = true;
27 | submitdata['pwet'] = 'youpla';
28 |
29 | $(".editable-text-full").editable("save.php", {
30 | indicator : " ",
31 | type : "text",
32 | // only limit to three letters example
33 | //pattern: "[A-Za-z]{3}",
34 | onedit : function() { console.log('If I return false edition will be canceled'); return true;},
35 | before : function() { console.log('Triggered before form appears');},
36 | callback : function(result, settings, submitdata) {
37 | console.log('Callback function: triggered after submit');
38 | console.log('Result: ' + result);
39 | console.log('Settings.width: ' + settings.width);
40 | console.log('Submitdata: ' + submitdata.pwet);
41 | },
42 | cancel : 'Cancel',
43 | cssclass : 'custom-class',
44 | cancelcssclass : 'btn btn-danger',
45 | // select all text
46 | select : true,
47 | submitcssclass : 'btn btn-success',
48 | maxlength : 200,
49 | onerror: function(settings, self, xhr) {
50 | console.log("Error with status code: " + xhr.status);
51 | // reset the form
52 | self.reset();
53 | },
54 | label : 'This is a label',
55 | onreset : function() { console.log('Triggered before reset') },
56 | onblur : function() { console.log('Triggered on blur event');return true; },
57 | onsubmit : function() { console.log('Triggered before submit') },
58 | showfn : function(elem) { elem.fadeIn('slow') },
59 | submit : 'Save',
60 | submitdata : submitdata,
61 | /* submitdata as a function example
62 | submitdata : function(revert, settings, submitdata) {
63 | console.log("Revert text: " + revert);
64 | console.log(settings);
65 | console.log("User submitted text: " + submitdata.value);
66 | },
67 | */
68 | tooltip : "Click to edit...",
69 | width : 160
70 | });
71 |
72 |
73 | // NORMAL TEXTAREA
74 | $(".editable_textarea").editable("save.php", {
75 | type : 'textarea',
76 | submit : 'OK',
77 | cancelcssclass : 'btn btn-danger',
78 | submitcssclass : 'btn btn-success',
79 | cancel : 'Nope',
80 | width: 300
81 | });
82 |
83 | // INLINE SELECT
84 | $(".editable-select").editable("save.php", {
85 | type : "select",
86 | sortselectoptions: true,
87 | // custom class for the select element
88 | inputcssclass: 'some-class',
89 | // do nothing onBlur
90 | onblur: 'ignore',
91 | data : '{"Wiki":"Wiki","Banana":"Banana","Apple":"Apple", "Pear":"Pear", "selected":"Pear"}',
92 | submitdata : function() { return {id : 42, something: 'else'};},
93 | style : "inherit"
94 | });
95 | // INLINE SELECT WITH JSON
96 | $(".editable-select-json").editable("save.php", {
97 | type : "select",
98 | loadurl : "json.php",
99 | loadtext : "Fetching JSON…",
100 | submit : "OK",
101 | style : "inherit"
102 | });
103 | // MULTIPLE SELECT
104 | $(".multiple-select").editable("save.php", {
105 | type : "select",
106 | data : '{"Wiki":"Wiki","Banana":"Banana","Apple":"Apple", "Pear":"Pear"}',
107 | submit: 'OK',
108 | multiple : true,
109 | onblur: function() { return true; },
110 | // use intercept to display the results as we want it
111 | intercept: function(result, status) {
112 | return "You selected: " + result + ". ";
113 | },
114 | onerror: function(settings, self, xhr) {
115 | console.log("Error with status code: " + xhr.status);
116 | },
117 | submitdata : function(revert, settings, result) {
118 | console.log("User selected values: " + result.value);
119 | },
120 | });
121 |
122 | // DIFFERENT EVENTS
123 | // click
124 | $(".click").editable("save.php", {
125 | tooltip : "Click to edit...",
126 | style : "inherit"
127 | });
128 |
129 | // double click
130 | $(".dblclick").editable("save.php", {
131 | tooltip : "Doubleclick to edit...",
132 | event : "dblclick",
133 | style : "inherit"
134 | });
135 |
136 | // mouseover
137 | $(".mouseover").editable("save.php", {
138 | tooltip : "Move mouseover to edit...",
139 | event : "mouseover",
140 | style : "inherit"
141 | });
142 |
143 | // INTERCEPT
144 | // GET BACK JSON AND PROCESS IT BEFORE DISPLAY
145 | $(".intercept").editable("json2.php", {
146 | submit : 'OK',
147 | intercept : function(jsondata) {
148 | json = JSON.parse(jsondata);
149 | console.log(json.status);
150 | console.log(json.other);
151 | return json.result;
152 | },
153 | });
154 |
155 | // EMAIL
156 | $(".email").editable("save.php", {
157 | type: "email",
158 | tooltip: "Enter a valid email address",
159 | placeholder: "nico.tesla@example.com",
160 | });
161 | // NUMBER
162 | $(".number").editable("save.php", {
163 | type: "number",
164 | tooltip: "Click to edit: number",
165 | placeholder: "0",
166 | min: 0,
167 | max: 10,
168 | step: 1
169 | });
170 | // URL
171 | $(".url").editable("save.php", {
172 | type: "url",
173 | tooltip: "Enter a valid URL",
174 | placeholder: "https://www.example.com"
175 | });
176 |
177 |
178 | // CSS BUTTONS
179 | $(".css-buttons").editable("save.php", {
180 | submit : 'OK',
181 | cancel : 'Cancel',
182 | cssclass : 'custom-class',
183 | cancelcssclass : 'btn btn-danger',
184 | submitcssclass : 'btn btn-success',
185 | formid : 'abc-123'
186 | });
187 |
188 | // CHECKBOX
189 | $(".checkbox").editable("save.php", {
190 | type : "checkbox",
191 | submit : 'ok'
192 | });
193 |
194 | // CHAR COUNTER
195 | $(".charcounter").editable("save.php", {
196 | type : "charcounter",
197 | submit : 'OK',
198 | tooltip : "Click to edit...",
199 | onblur : "ignore",
200 | charcounter : {
201 | characters : 60
202 | }
203 | });
204 |
205 | // MASKED INPUT
206 | $(".masked").editable("save.php", {
207 | type : "masked",
208 | mask : "99/99/9999",
209 | submit : 'OK',
210 | tooltip : "Click to edit..."
211 | });
212 |
213 | // AUTOGROW
214 | $(".autogrow").editable("save.php", {
215 | type : "autogrow",
216 | submit : 'OK',
217 | cancel : 'cancel',
218 | tooltip : "Click to edit...",
219 | onblur : "ignore"
220 | });
221 | // DATEPICKER
222 | $(".datepicker").editable("save.php", {
223 | type : 'datepicker',
224 | datepicker : {
225 | format: "dd-mm-yy"
226 | },
227 | submit : 'OK',
228 | tooltip : "Click to edit..."
229 | });
230 | // TIME
231 | $(".timepicker").editable("save.php", {
232 | type : 'time',
233 | submit : 'OK',
234 | tooltip : "Click to edit..."
235 | });
236 |
237 | // Non existing element should not cause error
238 | $("#nosuch").editable("save.php", {
239 | type : 'textarea',
240 | submit : 'OK'
241 | });
242 |
243 | });
244 |
245 |
--------------------------------------------------------------------------------
/demos/js/prism.js:
--------------------------------------------------------------------------------
1 | /* PrismJS 1.11.0
2 | http://prismjs.com/download.html?themes=prism&languages=markup+clike+javascript */
3 | var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(\w+)\b/i,t=0,n=_self.Prism={manual:_self.Prism&&_self.Prism.manual,disableWorkerMessageHandler:_self.Prism&&_self.Prism.disableWorkerMessageHandler,util:{encode:function(e){return e instanceof r?new r(e.type,n.util.encode(e.content),e.alias):"Array"===n.util.type(e)?e.map(n.util.encode):e.replace(/&/g,"&").replace(/e.length)return;if(!(w instanceof s)){h.lastIndex=0;var _=h.exec(w),P=1;if(!_&&m&&b!=t.length-1){if(h.lastIndex=k,_=h.exec(e),!_)break;for(var A=_.index+(d?_[1].length:0),j=_.index+_[0].length,x=b,O=k,N=t.length;N>x&&(j>O||!t[x].type&&!t[x-1].greedy);++x)O+=t[x].length,A>=O&&(++b,k=O);if(t[b]instanceof s||t[x-1].greedy)continue;P=x-b,w=e.slice(k,O),_.index-=k}if(_){d&&(p=_[1].length);var A=_.index+p,_=_[0].slice(p),j=A+_.length,S=w.slice(0,A),C=w.slice(j),M=[b,P];S&&(++b,k+=S.length,M.push(S));var E=new s(g,f?n.tokenize(_,f):_,y,_,m);if(M.push(E),C&&M.push(C),Array.prototype.splice.apply(t,M),1!=P&&n.matchGrammar(e,t,r,b,k,!0,g),i)break}else if(i)break}}}}},tokenize:function(e,t){var r=[e],a=t.rest;if(a){for(var l in a)t[l]=a[l];delete t.rest}return n.matchGrammar(e,r,t,0,0,!1),r},hooks:{all:{},add:function(e,t){var r=n.hooks.all;r[e]=r[e]||[],r[e].push(t)},run:function(e,t){var r=n.hooks.all[e];if(r&&r.length)for(var a,l=0;a=r[l++];)a(t)}}},r=n.Token=function(e,t,n,r,a){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!a};if(r.stringify=function(e,t,a){if("string"==typeof e)return e;if("Array"===n.util.type(e))return e.map(function(n){return r.stringify(n,t,e)}).join("");var l={type:e.type,content:r.stringify(e.content,t,a),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:a};if(e.alias){var i="Array"===n.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(l.classes,i)}n.hooks.run("wrap",l);var o=Object.keys(l.attributes).map(function(e){return e+'="'+(l.attributes[e]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+l.tag+' class="'+l.classes.join(" ")+'"'+(o?" "+o:"")+">"+l.content+""+l.tag+">"},!_self.document)return _self.addEventListener?(n.disableWorkerMessageHandler||_self.addEventListener("message",function(e){var t=JSON.parse(e.data),r=t.language,a=t.code,l=t.immediateClose;_self.postMessage(n.highlight(a,n.languages[r],r)),l&&_self.close()},!1),_self.Prism):_self.Prism;var a=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return a&&(n.filename=a.src,n.manual||a.hasAttribute("data-manual")||("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(n.highlightAll):window.setTimeout(n.highlightAll,16):document.addEventListener("DOMContentLoaded",n.highlightAll))),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism);
4 | Prism.languages.markup={comment://,prolog:/<\?[\s\S]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/(^|[^\\])["']/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/?[\da-z]{1,8};/i},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))}),Prism.languages.xml=Prism.languages.markup,Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup;
5 | Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(?:true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/};
6 | Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\d*\.?\d+(?:[Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i,operator:/-[-=]?|\+[+=]?|!=?=?|<=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[[^\]\r\n]+]|\\.|[^\/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0},"function-variable":{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,alias:"function"}}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|[^\\`])*`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
58 |
59 |
Core features
60 |
<!-- include this in your HTML -->
61 | <script src=/path/to/jquery.jeditable.min.js></script>
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
Basic minimal example
70 |
The most basic example (press enter to validate). No options.
71 |
Click this text to edit it.
72 |
Show source code
73 |
74 |
$(".editable-text").editable("save.php");
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
Complete example
83 |
A more complete example with a bunch of options.
84 |
Click this text to edit it.
85 |
Show source code
86 |
87 |
/* data that will be sent along */
88 | var submitdata = {}
89 | /* this will make the save.php script take a long time so you can see the spinner ;) */
90 | submitdata['slow'] = true;
91 | submitdata['pwet'] = 'youpla';
92 |
93 | $(".editable-text-full").editable("save.php", {
94 | indicator : "<img src='img/spinner.svg' />",
95 | type : "text",
96 | // only limit to three letters example
97 | //pattern: "[A-Za-z]{3}",
98 | onedit : function() { console.log('If I return false edition will be canceled'); return true;},
99 | before : function() { console.log('Triggered before form appears')},
100 | callback : function(result, settings, submitdata) {
101 | console.log('Triggered after submit');
102 | console.log('Result: ' + result);
103 | console.log('Settings.width: ' + settings.width);
104 | console.log('Submitdata: ' + submitdata.pwet);
105 | },
106 | cancel : 'Cancel',
107 | cssclass : 'custom-class',
108 | cancelcssclass : 'btn btn-danger',
109 | submitcssclass : 'btn btn-success',
110 | maxlength : 200,
111 | // select all text
112 | select : true,
113 | label : 'This is a label',
114 | onreset : function() { console.log('Triggered before reset') },
115 | onsubmit : function() { console.log('Triggered before submit') },
116 | showfn : function(elem) { elem.fadeIn('slow') },
117 | submit : 'Save',
118 | submitdata : submitdata,
119 | /* submitdata as a function example
120 | submitdata : function(revert, settings, submitdata) {
121 | console.log("Revert text: " + revert);
122 | console.log(settings);
123 | console.log("User submitted text: " + submitdata.value);
124 | },
125 | */
126 | tooltip : "Click to edit...",
127 | width : 160
128 | });
129 |
130 | /* target as a function example
131 | $(".editable-text-full").editable(function(input, settings, elem) {
132 | console.log(input);
133 | console.log(settings);
134 | console.log($(elem).data('test'));
135 | }, {});
136 | */
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
Normal textarea
146 |
Example of the 'textarea' type.
147 |
If you click anywhere on this text, it will become a textarea that you can edit. And then you can click OK to save it.
148 |
149 |
Show source code
150 |
151 |
$(".editable_textarea").editable("save.php", {
152 | type : 'textarea',
153 | submit : 'OK',
154 | cancel : 'Nope'
155 | });
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
Select
164 |
Example of the 'select' type.
165 |
166 |
THIS IS A SELECT , click it to get a select menu. Options are from the "data" setting.
167 |
THIS IS A SELECT WITH JSON FEED , click it to get a select menu. Options are loaded from an ajax request getting JSON.
168 |
THIS IS A MULTIPLE SELECT. You can select several values (try holding Shift or Ctrl).
169 |
170 |
171 |
Show source code
172 |
173 |
// inline select
174 | $(".editable-select").editable("save.php", {
175 | type : "select",
176 | // this data will be sorted by value
177 | data : '{"Wiki":"Wiki","Banana":"Banana","Apple":"Apple", "Pear":"Pear", "selected":"Pear"}',
178 | submitdata : function() { return {id : 42, something: 'else'};},
179 | style : "inherit",
180 | });
181 | // with JSON feed
182 | $(".editable-select-json").editable("save.php", {
183 | type : "select",
184 | loadurl : "json.php",
185 | submit : "OK",
186 | style : "inherit"
187 | });
188 | // MULTIPLE SELECT
189 | $(".multiple-select").editable("save.php", {
190 | type : "select",
191 | data : '{"Wiki":"Wiki","Banana":"Banana","Apple":"Apple", "Pear":"Pear"}',
192 | submit: 'OK',
193 | multiple : true,
194 | onblur: function() { return true; },
195 | // use intercept to display the results as we want it
196 | intercept: function(result, status) {
197 | return "You selected: " + result + ". ";
198 | },
199 | onerror: function(settings, self, xhr) {
200 | console.log("Error with status code: " + xhr.status);
201 | },
202 | submitdata : function(revert, settings, result) {
203 | console.log("User selected values: " + result.value);
204 | },
205 | });
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
Different events
218 |
By default a click will trigger an edit. But you can bind other events as shown below.
219 |
220 | Click me if you dare! > or maybe you should
221 | doubleclick instead? Really lazy people can just
222 | mouseover me ...
223 |
224 |
Show source code
225 |
226 |
// click
227 | $(".click").editable("save.php", {
228 | tooltip : "Click to edit...",
229 | style : "inherit"
230 | });
231 |
232 | // double click
233 | $(".dblclick").editable("save.php", {
234 | tooltip : "Doubleclick to edit...",
235 | event : "dblclick",
236 | style : "inherit"
237 | });
238 |
239 | // mouseover
240 | $(".mouseover").editable("save.php", {
241 | tooltip : "Move mouseover to edit...",
242 | event : "mouseover",
243 | style : "inherit"
244 | });
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
Intercepting the data sent back
254 |
Useful if you want to process the returned data before it hits the page.
255 |
Click here to test the intercept option.
256 |
Show source code
257 |
258 |
$(".intercept").editable("json2.php", {
259 | submit : 'OK',
260 | intercept : function(jsondata) {
261 | json = JSON.parse(jsondata);
262 | console.log(json.status);
263 | console.log(json.other);
264 | return json.result;
265 | },
266 | });
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
E-mail, numbers, URL
277 |
You can restrict input to emails, numbers or urls
278 |
click@edit.me
279 |
-2.06
280 |
https://www.example.com
281 |
Show source code
282 |
283 |
// EMAIL
284 | $(".email").editable("save.php", {
285 | type: "email",
286 | tooltip: "Enter a valid email address",
287 | placeholder: "nico.tesla@example.com",
288 | });
289 | // NUMBER
290 | $(".number").editable("save.php", {
291 | type: "number",
292 | tooltip: "Click to edit: number",
293 | placeholder: "0",
294 | min: 0,
295 | max: 10,
296 | step: 1
297 | });
298 | // URL
299 | $(".url").editable("save.php", {
300 | type: "url",
301 | tooltip: "Enter a valid URL",
302 | placeholder: "https://www.example.com"
303 | });
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
Styling the buttons
314 |
If you want to use different css class for the submit and cancel button. Also show how to add an ID to the form.
315 |
Click here to show the buttons
316 |
Show source code
317 |
318 |
$(".css-buttons").editable("save.php", {
319 | submit : 'OK',
320 | cancel : 'Cancel',
321 | cssclass : 'custom-class',
322 | cancelcssclass : 'btn btn-danger',
323 | submitcssclass : 'btn btn-success',
324 | formid : 'abc-123'
325 | });
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
Checkbox
335 |
Click here to test checkbox input
336 |
Show source code
337 |
338 |
$(".checkbox").editable("save.php", {
339 | type : "checkbox",
340 | submit : 'ok'
341 | });
342 |
343 |
344 |
345 |
346 |
347 |
Features requiring plugins
348 |
349 |
350 |
351 |
352 |
Date Picker (requires jQuery-ui datepicker)
353 |
<!-- also include this in your HTML -->
354 | <script src=/path/to/jquery.jeditable.datepicker.min.js></script>
355 | <!-- also include jQuery-UI JS and CSS files -->
356 |
357 |
16-09-2018
358 |
Show source code
359 |
360 |
$(".datepicker").editable("save.php", {
361 | type : 'datepicker',
362 | submit : 'OK',
363 | datepicker : {
364 | format: "dd-mm-yy"
365 | },
366 | tooltip : "Click to edit..."
367 | });
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
Autogrow textarea
377 |
<!-- also include this in your HTML -->
378 | <script src=/path/to/jquery.jeditable.autogrow.min.js></script>
379 | <script src=/path/to/jquery.autogrowtextarea.js></script>
380 |
381 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
382 |
Depends on Autogrow-Textarea by Jevin O. Sewaruth.
383 |
Show source code
384 |
385 |
$(".autogrow").editable("save.php", {
386 | type : "autogrow",
387 | submit : 'OK',
388 | cancel : 'cancel',
389 | tooltip : "Click to edit...",
390 | onblur : "ignore"
391 | });
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
Masked Input
405 |
<!-- also include this in your HTML -->
406 | <script src=/path/to/jquery.jeditable.masked.min.js></script>
407 | <script src=/path/to/jquery.maskedinput.js></script>
408 |
409 |
19/12/2017
410 |
Depends on
411 | Masked Input by Josh Bush.
412 |
413 |
Show source code
414 |
415 |
$(".masked").editable("save.php", {
416 | type : "masked",
417 | mask : "99/99/9999",
418 | submit : 'OK',
419 | tooltip : "Click to edit..."
420 | });
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
Time Picker
431 |
<!-- also include this in your HTML -->
432 | <script src=/path/to/jquery.jeditable.time.min.js></script>
433 |
434 |
16:30
435 |
Show source code
436 |
437 |
$(".timepicker").editable("save.php", {
438 | type : 'time',
439 | submit : 'OK',
440 | tooltip : "Click to edit..."
441 | });
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
Character counter
451 |
<!-- also include this in your HTML -->
452 | <script src=/path/to/jquery.jeditable.charcounter.min.js></script>
453 | <script src=/path/to/jquery.charcounter.js></script>
454 |
455 |
The number of characters in the textarea will be counted.
456 |
Show source code
457 |
458 |
$(".charcounter").editable("save.php", {
459 | type : "charcounter",
460 | submit : 'OK',
461 | tooltip : "Click to edit...",
462 | onblur : "ignore",
463 | charcounter : {
464 | characters : 60
465 | }
466 | });
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |