<commit_before>/*************************************************
 * Copyright (c) 2015 Ansible, Inc.
 *
 * All Rights Reserved
 *************************************************/

/* jshint unused: vars */

export default
    [   'moment',
        'templateUrl',
        function(moment, templateUrl) {
            return {
                restrict: 'E',
                scope: {
                    date: '=',
                    minDate: '=',
                    autoUpdate: '=?',
                    inputClass: '&'
                },
                templateUrl: templateUrl('system-tracking/date-picker/date-picker'),
                link: function(scope, element, attrs) {
                    var lang = window.navigator.languages ?
                        window.navigator.languages[0] :
                            (window.navigator.language ||
                                window.navigator.userLanguage);
                    moment.locale(lang);
                    // We need to make sure this _never_ recurses, which sometimes happens
                    // with two-way binding.
                    var mustUpdateValue = true;
                    scope.autoUpdate = scope.autoUpdate === false ? false : true;

                    // convert the passed current date into the correct moment locale
                    scope.$watch('date', function(newValue) {
                        if (newValue) {
                            mustUpdateValue = false;
                            scope.dateValueMoment = moment(newValue, ['MM/DD/YYYY'], moment.locale());
                            scope.dateValue = scope.dateValueMoment.format('L');
                        }
                    }, true);

                    // as the date picker value changes, convert back to
                    // the english date to pass back into the scheduler lib
                    scope.$watch('dateValue', function(newValue) {
                        scope.dateValueMoment = moment(newValue, ['L'], moment.locale());
                        scope.date = scope.dateValueMoment.locale('en').format('L');
                        mustUpdateValue = true;
                    });

                    var localeData =
                        moment.localeData();
                    var dateFormat = momentFormatToDPFormat(localeData._longDateFormat.L);
                    var localeKey = momentLocaleToDPLocale(moment.locale());

                    element.find(".DatePicker").addClass("input-prepend date");
                    element.find(".DatePicker").find(".DatePicker-icon").addClass("add-on");
                    $(".date").systemTrackingDP({
                        autoclose: true,
                        language: localeKey,
                        format: dateFormat
                    });

                    function momentLocaleToDPLocale(localeKey) {
                        var parts = localeKey.split('-');
<commit_msg>fix scheduler datepicker issues<commit_after>/*************************************************
 * Copyright (c) 2015 Ansible, Inc.
 *
 * All Rights Reserved
 *************************************************/

/* jshint unused: vars */

export default
    [   'moment',
        'templateUrl',
        function(moment, templateUrl) {
            return {
                restrict: 'E',
                scope: {
                    date: '=',
                    minDate: '=',
                    autoUpdate: '=?',
                    inputClass: '&'
                },
                templateUrl: templateUrl('system-tracking/date-picker/date-picker'),
                link: function(scope, element, attrs) {
                    var lang = window.navigator.languages ?
                        window.navigator.languages[0] :
                            (window.navigator.language ||
                                window.navigator.userLanguage);
                    moment.locale(lang);
                    // We need to make sure this _never_ recurses, which sometimes happens
                    // with two-way binding.
                    var mustUpdateValue = true;
                    scope.autoUpdate = scope.autoUpdate === false ? false : true;

                    // convert the passed current date into the correct moment locale
                    scope.$watch('date', function(newValue) {
                        if (newValue) {
                            mustUpdateValue = false;
                            scope.dateValueMoment = moment(newValue, ['MM/DD/YYYY'], moment.locale());
                            scope.dateValue = scope.dateValueMoment.format('L');
                            element.find(".DatePicker").systemTrackingDP('update', scope.dateValue);
                        }
                    }, true);

                    // as the date picker value changes, convert back to
                    // the english date to pass back into the scheduler lib
                    scope.$watch('dateValue', function(newValue) {
                        scope.dateValueMoment = moment(newValue, ['L'], moment.locale());
                        scope.date = scope.dateValueMoment.locale('en').format('L');
                        mustUpdateValue = true;
                    });

                    var localeData =
                        moment.localeData();
                    var dateFormat = momentFormatToDPFormat(localeData._longDateFormat.L);
                    var localeKey = momentLocaleToDPLocale(moment.locale());

                    element.find(".DatePicker").addClass("input-prepend date");
                    element.find(".DatePicker").find(".DatePicker-icon").addClass("add-on");
                    element.find(".DatePicker").systemTrackingDP({
                        autoclose: true,
                        language: localeKey,
                        format: dateFormat
                    });

                    function momentLocaleToDPLocale(localeKey) {
                        var parts = localeKey.split('-');

{'fraction_non_alphanumeric': 0.1302031302031302, 'fraction_numerical': 0.001665001665001665, 'mean_word_length': 1.302414718282867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '935235', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1266, 'n_words': 279}