<commit_before>/**
 * @license Copyright (c) 2003-2015, CKSource - <NAME>. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */

'use strict';

(function () {
    CKEDITOR.dialog.add('link', function (editor) {
        var plugin = CKEDITOR.plugins.link;

        // Handles the event when the "Target" selection box is changed.
        var targetChanged = function () {
            var dialog = this.getDialog(),
                popupFeatures = dialog.getContentElement('target', 'popupFeatures'),
                targetName = dialog.getContentElement('target', 'linkTargetName'),
                value = this.getValue();

            if (!popupFeatures || !targetName)
                return;

            popupFeatures = popupFeatures.getElement();
            popupFeatures.hide();
            targetName.setValue('');

            switch (value) {
                case 'frame':
                    targetName.setLabel(editor.lang.link.targetFrameName);
                    targetName.getElement().show();
                    break;
                case 'popup':
                    popupFeatures.show();
                    targetName.setLabel(editor.lang.link.targetPopupName);
                    targetName.getElement().show();
                    break;
                default:
                    targetName.setValue(value);
                    targetName.getElement().hide();
                    break;
            }

        };

        // Handles the event when the "Type" selection box is changed.
        var linkTypeChanged = function () {
            var dialog = this.getDialog(),
                partIds = ['imcmsOptions', 'urlOptions', 'anchorOptions', 'emailOptions'],
                typeValue = this.getValue(),
                uploadTab = dialog.definition.getContents('upload'),
                uploadInitiallyHidden = uploadTab && uploadTab.hidden;

            if (typeValue == 'url' || typeValue == 'imcms') {
                if (editor.config.linkShowTargetTab)
                    dialog.showPage('target');
                if (!uploadInitiallyHidden)
                    dialog.showPage('upload');
            } else {
                dialog.hidePage('target');
                if (!uploadInitiallyHidden)
                    dialog.hidePage('upload');
            }

            for (var i = 0; i < partIds.length; i++) {
                var element = dialog.getContentElement('info', partIds[i]);
                if (!element)
                    continue;

                element = element.getElement().getParent().getParent();
                if (partIds[i] == typeValue + 'Options')
                    element.show();
                else
                    element.hide();
            }

            dialog.layout();
        };

        var setupParams = function (page, data) {
            if (data[page])
                this.setValue(data[page][this.id] || '');
        };

        var setupPopupParams = function (data) {
            return setupParams.call(this, 'target', data);
        };

        var setupAdvParams = function (data) {
            return setupParams.call(this, 'advanced', data);
        };

        var commitParams = function (page, data) {
            if (!data[page])
                data[page] = {};

            data[page][this.id] = this.getValue() || '';
        };

        var commitPopupParams = function (data) {
            return commitParams.call(this, 'target', data);
        };

        var commitAdvParams = function (data) {
            return commitParams.call(this, 'advanced', data);
        };

        var commonLang = editor.lang.common,
            linkLang = editor.lang.link,
            anchors;

        return {
            title: linkLang.title,
            minWidth: 350,
            minHeight: 230,
            contents: [{
                id: 'info',
                label: linkLang.info,
                title: linkLang.info,
                elements: [
                    {
                        id: 'linkType',
                        type: 'select',
                        label: linkLang.type,
                        'default': 'imcms',
                        items: [
                            ["ImCMS", 'imcms'],
                            [linkLang.toUrl, 'url'],
                            [linkLang.toAnchor, 'anchor'],
                            [linkLang.toEmail, 'email']
                        ],
                        onChange: linkTypeChanged,
                        setup: function (data) {
                            this.setValue(data.type || 'url');
                        },
                        commit: function (data) {
                            data.type = this.getValue();
                        }
                    },
                    {
                        type: 'vbox',
                        id: 'imcmsOptions',
                        children: [{
                            type: 'hbox',
                            widths: ['25%', '75%'],
                            children: [
                                {
                                    type: 'button',
                                    id: 'testr',
                                    label: commonLang.browseServer,
                                    onClick: function () {
                                        var that = this;
                                        var documentSearchDialog = new Imcms.Document.DocumentSearchDialog(function (term, callback) {
                                            Imcms.Editors.Document.filteredDocumentList(term, callback)
                                        });

                                        documentSearchDialog.result(function (data) {
                                            that.setValue(data.id);
                                        });
                                        documentSearchDialog._dialog.parent().css("z-index", "99999999");
                                        documentSearchDialog.open();
                                    },
                                    commit: function (data) {
                                        if (!data.imcms) {
                                            data.imcms = {};
                                        }
                                        data.imcms.docId = this.getValue();
                                    }
                                }
                            ],
                            setup: function () {
                                if (!this.getDialog().getContentElement('info', 'linkType'))
                                    this.getElement().show();
                            }
                        },
                            {
                                type: 'button',
                                id: 'browse',
                                hidden: 'true',
                                filebrowser: 'info:imcms',
                                label: commonLang.browseServer
                            }]
                    },
                    {
                        type: 'vbox',
                        id: 'urlOptions',
                        children: [{
                            type: 'hbox',
                            widths: ['25%', '75%'],
                            children: [{
                                id: 'protocol',
                                type: 'select',
                                label: commonLang.protocol,
                                'default': 'http://',<commit_msg>IMCMS-189 - Link in textfield does not work: - Removed unused element.<commit_after>/**
 * @license Copyright (c) 2003-2015, CKSource - <NAME>. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */

'use strict';

(function () {
    CKEDITOR.dialog.add('link', function (editor) {
        var plugin = CKEDITOR.plugins.link;

        // Handles the event when the "Target" selection box is changed.
        var targetChanged = function () {
            var dialog = this.getDialog(),
                popupFeatures = dialog.getContentElement('target', 'popupFeatures'),
                targetName = dialog.getContentElement('target', 'linkTargetName'),
                value = this.getValue();

            if (!popupFeatures || !targetName)
                return;

            popupFeatures = popupFeatures.getElement();
            popupFeatures.hide();
            targetName.setValue('');

            switch (value) {
                case 'frame':
                    targetName.setLabel(editor.lang.link.targetFrameName);
                    targetName.getElement().show();
                    break;
                case 'popup':
                    popupFeatures.show();
                    targetName.setLabel(editor.lang.link.targetPopupName);
                    targetName.getElement().show();
                    break;
                default:
                    targetName.setValue(value);
                    targetName.getElement().hide();
                    break;
            }

        };

        // Handles the event when the "Type" selection box is changed.
        var linkTypeChanged = function () {
            var dialog = this.getDialog(),
                partIds = ['imcmsOptions', 'urlOptions', 'anchorOptions', 'emailOptions'],
                typeValue = this.getValue(),
                uploadTab = dialog.definition.getContents('upload'),
                uploadInitiallyHidden = uploadTab && uploadTab.hidden;

            if (typeValue == 'url' || typeValue == 'imcms') {
                if (editor.config.linkShowTargetTab)
                    dialog.showPage('target');
                if (!uploadInitiallyHidden)
                    dialog.showPage('upload');
            } else {
                dialog.hidePage('target');
                if (!uploadInitiallyHidden)
                    dialog.hidePage('upload');
            }

            for (var i = 0; i < partIds.length; i++) {
                var element = dialog.getContentElement('info', partIds[i]);
                if (!element)
                    continue;

                element = element.getElement().getParent().getParent();
                if (partIds[i] == typeValue + 'Options')
                    element.show();
                else
                    element.hide();
            }

            dialog.layout();
        };

        var setupParams = function (page, data) {
            if (data[page])
                this.setValue(data[page][this.id] || '');
        };

        var setupPopupParams = function (data) {
            return setupParams.call(this, 'target', data);
        };

        var setupAdvParams = function (data) {
            return setupParams.call(this, 'advanced', data);
        };

        var commitParams = function (page, data) {
            if (!data[page])
                data[page] = {};

            data[page][this.id] = this.getValue() || '';
        };

        var commitPopupParams = function (data) {
            return commitParams.call(this, 'target', data);
        };

        var commitAdvParams = function (data) {
            return commitParams.call(this, 'advanced', data);
        };

        var commonLang = editor.lang.common,
            linkLang = editor.lang.link,
            anchors;

        return {
            title: linkLang.title,
            minWidth: 350,
            minHeight: 230,
            contents: [{
                id: 'info',
                label: linkLang.info,
                title: linkLang.info,
                elements: [
                    {
                        id: 'linkType',
                        type: 'select',
                        label: linkLang.type,
                        'default': 'imcms',
                        items: [
                            ["ImCMS", 'imcms'],
                            [linkLang.toUrl, 'url'],
                            [linkLang.toAnchor, 'anchor'],
                            [linkLang.toEmail, 'email']
                        ],
                        onChange: linkTypeChanged,
                        setup: function (data) {
                            this.setValue(data.type || 'url');
                        },
                        commit: function (data) {
                            data.type = this.getValue();
                        }
                    },
                    {
                        type: 'vbox',
                        id: 'imcmsOptions',
                        children: [{
                            type: 'hbox',
                            widths: ['25%', '75%'],
                            children: [
                                {
                                    type: 'button',
                                    id: 'testr',
                                    label: commonLang.browseServer,
                                    onClick: function () {
                                        var that = this;
                                        var documentSearchDialog = new Imcms.Document.DocumentSearchDialog(function (term, callback) {
                                            Imcms.Editors.Document.filteredDocumentList(term, callback)
                                        });

                                        documentSearchDialog.result(function (data) {
                                            that.setValue(data.id);
                                        });
                                        documentSearchDialog._dialog.parent().css("z-index", "99999999");
                                        documentSearchDialog.open();
                                    },
                                    commit: function (data) {
                                        if (!data.imcms) {
                                            data.imcms = {};
                                        }
                                        data.imcms.docId = this.getValue();
                                    }
                                }
                            ],
                            setup: function () {
                                if (!this.getDialog().getContentElement('info', 'linkType'))
                                    this.getElement().show();
                            }
                        }
                        ]
                    },
                    {
                        type: 'vbox',
                        id: 'urlOptions',
                        children: [{
                            type: 'hbox',
                            widths: ['25%', '75%'],
                            children: [{
                                id: 'protocol',
                                type: 'select',
                                label: commonLang.protocol,
                                'default': 'http://',
{'fraction_non_alphanumeric': 0.10203808887403942, 'fraction_numerical': 0.004343468092215168, 'mean_word_length': 0.9055258467023173, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 59, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1084137', 'n_tokens_mistral': 3314, 'n_tokens_neox': 3026, 'n_words': 640}