Issues (2687)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

html/template/default/js/function.js (44 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
$(function () {
2
3
    /////////// Drawer menu
4
5
    $('.nav-trigger').on('click', function (event) {
6
        event.preventDefault();
7
        if ($('.drawer-open #drawer').size() == 0) {
0 ignored issues
show
It is recommended to use === to compare with 0.

Generally, it is recommended to use strict comparison whenever possible and not to rely on the weaker type-juggling comparison operator.

Read more about comparison operations.

Loading history...
8
            $('.overlay').addClass('is-visible');
9
            $('#wrapper').addClass('drawer-open');
10
        } else {
11
            $('#wrapper').removeClass('drawer-open');
12
            $('.overlay').removeClass('is-visible');
13
            toggleCart('close')
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
14
        }
15
        return false;
16
    });
17
18
    //open cart form
19
    $('.cart-trigger').on('click', function (event) {
20
        event.preventDefault();
21
        toggleCart();
22
        $('#wrapper').removeClass('drawer-open');
23
24
    });
25
26
    //close lateral menu on mobile
27
    $('.overlay').on('swiperight', function () {
28
        if ($('#wrapper').hasClass('drawer-open')) {
29
            $('#wrapper').removeClass('drawer-open');
30
            $('.overlay').removeClass('is-visible');
31
        }
32
    });
33
    $('.overlay').on('click', function () {
34
        $('#wrapper').removeClass('drawer-open');
35
        toggleCart('close')
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
36
        $('.overlay').removeClass('is-visible');
37
    });
38
39
    function toggleCart(type) {
40
        if (type == "close") {
41
            //close cart
42
            $('.cart').removeClass('is-visible');
43
            $('.cart-trigger').removeClass('cart-is-visible');
44
            $('.overlay').removeClass('cart-is-visible');
45
        } else {
46
            //toggle cart visibility
47
            $('.cart').toggleClass('is-visible');
48
            $('.cart-trigger').toggleClass('cart-is-visible');
49
            $('.overlay').toggleClass('cart-is-visible');
50
            ($('.cart').hasClass('is-visible')) ? $('.overlay').addClass('is-visible') : $('.overlay').removeClass('is-visible');
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
51
        }
52
    }
53
54
55
    /////////// category accordion
56
    $("#category li .toggle").on('click', function () {
57
        var togglepanel = $(this).parent('a').next('ul');
58
        if (togglepanel.css("display") == "none") {
59
            $(this).parent('a').addClass("active");
60
            togglepanel.slideDown(300);
61
        } else {
62
            $(this).parent('a').removeClass("active");
63
            togglepanel.slideUp(300);
64
        }
65
        return false;
66
    });
67
68
    /////////// アコーディオン
69
    $(".accordion dl dt").on('click', function () {
70
        if ($(this).parent('dl').children('dd').css('display') == 'none') {
71
            $(this).addClass('active');
72
            $(this).parent('dl').children('dd').slideDown(300);
73
        } else {
74
            $(this).removeClass('active');
75
            $(this).parent('dl').children('dd').slideUp(300);
76
        }
77
        return false;
78
    });
79
80
    /////////// スムーススクロール
81
    $('a.anchor').on('click', function () {
82
        var speed = 400;//スクロール速度 単位:ミリ秒
83
        var href = $(this).attr("href");
84
        var destination = $(href == "#" || href == "" ? 'html' : href);
0 ignored issues
show
It is recommended to use === to compare with .

Generally, it is recommended to use strict comparison whenever possible and not to rely on the weaker type-juggling comparison operator.

Read more about comparison operations.

Loading history...
85
        var position = destination.offset().top;
86
        $("html,body").animate({scrollTop: position}, speed, 'swing');
87
        return false;
88
    });
89
90
    /////////// dropdownの中をクリックしても閉じないようにする
91
    $(".dropdown-menu").click(function (e) {
92
        e.stopPropagation();
93
    });
94
95
    /////////// 追従サイドバー + ページトップフェードイン
96
97
    // スクロールした時に以下の処理
98
    $(window).on("scroll", function () {
99
        // ページトップフェードイン
100
        if ($(this).scrollTop() > 300) {
101
            $('.pagetop').fadeIn();
102
        } else {
103
            $('.pagetop').fadeOut();
104
        }
105
106
        //PC表示の時のみに適用
107
        if (window.innerWidth > 767) {
108
109
            if ($('#shopping_confirm').length) {
110
111
                var side = $("#confirm_side"),
112
                    wrap = $("#shopping_confirm"),
113
                    min_move = wrap.offset().top,
114
                    max_move = min_move + wrap.height() - side.height() - 2 * parseInt(side.css("top")),
115
                    margin_bottom = max_move - min_move;
116
117
                var scrollTop = $(window).scrollTop();
118
                if (scrollTop > min_move && scrollTop < max_move) {
119
                    var margin_top = scrollTop - min_move;
120
                    side.css({"margin-top": margin_top});
121
                } else if (scrollTop < min_move) {
122
                    side.css({"margin-top": 0});
123
                } else if (scrollTop > max_move) {
124
                    side.css({"margin-top": margin_bottom});
125
                }
126
127
            }
128
        }
129
        return false;
130
    });
131
132
    // マスク処理
133
    $('.prevention-mask').on('click', function() {
134
        $overlay = $('<div class="prevention-masked">');
135
        $('body').append($overlay);
136
    });
137
138
    // ダブルクリック禁止
139
    $('.prevention-btn').on('click', function() {
140
        $(this).attr('disabled', 'disabled');
141
        var $form = $(this).parents('form');
142
        // マスク表示させるためsetTimeoutを使って処理を遅らせる
143
        setTimeout(function(){
144
            $form.submit();
145
        }, 0);
146
        return false;
147
    });
148
149
});
150
151
152
/////////// ロールオーバー
153
$.fn.rollover = function () {
154
    return this.each(function () {
155
        var src = $(this).attr('src');
156
        if (src.match('_on.')) return;
157
        var src_on = src.replace(/^(.+)(\.[a-z]+)$/, "$1_on$2");
158
        $('').attr('src', src_on);
159
        $(this).hover(
160
            function () {
161
                $(this).attr('src', src_on);
162
            },
163
            function () {
164
                $(this).attr('src', src);
165
            }
166
        );
167
    });
168
};
169
170
// 画像をロールオーバーする箇所(imgタグ)を指定
171
$(function () {
172
    $('.rollover').rollover();
173
});
174
175
176
/////////// 高さ揃え
177
/**
178
 * jquery.matchHeight-min.js v0.6.0
179
 * http://brm.io/jquery-match-height/
180
 * License: MIT
181
 */
182
(function (c) {
183
    var n = -1, f = -1, g = function (a) {
184
        return parseFloat(a) || 0
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
185
    }, r = function (a) {
186
        var b = null, d = [];
187
        c(a).each(function () {
188
            var a = c(this), k = a.offset().top - g(a.css("margin-top")), l = 0 < d.length ? d[d.length - 1] : null;
189
            null === l ? d.push(a) : 1 >= Math.floor(Math.abs(b - k)) ? d[d.length - 1] = l.add(a) : d.push(a);
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
190
            b = k
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
191
        });
192
        return d
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
193
    }, p = function (a) {
194
        var b = {byRow: !0, property: "height", target: null, remove: !1};
195
        if ("object" === typeof a)return c.extend(b, a);
196
        "boolean" === typeof a ? b.byRow = a : "remove" === a && (b.remove = !0);
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
197
        return b
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
198
    }, b = c.fn.matchHeight =
199
        function (a) {
200
            a = p(a);
201
            if (a.remove) {
202
                var e = this;
203
                this.css(a.property, "");
204
                c.each(b._groups, function (a, b) {
205
                    b.elements = b.elements.not(e)
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
206
                });
207
                return this
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
208
            }
209
            if (1 >= this.length && !a.target)return this;
210
            b._groups.push({elements: this, options: a});
211
            b._apply(this, a);
212
            return this
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
213
        };
214
    b._groups = [];
215
    b._throttle = 80;
216
    b._maintainScroll = !1;
217
    b._beforeUpdate = null;
218
    b._afterUpdate = null;
219
    b._apply = function (a, e) {
220
        var d = p(e), h = c(a), k = [h], l = c(window).scrollTop(), f = c("html").outerHeight(!0), m = h.parents().filter(":hidden");
221
        m.each(function () {
222
            var a = c(this);
223
            a.data("style-cache", a.attr("style"))
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
224
        });
225
        m.css("display", "block");
226
        d.byRow && !d.target && (h.each(function () {
227
            var a = c(this), b = "inline-block" === a.css("display") ? "inline-block" : "block";
228
            a.data("style-cache", a.attr("style"));
229
            a.css({
230
                display: b,
231
                "padding-top": "0",
232
                "padding-bottom": "0",
233
                "margin-top": "0",
234
                "margin-bottom": "0",
235
                "border-top-width": "0",
236
                "border-bottom-width": "0",
237
                height: "100px"
238
            })
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
239
        }), k = r(h), h.each(function () {
240
            var a = c(this);
241
            a.attr("style", a.data("style-cache") || "")
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
242
        }));
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
243
        c.each(k, function (a, b) {
244
            var e = c(b), f = 0;
245
            if (d.target)f =
246
                d.target.outerHeight(!1); else {
247
                if (d.byRow && 1 >= e.length) {
248
                    e.css(d.property, "");
249
                    return
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
250
                }
251
                e.each(function () {
252
                    var a = c(this), b = {display: "inline-block" === a.css("display") ? "inline-block" : "block"};
253
                    b[d.property] = "";
254
                    a.css(b);
255
                    a.outerHeight(!1) > f && (f = a.outerHeight(!1));
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
256
                    a.css("display", "")
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
257
                })
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
258
            }
259
            e.each(function () {
260
                var a = c(this), b = 0;
261
                d.target && a.is(d.target) || ("border-box" !== a.css("box-sizing") && (b += g(a.css("border-top-width")) + g(a.css("border-bottom-width")), b += g(a.css("padding-top")) + g(a.css("padding-bottom"))), a.css(d.property,
262
                    f - b))
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
263
            })
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
264
        });
265
        m.each(function () {
266
            var a = c(this);
267
            a.attr("style", a.data("style-cache") || null)
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
268
        });
269
        b._maintainScroll && c(window).scrollTop(l / f * c("html").outerHeight(!0));
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
270
        return this
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
271
    };
272
    b._applyDataApi = function () {
273
        var a = {};
274
        c("[data-match-height], [data-mh]").each(function () {
275
            var b = c(this), d = b.attr("data-mh") || b.attr("data-match-height");
276
            a[d] = d in a ? a[d].add(b) : b
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
277
        });
278
        c.each(a, function () {
279
            this.matchHeight(!0)
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
280
        })
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
281
    };
282
    var q = function (a) {
283
        b._beforeUpdate && b._beforeUpdate(a, b._groups);
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
284
        c.each(b._groups, function () {
285
            b._apply(this.elements,
286
                this.options)
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
287
        });
288
        b._afterUpdate && b._afterUpdate(a, b._groups)
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
289
    };
290
    b._update = function (a, e) {
291
        if (e && "resize" === e.type) {
292
            var d = c(window).width();
293
            if (d === n)return;
294
            n = d
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
295
        }
296
        a ? -1 === f && (f = setTimeout(function () {
297
            q(e);
298
            f = -1
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
299
        }, b._throttle)) : q(e)
0 ignored issues
show
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
300
    };
301
    c(b._applyDataApi);
302
    c(window).bind("load", function (a) {
303
        b._update(!1, a)
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
304
    });
305
    c(window).bind("resize orientationchange", function (a) {
306
        b._update(!0, a)
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
307
    })
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
308
})(jQuery);
309
310
// 高さ揃えの要素を指定
311
$(function () {
312
313
    $('.pickup_item').matchHeight({
314
        byRow: true,
315
        property: 'height'
316
    });
317
318
    $('.product_item .item_name').matchHeight({
319
        byRow: true,
320
        property: 'height'
321
    });
322
    $('button.thumbnail').matchHeight({
323
        byRow: true,
324
        property: 'height'
325
    });
326
    $('#login_box > div').matchHeight({});
327
});
328
329
// anchorをクリックした時にformを裏で作って指定のメソッドでリクエストを飛ばす
330
// Twigには以下のように埋め込む
331
// <a href="PATH" {{ csrf_token_for_anchor() }} data-method="(put/delete/postのうちいずれか)" data-confirm="xxxx" data-message="xxxx">
332
//
333
// オプション要素
334
// data-confirm : falseを定義すると確認ダイアログを出さない。デフォルトはダイアログを出す
335
// data-message : 確認ダイアログを出す際のメッセージをデフォルトから変更する
336
//
337
$(function () {
338
    var createForm = function (action, data) {
339
        var $form = $('<form action="' + action + '" method="post"></form>');
340
        for (input in data) {
0 ignored issues
show
Creating global 'for' variable. Should be 'for (var input ...'.
Loading history...
341
            if (data.hasOwnProperty(input)) {
342
                $form.append('<input name="' + input + '" value="' + data[input] + '">');
343
            }
344
        }
345
        return $form;
346
    };
347
348
    $('a[token-for-anchor]').click(function (e) {
349
        e.preventDefault();
350
        var $this = $(this);
351
        var data = $this.data();
352
        if (data.confirm != false) {
0 ignored issues
show
It is recommended to use !== to compare with false.

Generally, it is recommended to use strict comparison whenever possible and not to rely on the weaker type-juggling comparison operator.

Read more about comparison operations.

Loading history...
353
            if (!confirm(data.message ? data.message : '削除してもよろしいですか?')) {
354
                return false;
355
            }
356
        }
357
358
        var $form = createForm($this.attr('href'), {
359
            _token: $this.attr('token-for-anchor'),
360
            _method: data.method
361
        }).hide();
362
363
        $('body').append($form); // Firefox requires form to be on the page to allow submission
364
        $form.submit();
365
    });
366
});
367