LittleDemon WebShell


Linux server27.hostingraja.org 2.6.32-954.3.5.lve1.4.93.el6.x86_64 #1 SMP Wed Oct 4 17:04:29 UTC 2023 x86_64
Path : /home/udaipurk/public_html/websites/rishh/XStore Theme/xstore/framework/panel/js/settings/
File Upload :
Command :
Current File : //home/udaipurk/public_html/websites/rishh/XStore Theme/xstore/framework/panel/js/settings/media.js

/**
 * Description
 *
 * @package    media.js
 * @since      1.0.0
 * @author     Stas
 * @link       http://xstore.8theme.com
 * @license    Themeforest Split Licence
 */
jQuery(document).ready(function ($) {
    $(document).on('click', 'form.xstore-panel-settings .button-upload-file', function (e) {
        var fileUploader = '',
            title = $(this).data('title'),
            buttonTitle = $(this).data('button-title'),
            setting = $(this).data('option-name'),
            removeButton = $(this).next('.button-remove-file'),
            parent = $(this).parents('.xstore-panel-option'),
            fileType = $(this).data('file-type'),
            saveAs = $(this).data('save-as'),
            attachment,
            saveValue;

        e.preventDefault();

        fileUploader = wp.media({
            title: title,
            button: {
                text: buttonTitle
            },
            multiple: false,  // Set this to true to allow multiple files to be selected.
            library:
                {
                    type: [fileType]
                }
        })
            .on('select', function () {
                attachment = fileUploader.state().get('selection').first().toJSON();
                saveValue = attachment.url;
                // if ( saveAs == 'id' ) {
                //     saveValue = attachment.id
                // }
                if ($.inArray(fileType, ['image', 'image/svg+xml']) > -1) {
                    $(parent).find('.' + setting + '_preview').html('<img src="' + attachment.url + '">');
                } else if (fileType == 'audio') {
                    $(parent).find('.' + setting + '_preview').html('<img src="' + XStorePanelSettingsConfig.audioPlaceholder + '">');
                }
                $(parent).find('#' + setting).val(saveValue).trigger('change');
                removeButton.show();
            })
            .open();
    });

    $(document).on('click', 'form.xstore-panel-settings .button-remove-file', function (e) {
        let setting = $(this).data('option-name'),
            fileType = $(this).data('file-type'),
            parent = $(this).parents('.xstore-panel-option');
        $(parent).find('.' + setting + '_preview').html('');
        $(parent).find('#' + setting).val('').trigger('change');
        $(this).hide();
    });
});

LittleDemon - FACEBOOK
[ KELUAR ]