1(function( $ ) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 /** 32* 33* wpMediaUploader v1.0 2016-11-05 34* Copyright (c) 2016 Smartcat 35* 36*/ 37jQuery(document).ready(function ($) { 38$('.video_url div.fes-fields,.fes_cover_photo div.fes-fields,.audio_url div.fes-fields').addClass('upload-cover-wrapper'); 39 40$.wpMediaUploader = function (options) { 41 42var settings = $.extend({ 43 44target: '.upload-cover-wrapper', // The class wrapping the textbox 45uploaderTitle: 'Select or upload File', // The title of the media upload popup 46uploaderButton: 'Set File', // the text of the button in the media upload popup 47multiple: false, // Allow the user to select multiple images 48buttonText: 'Upload', // The text of the upload button 49buttonClass: '.upload-cover-button', // the class of the upload button 50previewSize: '150px', // The preview image size 51modal: false, // is the upload button within a bootstrap modal ? 52buttonStyle: {}, // style the button 53}, options); 54 55$(settings.target).append('<a href="#" class="' + settings.buttonClass.replace('.', '') + '">' + settings.buttonText + '</a>'); 56// $(settings.target).append('<div><br><img src="#" style="display: none; width: ' + settings.previewSize + '"/></div>') // image thumbnail 57 58$(settings.buttonClass).css(settings.buttonStyle); 59 60$('body').on('click', settings.buttonClass, function (e) { 61 62e.preventDefault(); 63var selector = $(this).parent(settings.target); 64var custom_uploader = wp.media({ 65title: settings.uploaderTitle, 66button: { 67text: settings.uploaderButton 68}, 69multiple: settings.multiple 70}) 71.on('select', function () { 72var attachment = custom_uploader.state().get('selection').first().toJSON(); 73selector.find('img').attr('src', attachment.url).show(); 74selector.find('input').val(attachment.url); 75if (settings.modal) { 76$('.modal').css('overflowY', 'auto'); 77} 78}) 79.open(); 80}); 81 82 83} 84 85$.wpMediaUploader(); 86 87}); 88 89 90 91})( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.