<commit_before>/*global logger*/
/*
    BootstrapInputAddons
    ========================

    @file      : BootstrapInputAddons.js
    @version   : 1.0.3
    @author    : <NAME>
    @date      : Mon, 25 Apr 2016 09:29:56 GMT
    @copyright : JAM-IT B.V.
    @license   : Apache V2

    Documentation
    ========================
    This widget gives the possibility to use bootstrap input add-ons on normal fields.
*/

define([
    "dojo/_base/declare",
    "mendix/validator",
    "mxui/widget/_WidgetBase",
    "dijit/_TemplatedMixin",

    "dojo/_base/kernel",
    "dojo/dom-class",
    "dojo/dom-style",
    "dojo/dom-construct",
    "dojo/dom-attr",
    "dojo/_base/array",
    "dojo/_base/lang",
    "dojo/html",
    "dojo/_base/event",
    "dojo/text!BootstrapInputAddons/widget/template/BootstrapInputAddons.html",
    "BootstrapInputAddons/lib/jquery-1.11.2"
], function (declare, validator, _WidgetBase, _TemplatedMixin, dojo, dojoClass, dojoStyle, dojoConstruct, dojoAttr, dojoArray, dojoLang, dojoHtml, dojoEvent, widgetTemplate, jQuery) {
    "use strict";

    // Declare widget's prototype.
    return declare("BootstrapInputAddons.widget.BootstrapInputAddons", [_WidgetBase, _TemplatedMixin], {
        // _TemplatedMixin will create our dom node using this HTML template.
        templateString: widgetTemplate,
        jQuery: jQuery.noConflict(true),
        // DOM elements
        inputDiv: null,
        inputNodes: null,
        inputNode: null,
        formGroupNode: null,

        // Parameters configured in the Modeler.\
        hideEnumregEx: "",
        showEnumAs: "",
        formOrientation: "",
        labelWidth: 0,
        placeholderText: "",
        decimalPrecision: "",
        groupDigits: "",
        showNegativeAsPositive: "",
        visibilityAttribute: "",
        editable: "",
        readOnlyMode: "",
        editableAttribute: "",
        showLabel: "",
        tooltipText: "",
        tooltipPosition: "",
        labelCaption: "",
        negativeLabelCaption: "",
        negativeClass: "",
        showLeftAddon: "",
        leftAddonCaption: "",
        showRightAddon: "",
        rightAddonCaption: "",
        showRightButtonAddon: "",
        rightAddonButtonCaption: "",
        isRequired: "",
        requiredMessage: "",
        useRegExValidation: "",
        regEx: "",
        regExMessage: "",
        mfToExecute: "",
        messageString: "",
        fieldAttribute: "",
        radioOrientation: "",

        onChange: "",
        onChangeAbortOnValidationErrors: "",
        onEnter: "",
        onLeave: "",
        onClick: "",

        // Internal variables. Non-primitives created in the prototype are shared between all widget instances.
        _formValidateListener: null,
        _handles: null,
        _contextObj: null,
        _alertDiv: null,
        _leftAddonSpan: null,
        _rightAddonSpan: null,
        _rightButtonAddonSpan: null,
        _labelNode: null,
        _toolTipNode: null,
        _validationMessage: null,
        _tooltipSpace: 0,

        // dojo.declare.constructor is called to construct the widget instance. Implement to initialize non-primitive properties.
        constructor: function () {
            this._handles = [];
        },

        // dijit._WidgetBase.postCreate is called after constructing the widget. Implement to do extra setup work.
        postCreate: function () {
            this._updateRendering();
            this._setupEvents();
        },

        // mxui.widget._WidgetBase.update is called when context is changed or initialized. Implement to re-render and / or fetch data.
        update: function (obj, callback) {
            this._contextObj = obj;
            this._resetSubscriptions();
            this._updateRendering();

            callback();
        },

        // mxui.widget._WidgetBase.enable is called when the widget should enable editing. Implement to enable editing if widget is input widget.
        enable: function () {
        },

        // mxui.widget._WidgetBase.enable is called when the widget should disable editing. Implement to disable editing if widget is input widget.
        disable: function () {
        },

        // mxui.widget._WidgetBase.resize is called when the page's layout is recalculated. Implement to do sizing calculations. Prefer using CSS instead.
        resize: function (box) {
        },

        // mxui.widget._WidgetBase.uninitialize is called when the widget is destroyed. Implement to do special tear-down work.
        uninitialize: function () {
            // Clean up listeners, helper objects, etc. There is no need to remove listeners added with this.connect / this.subscribe / this.own.
            if (this._formValidateListener) {
                this.mxform.unlisten(this._formValidateListener);
            }
        },

        // We want to stop events on a mobile device
        _stopBubblingEventOnMobile: function (e) {
            if (typeof document.ontouchstart !== "undefined") {
                dojoEvent.stop(e);
            }
        },

        // Attach events to HTML dom elements
        _setupEvents: function () {
            this.connect(this.inputNode, "change", function (event) {
                this._onChange(event);
            });

            this.connect(this.inputNode, "focus", function (e) {
                this._onEnter();
            });

            this.connect(this.inputNode, "blur", function (e) {
                this._onLeave();
            });

        },

        // Rerender the interface.
        _updateRendering: function () {
            if (this._isVisible()) {
                dojoStyle.set(this.domNode, "display", "block");

                var value = this._getFormattedValueFromContextObject(this.fieldAttribute);
                this.inputNode.value = value;

                var originalValue = this._contextObj.get(this.fieldAttribute);
                if (originalValue < 0) {
                    dojoClass.add(this.formGroupNode, this.negativeClass);
                } else {
                    dojoClass.remove(this.formGroupNode, this.negativeClass);
                }

                this._addLabel();
                this._addLeftAddon();
                this._addRightAddon();<commit_msg>bug fix ui of input<commit_after>/*global logger*/
/*
    BootstrapInputAddons
    ========================

    @file      : BootstrapInputAddons.js
    @version   : 1.0.3
    @author    : <NAME>
    @date      : Mon, 25 Apr 2016 09:29:56 GMT
    @copyright : JAM-IT B.V.
    @license   : Apache V2

    Documentation
    ========================
    This widget gives the possibility to use bootstrap input add-ons on normal fields.
*/

define([
    "dojo/_base/declare",
    "mendix/validator",
    "mxui/widget/_WidgetBase",
    "dijit/_TemplatedMixin",

    "dojo/_base/kernel",
    "dojo/dom-class",
    "dojo/dom-style",
    "dojo/dom-construct",
    "dojo/dom-attr",
    "dojo/_base/array",
    "dojo/_base/lang",
    "dojo/html",
    "dojo/_base/event",
    "dojo/text!BootstrapInputAddons/widget/template/BootstrapInputAddons.html",
    "BootstrapInputAddons/lib/jquery-1.11.2"
], function (declare, validator, _WidgetBase, _TemplatedMixin, dojo, dojoClass, dojoStyle, dojoConstruct, dojoAttr, dojoArray, dojoLang, dojoHtml, dojoEvent, widgetTemplate, jQuery) {
    "use strict";

    // Declare widget's prototype.
    return declare("BootstrapInputAddons.widget.BootstrapInputAddons", [_WidgetBase, _TemplatedMixin], {
        // _TemplatedMixin will create our dom node using this HTML template.
        templateString: widgetTemplate,
        jQuery: jQuery.noConflict(true),
        // DOM elements
        inputDiv: null,
        inputNodes: null,
        inputNode: null,
        formGroupNode: null,

        // Parameters configured in the Modeler.\
        hideEnumregEx: "",
        showEnumAs: "",
        formOrientation: "",
        labelWidth: 0,
        placeholderText: "",
        decimalPrecision: "",
        groupDigits: "",
        showNegativeAsPositive: "",
        visibilityAttribute: "",
        editable: "",
        readOnlyMode: "",
        editableAttribute: "",
        showLabel: "",
        tooltipText: "",
        tooltipPosition: "",
        labelCaption: "",
        negativeLabelCaption: "",
        negativeClass: "",
        showLeftAddon: "",
        leftAddonCaption: "",
        showRightAddon: "",
        rightAddonCaption: "",
        showRightButtonAddon: "",
        rightAddonButtonCaption: "",
        isRequired: "",
        requiredMessage: "",
        useRegExValidation: "",
        regEx: "",
        regExMessage: "",
        mfToExecute: "",
        messageString: "",
        fieldAttribute: "",
        radioOrientation: "",

        onChange: "",
        onChangeAbortOnValidationErrors: "",
        onEnter: "",
        onLeave: "",
        onClick: "",

        // Internal variables. Non-primitives created in the prototype are shared between all widget instances.
        _formValidateListener: null,
        _handles: null,
        _contextObj: null,
        _alertDiv: null,
        _leftAddonSpan: null,
        _rightAddonSpan: null,
        _rightButtonAddonSpan: null,
        _labelNode: null,
        _toolTipNode: null,
        _validationMessage: null,
        _tooltipSpace: 0,

        // dojo.declare.constructor is called to construct the widget instance. Implement to initialize non-primitive properties.
        constructor: function () {
            this._handles = [];
        },

        // dijit._WidgetBase.postCreate is called after constructing the widget. Implement to do extra setup work.
        postCreate: function () {
            this._updateRendering();
            this._setupEvents();
        },

        // mxui.widget._WidgetBase.update is called when context is changed or initialized. Implement to re-render and / or fetch data.
        update: function (obj, callback) {
            this._contextObj = obj;
            this._resetSubscriptions();
            this._updateRendering();

            callback();
        },

        // mxui.widget._WidgetBase.enable is called when the widget should enable editing. Implement to enable editing if widget is input widget.
        enable: function () {
        },

        // mxui.widget._WidgetBase.enable is called when the widget should disable editing. Implement to disable editing if widget is input widget.
        disable: function () {
        },

        // mxui.widget._WidgetBase.resize is called when the page's layout is recalculated. Implement to do sizing calculations. Prefer using CSS instead.
        resize: function (box) {
        },

        // mxui.widget._WidgetBase.uninitialize is called when the widget is destroyed. Implement to do special tear-down work.
        uninitialize: function () {
            // Clean up listeners, helper objects, etc. There is no need to remove listeners added with this.connect / this.subscribe / this.own.
            if (this._formValidateListener) {
                this.mxform.unlisten(this._formValidateListener);
            }
        },

        // We want to stop events on a mobile device
        _stopBubblingEventOnMobile: function (e) {
            if (typeof document.ontouchstart !== "undefined") {
                dojoEvent.stop(e);
            }
        },

        // Attach events to HTML dom elements
        _setupEvents: function () {
            this.connect(this.inputNode, "change", function (event) {
                this._onChange(event);
            });

            this.connect(this.inputNode, "focus", function (e) {
                this._onEnter();
            });

            this.connect(this.inputNode, "blur", function (e) {
                this._onLeave();
            });

        },

        // Rerender the interface.
        _updateRendering: function () {
            if (this._isVisible()) {
                dojoStyle.set(this.domNode, "display", "block");
                dojoStyle.set(this.inputDiv, "display", "block");

                var value = this._getFormattedValueFromContextObject(this.fieldAttribute);
                this.inputNode.value = value;

                var originalValue = this._contextObj.get(this.fieldAttribute);
                if (originalValue < 0) {
                    dojoClass.add(this.formGroupNode, this.negativeClass);
                } else {
                    dojoClass.remove(this.formGroupNode, this.negativeClass);
                }

                this._addLabel();
                this._addLeftAddon();
                this._addRightAddon();
{'fraction_non_alphanumeric': 0.11208808618504436, 'fraction_numerical': 0.003643852978453739, 'mean_word_length': 2.037776708373436, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1689102', 'n_tokens_mistral': 3443, 'n_tokens_neox': 3311, 'n_words': 816}