Skip to content

Commit

Permalink
widgets/help - jsDoc style documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ksraj123 committed Jan 23, 2021
1 parent a4b194f commit 474da28
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions js/widgets/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
class HelpWidget {
static ICONSIZE = 32;

/**
* @param {Blocks} blocks
*/
constructor(blocks) {
this.beginnerBlocks = [];
this.advancedBlocks = [];
Expand Down Expand Up @@ -56,6 +59,11 @@ class HelpWidget {
setTimeout(this.widgetWindow.sendToCenter, 50);
}

/**
* @private
* @param {Blocks} blocks
* @returns {void}
*/
_setup(blocks) {
const iconSize = HelpWidget.ICONSIZE;
// Which help page are we on?
Expand Down Expand Up @@ -260,6 +268,11 @@ class HelpWidget {
this.widgetWindow.takeFocus();
}

/**
* @private
* @param {number} page
* @returns {void}
*/
_showPage(page) {
const helpBody = docById("helpBodyDiv");
let body = "";
Expand Down Expand Up @@ -309,8 +322,12 @@ class HelpWidget {
this.widgetWindow.takeFocus();
}

// Prepare a list of beginner and advanced blocks and cycle through their help

/**
* Prepare a list of beginner and advanced blocks and cycle through their help
* @private
* @param {Blocks} blocks
* @returns {void}
*/
_prepareBlockList(blocks) {
for (const key in blocks.protoBlockDict) {
if (
Expand Down Expand Up @@ -340,9 +357,15 @@ class HelpWidget {
this._blockHelp(blocks.protoBlockDict[this.appendedBlockList[0]], blocks);
}

// Function to display help related to a single block
// called recursively to cycle through help string of all blocks (Beginner Blocks First)

/**
* Function to display help related to a single block
* called recursively to cycle through help string of all blocks (Beginner Blocks First)
* @private
* @param {ProtoBlock} block
* @param {Blocks} blocks
* @returns {void}
*/
_blockHelp(block, blocks) {
const widgetWindow = window.widgetWindows.windowFor(this, "help", "help");
this.widgetWindow = widgetWindow;
Expand Down Expand Up @@ -379,11 +402,6 @@ class HelpWidget {
this.widgetWindow.updateTitle(_(label));
}

// display help menu
// docById("helpBodyDiv").style.height = "325px";
// docById("helpBodyDiv").style.width = "400px";
// this._showPage(0);

if (block.name !== null) {
const name = block.name;
const advIcon =
Expand Down Expand Up @@ -514,6 +532,9 @@ class HelpWidget {
this.widgetWindow.takeFocus();
}

/**
* @deprecated
*/
showPageByName(pageName) {
for (let i = 0; i < HELPCONTENT.length; i++) {
if (HELPCONTENT[i].includes(pageName)) {
Expand Down

0 comments on commit 474da28

Please sign in to comment.