{#
This file is part of EC-CUBE
Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
http://www.ec-cube.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}
{% set body_class = 'product_page' %}
{% block stylesheet %}
<style>
.slick-slider {
margin-bottom: 30px;
}
.slick-dots {
position: absolute;
bottom: -45px;
display: block;
width: 100%;
padding: 0;
list-style: none;
text-align: center;
}
.slick-dots li {
position: relative;
display: inline-block;
width: 20px;
height: 20px;
margin: 0 5px;
padding: 0;
cursor: pointer;
}
.slick-dots li button {
font-size: 0;
line-height: 0;
display: block;
width: 20px;
height: 20px;
padding: 5px;
cursor: pointer;
color: transparent;
border: 0;
outline: none;
background: transparent;
}
.slick-dots li button:hover,
.slick-dots li button:focus {
outline: none;
}
.slick-dots li button:hover:before,
.slick-dots li button:focus:before {
opacity: 1;
}
.slick-dots li button:before {
content: " ";
line-height: 20px;
position: absolute;
top: 0;
left: 0;
width: 12px;
height: 12px;
text-align: center;
opacity: .25;
background-color: black;
border-radius: 50%;
}
.slick-dots li.slick-active button:before {
opacity: .75;
background-color: black;
}
.slick-dots li button.thumbnail img {
width: 0;
height: 0;
}
</style>
{% endblock %}
{% block javascript %}
<script>
eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
// 規格2に選択肢を割り当てる。
function fnSetClassCategories(form, classcat_id2_selected) {
var $form = $(form);
var product_id = $form.find('input[name=product_id]').val();
var $sele1 = $form.find('select[name=classcategory_id1]');
var $sele2 = $form.find('select[name=classcategory_id2]');
eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
}
{% if form.classcategory_id2 is defined %}
fnSetClassCategories(
$('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
);
{% elseif form.classcategory_id1 is defined %}
eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
{% endif %}
</script>
<script>
$(function() {
// bfcache無効化
$(window).bind('pageshow', function(event) {
if (event.originalEvent.persisted) {
location.reload(true);
}
});
// Core Web Vital の Cumulative Layout Shift(CLS)対策のため
// img タグに width, height が付与されている.
// 630px 未満の画面サイズでは縦横比が壊れるための対策
// see https://github.com/EC-CUBE/ec-cube/pull/5023
// $('.ec-grid2__cell').hide();
var removeSize = function () {
$('.slide-item').height('');
$('.slide-item img')
.removeAttr('width')
.removeAttr('height')
.removeAttr('style');
};
var slickInitial = function(slick) {
$('.ec-grid2__cell').fadeIn(1500);
var baseHeight = $(slick.target).height();
var baseWidth = $(slick.target).width();
var rate = baseWidth / baseHeight;
$('.slide-item').height(baseHeight * rate); // 余白を削除する
// transform を使用することでCLSの影響を受けないようにする
$('.slide-item img')
.css(
{
'transform-origin': 'top left',
'transform': 'scaleY(' + rate + ')',
'transition': 'transform .1s'
}
);
// 正しいサイズに近くなったら属性を解除する
setTimeout(removeSize, 500);
};
$('.item_visual').on('init', slickInitial);
// リサイズ時は CLS の影響を受けないため属性を解除する
$(window).resize(removeSize);
$('.item_visual').slick({
dots: false,
arrows: false,
responsive: [{
breakpoint: 768,
settings: {
dots: true
}
}]
});
$('.slideThumb').on('click', function() {
var index = $(this).attr('data-index');
$('.item_visual').slick('slickGoTo', index, false);
})
});
</script>
<script>
$(function() {
$('.add-cart').on('click', function(event) {
{% if form.classcategory_id1 is defined %}
// 規格1フォームの必須チェック
if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
$('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
return true;
} else {
$('#classcategory_id1')[0].setCustomValidity('');
}
{% endif %}
{% if form.classcategory_id2 is defined %}
// 規格2フォームの必須チェック
if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
$('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
return true;
} else {
$('#classcategory_id2')[0].setCustomValidity('');
}
{% endif %}
// 個数フォームのチェック
if ($('#quantity').val() < 1) {
$('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
return true;
} else {
$('#quantity')[0].setCustomValidity('');
}
event.preventDefault();
$form = $('#form1');
$.ajax({
url: $form.attr('action'),
type: $form.attr('method'),
data: $form.serialize(),
dataType: 'json',
beforeSend: function(xhr, settings) {
// Buttonを無効にする
$('.add-cart').prop('disabled', true);
}
}).done(function(data) {
// レスポンス内のメッセージをalertで表示
$.each(data.messages, function() {
$('#ec-modal-header').text(this);
});
$('.ec-modal').show()
// カートブロックを更新する
$.ajax({
url: "{{ url('block_cart') }}",
type: 'GET',
dataType: 'html'
}).done(function(html) {
$('.ec-headerRole__cart').html(html);
});
}).fail(function(data) {
alert('{{ 'カートへの追加に失敗しました。'|trans }}');
}).always(function(data) {
// Buttonを有効にする
$('.add-cart').prop('disabled', false);
});
});
});
$('.ec-modal-wrap').on('click', function(e) {
// モーダル内の処理は外側にバブリングさせない
e.stopPropagation();
});
$('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
$('.ec-modal').hide()
});
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "{{ Product.name }}",
"image": [
{% for img in Product.ProductImage %}
"{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
{% else %}
"{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
{% endfor %}
],
"description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
{% if Product.code_min %}
"sku": "{{ Product.code_min }}",
{% endif %}
"offers": {
"@type": "Offer",
"url": "{{ url('product_detail', {'id': Product.id}) }}",
"priceCurrency": "{{ eccube_config.currency }}",
"price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
"availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
}
}
</script>
{% endblock %}
{% block main %}
<div class="ec-productRole">
<div class="ec-grid2">
<div class="ec-grid2__cell">
{# <div class="product-image">#}
{# <div class="uchiwa_img_wrapper" style="width:50%;margin: 20px">#}
{# <canvas id="uchiwaCanvas" class="img_canvas" height="512" width="512"></canvas>#}
{# </div>#}
{# </div>#}
<div class="ec-sliderItemRole">
<div class="item_visual">
{% for ProductImage in Product.ProductImage %}
<div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550"{% if loop.index > 1 %} loading="lazy"{% endif %}></div>
{% else %}
<div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550"></div>
{% endfor %}
</div>
<div class="item_nav">
{% for ProductImage in Product.ProductImage %}
<div class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}" alt="" width="133" height="133" loading="lazy"></div>
{% endfor %}
</div>
</div>
</div>
<div class="ec-grid2__cell">
<div class="ec-productRole__profile">
{# 商品名 #}
<div class="ec-productRole__title">
<h2 class="ec-headingTitle">{{ Product.name }}</h2>
</div>
{# <div style="width: 50%;margin: 20px;display:none;">#}
{# <input type="text" id="uchiwa_up_text" name="uchiwa_up_text" value="未来"/><br/>#}
{# <input type="text" id="uchiwa_main_text" name="uchiwa_main_text" value="看"#}
{# style="width:100%;"/><br>#}
{# <input type="text" id="uchiwa_low_text" name="uchiwa_lo_text" value="板"/><br/>#}
{# <button id="uchiwa_set" type="button">再作画</button>#}
{# <br/>#}
{# 一番外側の色:#}
{# <select id="uchiwa_back_color1" name="back_color1">#}
{# </select>#}
{# <br/>#}
{# フチの外枠:#}
{# <select id="uchiwa_back_color2" name="back_color2">#}
{# </select>#}
{# <br/>#}
{# フチの中:#}
{# <select id="uchiwa_back_color3" name="back_color3">#}
{# </select>#}
{# <br/>#}
{# 文字の色:#}
{# <select id="uchiwa_back_color4" name="back_color4">#}
{# </select>#}
{# <br/>#}
{# </div>#}
{# タグ #}
<ul class="ec-productRole__tags">
{% for Tag in Product.Tags %}
<li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
{% endfor %}
</ul>
{# 通常価格 #}
{% if Product.hasProductClass -%}
<div class="ec-productRole__priceRegular">
{% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
<span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span
class="price01-default">{{ Product.getPrice01IncTaxMin|price }}</span></span>
<span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
{% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
<span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span
class="price01-default">{{ Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }}</span></span>
<span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
{% endif %}
</div>
{% else %}
{% if Product.getPrice01Max is not null %}
<span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:{{ Product.getPrice01IncTaxMin|price }}</span>
<span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
{% endif %}
{% endif %}
{# 販売価格 #}
<div class="ec-productRole__price">
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
<div class="ec-price">
<span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="ec-price__tax">{{ '税込'|trans }}</span>
</div>
{% else %}
<div class="ec-price">
<span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
<span class="ec-price__tax">{{ '税込'|trans }}</span>
</div>
{% endif %}
{% else %}
<div class="ec-price">
<span class="ec-price__price">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="ec-price__tax">{{ '税込'|trans }}</span>
</div>
{% endif %}
</div>
{# 商品コード #}
{% if Product.code_min is not empty %}
<div class="ec-productRole__code">
{{ '商品コード'|trans }}: <span
class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
</div>
{% endif %}
{# 関連カテゴリ #}
{% if Product.ProductCategories is not empty %}
<div class="ec-productRole__category">
<div>{{ '関連カテゴリ'|trans }}</div>
{% for ProductCategory in Product.ProductCategories %}
<ul>
<li>
{% for Category in ProductCategory.Category.path %}
<a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
<span>></span>{% endif -%}
{% endfor %}
</li>
</ul>
{% endfor %}
</div>
{% endif %}
<form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
{% if Product.stock_find %}
<div class="ec-productRole__actions">
{% if form.classcategory_id1 is defined %}
<div class="ec-select">
{{ form_row(form.classcategory_id1) }}
{{ form_errors(form.classcategory_id1) }}
</div>
{% if form.classcategory_id2 is defined %}
<div class="ec-select">
{{ form_row(form.classcategory_id2) }}
{{ form_errors(form.classcategory_id2) }}
</div>
{% endif %}
{% endif %}
{# <div class="ec-numberInput"><span>文字</span>#}
{# {{ form_widget(form.order_text1) }}#}
{# {{ form_errors(form.order_text1) }}#}
{# </div>#}
{# <div class="ec-numberInput"><span>上文字</span>#}
{# {{ form_widget(form.order_text1) }}#}
{# {{ form_errors(form.order_text1) }}#}
{# </div>#}
{# <div class="ec-numberInput"><span>文字</span>#}
{# {{ form_widget(form.order_text2) }}#}
{# {{ form_errors(form.order_text2) }}#}
{# </div>#}
{# <div class="ec-numberInput"><span>下文字</span>#}
{# {{ form_widget(form.order_text3) }}#}
{# {{ form_errors(form.order_text3) }}#}
{# </div>#}
{# <div class="ec-numberInput"><span>外枠の色</span>#}
{# {{ form_widget(form.order_color1) }}#}
{# {{ form_errors(form.order_color1) }}#}
{# </div>#}
{# <div class="ec-numberInput"><span>文字の色</span>#}
{# {{ form_widget(form.order_color2) }}#}
{# {{ form_errors(form.order_color2) }}#}
{# </div>#}
{# <div class="ec-numberInput"><span>書体</span>#}
{# {{ form_widget(form.order_font) }}#}
{# {{ form_errors(form.order_font) }}#}
{# </div>#}
{# <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>#}
{# {{ form_widget(form.quantity) }}#}
{# {{ form_errors(form.quantity) }}#}
{# </div>#}
</div>
{{ form_rest(form) }}
<div class="ec-productRole__btn">
<button type="submit" class="ec-blockBtn--action add-cart">
{{ 'カートに入れる'|trans }}
</button>
</div>
{% else %}
<div class="ec-productRole__btn">
<button type="button" class="ec-blockBtn--action" disabled="disabled">
{{ 'ただいま品切れ中です。'|trans }}
</button>
</div>
{% endif %}
</form>
<div class="ec-modal">
<div class="ec-modal-overlay">
<div class="ec-modal-wrap">
<span class="ec-modal-close"><span class="ec-icon"><img
src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
<div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
<div class="ec-modal-box">
<div class="ec-role">
<span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
<a href="{{ url('cart') }}"
class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
</div>
</div>
</div>
</div>
</div>
{% if BaseInfo.option_favorite_product %}
<form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
<div class="ec-productRole__btn">
{% if is_favorite == false %}
<button type="submit" id="favorite" class="ec-blockBtn--cancel">
{{ 'お気に入りに追加'|trans }}
</button>
{% else %}
<button type="submit" id="favorite" class="ec-blockBtn--cancel"
disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}
</button>
{% endif %}
</div>
</form>
{% endif %}
<div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
</div>
</div>
</div>
</div>
{% if Product.freearea %}
<div class="ec-productRole__description">
{{ include(template_from_string(Product.freearea)) }}
</div>
{% endif %}
</div>
<script>
// https://mirai-kanban.com/ecshop/html/user_data/assets/js/test2.html
const uchiwa_base_dir = 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/';
let uchiwa_pattern;
let uchiwaCtx;
let uchiwaSelected_index;
let uchiwaCanvasHeight = 512;
const uchiwa_gritter_file = ['red.png', 'pink.png', 'orange.png'];
const uchiwa_color_list = [
{
'name': '白',
'type': 'solid',
'code': '#ffffff',
},
{
'name': '黒',
'type': 'solid',
'code': '#000000',
},
{
'name': '赤',
'type': 'solid',
'code': '#ff0000',
},
{
'name': '緑',
'type': 'solid',
'code': '#00ff00',
},
{
'name': '青',
'type': 'solid',
'code': '#0000ff',
},
{
'name': 'メタル赤',
'type': 'glitter',
'code': '0',
},
{
'name': 'メタルピンク',
'type': 'glitter',
'code': '1',
},
{
'name': 'メタルオレンジ',
'type': 'glitter',
'code': '2',
},
];
function uchiwaSearchColorIndex(idx) {
let nowSelect = uchiwa_color_list[idx];
if (nowSelect.type === 'solid') {
return nowSelect.code;
} else if (nowSelect.type === 'glitter') {
return uchiwa_pattern[Number(nowSelect.code)];
}
return '#000000;'
}
function UchiwaInitSelector() {
const elements = [
'uchiwa_back_color1',
'uchiwa_back_color2',
'uchiwa_back_color3',
'uchiwa_back_color4',
];
uchiwaSelected_index = [7, 1, 0, 2]; // default select
elements.forEach(function (name, index) {
let elem = document.getElementById(name);
uchiwa_color_list.forEach(function (item, c_index) {
let addOption = document.createElement("option")
addOption.value = c_index.toString();
addOption.text = item.name;
elem.add(addOption);
})
elem.selectedIndex = uchiwaSelected_index[index];
})
}
async function UchiwaInitCanvas() {
// const c = document.getElementById('c');
uchiwaCtx = document.getElementById('uchiwaCanvas').getContext('2d');
await uchiwaSetPatterns(uchiwaCtx);
await uchiwaGetFont("M PLUS Rounded 1c");
uchiwaWriteCanvas();
}
async function uchiwaGetFont(fontName) {
const urlFamilyName = fontName.replace(/ /g, "+");
const googleApiUrl = `https://fonts.googleapis.com/css?family=${urlFamilyName}`;
const response = await fetch(googleApiUrl);
if (response.ok) {
// url()の中身のURLだけ抽出
const cssFontFace = await response.text();
const matchUrls = cssFontFace.match(/url\(.+?\)/g);
if (!matchUrls) throw new Error("フォントが見つかりませんでした");
for (const url of matchUrls) {
const font = new FontFace(fontName, url);
await font.load();
document.fonts.add(font);
}
} else {
console.log('error get font fetch', response);
}
}
function uchiwaChangeFont(uchiwaCtx, size, width, font_size = 400) {
if (size === 'large') {
uchiwaCtx.font = "normal normal 900 " + font_size + "px 'M PLUS Rounded 1c'";
} else {
uchiwaCtx.font = "normal normal 900 " + font_size + "px 'M PLUS Rounded 1c'";
}
uchiwaCtx.lineWidth = width;
}
function uchiwaDrawLargeText(uchiwaCtx, text, small_lo = '', small_up = '') {
const canvas_height = document.getElementById('uchiwaCanvas').height;
const main_scale_base = canvas_height / 512;
// base
const main_size = 400 * main_scale_base; // 400
const main_x = 50;
const main_y = main_scale_base * 410; // 410 // main_size + 5
const main_round_width = [100 * main_scale_base, 40 * main_scale_base, 30 * main_scale_base, 0];
const small_size = 60 * main_scale_base;
let small_width = 0;
let small_x = 50;
const small_y = 450 * main_scale_base;
const small_x_up = 30;
const small_y_up = main_scale_base * 100;
const small_round_width = [60 * main_scale_base, 20 * main_scale_base, 10 * main_scale_base, 0];
let main_scale = (512 / canvas_height) / countGrapheme(text); // 512 / canvas_height
console.log('main_size:', main_size);
console.log('main_y:', main_y);
uchiwaCtx.scale(main_scale, 1);
uchiwaChangeFont(uchiwaCtx, 'large', main_round_width[0], main_size);
uchiwaCtx.lineJoin = "round";
uchiwaCtx.miterLimit = "5";
// uchiwaCtx.strokeStyle = "#00ff00";
uchiwaCtx.strokeStyle = uchiwaSearchColorIndex(uchiwaSelected_index[0]);
uchiwaCtx.strokeText(text, main_x, main_y);
uchiwaCtx.setTransform(1, 0, 0, 1, 0, 0);
if (small_lo !== '') {
uchiwaChangeFont(uchiwaCtx, 'small', small_round_width[0], small_size);
// uchiwaCtx.strokeStyle = "#00ff00";
small_width = uchiwaCtx.measureText(small_lo);
small_x = 450 - small_width.width
uchiwaCtx.strokeText(small_lo, small_x, small_y);
}
if (small_up !== '') {
uchiwaChangeFont(uchiwaCtx, 'small', small_round_width[0], small_size);
// uchiwaCtx.strokeStyle = "#00ff00";
uchiwaCtx.strokeText(small_up, small_x_up, small_y_up);
}
// outer line
uchiwaCtx.scale(main_scale, 1);
// for( let i = 1; i <= 3; i++ ) {
// uchiwaChangeFont(uchiwaCtx, 'large', main_round_width[i], main_size);
// uchiwaCtx.strokeStyle = uchiwaSearchColorIndex(uchiwaSelected_index[i]);
// uchiwaCtx.strokeText(text, main_x, main_y);
// }
uchiwaChangeFont(uchiwaCtx, 'large', main_round_width[1], main_size);
uchiwaCtx.strokeStyle = uchiwaSearchColorIndex(uchiwaSelected_index[1]);
uchiwaCtx.strokeText(text, main_x, main_y);
// inner white
uchiwaChangeFont(uchiwaCtx, 'large', main_round_width[2], main_size);
uchiwaCtx.strokeStyle = uchiwaSearchColorIndex(uchiwaSelected_index[2]);
uchiwaCtx.strokeText(text, main_x, main_y);
// text
uchiwaChangeFont(uchiwaCtx, 'large', main_round_width[3], main_size);
uchiwaCtx.fillStyle = uchiwaSearchColorIndex(uchiwaSelected_index[3]);
uchiwaCtx.fillText(text, main_x, main_y);
uchiwaCtx.setTransform(1, 0, 0, 1, 0, 0);
if (small_lo !== '') {
uchiwaChangeFont(uchiwaCtx, 'small', small_round_width[1], small_size);
uchiwaCtx.strokeStyle = uchiwaSearchColorIndex(uchiwaSelected_index[1]);
uchiwaCtx.strokeText(small_lo, small_x, small_y);
uchiwaChangeFont(uchiwaCtx, 'small', small_round_width[2], small_size);
uchiwaCtx.strokeStyle = uchiwaSearchColorIndex(uchiwaSelected_index[2]);
uchiwaCtx.strokeText(small_lo, small_x, small_y);
uchiwaChangeFont(uchiwaCtx, 'small', small_round_width[3], small_size);
uchiwaCtx.fillStyle = uchiwaSearchColorIndex(uchiwaSelected_index[3]);
uchiwaCtx.fillText(small_lo, small_x, small_y);
}
if (small_up !== '') {
uchiwaChangeFont(uchiwaCtx, 'small', small_round_width[1], small_size);
uchiwaCtx.strokeStyle = uchiwaSearchColorIndex(uchiwaSelected_index[1]);
uchiwaCtx.strokeText(small_up, small_x_up, small_y_up);
uchiwaChangeFont(uchiwaCtx, 'small', small_round_width[2], small_size);
uchiwaCtx.strokeStyle = uchiwaSearchColorIndex(uchiwaSelected_index[2]);
uchiwaCtx.strokeText(small_up, small_x_up, small_y_up);
uchiwaChangeFont(uchiwaCtx, 'small', small_round_width[3], small_size);
uchiwaCtx.fillStyle = uchiwaSearchColorIndex(uchiwaSelected_index[3]);
uchiwaCtx.fillText(small_up, small_x_up, small_y_up);
}
}
function uchiwaLoadImages(list) {
async function load(src) {
const img = new Image()
img.src = uchiwa_base_dir + src
await img.decode()
return img
}
return Promise.all(list.map(src => load(src)))
}
async function uchiwaSetPatterns(uchiwaCtx) {
const images = await uchiwaLoadImages(uchiwa_gritter_file);
uchiwa_pattern = images.map(await function (img) {
return uchiwaCtx.createPattern(img, "repeat");
})
}
function uchiwaWriteCanvas() {
const c = document.getElementById('uchiwaCanvas');
// const element = document.getElementById('uchiwa_main_text');
const text = document.getElementById('uchiwa_main_text').value.toString();
const up_text = document.getElementById('uchiwa_up_text').value.toString();
const lo_text = document.getElementById('uchiwa_low_text').value.toString();
uchiwaCtx.setTransform(1, 0, 0, 1, 0, 0);
uchiwaCtx.clearRect(0, 0, c.width, c.height);
uchiwaCtx.fillStyle = "#cccccc";
uchiwaCtx.fillRect(0, 0, c.width, c.height);
if (text !== '') {
uchiwaDrawLargeText(uchiwaCtx, text, lo_text, up_text);
}
}
function countGrapheme(string) {
const segmenter = new Intl.Segmenter("ja", {granularity: "grapheme"});
return [...segmenter.segment(string)].length;
}
window.addEventListener("load", () => {
UchiwaInitSelector();
console.log("ページが完全に読み込まれました");
UchiwaInitCanvas();
const button = document.getElementById("uchiwa_set");
button.addEventListener("click", uchiwaWriteCanvas);
const base_select = document.getElementById('uchiwa_back_color1');
base_select.addEventListener("change", function () {
uchiwaSelected_index[0] = Number(base_select.value);
uchiwaWriteCanvas();
});
const base_select2 = document.getElementById('uchiwa_back_color2');
base_select2.addEventListener("change", function () {
uchiwaSelected_index[1] = Number(base_select2.value);
uchiwaWriteCanvas();
});
const base_select3 = document.getElementById('uchiwa_back_color3');
base_select3.addEventListener("change", function () {
uchiwaSelected_index[2] = Number(base_select3.value);
uchiwaWriteCanvas();
});
const base_select4 = document.getElementById('uchiwa_back_color4');
base_select4.addEventListener("change", function () {
uchiwaSelected_index[3] = Number(base_select4.value);
uchiwaWriteCanvas();
});
$('select[name=classcategory_id1]').on('change', function (data) {
let size_select = $(this).val();
const canvasElement = document.getElementById('uchiwaCanvas');
switch (Number(size_select)) {
case 7:
// uchiwaCtx.height = 512;
canvasElement.height = 512;
break;
case 8:
canvasElement.height = 256;
// uchiwaCtx.height = 256;
break;
case 9:
canvasElement.height = 170;
// uchiwaCtx.height = 170;
break;
}
uchiwaWriteCanvas();
})
});
</script>
{# <script>#}
{# const item_product_color_type1 = "{{ Product.product_color_type1 }}";#}
{# const item_product_color_type2 = "{{ Product.product_color_type2 }}";#}
{# const gritter_array = [#}
{# 'レッド','パステルピンク','オレンジ','パープル',#}
{# 'ブルー','アクアブルー','イエロー','パステルグリーン',#}
{# 'ブラック','ゴールド',#}
{# ];#}
{# const solid_array = [#}
{# '1:mono','2:mono','3:mono','4:mono',#}
{# '5:レッド','6:レッド','7:レッド',#}
{# '8:パープル','9:パープル','10:パープル','11:パープル',#}
{# '12:ピンク','13:ピンク','14:ピンク','15:ピンク',#}
{# '16:オレンジ','17:オレンジ','18:オレンジ',#}
{# '19:イエロー','20:イエロー',#}
{# '21:グリーン','22:グリーン','23:グリーン','24:グリーン',#}
{# '25:ブルー','26:ブルー','27:ブルー','28:ブルー','30:ブルー',#}
{# '31:エメラルド','32:エメラルド','33:エメラルド','34:エメラルド',#}
{# '35:ビビッド','36:ビビッド','37:ビビッド',#}
{# ]#}
{# let color1_array = gritter_array;#}
{# let color2_array = gritter_array;#}
{# if( item_product_color_type1 === 'ソリッド') {#}
{# color1_array = solid_array;#}
{# }#}
{# if( item_product_color_type2 === 'ソリッド') {#}
{# color2_array = solid_array;#}
{# }#}
{# $('form #order_color1').empty();#}
{# $('form #order_color2').empty();#}
{# color1_array.forEach( item => {#}
{# $('form #order_color1').append('<option value="' + item + '">' + item + '</option>');#}
{# })#}
{# color2_array.forEach( item => {#}
{# $('form #order_color2').append('<option value="' + item + '">' + item + '</option>');#}
{# })#}
{# </script>#}
<script>
const item_product_color_type1 = "{{ Product.product_color_type1 }}";
const item_product_color_type2 = "{{ Product.product_color_type2 }}";
const gritter_array = [
{ 'label': 'レッド', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'パステルピンク', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'オレンジ', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'パープル', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'ブルー', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'アクアブルー', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'イエロー', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'パステルグリーン', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'ブラック', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'ゴールド', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' },
{ 'label': 'シルバー', 'url': 'https://mirai-kanban.com/ecshop/html/user_data/assets/js/pink.png' }
];
const solid_array = [
{ 'label': '1:mono', 'color': '#FFFFFF' },
{ 'label': '2:mono', 'color': '#C9CACA' },
{ 'label': '3:mono', 'color': '#797A7A' },
{ 'label': '4:mono', 'color': '#231815' },
{ 'label': '5:レッド', 'color': '#C30D23' },
{ 'label': '6:レッド', 'color': '#E83828' },
{ 'label': '7:レッド', 'color': '#DC4F48' },
{ 'label': '8:パープル', 'color': '#A3127F' },
{ 'label': '9:パープル', 'color': '#C02D8B' },
{ 'label': '10:パープル', 'color': '#DE83B3' },
{ 'label': '11:パープル', 'color': '#B1A1CB' },
{ 'label': '12:ピンク', 'color': '#E4007F' },
{ 'label': '13:ピンク', 'color': '#E7397A' },
{ 'label': '14:ピンク', 'color': '#EB6BA4' },
{ 'label': '15:ピンク', 'color': '#F0A6C7' },
{ 'label': '16:オレンジ', 'color': '#EE761C' },
{ 'label': '17:オレンジ', 'color': '#F49E15' },
{ 'label': '18:オレンジ', 'color': '#F8B62D' },
{ 'label': '19:イエロー', 'color': '#F6E123' },
{ 'label': '20:イエロー', 'color': '#F0EB79' },
{ 'label': '21:グリーン', 'color': '#22AC38' },
{ 'label': '22:グリーン', 'color': '#8FC31F' },
{ 'label': '23:グリーン', 'color': '#B4D23E' },
{ 'label': '24:グリーン', 'color': '#E1D841' },
{ 'label': '25:ブルー', 'color': '#0067B6' },
{ 'label': '26:ブルー', 'color': '#00A0E9' },
{ 'label': '27:ブルー', 'color': '#43B9DF' },
{ 'label': '28:ブルー', 'color': '#8FD2ED' },
{ 'label': '29:ブルー', 'color': '#C1E5F1' },
{ 'label': '30:エメラルド', 'color': '#4CB787' },
{ 'label': '31:エメラルド', 'color': '#3DB79F' },
{ 'label': '32:エメラルド', 'color': '#7BC8B9' },
{ 'label': '33:エメラルド', 'color': '#9BD3CA' },
{ 'label': '34:ビビッドカラー', 'color': '#0091DB' },
{ 'label': '35:ビビッドカラー', 'color': '#FFF100' },
{ 'label': '36:ビビッドカラー', 'color': '#E61673' }
];
let color1_array = gritter_array;
let color2_array = gritter_array;
if( item_product_color_type1 === 'ソリッド') {
color1_array = solid_array;
}
if( item_product_color_type2 === 'ソリッド') {
color2_array = solid_array;
}
$('form #order_color1').empty();
$('form #order_color2').empty();
color1_array.forEach( item => {
$('form #order_color1').append('<option value="' + item.color + '">' + item.label + '</option>');
})
color2_array.forEach( item => {
$('form #order_color2').append('<option value="' + item.color + '">' + item.label + '</option>');
})
</script>
{% endblock %}