<commit_before>'use strict';

!function($, m) {

    /**
     * Datepicker module.
     * @module foundation.datepicker
     * @requires foundation.util.keyboard
     * @requires foundation.util.box
     * @requires foundation.util.triggers
     */

    class Datepicker {
        /**
         * Creates a new instance of a datepicker.
         * @class
         * @param {jQuery} input - jQuery object to make into a datepicker.
         * @param {Object} options - Overrides to the default plugin settings.
         */
        constructor(input, options) {
            this.$input = input;
            this.options = $.extend({}, Datepicker.defaults, this.$input.data(), options);
            this._init();

            Foundation.registerPlugin(this, 'Datepicker');
            Foundation.Keyboard.register('Datepicker', {
                'ENTER': 'open',
                'ESCAPE': 'close',
                'TAB': 'tab_forward',
                'SHIFT_TAB': 'tab_backward'
            });

        }

        /**
         * Initializes the plugin by setting/checking options and attributes, adding helper variables, and saving the anchor.
         * @function
         * @private
         */
        _init() {
            var $id = Foundation.GetYoDigits(6, 'datepicker');

            this.$input.attr({
                'data-toggle': $id,
                'aria-controls': $id,
                'data-is-focus': false,
                'data-yeti-box': $id,
                'aria-haspopup': true,
                'aria-expanded': false

            });

            this.options.positionClass = this.getPositionClass();
            this.counter = 4;
            this.usedPositions = [];


            this.$element = $('<div class="datepicker-container"></div>');
            this.$input.after(this.$element);

            this.$element.attr({
                'id': $id,
                'aria-hidden': 'true',
                'data-yeti-box': $id,
                'data-resize': $id,
                'aria-labelledby': this.$input[0].id || Foundation.GetYoDigits(6, 'datepicker-input')
            });
            this.weekDaysHeader = this.buildWeekDaysheader();
            this._events();
            this.currentMonth = moment().date(1);
        }

        buildWeekDaysheader() {
            var weekDaysHeader = '';
            for (var i = this.options.weekstart; i < (this.options.weekstart + 7); i++) {
                var weekday = i;
                if (weekday > 6) weekday = weekday-7;
                var weekdayName = moment().day(weekday).format('ddd');
                weekDaysHeader+= m.render(this.options.weekdayHeaderTemplate, {
                    dayType: 'weekday-header',
                    day: weekdayName
                });
            }
            return weekDaysHeader;
        }

        buildCalender() {
            this.$element.html('');
            var date = this.$input.val() == '' ? moment() : moment(this.$input.val(), this.options.format, true);
            var monthViewModel = {
                month: this.currentMonth.format('MMMM'),
                weekdays: this.weekDaysHeader,
                days: this.buildCalenderDays(date)
            };

            var $calender = $(m.render(this.options.calenderTemplate, monthViewModel));

            $calender
                .on('click', '.months-nav > a', this.navigateMonths.bind(this))
                .on('click', '.day', this.selectDay.bind(this));

            this.$element.append($calender);
        }

        navigateMonths(e) {
            if ($(e.currentTarget).hasClass('calender-nav-next')) this.currentMonth.add(1,'month');
            if ($(e.currentTarget).hasClass('calender-nav-previous')) this.currentMonth.subtract(1,'month');
            this.buildCalender();
            return false;
        }

        selectDay(e) {
            this.$input.val($(e.currentTarget).data('date'));
            this.currentMonth = moment($(e.currentTarget).data('date'), this.options.format).date(1);
            this.close();
        }

        buildCalenderDays(date) {
            var days = '';
            var currentDate = moment(date.format('YYYY-MM-DD'));
            var first = moment(this.currentMonth.format('YYYY-MM-DD'));
            first.date(1);
            var last = first.clone();
            last.add(1, 'month').subtract(1, 'day');
            first.day(this.options.weekstart);
            if (last.day() != (this.options.weekstart-1)) last.day((this.options.weekstart - 1) +7);
            for (first; !first.isAfter(last.format('YYYY-MM-DD')); first.add(1, 'day')) {
                var dayType = first.isSame(
                    currentDate.format('YYYY-MM-DD'), 'day')
                    ? 'current'
                    : (first.isSame(this.currentMonth.format('YYYY-MM-DD'), 'month'))
                    ? (first.isSame(moment().format('YYYY-MM-DD'), 'day') ? 'same-month today' : 'same-month')
                    : 'other-month';

                days+= m.render(this.options.dayTemplate, {
                    dayType: dayType,
                    date: first.format(this.options.format),
                    day: first.date()
                });
            }
            return days;
        }

        /**
         * Helper function to determine current orientation of datepicker pane.
         * @function
         * @returns {String} position - string value of a position class.
         */
        getPositionClass() {
            var verticalPosition = this.$input[0].className.match(/(top|left|right|bottom)/g);
            verticalPosition = verticalPosition ? verticalPosition[0] : '';
            var horizontalPosition = /float-(\S+)\s/.exec(this.$input[0].className);
            horizontalPosition = horizontalPosition ? horizontalPosition[1] : '';
            var position = horizontalPosition ? horizontalPosition + ' ' + verticalPosition : verticalPosition;
            return position;
        }

        /**
         * Adjusts the datepicker panes orientation by adding/removing positioning classes.
         * @function
         * @private
         * @param {String} position - position class to remove.
         */
        _reposition(position) {
            this.usedPositions.push(position ? position : 'bottom');
            //default, try switching to opposite side
            if(!position && (this.usedPositions.indexOf('top') < 0)){
                this.$element.addClass('top');
            }else if(position === 'top' && (this.usedPositions.indexOf('bottom') < 0)){
                this.$element.removeClass(position);
            }else if(position === 'left' && (this.usedPositions.indexOf('right') < 0)){
                this.$element.removeClass(position)
                    .addClass('right');
            }else if(position === 'right' && (this.usedPositions.indexOf('left') < 0)){
                this.$element.removeClass(position)
                    .addClass('left');
            }

            //if default change didn't work, try bottom or left first
            else if(!position && (this.usedPositions.indexOf('top') > -1) && (this.usedPositions.indexOf('left') < 0)){
                this.$element.addClass('left');
            }else if(position === 'top' && (this.usedPositions.indexOf('bottom') > -1) && (this.usedPositions.indexOf('left') < 0)){
                this.$element.removeClass(position)
                    .addClass('left');
            }else if(position === 'left' && (this.usedPositions.indexOf('right') > -1) && (this.usedPositions.indexOf('bottom') < 0)){
                this.$element.removeClass(position);
            }else if(position === 'right' && (this.usedPositions.indexOf('left') > -1) && (this.usedPositions.indexOf('bottom') < 0)){
                this.$element.removeClass(position);
            }
            //if nothing cleared, set to bottom
            else{
                this.$element.removeClass(position);
            }
            this.classChanged = true;
            this.counter--;
        }

        /**
         * Sets the position and orientation of the datepicker pane, checks for collisions.
         * Recursively calls itself if a collision is detected, with a new position class.
         * @function
         * @private
         */
        _setPosition() {
            if(this.$input.attr('aria-expanded') === 'false'){ return false; }
            var position = this.getPositionClass(),
                $eleDims = Foundation.Box.GetDimensions(this.$element),
                $inputDims = Foundation.Box.GetDimensions(this.$input),
                _this = this,
                direction = (position === 'left' ? 'left' : ((position === 'right') ? 'left' : 'top')),
                param = (direction === 'top') ? 'height' : 'width',
                offset = (param === 'height') ? this.options.vOffset : this.options.hOffset;



            if(($eleDims.width >= $eleDims.windowDims.width) || (!this.counter && !Foundation.Box.ImNotTouchingYou(this.$element))){
                this.$element.offset(Foundation.Box.GetOffsets(this.$element, this.$input, 'center bottom', this.options.vOffset, this.options.hOffset, true)).css({
                    'width': $eleDims.windowDims.width - (this.options.hOffset * 2),
                    'height': 'auto'
                });
                this.classChanged = true;
                return false;
            }

            this.$element.offset(Foundation.Box.GetOffsets(this.$element, this.$input, position, this.options.vOffset, this.options.hOffset));

            while(!Foundation.Box.ImNotTouchingYou(this.$element, false, true) && this.counter){
                this._reposition(position);
                this._setPosition();
            }
        }

        /**
         * Adds event listeners to the element utilizing the triggers utility library.
         * @function
         * @private
         */
        _events() {
            var _this = this;
            this.$element.on({
                'open.zf.trigger': this.open.bind(this),
                'close.zf.trigger': this.close.bind(this),
                'toggle.zf.trigger': this.toggle.bind(this),
                'resizeme.zf.trigger': this._setPosition.bind(this)
            });
            this.$input.add(this.$element).on('keydown.zf.datepicker', function(e) {

                Foundation.Keyboard.handleKey(e, 'Datepicker', {
                    tab_forward: function() {
                        _this.close();
                    },
                    tab_backward: function() {
                        _this.close();
                    },
                    open: function() {
                        if ($target.is(_this.$input)) {
                            _this.open();
                            _this.$element.attr('tabindex', -1).focus();
                            e.preventDefault();
                        }
                    },
                    close: function() {
                        _this.close();
                        _this.$input.focus();
                    }
                });
            });
        }

        /**
         * Adds an event handler to the body to close any datepickers on a click.
         * @function
         * @private
         */
        _addBodyHandler() {
            var $body = $(document.body).not(this.$element),
                _this = this;
            $body.off('click.zf.datepicker')
                .on('click.zf.datepicker', function(e){
                    if(_this.$input.is(e.target) || _this.$input.find(e.target).length) {
                        return;
                    }
                    if(_this.$element.find(e.target).length) {
                        return;
                    }
                    _this.close();
                    $body.off('click.zf.datepicker');
                });
        }

        /**
         * Opens the datepicker pane, and fires a bubbling event to close other datepickers.
         * @function
         * @fires Datepicker#closeme
         * @fires Datepicker#show
         */
        open() {
            // var _this = this;
            /**
             * Fires to close other open datepickers
             * @event Datepicker#closeme
             */
            this.$element.trigger('closeme.zf.datepicker', this.$element.attr('id'));
            this.$input.attr({'aria-expanded': true});

            this._setPosition();
            this.$element.addClass('is-open')
                .attr({'aria-hidden': false});

            this.buildCalender();

            if(this.options.autoFocus){
                var $focusable = Foundation.Keyboard.findFocusable(this.$element);
                if($focusable.length){
                    $focusable.eq(0).focus();
                }
            }

            if(this.options.closeOnClick){ this._addBodyHandler(); }

            /**
             * Fires once the datepicker is visible.
             * @event Datepicker#show
             */
            this.$element.trigger('show.zf.datepicker', [this.$element]);
        }

        /**
         * Closes the open datepicker pane.
         * @function
         * @fires Datepicker#hide
         */
        close() {
            if(!this.$element.hasClass('is-open')){
                return false;
            }
            this.$element.removeClass('is-open')
                .attr({'aria-hidden': true});

            this.$input.attr('aria-expanded', false);

            if(this.classChanged){
                var curPositionClass = this.getPositionClass();
                if(curPositionClass){
                    this.$element.removeClass(curPositionClass);
                }
                this.$element
                    .addClass(this.options.positionClass)
                    .css({height: '', width: ''});
                this.classChanged = false;
                this.counter = 4;
                this.usedPositions.length = 0;
            }
            this.$element.trigger('hide.zf.datepicker', [this.$element]);
        }

        /**
         * Toggles the datepicker pane's visibility.
         * @function
         */
        toggle() {
            if(this.$element.hasClass('is-open')){
                this.close();
            }else{
                this.open();
            }
        }

        /**
         * Destroys the datepicker.
         * @function
         */
        destroy() {
            this.$element.off('.zf.trigger').hide();
            this.$input.off('.zf.datepicker');

            Foundation.unregisterPlugin(this);
        }
    }

    Datepicker.defaults = {
        /**
         * Number of pixels between the datepicker pane and the triggering element on open.
         * @option
         * @example 1
         */
        vOffset: 0,
        /**
         * Number of pixels between the datepicker pane and the triggering element on open.
         * @option
         * @example 1
         */
        hOffset: 0,
        /**
         * Class applied to adjust open position. JS will test and fill this in.
         * @option
         * @example 'top'
         */
        positionClass: '',
        /**
         * Allow the plugin to set focus to the first focusable element within the pane, regardless of method of opening.
         * @option
         * @example true
         */
        autoFocus: false,
        /**
         * Allows a click on the body to close the datepicker.
         * @option
         * @example false
         */
        closeOnClick: true,
        format: "DD/MM/YYYY",
        locale: 'en',
        weekstart: 1,
        calenderTemplate:
        '<div class="foudation-calender">' +
        '<div class="calender-header">' +
        '<div class="months-nav">' +
        '<a class="calender-nav-previous">' +
        '<i class="fa fa-chevron-left fi-arrow-left"></i>' +
        '</a>' +
        '<div>{{month}}</div>' +
        '<a class="calender-nav-next">' +
        '<i class="fa fa-chevron-right fi-arrow-right"></i>' +
        '</a>' +
        '</div>' +
        '<div class="weekdays row small-up-7 collapse">{{{weekdays}}}</div>' +
        '</div>' +
        '<div class="days row small-up-7 collapse">{{{days}}}</div>' +
        '</div>',
        weekdayHeaderTemplate:
            '<div class="column day {{dayType}}"><strong>{{day}}</strong></div>',
        dayTemplate:
            '<div class="column"><a class="day {{dayType}}" data-date="{{date}}">{{day}}</a></div>'
    };

// Window exports
    Foundation.plugin(Datepicker, 'Datepicker');

}(jQuery, Mustache);
<commit_msg>use dependencies as parameters, add year to header<commit_after>'use strict';

!function($, mu, mm) {

    /**
     * Datepicker module.
     * @module foundation.datepicker
     * @requires foundation.util.keyboard
     * @requires foundation.util.box
     * @requires foundation.util.triggers
     */

    class Datepicker {
        /**
         * Creates a new instance of a datepicker.
         * @class
         * @param {jQuery} input - jQuery object to make into a datepicker.
         * @param {Object} options - Overrides to the default plugin settings.
         */
        constructor(input, options) {
            this.$input = input;
            this.options = $.extend({}, Datepicker.defaults, this.$input.data(), options);
            this._init();

            Foundation.registerPlugin(this, 'Datepicker');
            Foundation.Keyboard.register('Datepicker', {
                'ENTER': 'open',
                'ESCAPE': 'close',
                'TAB': 'tab_forward',
                'SHIFT_TAB': 'tab_backward'
            });

        }

        /**
         * Initializes the plugin by setting/checking options and attributes, adding helper variables, and saving the anchor.
         * @function
         * @private
         */
        _init() {
            var $id = Foundation.GetYoDigits(6, 'datepicker');

            this.$input.attr({
                'data-toggle': $id,
                'aria-controls': $id,
                'data-is-focus': false,
                'data-yeti-box': $id,
                'aria-haspopup': true,
                'aria-expanded': false

            });

            this.options.positionClass = this.getPositionClass();
            this.counter = 4;
            this.usedPositions = [];


            this.$element = $('<div class="datepicker-container"></div>');
            this.$input.after(this.$element);

            this.$element.attr({
                'id': $id,
                'aria-hidden': 'true',
                'data-yeti-box': $id,
                'data-resize': $id,
                'aria-labelledby': this.$input[0].id || Foundation.GetYoDigits(6, 'datepicker-input')
            });
            this.weekDaysHeader = this.buildWeekDaysheader();
            this._events();
            this.currentMonth = mm().date(1);
        }

        buildWeekDaysheader() {
            var weekDaysHeader = '';
            for (var i = this.options.weekstart; i < (this.options.weekstart + 7); i++) {
                var weekday = i;
                if (weekday > 6) weekday = weekday-7;
                var weekdayName = mm().day(weekday).format('ddd');
                weekDaysHeader+= mu.render(this.options.weekdayHeaderTemplate, {
                    dayType: 'weekday-header',
                    day: weekdayName
                });
            }
            return weekDaysHeader;
        }

        buildCalender() {
            this.$element.html('');
            var date = this.$input.val() == '' ? mm() : mm(this.$input.val(), this.options.format, true);
            var monthViewModel = {
                month: this.currentMonth.format('MMMM YYYY'),
                weekdays: this.weekDaysHeader,
                days: this.buildCalenderDays(date)
            };

            var $calender = $(mu.render(this.options.calenderTemplate, monthViewModel));

            $calender
                .on('click', '.months-nav > a', this.navigateMonths.bind(this))
                .on('click', '.day', this.selectDay.bind(this));

            this.$element.append($calender);
        }

        navigateMonths(e) {
            if ($(e.currentTarget).hasClass('calender-nav-next')) this.currentMonth.add(1,'month');
            if ($(e.currentTarget).hasClass('calender-nav-previous')) this.currentMonth.subtract(1,'month');
            this.buildCalender();
            return false;
        }

        selectDay(e) {
            this.$input.val($(e.currentTarget).data('date'));
            this.currentMonth = mm($(e.currentTarget).data('date'), this.options.format).date(1);
            this.close();
        }

        buildCalenderDays(date) {
            var days = '';
            var currentDate = mm(date.format('YYYY-MM-DD'));
            var first = mm(this.currentMonth.format('YYYY-MM-DD'));
            first.date(1);
            var last = first.clone();
            last.add(1, 'month').subtract(1, 'day');
            first.day(this.options.weekstart);
            if (last.day() != (this.options.weekstart-1)) last.day((this.options.weekstart - 1) +7);
            for (first; !first.isAfter(last.format('YYYY-MM-DD')); first.add(1, 'day')) {
                var dayType = first.isSame(
                    currentDate.format('YYYY-MM-DD'), 'day')
                    ? 'current'
                    : (first.isSame(this.currentMonth.format('YYYY-MM-DD'), 'month'))
                    ? (first.isSame(mm().format('YYYY-MM-DD'), 'day') ? 'same-month today' : 'same-month')
                    : 'other-month';

                days+= mu.render(this.options.dayTemplate, {
                    dayType: dayType,
                    date: first.format(this.options.format),
                    day: first.date()
                });
            }
            return days;
        }

        /**
         * Helper function to determine current orientation of datepicker pane.
         * @function
         * @returns {String} position - string value of a position class.
         */
        getPositionClass() {
            var verticalPosition = this.$input[0].className.match(/(top|left|right|bottom)/g);
            verticalPosition = verticalPosition ? verticalPosition[0] : '';
            var horizontalPosition = /float-(\S+)\s/.exec(this.$input[0].className);
            horizontalPosition = horizontalPosition ? horizontalPosition[1] : '';
            var position = horizontalPosition ? horizontalPosition + ' ' + verticalPosition : verticalPosition;
            return position;
        }

        /**
         * Adjusts the datepicker panes orientation by adding/removing positioning classes.
         * @function
         * @private
         * @param {String} position - position class to remove.
         */
        _reposition(position) {
            this.usedPositions.push(position ? position : 'bottom');
            //default, try switching to opposite side
            if(!position && (this.usedPositions.indexOf('top') < 0)){
                this.$element.addClass('top');
            }else if(position === 'top' && (this.usedPositions.indexOf('bottom') < 0)){
                this.$element.removeClass(position);
            }else if(position === 'left' && (this.usedPositions.indexOf('right') < 0)){
                this.$element.removeClass(position)
                    .addClass('right');
            }else if(position === 'right' && (this.usedPositions.indexOf('left') < 0)){
                this.$element.removeClass(position)
                    .addClass('left');
            }

            //if default change didn't work, try bottom or left first
            else if(!position && (this.usedPositions.indexOf('top') > -1) && (this.usedPositions.indexOf('left') < 0)){
                this.$element.addClass('left');
            }else if(position === 'top' && (this.usedPositions.indexOf('bottom') > -1) && (this.usedPositions.indexOf('left') < 0)){
                this.$element.removeClass(position)
                    .addClass('left');
            }else if(position === 'left' && (this.usedPositions.indexOf('right') > -1) && (this.usedPositions.indexOf('bottom') < 0)){
                this.$element.removeClass(position);
            }else if(position === 'right' && (this.usedPositions.indexOf('left') > -1) && (this.usedPositions.indexOf('bottom') < 0)){
                this.$element.removeClass(position);
            }
            //if nothing cleared, set to bottom
            else{
                this.$element.removeClass(position);
            }
            this.classChanged = true;
            this.counter--;
        }

        /**
         * Sets the position and orientation of the datepicker pane, checks for collisions.
         * Recursively calls itself if a collision is detected, with a new position class.
         * @function
         * @private
         */
        _setPosition() {
            if(this.$input.attr('aria-expanded') === 'false'){ return false; }
            var position = this.getPositionClass(),
                $eleDims = Foundation.Box.GetDimensions(this.$element),
                $inputDims = Foundation.Box.GetDimensions(this.$input),
                _this = this,
                direction = (position === 'left' ? 'left' : ((position === 'right') ? 'left' : 'top')),
                param = (direction === 'top') ? 'height' : 'width',
                offset = (param === 'height') ? this.options.vOffset : this.options.hOffset;



            if(($eleDims.width >= $eleDims.windowDims.width) || (!this.counter && !Foundation.Box.ImNotTouchingYou(this.$element))){
                this.$element.offset(Foundation.Box.GetOffsets(this.$element, this.$input, 'center bottom', this.options.vOffset, this.options.hOffset, true)).css({
                    'width': $eleDims.windowDims.width - (this.options.hOffset * 2),
                    'height': 'auto'
                });
                this.classChanged = true;
                return false;
            }

            this.$element.offset(Foundation.Box.GetOffsets(this.$element, this.$input, position, this.options.vOffset, this.options.hOffset));

            while(!Foundation.Box.ImNotTouchingYou(this.$element, false, true) && this.counter){
                this._reposition(position);
                this._setPosition();
            }
        }

        /**
         * Adds event listeners to the element utilizing the triggers utility library.
         * @function
         * @private
         */
        _events() {
            var _this = this;
            this.$element.on({
                'open.zf.trigger': this.open.bind(this),
                'close.zf.trigger': this.close.bind(this),
                'toggle.zf.trigger': this.toggle.bind(this),
                'resizeme.zf.trigger': this._setPosition.bind(this)
            });
            this.$input.add(this.$element).on('keydown.zf.datepicker', function(e) {

                Foundation.Keyboard.handleKey(e, 'Datepicker', {
                    tab_forward: function() {
                        _this.close();
                    },
                    tab_backward: function() {
                        _this.close();
                    },
                    open: function() {
                        if ($target.is(_this.$input)) {
                            _this.open();
                            _this.$element.attr('tabindex', -1).focus();
                            e.preventDefault();
                        }
                    },
                    close: function() {
                        _this.close();
                        _this.$input.focus();
                    }
                });
            });
        }

        /**
         * Adds an event handler to the body to close any datepickers on a click.
         * @function
         * @private
         */
        _addBodyHandler() {
            var $body = $(document.body).not(this.$element),
                _this = this;
            $body.off('click.zf.datepicker')
                .on('click.zf.datepicker', function(e){
                    if(_this.$input.is(e.target) || _this.$input.find(e.target).length) {
                        return;
                    }
                    if(_this.$element.find(e.target).length) {
                        return;
                    }
                    _this.close();
                    $body.off('click.zf.datepicker');
                });
        }

        /**
         * Opens the datepicker pane, and fires a bubbling event to close other datepickers.
         * @function
         * @fires Datepicker#closeme
         * @fires Datepicker#show
         */
        open() {
            // var _this = this;
            /**
             * Fires to close other open datepickers
             * @event Datepicker#closeme
             */
            this.$element.trigger('closeme.zf.datepicker', this.$element.attr('id'));
            this.$input.attr({'aria-expanded': true});

            this._setPosition();
            this.$element.addClass('is-open')
                .attr({'aria-hidden': false});

            this.buildCalender();

            if(this.options.autoFocus){
                var $focusable = Foundation.Keyboard.findFocusable(this.$element);
                if($focusable.length){
                    $focusable.eq(0).focus();
                }
            }

            if(this.options.closeOnClick){ this._addBodyHandler(); }

            /**
             * Fires once the datepicker is visible.
             * @event Datepicker#show
             */
            this.$element.trigger('show.zf.datepicker', [this.$element]);
        }

        /**
         * Closes the open datepicker pane.
         * @function
         * @fires Datepicker#hide
         */
        close() {
            if(!this.$element.hasClass('is-open')){
                return false;
            }
            this.$element.removeClass('is-open')
                .attr({'aria-hidden': true});

            this.$input.attr('aria-expanded', false);

            if(this.classChanged){
                var curPositionClass = this.getPositionClass();
                if(curPositionClass){
                    this.$element.removeClass(curPositionClass);
                }
                this.$element
                    .addClass(this.options.positionClass)
                    .css({height: '', width: ''});
                this.classChanged = false;
                this.counter = 4;
                this.usedPositions.length = 0;
            }
            this.$element.trigger('hide.zf.datepicker', [this.$element]);
        }

        /**
         * Toggles the datepicker pane's visibility.
         * @function
         */
        toggle() {
            if(this.$element.hasClass('is-open')){
                this.close();
            }else{
                this.open();
            }
        }

        /**
         * Destroys the datepicker.
         * @function
         */
        destroy() {
            this.$element.off('.zf.trigger').hide();
            this.$input.off('.zf.datepicker');

            Foundation.unregisterPlugin(this);
        }
    }

    Datepicker.defaults = {
        /**
         * Number of pixels between the datepicker pane and the triggering element on open.
         * @option
         * @example 1
         */
        vOffset: 0,
        /**
         * Number of pixels between the datepicker pane and the triggering element on open.
         * @option
         * @example 1
         */
        hOffset: 0,
        /**
         * Class applied to adjust open position. JS will test and fill this in.
         * @option
         * @example 'top'
         */
        positionClass: '',
        /**
         * Allow the plugin to set focus to the first focusable element within the pane, regardless of method of opening.
         * @option
         * @example true
         */
        autoFocus: false,
        /**
         * Allows a click on the body to close the datepicker.
         * @option
         * @example false
         */
        closeOnClick: true,
        format: "DD/MM/YYYY",
        locale: 'en',
        weekstart: 1,
        calenderTemplate:
        '<div class="foudation-calender">' +
        '<div class="calender-header">' +
        '<div class="months-nav">' +
        '<a class="calender-nav-previous">' +
        '<i class="fa fa-chevron-left fi-arrow-left"></i>' +
        '</a>' +
        '<div>{{month}}</div>' +
        '<a class="calender-nav-next">' +
        '<i class="fa fa-chevron-right fi-arrow-right"></i>' +
        '</a>' +
        '</div>' +
        '<div class="weekdays row small-up-7 collapse">{{{weekdays}}}</div>' +
        '</div>' +
        '<div class="days row small-up-7 collapse">{{{days}}}</div>' +
        '</div>',
        weekdayHeaderTemplate:
            '<div class="column day {{dayType}}"><strong>{{day}}</strong></div>',
        dayTemplate:
            '<div class="column"><a class="day {{dayType}}" data-date="{{date}}">{{day}}</a></div>'
    };

// Window exports
    Foundation.plugin(Datepicker, 'Datepicker');

}(jQuery, Mustache, moment);

{'fraction_non_alphanumeric': 0.14179239589619794, 'fraction_numerical': 0.002776101388050694, 'mean_word_length': 1.5327474207107374, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7225900', 'n_tokens_mistral': 8938, 'n_tokens_neox': 8535, 'n_words': 1674}