/** Bootstrap-datepicker. Description and examples: https://github.com/eternicode/bootstrap-datepicker. For **i18n** you should include js file from here: https://github.com/eternicode/bootstrap-datepicker/tree/master/js/locales and set `language` option. Since 1.4.0 date has different appearance in **popup** and **inline** modes. @class date @extends abstractinput @final @example 15/05/1984 **/ (function ($) { "use strict"; var Date = function (options) { console.log('Date input constructor called'); this.init('date', options, Date.defaults); this.initPicker(options, Date.defaults); // Ensure type is set correctly this.type = 'date'; console.log('Date input initialized'); }; $.fn.editableutils.inherit(Date, $.fn.editabletypes.abstractinput); $.extend(Date.prototype, { prerender: function() { // Call parent prerender Date.superclass.prerender.call(this); }, initPicker: function(options, defaults) { //'format' is set directly from settings or data-* attributes //by default viewformat equals to format if(!this.options.viewformat) { 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, { format: this.options.viewformat }); //language this.options.datepicker.language = this.options.datepicker.language || 'en'; //store DPglobal - ensure bootstrap-datepicker is available if (!$.fn.datepicker || !$.fn.datepicker.DPGlobal) { console.error('Bootstrap-datepicker not found or DPGlobal not available'); console.error('Please include bootstrap-datepicker.js and bootstrap-datepicker.css in your page'); // Set error state instead of throwing this.error = 'Bootstrap-datepicker is required but not found. Please include bootstrap-datepicker.js and bootstrap-datepicker.css'; return; } this.dpg = $.fn.datepicker.DPGlobal; //store parsed formats this.parsedFormat = this.dpg.parseFormat(this.options.format); this.parsedViewFormat = this.dpg.parseFormat(this.options.viewformat); }, render: function () { console.log('Date render method called'); // Ensure we have an input element if (!this.$input || !this.$input.length) { console.log('Date render: No input element found'); return; } console.log('Date render: Input element found'); // Initialize datepicker immediately try { this.$input.datepicker(this.options.datepicker); console.log('Date render: Datepicker initialized'); // Force set the initial value if we have one if (this.value) { this.$input.datepicker('setDate', this.value); } } catch (error) { console.log('Date render: Datepicker error:', error); } // Use a more aggressive approach - hide buttons with multiple methods var self = this; setTimeout(function() { // Try multiple selectors to find buttons var $buttons = self.$form ? self.$form.find('.editable-buttons') : $(); if ($buttons.length === 0) { $buttons = self.$tpl.closest('.editableform').find('.editable-buttons'); } if ($buttons.length === 0) { $buttons = self.$tpl.closest('.editable-container').find('.editable-buttons'); } console.log('Date render: Found buttons:', $buttons.length); if ($buttons.length > 0) { $buttons.hide(); $buttons.css('display', 'none'); console.log('Date render: Hidden buttons'); } }, 100); //"clear" link if(this.options.clear) { this.$clear = $('').html(this.options.clear).click($.proxy(function(e){ e.preventDefault(); e.stopPropagation(); this.clear(); }, this)); this.$tpl.parent().append($('
data-value attribute.d, dd, m, mm, yy, yyyy
@property format
@type string
@default yyyy-mm-dd
**/
format:'yyyy-mm-dd',
/**
Format used for displaying date. Also applied when converting date from element's text on init.
If not specified equals to format
@property viewformat
@type string
@default null
**/
viewformat: null,
/**
Configuration of datepicker.
Full list of options: http://bootstrap-datepicker.readthedocs.org/en/latest/options.html
@property datepicker
@type object
@default {
weekStart: 0,
startView: 0,
minViewMode: 0,
autoclose: false
}
**/
datepicker:{
weekStart: 0,
startView: 0,
minViewMode: 0,
autoclose: false
},
/**
Text shown as clear date button.
If false clear button will not be rendered.
@property clear
@type boolean|string
@default 'x clear'
**/
clear: '× clear'
});
$.fn.editabletypes.date = Date;
}(window.jQuery));