From 2778630c7b7f6e450c2f9a1ce494fe9d19e2fb35 Mon Sep 17 00:00:00 2001 From: vitalets <noginsk@rambler.ru> Date: Tue, 2 Apr 2013 13:36:18 +0400 Subject: [PATCH] tests for datetimefield --- src/editable-form/editable-form-utils.js | 5 +++++ src/inputs/datetime/datetime.js | 6 +++++- src/inputs/datetime/datetimefield.js | 8 ++++---- test/main.js | 1 + test/unit/datefield.js | 4 ++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/editable-form/editable-form-utils.js b/src/editable-form/editable-form-utils.js index 89cff18..c8dedb7 100644 --- a/src/editable-form/editable-form-utils.js +++ b/src/editable-form/editable-form-utils.js @@ -195,6 +195,11 @@ type = 'combodate'; } } + + //`datetime` should be datetimefield in 'inline' mode + if(type === 'datetime' && options.mode === 'inline') { + type = 'datetimefield'; + } //change wysihtml5 to textarea for jquery UI and plain versions if(type === 'wysihtml5' && !$.fn.editabletypes[type]) { diff --git a/src/inputs/datetime/datetime.js b/src/inputs/datetime/datetime.js index 2a9cd9e..50b6ca6 100644 --- a/src/inputs/datetime/datetime.js +++ b/src/inputs/datetime/datetime.js @@ -80,7 +80,11 @@ $(function(){ value2html: function(value, element) { //formatDate works with UTCDate! var text = value ? this.dpg.formatDate(this.toUTC(value), this.parsedViewFormat, this.options.datetimepicker.language, this.options.formatType) : ''; - DateTime.superclass.value2html(text, element); + if(element) { + DateTime.superclass.value2html(text, element); + } else { + return text; + } }, html2value: function(html) { diff --git a/src/inputs/datetime/datetimefield.js b/src/inputs/datetime/datetimefield.js index a12f268..d8c93a6 100644 --- a/src/inputs/datetime/datetimefield.js +++ b/src/inputs/datetime/datetimefield.js @@ -34,10 +34,10 @@ Automatically shown in inline mode. }, this)); }, - + value2input: function(value) { - this.$input.val(value ? this.dpg.formatDate(value, this.parsedViewFormat, this.options.datepicker.language) : ''); - this.$tpl.datepicker('update'); + this.$input.val(this.value2html(value)); + this.$tpl.datetimepicker('update'); }, input2value: function() { @@ -62,7 +62,7 @@ Automatically shown in inline mode. @property inputclass @default 'input-small' **/ - inputclass: 'input-small', + inputclass: 'input-medium', /* datetimepicker config */ datetimepicker:{ diff --git a/test/main.js b/test/main.js index 775112b..8d91fb5 100644 --- a/test/main.js +++ b/test/main.js @@ -38,6 +38,7 @@ require(["loader", jqurl], function(loader) { case 'bootstrap': custom = ['test/unit/datefield', 'test/unit/date', + 'test/unit/datetimefield', 'test/unit/datetime', 'test/unit/wysihtml5', 'test/unit/typeahead' diff --git a/test/unit/datefield.js b/test/unit/datefield.js index 93380db..8433e1d 100644 --- a/test/unit/datefield.js +++ b/test/unit/datefield.js @@ -50,8 +50,8 @@ $(function () { equal(p.find('input').val(), d, 'date set correct'); //open picker - p.find('span').click(); - var picker = p.find('span').parent().data().datepicker.picker; + p.find('span.add-on').click(); + var picker = p.find('span.add-on').parent().data().datepicker.picker; ok(picker.is(':visible'), 'picker shown'); ok(picker.find('td.day.active').is(':visible'), 'active day is visible');