<commit_before>﻿/*
 * SPEasyForms.adapterCollection - collection of field control adapters.
 *
 * @requires jQuery.SPEasyForms.2015.01.beta 
 * @copyright 2014-2015 <NAME>
 * @license under the MIT license:
 *    http://www.opensource.org/licenses/mit-license.php
 */
/* global spefjQuery */
(function ($, undefined) {

    ////////////////////////////////////////////////////////////////////////////
    // Collection of field control adapters.
    ////////////////////////////////////////////////////////////////////////////
    $.spEasyForms.adapterCollection = {
        adapterImplementations: {},

        supportedTypes: function (options) {
            var opt = $.extend({}, $.spEasyForms.defaults, options);
            var result = [];
            if (opt.currentConfig.adapters && opt.currentConfig.adapters.def) {
                $.each(Object.keys(adapterCollection.adapterImplementations), function (idx, impl) {
                    if (impl in adapterCollection.adapterImplementations) {
                        result = result.concat(adapterCollection.adapterImplementations[impl].supportedTypes(opt));
                    }
                });
                result = $(result).filter(function (pos, item) {
                    return $.inArray(item, result) === pos;
                });
            }
            return result;
        },

        transform: function (options) {
            if (window.location.href.toLowerCase().indexOf("speasyformssettings.aspx") < 0) {
                var opt = $.extend({}, $.spEasyForms.defaults, options);
                if (opt.currentConfig && opt.currentConfig.adapters && opt.currentConfig.adapters.def) {
                    opt.adapters = opt.currentConfig.adapters.def;
                    $.each(opt.adapters, function (idx, adapter) {
                        opt.adapter = adapter;
                        if (opt.adapter.type in adapterCollection.adapterImplementations) {
                            adapterCollection.adapterImplementations[opt.adapter.type].transform(opt);
                        }
                    });
                }
            }
        },

        toEditor: function (options) {
            var opt = $.extend({}, $.spEasyForms.defaults, options);
            opt.adapters = opt.currentConfig.adapters.def;

            $.each(Object.keys(adapterCollection.adapterImplementations), function (idx, impl) {
                if (impl in adapterCollection.adapterImplementations) {
                    adapterCollection.adapterImplementations[impl].toEditor(opt);
                }
            });

            $("tr.speasyforms-adapter-static").remove();
            $.each(Object.keys(opt.adapters).sort(this.compareAdapters), function (idx, adapterField) {
                opt.adapter = opt.adapters[adapterField];
                opt.fieldName = adapterField;
                if (opt.adapter.type in adapterCollection.adapterImplementations) {
                    adapterCollection.drawAdapter(opt);
                }
            });
            if ($("tr.speasyforms-adapter-static").length === 0) {
                $("#spEasyFormsAdapterTable").append("<tr class='speasyforms-adapter-static'>" +
                    "<td class='ui-widget-content ui-corner-all nobr' colspan='5'>" +
                    "There are no adpaters configured for the current form.</td></tr>");
            }
            $("#spEasyFormsAdapterTable th").addClass("ui-widget-header").addClass("ui-corner-all").addClass("nobr");
            $("#tabs-min-adapters").append("<br /><br />");

            if ($("#spEasyFormsAdapterTable tr.speasyforms-fieldmissing").length > 0 && opt.verbose) {
                $("#adapterTab").addClass("speasyforms-fieldmissing").addClass("ui-state-error");
            }
            else {
                $("#adapterTab").removeClass("speasyforms-fieldmissing").removeClass("ui-state-error");
            }

            $("tr.speasyforms-adapter-static").each(function (idx, r) {
                var row = $(r);
                var internalName = $(row.find("td")[1]).text();
                if (row.find("td").length > 1) {
                    row.append("<td><button id='" + internalName + "Delete' title='Delete' class='speasyforms-containerbtn speasyforms-deleteadapter' style='height: 25px;'></button></td>");
                }
            });

            $(".speasyforms-deleteadapter").button({
                icons: {<commit_msg>fixed display of adapters on missing fields, applied jquery ui class<commit_after>﻿/*
 * SPEasyForms.adapterCollection - collection of field control adapters.
 *
 * @requires jQuery.SPEasyForms.2015.01.beta 
 * @copyright 2014-2015 Joe McShea
 * @license under the MIT license:
 *    http://www.opensource.org/licenses/mit-license.php
 */
/* global spefjQuery */
(function ($, undefined) {

    ////////////////////////////////////////////////////////////////////////////
    // Collection of field control adapters.
    ////////////////////////////////////////////////////////////////////////////
    $.spEasyForms.adapterCollection = {
        adapterImplementations: {},

        supportedTypes: function (options) {
            var opt = $.extend({}, $.spEasyForms.defaults, options);
            var result = [];
            if (opt.currentConfig.adapters && opt.currentConfig.adapters.def) {
                $.each(Object.keys(adapterCollection.adapterImplementations), function (idx, impl) {
                    if (impl in adapterCollection.adapterImplementations) {
                        result = result.concat(adapterCollection.adapterImplementations[impl].supportedTypes(opt));
                    }
                });
                result = $(result).filter(function (pos, item) {
                    return $.inArray(item, result) === pos;
                });
            }
            return result;
        },

        transform: function (options) {
            if (window.location.href.toLowerCase().indexOf("speasyformssettings.aspx") < 0) {
                var opt = $.extend({}, $.spEasyForms.defaults, options);
                if (opt.currentConfig && opt.currentConfig.adapters && opt.currentConfig.adapters.def) {
                    opt.adapters = opt.currentConfig.adapters.def;
                    $.each(opt.adapters, function (idx, adapter) {
                        opt.adapter = adapter;
                        if (opt.adapter.type in adapterCollection.adapterImplementations) {
                            adapterCollection.adapterImplementations[opt.adapter.type].transform(opt);
                        }
                    });
                }
            }
        },

        toEditor: function (options) {
            var opt = $.extend({}, $.spEasyForms.defaults, options);
            opt.adapters = opt.currentConfig.adapters.def;

            $.each(Object.keys(adapterCollection.adapterImplementations), function (idx, impl) {
                if (impl in adapterCollection.adapterImplementations) {
                    adapterCollection.adapterImplementations[impl].toEditor(opt);
                }
            });

            $("tr.speasyforms-adapter-static").remove();
            $.each(Object.keys(opt.adapters).sort(this.compareAdapters), function (idx, adapterField) {
                opt.adapter = opt.adapters[adapterField];
                opt.fieldName = adapterField;
                if (opt.adapter.type in adapterCollection.adapterImplementations) {
                    adapterCollection.drawAdapter(opt);
                }
            });
            if ($("tr.speasyforms-adapter-static").length === 0) {
                $("#spEasyFormsAdapterTable").append("<tr class='speasyforms-adapter-static'>" +
                    "<td class='ui-widget-content ui-corner-all nobr' colspan='5'>" +
                    "There are no adpaters configured for the current form.</td></tr>");
            }
            $("#spEasyFormsAdapterTable th").addClass("ui-widget-header").addClass("ui-corner-all").addClass("nobr");
            $("#tabs-min-adapters").append("<br /><br />");

            if ($("#spEasyFormsAdapterTable tr.speasyforms-fieldmissing").length > 0 && opt.verbose) {
                $("#spEasyFormsAdapterTable tr.speasyforms-fieldmissing td").addClass("ui-state-error");
            }

            $("tr.speasyforms-adapter-static").each(function (idx, r) {
                var row = $(r);
                var internalName = $(row.find("td")[1]).text();
                if (row.find("td").length > 1) {
                    row.append("<td><button id='" + internalName + "Delete' title='Delete' class='speasyforms-containerbtn speasyforms-deleteadapter' style='height: 25px;'></button></td>");
                }
            });

            $(".speasyforms-deleteadapter").button({
                icons: {
{'fraction_non_alphanumeric': 0.1661193522817348, 'fraction_numerical': 0.00498244819386253, 'mean_word_length': 1.733519034354689, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5329906', 'n_tokens_mistral': 2259, 'n_tokens_neox': 2115, 'n_words': 365}