diff --git a/src/inputs/date/date.js b/src/inputs/date/date.js index 59052dc..20c1e49 100644 --- a/src/inputs/date/date.js +++ b/src/inputs/date/date.js @@ -26,7 +26,7 @@ $(function(){ this.init('date', options, Date.defaults); //set popular options directly from settings or data-* attributes - var directOptions = $.fn.editableform.utils.sliceObj(this.options, ['format', 'weekStart', 'startView']); + var directOptions = $.fn.editableform.utils.sliceObj(this.options, ['format']); //overriding datepicker config (as by default jQuery extend() is not recursive) this.options.datepicker = $.extend({}, Date.defaults.datepicker, directOptions, options.datepicker); diff --git a/src/inputs/dateui/dateui.js b/src/inputs/dateui/dateui.js index 35817d2..1399f66 100644 --- a/src/inputs/dateui/dateui.js +++ b/src/inputs/dateui/dateui.js @@ -26,7 +26,7 @@ $(function(){ this.init('dateui', options, DateUI.defaults); //set popular options directly from settings or data-* attributes - var directOptions = $.fn.editableform.utils.sliceObj(this.options, ['format', 'firstDay']); + var directOptions = $.fn.editableform.utils.sliceObj(this.options, ['format']); //overriding datepicker config (as by default jQuery extend() is not recursive) this.options.datepicker = $.extend({}, DateUI.defaults.datepicker, directOptions, options.datepicker); diff --git a/test/index.html b/test/index.html index 3bba295..c84c9d4 100644 --- a/test/index.html +++ b/test/index.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8"> - <title>Test Bootstrap Editable</title> + <title>Test X-editable</title> <!-- jquery --> <script src="../libs/jquery/jquery-1.8.2.js"></script> diff --git a/test/unit/date.js b/test/unit/date.js index da7843b..fec2cc7 100644 --- a/test/unit/date.js +++ b/test/unit/date.js @@ -16,8 +16,11 @@ $(function () { asyncTest("popover should contain datepicker with value and save new entered date", function () { expect(9); + + $.fn.editableform.types.date.defaults.datepicker.weekStart = 1; + var d = '15.05.1984', - e = $('<a href="#" data-type="date" data-pk="1" data-weekstart="1" data-url="post-date.php">'+d+'</a>').appendTo(fx).editable({ + e = $('<a href="#" data-type="date" data-pk="1" data-url="post-date.php">'+d+'</a>').appendTo(fx).editable({ format: f, datepicker: { @@ -57,9 +60,12 @@ $(function () { }); asyncTest("viewformat, init by text", function () { + + $.fn.editableform.types.date.defaults.datepicker.weekStart = 1; + var dview = '15/05/1984', d = '1984-05-15', - e = $('<a href="#" data-type="date" data-pk="1" data-weekstart="1" data-url="post-date1.php">'+dview+'</a>').appendTo(fx).editable({ + e = $('<a href="#" data-type="date" data-pk="1" data-url="post-date1.php">'+dview+'</a>').appendTo(fx).editable({ format: 'yyyy-mm-dd', viewformat: 'dd/mm/yyyy', datepicker: { diff --git a/test/unit/dateui.js b/test/unit/dateui.js index 1519ccd..1fc14fa 100644 --- a/test/unit/dateui.js +++ b/test/unit/dateui.js @@ -20,7 +20,9 @@ $(function () { e = $('<a href="#" data-type="date" data-pk="1" data-url="post-date.php">'+dview+'</a>').appendTo(fx).editable({ format: 'dd.mm.yyyy', viewformat: 'dd/mm/yyyy', - firstDay: 1 + datepicker: { + firstDay: 1 + } }), nextD = '16.05.1984', nextDview = '16/05/1984'; diff --git a/test/unit/select.js b/test/unit/select.js index 0646f23..d4c5e39 100644 --- a/test/unit/select.js +++ b/test/unit/select.js @@ -9,11 +9,15 @@ $(function () { 5: 'Admin', 6: '', '': 'Nothing' - }; + }; - window.size = 0; + //groups as array + window.groupsArr = []; + for(var i in groups) { + groupsArr.push({value: i, text: groups[i]}); + } - for (e in groups) { size++; } + window.size = groupsArr.length; $.mockjax({ url: 'groups.php', @@ -86,7 +90,25 @@ $(function () { ok(!p.is(':visible'), 'popover was removed'); }); - test("load options from native array", function () { + test("load options from normal array", function () { + var e = $('<a href="#" data-type="select" data-value="2" data-url="post.php">customer</a>').appendTo('#qunit-fixture').editable({ + pk: 1, + source: groupsArr, + placement: 'right' + }); + + e.click() + var p = tip(e); + ok(p.is(':visible'), 'popover visible'); + ok(p.find('select').length, 'select exists'); + equal(p.find('select').find('option').length, groupsArr.length, 'options loaded'); + equal(p.find('select').val(), e.data('editable').value, 'selected value correct'); + + p.find('button[type=button]').click(); + ok(!p.is(':visible'), 'popover was removed'); + }); + + test("load options from simple array", function () { var arr = ['q', 'w', 'x'], e = $('<a href="#" data-type="select" data-value="2" data-url="post.php">customer</a>').appendTo('#qunit-fixture').editable({ pk: 1,