Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor javascript.

Eliminate all inline <script> tags and javascript function calls.
Rename admin-terms.js to admin-taxonomy.js
  • Loading branch information...
commit 598e894f24e1e24c58edc875c795b6980ddcefb4 1 parent f8d5de3
Michael Sisk authored
View
86 -/js/admin-config.js
@@ -1,55 +1,45 @@
-/** Update collection slug previews. */
-function webcomic_slug_preview( url ) {
- jQuery( 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'
- }, function( data ) {
- $( data.container ).val( data.slug ).siblings( '.description' ).children( 'b' ).html( data.slug )
- } );
+jQuery( function( $ ) {
+ 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() {
+ $.getJSON( url, {
+ slug: $( this ).val(),
+ 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 )
} );
} );
-}
-
-/** Enable or disable print defaults. */
-function webcomic_commerce_defaults( url ) {
- jQuery( function( $ ) {
- $( '#webcomic_commerce_business' ).on( 'change', function() {
- $.getJSON( url, {
- business: $( this ).val(),
- webcomic_admin_ajax: 'WebcomicConfig::ajax_commerce_defaults'
- }, function ( data ) {
- if ( data.clear ) {
- $( '#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' );
- }
- } );
- } ).trigger( 'change' );
- } );
-}
-
-/** Update Twitter authorized account. */
-function webcomic_twitter_account( url ) {
- jQuery( 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'
- }, function ( data ) {
- $( '#webcomic_twitter_account' ).html( data );
- } );
+
+ /** Enable or disable print defaults. */
+ $( '#webcomic_commerce_business' ).on( 'change', function() {
+ $.getJSON( url, {
+ business: $( this ).val(),
+ webcomic_admin_ajax: 'WebcomicConfig::ajax_commerce_defaults'
+ }, function ( data ) {
+ if ( data.clear ) {
+ $( '#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' );
+ }
+ } );
+ } ).trigger( 'change' );
+
+ /** Update Twitter authorized account. */
+ $( '#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'
+ }, function ( data ) {
+ $( '#webcomic_twitter_account' ).html( data );
} );
} );
-}
-
-/** Toggle collection setting sections. */
-jQuery( function( $ ) {
+
+ /** Toggle collection setting sections. */
$( '.wrap h3' ).css( {
'border-top': 'thin solid #dfdfdf',
color: '#21759b',
View
20 -/js/admin-legacy.js
@@ -1,14 +1,12 @@
/** Automatically continue legacy upgrades. */
-function webcomic_auto_upgrade( c ) {
- jQuery( function( $ ) {
- setTimeout( function() {
- $( '.webcomic-auto #upgrade_legacy' ).trigger( 'click' );
- }, 5000 );
+jQuery( function( $ ) {
+ setTimeout( function() {
+ $( '.webcomic-auto #upgrade_legacy' ).trigger( 'click' );
+ }, 5000 );
+
+ $( '.webcomic-auto #upgrade_legacy' ).on( 'click', function() {
+ $( this ).hide();
- $( '.webcomic-auto #upgrade_legacy' ).on( 'click', function() {
- $( this ).hide();
-
- $( '.webcomic-auto-message' ).html( c );
- } );
+ $( '.webcomic-auto-message' ).html( $( '[data-webcomic-upgrade-continue]' ).data( 'webcomic-upgrade-continue' ) );
} );
-}
+} );
View
83 -/js/admin-media.js
@@ -1,50 +1,45 @@
-/** Warn if no selected days match the start date. */
-function webcomic_generator( warning ) {
- jQuery( function( $ ) {
- $( 'form' ).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;
+jQuery( function( $ ) {
+ /** Warn if no selected days match the start date. */
+ $( '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 ) {
+ d1 = parseInt( $( e ).val() );
+ d2 = parseInt( d.getDay() );
- $.each( $( 'input[name="webcomic_generate_days[]"]:checked' ), function( i, e ) {
- d1 = parseInt( $( e ).val() );
- d2 = parseInt( d.getDay() );
+ if ( d1 === d2 || ( 7 === d1 && 0 === d2 ) ) {
+ x = true;
- if ( d1 === d2 || ( 7 === d1 && 0 === d2 ) ) {
- x = true;
-
- return false;
- }
- } );
-
- if ( !x ) {
- return window.confirm( warning );
+ return false;
}
} );
- $( '.wp-list-table tbody' ).sortable();
- } );
-}
-
-/** Handle webcomic media reordering. */
-function webcomic_media( url ) {
- jQuery( function( $ ) {
- $( 'ul' ).sortable( {
- update: function() {
- $.post( url, {
- ids: $( '[name="ids[]"]' ).serializeArray(),
- webcomic_admin_ajax: 'WebcomicMedia::ajax_order_media'
- }, function( data ) {
- var message = $( 'div p' ).html();
-
- $( 'div p' ).html( data );
-
- setTimeout( function() {
- $( 'div p' ).html( message );
- }, 5000 );
- } );
- }
- } );
+ if ( !x ) {
+ 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();
+
+ /** Handle webcomic media reordering. */
+ $( '.webcomic-media' ).sortable( {
+ update: function() {
+ $.post( url, {
+ ids: $( '[name="ids[]"]' ).serializeArray(),
+ webcomic_admin_ajax: 'WebcomicMedia::ajax_order_media'
+ }, function( data ) {
+ var message = $( 'div p' ).html();
+
+ $( 'div p' ).html( data );
+
+ setTimeout( function() {
+ $( 'div p' ).html( message );
+ }, 5000 );
+ } );
+ }
} );
-}
+} );
View
85 -/js/admin-meta.js
@@ -1,49 +1,44 @@
-/** Refresh the webcomic media meta box. */
-function webcomic_media_meta( url ) {
- jQuery( function( $ ) {
- $( document ).on( 'mousedown', '.media-modal-close,.media-modal-backdrop,.media-button-insert', function() {
-
- setTimeout( function() {
- $.get( url, {
- post: $( '#post_ID' ).val(),
- webcomic_admin_ajax: 'WebcomicPosts::ajax_media_preview'
- }, function( data ) {
- $( '#webcomic_media_preview' ).html( data );
- } );
- }, 500 );
- } );
- } );
-}
-
-/** Dynamically update the price preview for prints. */
-function webcomic_prints_meta( currency, sold ) {
- jQuery( function( $ ) {
- $( '#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' );
- } );
+jQuery( function( $ ) {
+ /** Refresh the webcomic media meta box. */
+ $( document ).on( 'mousedown', '.media-modal-close,.media-modal-backdrop,.media-button-insert', function() {
- $( '#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' );
- } );
+ setTimeout( function() {
+ $.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 );
+ } );
+ }, 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_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_original_available' ).on( 'click', function() {
+ calculate_total( 'original' );
+ } );
+
+ /** Calculate and update print prices. */
+ function calculate_total( id ) {
+ var total;
- 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' ) );
+ } 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 ) ) );
- if ( 'original' === id && !$( '#webcomic_commerce_original_available' ).attr( 'checked' ) ) {
- $( '#webcomic_original_total' ).html( sold );
- } 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 ) ) );
-
- $( '#webcomic_' + id + '_total' ).html( total.toFixed( 2 ) + ' ' + currency );
- }
+ $( '#webcomic_' + id + '_total' ).html( total.toFixed( 2 ) + ' ' + $( '[data-webcomic-currency]' ).data( 'webcomic-currency' ) );
}
- } );
-}
+ }
+} );
View
40 -/js/admin-pages.js
@@ -1,27 +1,23 @@
-/** Update meta data values in the quick edit box for pages. */
-function webcomic_page_quick_edit( url ) {
- jQuery( 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'
- }, function ( data ) {
- $( '#webcomic_page_collection' ).val( data.collection );
- } );
+jQuery( function( $ ) {
+ 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() {
+ $.getJSON( url, {
+ 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 );
} );
} );
-}
-/** Save meta data values from the quick edit box for pages. */
-function webcomic_page_quick_save( url ) {
- jQuery( 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'
- } );
+ /** Save meta data values from the quick edit box for pages. */
+ $( '.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'
} );
} );
-}
+} );
View
50 -/js/admin-posts.js
@@ -1,31 +1,27 @@
-/** Update meta data values in the quick edit box for webcomic posts. */
-function webcomic_quick_edit( url ) {
- jQuery( 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: 'WebcomicPosts::ajax_quick_edit'
- }, function ( data ) {
- $( '#webcomic_prints' ).attr( 'checked', data.prints ).attr( 'disabled', data.prints_disabled );
- $( '#webcomic_original' ).attr( 'checked', data.original );
- $( '#webcomic_transcripts' ).attr( 'checked', data.transcripts );
- } );
+jQuery( function( $ ) {
+ var url = $( '[data-webcomic-admin-url]' ).data( 'webcomic-admin-url' );
+
+ /** Update meta data values in the quick edit box for webcomic posts. */
+ $( 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: 'WebcomicPosts::ajax_quick_edit'
+ }, function ( data ) {
+ $( '#webcomic_prints' ).attr( 'checked', data.prints ).attr( 'disabled', data.prints_disabled );
+ $( '#webcomic_original' ).attr( 'checked', data.original );
+ $( '#webcomic_transcripts' ).attr( 'checked', data.transcripts );
} );
} );
-}
-
-/** Save meta data values from the quick edit box for webcomic posts. */
-function webcomic_quick_save( url ) {
- jQuery( function( $ ) {
- $( '.save' ).on( 'click', function() {
- $.get( url, {
- post: $( this ).parents( 'tr' ).attr( 'id' ).substr( 5, $( this ).parents( 'tr' ).attr( 'id' ).length ),
- prints: $( '#webcomic_prints:checked' ).val() ? 1 : 0,
- original: $( '#webcomic_original:checked' ).val() ? 1 : 0,
- transcripts: $( '#webcomic_transcripts:checked' ).val() ? 1 : 0,
- webcomic_inline_save: $( '#webcomic_inline_save' ).val(),
- webcomic_admin_ajax: 'WebcomicPosts::ajax_quick_save'
- } );
+
+ /** Save meta data values from the quick edit box for webcomic posts. */
+ $( '.save' ).on( 'click', function() {
+ $.get( url, {
+ post: $( this ).parents( 'tr' ).attr( 'id' ).substr( 5, $( this ).parents( 'tr' ).attr( 'id' ).length ),
+ prints: $( '#webcomic_prints:checked' ).val() ? 1 : 0,
+ original: $( '#webcomic_original:checked' ).val() ? 1 : 0,
+ transcripts: $( '#webcomic_transcripts:checked' ).val() ? 1 : 0,
+ webcomic_inline_save: $( '#webcomic_inline_save' ).val(),
+ webcomic_admin_ajax: 'WebcomicPosts::ajax_quick_save'
} );
} );
-}
+} );
View
12 -/js/admin-taxonomy.js
@@ -0,0 +1,12 @@
+/**
+ * Modify the add/edit tag forms to disable AJAX submission and
+ * accept file uploads. Also disable AJAX deletion of storylines.
+ */
+jQuery( function( $ ) {
+ $( '#addtag,#edittag' ).attr( 'enctype', 'multipart/form-data' );
+ $( '#submit' ).attr( 'id', 'webcomic-submit' );
+
+ if ( 'storyline' === $( '[data-webcomic-taxonomy]' ).data( 'webcomic-taoxnomy' ) ) {
+ $( 'a.delete-tag' ).removeClass( 'delete-tag' ).addClass( 'webcomic-delete-term' );
+ }
+} );
View
14 -/js/admin-terms.js
@@ -1,14 +0,0 @@
-/**
- * Modify the add/edit tag forms to disable AJAX submission and
- * accept file uploads. Also disable AJAX deletion of storylines.
- */
-function webcomic_edit_terms( taxonomy ) {
- jQuery( function( $ ) {
- $( '#addtag,#edittag' ).attr( 'enctype', 'multipart/form-data' );
- $( '#submit' ).attr( 'id', 'webcomic-submit' );
-
- if ( 'storyline' === taxonomy ) {
- $( 'a.delete-tag' ).removeClass( 'delete-tag' ).addClass( 'webcomic-delete-term' );
- }
- } );
-}
View
86 -/js/admin-transcripts.js
@@ -1,48 +1,50 @@
-/**
- * Handle updating the post list (when the collection is changed)
- * and the webcomic preview (when the post is changed).
- */
-function webcomic_transcript_meta( url ) {
- jQuery( function( $ ) {
- $( '#webcomic_collection' ).attr( 'disabled', false ).on( 'change', function() {
- $.get( url, {
- collection: $( '#webcomic_collection' ).val(),
- parent: $( '#webcomic_parent' ).val(),
- webcomic_admin_ajax: 'WebcomicTranscripts::ajax_posts'
- }, function( data ) {
- $( '#webcomic_post_list' ).html( data );
- $( '#webcomic_post' ).trigger( 'change' );
- } );
+jQuery( function( $ ) {
+ var url = $( '[data-webcomic-admin-url]' ).data( 'webcomic-admin-url' );
+
+ /**
+ * Update the post list when the collection is changed.
+ */
+ $( '#webcomic_collection' ).attr( 'disabled', false ).on( 'change', function() {
+ $.get( url, {
+ collection: $( '#webcomic_collection' ).val(),
+ parent: $( '#webcomic_parent' ).val(),
+ webcomic_admin_ajax: 'WebcomicTranscripts::ajax_posts'
+ }, function( data ) {
+ $( '#webcomic_post_list' ).html( data );
+ $( '#webcomic_post' ).trigger( 'change' );
} );
-
- $( '#webcomic_author_add' ).on( 'click', function() {
- var key = ( new Date() ).getTime();
-
- $( '#webcomic_author_table tbody' ).append( '<tr><td><button class="delete">-</button></td><td><input type="text" name="webcomic_author_new[' + key + '][name]"></td><td><input type="email" name="webcomic_author_new[' + key + '][email]"></td><td><input type="url" name="webcomic_author_new[' + key + '][url]"></td><td><input type="text" name="webcomic_author_new[' + key + '][ip]"></td><td><input type="text" name="webcomic_author_new[' + key + '][time]"></td></tr>' );
-
- return false;
+ } );
+
+ /** Update the webcomic preview when the post is changed. */
+ $( document ).on( 'change', '#webcomic_post', function() {
+ $.get( url, {
+ parent: $( '#webcomic_post' ).val() ? $( '#webcomic_post' ).val() : 0,
+ webcomic_admin_ajax: 'WebcomicTranscripts::ajax_post_transcripts'
+ }, function( data ) {
+ $( '#webcomic_post_transcripts' ).html( data );
} );
- $( document ).on( 'click', '#webcomic_author_table .delete', function() {
- $( this ).parents( 'tr' ).remove();
-
- return false;
+ $.get( url, {
+ post: $( '#webcomic_post' ).val() ? $( '#webcomic_post' ).val() : 0,
+ webcomic_admin_ajax: 'WebcomicTranscripts::ajax_preview'
+ }, function( data ) {
+ $( '#webcomic_post_preview' ).html( data );
} );
+ } );
+
+ /** Add a new row for custom authors. */
+ $( '#webcomic_author_add' ).on( 'click', function() {
+ var key = ( new Date() ).getTime();
- $( document ).on( 'change', '#webcomic_post', function() {
- $.get( url, {
- parent: $( '#webcomic_post' ).val() ? $( '#webcomic_post' ).val() : 0,
- webcomic_admin_ajax: 'WebcomicTranscripts::ajax_post_transcripts'
- }, function( data ) {
- $( '#webcomic_post_transcripts' ).html( data );
- } );
-
- $.get( url, {
- post: $( '#webcomic_post' ).val() ? $( '#webcomic_post' ).val() : 0,
- webcomic_admin_ajax: 'WebcomicTranscripts::ajax_preview'
- }, function( data ) {
- $( '#webcomic_post_preview' ).html( data );
- } );
- } );
+ $( '#webcomic_author_table tbody' ).append( '<tr><td><button class="delete">-</button></td><td><input type="text" name="webcomic_author_new[' + key + '][name]"></td><td><input type="email" name="webcomic_author_new[' + key + '][email]"></td><td><input type="url" name="webcomic_author_new[' + key + '][url]"></td><td><input type="text" name="webcomic_author_new[' + key + '][ip]"></td><td><input type="text" name="webcomic_author_new[' + key + '][time]"></td></tr>' );
+
+ return false;
+ } );
+
+ /** Delete an existing author row. */
+ $( document ).on( 'click', '#webcomic_author_table .delete', function() {
+ $( this ).parents( 'tr' ).remove();
+
+ return false;
} );
-}
+} );
View
18 -/php/config.php
@@ -13,13 +13,11 @@ class WebcomicConfig extends Webcomic {
*
* @uses WebcomicConfig::admin_init()
* @uses WebcomicConfig::admin_menu()
- * @uses WebcomicConfig::admin_footer()
* @uses WebcomicConfig::admin_enqueue_scripts()
*/
public function __construct() {
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
- add_action( 'admin_footer', array( $this, 'admin_footer' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
}
@@ -154,18 +152,6 @@ public function admin_menu() {
}
}
- /** Render javascript for settings pages.
- *
- * @hook admin_footer
- */
- public function admin_footer() {
- $screen = get_current_screen();
-
- if ( preg_match( '/^webcomic\d+_page_webcomic\d+-options$/', $screen->id ) ) {
- printf( "<script>webcomic_slug_preview('%s');webcomic_commerce_defaults('%s');webcomic_twitter_account('%s')</script>", admin_url(), admin_url(), admin_url() );
- }
- }
-
/** Register and enqueue settings scripts.
*
* @uses Webcomic::$url
@@ -189,8 +175,8 @@ public function admin_enqueue_scripts() {
public function page() {
$page = empty( $_GET[ 'post_type' ] ) ? 'webcomic-options' : "{$_GET[ 'post_type' ]}-options";
?>
- <div class="wrap">
- <div id="icon-options-general" class="icon32"></div>
+ <div class="wrap" >
+ <div id="icon-options-general" class="icon32" data-webcomic-admin-url="<?php echo admin_url(); ?>"></div>
<h2><?php echo 'webcomic-options' === $page ? __( 'Webcomic Settings', 'webcomic' ) : sprintf( __( '%s Settings', 'webcomic' ), esc_html( self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'name' ] ) ); ?></h2>
<form action="options.php" method="post"<?php echo 'webcomic' !== $page ? ' enctype="multipart/form-data"' : ''; ?>>
<?php
View
16 -/php/legacy.php
@@ -22,7 +22,6 @@ class WebcomicLegacy extends Webcomic {
* @uses WebcomicLegacy::init()
* @uses WebcomicLegacy::admin_init()
* @uses WebcomicLegacy::admin_menu()
- * @uses WebcomicLegacy::admin_footer()
* @uses WebcomicLegacy::admin_notices()
* @uses WebcomicLegacy::admin_enqueue_scripts()
* @uses WebcomicLegacy::list_term_exclusions()
@@ -33,7 +32,6 @@ public function __construct() {
add_action( 'init', array( $this, 'init' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
- add_action( 'admin_footer', array( $this, 'admin_footer' ) );
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'list_term_exclusions', array( $this, 'list_term_exclusions' ), 10, 2 );
@@ -128,18 +126,6 @@ public function admin_menu() {
add_submenu_page( 'tools.php', __( 'Upgrade Webcomic', 'webcomic' ), __( 'Upgrade Webcomic', 'webcomic' ), 'manage_options', 'webcomic-upgrader', array( $this, 'page' ) );
}
- /** Render javascript for upgrade page.
- *
- * @hook admin_footer
- */
- public function admin_footer() {
- $screen = get_current_screen();
-
- if ( 'tools_page_webcomic-upgrader' === $screen->id ) {
- printf( "<script>webcomic_auto_upgrade('%s')</script>", __( 'Continuing upgrade&hellip;', 'webcomic' ) );
- }
- }
-
/** Render upgrade tool notification.
*
* @return null
@@ -223,7 +209,7 @@ public function page() {
<p style="color:#e66f00;font-size:larger"><strong><?php _e( 'Webcomic has paused the upgrade to prevent a timeout error.', 'webcomic' ); ?></strong></p>
<p><?php _e( 'The upgrade will automatically resume in 5 seconds, or you may click <strong>Continue Upgrading</strong> to resume now.', 'webcomic' ); ?></p>
- <form method="post" class="webcomic-auto">
+ <form method="post" class="webcomic-auto" data-webcomic-upgrade-continue="<?php _e( 'Continuing upgrade&hellip;', 'webcomic' ); ?>">
<?php wp_nonce_field( 'webcomic_upgrade', 'webcomic_upgrade' ); ?>
<div class="form-wrap">
<?php submit_button( __( 'Continue Upgrading', 'webcomic' ), 'primary', 'upgrade_legacy', false ); ?>
View
20 -/php/media.php
@@ -15,7 +15,6 @@ class WebcomicMedia extends Webcomic {
* @uses Webcomic::$notice
* @uses WebcomicMedia::admin_init()
* @uses WebcomicMedia::admin_menu()
- * @uses WebcomicMedia::admin_footer()
* @uses WebcomicMedia::delete_attachment()
* @uses WebcomicMedia::admin_enqueue_scripts()
* @uses WebcomicMedia::media_upload_webcomic_media()
@@ -28,7 +27,6 @@ class WebcomicMedia extends Webcomic {
public function __construct() {
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
- add_action( 'admin_footer', array( $this, 'admin_footer' ) );
add_action( 'delete_attachment', array( $this, 'delete_attachment' ), 10, 1 );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'media_upload_webcomic_media', array( $this, 'media_upload_webcomic_media' ) );
@@ -183,18 +181,6 @@ public function admin_menu() {
add_submenu_page( 'upload.php', __( 'Webcomic Generator', 'webcomic' ), __( 'Webcomic Generator', 'webcomic' ), 'upload_files', 'webcomic-generator', array( $this, 'page_generator' ) );
}
- /** Render javascript for the webcomic generator.
- *
- * @hook admin_footer
- */
- public function admin_footer() {
- $screen = get_current_screen();
-
- if ( 'media_page_webcomic-generator' === $screen->id ) {
- printf( "<script>webcomic_generator( '%s' );</script>", __( 'The start date is not one of the selected publish days. Continue anyway?', 'webcomic' ) );
- }
- }
-
/** Manage webcomic media from the modal media manager.
*
* @hook media_upload_webcomic_media
@@ -202,7 +188,7 @@ public function admin_footer() {
public function media_upload_webcomic_media( $output = false ) {
if ( $output ) {
if ( $attachments = self::get_attachments( $_GET[ 'post_id' ] ) ) {
- printf( '<div><p>%s</p><hr></div><ul class="webcomic-media">', __( 'Drag and drop the media attachments to change the order Webcomic will display them.', 'webcomic' ) );
+ printf( '<div data-webcomic-modal-media="%s"><p>%s</p><hr></div><ul class="webcomic-media">', admin_url(), __( 'Drag and drop the media attachments to change the order Webcomic will display them.', 'webcomic' ) );
foreach ( $attachments as $attachment ) {
printf( '<li><span>%s</span><a href="%s" title="%s">%s</a><a href="%s" title="%s">%s</a><input type="hidden" name="ids[]" value="%s"></li>',
@@ -216,8 +202,6 @@ public function media_upload_webcomic_media( $output = false ) {
$attachment->ID
);
}
-
- printf( "</ul><script>webcomic_media( '%s' );</script>", admin_url() );
} else {
printf( '<div><p>%s</p></div>', __( 'To manage Webcomic Media please attach one or more images to this webcomic.', 'webcomic' ) );
}
@@ -611,7 +595,7 @@ public function page_generator() {
<div class="wrap">
<div class="icon32" id="icon-upload"></div>
<h2><?php _e( 'Webcomic Generator', 'webcomic' ); ?></h2>
- <form method="post">
+ <form method="post" class="webcomic-generator" data-webcomic-daycheck="<?php esc_attr_e( 'The start date is not one of the selected publish days. Continue anyway?', 'webcomic' ); ?>">
<?php wp_nonce_field( 'webcomic_generate', 'webcomic_generate' ); ?>
<div id="col-container">
<div id="col-right">
View
17 -/php/pages.php
@@ -11,7 +11,6 @@
class WebcomicPages extends Webcomic {
/** Register hooks.
*
- * @uses WebcomicPages::admin_footer()
* @uses WebcomicPages::add_meta_boxes()
* @uses WebcomicPages::wp_insert_post()
* @uses WebcomicPages::pre_post_update()
@@ -24,7 +23,6 @@ class WebcomicPages extends Webcomic {
* @uses WebcomicPages::manage_edit_page_sortable_columns()
*/
public function __construct() {
- add_action( 'admin_footer', array( $this, 'admin_footer' ) );
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
add_action( 'wp_insert_post', array( $this, 'wp_insert_post' ), 10, 2 );
add_action( 'pre_post_update', array( $this, 'pre_post_update' ), 10, 1 );
@@ -38,19 +36,6 @@ public function __construct() {
add_filter( 'manage_edit-page_sortable_columns', array( $this, 'manage_edit_page_sortable_columns' ), 10, 1 );
}
- /** Render javascript for page meta boxes.
- *
- * @uses Webcomic::$config
- * @hook admin_footer
- */
- public function admin_footer() {
- $screen = get_current_screen();
-
- if ( 'edit-page' === $screen->id ) {
- printf( "<script>webcomic_page_quick_save( '%s' );webcomic_page_quick_edit( '%s' );</script>", admin_url(), admin_url() );
- }
- }
-
/** Add page meta boxes.
*
* @uses WebcomicPages::box_webcomic_collection()
@@ -127,7 +112,7 @@ public function bulk_edit_custom_box( $column, $type ) {
if ( 'webcomic_collection' === $column and 'page' === $type ) {
wp_nonce_field( 'webcomic_page_meta_bulk', 'webcomic_page_meta_bulk' );
?>
- <fieldset class="inline-edit-col-right">
+ <fieldset class="inline-edit-col-right" data-webcomic-admin-url="<?php echo admin_url(); ?>">
<div class="inline-edit-group">
<label class="alignleft">
<span class="title"><?php _e( 'Webcomic Collection', 'webcomic' ); ?></span>
View
23 -/php/posts.php
@@ -12,7 +12,6 @@ class WebcomicPosts extends Webcomic {
/** Register hooks.
*
* @uses Webcomic::$config
- * @uses WebcomicPosts::admin_footer()
* @uses WebcomicPosts::add_meta_boxes()
* @uses WebcomicPosts::pre_post_update()
* @uses WebcomicPosts::update_collection()
@@ -29,7 +28,6 @@ class WebcomicPosts extends Webcomic {
* @uses WebcomicPosts::manage_edit_webcomic_columns()
*/
public function __construct() {
- add_action( 'admin_footer', array( $this, 'admin_footer' ) );
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
add_action( 'pre_post_update', array( $this, 'pre_post_update' ), 10, 1 );
add_action( 'wp_insert_post', array( $this, 'update_collection' ), 10, 2 );
@@ -51,21 +49,6 @@ public function __construct() {
}
}
- /** Render javascript for webcomic meta boxes.
- *
- * @uses Webcomic::$config
- * @hook admin_footer
- */
- public function admin_footer() {
- $screen = get_current_screen();
-
- if ( preg_match( '/^edit-webcomic\d+$/', $screen->id ) ) {
- printf( "<script>webcomic_quick_save( '%s' );webcomic_quick_edit( '%s' );</script>", admin_url(), admin_url() );
- } elseif ( isset( self::$config[ 'collections' ][ $screen->id ] ) ) {
- printf( "<script>webcomic_media_meta('%s');webcomic_prints_meta('%s','%s');if(!window.wpActiveEditor)window.wpActiveEditor=false</script>", admin_url(), self::$config[ 'collections' ][ $screen->id ][ 'commerce' ][ 'currency' ], __( '- SOLD -', 'webcomic' ) );
- }
- }
-
/** Add webcomic meta boxes.
*
* @uses Webcomic::$config
@@ -289,7 +272,7 @@ public function bulk_edit_custom_box( $column, $type ) {
if ( 'webcomic_attachments' === $column and preg_match( '/^webcomic\d+$/', $type ) ) {
wp_nonce_field( 'webcomic_meta_bulk', 'webcomic_meta_bulk' );
?>
- <fieldset class="inline-edit-col-right">
+ <fieldset class="inline-edit-col-right" data-webcomic-admin-url="<?php echo admin_url(); ?>">
<div class="inline-edit-group">
<label class="alignleft">
<span class="title"><?php _e( 'Transcribe', 'webcomic' ); ?></span>
@@ -471,7 +454,7 @@ public function manage_edit_webcomic_columns( $columns ) {
*/
public function box_media( $post ) {
?>
- <div id="webcomic_media_preview"><?php self::ajax_media_preview( $post->ID ); ?></div>
+ <div id="webcomic_media_preview" data-webcomic-admin-url="<?php echo admin_url(); ?>"><?php self::ajax_media_preview( $post->ID ); ?></div>
<?php
}
@@ -487,7 +470,7 @@ public function box_commerce( $post ) {
wp_nonce_field( 'webcomic_meta_commerce', 'webcomic_meta_commerce' );
?>
<p><label><input type="checkbox" name="webcomic_commerce_prints"<?php checked( ( 'auto-draft' === $post->post_status and self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'prints' ] ) or ( self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'business' ] and get_post_meta( $post->ID, 'webcomic_prints', true ) ) ); disabled( !self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'business' ] ); ?>> <?php _e( 'Sell prints', 'webcomic' ); ?></label></p>
- <div style="margin:0 -11px">
+ <div style="margin:0 -11px" data-webcomic-currency="<?php echo self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'currency' ]; ?>" data-webcomic-original="<?php esc_attr_e( '- SOLD -', 'webcomic' ); ?>">
<table class="widefat fixed">
<thead>
<tr>
View
21 -/php/taxonomy.php
@@ -13,7 +13,6 @@ class WebcomicTaxonomy extends Webcomic {
*
* @uses Webcomic::$config
* @uses WebcomicTaxonomy::admin_init()
- * @uses WebcomicTaxonomy::admin_footer()
* @uses WebcomicTaxonomy::edit_term()
* @uses WebcomicTaxonomy::create_term()
* @uses WebcomicTaxonomy::delete_term()
@@ -27,7 +26,6 @@ class WebcomicTaxonomy extends Webcomic {
*/
public function __construct() {
add_action( 'admin_init', array( $this, 'admin_init' ) );
- add_action( 'admin_footer', array( $this, 'admin_footer' ) );
add_action( 'edit_term', array( $this, 'edit_term' ), 10, 3 );
add_action( 'create_term', array( $this, 'create_term' ), 10, 3 );
add_action( 'delete_term', array( $this, 'delete_term' ), 10, 3 );
@@ -94,19 +92,6 @@ public function admin_init() {
}
}
- /** Render javascript for webcomic terms.
- *
- * @uses Webcomic::$config
- * @hook admin_footer
- */
- public function admin_footer() {
- $screen = get_current_screen();
-
- if ( preg_match( '/^edit-webcomic\d+_(storyline|character)$/', $screen->id ) ) {
- printf( "<script>webcomic_edit_terms( '%s' );</script>", preg_replace( '/^edit-webcomic\d+_/', '', $screen->id ) );
- }
- }
-
/** Detach media, upload new media, and update term group.
*
* @param integer $id The edited term ID.
@@ -250,9 +235,9 @@ public function admin_enqueue_scripts() {
$screen = get_current_screen();
if ( preg_match( '/^edit-webcomic\d+_(storyline|character)$/', $screen->id ) ) {
- wp_register_script( 'webcomic-admin-terms', self::$url . '-/js/admin-terms.js', array( 'jquery' ) );
+ wp_register_script( 'webcomic-admin-taxonomy', self::$url . '-/js/admin-taxonomy.js', array( 'jquery' ) );
- wp_enqueue_script( 'webcomic-admin-terms' );
+ wp_enqueue_script( 'webcomic-admin-taxonomy' );
}
}
@@ -296,7 +281,7 @@ public function add_form_fields( $taxonomy ) {
$upload_size = ( integer ) $upload_size;
}
?>
- <div class="form-field">
+ <div class="form-field" data-webcomic-taxonomy="<?php echo $storyline ? 'storyline' : 'character'; ?>">
<?php
if ( is_multisite() and !is_upload_space_available() ) {
printf( '<p>%s</p>', sprintf( __( 'Sorry, you have filled your storage quota (%s MB)', 'webcomic' ), get_space_allowed() ) );
View
16 -/php/transcripts.php
@@ -12,7 +12,6 @@ class WebcomicTranscripts extends Webcomic {
/** Register hooks.
*
* @uses WebcomicTranscripts::delete_post()
- * @uses WebcomicTranscripts::admin_footer()
* @uses WebcomicTranscripts::add_meta_boxes()
* @uses WebcomicTranscripts::post_updated()
* @uses WebcomicTranscripts::restrict_manage_posts()
@@ -29,7 +28,6 @@ class WebcomicTranscripts extends Webcomic {
*/
public function __construct() {
add_action( 'delete_post', array( $this, 'delete_post' ) );
- add_action( 'admin_footer', array( $this, 'admin_footer' ) );
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
add_action( 'post_updated', array( $this, 'post_updated' ), 10, 3 );
add_action( 'restrict_manage_posts', array( $this, 'restrict_manage_posts' ) );
@@ -60,18 +58,6 @@ public function delete_post( $id ) {
}
}
- /** Render javascript for the webcomic meta boxes.
- *
- * @hook admin_footer
- */
- public function admin_footer() {
- $screen = get_current_screen();
-
- if ( 'webcomic_transcript' === $screen->id ) {
- printf( "<script>webcomic_transcript_meta('%s');</script>", admin_url() );
- }
- }
-
/** Add transcript meta boxes.
*
* @uses WebcomicTranscripts::box_parent()
@@ -420,7 +406,7 @@ public function box_parent( $post ) {
wp_nonce_field( 'webcomic_meta_parent', 'webcomic_meta_parent' );
?>
<style>#webcomic_post_preview{overflow:auto}</style>
- <p>
+ <p data-webcomic-admin-url="<?php echo admin_url(); ?>">
<select name="webcomic_collection" id="webcomic_collection" disabled>
<optgroup label="<?php esc_attr_e( 'Collection', 'webcomic' ); ?>">
<?php
View
2  -/php/widgets.php
@@ -278,7 +278,7 @@ public function form( $instance ) {
</p>
<?php } else { ?>
<input type="hidden" name="<?php echo $this->get_field_name( 'gestures' ); ?>" value="<?php echo empty( $gestures ) ? '' : $gestures; ?>">
- <?php { ?>
+ <?php } ?>
<?php } else { ?>
<p style="color:#bc0b0b"><strong><?php _e( 'Please enable the dynamic navigation option on the Settings > Webcomic administrative page to use this widget.', 'webcomic' ); ?></strong></p>
<input type="hidden" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo empty( $title ) ? '' : esc_attr( $title ); ?>">
Please sign in to comment.
Something went wrong with that request. Please try again.