Skip to content

Commit

Permalink
added js to select styles
Browse files Browse the repository at this point in the history
  • Loading branch information
miya0001 committed Jul 7, 2024
1 parent 5b7eaf1 commit 95d4323
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 11 deletions.
3 changes: 2 additions & 1 deletion css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
{
width: 30%;
max-width: 256px;
border: 1px solid #0a4b78;;
border: 2px solid #8c8f94;
text-align: center;
position: relative;
margin: 0;
Expand All @@ -194,6 +194,7 @@
#geolonia-style-data-list li.active
{
opacity: 1;
border-color: #2271b1;
}

#geolonia-style-data-list li img
Expand Down
14 changes: 10 additions & 4 deletions geolonia-open-gis.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,16 @@ function() {
'geolonia-gis-meta-style',
__( 'Style', 'geolonia-open-gis' ),
function() {
$style = GEOLONIA_GIS_DEFAULT_STYLE;
$current_style = GEOLONIA_GIS_DEFAULT_STYLE;

if ( get_post_meta( get_the_ID(), '_geolonia-gis-style', true ) ) {
$style = get_post_meta( get_the_ID(), '_geolonia-gis-style', true );
$current_style = get_post_meta( get_the_ID(), '_geolonia-gis-style', true );
}

wp_nonce_field( 'geolonia-gis-nonce-style', 'geolonia-gis-nonce-style' );
?>
<div class="select-geolonia-styles">
<input id="geolonia-gis-style" name="geolonia-gis-style" list="styles" class="geolonia-meta" value="<?php echo esc_attr($style) ?>" autocomplete="off" />
<input id="geolonia-gis-style" name="geolonia-gis-style" list="styles" class="geolonia-meta" value="<?php echo esc_url($current_style) ?>" autocomplete="off" />
<ul id="geolonia-style-data-list">
<?php
$default_styles = apply_filters( 'geolonia-open-gis-styles', array(
Expand All @@ -279,8 +279,14 @@ function() {
),
) );



foreach ( $default_styles as $style ) {
echo '<li data-url="' . esc_url( $style['url'] ) . '"><img src="' . esc_url( $style['image'] ) . '"><div class="style-name">' . esc_html( $style['name'] ) . '</div></li>';
if ($current_style === $style['url']) {
echo '<li class="active" data-url="' . esc_url( $style['url'] ) . '"><img src="' . esc_url( $style['image'] ) . '"><div class="style-name">' . esc_html( $style['name'] ) . '</div></li>';
} else {
echo '<li data-url="' . esc_url( $style['url'] ) . '"><img src="' . esc_url( $style['image'] ) . '"><div class="style-name">' . esc_html( $style['name'] ) . '</div></li>';
}
}
?>
</ul>
Expand Down
9 changes: 8 additions & 1 deletion js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,21 @@ if (document.getElementById('geolonia-gis-editor-container')) {

document.querySelectorAll('#geolonia-style-data-list li').forEach((li) => {
li.addEventListener('click', (e) => {
document.querySelectorAll('#geolonia-style-data-list li').forEach((li) => {
li.classList.remove('active')
})
e.currentTarget.classList.add('active')

const styleUrl = e.currentTarget.dataset.url
document.getElementById('geolonia-gis-style').value = styleUrl
map.setStyle(styleUrl)
})
li.addEventListener('mouseover', (e) => {
e.currentTarget.classList.add('hover')
})
li.addEventListener('mouseleave', (e) => {
document.querySelectorAll('#geolonia-style-data-list li').forEach((li) => {
li.classList.remove('hover')
e.currentTarget.classList.add('hover')
})
})
})
Expand Down
Binary file modified languages/geolonia-open-gis-ja.mo
Binary file not shown.
21 changes: 18 additions & 3 deletions languages/geolonia-open-gis-ja.po
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Copyright (C) 2024 Geolonia Inc.
# This file is distributed under the same license as the Geolonia Open GIS plugin.
msgid ""
msgstr ""
"Project-Id-Version: Geolonia Open GIS 0.1.0\n"
Expand All @@ -11,6 +9,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-06-29T16:10:36+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Language: \n"
"X-Generator: WP-CLI 2.9.0\n"
"X-Domain: geolonia-open-gis\n"

Expand Down Expand Up @@ -55,6 +54,22 @@ msgstr "現在のズームレベルを使用する"
msgid "Style"
msgstr "スタイル"

#: geolonia-open-gis.php:368
#: geolonia-open-gis.php:395
msgid "Number of features: <span id=\"num-of-features\"></span>"
msgstr "地物の数: <span id=\"num-of-features\"></span>"

#: geolonia-open-gis.php:266
msgid "Standard"
msgstr "標準"

#: geolonia-open-gis.php:271
msgid "GSI"
msgstr "地理院地図"

#: geolonia-open-gis.php:276
msgid "Blank Map"
msgstr "白地図"

#: inc/functions.php:10
msgid "Map"
msgstr "地図"
20 changes: 18 additions & 2 deletions languages/geolonia-open-gis.pot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-06-29T16:13:37+00:00\n"
"POT-Creation-Date: 2024-07-07T05:50:45+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.9.0\n"
"X-Domain: geolonia-open-gis\n"
Expand Down Expand Up @@ -55,6 +55,22 @@ msgstr ""
msgid "Style"
msgstr ""

#: geolonia-open-gis.php:368
#: geolonia-open-gis.php:266
msgid "Standard"
msgstr ""

#: geolonia-open-gis.php:271
msgid "GSI"
msgstr ""

#: geolonia-open-gis.php:276
msgid "Blank Map"
msgstr ""

#: geolonia-open-gis.php:395
msgid "Number of features: <span id=\"num-of-features\"></span>"
msgstr ""

#: inc/functions.php:10
msgid "Map"
msgstr ""

0 comments on commit 95d4323

Please sign in to comment.