/*jslint regexp: false, continue: true, indent: 4 */ /*global $, alert, jQuery */ "use strict"; (function ($) { $.tools = $.tools || {version: '@VERSION'}; $.views.settings.debugMode(true); var tool; var LABELS = {}; tool = $.tools.recurrenceinput = { conf: { lang: 'en', readOnly: false, firstDay: 0, // "REMOTE" FIELD startField: null, startFieldYear: null, startFieldMonth: null, startFieldDay: null, ajaxURL: null, ajaxContentType: 'application/json; charset=utf8', ributtonExtraClass: '', // INPUT CONFIGURATION hasRepeatForeverButton: true, // FORM OVERLAY formOverlay: { speed: 'fast', fixed: false }, // JQUERY TEMPLATE NAMES template: { form: '#jquery-recurrenceinput-form-tmpl', display: '#jquery-recurrenceinput-display-tmpl' }, // RECURRENCE TEMPLATES rtemplate: { daily: { rrule: 'FREQ=DAILY', fields: [ 'ridailyinterval', 'rirangeoptions' ] }, mondayfriday: { rrule: 'FREQ=WEEKLY;BYDAY=MO,FR', fields: [ 'rirangeoptions' ] }, weekdays: { rrule: 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR', fields: [ 'rirangeoptions' ] }, weekly: { rrule: 'FREQ=WEEKLY', fields: [ 'riweeklyinterval', 'riweeklyweekdays', 'rirangeoptions' ] }, monthly: { rrule: 'FREQ=MONTHLY', fields: [ 'rimonthlyinterval', 'rimonthlyoptions', 'rirangeoptions' ] }, yearly: { rrule: 'FREQ=YEARLY', fields: [ 'riyearlyinterval', 'riyearlyoptions', 'rirangeoptions' ] } } }, localize: function (language, labels) { LABELS[language] = labels; }, setTemplates: function (templates, titles) { var lang, template; tool.conf.rtemplate = templates; for (lang in titles) { if (titles.hasOwnProperty(lang)) { for (template in titles[lang]) { if (titles[lang].hasOwnProperty(template)) { LABELS[lang].rtemplate[template] = titles[lang][template]; } } } } } }; tool.localize("en", { displayUnactivate: 'Does not repeat', displayActivate: 'Repeats every', add_rules: 'Add', edit_rules: 'Edit', delete_rules: 'Delete', add: 'Add', refresh: 'Refresh', title: 'Repeat', preview: 'Selected dates', addDate: 'Add date', recurrenceType: 'Repeats:', dailyInterval1: 'Repeat every:', dailyInterval2: 'days', weeklyInterval1: 'Repeat every:', weeklyInterval2: 'week(s)', weeklyWeekdays: 'Repeat on:', weeklyWeekdaysHuman: 'on:', monthlyInterval1: 'Repeat every:', monthlyInterval2: 'month(s)', monthlyDayOfMonth1: 'Day', monthlyDayOfMonth1Human: 'on day', monthlyDayOfMonth2: 'of the month', monthlyDayOfMonth3: 'month(s)', monthlyWeekdayOfMonth1: 'The', monthlyWeekdayOfMonth1Human: 'on the', monthlyWeekdayOfMonth2: '', monthlyWeekdayOfMonth3: 'of the month', monthlyRepeatOn: 'Repeat on:', yearlyInterval1: 'Repeat every:', yearlyInterval2: 'year(s)', yearlyDayOfMonth1: 'Every', yearlyDayOfMonth1Human: 'on', yearlyDayOfMonth2: '', yearlyDayOfMonth3: '', yearlyWeekdayOfMonth1: 'The', yearlyWeekdayOfMonth1Human: 'on the', yearlyWeekdayOfMonth2: '', yearlyWeekdayOfMonth3: 'of', yearlyWeekdayOfMonth4: '', yearlyRepeatOn: 'Repeat on:', range: 'End recurrence:', rangeNoEnd: 'Never', rangeByOccurrences1: 'After', rangeByOccurrences1Human: 'ends after', rangeByOccurrences2: 'occurrence(s)', rangeByEndDate: 'On', rangeByEndDateHuman: 'ends on', including: ', and also', except: ', except for', cancel: 'Cancel', save: 'Save', recurrenceStart: 'Start of the recurrence', additionalDate: 'Additional date', include: 'Include', exclude: 'Exclude', remove: 'Remove', orderIndexes: ['first', 'second', 'third', 'fourth', 'last'], months: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], shortMonths: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], weekdays: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], shortWeekdays: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], longDateFormat: 'mmmm dd, yyyy', shortDateFormat: 'mm/dd/yyyy', unsupportedFeatures: 'Warning: This event uses recurrence features not ' + 'supported by this widget. Saving the recurrence ' + 'may change the recurrence in unintended ways:', noTemplateMatch: 'No matching recurrence template', multipleDayOfMonth: 'This widget does not support multiple days in monthly or yearly recurrence', bysetpos: 'BYSETPOS is not supported', noRule: 'No RRULE in RRULE data', noRepeatEvery: 'Error: The "Repeat every"-field must be between 1 and 1000', noEndDate: 'Error: End date is not set. Please set a correct value', noRepeatOn: 'Error: "Repeat on"-value must be selected', pastEndDate: 'Error: End date cannot be before start date', noEndAfterNOccurrences: 'Error: The "After N occurrences"-field must be between 1 and 1000', alreadyAdded: 'This date was already added', rtemplate: { daily: 'Daily', mondayfriday: 'Monday and Friday', weekdays: 'Weekday', weekly: 'Weekly', monthly: 'Monthly', yearly: 'Yearly' } }); var OCCURRENCETMPL = ['
', '{{for occurrences}}', '
', '', '{{:formattedDate}}', '{{if type === "start"}}', '{{:~root.i18n.recurrenceStart}}', '{{/if}}', '{{if type === "rdate"}}', '{{:~root.i18n.additionalDate}}', '{{/if}}', '', '{{if !~root.readOnly}}', '', '{{if type === "rrule"}}', '', '{{:~root.i18n.exclude}}', '', '{{/if}}', '{{if type === "rdate"}}', '', '{{:~root.i18n.remove}}', '', '{{/if}}', '{{if type === "exdate"}}', '', '{{:~root.i18n.include}}', '', '{{/if}}', '', '{{/if}}', '
', '{{/for}}', '
', '{{for batch.batches}}', '{{if #getIndex() === ~root.batch.currentBatch}}{{/if}}', '[{{:~root.batch.batches[#getIndex()][0]}} - {{:~root.batch.batches[#getIndex()][1]}}]', '{{if #getIndex() === ~root.batch.currentBatch}}{{/if}}', '{{/for}}', '
'].join('\n'); $.templates('occurrenceTmpl', OCCURRENCETMPL); var DISPLAYTMPL = ['
', '
', '{{if !readOnly}}', '', '', '{{/if}}', '', '
', ''].join('\n'); $.templates('displayTmpl', DISPLAYTMPL); var FORMTMPL = ['