Put location picker trigger in dedicated js file

This commit is contained in:
Brian Miyaji
2014-02-09 00:34:52 +11:00
parent 77ddbc2194
commit e2536f72d1
3 changed files with 18 additions and 17 deletions

View File

@@ -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' ) ) );

View 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
});
});

View File

@@ -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
});
});