Put location picker trigger in dedicated js file
This commit is contained in:
@@ -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' ) ) );
|
||||
|
||||
15
assets/js/admin-locationpicker.js
Normal file
15
assets/js/admin-locationpicker.js
Normal file
@@ -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
|
||||
});
|
||||
});
|
||||
@@ -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
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user