<commit_before>var fluid_1_5 = fluid_1_5 || {};

(function ($, fluid) {

    /*******************************************
     * A custom adjuster used to increment or  *
     * decrement a given value by a given step *
     *******************************************/

    fluid.defaults("gpii.textfieldStepper", {
        gradeNames: ["fluid.viewComponent", "autoInit"],
        components: {
            textfield: {
                type: "fluid.textfieldSlider.textfield",
                container: "{textfieldStepper}.dom.textfield",
                options: {
                    model: "{textfieldStepper}.model",
                    range: "{textfieldStepper}.options.range",
                    applier: "{textfieldStepper}.applier"
                }
            },
            buttons: {
                type: "gpii.textfieldStepper.buttons",
                container: "{textfieldStepper}.dom.buttons",
                options: {
                    model: "{textfieldStepper}.model",
                    range: "{textfieldStepper}.options.range",
                    applier: "{textfieldStepper}.applier"
                }
            }
        },
        selectors: {
            textfield: ".gpii-textfieldStepper-field"
        },
        events: {
            modelChanged: null,
            afterRender: null
        },
        listeners: {
            modelChanged: "{that}.refreshView"
        },
        model: {
            value: null
        },
        range: {
            min: -Infinity,
            max: Infinity,
            step: 1
        },
        invokers: {
            refreshView: {
                funcName: "gpii.textfieldStepper.refreshView",
                args: ["{that}"]
            }
        },
        finalInitFunction: "gpii.textfieldStepper.finalInit",
        renderOnInit: true
    });

    gpii.textfieldStepper.finalInit = function (that) {

        that.applier.modelChanged.addListener("value", function (newModel) {
            that.events.modelChanged.fire(newModel.value);
        });

        if (that.options.renderOnInit) {
            that.refreshView();
        }
    };

    gpii.textfieldStepper.refreshView = function (that) {
        that.textfield.container.val(that.model.value);
        that.events.afterRender.fire(that);
    };

    fluid.defaults("gpii.textfieldStepper.buttons", {
        gradeNames: ["fluid.viewComponent", "autoInit"],
        selectors: {
            inc: ".gpii-textfieldStepper-increment",
            dec: ".gpii-textfieldStepper-decrement"
        },
        events: {
            modelChanged: null
        },
        listeners: {
            onCreate: {
                listener: "gpii.textfieldStepper.buttons.init",
                args: "{that}"
            }
        },
        range: {} // should be used to specify the min, max range and step e.g. {min: 0, max: 100, step: 5}
    });

    gpii.textfieldStepper.buttons.init = function (that) {
        that.locate("inc").click(function () {
            var newValue = that.model.value + that.options.range.step;
            that.applier.requestChange("value", newValue);
        });

        that.locate("dec").click(function () {
            var newValue = that.model.value - that.options.range.step;
            that.applier.requestChange("value", newValue);
        });

        that.applier.modelChanged.addListener("value", function (newModel) {
            if (typeof newModel.value !== "number") {
                that.applier.requestChange("value", parseInt(newModel.value, 10));
            }
        });
    };

    fluid.defaults("gpii.uiOptions.textfieldStepper", {
        gradeNames: ["gpii.textfieldStepper", "autoInit"],
        model: "{fluid.uiOptions.panels}.model",
        range: "{fluid.uiOptions.panels}.options.range",
        listeners: {
            modelChanged: {
                listener: "{fluid.uiOptions.panels}.applier.requestChange",
                args: ["{that}.options.path", "{arguments}.0"]
            }
        },<commit_msg>GPII-153: Textfield Stepper jQuery click added declaratively now.<commit_after>var fluid_1_5 = fluid_1_5 || {};

(function ($, fluid) {

    /*******************************************
     * A custom adjuster used to increment or  *
     * decrement a given value by a given step *
     *******************************************/

    fluid.defaults("gpii.textfieldStepper", {
        gradeNames: ["fluid.viewComponent", "autoInit"],
        components: {
            textfield: {
                type: "fluid.textfieldSlider.textfield",
                container: "{textfieldStepper}.dom.textfield",
                options: {
                    model: "{textfieldStepper}.model",
                    range: "{textfieldStepper}.options.range",
                    applier: "{textfieldStepper}.applier"
                }
            },
            buttons: {
                type: "gpii.textfieldStepper.buttons",
                container: "{textfieldStepper}.dom.buttons",
                options: {
                    model: "{textfieldStepper}.model",
                    range: "{textfieldStepper}.options.range",
                    applier: "{textfieldStepper}.applier"
                }
            }
        },
        selectors: {
            textfield: ".gpii-textfieldStepper-field"
        },
        events: {
            modelChanged: null,
            afterRender: null
        },
        listeners: {
            modelChanged: "{that}.refreshView"
        },
        model: {
            value: null
        },
        range: {
            min: -Infinity,
            max: Infinity,
            step: 1
        },
        invokers: {
            refreshView: {
                funcName: "gpii.textfieldStepper.refreshView",
                args: ["{that}"]
            }
        },
        finalInitFunction: "gpii.textfieldStepper.finalInit",
        renderOnInit: true
    });

    gpii.textfieldStepper.finalInit = function (that) {

        that.applier.modelChanged.addListener("value", function (newModel) {
            that.events.modelChanged.fire(newModel.value);
        });

        if (that.options.renderOnInit) {
            that.refreshView();
        }
    };

    gpii.textfieldStepper.refreshView = function (that) {
        that.textfield.container.val(that.model.value);
        that.events.afterRender.fire(that);
    };

    fluid.defaults("gpii.textfieldStepper.buttons", {
        gradeNames: ["fluid.viewComponent", "autoInit"],
        selectors: {
            inc: ".gpii-textfieldStepper-increment",
            dec: ".gpii-textfieldStepper-decrement"
        },
        events: {
            modelChanged: null
        },
        listeners: {
            onCreate: [ {
                "this": "{that}.dom.inc",
                "method": "click",
                "args": ["{that}.increaseValue"]
            }, {
                "this": "{that}.dom.dec",
                "method": "click",
                "args": ["{that}.decreaseValue"]
            }, {
                funcName: "gpii.textfieldStepper.buttons.parseInt",
                args: ["{that}"]
            }]
        },
        invokers: {
            increaseValue: {
                funcName: "gpii.textfieldStepper.buttons.increaseValue",
                args: ["{that}"]
            },
            decreaseValue: {
                funcName: "gpii.textfieldStepper.buttons.decreaseValue",
                args: ["{that}"]
            }
        },
        range: {} // should be used to specify the min, max range and step e.g. {min: 0, max: 100, step: 5}
    });

    gpii.textfieldStepper.buttons.alterValue = function (that, operation) {
        var currentValue = that.model.value;
        var step = that.options.range.step;
        var newValue = operation == "+" ? currentValue + step : currentValue - step;

        that.applier.requestChange("value", newValue);
    };

    gpii.textfieldStepper.buttons.increaseValue = function (that) {
        gpii.textfieldStepper.buttons.alterValue(that, "+");
    };

    gpii.textfieldStepper.buttons.decreaseValue = function (that) {
        gpii.textfieldStepper.buttons.alterValue(that, "-");
    };

    gpii.textfieldStepper.buttons.parseInt = function (that) {
        that.applier.modelChanged.addListener("value", function (newModel) {
            if (typeof newModel.value !== "number") {
                that.applier.requestChange("value", parseInt(newModel.value, 10));
            }
        });
    };

    fluid.defaults("gpii.uiOptions.textfieldStepper", {
        gradeNames: ["gpii.textfieldStepper", "autoInit"],
        model: "{fluid.uiOptions.panels}.model",
        range: "{fluid.uiOptions.panels}.options.range",
        listeners: {
            modelChanged: {
                listener: "{fluid.uiOptions.panels}.applier.requestChange",
                args: ["{that}.options.path", "{arguments}.0"]
            }
        },
{'fraction_non_alphanumeric': 0.1459102607138861, 'fraction_numerical': 0.003244936779679982, 'mean_word_length': 1.7019347037484884, 'pattern_counts': {'":': 6, '<': 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': '242477', 'n_tokens_mistral': 2533, 'n_tokens_neox': 2426, 'n_words': 391}