Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Left Arrow functionality to the left arrow in beginner block #3531

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 59 additions & 15 deletions js/widgets/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class HelpWidget {
this._helpDiv = document.createElement("div");

// Give the DOM time to create the div.
setTimeout(() => this._setup(useActiveBlock), 0);
setTimeout(() => this._setup(useActiveBlock, 0), 0);

// Position center
setTimeout(this.widgetWindow.sendToCenter, 50);
Expand All @@ -69,9 +69,8 @@ class HelpWidget {
* @param {useActiveBlock} Show help for the active block.
* @returns {void}
*/
_setup(useActiveBlock) {
_setup(useActiveBlock, page) {
// Which help page are we on?
let page = 0;

this._helpDiv.style.width = 100 +"%";
this._helpDiv.style.backgroundColor = "#e8e8e8";
Expand All @@ -92,7 +91,12 @@ class HelpWidget {

let leftArrow, rightArrow;
if (!useActiveBlock) {
this.widgetWindow.updateTitle(_("Take a tour"));
if (page == 0) {
this.widgetWindow.updateTitle("TAKE A TOUR");
}
else {
this.widgetWindow.updateTitle(HELPCONTENT[page][0]);
}
rightArrow = document.getElementById("right-arrow");
rightArrow.style.display = "block";
rightArrow.classList.add("hover");
Expand All @@ -117,6 +121,12 @@ class HelpWidget {
if (page > 0){
page = page - 1;
leftArrow.classList.remove('disabled');
if (page == 0) {
this.widgetWindow.updateTitle("TAKE A TOUR");
}
else {
this.widgetWindow.updateTitle(HELPCONTENT[page][0]);
}
this._showPage(page);
}
if (page === 0){
Expand All @@ -132,14 +142,24 @@ class HelpWidget {
if (page === HELPCONTENT.length) {
page = 0;
}

if (page == 0) {
this.widgetWindow.updateTitle("TAKE A TOUR");
}
else {
this.widgetWindow.updateTitle(HELPCONTENT[page][0]);
}
this._showPage(page);
};
} else {
if (this.activity.blocks.activeBlock.name !== null) {
const label = this.activity.blocks.blockList[this.activity.blocks.activeBlock]
.protoblock.staticLabels[0];
this.widgetWindow.updateTitle(_(label));
if (page == 0) {
this.widgetWindow.updateTitle("TAKE A TOUR");
}
else {
this.widgetWindow.updateTitle(HELPCONTENT[page][0]);
}
}

rightArrow = document.getElementById("right-arrow");
Expand All @@ -155,7 +175,7 @@ class HelpWidget {
// display help menu
docById("helpBodyDiv").style.height = "325px";
docById("helpBodyDiv").style.width = "345px";
this._showPage(0);
this._showPage(page);
} else {
// display help for this block
if (this.activity.blocks.activeBlock.name !== null) {
Expand Down Expand Up @@ -343,6 +363,24 @@ class HelpWidget {
this._prepareBlockList();
};
}
else{
const cell = docById("right-arrow");
let leftArrow = docById("left-arrow");
cell.onclick = () => {
page = page + 1;
leftArrow.classList.remove('disabled');
if (page === HELPCONTENT.length) {
page = 0;
}
if (page == 0) {
this.widgetWindow.updateTitle("TAKE A TOUR");
}
else {
this.widgetWindow.updateTitle(HELPCONTENT[page][0]);
}
this._showPage(page);
};
}

helpBody.style.color = "#505050";
helpBody.insertAdjacentHTML("afterbegin", body) ;
Expand Down Expand Up @@ -418,12 +456,12 @@ class HelpWidget {
} else if (event.key === 'ArrowRight') {
rightArrow.click();
}
} ;
};

if(this.index == this.appendedBlockList.length - 1)
{
rightArrow.classList.add("disabled") ;       
        }
rightArrow.classList.add("disabled");
}
cell.onclick = () => {
if (this.index !== this.appendedBlockList.length - 1) {
this.index += 1;
Expand All @@ -436,13 +474,19 @@ class HelpWidget {
cell = docById("left-arrow");

cell.onclick = () => {
if (this.index !== 0) {
this.index -= 1;
if (this.index == 0) {
const widgetWindow = window.widgetWindows.windowFor(this, "help", "help");
this.widgetWindow = widgetWindow;
widgetWindow.clear();
this._helpDiv = document.createElement("div");
this._setup(false, HELPCONTENT.length-1);
}

this._blockHelp(
else {
this.index -= 1;
this._blockHelp (
this.activity.blocks.protoBlockDict[this.appendedBlockList[this.index]]
);
);
}
};
if (block.name !== null) {
const label = block.staticLabels[0];
Expand Down
Loading