Navigation Menu

Skip to content

Commit

Permalink
Mindless refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Sisk committed Dec 3, 2013
1 parent aa8f874 commit 5699986
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 219 deletions.
80 changes: 40 additions & 40 deletions -/js/admin-config.js
@@ -1,80 +1,80 @@
jQuery( function( $ ) {
var url = $( '[data-webcomic-admin-url]' ).data( 'webcomic-admin-url' );
var url = $( "[data-webcomic-admin-url]" ).data( "webcomic-admin-url" );

/** Update collection slug previews. */
$( '#webcomic_slugs_archive,#webcomic_slugs_webcomic,#webcomic_slugs_storyline,#webcomic_slugs_character' ).on( 'change', function() {
$( "#webcomic_slugs_archive,#webcomic_slugs_webcomic,#webcomic_slugs_storyline,#webcomic_slugs_character" ).on( "change", function() {
$.getJSON( url, {
slug: $( this ).val(),
preview: '#' + $( this ).attr( 'id' ),
collection: $( '[name=webcomic_collection]' ).val(),
webcomic_admin_ajax: 'WebcomicConfig::ajax_slug_preview'
preview: "#" + $( this ).attr( "id" ),
collection: $( "[name=webcomic_collection]" ).val(),
webcomic_admin_ajax: "WebcomicConfig::ajax_slug_preview"
}, function( data ) {
$( data.container ).val( data.slug ).siblings( '.description' ).children( 'b' ).html( data.slug )
$( data.container ).val( data.slug ).siblings( ".description" ).children( "b" ).html( data.slug )
} );
} );

/** Enable or disable print defaults. */
$( '#webcomic_commerce_business' ).on( 'change', function() {
$( "#webcomic_commerce_business" ).on( "change", function() {
$.getJSON( url, {
business: $( this ).val(),
webcomic_admin_ajax: 'WebcomicConfig::ajax_commerce_defaults'
webcomic_admin_ajax: "WebcomicConfig::ajax_commerce_defaults"
}, function ( data ) {
if ( data.clear ) {
$( '#webcomic_commerce_prints,#webcomic_commerce_originals' ).removeAttr( 'disabled' ).siblings( 'span' ).removeClass( 'description' );
$( "#webcomic_commerce_prints,#webcomic_commerce_originals" ).removeAttr( "disabled" ).siblings( "span" ).removeClass( "description" );
} else {
$( '#webcomic_commerce_prints,#webcomic_commerce_originals' ).removeAttr( 'checked' ).attr( 'disabled', true ).siblings( 'span' ).addClass( 'description' );
$( "#webcomic_commerce_prints,#webcomic_commerce_originals" ).removeAttr( "checked" ).attr( "disabled", true ).siblings( "span" ).addClass( "description" );
}
} );
} ).trigger( 'change' );
} ).trigger( "change" );

/** Update Twitter authorized account. */
$( '#webcomic_twitter_consumer_key,#webcomic_twitter_consumer_secret' ).on( 'change', function() {
$( "#webcomic_twitter_consumer_key,#webcomic_twitter_consumer_secret" ).on( "change", function() {
$.get( url, {
consumer_key: $( '#webcomic_twitter_consumer_key' ).val(),
consumer_secret: $( '#webcomic_twitter_consumer_secret' ).val(),
collection: $( '[name=webcomic_collection]' ).val(),
webcomic_admin_ajax: 'WebcomicConfig::ajax_twitter_account'
consumer_key: $( "#webcomic_twitter_consumer_key" ).val(),
consumer_secret: $( "#webcomic_twitter_consumer_secret" ).val(),
collection: $( "[name=webcomic_collection]" ).val(),
webcomic_admin_ajax: "WebcomicConfig::ajax_twitter_account"
}, function ( data ) {
$( '#webcomic_twitter_account' ).html( data );
$( "#webcomic_twitter_account" ).html( data );
} );
} );

/** Remove the webcomic image. */
$( document ).on( 'click', '.webcomic-image-x', function() {
$( document ).on( "click", ".webcomic-image-x", function() {
$e = $( this );

$.get( url, {
id: 0,
webcomic_admin_ajax: $e.data( 'callback' )
webcomic_admin_ajax: $e.data( "callback" )
}, function( data ) {
$( $e.data( 'target' ) ).html( data );
$( $e.data( "target" ) ).html( data );
} );
} );

/** Toggle collection setting sections. */
$( '.wrap h3' ).css( {
'border-top': 'thin solid #dfdfdf',
color: '#21759b',
cursor: 'pointer',
padding: '.5em 0 0'
} ).nextAll( 'table' ).hide();
$( ".wrap h3" ).css( {
"border-top": "thin solid #ddd",
color: "#0074a2",
cursor: "pointer",
padding: ".5em 0 0"
} ).nextAll( "table" ).hide();

$( '.wrap h3' ).on( 'mouseenter', function() { $( this ).css( 'color', '#d54e21' ); } );
$( '.wrap h3' ).on( 'mouseleave', function() { $( this ).css( 'color', '#21759b' ); } );
$( ".wrap h3" ).on( "mouseenter", function() { $( this ).css( "color", "#2ea2cc" ); } );
$( ".wrap h3" ).on( "mouseleave", function() { $( this ).css( "color", "#0074a2" ); } );

$( '.wrap h3' ).on( 'click', function() {
$( this ).nextAll( 'table:first' ).toggle();
$( ".wrap h3" ).on( "click", function() {
$( this ).nextAll( "table:first" ).toggle();
} );

$( '.wrap :not(table) + h3:first' ).trigger( 'click' );
$( ".wrap :not(table) + h3:first" ).trigger( "click" );
} );

/** Enable fancy image selection. */
( function( $ ) {
var frame;

$( function() {
$( document ). on( 'click', '.webcomic-image', function( e ) {
$( document ). on( "click", ".webcomic-image", function( e ) {
var $e = $( this );

e.preventDefault();
Expand All @@ -86,21 +86,21 @@ jQuery( function( $ ) {
}

frame = wp.media.frames.webcomicPoster = wp.media( {
title: $e.data( 'title' ),
title: $e.data( "title" ),
library: {
type: 'image'
type: "image"
},
button: {
text: $e.data( 'update' )
text: $e.data( "update" )
}
} );

frame.on( 'select', function() {
$.get( $( '[data-webcomic-admin-url]' ).data( 'webcomic-admin-url' ), {
id: frame.state().get( 'selection' ).first().id,
webcomic_admin_ajax: $e.data( 'callback' )
frame.on( "select", function() {
$.get( $( "[data-webcomic-admin-url]" ).data( "webcomic-admin-url" ), {
id: frame.state().get( "selection" ).first().id,
webcomic_admin_ajax: $e.data( "callback" )
}, function( data ) {
$( $e.data( 'target' ) ).html( data );
$( $e.data( "target" ) ).html( data );
} );
} );

Expand Down
6 changes: 3 additions & 3 deletions -/js/admin-legacy.js
@@ -1,12 +1,12 @@
/** Automatically continue legacy upgrades. */
jQuery( function( $ ) {
setTimeout( function() {
$( '.webcomic-auto #upgrade_legacy' ).trigger( 'click' );
$( ".webcomic-auto #upgrade_legacy" ).trigger( "click" );
}, 5000 );

$( '.webcomic-auto #upgrade_legacy' ).on( 'click', function() {
$( ".webcomic-auto #upgrade_legacy" ).on( "click", function() {
$( this ).hide();

$( '.webcomic-auto-message' ).html( $( '[data-webcomic-upgrade-continue]' ).data( 'webcomic-upgrade-continue' ) );
$( ".webcomic-auto-message" ).html( $( "[data-webcomic-upgrade-continue]" ).data( "webcomic-upgrade-continue" ) );
} );
} );
54 changes: 27 additions & 27 deletions -/js/admin-media.js
@@ -1,14 +1,14 @@
jQuery( function( $ ) {
var url = $( '[data-webcomic-admin-url]' ).data( 'webcomic-admin-url' );
var url = $( "[data-webcomic-admin-url]" ).data( "webcomic-admin-url" );

/** Warn if no selected days match the start date. */
$( 'form.webcomic-generator' ).on( 'submit', function() {
var v = $( 'input[name="webcomic_generate_start"]' ).val().split( '-' ),
$( "form.webcomic-generator" ).on( "submit", function() {
var v = $( "input[name='webcomic_generate_start']" ).val().split( "-" ),
d = new Date( v[ 0 ], parseInt( v[ 1 ] ) - 1, v[ 2 ] ),
x = false,
d1 = d2 = 0;

$.each( $( 'input[name="webcomic_generate_days[]"]:checked' ), function( i, e ) {
$.each( $( "input[name='webcomic_generate_days[]']:checked" ), function( i, e ) {
d1 = parseInt( $( e ).val() );
d2 = parseInt( d.getDay() );

Expand All @@ -20,56 +20,56 @@ jQuery( function( $ ) {
} );

if ( !x ) {
return window.confirm( $( '[data-webcomic-daycheck]' ).data( 'webcomic-daycheck' ) );
return window.confirm( $( "[data-webcomic-daycheck]" ).data( "webcomic-daycheck" ) );
}
} );

/** Allow media to be reordered when using the generator. */
$( '.webcomic-generator .wp-list-table tbody' ).sortable();
$( ".webcomic-generator .wp-list-table tbody" ).sortable();

/** Handle webcomic media reordering. */
$( '.webcomic-media-sort' ).sortable( {
$( ".webcomic-media-sort" ).sortable( {
update: function() {
$.post( url, {
ids: $( '[name="ids[]"]' ).serializeArray(),
webcomic_admin_ajax: 'WebcomicMedia::ajax_sort_media'
ids: $( "[name='ids[]']" ).serializeArray(),
webcomic_admin_ajax: "WebcomicMedia::ajax_sort_media"
}, function( data ) {
var message = $( 'div p' ).html();
var message = $( "div p" ).html();

$( 'div p' ).html( data );
$( "div p" ).html( data );

setTimeout( function() {
$( 'div p' ).html( message );
$( "div p" ).html( message );
}, 3000 );
} );
}
} );

/** Add regenerate and detach bulk actions. */
$( 'body.wp-admin.upload-php [name="action"],body.wp-admin.upload-php [name="action2"]' ).append( '<option value="webcomic_regenerate">'
+ $( '[data-webcomic-regenerate]' ).data( 'webcomic-regenerate' )
+ '</option><option value="webcomic_detach">'
+ $( '[data-webcomic-detach]' ).data( 'webcomic-detach' )
+ '</option>'
$( "body.wp-admin.upload-php [name='action'],body.wp-admin.upload-php [name='action2']" ).append( "<option value='webcomic_regenerate'>"
+ $( "[data-webcomic-regenerate]" ).data( "webcomic-regenerate" )
+ "</option><option value='webcomic_detach'>"
+ $( "[data-webcomic-detach]" ).data( "webcomic-detach" )
+ "</option>"
);

$( 'body.wp-admin.upload-php #doaction' ).on( 'click', function( e ) {
if ( 'webcomic_regenerate' === $( '[name="action"]' ).val() || 'webcomic_detach' === $( '[name="action"]' ).val() ) {
webcomic_bulk_action( $( '[name="action"]' ) );
$( "body.wp-admin.upload-php #doaction" ).on( "click", function( e ) {
if ( "webcomic_regenerate" === $( "[name='action']" ).val() || "webcomic_detach" === $( "[name='action']" ).val() ) {
webcomic_bulk_action( $( "[name='action']" ) );
}
} );

$( 'body.wp-admin.upload-php #doaction2' ).on( 'click', function( e ) {
if ( 'webcomic_regenerate' === $( '[name="action2"]' ).val() || 'webcomic_detach' === $( '[name="action2"]' ).val() ) {
webcomic_bulk_action( $( '[name="action2"]' ) );
$( "body.wp-admin.upload-php #doaction2" ).on( "click", function( e ) {
if ( "webcomic_regenerate" === $( "[name='action2']" ).val() || "webcomic_detach" === $( "[name='action2']" ).val() ) {
webcomic_bulk_action( $( "[name='action2']" ) );
}
} );

function webcomic_bulk_action( $el ) {
var $form = $el.parents( 'form' );
var $form = $el.parents( "form" );

$el.attr( 'name', 'webcomic_action' );
$form.attr( 'method', 'post' );
$form.attr( 'action', url );
$el.attr( "name", "webcomic_action" );
$form.attr( "method", "post" );
$form.attr( "action", url );
}
} );
34 changes: 17 additions & 17 deletions -/js/admin-meta.js
Expand Up @@ -2,45 +2,45 @@ var wpActiveEditor;

jQuery( function( $ ) {
/** Refresh the webcomic media meta box. */
$( document ).on( 'mousedown', '.media-modal-close,.media-modal-backdrop,.media-button-insert', function() {
$( document ).on( "mousedown", ".media-modal-close,.media-modal-backdrop,.media-button-insert", function() {

setTimeout( function() {
$.get( $( '[data-webcomic-admin-url]' ).data( 'webcomic-admin-url' ), {
post: $( '#post_ID' ).val(),
webcomic_admin_ajax: 'WebcomicPosts::ajax_media_preview'
$.get( $( "[data-webcomic-admin-url]" ).data( "webcomic-admin-url" ), {
post: $( "#post_ID" ).val(),
webcomic_admin_ajax: "WebcomicPosts::ajax_media_preview"
}, function( data ) {
$( '#webcomic_media_preview' ).html( data );
$( "#webcomic_media_preview" ).html( data );
} );
}, 500 );
} );

/** Dynamically update the price preview for prints. */
$( '#webcomic_commerce_adjust_prices_domestic,#webcomic_commerce_adjust_shipping_domestic' ).on( 'change', function() {
calculate_total( 'domestic' );
$( "#webcomic_commerce_adjust_prices_domestic,#webcomic_commerce_adjust_shipping_domestic" ).on( "change", function() {
calculate_total( "domestic" );
} );

$( '#webcomic_commerce_adjust_prices_international,#webcomic_commerce_adjust_shipping_international' ).on( 'change', function() {
calculate_total( 'international' );
$( "#webcomic_commerce_adjust_prices_international,#webcomic_commerce_adjust_shipping_international" ).on( "change", function() {
calculate_total( "international" );
} );

$( '#webcomic_commerce_adjust_prices_original,#webcomic_commerce_adjust_shipping_original' ).on( 'change', function() {
calculate_total( 'original' );
$( "#webcomic_commerce_adjust_prices_original,#webcomic_commerce_adjust_shipping_original" ).on( "change", function() {
calculate_total( "original" );
} );

$( '#webcomic_commerce_original_available' ).on( 'click', function() {
calculate_total( 'original' );
$( "#webcomic_commerce_original_available" ).on( "click", function() {
calculate_total( "original" );
} );

/** Calculate and update print prices. */
function calculate_total( id ) {
var total;

if ( 'original' === id && !$( '#webcomic_commerce_original_available' ).attr( 'checked' ) ) {
$( '#webcomic_original_total' ).html( $( '[data-webcomic-original]' ).data( 'webcomic-original' ) );
if ( "original" === id && !$( "#webcomic_commerce_original_available" ).attr( "checked" ) ) {
$( "#webcomic_original_total" ).html( $( "[data-webcomic-original]" ).data( "webcomic-original" ) );
} else {
total = ( parseFloat( $( '#webcomic_commerce_' + id + '_price' ).html() ) * ( 1 + ( parseFloat( $( '#webcomic_commerce_adjust_prices_' + id ).val() ) * .01 ) ) ) + ( parseFloat( $( '#webcomic_commerce_' + id + '_shipping' ).html() ) * ( 1 + ( parseFloat( $( '#webcomic_commerce_adjust_shipping_' + id ).val() ) * .01 ) ) );
total = ( parseFloat( $( "#webcomic_commerce_" + id + "_price" ).html() ) * ( 1 + ( parseFloat( $( "#webcomic_commerce_adjust_prices_" + id ).val() ) * .01 ) ) ) + ( parseFloat( $( "#webcomic_commerce_" + id + "_shipping" ).html() ) * ( 1 + ( parseFloat( $( "#webcomic_commerce_adjust_shipping_" + id ).val() ) * .01 ) ) );

$( '#webcomic_' + id + '_total' ).html( total.toFixed( 2 ) + ' ' + $( '[data-webcomic-currency]' ).data( 'webcomic-currency' ) );
$( "#webcomic_" + id + "_total" ).html( total.toFixed( 2 ) + " " + $( "[data-webcomic-currency]" ).data( "webcomic-currency" ) );
}
}
} );
20 changes: 10 additions & 10 deletions -/js/admin-pages.js
@@ -1,23 +1,23 @@
jQuery( function( $ ) {
var url = $( '[data-webcomic-admin-url]' ).data( 'webcomic-admin-url' );
var url = $( "[data-webcomic-admin-url]" ).data( "webcomic-admin-url" );

/** Update meta data values in the quick edit box for pages. */
$( document ).on( 'click', 'a.editinline', function() {
$( document ).on( "click", "a.editinline", function() {
$.getJSON( url, {
post: $( this ).parents( 'tr' ).attr( 'id' ).substr( 5, $( this ).parents( 'tr' ).attr( 'id' ).length ),
webcomic_admin_ajax: 'WebcomicPages::ajax_quick_edit'
post: $( this ).parents( "tr" ).attr( "id" ).substr( 5, $( this ).parents( "tr" ).attr( "id" ).length ),
webcomic_admin_ajax: "WebcomicPages::ajax_quick_edit"
}, function ( data ) {
$( '#webcomic_page_collection' ).val( data.collection );
$( "#webcomic_page_collection" ).val( data.collection );
} );
} );

/** Save meta data values from the quick edit box for pages. */
$( '.save' ).on( 'click', function() {
$( ".save" ).on( "click", function() {
$.get( url, {
post: $( this ).parents( 'tr' ).attr( 'id' ).substr( 5, $( this ).parents( 'tr' ).attr( 'id' ).length ),
collection: $( '#webcomic_page_collection' ).val(),
webcomic_page_inline_save: $( '#webcomic_page_inline_save' ).val(),
webcomic_admin_ajax: 'WebcomicPages::ajax_quick_save'
post: $( this ).parents( "tr" ).attr( "id" ).substr( 5, $( this ).parents( "tr" ).attr( "id" ).length ),
collection: $( "#webcomic_page_collection" ).val(),
webcomic_page_inline_save: $( "#webcomic_page_inline_save" ).val(),
webcomic_admin_ajax: "WebcomicPages::ajax_quick_save"
} );
} );
} );

0 comments on commit 5699986

Please sign in to comment.