From 6099e5176d21882a483bee75984c9e53e9611393 Mon Sep 17 00:00:00 2001 From: Georgi Kostov <p_e_a@gbg.bg> Date: Fri, 21 Mar 2014 16:50:06 +0200 Subject: [PATCH 1/2] added Slider editor --- src/inputs-ext/slider/slider.js | 78 +++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/inputs-ext/slider/slider.js diff --git a/src/inputs-ext/slider/slider.js b/src/inputs-ext/slider/slider.js new file mode 100644 index 0000000..2f3a7e8 --- /dev/null +++ b/src/inputs-ext/slider/slider.js @@ -0,0 +1,78 @@ +/** +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); + +// // copy `input-sm | input-lg` classes to placeholder input +// if($.fn.editableform.engine === 'bs3') { +// if(this.$input.hasClass('input-sm')) { +// this.$input.siblings('input.tt-hint').addClass('input-sm'); +// } +// if(this.$input.hasClass('input-lg')) { +// this.$input.siblings('input.tt-hint').addClass('input-lg'); +// } +// } + }, + + 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)); \ No newline at end of file From c2e64bc98971e2f3ea2bba31b76710d5aaad995d Mon Sep 17 00:00:00 2001 From: Georgi Kostov <p_e_a@gbg.bg> Date: Fri, 5 Feb 2016 09:40:05 +0200 Subject: [PATCH 2/2] removed commented out code --- src/inputs-ext/slider/slider.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/inputs-ext/slider/slider.js b/src/inputs-ext/slider/slider.js index 2f3a7e8..35d3dff 100644 --- a/src/inputs-ext/slider/slider.js +++ b/src/inputs-ext/slider/slider.js @@ -34,16 +34,6 @@ Make sure to include the plugin's code before using this editor. // apply slider this.$input.slider(this.options.slider); - -// // copy `input-sm | input-lg` classes to placeholder input -// if($.fn.editableform.engine === 'bs3') { -// if(this.$input.hasClass('input-sm')) { -// this.$input.siblings('input.tt-hint').addClass('input-sm'); -// } -// if(this.$input.hasClass('input-lg')) { -// this.$input.siblings('input.tt-hint').addClass('input-lg'); -// } -// } }, value2input: function(value) {