Clean up js

This commit is contained in:
Robin Cornett
2016-04-02 12:05:19 -04:00
parent dbc2d2786c
commit 0c966656fe
3 changed files with 22 additions and 21 deletions
@@ -151,8 +151,8 @@ class Display_Featured_Image_Genesis_Output {
'medium_large' => $medium_large[3] ? $medium_large[1] : '',
),
'height' => (int) $this->setting['less_header'],
'centeredX' => (int) (bool) $backstretch_vars['centeredX'],
'centeredY' => (int) (bool) $backstretch_vars['centeredY'],
'centeredX' => (bool) $backstretch_vars['centeredX'],
'centeredY' => (bool) $backstretch_vars['centeredY'],
'fade' => (int) $backstretch_vars['fade'],
);
+18 -18
View File
@@ -1,8 +1,9 @@
jQuery(document).ready(function($){
jQuery( document ).ready( function ( $ ) {
'use strict';
var custom_uploader;
var target_input;
var preview;
var custom_uploader,
target_input,
preview;
$( '.upload_default_image' ).click(function(e) {
@@ -11,16 +12,16 @@ jQuery(document).ready(function($){
e.preventDefault();
//If the uploader object has already been created, reopen the dialog
if (custom_uploader) {
if ( custom_uploader ) {
custom_uploader.open();
return;
}
//Extend the wp.media object
custom_uploader = wp.media.frames.file_frame = wp.media({
title: ([objectL10n.text]),
title: ( [ objectL10n.text ] ),
button: {
text: ([objectL10n.text])
text: ( [ objectL10n.text ] )
},
multiple: false
});
@@ -28,12 +29,12 @@ jQuery(document).ready(function($){
//When a file is selected, grab the URL and set it as the text field's value
custom_uploader.on( 'select', function() {
attachment = custom_uploader.state().get( 'selection' ).first().toJSON();
preview = $( target_input ).prevAll( '.upload_logo_preview' );
previewImage = $( '<div class="upload_logo_preview"><img width="300" src="' + attachment.url + '" /></div>' );
var attachment = custom_uploader.state().get( 'selection' ).first().toJSON(),
preview = $( target_input ).prevAll( '.upload_logo_preview' ),
previewImage = $( '<div class="upload_logo_preview"><img width="300" src="' + attachment.url + '" /></div>' );
$( target_input ).val( attachment.id );
if ( $( preview ).length ) {
$( preview ).remove();
if ( preview.length ) {
preview.remove();
}
$( target_input ).before( previewImage );
});
@@ -45,8 +46,8 @@ jQuery(document).ready(function($){
$( '.delete_image' ).click( function() {
target_input = $(this).prevAll( '.upload_image_id' );
previewView = $(this).prevAll( '.upload_logo_preview' );
target_input = $( this ).prevAll( '.upload_image_id' );
var previewView = $( this ).prevAll( '.upload_logo_preview' );
$( target_input ).val( '' );
$( previewView ).remove();
@@ -54,9 +55,9 @@ jQuery(document).ready(function($){
});
$( '#submit' ).click( function() {
submitButton = $(this).parentsUntil( '#addtag' );
previewView = submitButton.siblings( '.term-image-wrap' ).children( '.upload_logo_preview' );
clearInput = submitButton.siblings( '.term-image-wrap' ).children( '.upload_image_id' );
var submitButton = $( this ).parentsUntil( '#addtag' ),
previewView = submitButton.siblings( '.term-image-wrap' ).children( '.upload_logo_preview' ),
clearInput = submitButton.siblings( '.term-image-wrap' ).children( '.upload_image_id' );
if ( $( previewView ).length && $( submitButton ).length ) {
$( previewView ).delay( 1000 ).fadeOut( 200, function() {
@@ -65,5 +66,4 @@ jQuery(document).ready(function($){
});
}
});
});
+2 -1
View File
@@ -1,4 +1,5 @@
function term_postback( select_id, taxonomy ) {
'use strict';
var data = {
action: 'widget_selector',
taxonomy: taxonomy
@@ -22,4 +23,4 @@ function term_postback( select_id, taxonomy ) {
control.append(new_option);
});
});
}
}