<commit_before>Ext.namespace('Sage.Platform.Mobile.Controls');

(function() {
    var U = Sage.Platform.Mobile.Utility;

    Sage.Platform.Mobile.Controls.DateField = Ext.extend(Sage.Platform.Mobile.Controls.Field, {
        //TODO: make the input a HTML5 "date" field. Webkit & Chrome, overrides our styles for that. 
        template: new Simplate([
            '<label for="{%= $.name %}">{%: $.label %}</label>',
            '<a class="button whiteButton"><span>{%: $.lookupText %}</span></a>',
            '<input type="text" readonly="readonly" />'
        ]),
        textTemplate: false,
        emptyText: 'empty',
        completeText: 'Select',
        lookupText: '...',
        view: 'generic_calendar',
        showTime: false,
        init: function() {
            Sage.Platform.Mobile.Controls.DateField.superclass.init.apply(this, arguments);

            this.containerEl.on('click', this.onClick, this);
        },
        complete: function() {
            var view = App.getActiveView();
            if (view)
            {
                this.currentValue = view.getDateTime();
                
                this.setText(this.currentValue);

                this.fireEvent('change', this.currentValue, this);

                ReUI.back();
            }
        },
        createNavigationOptions: function() {
            return {
                tools: {
                    tbar: [{
                        name: 'complete',
                        title: this.completeText,
                        cls: 'button',
                        fn: this.complete,
                        scope: this
                    }]
                },
                date: this.originalValue,
                showTime: this.showTime
            };
        },
        navigateToDateView: function() {
            var view = App.getView(this.view),
                options = this.createNavigationOptions();
            if (view && options)
                view.show(options);
        },
        onClick: function(evt, el, o) {
            if (evt.getTarget('a'))
            {
                evt.stopEvent();
                
                this.navigateToDateView();
            }
        },
        isDirty: function() {
            if (!this.originalValue && this.currentValue) return true;

            if (this.originalValue && this.currentValue) return !this.originalValue.equals(this.currentValue);

            return false;
        },
        getValue: function() {
            return this.currentValue.toISOString();
        },
        //FIXME: Date.parse returns NaN for strings like '2006-12-11T00:00:00-07:00'
        setValue: function(val, initial) {
            var d;
            if (typeof val == 'string') d = this.parseDate(val);
            if (!val || !d || d.constructor !== Date) return;

            if (initial) this.originalValue = d;            

            this.setText(d);
        },<commit_msg>Small fix in Datefield for getValue and setValue.<commit_after>Ext.namespace('Sage.Platform.Mobile.Controls');

(function() {
    var U = Sage.Platform.Mobile.Utility;

    Sage.Platform.Mobile.Controls.DateField = Ext.extend(Sage.Platform.Mobile.Controls.Field, {
        //TODO: make the input a HTML5 "date" field. Webkit & Chrome, overrides our styles for that. 
        template: new Simplate([
            '<label for="{%= $.name %}">{%: $.label %}</label>',
            '<a class="button whiteButton"><span>{%: $.lookupText %}</span></a>',
            '<input type="text" readonly="readonly" />'
        ]),
        textTemplate: false,
        emptyText: 'empty',
        completeText: 'Select',
        lookupText: '...',
        view: 'generic_calendar',
        showTime: false,
        init: function() {
            Sage.Platform.Mobile.Controls.DateField.superclass.init.apply(this, arguments);

            this.containerEl.on('click', this.onClick, this);
        },
        complete: function() {
            var view = App.getActiveView();
            if (view)
            {
                this.currentValue = view.getDateTime();
                
                this.setText(this.currentValue);

                this.fireEvent('change', this.currentValue, this);

                ReUI.back();
            }
        },
        createNavigationOptions: function() {
            return {
                tools: {
                    tbar: [{
                        name: 'complete',
                        title: this.completeText,
                        cls: 'button',
                        fn: this.complete,
                        scope: this
                    }]
                },
                date: this.originalValue,
                showTime: this.showTime
            };
        },
        navigateToDateView: function() {
            var view = App.getView(this.view),
                options = this.createNavigationOptions();
            if (view && options)
                view.show(options);
        },
        onClick: function(evt, el, o) {
            if (evt.getTarget('a'))
            {
                evt.stopEvent();
                
                this.navigateToDateView();
            }
        },
        isDirty: function() {
            if (!this.originalValue && this.currentValue) return true;

            if (this.originalValue && this.currentValue) return !this.originalValue.equals(this.currentValue);

            return false;
        },
        getValue: function() {
            //TODO: Need to adapt as per service payload type, and return JSONDate or ISOString 
            var JSONDate = false;

            if (this.currentValue) JSONDate = String.format("\/Date({0})\/", this.currentValue.getTime());

            return JSONDate;
        },
        //FIXME: Date.parse returns NaN for strings like '2006-12-11T00:00:00-07:00'
        setValue: function(val, initial) {
            var d;
            if (typeof val == 'string') d = this.parseDate(val);
            if (!val || !d || d.constructor !== Date) return;

            this.currentValue = d;

            if (initial) this.originalValue = this.currentValue;

            this.setText(d);
        },
{'fraction_non_alphanumeric': 0.1270458596661805, 'fraction_numerical': 0.006319883325230919, 'mean_word_length': 1.4727564102564104, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '2818997', 'n_tokens_mistral': 1649, 'n_tokens_neox': 1570, 'n_words': 343}