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

NewPalette #2392

Merged
merged 12 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions css/activities.css
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,13 @@ input.timbreName {
visibility: hidden;
}

#palette td ,thead ,tr ,table {
border-collapse: collapse;
padding: 0;
margin: 0;
border:0;
}

#printText {
border: 2px solid rgb(150, 150, 150);
z-index: 100;
Expand All @@ -1435,3 +1442,9 @@ input.timbreName {
height: 28px;
filter: invert(100%);
}
::-webkit-scrollbar {
display: none;
}
.disable_highlighting {
user-select: none;
}
25 changes: 13 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -421,18 +421,6 @@
tabindex="-1"
></div>

<div id="searchBar" tabindex="-1">
<input
type="text"
name="search"
id="search"
class="ui-autocomplete"
placeholder="Search for Blocks"
tabindex="-1"
/>
<ul class="matches" id="searchResults"></ul>
</div>

<div id="pastecode" tabindex="-1">
<input
type="text"
Expand Down Expand Up @@ -798,5 +786,18 @@
</div>
</div>
<!-- hideContents -->

<div id="searchBar" tabindex="-1">
<input
type="text"
name="search"
id="search"
class="ui-autocomplete"
placeholder="Search for Blocks"
tabindex="-1"
/>
<ul class="matches" id="searchResults"></ul>
</div>

</body>
</html>
156 changes: 26 additions & 130 deletions js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ function Activity() {
_loadButtonDragHandler = this._loadButtonDragHandler;

scrollBlockContainer = false;
scrollPaletteContainer = false;

if (_THIS_IS_TURTLE_BLOCKS_) {
function facebookInit() {
Expand Down Expand Up @@ -314,7 +313,6 @@ function Activity() {
swiping = false;
menuButtonsVisible = false;
scrollBlockContainer = false;
scrollPaletteContainer = false;
currentKeyCode = 0;
pasteContainer = null;
pasteImage = null;
Expand Down Expand Up @@ -1074,7 +1072,6 @@ function Activity() {
function setScroller() {
blocks.activeBlock = null;
scrollBlockContainer = !scrollBlockContainer;
scrollPaletteContainer = !scrollPaletteContainer;
let enableHorizScrollIcon = docById("enableHorizScrollIcon");
let disableHorizScrollIcon = docById("disableHorizScrollIcon");
if (scrollBlockContainer && !beginnerMode) {
Expand Down Expand Up @@ -1387,80 +1384,6 @@ function Activity() {
delta: 0
};

let __paletteWheelHandler = function(event) {
// vertical scroll
if (event.deltaY !== 0 && event.axis === event.VERTICAL_AXIS) {
if (palettes.paletteVisible) {
if (event.clientX > cellSize + MENUWIDTH) {
palettesContainer.y -= event.deltaY;
}
} else {
if (event.clientX > cellSize) {
palettesContainer.y -= event.deltaY;
}
}
}

// horizontal scroll
if (scrollPaletteContainer) {
if (event.deltaX !== 0 && event.axis === event.HORIZONTAL_AXIS) {
if (palettes.paletteVisible) {
if (event.clientX > cellSize + MENUWIDTH) {
palettesContainer.x -= event.deltaX;
}
} else {
if (event.clientX > cellSize) {
palettesContainer.x -= event.deltaX;
}
}
}
} else {
event.preventDefault();
}

refreshCanvas();
};

let myCanvas = docById("myCanvas");

let __heightBasedScroll = function(event) {
actualReszieHandler(); // check size during init
window.addEventListener("resize", resizeThrottler, false);
let resizeTimeout;

function resizeThrottler() {
// Ignore resize events as long as an actualResizeHandler
// execution is in queue.
if (!resizeTimeout) {
resizeTimeout = setTimeout(function() {
resizeTimeout = null;
actualReszieHandler();
// The actualResizeHandler will execute at the
// rate of 15 FPS.
}, 66);
}
}
};

function actualReszieHandler() {
// Handle the resize event
let h = window.innerHeight;

if (h < 500) {
//activate on mobile
myCanvas.addEventListener(
"wheel",
__paletteWheelHandler,
false
);
} else {
// Cleanup event listeners
myCanvas.removeEventListener("wheel", __paletteWheelHandler);
}
}

__heightBasedScroll();

let closeAnyOpenMenusAndLabels = function () {
if (docById("wheelDiv")!= null) docById("wheelDiv").style.display = "none";
if (docById("contextWheelDiv")!= null) docById("contextWheelDiv").style.display = "none";
Expand All @@ -1471,35 +1394,17 @@ function Activity() {
let __wheelHandler = function(event) {
if (event.deltaY !== 0 && event.axis === event.VERTICAL_AXIS) {
closeAnyOpenMenusAndLabels();// closes all wheelnavs when scrolling .
if (palettes.paletteVisible) {
if (event.clientX > cellSize + MENUWIDTH) {
blocksContainer.y -= event.deltaY;
}
} else {
if (event.clientX > cellSize) {
blocksContainer.y -= event.deltaY;
}
}
blocksContainer.y -= event.deltaY;
}

// horizontal scroll
if (scrollBlockContainer) {
if (event.deltaX !== 0 && event.axis === event.HORIZONTAL_AXIS) {
closeAnyOpenMenusAndLabels();
if (palettes.paletteVisible) {
if (event.clientX > cellSize + MENUWIDTH) {
blocksContainer.x -= event.deltaX;
}
} else {
if (event.clientX > cellSize) {
blocksContainer.x -= event.deltaX;
}
}
blocksContainer.x -= event.deltaX;
}
} else {
event.preventDefault();
}

refreshCanvas();
};

Expand Down Expand Up @@ -1581,19 +1486,19 @@ function Activity() {
let scrollSpeed = 30;

if (event.clientX < cellSize) {
palettes.menuScrollEvent(delta, scrollSpeed);
palettes.hidePaletteIconCircles();
//palettes.menuScrollEvent(delta, scrollSpeed);
//palettes.hidePaletteIconCircles();
} else {
let palette = palettes.findPalette(
event.clientX / turtleBlocksScale,
event.clientY / turtleBlocksScale
);
if (palette) {
// if we are moving the palettes, deselect the active block.
blocks.activeBlock = null;
// let palette = palettes.findPalette(
// event.clientX / turtleBlocksScale,
// event.clientY / turtleBlocksScale
// );
// if (palette) {
// // if we are moving the palettes, deselect the active block.
// blocks.activeBlock = null;

palette.scrollEvent(delta, scrollSpeed);
}
// //palette.scrollEvent(delta, scrollSpeed);
// }
}
}

Expand Down Expand Up @@ -1803,6 +1708,8 @@ function Activity() {
* Shows search widget
*/
showSearchWidget = function() {
//bring to top;
searchWidget.style.zIndex = 1 ;
if (searchWidget.style.visibility === "visible") {
hideSearchWidget();
} else {
Expand All @@ -1812,7 +1719,7 @@ function Activity() {
}

searchWidget.value = null;
docById("searchResults").style.visibility = "visible";
//docById("searchResults").style.visibility = "visible";
searchWidget.style.visibility = "visible";
searchWidget.style.left =
palettes.getSearchPos()[0] * turtleBlocksScale + "px";
Expand All @@ -1826,7 +1733,7 @@ function Activity() {
setTimeout(function() {
searchWidget.focus();
doSearch();
}, 500);
}, 500);
}
};

Expand Down Expand Up @@ -2241,9 +2148,6 @@ function Activity() {
);
blocks.blockMoved(blocks.activeBlock);
blocks.adjustDocks(blocks.activeBlock, true);
} else if (palettes.mouseOver) {
palettes.menuScrollEvent(1, 10);
palettes.hidePaletteIconCircles();
} else if (palettes.activePalette != null) {
palettes.activePalette.scrollEvent(
STANDARDBLOCKHEIGHT,
Expand All @@ -2268,9 +2172,6 @@ function Activity() {
);
blocks.blockMoved(blocks.activeBlock);
blocks.adjustDocks(blocks.activeBlock, true);
} else if (palettes.mouseOver) {
palettes.menuScrollEvent(-1, 10);
palettes.hidePaletteIconCircles();
} else if (palettes.activePalette != null) {
palettes.activePalette.scrollEvent(
-STANDARDBLOCKHEIGHT,
Expand Down Expand Up @@ -2542,8 +2443,6 @@ function Activity() {
blocks.setScale(turtleBlocksScale);
boundary.setScale(w, h, turtleBlocksScale);

palettes.setScale(turtleBlocksScale);

trashcan.resizeEvent(turtleBlocksScale);

// We need to reposition the palette buttons
Expand Down Expand Up @@ -2932,6 +2831,8 @@ function Activity() {
* Opens samples on planet after closing all sub menus
*/
_doOpenSamples = function() {
if (docById("palette").style.display != "none")
docById("palette").style.display = "none";
toolbar.closeAuxToolbar(_showHideAuxMenu);
planet.openPlanet();
};
Expand Down Expand Up @@ -3120,6 +3021,7 @@ function Activity() {
*/
this.showContents = function() {
docById("loading-image-container").style.display = "none";
docById("palette").style.display = "block";
// docById('canvas').style.display = 'none';
docById("hideContents").style.display = "block";

Expand Down Expand Up @@ -3217,11 +3119,7 @@ function Activity() {
50
)}...`
);
// First, hide the palettes as they will need updating.
for (let name in blocks.palettes.dict) {
blocks.palettes.dict[name].hideMenu(true);
}


blocks.loadNewBlocks(JSON.parse(sessionData));
}
} catch (e) {
Expand Down Expand Up @@ -4699,12 +4597,11 @@ function Activity() {
* turtles
* logo (drawing)
*/
palettesContainer = new createjs.Container();
blocksContainer = new createjs.Container();
trashContainer = new createjs.Container();
turtleContainer = new createjs.Container();
stage.addChild(turtleContainer);
stage.addChild(trashContainer, blocksContainer, palettesContainer);
stage.addChild(trashContainer, blocksContainer);
that._setupBlocksContainerEvents();

trashcan = new Trashcan();
Expand Down Expand Up @@ -4748,8 +4645,8 @@ function Activity() {
palettes = new Palettes();
palettes
.setCanvas(canvas)
.setStage(palettesContainer)
.setRefreshCanvas(refreshCanvas)
.setBlocksContainer(blocksContainer)
.setSize(cellSize)
.setTrashcan(trashcan)
.setSearch(showSearchWidget, hideSearchWidget)
Expand Down Expand Up @@ -4816,6 +4713,7 @@ function Activity() {

this.showMusicBlocks = function() {
document.getElementById("toolbars").style.display = "block";
document.getElementById("palette").style.display = "block";

widgetWindows.showWindows();

Expand Down Expand Up @@ -4884,10 +4782,8 @@ function Activity() {
_allClear(false);

// First, hide the palettes as they will need updating.
for (let name in blocks.palettes.dict) {
blocks.palettes.dict[name].hideMenu(true);
}

blocks.palettes._hideMenus(true);

let __afterLoad = function() {
document.removeEventListener(
"finishedLoading",
Expand Down
Loading