mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
js: Create the puzzle resize handle only if the puzzle is resizable
If there's no resizable div to attach it to, there's not much point in creating the handle and the doing nothing with it.
This commit is contained in:
16
emccpre.js
16
emccpre.js
@ -447,11 +447,13 @@ function initPuzzle() {
|
|||||||
permalink_desc = document.getElementById("permalink-desc");
|
permalink_desc = document.getElementById("permalink-desc");
|
||||||
permalink_seed = document.getElementById("permalink-seed");
|
permalink_seed = document.getElementById("permalink-seed");
|
||||||
|
|
||||||
// Create the resize handle.
|
resizable_div = document.getElementById("resizable");
|
||||||
var resize_handle = document.createElement("canvas");
|
if (resizable_div !== null) {
|
||||||
resize_handle.width = 10;
|
// Create the resize handle.
|
||||||
resize_handle.height = 10;
|
var resize_handle = document.createElement("canvas");
|
||||||
{
|
resize_handle.width = 10;
|
||||||
|
resize_handle.height = 10;
|
||||||
|
|
||||||
var ctx = resize_handle.getContext("2d");
|
var ctx = resize_handle.getContext("2d");
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
for (var i = 1; i <= 7; i += 3) {
|
for (var i = 1; i <= 7; i += 3) {
|
||||||
@ -463,9 +465,7 @@ function initPuzzle() {
|
|||||||
ctx.lineJoin = 'round';
|
ctx.lineJoin = 'round';
|
||||||
ctx.strokeStyle = '#000000';
|
ctx.strokeStyle = '#000000';
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
|
||||||
resizable_div = document.getElementById("resizable");
|
|
||||||
if (resizable_div !== null) {
|
|
||||||
resizable_div.appendChild(resize_handle);
|
resizable_div.appendChild(resize_handle);
|
||||||
resize_handle.id = "resizehandle";
|
resize_handle.id = "resizehandle";
|
||||||
resize_handle.title = "Drag to resize the puzzle. Right-click to restore the default size.";
|
resize_handle.title = "Drag to resize the puzzle. Right-click to restore the default size.";
|
||||||
|
Reference in New Issue
Block a user