allow data-datepicker and data-datetimepicker, fix

This commit is contained in:
vitalets 2013-07-21 03:35:14 +04:00
parent 40e0a890a2
commit 0eb6a0ffff
4 changed files with 23 additions and 1 deletions
src/inputs
date
datetime
test/unit

@ -48,6 +48,9 @@ $(function(){
this.options.viewformat = this.options.format;
}
//try parse datepicker config defined as json string in data-datepicker
options.datepicker = $.fn.editableutils.tryParseJson(options.datepicker, true);
//overriding datepicker config (as by default jQuery extend() is not recursive)
//since 1.4 datepicker internally uses viewformat instead of format. Format is for submit only
this.options.datepicker = $.extend({}, defaults.datepicker, options.datepicker, {

@ -46,6 +46,9 @@ $(function(){
if(!this.options.viewformat) {
this.options.viewformat = this.options.format;
}
//try parse datetimepicker config defined as json string in data-datetimepicker
options.datetimepicker = $.fn.editableutils.tryParseJson(options.datetimepicker, true);
//overriding datetimepicker config (as by default jQuery extend() is not recursive)
//since 1.4 datetimepicker internally uses viewformat instead of format. Format is for submit only

@ -133,7 +133,14 @@ $(function () {
equal(frmt(e.data('editable').value, 'yyyy-mm-dd'), d, 'value correct');
equal(e.text(), dview, 'text correct');
});
});
test("datepicker options can be defined in data-datepicker string", function () {
var e = $('<a href="#" data-type="date" data-datepicker="{weekStart: 2}" data-pk="1" data-url="/post"></a>').appendTo('#qunit-fixture').editable({
});
equal(e.data('editable').input.options.datepicker.weekStart, 2, 'options applied correct');
});
test("input should contain today if element is empty", function () {

@ -140,6 +140,15 @@ $(function () {
});
test("datetimepicker options can be defined in data-datetimepicker string", function () {
var e = $('<a href="#" data-type="datetime" data-datetimepicker="{weekStart: 2}" data-pk="1" data-url="/post"></a>').appendTo('#qunit-fixture').editable({
});
equal(e.data('editable').input.options.datetimepicker.weekStart, 2, 'options applied correct');
});
test("viewformat, init by value", function () {
var dview = '15/05/1984 15:45',
d = '1984-05-15 15:45',