diff --git a/admin/hooks/admin-enqueue-scripts.php b/admin/hooks/admin-enqueue-scripts.php index b3bf9c98..3dbf2c48 100644 --- a/admin/hooks/admin-enqueue-scripts.php +++ b/admin/hooks/admin-enqueue-scripts.php @@ -10,10 +10,11 @@ function sportspress_admin_enqueue_scripts( $hook ) { if ( $hook == 'edit-tags.php' && isset( $_GET['taxonomy'] ) && $_GET['taxonomy'] == 'sp_venue' ): wp_enqueue_script( 'google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places' ); - wp_enqueue_script( 'jquery-locationpicker', SPORTSPRESS_PLUGIN_URL .'/assets/js/locationpicker.jquery.js', array( 'jquery' ), '0.1.6', true ); + wp_enqueue_script( 'jquery-locationpicker', SPORTSPRESS_PLUGIN_URL .'assets/js/locationpicker.jquery.js', array( 'jquery' ), '0.1.6', true ); + wp_enqueue_script( 'sportspress-admin-locationpicker', SPORTSPRESS_PLUGIN_URL .'assets/js/admin-locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), time(), true ); endif; - wp_enqueue_script( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL .'/assets/js/admin.js', array( 'jquery' ), time(), true ); + wp_enqueue_script( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL .'assets/js/admin.js', array( 'jquery' ), time(), true ); // Localize scripts. wp_localize_script( 'sportspress-admin', 'localized_strings', array( 'remove_text' => __( 'Remove', 'sportspress' ) ) ); diff --git a/assets/js/admin-locationpicker.js b/assets/js/admin-locationpicker.js new file mode 100644 index 00000000..8fc6ad94 --- /dev/null +++ b/assets/js/admin-locationpicker.js @@ -0,0 +1,15 @@ +jQuery(document).ready(function($){ + $(".sp-location-picker").locationpicker({ + location: { + latitude: Number($(".sp-latitude").val()), + longitude: Number($(".sp-longitude").val()) + }, + radius: 0, + inputBinding: { + latitudeInput: $(".sp-latitude"), + longitudeInput: $(".sp-longitude"), + locationNameInput: $(".sp-address") + }, + enableAutocomplete: true + }); +}); \ No newline at end of file diff --git a/assets/js/admin.js b/assets/js/admin.js index f8c58f40..d275fc49 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -168,19 +168,4 @@ jQuery(document).ready(function($){ return event.keyCode != 13; }); - // Location picker - $(".sp-location-picker").locationpicker({ - location: { - latitude: Number($(".sp-latitude").val()), - longitude: Number($(".sp-longitude").val()) - }, - radius: 0, - inputBinding: { - latitudeInput: $(".sp-latitude"), - longitudeInput: $(".sp-longitude"), - locationNameInput: $(".sp-address") - }, - enableAutocomplete: true - }); - }); \ No newline at end of file