Version Description
- Fixed: Clicking the marker would no longer open the info window after a Google Maps API update. This only happened if street view was enabled.
- Fixed: A fatal error on some installations caused by the usage of mysql_real_escape_string, it is replaced with esc_sql.
- Fixed: A problem where some themes would just show "1" instead of the shortcode output.
- Fixed: The "dismiss" link not working in the notice that reminds users to define a start point.
- Fixed: A missing html tag that broken the store listing in IE7/8.
- Changed: Replaced the non-GPL compatible dropdown script.
Download this release
Release Info
Developer | tijmensmit |
Plugin | WP Store Locator |
Version | 1.2.24 |
Comparing to | |
See all releases |
Code changes from version 1.2.23 to 1.2.24
- admin/class-admin.php +2 -1
- admin/class-store-overview.php +3 -3
- css/styles.css +60 -162
- frontend/class-frontend.php +1 -3
- js/jquery.easydropdown.js +0 -479
- js/jquery.easydropdown.min.js +0 -24
- js/wpsl-gmap.js +96 -12
- readme.txt +9 -1
- wp-store-locator.php +2 -2
admin/class-admin.php
CHANGED
@@ -1624,6 +1624,8 @@ if ( !class_exists( 'WPSL_Admin' ) ) {
|
|
1624 |
public function admin_scripts() {
|
1625 |
|
1626 |
$screen = get_current_screen();
|
|
|
|
|
1627 |
|
1628 |
/* Only enqueue the styles and scripts if we are on a page that belongs to the store locator */
|
1629 |
if ( strpos( $screen->id, 'wpsl_' ) !== false ) {
|
@@ -1632,7 +1634,6 @@ if ( !class_exists( 'WPSL_Admin' ) ) {
|
|
1632 |
wp_enqueue_style( 'jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css' );
|
1633 |
wp_enqueue_style( 'wpsl-admin-css', plugins_url( '/css/style.css', __FILE__ ), false );
|
1634 |
wp_enqueue_script( 'wpsl-gmap', ( "//maps.google.com/maps/api/js?sensor=false&libraries=places&language=" . $this->settings['api_language'] ), false, '', true ); // we set the language here to make sure the geocode response returns the country name in the correct language
|
1635 |
-
wp_enqueue_script( 'wpsl-admin-js', plugins_url( '/js/wpsl-admin.js', __FILE__ ), array( 'jquery' ), false );
|
1636 |
wp_enqueue_script( 'wpsl-queue', plugins_url( '/js/ajax-queue.js', __FILE__ ), array( 'jquery' ), false );
|
1637 |
wp_enqueue_script( 'wpsl-retina', plugins_url( '/js/retina-1.1.0.js', __FILE__ ), array( 'jquery' ), false );
|
1638 |
wp_localize_script( 'wpsl-admin-js', 'wpslL10n', $this->admin_js_l10n() );
|
1624 |
public function admin_scripts() {
|
1625 |
|
1626 |
$screen = get_current_screen();
|
1627 |
+
|
1628 |
+
wp_enqueue_script( 'wpsl-admin-js', plugins_url( '/js/wpsl-admin.js', __FILE__ ), array( 'jquery' ), false );
|
1629 |
|
1630 |
/* Only enqueue the styles and scripts if we are on a page that belongs to the store locator */
|
1631 |
if ( strpos( $screen->id, 'wpsl_' ) !== false ) {
|
1634 |
wp_enqueue_style( 'jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css' );
|
1635 |
wp_enqueue_style( 'wpsl-admin-css', plugins_url( '/css/style.css', __FILE__ ), false );
|
1636 |
wp_enqueue_script( 'wpsl-gmap', ( "//maps.google.com/maps/api/js?sensor=false&libraries=places&language=" . $this->settings['api_language'] ), false, '', true ); // we set the language here to make sure the geocode response returns the country name in the correct language
|
|
|
1637 |
wp_enqueue_script( 'wpsl-queue', plugins_url( '/js/ajax-queue.js', __FILE__ ), array( 'jquery' ), false );
|
1638 |
wp_enqueue_script( 'wpsl-retina', plugins_url( '/js/retina-1.1.0.js', __FILE__ ), array( 'jquery' ), false );
|
1639 |
wp_localize_script( 'wpsl-admin-js', 'wpslL10n', $this->admin_js_l10n() );
|
admin/class-store-overview.php
CHANGED
@@ -308,13 +308,13 @@ class WPSL_Store_Overview extends WP_List_Table {
|
|
308 |
);
|
309 |
} else {
|
310 |
/* Order params */
|
311 |
-
$orderby = !empty ( $_GET["orderby"] ) ?
|
312 |
-
$order = !empty ( $_GET["order"] ) ?
|
313 |
$order_sql = $orderby.' '.$order;
|
314 |
|
315 |
/* Pagination parameters */
|
316 |
$total_items = $wpdb->get_var( "SELECT COUNT(*) AS count FROM $wpdb->wpsl_stores" );
|
317 |
-
$paged = !empty ( $_GET["paged"] ) ?
|
318 |
|
319 |
if ( empty( $paged ) || !is_numeric( $paged ) || $paged <= 0 ) {
|
320 |
$paged = 1;
|
308 |
);
|
309 |
} else {
|
310 |
/* Order params */
|
311 |
+
$orderby = !empty ( $_GET["orderby"] ) ? esc_sql( $_GET["orderby"] ) : 'store';
|
312 |
+
$order = !empty ( $_GET["order"] ) ? esc_sql( $_GET["order"] ) : 'ASC';
|
313 |
$order_sql = $orderby.' '.$order;
|
314 |
|
315 |
/* Pagination parameters */
|
316 |
$total_items = $wpdb->get_var( "SELECT COUNT(*) AS count FROM $wpdb->wpsl_stores" );
|
317 |
+
$paged = !empty ( $_GET["paged"] ) ? esc_sql( $_GET["paged"] ) : '';
|
318 |
|
319 |
if ( empty( $paged ) || !is_numeric( $paged ) || $paged <= 0 ) {
|
320 |
$paged = 1;
|
css/styles.css
CHANGED
@@ -245,6 +245,29 @@ div elements, we disable it to prevent it from messing up the map
|
|
245 |
float:left;
|
246 |
}
|
247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
#wpsl-search-wrap .wpsl-input label {
|
249 |
margin-right:0;
|
250 |
}
|
@@ -320,26 +343,7 @@ div elements, we disable it to prevent it from messing up the map
|
|
320 |
margin-right:0;
|
321 |
}
|
322 |
|
323 |
-
/* ---
|
324 |
-
.wpsl-dropdown,
|
325 |
-
.wpsl-dropdown div,
|
326 |
-
.wpsl-dropdown li,
|
327 |
-
.wpsl-dropdown div::after{
|
328 |
-
-webkit-transition: all 150ms ease-in-out;
|
329 |
-
-moz-transition: all 150ms ease-in-out;
|
330 |
-
-ms-transition: all 150ms ease-in-out;
|
331 |
-
transition: all 150ms ease-in-out;
|
332 |
-
}
|
333 |
-
|
334 |
-
.wpsl-dropdown .selected::after,
|
335 |
-
.wpsl-dropdown.scrollable div::after{
|
336 |
-
-webkit-pointer-events: none;
|
337 |
-
-moz-pointer-events: none;
|
338 |
-
-ms-pointer-events: none;
|
339 |
-
pointer-events: none;
|
340 |
-
}
|
341 |
-
|
342 |
-
/* WRAPPER */
|
343 |
.wpsl-dropdown {
|
344 |
position: relative;
|
345 |
width: 90px;
|
@@ -351,176 +355,72 @@ div elements, we disable it to prevent it from messing up the map
|
|
351 |
-moz-user-select: none;
|
352 |
user-select: none;
|
353 |
margin-right: 0 !important;
|
354 |
-
}
|
355 |
-
|
356 |
-
.wpsl-no-results .wpsl-dropdown {
|
357 |
-
width: 114px;
|
358 |
-
}
|
359 |
-
|
360 |
-
.wpsl-dropdown.open{
|
361 |
z-index: 2;
|
362 |
}
|
363 |
-
#wpsl-search-input:hover,
|
364 |
-
.wpsl-dropdown:hover{
|
365 |
-
box-shadow: 0 0 5px rgba(0,0,0,.15);
|
366 |
-
}
|
367 |
-
wpsl-search-input.focus,
|
368 |
-
.wpsl-dropdown.focus{
|
369 |
-
box-shadow: 0 0 5px rgba(51,102,248,.4);
|
370 |
-
}
|
371 |
-
|
372 |
-
/* CARAT */
|
373 |
-
.wpsl-dropdown .carat{
|
374 |
-
position: absolute;
|
375 |
-
right: 12px;
|
376 |
-
top: 50%;
|
377 |
-
margin-top: -4px;
|
378 |
-
border: 6px solid transparent;
|
379 |
-
border-top: 8px solid #000;
|
380 |
-
}
|
381 |
-
|
382 |
-
.wpsl-dropdown.open .carat{
|
383 |
-
margin-top: -10px;
|
384 |
-
border-top: 6px solid transparent;
|
385 |
-
border-bottom: 8px solid #000;
|
386 |
-
}
|
387 |
|
388 |
-
.wpsl-dropdown
|
389 |
-
border-top-color: #999;
|
390 |
-
}
|
391 |
-
|
392 |
-
/* OLD SELECT (HIDDEN) */
|
393 |
-
.wpsl-dropdown .old{
|
394 |
position: absolute;
|
395 |
left: 0;
|
396 |
-
top: 0;
|
397 |
-
height: 0;
|
398 |
-
width: 0;
|
399 |
-
overflow: hidden;
|
400 |
-
}
|
401 |
-
|
402 |
-
.wpsl-dropdown select{
|
403 |
-
position: absolute;
|
404 |
-
left: 0px;
|
405 |
-
top: 0px;
|
406 |
-
}
|
407 |
-
|
408 |
-
.wpsl-dropdown.touch .old{
|
409 |
width: 100%;
|
410 |
height: 100%;
|
|
|
|
|
|
|
|
|
411 |
}
|
412 |
|
413 |
-
.wpsl-dropdown
|
414 |
-
|
415 |
-
height: 100%;
|
416 |
-
opacity: 0;
|
417 |
}
|
418 |
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
#wpsl-search-wrap .wpsl-dropdown div {
|
423 |
-
margin-right: 0;
|
424 |
-
}
|
425 |
-
.wpsl-dropdown .selected,
|
426 |
-
.wpsl-dropdown li{
|
427 |
display: block;
|
428 |
line-height: 1;
|
429 |
color: #000;
|
430 |
-
padding: 9px 12px;
|
431 |
overflow: hidden;
|
432 |
white-space: nowrap;
|
433 |
}
|
434 |
|
435 |
-
.wpsl-
|
436 |
-
color: #999;
|
437 |
-
}
|
438 |
-
|
439 |
-
.wpsl-dropdown .selected::after{
|
440 |
-
content: '';
|
441 |
-
position: absolute;
|
442 |
-
right: 0;
|
443 |
-
top: 0;
|
444 |
-
bottom: 0;
|
445 |
-
width: 60px;
|
446 |
-
border-radius: 0 2px 2px 0;
|
447 |
-
}
|
448 |
-
|
449 |
-
/* DROP DOWN WRAPPER */
|
450 |
-
.wpsl-dropdown div{
|
451 |
-
position: absolute;
|
452 |
-
height: 0;
|
453 |
-
left: -1px;
|
454 |
-
right: -1px;
|
455 |
-
top: 100%;
|
456 |
-
margin-top: -1px;
|
457 |
-
background: #fff;
|
458 |
-
border: 1px solid #ccc;
|
459 |
-
border-top: 1px solid #eee;
|
460 |
-
border-radius: 0 0 3px 3px;
|
461 |
-
overflow: hidden;
|
462 |
-
opacity: 0;
|
463 |
-
}
|
464 |
-
|
465 |
-
/* Height is adjusted by JS on open */
|
466 |
-
|
467 |
-
.wpsl-dropdown.open div{
|
468 |
-
opacity: 1;
|
469 |
-
z-index: 2;
|
470 |
-
}
|
471 |
-
|
472 |
-
/* FADE OVERLAY FOR SCROLLING LISTS */
|
473 |
-
|
474 |
-
.wpsl-dropdown.scrollable div::after{
|
475 |
-
content: '';
|
476 |
position: absolute;
|
477 |
-
|
478 |
-
right:
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
.wpsl-dropdown.scrollable.bottom div::after{
|
485 |
-
opacity: 0;
|
486 |
}
|
487 |
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
left: 0;
|
493 |
-
top: 0;
|
494 |
-
height: 100%;
|
495 |
-
width: 100%;
|
496 |
-
list-style: none;
|
497 |
-
overflow: hidden;
|
498 |
-
padding:0;
|
499 |
-
margin:0;
|
500 |
}
|
501 |
|
502 |
-
.wpsl-dropdown
|
503 |
-
|
|
|
|
|
|
|
504 |
}
|
505 |
|
506 |
-
|
507 |
-
|
|
|
508 |
list-style: none;
|
509 |
-
padding:
|
510 |
-
margin:0 !important;
|
511 |
}
|
512 |
|
513 |
-
|
514 |
-
|
515 |
-
background: #f8f9f8;
|
516 |
-
position: relative;
|
517 |
-
z-index: 3;
|
518 |
-
color: #000;
|
519 |
}
|
520 |
|
521 |
-
#wpsl-
|
522 |
-
|
523 |
-
|
524 |
}
|
525 |
|
526 |
.clearfix:before,
|
@@ -540,8 +440,6 @@ wpsl-search-input.focus,
|
|
540 |
margin-bottom:10px;
|
541 |
}
|
542 |
|
543 |
-
/* */
|
544 |
-
|
545 |
@media (max-width: 825px) {
|
546 |
#wpsl-search-input {
|
547 |
width: 348px;
|
245 |
float:left;
|
246 |
}
|
247 |
|
248 |
+
#wpsl-search-wrap .wpsl-dropdown div {
|
249 |
+
position: absolute;
|
250 |
+
float: none;
|
251 |
+
margin: -1px 0 0 0;
|
252 |
+
top: 100%;
|
253 |
+
left: -1px;
|
254 |
+
right: -1px;
|
255 |
+
border: 1px solid #ccc;
|
256 |
+
background: #fff;
|
257 |
+
border-top: 1px solid #eee;
|
258 |
+
border-radius: 0 0 3px 3px;
|
259 |
+
opacity: 0;
|
260 |
+
overflow: hidden;
|
261 |
+
-webkit-transition: all 150ms ease-in-out;
|
262 |
+
-moz-transition: all 150ms ease-in-out;
|
263 |
+
-ms-transition: all 150ms ease-in-out;
|
264 |
+
transition: all 150ms ease-in-out;
|
265 |
+
}
|
266 |
+
|
267 |
+
#wpsl-search-wrap .wpsl-dropdown.wpsl-active div {
|
268 |
+
opacity: 1;
|
269 |
+
}
|
270 |
+
|
271 |
#wpsl-search-wrap .wpsl-input label {
|
272 |
margin-right:0;
|
273 |
}
|
343 |
margin-right:0;
|
344 |
}
|
345 |
|
346 |
+
/* --- dropdowns --- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
.wpsl-dropdown {
|
348 |
position: relative;
|
349 |
width: 90px;
|
355 |
-moz-user-select: none;
|
356 |
user-select: none;
|
357 |
margin-right: 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
z-index: 2;
|
359 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
|
361 |
+
.wpsl-dropdown ul {
|
|
|
|
|
|
|
|
|
|
|
362 |
position: absolute;
|
363 |
left: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
width: 100%;
|
365 |
height: 100%;
|
366 |
+
padding: 0;
|
367 |
+
margin: 0;
|
368 |
+
list-style: none;
|
369 |
+
overflow: hidden;
|
370 |
}
|
371 |
|
372 |
+
.wpsl-dropdown:hover {
|
373 |
+
box-shadow: 0 0 5px rgba( 0, 0, 0, 0.15 );
|
|
|
|
|
374 |
}
|
375 |
|
376 |
+
.wpsl-dropdown .wpsl-selected-item,
|
377 |
+
.wpsl-dropdown li {
|
378 |
+
position: relative;
|
|
|
|
|
|
|
|
|
|
|
379 |
display: block;
|
380 |
line-height: 1;
|
381 |
color: #000;
|
|
|
382 |
overflow: hidden;
|
383 |
white-space: nowrap;
|
384 |
}
|
385 |
|
386 |
+
.wpsl-selected-item:after {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
position: absolute;
|
388 |
+
content: "";
|
389 |
+
right: 12px;
|
390 |
+
top: 50%;
|
391 |
+
margin-top: -4px;
|
392 |
+
border: 6px solid transparent;
|
393 |
+
border-top: 8px solid #000;
|
|
|
|
|
|
|
394 |
}
|
395 |
|
396 |
+
.wpsl-active .wpsl-selected-item:after {
|
397 |
+
margin-top: -10px;
|
398 |
+
border: 6px solid transparent;
|
399 |
+
border-bottom: 8px solid #000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
}
|
401 |
|
402 |
+
.wpsl-dropdown li:hover {
|
403 |
+
background: #f8f9f8;
|
404 |
+
position: relative;
|
405 |
+
z-index: 3;
|
406 |
+
color: #000;
|
407 |
}
|
408 |
|
409 |
+
.wpsl-dropdown .wpsl-selected-item,
|
410 |
+
.wpsl-dropdown li,
|
411 |
+
.wpsl-selected-item {
|
412 |
list-style: none;
|
413 |
+
padding: 9px 12px !important;
|
414 |
+
margin:0 !important;
|
415 |
}
|
416 |
|
417 |
+
.wpsl-selected-dropdown {
|
418 |
+
font-weight: bold;
|
|
|
|
|
|
|
|
|
419 |
}
|
420 |
|
421 |
+
#wpsl-radius, #wpsl-results {
|
422 |
+
float: left;
|
423 |
+
margin-right: 15px;
|
424 |
}
|
425 |
|
426 |
.clearfix:before,
|
440 |
margin-bottom:10px;
|
441 |
}
|
442 |
|
|
|
|
|
443 |
@media (max-width: 825px) {
|
444 |
#wpsl-search-input {
|
445 |
width: 348px;
|
frontend/class-frontend.php
CHANGED
@@ -38,7 +38,7 @@ if ( !class_exists( 'WPSL_Frontend' ) ) {
|
|
38 |
$this->add_frontend_scripts();
|
39 |
|
40 |
$template_list = $this->get_templates();
|
41 |
-
$output =
|
42 |
|
43 |
return $output;
|
44 |
}
|
@@ -171,7 +171,6 @@ if ( !class_exists( 'WPSL_Frontend' ) ) {
|
|
171 |
*/
|
172 |
public function add_frontend_scripts() {
|
173 |
wp_enqueue_style( 'wpsl-css', WPSL_URL . 'css/styles.css', false );
|
174 |
-
wp_enqueue_script( 'wpsl-dropdown', WPSL_URL.'js/jquery.easydropdown.min.js', array( 'jquery' ) ); //not minified version is in the js folder
|
175 |
wp_enqueue_script( 'wpsl-gmap', ( "//maps.google.com/maps/api/js?sensor=false".$this->get_gmap_api_attributes() ),'' ,'' ,true );
|
176 |
|
177 |
if ( $this->settings['marker_clusters'] ) {
|
@@ -220,7 +219,6 @@ if ( !class_exists( 'WPSL_Frontend' ) ) {
|
|
220 |
$settings['clusterSize'] = $this->settings['cluster_size'];
|
221 |
}
|
222 |
|
223 |
-
/* The __( string, 'wpsl' ) makes the labels accessible in wpml */
|
224 |
$labels = array(
|
225 |
'preloader' => stripslashes( __( $this->settings['preloader_label'], 'wpsl' ) ),
|
226 |
'noResults' => stripslashes( __( $this->settings['no_results_label'], 'wpsl' ) ),
|
38 |
$this->add_frontend_scripts();
|
39 |
|
40 |
$template_list = $this->get_templates();
|
41 |
+
$output = include( $template_list[ absint( $this->settings['template_id'] ) ]['path'] );
|
42 |
|
43 |
return $output;
|
44 |
}
|
171 |
*/
|
172 |
public function add_frontend_scripts() {
|
173 |
wp_enqueue_style( 'wpsl-css', WPSL_URL . 'css/styles.css', false );
|
|
|
174 |
wp_enqueue_script( 'wpsl-gmap', ( "//maps.google.com/maps/api/js?sensor=false".$this->get_gmap_api_attributes() ),'' ,'' ,true );
|
175 |
|
176 |
if ( $this->settings['marker_clusters'] ) {
|
219 |
$settings['clusterSize'] = $this->settings['cluster_size'];
|
220 |
}
|
221 |
|
|
|
222 |
$labels = array(
|
223 |
'preloader' => stripslashes( __( $this->settings['preloader_label'], 'wpsl' ) ),
|
224 |
'noResults' => stripslashes( __( $this->settings['no_results_label'], 'wpsl' ) ),
|
js/jquery.easydropdown.js
DELETED
@@ -1,479 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* EASYDROPDOWN - A Drop-down Builder for Styleable Inputs and Menus
|
3 |
-
* Version: 2.1.4
|
4 |
-
* License: Creative Commons Attribution 3.0 Unported - CC BY 3.0
|
5 |
-
* http://creativecommons.org/licenses/by/3.0/
|
6 |
-
* This software may be used freely on commercial and non-commercial projects with attribution to the author/copyright holder.
|
7 |
-
* Author: Patrick Kunka
|
8 |
-
* Copyright 2013 Patrick Kunka, All Rights Reserved
|
9 |
-
*/
|
10 |
-
|
11 |
-
|
12 |
-
(function($){
|
13 |
-
|
14 |
-
function EasyDropDown(){
|
15 |
-
this.isField = true,
|
16 |
-
this.down = false,
|
17 |
-
this.inFocus = false,
|
18 |
-
this.disabled = false,
|
19 |
-
this.cutOff = false,
|
20 |
-
this.hasLabel = false,
|
21 |
-
this.keyboardMode = false,
|
22 |
-
this.nativeTouch = true,
|
23 |
-
this.wrapperClass = 'dropdown',
|
24 |
-
this.onChange = null;
|
25 |
-
};
|
26 |
-
|
27 |
-
EasyDropDown.prototype = {
|
28 |
-
constructor: EasyDropDown,
|
29 |
-
instances: {},
|
30 |
-
init: function(domNode, settings){
|
31 |
-
var self = this;
|
32 |
-
|
33 |
-
$.extend(self, settings);
|
34 |
-
self.$select = $(domNode);
|
35 |
-
self.id = domNode.id;
|
36 |
-
self.options = [];
|
37 |
-
self.$options = self.$select.find('option');
|
38 |
-
self.isTouch = 'ontouchend' in document;
|
39 |
-
self.$select.removeClass(self.wrapperClass+' dropdown');
|
40 |
-
if(self.$select.is(':disabled')){
|
41 |
-
self.disabled = true;
|
42 |
-
};
|
43 |
-
if(self.$options.length){
|
44 |
-
self.$options.each(function(i){
|
45 |
-
var $option = $(this);
|
46 |
-
if($option.is(':selected')){
|
47 |
-
self.selected = {
|
48 |
-
index: i,
|
49 |
-
title: $option.text()
|
50 |
-
}
|
51 |
-
self.focusIndex = i;
|
52 |
-
};
|
53 |
-
if($option.hasClass('label') && i == 0){
|
54 |
-
self.hasLabel = true;
|
55 |
-
self.label = $option.text();
|
56 |
-
$option.attr('value','');
|
57 |
-
} else {
|
58 |
-
self.options.push({
|
59 |
-
domNode: $option[0],
|
60 |
-
title: $option.text(),
|
61 |
-
value: $option.val(),
|
62 |
-
selected: $option.is(':selected')
|
63 |
-
});
|
64 |
-
};
|
65 |
-
});
|
66 |
-
if(!self.selected){
|
67 |
-
self.selected = {
|
68 |
-
index: 0,
|
69 |
-
title: self.$options.eq(0).text()
|
70 |
-
}
|
71 |
-
self.focusIndex = 0;
|
72 |
-
};
|
73 |
-
self.render();
|
74 |
-
};
|
75 |
-
},
|
76 |
-
|
77 |
-
render: function(){
|
78 |
-
var self = this,
|
79 |
-
touchClass = self.isTouch && self.nativeTouch ? ' touch' : '',
|
80 |
-
disabledClass = self.disabled ? ' disabled' : '';
|
81 |
-
|
82 |
-
self.$container = self.$select.wrap('<div class="'+self.wrapperClass+touchClass+disabledClass+'"><span class="old"/></div>').parent().parent();
|
83 |
-
self.$active = $('<span class="selected">'+self.selected.title+'</span>').appendTo(self.$container);
|
84 |
-
self.$carat = $('<span class="carat"/>').appendTo(self.$container);
|
85 |
-
self.$scrollWrapper = $('<div><ul/></div>').appendTo(self.$container);
|
86 |
-
self.$dropDown = self.$scrollWrapper.find('ul');
|
87 |
-
self.$form = self.$container.closest('form');
|
88 |
-
$.each(self.options, function(){
|
89 |
-
var option = this,
|
90 |
-
active = option.selected ? ' class="active"':'';
|
91 |
-
self.$dropDown.append('<li'+active+'>'+option.title+'</li>');
|
92 |
-
});
|
93 |
-
self.$items = self.$dropDown.find('li');
|
94 |
-
|
95 |
-
if(self.cutOff && self.$items.length > self.cutOff)self.$container.addClass('scrollable');
|
96 |
-
|
97 |
-
self.getMaxHeight();
|
98 |
-
|
99 |
-
if(self.isTouch && self.nativeTouch){
|
100 |
-
self.bindTouchHandlers();
|
101 |
-
} else {
|
102 |
-
self.bindHandlers();
|
103 |
-
};
|
104 |
-
},
|
105 |
-
|
106 |
-
getMaxHeight: function(){
|
107 |
-
var self = this;
|
108 |
-
|
109 |
-
self.maxHeight = 0;
|
110 |
-
|
111 |
-
for(i = 0; i < self.$items.length; i++){
|
112 |
-
var $item = self.$items.eq(i);
|
113 |
-
self.maxHeight += $item.outerHeight();
|
114 |
-
if(self.cutOff == i+1){
|
115 |
-
break;
|
116 |
-
};
|
117 |
-
};
|
118 |
-
},
|
119 |
-
|
120 |
-
bindTouchHandlers: function(){
|
121 |
-
var self = this;
|
122 |
-
self.$container.on('click.easyDropDown',function(){
|
123 |
-
self.$select.focus();
|
124 |
-
});
|
125 |
-
self.$select.on({
|
126 |
-
change: function(){
|
127 |
-
var $selected = $(this).find('option:selected'),
|
128 |
-
title = $selected.text(),
|
129 |
-
value = $selected.val();
|
130 |
-
|
131 |
-
self.$active.text(title);
|
132 |
-
if(typeof self.onChange === 'function'){
|
133 |
-
self.onChange.call(self.$select[0],{
|
134 |
-
title: title,
|
135 |
-
value: value
|
136 |
-
});
|
137 |
-
};
|
138 |
-
},
|
139 |
-
focus: function(){
|
140 |
-
self.$container.addClass('focus');
|
141 |
-
},
|
142 |
-
blur: function(){
|
143 |
-
self.$container.removeClass('focus');
|
144 |
-
}
|
145 |
-
});
|
146 |
-
},
|
147 |
-
|
148 |
-
bindHandlers: function(){
|
149 |
-
var self = this;
|
150 |
-
self.query = '';
|
151 |
-
self.$container.on({
|
152 |
-
'click.easyDropDown': function(){
|
153 |
-
if(!self.down && !self.disabled){
|
154 |
-
self.open();
|
155 |
-
} else {
|
156 |
-
self.close();
|
157 |
-
};
|
158 |
-
},
|
159 |
-
'mousemove.easyDropDown': function(){
|
160 |
-
if(self.keyboardMode){
|
161 |
-
self.keyboardMode = false;
|
162 |
-
};
|
163 |
-
}
|
164 |
-
});
|
165 |
-
|
166 |
-
$('body').on('click.easyDropDown.'+self.id,function(e){
|
167 |
-
var $target = $(e.target),
|
168 |
-
classNames = self.wrapperClass.split(' ').join('.');
|
169 |
-
|
170 |
-
if(!$target.closest('.'+classNames).length && self.down){
|
171 |
-
self.close();
|
172 |
-
};
|
173 |
-
});
|
174 |
-
|
175 |
-
self.$items.on({
|
176 |
-
'click.easyDropDown': function(){
|
177 |
-
var index = $(this).index();
|
178 |
-
self.select(index);
|
179 |
-
self.$select.focus();
|
180 |
-
},
|
181 |
-
'mouseover.easyDropDown': function(){
|
182 |
-
if(!self.keyboardMode){
|
183 |
-
var $t = $(this);
|
184 |
-
$t.addClass('focus').siblings().removeClass('focus');
|
185 |
-
self.focusIndex = $t.index();
|
186 |
-
};
|
187 |
-
},
|
188 |
-
'mouseout.easyDropDown': function(){
|
189 |
-
if(!self.keyboardMode){
|
190 |
-
$(this).removeClass('focus');
|
191 |
-
};
|
192 |
-
}
|
193 |
-
});
|
194 |
-
|
195 |
-
self.$select.on({
|
196 |
-
'focus.easyDropDown': function(){
|
197 |
-
self.$container.addClass('focus');
|
198 |
-
self.inFocus = true;
|
199 |
-
},
|
200 |
-
'blur.easyDropDown': function(){
|
201 |
-
self.$container.removeClass('focus');
|
202 |
-
self.inFocus = false;
|
203 |
-
},
|
204 |
-
'keydown.easyDropDown': function(e){
|
205 |
-
if(self.inFocus){
|
206 |
-
self.keyboardMode = true;
|
207 |
-
var key = e.keyCode;
|
208 |
-
|
209 |
-
if(key == 38 || key == 40 || key == 32){
|
210 |
-
e.preventDefault();
|
211 |
-
if(key == 38){
|
212 |
-
self.focusIndex--
|
213 |
-
self.focusIndex = self.focusIndex < 0 ? self.$items.length - 1 : self.focusIndex;
|
214 |
-
} else if(key == 40){
|
215 |
-
self.focusIndex++
|
216 |
-
self.focusIndex = self.focusIndex > self.$items.length - 1 ? 0 : self.focusIndex;
|
217 |
-
};
|
218 |
-
if(!self.down){
|
219 |
-
self.open();
|
220 |
-
};
|
221 |
-
self.$items.removeClass('focus').eq(self.focusIndex).addClass('focus');
|
222 |
-
if(self.cutOff){
|
223 |
-
self.scrollToView();
|
224 |
-
};
|
225 |
-
self.query = '';
|
226 |
-
};
|
227 |
-
if(self.down){
|
228 |
-
if(key == 9 || key == 27){
|
229 |
-
self.close();
|
230 |
-
} else if(key == 13){
|
231 |
-
e.preventDefault();
|
232 |
-
self.select(self.focusIndex);
|
233 |
-
self.close();
|
234 |
-
return false;
|
235 |
-
} else if(key == 8){
|
236 |
-
e.preventDefault();
|
237 |
-
self.query = self.query.slice(0,-1);
|
238 |
-
self.search();
|
239 |
-
clearTimeout(self.resetQuery);
|
240 |
-
return false;
|
241 |
-
} else if(key != 38 && key != 40){
|
242 |
-
var letter = String.fromCharCode(key);
|
243 |
-
self.query += letter;
|
244 |
-
self.search();
|
245 |
-
clearTimeout(self.resetQuery);
|
246 |
-
};
|
247 |
-
};
|
248 |
-
};
|
249 |
-
},
|
250 |
-
'keyup.easyDropDown': function(){
|
251 |
-
self.resetQuery = setTimeout(function(){
|
252 |
-
self.query = '';
|
253 |
-
},1200);
|
254 |
-
}
|
255 |
-
});
|
256 |
-
|
257 |
-
self.$dropDown.on('scroll.easyDropDown',function(e){
|
258 |
-
if(self.$dropDown[0].scrollTop >= self.$dropDown[0].scrollHeight - self.maxHeight){
|
259 |
-
self.$container.addClass('bottom');
|
260 |
-
} else {
|
261 |
-
self.$container.removeClass('bottom');
|
262 |
-
};
|
263 |
-
});
|
264 |
-
|
265 |
-
if(self.$form.length){
|
266 |
-
self.$form.on('reset.easyDropDown', function(){
|
267 |
-
var active = self.hasLabel ? self.label : self.options[0].title;
|
268 |
-
self.$active.text(active);
|
269 |
-
});
|
270 |
-
};
|
271 |
-
},
|
272 |
-
|
273 |
-
unbindHandlers: function(){
|
274 |
-
var self = this;
|
275 |
-
|
276 |
-
self.$container
|
277 |
-
.add(self.$select)
|
278 |
-
.add(self.$items)
|
279 |
-
.add(self.$form)
|
280 |
-
.add(self.$dropDown)
|
281 |
-
.off('.easyDropDown');
|
282 |
-
$('body').off('.'+self.id);
|
283 |
-
},
|
284 |
-
|
285 |
-
open: function(){
|
286 |
-
var self = this,
|
287 |
-
scrollTop = window.scrollY || document.documentElement.scrollTop,
|
288 |
-
scrollLeft = window.scrollX || document.documentElement.scrollLeft,
|
289 |
-
scrollOffset = self.notInViewport(scrollTop);
|
290 |
-
|
291 |
-
self.closeAll();
|
292 |
-
self.getMaxHeight();
|
293 |
-
self.$select.focus();
|
294 |
-
window.scrollTo(scrollLeft, scrollTop+scrollOffset);
|
295 |
-
self.$container.addClass('open');
|
296 |
-
self.$scrollWrapper.css('height',self.maxHeight+'px');
|
297 |
-
self.down = true;
|
298 |
-
},
|
299 |
-
|
300 |
-
close: function(){
|
301 |
-
var self = this;
|
302 |
-
self.$container.removeClass('open');
|
303 |
-
self.$scrollWrapper.css('height','0px');
|
304 |
-
self.focusIndex = self.selected.index;
|
305 |
-
self.query = '';
|
306 |
-
self.down = false;
|
307 |
-
},
|
308 |
-
|
309 |
-
closeAll: function(){
|
310 |
-
var self = this,
|
311 |
-
instances = Object.getPrototypeOf(self).instances;
|
312 |
-
for(var key in instances){
|
313 |
-
var instance = instances[key];
|
314 |
-
instance.close();
|
315 |
-
};
|
316 |
-
},
|
317 |
-
|
318 |
-
select: function(index){
|
319 |
-
var self = this;
|
320 |
-
|
321 |
-
if(typeof index === 'string'){
|
322 |
-
index = self.$select.find('option[value='+index+']').index() - 1;
|
323 |
-
};
|
324 |
-
|
325 |
-
var option = self.options[index],
|
326 |
-
selectIndex = self.hasLabel ? index + 1 : index;
|
327 |
-
self.$items.removeClass('active').eq(index).addClass('active');
|
328 |
-
self.$active.text(option.title);
|
329 |
-
self.$select
|
330 |
-
.find('option')
|
331 |
-
.removeAttr('selected')
|
332 |
-
.eq(selectIndex)
|
333 |
-
.prop('selected',true)
|
334 |
-
.parent()
|
335 |
-
.trigger('change');
|
336 |
-
|
337 |
-
self.selected = {
|
338 |
-
index: index,
|
339 |
-
title: option.title
|
340 |
-
};
|
341 |
-
self.focusIndex = i;
|
342 |
-
if(typeof self.onChange === 'function'){
|
343 |
-
self.onChange.call(self.$select[0],{
|
344 |
-
title: option.title,
|
345 |
-
value: option.value
|
346 |
-
});
|
347 |
-
};
|
348 |
-
},
|
349 |
-
|
350 |
-
search: function(){
|
351 |
-
var self = this,
|
352 |
-
lock = function(i){
|
353 |
-
self.focusIndex = i;
|
354 |
-
self.$items.removeClass('focus').eq(self.focusIndex).addClass('focus');
|
355 |
-
self.scrollToView();
|
356 |
-
},
|
357 |
-
getTitle = function(i){
|
358 |
-
return self.options[i].title.toUpperCase();
|
359 |
-
};
|
360 |
-
|
361 |
-
for(i = 0; i < self.options.length; i++){
|
362 |
-
var title = getTitle(i);
|
363 |
-
if(title.indexOf(self.query) == 0){
|
364 |
-
lock(i);
|
365 |
-
return;
|
366 |
-
};
|
367 |
-
};
|
368 |
-
|
369 |
-
for(i = 0; i < self.options.length; i++){
|
370 |
-
var title = getTitle(i);
|
371 |
-
if(title.indexOf(self.query) > -1){
|
372 |
-
lock(i);
|
373 |
-
break;
|
374 |
-
};
|
375 |
-
};
|
376 |
-
},
|
377 |
-
|
378 |
-
scrollToView: function(){
|
379 |
-
var self = this;
|
380 |
-
if(self.focusIndex >= self.cutOff){
|
381 |
-
var $focusItem = self.$items.eq(self.focusIndex),
|
382 |
-
scroll = ($focusItem.outerHeight() * (self.focusIndex + 1)) - self.maxHeight;
|
383 |
-
|
384 |
-
self.$dropDown.scrollTop(scroll);
|
385 |
-
};
|
386 |
-
},
|
387 |
-
|
388 |
-
notInViewport: function(scrollTop){
|
389 |
-
var self = this,
|
390 |
-
range = {
|
391 |
-
min: scrollTop,
|
392 |
-
max: scrollTop + (window.innerHeight || document.documentElement.clientHeight)
|
393 |
-
},
|
394 |
-
menuBottom = self.$dropDown.offset().top + self.maxHeight;
|
395 |
-
|
396 |
-
if(menuBottom >= range.min && menuBottom <= range.max){
|
397 |
-
return 0;
|
398 |
-
} else {
|
399 |
-
return (menuBottom - range.max) + 5;
|
400 |
-
};
|
401 |
-
},
|
402 |
-
|
403 |
-
destroy: function(){
|
404 |
-
var self = this;
|
405 |
-
self.unbindHandlers();
|
406 |
-
self.$select.unwrap().siblings().remove();
|
407 |
-
self.$select.unwrap();
|
408 |
-
delete Object.getPrototypeOf(self).instances[self.$select[0].id];
|
409 |
-
},
|
410 |
-
|
411 |
-
disable: function(){
|
412 |
-
var self = this;
|
413 |
-
self.disabled = true;
|
414 |
-
self.$container.addClass('disabled');
|
415 |
-
self.$select.attr('disabled',true);
|
416 |
-
if(!self.down)self.close();
|
417 |
-
},
|
418 |
-
|
419 |
-
enable: function(){
|
420 |
-
var self = this;
|
421 |
-
self.disabled = false;
|
422 |
-
self.$container.removeClass('disabled');
|
423 |
-
self.$select.attr('disabled',false);
|
424 |
-
}
|
425 |
-
};
|
426 |
-
|
427 |
-
var instantiate = function(domNode, settings){
|
428 |
-
domNode.id = !domNode.id ? 'EasyDropDown'+rand() : domNode.id;
|
429 |
-
var instance = new EasyDropDown();
|
430 |
-
if(!instance.instances[domNode.id]){
|
431 |
-
instance.instances[domNode.id] = instance;
|
432 |
-
instance.init(domNode, settings);
|
433 |
-
};
|
434 |
-
},
|
435 |
-
rand = function(){
|
436 |
-
return ('00000'+(Math.random()*16777216<<0).toString(16)).substr(-6).toUpperCase();
|
437 |
-
};
|
438 |
-
|
439 |
-
$.fn.easyDropDown = function(){
|
440 |
-
var args = arguments,
|
441 |
-
dataReturn = [],
|
442 |
-
eachReturn;
|
443 |
-
|
444 |
-
eachReturn = this.each(function(){
|
445 |
-
if(args && typeof args[0] === 'string'){
|
446 |
-
var data = EasyDropDown.prototype.instances[this.id][args[0]](args[1], args[2]);
|
447 |
-
if(data)dataReturn.push(data);
|
448 |
-
} else {
|
449 |
-
instantiate(this, args[0]);
|
450 |
-
};
|
451 |
-
});
|
452 |
-
|
453 |
-
if(dataReturn.length){
|
454 |
-
return dataReturn.length > 1 ? dataReturn : dataReturn[0];
|
455 |
-
} else {
|
456 |
-
return eachReturn;
|
457 |
-
};
|
458 |
-
};
|
459 |
-
|
460 |
-
$(function(){
|
461 |
-
if(typeof Object.getPrototypeOf !== 'function'){
|
462 |
-
if(typeof 'test'.__proto__ === 'object'){
|
463 |
-
Object.getPrototypeOf = function(object){
|
464 |
-
return object.__proto__;
|
465 |
-
};
|
466 |
-
} else {
|
467 |
-
Object.getPrototypeOf = function(object){
|
468 |
-
return object.constructor.prototype;
|
469 |
-
};
|
470 |
-
};
|
471 |
-
};
|
472 |
-
|
473 |
-
$('select.dropdown').each(function(){
|
474 |
-
var json = $(this).attr('data-settings');
|
475 |
-
settings = json ? $.parseJSON(json) : {};
|
476 |
-
instantiate(this, settings);
|
477 |
-
});
|
478 |
-
});
|
479 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/jquery.easydropdown.min.js
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* EASYDROPDOWN - A Drop-down Builder for Styleable Inputs and Menus
|
3 |
-
* Version: 2.1.4
|
4 |
-
* License: Creative Commons Attribution 3.0 Unported - CC BY 3.0
|
5 |
-
* http://creativecommons.org/licenses/by/3.0/
|
6 |
-
* This software may be used freely on commercial and non-commercial projects with attribution to the author/copyright holder.
|
7 |
-
* Author: Patrick Kunka
|
8 |
-
* Copyright 2013 Patrick Kunka, All Rights Reserved
|
9 |
-
*/
|
10 |
-
|
11 |
-
(function(d){function e(){this.isField=!0;this.keyboardMode=this.hasLabel=this.cutOff=this.disabled=this.inFocus=this.down=!1;this.nativeTouch=!0;this.wrapperClass="dropdown";this.onChange=null}e.prototype={constructor:e,instances:{},init:function(a,c){var b=this;d.extend(b,c);b.$select=d(a);b.id=a.id;b.options=[];b.$options=b.$select.find("option");b.isTouch="ontouchend"in document;b.$select.removeClass(b.wrapperClass+" dropdown");b.$select.is(":disabled")&&(b.disabled=!0);b.$options.length&&(b.$options.each(function(a){var c=
|
12 |
-
d(this);c.is(":selected")&&(b.selected={index:a,title:c.text()},b.focusIndex=a);c.hasClass("label")&&0==a?(b.hasLabel=!0,b.label=c.text(),c.attr("value","")):b.options.push({domNode:c[0],title:c.text(),value:c.val(),selected:c.is(":selected")})}),b.selected||(b.selected={index:0,title:b.$options.eq(0).text()},b.focusIndex=0),b.render())},render:function(){var a=this;a.$container=a.$select.wrap('<div class="'+a.wrapperClass+(a.isTouch&&a.nativeTouch?" touch":"")+(a.disabled?" disabled":"")+'"><span class="old"/></div>').parent().parent();
|
13 |
-
a.$active=d('<span class="selected">'+a.selected.title+"</span>").appendTo(a.$container);a.$carat=d('<span class="carat"/>').appendTo(a.$container);a.$scrollWrapper=d("<div><ul/></div>").appendTo(a.$container);a.$dropDown=a.$scrollWrapper.find("ul");a.$form=a.$container.closest("form");d.each(a.options,function(){a.$dropDown.append("<li"+(this.selected?' class="active"':"")+">"+this.title+"</li>")});a.$items=a.$dropDown.find("li");a.cutOff&&a.$items.length>a.cutOff&&a.$container.addClass("scrollable");
|
14 |
-
a.getMaxHeight();a.isTouch&&a.nativeTouch?a.bindTouchHandlers():a.bindHandlers()},getMaxHeight:function(){for(i=this.maxHeight=0;i<this.$items.length;i++){var a=this.$items.eq(i);this.maxHeight+=a.outerHeight();if(this.cutOff==i+1)break}},bindTouchHandlers:function(){var a=this;a.$container.on("click.easyDropDown",function(){a.$select.focus()});a.$select.on({change:function(){var c=d(this).find("option:selected"),b=c.text(),c=c.val();a.$active.text(b);"function"===typeof a.onChange&&a.onChange.call(a.$select[0],
|
15 |
-
{title:b,value:c})},focus:function(){a.$container.addClass("focus")},blur:function(){a.$container.removeClass("focus")}})},bindHandlers:function(){var a=this;a.query="";a.$container.on({"click.easyDropDown":function(){a.down||a.disabled?a.close():a.open()},"mousemove.easyDropDown":function(){a.keyboardMode&&(a.keyboardMode=!1)}});d("body").on("click.easyDropDown."+a.id,function(c){c=d(c.target);var b=a.wrapperClass.split(" ").join(".");!c.closest("."+b).length&&a.down&&a.close()});a.$items.on({"click.easyDropDown":function(){var c=
|
16 |
-
d(this).index();a.select(c);a.$select.focus()},"mouseover.easyDropDown":function(){if(!a.keyboardMode){var c=d(this);c.addClass("focus").siblings().removeClass("focus");a.focusIndex=c.index()}},"mouseout.easyDropDown":function(){a.keyboardMode||d(this).removeClass("focus")}});a.$select.on({"focus.easyDropDown":function(){a.$container.addClass("focus");a.inFocus=!0},"blur.easyDropDown":function(){a.$container.removeClass("focus");a.inFocus=!1},"keydown.easyDropDown":function(c){if(a.inFocus){a.keyboardMode=
|
17 |
-
!0;var b=c.keyCode;if(38==b||40==b||32==b)c.preventDefault(),38==b?(a.focusIndex--,a.focusIndex=0>a.focusIndex?a.$items.length-1:a.focusIndex):40==b&&(a.focusIndex++,a.focusIndex=a.focusIndex>a.$items.length-1?0:a.focusIndex),a.down||a.open(),a.$items.removeClass("focus").eq(a.focusIndex).addClass("focus"),a.cutOff&&a.scrollToView(),a.query="";if(a.down)if(9==b||27==b)a.close();else{if(13==b)return c.preventDefault(),a.select(a.focusIndex),a.close(),!1;if(8==b)return c.preventDefault(),a.query=a.query.slice(0,
|
18 |
-
-1),a.search(),clearTimeout(a.resetQuery),!1;38!=b&&40!=b&&(c=String.fromCharCode(b),a.query+=c,a.search(),clearTimeout(a.resetQuery))}}},"keyup.easyDropDown":function(){a.resetQuery=setTimeout(function(){a.query=""},1200)}});a.$dropDown.on("scroll.easyDropDown",function(c){a.$dropDown[0].scrollTop>=a.$dropDown[0].scrollHeight-a.maxHeight?a.$container.addClass("bottom"):a.$container.removeClass("bottom")});if(a.$form.length)a.$form.on("reset.easyDropDown",function(){a.$active.text(a.hasLabel?a.label:
|
19 |
-
a.options[0].title)})},unbindHandlers:function(){this.$container.add(this.$select).add(this.$items).add(this.$form).add(this.$dropDown).off(".easyDropDown");d("body").off("."+this.id)},open:function(){var a=window.scrollY||document.documentElement.scrollTop,c=window.scrollX||document.documentElement.scrollLeft,b=this.notInViewport(a);this.closeAll();this.getMaxHeight();this.$select.focus();window.scrollTo(c,a+b);this.$container.addClass("open");this.$scrollWrapper.css("height",this.maxHeight+"px");
|
20 |
-
this.down=!0},close:function(){this.$container.removeClass("open");this.$scrollWrapper.css("height","0px");this.focusIndex=this.selected.index;this.query="";this.down=!1},closeAll:function(){var a=Object.getPrototypeOf(this).instances,c;for(c in a)a[c].close()},select:function(a){"string"===typeof a&&(a=this.$select.find("option[value="+a+"]").index()-1);var c=this.options[a],b=this.hasLabel?a+1:a;this.$items.removeClass("active").eq(a).addClass("active");this.$active.text(c.title);this.$select.find("option").removeAttr("selected").eq(b).prop("selected",
|
21 |
-
!0).parent().trigger("change");this.selected={index:a,title:c.title};this.focusIndex=i;"function"===typeof this.onChange&&this.onChange.call(this.$select[0],{title:c.title,value:c.value})},search:function(){var a=this,c=function(b){a.focusIndex=b;a.$items.removeClass("focus").eq(a.focusIndex).addClass("focus");a.scrollToView()};for(i=0;i<a.options.length;i++){var b=a.options[i].title.toUpperCase();if(0==b.indexOf(a.query)){c(i);return}}for(i=0;i<a.options.length;i++)if(b=a.options[i].title.toUpperCase(),
|
22 |
-
-1<b.indexOf(a.query)){c(i);break}},scrollToView:function(){if(this.focusIndex>=this.cutOff){var a=this.$items.eq(this.focusIndex).outerHeight()*(this.focusIndex+1)-this.maxHeight;this.$dropDown.scrollTop(a)}},notInViewport:function(a){var c=a+(window.innerHeight||document.documentElement.clientHeight),b=this.$dropDown.offset().top+this.maxHeight;return b>=a&&b<=c?0:b-c+5},destroy:function(){this.unbindHandlers();this.$select.unwrap().siblings().remove();this.$select.unwrap();delete Object.getPrototypeOf(this).instances[this.$select[0].id]},
|
23 |
-
disable:function(){this.disabled=!0;this.$container.addClass("disabled");this.$select.attr("disabled",!0);this.down||this.close()},enable:function(){this.disabled=!1;this.$container.removeClass("disabled");this.$select.attr("disabled",!1)}};var f=function(a,c){a.id=a.id?a.id:"EasyDropDown"+("00000"+(16777216*Math.random()<<0).toString(16)).substr(-6).toUpperCase();var b=new e;b.instances[a.id]||(b.instances[a.id]=b,b.init(a,c))};d.fn.easyDropDown=function(){var a=arguments,c=[],b;b=this.each(function(){if(a&&
|
24 |
-
"string"===typeof a[0]){var b=e.prototype.instances[this.id][a[0]](a[1],a[2]);b&&c.push(b)}else f(this,a[0])});return c.length?1<c.length?c:c[0]:b};d(function(){"function"!==typeof Object.getPrototypeOf&&(Object.getPrototypeOf="object"===typeof"test".__proto__?function(a){return a.__proto__}:function(a){return a.constructor.prototype});d("select.dropdown").each(function(){var a=d(this).attr("data-settings");settings=a?d.parseJSON(a):{};f(this,settings)})})})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/wpsl-gmap.js
CHANGED
@@ -8,8 +8,7 @@ var geocoder, map, infoWindow, directionsDisplay, directionsService, geolocation
|
|
8 |
startMarkerData,
|
9 |
startAddress,
|
10 |
startLatLng,
|
11 |
-
autoLoad = wpslSettings.autoLoad
|
12 |
-
$selects = $( "#wpsl-search-wrap select" );
|
13 |
|
14 |
/**
|
15 |
* Initialize the map with the correct settings
|
@@ -87,11 +86,8 @@ function initializeGmap() {
|
|
87 |
* We do this because several people have reported issues with it on iOS and Android devices. So on mobile
|
88 |
* devices the dropdowns will be styled according to the browser styles on that device.
|
89 |
*/
|
90 |
-
if ( !checkMobileUserAgent() ) {
|
91 |
-
|
92 |
-
cutOff: 10,
|
93 |
-
wrapperClass: "wpsl-dropdown"
|
94 |
-
});
|
95 |
} else {
|
96 |
$( "#wpsl-search-wrap select").show();
|
97 |
$( "#wpsl-wrap" ).addClass( "wpsl-mobile" );
|
@@ -626,8 +622,8 @@ function makeAjaxRequest( startLatLng, resetMap, autoLoad ) {
|
|
626 |
ajaxData.max_results = $( "#wpsl-results .wpsl-dropdown" ).val();
|
627 |
ajaxData.radius = $( "#wpsl-radius .wpsl-dropdown" ).val();
|
628 |
} else {
|
629 |
-
ajaxData.max_results = parseInt( $( "#wpsl-results .wpsl-dropdown
|
630 |
-
ajaxData.radius = parseInt( $( "#wpsl-radius .wpsl-dropdown
|
631 |
}
|
632 |
}
|
633 |
|
@@ -799,8 +795,7 @@ function addMarker( latLng, storeId, infoWindowData, draggable ) {
|
|
799 |
} else {
|
800 |
setInfoWindowContent( marker, wpslLabels.startPoint );
|
801 |
}
|
802 |
-
|
803 |
-
google.maps.event.clearListeners( infoWindow );
|
804 |
google.maps.event.addListener( infoWindow, "domready", function() {
|
805 |
infoWindowActions( marker, latLng );
|
806 |
});
|
@@ -1203,7 +1198,7 @@ function storeHtml( response, url ) {
|
|
1203 |
address2 = "<span class='wpsl-street'>" + response.address2 + "</span>";
|
1204 |
}
|
1205 |
|
1206 |
-
html = "<li data-store-id='" + id + "'><div><p>" + storeImg + "<strong>" + store + "</strong><span class='wpsl-street'>" + address + "</span>" + address2 + city + " " + state + " " + zip + "<span class='wpsl-country'>" + country + "</p>" + moreInfo + "</div>" + distance + "<a class='wpsl-directions' " + url.target + " href='" + url.src + "'>" + wpslLabels.directions + "</a></li>";
|
1207 |
|
1208 |
return html;
|
1209 |
}
|
@@ -1363,6 +1358,95 @@ $( "#wpsl-stores" ).on( "click", ".wpsl-store-details", function() {
|
|
1363 |
}
|
1364 |
});
|
1365 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1366 |
if ( $( "#wpsl-gmap" ).length ) {
|
1367 |
google.maps.event.addDomListener( window, "load", initializeGmap );
|
1368 |
}
|
8 |
startMarkerData,
|
9 |
startAddress,
|
10 |
startLatLng,
|
11 |
+
autoLoad = wpslSettings.autoLoad;
|
|
|
12 |
|
13 |
/**
|
14 |
* Initialize the map with the correct settings
|
86 |
* We do this because several people have reported issues with it on iOS and Android devices. So on mobile
|
87 |
* devices the dropdowns will be styled according to the browser styles on that device.
|
88 |
*/
|
89 |
+
if ( !checkMobileUserAgent() && $( ".wpsl-dropdown" ).length ) {
|
90 |
+
createDropdowns();
|
|
|
|
|
|
|
91 |
} else {
|
92 |
$( "#wpsl-search-wrap select").show();
|
93 |
$( "#wpsl-wrap" ).addClass( "wpsl-mobile" );
|
622 |
ajaxData.max_results = $( "#wpsl-results .wpsl-dropdown" ).val();
|
623 |
ajaxData.radius = $( "#wpsl-radius .wpsl-dropdown" ).val();
|
624 |
} else {
|
625 |
+
ajaxData.max_results = parseInt( $( "#wpsl-results .wpsl-selected-dropdown" ).text() );
|
626 |
+
ajaxData.radius = parseInt( $( "#wpsl-radius .wpsl-selected-dropdown" ).text() );
|
627 |
}
|
628 |
}
|
629 |
|
795 |
} else {
|
796 |
setInfoWindowContent( marker, wpslLabels.startPoint );
|
797 |
}
|
798 |
+
|
|
|
799 |
google.maps.event.addListener( infoWindow, "domready", function() {
|
800 |
infoWindowActions( marker, latLng );
|
801 |
});
|
1198 |
address2 = "<span class='wpsl-street'>" + response.address2 + "</span>";
|
1199 |
}
|
1200 |
|
1201 |
+
html = "<li data-store-id='" + id + "'><div><p>" + storeImg + "<strong>" + store + "</strong><span class='wpsl-street'>" + address + "</span>" + address2 + city + " " + state + " " + zip + "<span class='wpsl-country'>" + country + "</span></p>" + moreInfo + "</div>" + distance + "<a class='wpsl-directions' " + url.target + " href='" + url.src + "'>" + wpslLabels.directions + "</a></li>";
|
1202 |
|
1203 |
return html;
|
1204 |
}
|
1358 |
}
|
1359 |
});
|
1360 |
|
1361 |
+
/**
|
1362 |
+
* Create the dropdown filters
|
1363 |
+
*
|
1364 |
+
* Inspired by https://github.com/patrickkunka/easydropdown
|
1365 |
+
*
|
1366 |
+
* @since 1.2.24
|
1367 |
+
* @returns void
|
1368 |
+
*/
|
1369 |
+
function createDropdowns() {
|
1370 |
+
|
1371 |
+
$( ".wpsl-dropdown" ).each( function( index ) {
|
1372 |
+
var active, maxHeight, $this = $( this );
|
1373 |
+
|
1374 |
+
$this.$dropdownWrap = $this.wrap( "<div class='wpsl-dropdown'></div>" ).parent();
|
1375 |
+
$this.$selectedVal = $this.val();
|
1376 |
+
$this.$dropdownElem = $( "<div><ul/></div>" ).appendTo( $this.$dropdownWrap );
|
1377 |
+
$this.$dropdown = $this.$dropdownElem.find( "ul" );
|
1378 |
+
$this.$options = $this.$dropdownWrap.find( "option" );
|
1379 |
+
|
1380 |
+
/* Hide the original <select> and remove the css class */
|
1381 |
+
$this.hide().removeClass( "wpsl-dropdown" );
|
1382 |
+
|
1383 |
+
/* Loop over the options from the <select> and move them to a <li> instead */
|
1384 |
+
$.each( $this.$options, function() {
|
1385 |
+
if ( $( this ).val() == $this.$selectedVal ) {
|
1386 |
+
active = 'class="wpsl-selected-dropdown"';
|
1387 |
+
} else {
|
1388 |
+
active = '';
|
1389 |
+
}
|
1390 |
+
|
1391 |
+
$this.$dropdown.append( "<li " + active + ">" + $( this ).text() + "</li>" );
|
1392 |
+
});
|
1393 |
+
|
1394 |
+
$this.$dropdownElem.before( "<span class='wpsl-selected-item'>" + $this.find( ":selected" ).text() + "</span>" );
|
1395 |
+
$this.$dropdownItem = $this.$dropdownElem.find( "li" );
|
1396 |
+
|
1397 |
+
/* Listen for clicks on the 'wpsl-dropdown' div */
|
1398 |
+
$this.$dropdownWrap.on( "click", function( e ) {
|
1399 |
+
closeDropdowns();
|
1400 |
+
|
1401 |
+
$( this ).toggleClass( "wpsl-active" );
|
1402 |
+
maxHeight = 0;
|
1403 |
+
|
1404 |
+
/* Either calculate the correct height for the <ul> or set it to 0 to hide it */
|
1405 |
+
if ( $( this ).hasClass( "wpsl-active" ) ) {
|
1406 |
+
$this.$dropdownItem.each( function( index ) {
|
1407 |
+
maxHeight += $( this ).outerHeight();
|
1408 |
+
});
|
1409 |
+
|
1410 |
+
$this.$dropdownElem.css( "height", maxHeight + 2 + "px" );
|
1411 |
+
} else {
|
1412 |
+
$this.$dropdownElem.css( "height", 0 );
|
1413 |
+
}
|
1414 |
+
|
1415 |
+
e.stopPropagation();
|
1416 |
+
});
|
1417 |
+
|
1418 |
+
/* Listen for clicks on the individual dropdown items */
|
1419 |
+
$this.$dropdownItem.on( "click", function( e ) {
|
1420 |
+
|
1421 |
+
/* Set the correct value as the selected item */
|
1422 |
+
$this.$dropdownWrap.find( $( ".wpsl-selected-item" ) ).html( $( this ).text() );
|
1423 |
+
|
1424 |
+
/* Apply the class to the correct item to make it bold */
|
1425 |
+
$this.$dropdownItem.removeClass( "wpsl-selected-dropdown" );
|
1426 |
+
$( this ).addClass( "wpsl-selected-dropdown" );
|
1427 |
+
|
1428 |
+
closeDropdowns();
|
1429 |
+
|
1430 |
+
e.stopPropagation();
|
1431 |
+
});
|
1432 |
+
});
|
1433 |
+
|
1434 |
+
$( document ).click( function() {
|
1435 |
+
closeDropdowns();
|
1436 |
+
});
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
/**
|
1440 |
+
* Close all the dropdowns
|
1441 |
+
*
|
1442 |
+
* @since 1.2.24
|
1443 |
+
* @returns void
|
1444 |
+
*/
|
1445 |
+
function closeDropdowns() {
|
1446 |
+
$( ".wpsl-dropdown" ).removeClass( "wpsl-active" );
|
1447 |
+
$( ".wpsl-dropdown div" ).css( "height", 0 );
|
1448 |
+
}
|
1449 |
+
|
1450 |
if ( $( "#wpsl-gmap" ).length ) {
|
1451 |
google.maps.event.addDomListener( window, "load", initializeGmap );
|
1452 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: tijmensmit
|
|
3 |
Tags: google maps, store locator, business locations, geocoding, stores, geo
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 4.1
|
6 |
-
Stable tag: 1.2.
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl.html
|
9 |
|
@@ -78,6 +78,14 @@ If you find a plugin or theme that causes a conflict, please report it on the [s
|
|
78 |
|
79 |
== Changelog ==
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
= 1.2.23 =
|
82 |
* Fixed the geocoding request for the map preview on the add/edit page not including the zipcode when it's present, which can misplace the marker
|
83 |
|
3 |
Tags: google maps, store locator, business locations, geocoding, stores, geo
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 4.1
|
6 |
+
Stable tag: 1.2.24
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl.html
|
9 |
|
78 |
|
79 |
== Changelog ==
|
80 |
|
81 |
+
= 1.2.24 =
|
82 |
+
* Fixed: Clicking the marker would no longer open the info window after a Google Maps API update. This only happened if street view was enabled.
|
83 |
+
* Fixed: A fatal error on some installations caused by the usage of mysql_real_escape_string, it is replaced with esc_sql.
|
84 |
+
* Fixed: A problem where some themes would just show "1" instead of the shortcode output.
|
85 |
+
* Fixed: The "dismiss" link not working in the notice that reminds users to define a start point.
|
86 |
+
* Fixed: A missing html tag that broken the store listing in IE7/8.
|
87 |
+
* Changed: Replaced the non-GPL compatible dropdown script.
|
88 |
+
|
89 |
= 1.2.23 =
|
90 |
* Fixed the geocoding request for the map preview on the add/edit page not including the zipcode when it's present, which can misplace the marker
|
91 |
|
wp-store-locator.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI:
|
|
5 |
Description: An easy to use location management system that enables users to search for nearby physical stores
|
6 |
Author: Tijmen Smit
|
7 |
Author URI: http://tijmensmit.com/
|
8 |
-
Version: 1.2.
|
9 |
Text Domain: wpsl
|
10 |
Domain Path: /languages/
|
11 |
License: GPLv3
|
@@ -83,7 +83,7 @@ if ( !class_exists( 'WP_Store_locator' ) ) {
|
|
83 |
public function define_constants() {
|
84 |
|
85 |
if ( !defined( 'WPSL_VERSION_NUM' ) )
|
86 |
-
define( 'WPSL_VERSION_NUM', '1.2.
|
87 |
|
88 |
if ( !defined( 'WPSL_URL' ) )
|
89 |
define( 'WPSL_URL', plugin_dir_url( __FILE__ ) );
|
5 |
Description: An easy to use location management system that enables users to search for nearby physical stores
|
6 |
Author: Tijmen Smit
|
7 |
Author URI: http://tijmensmit.com/
|
8 |
+
Version: 1.2.24
|
9 |
Text Domain: wpsl
|
10 |
Domain Path: /languages/
|
11 |
License: GPLv3
|
83 |
public function define_constants() {
|
84 |
|
85 |
if ( !defined( 'WPSL_VERSION_NUM' ) )
|
86 |
+
define( 'WPSL_VERSION_NUM', '1.2.24' );
|
87 |
|
88 |
if ( !defined( 'WPSL_URL' ) )
|
89 |
define( 'WPSL_URL', plugin_dir_url( __FILE__ ) );
|