From b23fe783e398b99f413c079fd3de405a80ca537b Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 10 Oct 2016 18:21:18 +0200 Subject: [PATCH] Fix the color picker in Chrome and hide the buttons when not supported --- www/slide/inner.html | 4 ++++ www/slide/main.js | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/www/slide/inner.html b/www/slide/inner.html index 01eac32a6..ad933baa0 100644 --- a/www/slide/inner.html +++ b/www/slide/inner.html @@ -136,6 +136,9 @@ background-position: bottom; background-repeat: repeat-x; } + #colorPicker_check { + display: block; + } @@ -147,6 +150,7 @@
+
diff --git a/www/slide/main.js b/www/slide/main.js index f31afc6d5..8a96dbd7a 100644 --- a/www/slide/main.js +++ b/www/slide/main.js @@ -458,21 +458,31 @@ define([ 'style': 'font-family: FontAwesome; font-weight: bold; color: #fff; background: #000;', title: Messages.colorButton + '\n' + Messages.colorButtonTitle }); - $testColor = $('', { type: 'color' }); - if ($testColor.attr('type') !== "color") {alert('not supported'); return;} + $testColor = $('', { type: 'color', value: '!' }); + var $check = $pad.contents().find("#colorPicker_check"); + if ($testColor.attr('type') !== "color" || $testColor.val() === '!') { return; } // TODO $back.on('click', function() { - $('', { type: 'color', value: backColor }) + var $picker = $('', { type: 'color', value: backColor }) .on('change', function() { updateColors(undefined, this.value); onLocal(); - }).click(); + }); + $check.append($picker); + setTimeout(function() { + $picker.click(); + }, 0); }); $text.on('click', function() { - $('', { type: 'color', value: textColor }) + var $picker = $('', { type: 'color', value: textColor }) .on('change', function() { updateColors(this.value, undefined); onLocal(); - }).click(); + $check.html(''); + }); + $check.append($picker); + setTimeout(function() { + $picker.click(); + }, 0); }); $rightside.append($back).append($text);