<commit_before>﻿/// <reference path="S:\Delivery\Aspectize.core\AspectizeIntellisenseLibrary.js" />

Aspectize.Extend("Autosize", {
    Properties: {},
    Events: [],
    Init: function (elem) {
        autosize($(elem));
    }
});

Aspectize.Extend("JQueryButton", {
    Properties: { value: '', disabled: false },
    Events: ['click'],
    Init: function (elem) {
        $(elem).button();
        $(elem).on('click', function (e) { Aspectize.UiExtensions.Notify(elem, 'click', e); });
    }
});

Aspectize.Extend("JQueryAutoComplete", {
    Properties: { Url: '', value: '', Custom: false, MultiValue: false, MultiValueSeparator: ',', FillSelected: true },
    Events: ['OnSelectItem', 'OnSelectNewItem'],
    Init: function (elem) {

        $(elem).autocomplete({
            minLength: 0,
            focus: function () {
                // prevent value inserted on focus
                return false;
            }
        });

        function buildSeparatorSplit(s) {

            var rx = new RegExp(s + '\\s*');

            return function (v) { return v.split(rx); };
        }

        var split = buildSeparatorSplit(',');

        function extractLast(term) {
            return split(term).pop();
        }


        Aspectize.UiExtensions.AddMergedPropertyChangeObserver(elem, function (sender, arg) {

            var url = Aspectize.UiExtensions.GetProperty(elem, 'Url');
            var multiValue = Aspectize.UiExtensions.GetProperty(elem, 'MultiValue');
            var fillSelected = Aspectize.UiExtensions.GetProperty(elem, 'FillSelected');

            var reInit = false;
            for (var p in arg) {

                switch (p) {

                    case 'Url':
                    case 'MultiValue':
                    case 'FillSelected': reInit = true; break;

                    case 'value': $(sender).val(arg[p]); break;

                    case 'MultiValueSeparator':

                        if (arg[p] !== ',') {
                            split = buildSeparatorSplit(arg[p]);
                        }
                }
            }

            if (reInit) {

                var jqVersion = jQuery.fn.jquery;
                var attribute = "autocomplete";

                if (jqVersion >= "1.9") {
                    attribute = "uiAutocomplete"; //ui-autocomplete ?
                }

                var options = {};

                options.change = function (event, ui) {
                    if (ui.item == null) {
                        Aspectize.UiExtensions.Notify(elem, 'OnSelectNewItem', this.value);
                    }
                };

                if (multiValue) {

                    options.source = function (request, response) {
                        $.getJSON(url, {
                            term: extractLast(request.term)
                        }, response);
                    };

                    options.select = function (event, ui) {

                        if (fillSelected) {
                            var currentValue = Aspectize.UiExtensions.GetProperty(elem, 'value');
                            var terms = split(currentValue);
                            // remove the current input
                            terms.pop();
                            terms.push(ui.item.label);

                            // add placeholder to get the comma-and-space at the end
                            terms.push("");
                            var s = Aspectize.UiExtensions.GetProperty(elem, 'MultiValueSeparator') + ' ';

                            var newValue = terms.join(s);
                            Aspectize.UiExtensions.ChangeProperty(elem, 'value', newValue);
                            $(elem).val(newValue);
                            //event.preventDefault();
                            event.stopPropagation();
                        }
                        //Aspectize.UiExtensions.ChangeProperty(elem, 'Custom', false);
                        Aspectize.UiExtensions.Notify(elem, 'OnSelectItem', ui.item.value);
                        return false;
                    };

                } else {

                    options.source = url;

                    options.select = function (event, ui) {
                        if (fillSelected) {
                            Aspectize.UiExtensions.ChangeProperty(elem, 'value', ui.item.label);
                            $(elem).val(ui.item.label);
                        }
                        //Aspectize.UiExtensions.ChangeProperty(elem, 'Custom', false);
                        Aspectize.UiExtensions.Notify(elem, 'OnSelectItem', ui.item.value);
                        return false;
                    };
                }

                var ac = $(elem).autocomplete(options);

                if (jqVersion >= "1.9") {
                    ac.data(attribute)._renderItem = function (ul, item) {
                        return $('<li class="ui-menu-item" role="presentation"></li>')
                            .data("item.autocomplete", item)
                            .append('<a><span class="' + item.type + '"></span>' + item.label + '</a>')
                            .appendTo(ul);
                    };
                }
            }
        });

        //Aspectize.UiExtensions.AddPropertyChangeObserver(elem, function (sender, arg) {
        //    var url = Aspectize.UiExtensions.GetProperty(elem, 'Url');
        //    var multiValue = Aspectize.UiExtensions.GetProperty(elem, 'MultiValue');
        //    var fillSelected = Aspectize.UiExtensions.GetProperty(elem, 'FillSelected');

        //    if (arg.Name === 'Url') {
        //        url = arg.Value;
        //    } else if (arg.Name === 'MultiValue') {
        //        multiValue = arg.Value;
        //    } else if (arg.Name === 'FillSelected') {
        //        fillSelected = arg.Value;
        //    } else if (arg.Name === 'value') {
        //        $(sender).val(arg.Value);
        //    }

        //    $(function () {
        //        var jqVersion = jQuery.fn.jquery;
        //        var attribute = "autocomplete";

        //        if (jqVersion >= "1.9") {
        //            attribute = "uiAutocomplete"; //ui-autocomplete ?
        //        }

        //        if (multiValue) {
        //            var results = $(elem).autocomplete({
        //                source: function (request, response) {
        //                    $.getJSON(url, {
        //                        term: extractLast(request.term)
        //                    }, response);
        //                },
        //                select: function (event, ui) {
        //                    if (fillSelected) {
        //                        var currentValue = Aspectize.UiExtensions.GetProperty(elem, 'value');
        //                        var terms = split(currentValue);
        //                        // remove the current input
        //                        terms.pop();
        //                        terms.push(ui.item.label);

        //                        // add placeholder to get the comma-and-space at the end
        //                        terms.push("");
        //                        var newValue = terms.join(", ");
        //                        Aspectize.UiExtensions.ChangeProperty(elem, 'value', newValue);
        //                        $(elem).val(newValue);
        //                        //event.preventDefault();
        //                        event.stopPropagation();
        //                    }
        //                    Aspectize.UiExtensions.ChangeProperty(elem, 'Custom', false);
        //                    Aspectize.UiExtensions.Notify(elem, 'OnSelectItem', ui.item.value);
        //                    return false;
        //                },
        //                change: function (event, ui) {
        //                    if (ui.item == null) {
        //                        Aspectize.UiExtensions.Notify(elem, 'OnSelectNewItem', this.value);
        //                    }
        //                }

        //            });

        //            if (jqVersion >= "1.9") {
        //                results.data(attribute)._renderItem = function (ul, item) {
        //                    return $('<li class="ui-menu-item" role="presentation"></li>')
        //                        .data("item.autocomplete", item)
        //                        .append('<a><span class="' + item.type + '"></span>' + item.label + '</a>')
        //                        .appendTo(ul);
        //                };
        //            }

        //        } else {

        //            var results = $(elem).autocomplete({
        //                source: url,
        //                select: function (event, ui) {
        //                    if (fillSelected) {
        //                        Aspectize.UiExtensions.ChangeProperty(elem, 'value', ui.item.label);
        //                        $(elem).val(ui.item.label);
        //                    }
        //                    Aspectize.UiExtensions.ChangeProperty(elem, 'Custom', false);
        //                    Aspectize.UiExtensions.Notify(elem, 'OnSelectItem', ui.item.value);
        //                    return false;
        //                },
        //                change: function (event, ui) {
        //                    if (ui.item == null) {
        //                        Aspectize.UiExtensions.Notify(elem, 'OnSelectNewItem', this.value);
        //                    }
        //                }
        //            });

        //            if (jqVersion >= "1.9") {
        //                results.data(attribute)._renderItem = function (ul, item) {
        //                    return $('<li class="ui-menu-item" role="presentation"></li>')
        //                        .data("item.autocomplete", item)
        //                        .append('<a><span class="' + item.type + '"></span>' + item.label + '</a>')
        //                        .appendTo(ul);
        //                };
        //            }
        //        }
        //    });
        //});

        $(elem).keyup(function () {
            var newValue = $(elem).val();
            Aspectize.UiExtensions.ChangeProperty(elem, 'value', newValue);
            Aspectize.UiExtensions.ChangeProperty(elem, 'Custom', true);
        });
    }
});

Aspectize.Extend("JQueryMask", {
    Properties: { Value: '', Mask: '' },
    Events: [],<commit_msg>deleted 'Custom' Property from AutoComplete Extention<commit_after>﻿/// <reference path="S:\Delivery\Aspectize.core\AspectizeIntellisenseLibrary.js" />

Aspectize.Extend("Autosize", {
    Properties: {},
    Events: [],
    Init: function (elem) {
        autosize($(elem));
    }
});

Aspectize.Extend("JQueryButton", {
    Properties: { value: '', disabled: false },
    Events: ['click'],
    Init: function (elem) {
        $(elem).button();
        $(elem).on('click', function (e) { Aspectize.UiExtensions.Notify(elem, 'click', e); });
    }
});

Aspectize.Extend("JQueryAutoComplete", {
    Properties: { Url: '', value: '', MultiValue: false, MultiValueSeparator: ',', FillSelected: true },
    Events: ['OnSelectItem', 'OnSelectNewItem'],
    Init: function (elem) {

        $(elem).autocomplete({
            minLength: 0,
            focus: function () {
                // prevent value inserted on focus
                return false;
            }
        });

        function buildSeparatorSplit(s) {

            var rx = new RegExp(s + '\\s*');

            return function (v) { return v.split(rx); };
        }

        var split = buildSeparatorSplit(',');

        function extractLast(term) {
            return split(term).pop();
        }


        Aspectize.UiExtensions.AddMergedPropertyChangeObserver(elem, function (sender, arg) {

            var url = Aspectize.UiExtensions.GetProperty(elem, 'Url');
            var multiValue = Aspectize.UiExtensions.GetProperty(elem, 'MultiValue');
            var fillSelected = Aspectize.UiExtensions.GetProperty(elem, 'FillSelected');

            var reInit = false;
            for (var p in arg) {

                switch (p) {

                    case 'Url':
                    case 'MultiValue':
                    case 'FillSelected': reInit = true; break;

                    case 'MultiValueSeparator':

                        split = buildSeparatorSplit(arg[p]);
                        break;
                }
            }

            if (reInit) {

                var jqVersion = jQuery.fn.jquery;
                var attribute = "autocomplete";

                if (jqVersion >= "1.9") {
                    attribute = "uiAutocomplete"; //ui-autocomplete ?
                }

                var options = {};

                options.change = function (event, ui) {
                    if (ui.item == null) {
                        Aspectize.UiExtensions.Notify(elem, 'OnSelectNewItem', this.value);
                    }
                };

                if (multiValue) {

                    options.source = function (request, response) {
                        $.getJSON(url, {
                            term: extractLast(request.term)
                        }, response);
                    };

                    options.select = function (event, ui) {

                        if (fillSelected) {
                            var currentValue = Aspectize.UiExtensions.GetProperty(elem, 'value');
                            var terms = split(currentValue);
                            // remove the current input
                            terms.pop();
                            terms.push(ui.item.label);

                            // add placeholder to get the comma-and-space at the end
                            terms.push("");
                            var s = Aspectize.UiExtensions.GetProperty(elem, 'MultiValueSeparator') + ' ';

                            var newValue = terms.join(s);
                            Aspectize.UiExtensions.ChangeProperty(elem, 'value', newValue);
                            $(elem).val(newValue);
                            //event.preventDefault();
                            event.stopPropagation();
                        }
                        Aspectize.UiExtensions.Notify(elem, 'OnSelectItem', ui.item.value);
                        return false;
                    };

                } else {

                    options.source = url;

                    options.select = function (event, ui) {
                        if (fillSelected) {
                            Aspectize.UiExtensions.ChangeProperty(elem, 'value', ui.item.label);
                            $(elem).val(ui.item.label);
                        }
                        Aspectize.UiExtensions.Notify(elem, 'OnSelectItem', ui.item.value);
                        return false;
                    };
                }

                var ac = $(elem).autocomplete(options);

                if (jqVersion >= "1.9") {
                    ac.data(attribute)._renderItem = function (ul, item) {
                        return $('<li class="ui-menu-item" role="presentation"></li>')
                            .data("item.autocomplete", item)
                            .append('<a><span class="' + item.type + '"></span>' + item.label + '</a>')
                            .appendTo(ul);
                    };
                }
            }
        });

        $(elem).keyup(function () {
            var newValue = $(elem).val();
            Aspectize.UiExtensions.ChangeProperty(elem, 'value', newValue);
           // Aspectize.UiExtensions.ChangeProperty(elem, 'Custom', true);
        });
    }
});

Aspectize.Extend("JQueryMask", {
    Properties: { Value: '', Mask: '' },
    Events: [],
{'fraction_non_alphanumeric': 0.1301965230536659, 'fraction_numerical': 0.0010078105316200555, 'mean_word_length': 1.1223098516241143, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4659328', 'n_tokens_mistral': 4021, 'n_tokens_neox': 3779, 'n_words': 716}