').append($label).appendTo(this.$tpl);
}
+
+ this.$input = this.$tpl.find('input[type="checkbox"]');
+ if(this.options.inputclass) {
+ this.$input.addClass(this.options.inputclass);
+ }
},
value2str: function(value) {
@@ -66,10 +71,9 @@ $(function(){
//set checked on required checkboxes
value2input: function(value) {
- var $checks = this.$input.find('input[type="checkbox"]');
- $checks.removeAttr('checked');
+ this.$input.removeAttr('checked');
if($.isArray(value) && value.length) {
- $checks.each(function(i, el) {
+ this.$input.each(function(i, el) {
var $el = $(el);
// cannot use $.inArray as it performs strict comparison
$.each(value, function(j, val){
@@ -85,7 +89,7 @@ $(function(){
input2value: function() {
var checked = [];
- this.$input.find('input:checked').each(function(i, el) {
+ this.$input.filter(':checked').each(function(i, el) {
checked.push($(el).val());
});
return checked;
@@ -105,11 +109,11 @@ $(function(){
},
activate: function() {
- this.$input.find('input[type="checkbox"]').first().focus();
+ this.$input.first().focus();
},
autosubmit: function() {
- this.$input.find('input[type="checkbox"]').on('keydown', function(e){
+ this.$input.on('keydown', function(e){
if (e.which === 13) {
$(this).closest('form').submit();
}
@@ -122,14 +126,14 @@ $(function(){
@property tpl
@default
',
/**
@property inputclass
@type string
- @default editable-checklist
+ @default
**/
- inputclass: 'editable-checklist',
+ inputclass: '',
/**
Separator of values when reading from 'data-value' string
diff --git a/src/inputs/date/date.js b/src/inputs/date/date.js
index 4d6d8b3..fe68def 100644
--- a/src/inputs/date/date.js
+++ b/src/inputs/date/date.js
@@ -60,14 +60,19 @@ $(function(){
render: function () {
Date.superclass.render.call(this);
this.$input.datepicker(this.options.datepicker);
-
+ },
+
+ postrender: function() {
+ //"clear" link
if(this.options.clear) {
this.$clear = $('
').html(this.options.clear).click($.proxy(function(e){
e.preventDefault();
e.stopPropagation();
this.clear();
}, this));
- }
+
+ this.$tpl.parent().append($('
').append(this.$clear));
+ }
},
value2html: function(value, element) {
@@ -123,12 +128,12 @@ $(function(){
@property tpl
@default
**/
- tpl:'
',
+ tpl:'
',
/**
@property inputclass
- @default editable-date well
+ @default
**/
- inputclass: 'editable-date well',
+ inputclass: '',
/**
Format used for sending value to server. Also applied when converting date from
data-value attribute.
Possible tokens are:
d, dd, m, mm, yy, yyyy
diff --git a/src/inputs/date/datefield.js b/src/inputs/date/datefield.js
index dc9c8d6..fd9d495 100644
--- a/src/inputs/date/datefield.js
+++ b/src/inputs/date/datefield.js
@@ -14,44 +14,41 @@ Automatically shown in inline mode.
$.extend(DateField.prototype, {
render: function () {
- this.$input = $(this.options.tpl);
- this.$field = this.$input.find('input');
+ this.$tpl = $(this.options.tpl);
+ this.$input = this.$tpl.find('input');
if(this.options.inputclass) {
- this.$field.addClass(this.options.inputclass);
+ this.$input.addClass(this.options.inputclass);
}
if (this.options.placeholder) {
- this.$field.attr('placeholder', this.options.placeholder);
+ this.$input.attr('placeholder', this.options.placeholder);
}
- this.$input.datepicker(this.options.datepicker);
+ this.$tpl.datepicker(this.options.datepicker);
//need to disable original event handlers
- this.$field.off('focus keydown');
+ this.$input.off('focus keydown');
//update value of datepicker
- this.$field.keyup($.proxy(function(){
- this.$input.removeData('date');
- this.$input.datepicker('update');
+ this.$input.keyup($.proxy(function(){
+ this.$tpl.removeData('date');
+ this.$tpl.datepicker('update');
}, this));
},
value2input: function(value) {
- this.$field.val(value ? this.dpg.formatDate(value, this.parsedViewFormat, this.options.datepicker.language) : '');
- this.$input.datepicker('update');
+ this.$input.val(value ? this.dpg.formatDate(value, this.parsedViewFormat, this.options.datepicker.language) : '');
+ this.$tpl.datepicker('update');
},
input2value: function() {
- return this.html2value(this.$field.val());
+ return this.html2value(this.$input.val());
},
activate: function() {
- if(this.$field.is(':visible')) {
- this.$field.focus();
- $.fn.editableutils.setCursorPosition(this.$field.get(0), this.$field.val().length);
- }
+ $.fn.editabletypes.text.prototype.activate.call(this);
},
autosubmit: function() {
@@ -64,12 +61,12 @@ Automatically shown in inline mode.
@property tpl
@default
**/
- tpl:'
',
+ tpl:'
',
/**
@property inputclass
- @default ''
+ @default 'input-small'
**/
- inputclass: '',
+ inputclass: 'input-small',
/* datepicker config */
datepicker: {
diff --git a/src/inputs/dateui/dateui.js b/src/inputs/dateui/dateui.js
index 674a16e..cace358 100644
--- a/src/inputs/dateui/dateui.js
+++ b/src/inputs/dateui/dateui.js
@@ -52,15 +52,20 @@ $(function(){
render: function () {
DateUI.superclass.render.call(this);
this.$input.datepicker(this.options.datepicker);
-
+ },
+
+ postrender: function() {
+ //"clear" link
if(this.options.clear) {
this.$clear = $('
').html(this.options.clear).click($.proxy(function(e){
e.preventDefault();
e.stopPropagation();
this.clear();
}, this));
+
+ this.$tpl.parent().append($('
').append(this.$clear));
}
- },
+ },
value2html: function(value, element) {
var text = $.datepicker.formatDate(this.options.viewformat, value);
@@ -134,12 +139,12 @@ $(function(){
@property tpl
@default
**/
- tpl:'
',
+ tpl:'
',
/**
@property inputclass
- @default 'editable-date'
+ @default ''
**/
- inputclass: 'editable-date',
+ inputclass: '',
/**
Format used for sending value to server. Also applied when converting date from
data-value attribute.
Full list of tokens: http://docs.jquery.com/UI/Datepicker/formatDate
diff --git a/src/inputs/dateui/dateuifield.js b/src/inputs/dateui/dateuifield.js
index d219484..d3e656d 100644
--- a/src/inputs/dateui/dateuifield.js
+++ b/src/inputs/dateui/dateuifield.js
@@ -14,9 +14,9 @@ Automatically shown in inline mode.
$.extend(DateUIField.prototype, {
render: function () {
- $.fn.editabletypes.dateui.superclass.render.call(this);
- this.$field = this.$input.find('input');
- this.$field.datepicker(this.options.datepicker);
+ this.$tpl = $(this.options.tpl);
+ this.$input = this.$tpl.find('input');
+ this.$input.datepicker(this.options.datepicker);
/*
if(this.options.clear) {
@@ -30,18 +30,15 @@ Automatically shown in inline mode.
},
value2input: function(value) {
- this.$field.val($.datepicker.formatDate(this.options.viewformat, value));
+ this.$input.val($.datepicker.formatDate(this.options.viewformat, value));
},
input2value: function() {
- return this.html2value(this.$field.val());
+ return this.html2value(this.$input.val());
},
activate: function() {
- if(this.$field.is(':visible')) {
- this.$field.focus();
- $.fn.editableutils.setCursorPosition(this.$field.get(0), this.$field.val().length);
- }
+ $.fn.editabletypes.text.prototype.activate.call(this);
},
autosubmit: function() {
diff --git a/src/inputs/html5types.js b/src/inputs/html5types.js
index e71017f..7a55842 100644
--- a/src/inputs/html5types.js
+++ b/src/inputs/html5types.js
@@ -155,29 +155,29 @@ Range (inherit from number)
$.fn.editableutils.inherit(Range, $.fn.editabletypes.number);
$.extend(Range.prototype, {
render: function () {
- this.$input = $(this.options.tpl);
- var $slider = this.$input.filter('input');
+ this.$tpl = $(this.options.tpl);
+ this.$input = this.$tpl.filter('input');
if(this.options.inputclass) {
- $slider.addClass(this.options.inputclass);
+ this.$input.addClass(this.options.inputclass);
}
if (this.options.min !== null) {
- $slider.attr('min', this.options.min);
+ this.$input.attr('min', this.options.min);
}
if (this.options.max !== null) {
- $slider.attr('max', this.options.max);
+ this.$input.attr('max', this.options.max);
}
if (this.options.step !== null) {
- $slider.attr('step', this.options.step);
+ this.$input.attr('step', this.options.step);
}
- $slider.on('input', function(){
+ this.$input.on('input', function(){
$(this).siblings('output').text($(this).val());
});
},
activate: function() {
- this.$input.filter('input').focus();
+ this.$input.focus();
}
});
Range.defaults = $.extend({}, $.fn.editabletypes.number.defaults, {
diff --git a/src/inputs/list.js b/src/inputs/list.js
index e5b7ba9..5c87220 100644
--- a/src/inputs/list.js
+++ b/src/inputs/list.js
@@ -14,8 +14,9 @@ List - abstract class for inputs that have source option loaded from js array or
$.extend(List.prototype, {
render: function () {
- List.superclass.render.call(this);
var deferred = $.Deferred();
+ this.$tpl = $(this.options.tpl);
+ this.$input = this.$tpl; //will be set in renderList
this.error = null;
this.sourceData = null;
this.prependData = null;
diff --git a/src/inputs/select.js b/src/inputs/select.js
index b4d3048..c4120aa 100644
--- a/src/inputs/select.js
+++ b/src/inputs/select.js
@@ -35,9 +35,13 @@ $(function(){
}
for(var i=0; i
', {value: this.sourceData[i].value}).text(this.sourceData[i].text));
+ this.$tpl.append($('