Clean up spaces, tabs, indentation, and bracket formatting

This commit is contained in:
Brian Miyaji
2021-11-10 15:41:40 +09:00
parent e58beb1201
commit 3dff686a00
285 changed files with 29638 additions and 24147 deletions

View File

@@ -1,26 +1,38 @@
jQuery(document).ready(function($){
jQuery( document ).ready(
function($){
// Color picker
$('.colorpick').iris( {
change: function(event, ui){
$(this).css( { backgroundColor: ui.color.toString() } );
},
hide: true,
border: true
} ).each( function() {
$(this).css( { backgroundColor: $(this).val() } );
})
.click(function(){
$('.iris-picker').hide();
$(this).closest('.sp-color-box, td').find('.iris-picker').show();
});
// Color picker
$( '.colorpick' ).iris(
{
change: function(event, ui){
$( this ).css( { backgroundColor: ui.color.toString() } );
},
hide: true,
border: true
}
).each(
function() {
$( this ).css( { backgroundColor: $( this ).val() } );
}
)
.click(
function(){
$( '.iris-picker' ).hide();
$( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
}
);
$('body').click(function() {
$('.iris-picker').hide();
});
$( 'body' ).click(
function() {
$( '.iris-picker' ).hide();
}
);
$('.sp-color-box, .colorpick').click(function(event){
event.stopPropagation();
});
$( '.sp-color-box, .colorpick' ).click(
function(event){
event.stopPropagation();
}
);
});
}
);

View File

@@ -1,11 +1,18 @@
jQuery(document).ready(function($){
jQuery( document ).ready(
function($){
// Dashboard countdown
$("#sportspress_dashboard_status .sp_status_list li.countdown").each(function() {
var $this = $(this), finalDate = $(this).data('countdown');
$this.countdown(finalDate, function(event) {
$this.find('strong').html(event.strftime("%D "+localized_strings.days+" %H:%M:%S"));
});
});
// Dashboard countdown
$( "#sportspress_dashboard_status .sp_status_list li.countdown" ).each(
function() {
var $this = $( this ), finalDate = $( this ).data( 'countdown' );
$this.countdown(
finalDate,
function(event) {
$this.find( 'strong' ).html( event.strftime( "%D " + localized_strings.days + " %H:%M:%S" ) );
}
);
}
);
});
}
);

View File

@@ -3,51 +3,63 @@
$shortcodes = '';
$options = array(
'event' => array(
'details', 'results', 'performance', 'venue', 'officials', 'teams', 'full',
),
'team' => array(),
'player' => array(
'details', 'statistics'
),
'event' => array(
'details',
'results',
'performance',
'venue',
'officials',
'teams',
'full',
),
'team' => array(),
'player' => array(
'details',
'statistics',
),
);
$options = apply_filters( 'sportspress_shortcodes', $options );
foreach ( $options as $name => $group ) {
if ( empty( $group ) ) continue;
$shortcodes .= $name . '[' . implode( '|', $group ) . ']';
if ( empty( $group ) ) {
continue;
}
$shortcodes .= $name . '[' . implode( '|', $group ) . ']';
}
$raw = apply_filters( 'sportspress_tinymce_strings', array(
'shortcodes' => $shortcodes,
'insert' => __( 'SportsPress Shortcodes', 'sportspress' ),
'auto' => __( 'Auto', 'sportspress' ),
'manual' => __( 'Manual', 'sportspress' ),
'select' => __( 'Select...', 'sportspress' ),
'event' => __( 'Event', 'sportspress' ),
'details' => __( 'Details', 'sportspress' ),
'results' => __( 'Results', 'sportspress' ),
'countdown' => __( 'Countdown', 'sportspress' ),
'performance' => __( 'Box Score', 'sportspress' ),
'venue' => __( 'Venue', 'sportspress' ),
'officials' => __( 'Officials', 'sportspress' ),
'teams' => __( 'Teams', 'sportspress' ),
'full' => __( 'Full Info', 'sportspress' ),
'calendar' => __( 'Calendar', 'sportspress' ),
'statistics' => __( 'Statistics', 'sportspress' ),
'team' => __( 'Team', 'sportspress' ),
'standings' => __( 'League Table', 'sportspress' ),
'player' => __( 'Player', 'sportspress' ),
'list' => __( 'List', 'sportspress' ),
'blocks' => __( 'Blocks', 'sportspress' ),
'gallery' => __( 'Gallery', 'sportspress' ),
));
$raw = apply_filters(
'sportspress_tinymce_strings',
array(
'shortcodes' => $shortcodes,
'insert' => __( 'SportsPress Shortcodes', 'sportspress' ),
'auto' => __( 'Auto', 'sportspress' ),
'manual' => __( 'Manual', 'sportspress' ),
'select' => __( 'Select...', 'sportspress' ),
'event' => __( 'Event', 'sportspress' ),
'details' => __( 'Details', 'sportspress' ),
'results' => __( 'Results', 'sportspress' ),
'countdown' => __( 'Countdown', 'sportspress' ),
'performance' => __( 'Box Score', 'sportspress' ),
'venue' => __( 'Venue', 'sportspress' ),
'officials' => __( 'Officials', 'sportspress' ),
'teams' => __( 'Teams', 'sportspress' ),
'full' => __( 'Full Info', 'sportspress' ),
'calendar' => __( 'Calendar', 'sportspress' ),
'statistics' => __( 'Statistics', 'sportspress' ),
'team' => __( 'Team', 'sportspress' ),
'standings' => __( 'League Table', 'sportspress' ),
'player' => __( 'Player', 'sportspress' ),
'list' => __( 'List', 'sportspress' ),
'blocks' => __( 'Blocks', 'sportspress' ),
'gallery' => __( 'Gallery', 'sportspress' ),
)
);
$formatted = array();
foreach ( $raw as $key => $value ) {
$formatted[] = $key . ': "' . esc_js( $value ) . '"';
$formatted[] = $key . ': "' . esc_js( $value ) . '"';
}
$strings = 'tinyMCE.addI18n({' . _WP_Editors::$mce_locale . ':{

View File

@@ -1,42 +1,58 @@
/* global tinymce */
( function () {
tinymce.PluginManager.add( 'sp_shortcodes_button', function( editor, url ) {
var ed = tinymce.activeEditor;
tinymce.PluginManager.add(
'sp_shortcodes_button',
function( editor, url ) {
var ed = tinymce.activeEditor;
var groups = ed.getLang( 'sportspress.shortcodes' ).split("]");
var menu = new Array();
var groups = ed.getLang( 'sportspress.shortcodes' ).split( "]" );
var menu = new Array();
groups.forEach(function(g) {
if ( "" == g ) return;
var p = g.split("[");
var label = p.shift();
var variations = p.shift();
var shortcodes = typeof variations!== 'undefined' ? variations.split("|") : [];
var submenu = new Array();
shortcodes.forEach(function(s) {
submenu.push({
text: ed.getLang( 'sportspress.' + s ),
onclick: function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( ed.getLang( 'sportspress.' + label ) + ' - ' + ed.getLang( 'sportspress.' + s ), 'admin-ajax.php?action=sportspress_' + label + '_' + s + '_shortcode&width=' + W + '&height=' + H );
groups.forEach(
function(g) {
if ( "" == g ) {
return;
}
});
});
menu.push({
text: ed.getLang( 'sportspress.' + label ),
menu: submenu
});
});
var p = g.split( "[" );
var label = p.shift();
var variations = p.shift();
var shortcodes = typeof variations !== 'undefined' ? variations.split( "|" ) : [];
var submenu = new Array();
shortcodes.forEach(
function(s) {
submenu.push(
{
text: ed.getLang( 'sportspress.' + s ),
onclick: function() {
// triggers the thickbox
var width = jQuery( window ).width(), H = jQuery( window ).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( ed.getLang( 'sportspress.' + label ) + ' - ' + ed.getLang( 'sportspress.' + s ), 'admin-ajax.php?action=sportspress_' + label + '_' + s + '_shortcode&width=' + W + '&height=' + H );
}
}
);
}
);
menu.push(
{
text: ed.getLang( 'sportspress.' + label ),
menu: submenu
}
);
}
);
editor.addButton( 'sp_shortcodes_button', {
title: ed.getLang('sportspress.insert'),
text: false,
icon: false,
type: 'menubutton',
menu: menu
});
});
editor.addButton(
'sp_shortcodes_button',
{
title: ed.getLang( 'sportspress.insert' ),
text: false,
icon: false,
type: 'menubutton',
menu: menu
}
);
}
);
})();

View File

@@ -1,37 +1,55 @@
jQuery(document).ready(function($){
$("#title").keyup(function() {
val = $(this).val();
if ( val == '' ) val = 'f(x)';
$(".sp-equation-variable").text( val + ' =' );
});
jQuery( document ).ready(
function($){
$( "#title" ).keyup(
function() {
val = $( this ).val();
if ( val == '' ) {
val = 'f(x)';
}
$( ".sp-equation-variable" ).text( val + ' =' );
}
);
$(".sp-equation-parts .button").draggable({
appendTo: "body",
helper: "clone",
cursor: "move",
distance: 10,
containment: "#sp_equationdiv",
}).click(function() {
$("<label class='button'></label>").text( $(this).text() ).append("<span class='remove'>&times;</span><input name='sp_equation[]' type='hidden' value='" + $(this).data("variable") + "'>").appendTo( $(".sp-equation-formula") );
});
$( ".sp-equation-parts .button" ).draggable(
{
appendTo: "body",
helper: "clone",
cursor: "move",
distance: 10,
containment: "#sp_equationdiv",
}
).click(
function() {
$( "<label class='button'></label>" ).text( $( this ).text() ).append( "<span class='remove'>&times;</span><input name='sp_equation[]' type='hidden' value='" + $( this ).data( "variable" ) + "'>" ).appendTo( $( ".sp-equation-formula" ) );
}
);
$(".sp-equation").droppable({
activeClass: "ui-state-active",
hoverClass: "ui-state-hover",
accept: ".button:not(.ui-sortable-helper)",
drop: function( event, ui ) {
$("<label class='button'></label>").text( ui.draggable.text() ).append("<span class='remove'>&times;</span><input name='sp_equation[]' type='hidden' value='" + ui.draggable.data("variable") + "'>").appendTo( $(".sp-equation-formula") );
}
}).sortable({
items: ".button",
tolerance: "pointer",
containment: "#sp_equationdiv",
sort: function() {
$( this ).removeClass( "ui-state-active" );
}
});
$( ".sp-equation" ).droppable(
{
activeClass: "ui-state-active",
hoverClass: "ui-state-hover",
accept: ".button:not(.ui-sortable-helper)",
drop: function( event, ui ) {
$( "<label class='button'></label>" ).text( ui.draggable.text() ).append( "<span class='remove'>&times;</span><input name='sp_equation[]' type='hidden' value='" + ui.draggable.data( "variable" ) + "'>" ).appendTo( $( ".sp-equation-formula" ) );
}
}
).sortable(
{
items: ".button",
tolerance: "pointer",
containment: "#sp_equationdiv",
sort: function() {
$( this ).removeClass( "ui-state-active" );
}
}
);
$(".sp-equation-formula").on("click", ".button .remove", function() {
$(this).closest(".button").remove();
});
});
$( ".sp-equation-formula" ).on(
"click",
".button .remove",
function() {
$( this ).closest( ".button" ).remove();
}
);
}
);

View File

@@ -1,37 +1,52 @@
jQuery(document).ready(function($){
jQuery( document ).ready(
function($){
// Icon picker
$('.sp-icons input').on('change', function() {
if ('' == $(this).val()) {
$('.sp-custom-colors').hide();
$('.sp-custom-thumbnail').show();
} else {
$('.sp-custom-thumbnail').hide();
$('.sp-custom-colors').show();
}
});
// Icon picker
$( '.sp-icons input' ).on(
'change',
function() {
if ('' == $( this ).val()) {
$( '.sp-custom-colors' ).hide();
$( '.sp-custom-thumbnail' ).show();
} else {
$( '.sp-custom-thumbnail' ).hide();
$( '.sp-custom-colors' ).show();
}
}
);
// Color picker
$('.colorpick').iris( {
change: function(event, ui){
$(this).css( { backgroundColor: ui.color.toString() } );
},
hide: true,
border: true
} ).each( function() {
$(this).css( { backgroundColor: $(this).val() } );
})
.click(function(){
$('.iris-picker').hide();
$(this).closest('.sp-color-box-for-icon, td').find('.iris-picker').show();
});
// Color picker
$( '.colorpick' ).iris(
{
change: function(event, ui){
$( this ).css( { backgroundColor: ui.color.toString() } );
},
hide: true,
border: true
}
).each(
function() {
$( this ).css( { backgroundColor: $( this ).val() } );
}
)
.click(
function(){
$( '.iris-picker' ).hide();
$( this ).closest( '.sp-color-box-for-icon, td' ).find( '.iris-picker' ).show();
}
);
$('body').click(function() {
$('.iris-picker').hide();
});
$( 'body' ).click(
function() {
$( '.iris-picker' ).hide();
}
);
$('.sp-color-box-for-icon, .colorpick').click(function(event){
event.stopPropagation();
});
$( '.sp-color-box-for-icon, .colorpick' ).click(
function(event){
event.stopPropagation();
}
);
});
}
);

View File

@@ -24,56 +24,72 @@
var $post_row = $( '#post-' + $post_id );
// get the data
var $number = $( '.column-sp_number', $post_row ).text();
var $current_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'current-teams' ) ).split(',');
var $past_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'past-teams' ) ).split(',');
var $number = $( '.column-sp_number', $post_row ).text();
var $current_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'current-teams' ) ).split( ',' );
var $past_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'past-teams' ) ).split( ',' );
// populate the data
$( ':input[name="sp_number"]', $edit_row ).val( $number );
$( ':input[name="sp_current_team[]"]', $edit_row ).each(function() {
$(this).prop("checked", ($.inArray($(this).val(), $current_teams ) != -1));
});
$( ':input[name="sp_past_team[]"]', $edit_row ).each(function() {
$(this).prop("checked", ($.inArray($(this).val(), $past_teams ) != -1));
});
$( ':input[name="sp_current_team[]"]', $edit_row ).each(
function() {
$( this ).prop( "checked", ($.inArray( $( this ).val(), $current_teams ) != -1) );
}
);
$( ':input[name="sp_past_team[]"]', $edit_row ).each(
function() {
$( this ).prop( "checked", ($.inArray( $( this ).val(), $past_teams ) != -1) );
}
);
}
};
$( document ).on( 'click', '#bulk_edit', function() {
// define the bulk edit row
var $bulk_row = $( '#bulk-edit' );
$( document ).on(
'click',
'#bulk_edit',
function() {
// define the bulk edit row
var $bulk_row = $( '#bulk-edit' );
// get the selected post ids that are being edited
var $post_ids = new Array();
$bulk_row.find( '#bulk-titles' ).children().each( function() {
$post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
});
// get the selected post ids that are being edited
var $post_ids = new Array();
$bulk_row.find( '#bulk-titles' ).children().each(
function() {
$post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
}
);
// get the data
var $current_teams = [];
$bulk_row.find( 'input[name="sp_current_team[]"]:checked' ).each(function() {
$current_teams.push( $(this).val() );
});
// get the data
var $current_teams = [];
$bulk_row.find( 'input[name="sp_current_team[]"]:checked' ).each(
function() {
$current_teams.push( $( this ).val() );
}
);
var $past_teams = [];
$bulk_row.find( 'input[name="sp_past_team[]"]:checked' ).each(function() {
$past_teams.push( $(this).val() );
});
var $past_teams = [];
$bulk_row.find( 'input[name="sp_past_team[]"]:checked' ).each(
function() {
$past_teams.push( $( this ).val() );
}
);
// save the data
$.ajax({
url: ajaxurl, // this is a variable that WordPress has already defined for us
type: 'POST',
async: false,
cache: false,
data: {
action: 'save_bulk_edit_sp_player',
post_ids: $post_ids,
current_teams: $current_teams,
past_teams: $past_teams,
nonce: $("#sp_player_edit_nonce").val()
}
});
});
// save the data
$.ajax(
{
url: ajaxurl, // this is a variable that WordPress has already defined for us
type: 'POST',
async: false,
cache: false,
data: {
action: 'save_bulk_edit_sp_player',
post_ids: $post_ids,
current_teams: $current_teams,
past_teams: $past_teams,
nonce: $( "#sp_player_edit_nonce" ).val()
}
}
);
}
);
})(jQuery);
})( jQuery );

View File

@@ -1,64 +1,92 @@
jQuery(document).ready(function($){
jQuery( document ).ready(
function($){
// Display custom sport name field as needed
$("body.toplevel_page_sportspress #sportspress_sport").change(function() {
$target = $("#sportspress_custom_sport_name");
if ( $(this).val() == "custom" )
$target.show();
else
$target.hide();
});
// Display custom sport name field as needed
$( "body.toplevel_page_sportspress #sportspress_sport" ).change(
function() {
$target = $( "#sportspress_custom_sport_name" );
if ( $( this ).val() == "custom" ) {
$target.show();
} else {
$target.hide();
}
}
);
// Color picker
$('.colorpick').iris( {
change: function(event, ui){
$(this).css( { backgroundColor: ui.color.toString() } );
},
hide: true,
border: true
} ).each( function() {
$(this).css( { backgroundColor: $(this).val() } );
})
.click(function(){
$('.iris-picker').hide();
$(this).closest('.sp-color-box, td').find('.iris-picker').show();
});
// Color picker
$( '.colorpick' ).iris(
{
change: function(event, ui){
$( this ).css( { backgroundColor: ui.color.toString() } );
},
hide: true,
border: true
}
).each(
function() {
$( this ).css( { backgroundColor: $( this ).val() } );
}
)
.click(
function(){
$( '.iris-picker' ).hide();
$( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
}
);
$('body').click(function() {
$('.iris-picker').hide();
});
$( 'body' ).click(
function() {
$( '.iris-picker' ).hide();
}
);
$('.sp-color-box, .colorpick').click(function(event){
event.stopPropagation();
});
$( '.sp-color-box, .colorpick' ).click(
function(event){
event.stopPropagation();
}
);
// Chosen select
$(".chosen-select").chosen({
allow_single_deselect: true,
single_backstroke_delete: false,
placeholder_text_multiple: localized_strings.none
});
// Chosen select
$( ".chosen-select" ).chosen(
{
allow_single_deselect: true,
single_backstroke_delete: false,
placeholder_text_multiple: localized_strings.none
}
);
// Preset field modifier
$(".sp-custom-input-wrapper .preset").click(function() {
val = $(this).val();
if(val == "\\c\\u\\s\\t\\o\\m") return true;
example = $(this).attr("data-example");
$(this).closest(".sp-custom-input-wrapper").find(".value").val(val).siblings(".example").html(example);
});
// Preset field modifier
$( ".sp-custom-input-wrapper .preset" ).click(
function() {
val = $( this ).val();
if (val == "\\c\\u\\s\\t\\o\\m") {
return true;
}
example = $( this ).attr( "data-example" );
$( this ).closest( ".sp-custom-input-wrapper" ).find( ".value" ).val( val ).siblings( ".example" ).html( example );
}
);
// Select custom preset when field is brought to focus
$(".sp-custom-input-wrapper .value").focus(function() {
$(this).siblings("label").find(".preset").prop("checked", true);
});
// Select custom preset when field is brought to focus
$( ".sp-custom-input-wrapper .value" ).focus(
function() {
$( this ).siblings( "label" ).find( ".preset" ).prop( "checked", true );
}
);
// Adjust example field when custom preset is entered
$(".sp-custom-input-wrapper .value").on("keyup", function() {
val = $(this).val();
if ( val === undefined ) return true;
format = $(this).attr("data-example-format");
example = format.replace(/__val__/g, val);
$(this).siblings(".example").html(example);
});
// Adjust example field when custom preset is entered
$( ".sp-custom-input-wrapper .value" ).on(
"keyup",
function() {
val = $( this ).val();
if ( val === undefined ) {
return true;
}
format = $( this ).attr( "data-example-format" );
example = format.replace( /__val__/g, val );
$( this ).siblings( ".example" ).html( example );
}
);
});
}
);

View File

@@ -1,54 +1,76 @@
//Get variables form input values
latitude = document.getElementById('term_meta[sp_latitude]').value;
longitude = document.getElementById('term_meta[sp_longitude]').value;
//Initialize the map and add the Search control box
var map = L.map('sp-location-picker').setView([latitude, longitude], 15),
// Get variables form input values
latitude = document.getElementById( 'term_meta[sp_latitude]' ).value;
longitude = document.getElementById( 'term_meta[sp_longitude]' ).value;
// Initialize the map and add the Search control box
var map = L.map( 'sp-location-picker' ).setView( [latitude, longitude], 15 ),
geocoder = L.Control.Geocoder.nominatim(),
control = L.Control.geocoder({
geocoder: geocoder,
collapsed: false,
defaultMarkGeocode: false
}).addTo(map),
//Add a marker to use from the begining
marker = L.marker([latitude, longitude],{draggable: true, autoPan: true}).addTo(map);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
//Pass the values to the fields after dragging
marker.on('dragend', function (e) {
document.getElementById('term_meta[sp_latitude]').value = marker.getLatLng().lat;
document.getElementById('term_meta[sp_longitude]').value = marker.getLatLng().lng;
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
var r = results[0];
if (r) {
document.getElementById('term_meta[sp_address]').value = r.name;
control = L.Control.geocoder(
{
geocoder: geocoder,
collapsed: false,
defaultMarkGeocode: false
}
})
});
).addTo( map ),
// Add a marker to use from the begining
marker = L.marker( [latitude, longitude],{draggable: true, autoPan: true} ).addTo( map );
//After searching
control.on('markgeocode', function(e) {
var center = e.geocode.center;
var address = e.geocode.name;
map.setView([center.lat, center.lng], 15); //Center map to the new place
map.removeLayer(marker); //Remove previous marker
marker = L.marker([center.lat, center.lng],{draggable: true, autoPan: true}).addTo(map); //Add new marker to use
//Pass the values to the fields after searching
document.getElementById('term_meta[sp_latitude]').value = center.lat;
document.getElementById('term_meta[sp_longitude]').value = center.lng;
document.getElementById('term_meta[sp_address]').value = address;
//Pass the values to the fields after dragging
marker.on('dragend', function (e) {
document.getElementById('term_meta[sp_latitude]').value = marker.getLatLng().lat;
document.getElementById('term_meta[sp_longitude]').value = marker.getLatLng().lng;
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
var r = results[0];
if (r) {
document.getElementById('term_meta[sp_address]').value = r.name;
L.tileLayer(
'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
{
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}
).addTo( map );
// Pass the values to the fields after dragging
marker.on(
'dragend',
function (e) {
document.getElementById( 'term_meta[sp_latitude]' ).value = marker.getLatLng().lat;
document.getElementById( 'term_meta[sp_longitude]' ).value = marker.getLatLng().lng;
geocoder.reverse(
marker.getLatLng(),
map.options.crs.scale( map.getZoom() ),
function(results) {
var r = results[0];
if (r) {
document.getElementById( 'term_meta[sp_address]' ).value = r.name;
}
}
})
});
}).addTo(map);
)
}
);
// After searching
control.on(
'markgeocode',
function(e) {
var center = e.geocode.center;
var address = e.geocode.name;
map.setView( [center.lat, center.lng], 15 ); // Center map to the new place
map.removeLayer( marker ); // Remove previous marker
marker = L.marker( [center.lat, center.lng],{draggable: true, autoPan: true} ).addTo( map ); // Add new marker to use
// Pass the values to the fields after searching
document.getElementById( 'term_meta[sp_latitude]' ).value = center.lat;
document.getElementById( 'term_meta[sp_longitude]' ).value = center.lng;
document.getElementById( 'term_meta[sp_address]' ).value = address;
// Pass the values to the fields after dragging
marker.on(
'dragend',
function (e) {
document.getElementById( 'term_meta[sp_latitude]' ).value = marker.getLatLng().lat;
document.getElementById( 'term_meta[sp_longitude]' ).value = marker.getLatLng().lng;
geocoder.reverse(
marker.getLatLng(),
map.options.crs.scale( map.getZoom() ),
function(results) {
var r = results[0];
if (r) {
document.getElementById( 'term_meta[sp_address]' ).value = r.name;
}
}
)
}
);
}
).addTo( map );

View File

@@ -1,54 +1,76 @@
//Get variables form input values
latitude = document.getElementById('sp_latitude').value;
longitude = document.getElementById('sp_longitude').value;
//Initialize the map and add the Search control box
var map = L.map('sp-location-picker').setView([latitude, longitude], 15),
// Get variables form input values
latitude = document.getElementById( 'sp_latitude' ).value;
longitude = document.getElementById( 'sp_longitude' ).value;
// Initialize the map and add the Search control box
var map = L.map( 'sp-location-picker' ).setView( [latitude, longitude], 15 ),
geocoder = L.Control.Geocoder.nominatim(),
control = L.Control.geocoder({
geocoder: geocoder,
collapsed: false,
defaultMarkGeocode: false
}).addTo(map),
//Add a marker to use from the begining
marker = L.marker([latitude, longitude],{draggable: true, autoPan: true}).addTo(map);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
//Pass the values to the fields after dragging
marker.on('dragend', function (e) {
document.getElementById('sp_latitude').value = marker.getLatLng().lat;
document.getElementById('sp_longitude').value = marker.getLatLng().lng;
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
var r = results[0];
if (r) {
document.getElementById('sp_address').value = r.name;
control = L.Control.geocoder(
{
geocoder: geocoder,
collapsed: false,
defaultMarkGeocode: false
}
})
});
).addTo( map ),
// Add a marker to use from the begining
marker = L.marker( [latitude, longitude],{draggable: true, autoPan: true} ).addTo( map );
//After searching
control.on('markgeocode', function(e) {
var center = e.geocode.center;
var address = e.geocode.name;
map.setView([center.lat, center.lng], 15); //Center map to the new place
map.removeLayer(marker); //Remove previous marker
marker = L.marker([center.lat, center.lng],{draggable: true, autoPan: true}).addTo(map); //Add new marker to use
//Pass the values to the fields after searching
document.getElementById('sp_latitude').value = center.lat;
document.getElementById('sp_longitude').value = center.lng;
document.getElementById('sp_address').value = address;
//Pass the values to the fields after dragging
marker.on('dragend', function (e) {
document.getElementById('sp_latitude').value = marker.getLatLng().lat;
document.getElementById('sp_longitude').value = marker.getLatLng().lng;
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
var r = results[0];
if (r) {
document.getElementById('sp_address').value = r.name;
L.tileLayer(
'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
{
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}
).addTo( map );
// Pass the values to the fields after dragging
marker.on(
'dragend',
function (e) {
document.getElementById( 'sp_latitude' ).value = marker.getLatLng().lat;
document.getElementById( 'sp_longitude' ).value = marker.getLatLng().lng;
geocoder.reverse(
marker.getLatLng(),
map.options.crs.scale( map.getZoom() ),
function(results) {
var r = results[0];
if (r) {
document.getElementById( 'sp_address' ).value = r.name;
}
}
})
});
}).addTo(map);
)
}
);
// After searching
control.on(
'markgeocode',
function(e) {
var center = e.geocode.center;
var address = e.geocode.name;
map.setView( [center.lat, center.lng], 15 ); // Center map to the new place
map.removeLayer( marker ); // Remove previous marker
marker = L.marker( [center.lat, center.lng],{draggable: true, autoPan: true} ).addTo( map ); // Add new marker to use
// Pass the values to the fields after searching
document.getElementById( 'sp_latitude' ).value = center.lat;
document.getElementById( 'sp_longitude' ).value = center.lng;
document.getElementById( 'sp_address' ).value = address;
// Pass the values to the fields after dragging
marker.on(
'dragend',
function (e) {
document.getElementById( 'sp_latitude' ).value = marker.getLatLng().lat;
document.getElementById( 'sp_longitude' ).value = marker.getLatLng().lng;
geocoder.reverse(
marker.getLatLng(),
map.options.crs.scale( map.getZoom() ),
function(results) {
var r = results[0];
if (r) {
document.getElementById( 'sp_address' ).value = r.name;
}
}
)
}
);
}
).addTo( map );

File diff suppressed because it is too large Load Diff

View File

@@ -1,24 +1,32 @@
jQuery(document).ready(function($){
jQuery( document ).ready(
function($){
// Tiptip
$(".sp-tip").tipTip({
delay: 200,
fadeIn: 100,
fadeOut: 100
});
$(".sp-desc-tip").tipTip({
delay: 200,
fadeIn: 100,
fadeOut: 100,
defaultPosition: 'right'
});
// Tiptip
$( ".sp-tip" ).tipTip(
{
delay: 200,
fadeIn: 100,
fadeOut: 100
}
);
$( ".sp-desc-tip" ).tipTip(
{
delay: 200,
fadeIn: 100,
fadeOut: 100,
defaultPosition: 'right'
}
);
// Chosen select
$(".chosen-select, #poststuff #post_author_override").chosen({
allow_single_deselect: true,
search_contains: true,
single_backstroke_delete: false,
disable_search_threshold: 10,
placeholder_text_multiple: localized_strings.none
});
});
// Chosen select
$( ".chosen-select, #poststuff #post_author_override" ).chosen(
{
allow_single_deselect: true,
search_contains: true,
single_backstroke_delete: false,
disable_search_threshold: 10,
placeholder_text_multiple: localized_strings.none
}
);
}
);

View File

@@ -1,41 +1,60 @@
jQuery(document).ready(function($){
jQuery( document ).ready(
function($){
// Orderby affects order select in widget options
$("body").on("change", ".sp-select-orderby", function() {
$(this).closest(".widget-content").find(".sp-select-order").prop("disabled", $(this).val() == "default");
});
// Orderby affects order select in widget options
$( "body" ).on(
"change",
".sp-select-orderby",
function() {
$( this ).closest( ".widget-content" ).find( ".sp-select-order" ).prop( "disabled", $( this ).val() == "default" );
}
);
// Calendar affects view all link checkbox in widget options
$("body").on("change", ".sp-event-calendar-select", function() {
$el = $(this).closest(".widget-content").find(".sp-event-calendar-show-all-toggle");
if($(this).val() == 0)
$el.hide();
else
$el.show();
});
// Calendar affects view all link checkbox in widget options
$( "body" ).on(
"change",
".sp-event-calendar-select",
function() {
$el = $( this ).closest( ".widget-content" ).find( ".sp-event-calendar-show-all-toggle" );
if ($( this ).val() == 0) {
$el.hide();
} else {
$el.show();
}
}
);
// Show or hide datepicker
$("body").on("change", ".sp-date-selector select", function() {
if ( $(this).val() == "range" ) {
$(this).closest(".sp-date-selector").find(".sp-date-range").show();
} else {
$(this).closest(".sp-date-selector").find(".sp-date-range").hide();
}
});
$(".sp-date-selector select").trigger("change");
// Show or hide datepicker
$( "body" ).on(
"change",
".sp-date-selector select",
function() {
if ( $( this ).val() == "range" ) {
$( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).show();
} else {
$( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).hide();
}
}
);
$( ".sp-date-selector select" ).trigger( "change" );
// Toggle date range selectors
$("body").on("change", ".sp-date-relative input", function() {
$relative = $(this).closest(".sp-date-relative").siblings(".sp-date-range-relative").toggle(0, $(this).attr("checked"));
$absolute = $(this).closest(".sp-date-relative").siblings(".sp-date-range-absolute").toggle(0, $(this).attr("checked"));
// Toggle date range selectors
$( "body" ).on(
"change",
".sp-date-relative input",
function() {
$relative = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-relative" ).toggle( 0, $( this ).attr( "checked" ) );
$absolute = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-absolute" ).toggle( 0, $( this ).attr( "checked" ) );
if ($(this).attr("checked")) {
$relative.show();
$absolute.hide();
} else {
$absolute.show();
$relative.hide();
}
});
$(".sp-date-selector input").trigger("change");
});
if ($( this ).attr( "checked" )) {
$relative.show();
$absolute.hide();
} else {
$absolute.show();
$relative.hide();
}
}
);
$( ".sp-date-selector input" ).trigger( "change" );
}
);