diff --git a/js/scheduler.js b/js/scheduler.js index 0661bd219..d36b65e37 100644 --- a/js/scheduler.js +++ b/js/scheduler.js @@ -515,7 +515,7 @@ item.find('label').removeClass('active'); temp = recur.BYDAY.split(','); for (i = 0, l = temp.length; i < l; i++) { - item.find('input[data-value="' + temp[i] + '"]').parent().addClass('active'); + item.find('input[data-value="' + temp[i] + '"]').prop('checked',true).parent().addClass('active'); } } @@ -525,12 +525,12 @@ this.$element.find('.repeat-monthly label.radio-custom').removeClass('checked'); if (recur.BYMONTHDAY) { temp = this.$element.find('.repeat-monthly-date'); - temp.find('input').addClass('checked').attr('checked', 'checked'); + temp.find('input').addClass('checked').prop('checked', true); temp.find('label.radio-custom').addClass('checked'); temp.find('.selectlist').selectlist('selectByValue', recur.BYMONTHDAY); } else if (recur.BYDAY) { temp = this.$element.find('.repeat-monthly-day'); - temp.find('input').addClass('checked').attr('checked', 'checked'); + temp.find('input').addClass('checked').prop('checked', true); temp.find('label.radio-custom').addClass('checked'); if (recur.BYSETPOS) { temp.find('.month-day-pos').selectlist('selectByValue', recur.BYSETPOS); @@ -545,7 +545,7 @@ this.$element.find('.repeat-yearly label.radio-custom').removeClass('checked'); if (recur.BYMONTHDAY) { temp = this.$element.find('.repeat-yearly-date'); - temp.find('input').addClass('checked').attr('checked', 'checked'); + temp.find('input').addClass('checked').prop('checked', true); temp.find('label.radio-custom').addClass('checked'); if (recur.BYMONTH) { temp.find('.year-month').selectlist('selectByValue', recur.BYMONTH); @@ -554,7 +554,7 @@ temp.find('.year-month-day').selectlist('selectByValue', recur.BYMONTHDAY); } else if (recur.BYSETPOS) { temp = this.$element.find('.repeat-yearly-day'); - temp.find('input').addClass('checked').attr('checked', 'checked'); + temp.find('input').addClass('checked').prop('checked', true); temp.find('label.radio-custom').addClass('checked'); temp.find('.year-month-day-pos').selectlist('selectByValue', recur.BYSETPOS); if (recur.BYDAY) { diff --git a/test/scheduler-test.js b/test/scheduler-test.js index 71475b445..297022d01 100644 --- a/test/scheduler-test.js +++ b/test/scheduler-test.js @@ -5,6 +5,8 @@ define(function(require){ var $ = require('jquery'); var html = require('text!test/markup/scheduler-markup.html'); + var templateHtml = html; + /* FOR DEV TESTING */ // html = require('text!index.html!strip'); html = $('
'+html+'
').find('#MyScheduler'); @@ -177,6 +179,11 @@ define(function(require){ test = (test.find('[data-value="MO"]').parent().hasClass('active') && test.find('[data-value="TH"]').parent().hasClass('active')) ? true : false; ok(($repIntSelDrop.html()==='Weekly' && $repPanSpinbox.spinbox('value')==='7' && test), 'weekly recurrence set correctly'); + $scheduler.scheduler('value', { recurrencePattern: 'FREQ=WEEKLY;BYDAY=MO,TH;' }); + test = $scheduler.find('.repeat-days-of-the-week .btn-group'); + ok(test.find('[data-value="MO"]').is(':checked'), 'weekly recurrence option set correctly with "checked" attribute'); + ok(test.find('[data-value="TH"]').is(':checked'), 'weekly recurrence option set correctly with "checked" attribute'); + $scheduler.scheduler('value', { recurrencePattern: 'FREQ=MONTHLY;INTERVAL=9;BYDAY=SA;BYSETPOS=4;' }); test = $scheduler.find('.repeat-monthly-day'); ok(($repIntSelDrop.html()==='Monthly' && $repPanSpinbox.spinbox('value')==='9' && test.find('div.radio input').hasClass('checked') && @@ -212,6 +219,24 @@ define(function(require){ // } }); + test('should set/get recurrence pattern properly', function() { + var schedule = { + startDateTime: '2014-03-31T03:23+02:00', + timeZone: { + offset: '+02:00' + }, + recurrencePattern: 'FREQ=WEEKLY;BYDAY=WE;INTERVAL=1;' + }; + + // note: currently, the scheduler doesn't reset it's markup/state + // when setValue is called. so ensure we're starting with initial template markup + // that hasn't been altered by another unit test + var $scheduler = $('
'+templateHtml+'
').find('#MyScheduler').scheduler(); + $scheduler.scheduler('value', schedule); + + equal($scheduler.scheduler('value').recurrencePattern, schedule.recurrencePattern, 'schedule set correctly'); + }); + // TODO: need more end date test or dry out code where start and end use same methods test('should initialize with end date provided', function() {