# You must use a tab-size of 4 spaces to edit this file.
---
zenario_pro_features_spare_alias:
    priv: _PRIV_PUBLISH_CONTENT_ITEM
    title: Creating a spare alias (301 redirect)
    key:
        id: ""
        id_is_error_log_id: false
    identifier:
        css_class: alias_url
        label: Spare alias
    hide_tab_bar: Yes
    tabs:
        spare_alias:
            edit_mode:
                enabled: Yes
            show_errors_after_field: description
            fields:
                description:
                    full_width: Yes
                    snippet:
                        html: |
                            <p>A spare alias is a permanent (301) redirect. When a visitor requests a spare alias, they can be redirected to another content item or external URL.</p>
                            <p>Use this admin box to define a spare alias, and where visitors will be redirected to.</p>
                grouping_left:
                    type: grouping
                    grouping_css_class: zenario_grouping__left
                alias:
                    grouping: grouping_left
                    label: 'Spare alias name:'
                    type: text
                    maxlength: 255
                    style: 'width:350px'
                    oninput: |
                        var $preview = $('#spare_alias_preview');
                        var alias = $(this).val().split('/').pop();

                        if (zenarioA.siteSettings.mod_rewrite_enabled && $preview.data('suffix')) {
                            alias = alias.replace($preview.data('suffix'), '');
                        }
                        $(this).val(alias);
                        
                        var preview = $preview.data('base') + alias;
                        var target = false;

                        if (zenarioAB.value("target_loc") == "int") {
                            target = zenarioAB.value("redirect_target_url")
                        } else {
                            target = get("ext_url").value;
                            var pattern = /^((http|https|ftp):\/\/)/;
                            if (!pattern.test(target)) {
                                target = 'http://' + target;
                            }
                        }

                        if (alias !== "") {
                            preview += $preview.data('suffix');
                        }
                        
                        $preview.text(preview).prop('href', target);
                    post_field_html: |
                        &nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:30px;position:absolute;">⟶</span>
                preview:
                    grouping: grouping_left
                    pre_field_html: 'Preview:<br>'
                    note_below: |
                        Click this URL to test.
                    snippet:
                        html: ''
                redirect_target_url:
                    grouping: grouping_left
                    type: text
                    style: display:none;
                grouping_right:
                    type: grouping
                    grouping_css_class: zenario_grouping__right
                target_loc:
                    grouping: grouping_right
                    label: 'Redirect visitors to:'
                    type: select
                    value: int
                    values:
                        int:
                            ord: 2
                            label: A content item
                        ext:
                            ord: 3
                            label: An external URL
                    format_onchange: Yes
                hyperlink_target:
                    grouping: grouping_right
                    label: 'Content item:'
                    pick_items:
                        path: zenario__content/panels/content/refiners/published_draft_and_unlisted_only////
                        min_path: zenario__content/panels/content
                        max_path: zenario__content/panels/content
                        target_path: zenario__content/panels/content
                        select_phrase: Select content item...
                        hide_remove_button: Yes
                    validation:
                        required_if_not_hidden: Please select a content item
                    format_onchange: Yes
                    indent: 1
                ext_url:
                    grouping: grouping_right
                    label: 'External URL:'
                    type: url
                    maxlength: "255"
                    validation:
                        required_if_not_hidden: Please enter a URL
                    indent: 1
                    onkeyup: |
                        $(lib.get('alias')).keyup();
                delete_error_log:
                    grouping: grouping_right
                    label: ''                    
                    type: checkbox
                    value: false
                delete_alias:              
                    type: hidden
    confirm:
        show: false
        html: true
        cancel_button_message: Cancel
        message_type: warning
