UNPKG

@narmafzam/jalali-datepicker

Version:

just a jalali-datepicker

63 lines (52 loc) 1.91 kB
let Config = require('./config'); let Constant = require('./constant'); let PersianDate = require('../../bower_components/persian-date/dist/persian-date'); class Options { constructor(options, model) { this.model = model; return this._compatibility( $.extend(true, this, Config, options) ); } _compatibility(options) { if (options.inline) { options.toolbox.submitButton.enabled = false; } if (!options.template) { options.template = Constant.TEMPLATE; } PersianDate.toCalendar(options.calendarType); PersianDate.toLocale(options.calendar[options.calendarType].locale); if (options.onlyTimePicker) { options.dayPicker.enabled = false; options.monthPicker.enabled = false; options.yearPicker.enabled = false; options.navigator.enabled = false; options.toolbox.enabled = false; options.timePicker.enabled = true; } if (options.timePicker.hour.step === null) { options.timePicker.hour.step = options.timePicker.step; } if (options.timePicker.minute.step === null) { options.timePicker.minute.step = options.timePicker.step; } if (options.timePicker.second.step === null) { options.timePicker.second.step = options.timePicker.step; } if (options.dayPicker.enabled === false) { options.onlySelectOnDate = false; } options._viewModeList = []; if (options.dayPicker.enabled) { options._viewModeList.push('day'); } if (options.monthPicker.enabled) { options._viewModeList.push('month'); } if (options.yearPicker.enabled) { options._viewModeList.push('year'); } } } module.exports = Options;