From 8c8a9d1df880a2da751a7ee461a7a5fa38640ffd Mon Sep 17 00:00:00 2001 From: Sarthak gupta Date: Sun, 26 Jan 2020 15:47:47 +0530 Subject: [PATCH 1/3] Update toon.js --- activities/Fototoon.activity/js/toon.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/activities/Fototoon.activity/js/toon.js b/activities/Fototoon.activity/js/toon.js index a0a3c84a8..9a9d3559c 100644 --- a/activities/Fototoon.activity/js/toon.js +++ b/activities/Fototoon.activity/js/toon.js @@ -573,8 +573,10 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct var bold = box.getSelectedGlobe().getTextViewer().toggleBold(); if (bold) { editor.style.fontWeight = 'bold'; + document.getElementById("text-set-bold").style.backgroundColor = "grey"; } else { editor.style.fontWeight = 'normal'; + document.getElementById("text-set-bold").style.backgroundColor = ""; }; }); @@ -582,8 +584,10 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct var italic = box.getSelectedGlobe().getTextViewer().toggleItalic(); if (italic) { editor.style.fontStyle = 'italic'; + document.getElementById("text-set-italic").style.backgroundColor = "grey"; } else { editor.style.fontStyle = 'normal'; + document.getElementById("text-set-italic").style.backgroundColor = ""; }; }); @@ -706,6 +710,7 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct this._text = ''; this._color = BLACK; + document.getElementsByClassName("color-picker")[0].style.border = "5px solid #696969"; this._width = globe._width - 20; this._height = SIZE_RESIZE_AREA / 2; this._size = DEFAULT_FONT_SIZE; @@ -837,8 +842,23 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct }; this.setColor = function(color) { + console.log("Before: " + this._color); + let color_class = document.getElementsByClassName("color-picker"); + for(let index=0; index<=9; index++) + { + if(color_class[index].value == this._color) + { + color_class[index].style.border = "2px solid white"; + } + if(color_class[index].value == color) + { + color_class[index].style.border = "5px solid #696969"; + } + + } this._color = color; this.update(); + console.log("After: " + this._color); return this._color; }; From 3eb78277491c356b8f30a0d3b791db9158be10bc Mon Sep 17 00:00:00 2001 From: Sarthak gupta Date: Sun, 26 Jan 2020 15:52:16 +0530 Subject: [PATCH 2/3] removed console.log statements --- activities/Fototoon.activity/js/toon.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/activities/Fototoon.activity/js/toon.js b/activities/Fototoon.activity/js/toon.js index 9a9d3559c..470ee4520 100644 --- a/activities/Fototoon.activity/js/toon.js +++ b/activities/Fototoon.activity/js/toon.js @@ -842,7 +842,6 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct }; this.setColor = function(color) { - console.log("Before: " + this._color); let color_class = document.getElementsByClassName("color-picker"); for(let index=0; index<=9; index++) { @@ -858,7 +857,6 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct } this._color = color; this.update(); - console.log("After: " + this._color); return this._color; }; From 696607c9b6a62eb70968618fcb8fd26b15591af0 Mon Sep 17 00:00:00 2001 From: Sarthak gupta Date: Sun, 26 Jan 2020 17:18:10 +0530 Subject: [PATCH 3/3] resolved error for multiple globes --- activities/Fototoon.activity/js/toon.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/activities/Fototoon.activity/js/toon.js b/activities/Fototoon.activity/js/toon.js index 470ee4520..091a13d4b 100644 --- a/activities/Fototoon.activity/js/toon.js +++ b/activities/Fototoon.activity/js/toon.js @@ -710,7 +710,6 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct this._text = ''; this._color = BLACK; - document.getElementsByClassName("color-picker")[0].style.border = "5px solid #696969"; this._width = globe._width - 20; this._height = SIZE_RESIZE_AREA / 2; this._size = DEFAULT_FONT_SIZE; @@ -893,15 +892,32 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct // (used when a globe is selected) editor.style.fontSize = this._size + 'px'; editor.style.color = this._color; + let color_class = document.getElementsByClassName("color-picker"); + for(let index=0; index<=9; index++) + { + if(color_class[index].value == this._color) + { + color_class[index].style.border = "5px solid #696969"; + } + else + { + color_class[index].style.border = "2px solid white"; + } + + } if (this._italic) { editor.style.fontStyle = 'italic'; + document.getElementById("text-set-italic").style.backgroundColor = "grey"; } else { editor.style.fontStyle = 'normal'; + document.getElementById("text-set-italic").style.backgroundColor = ""; }; if (this._bold) { editor.style.fontWeight = 'bold'; + document.getElementById("text-set-bold").style.backgroundColor = "grey"; } else { editor.style.fontWeight = 'normal'; + document.getElementById("text-set-bold").style.backgroundColor = ""; }; };