Skip to content

Commit

Permalink
Merge pull request #389 from entrylabs/feature/print
Browse files Browse the repository at this point in the history
Feature/print
  • Loading branch information
chanlee authored Jul 13, 2016
2 parents 2fcf61b + 9e8ccb9 commit 470affe
Show file tree
Hide file tree
Showing 18 changed files with 14,179 additions and 13,837 deletions.
23,954 changes: 12,006 additions & 11,948 deletions dist/entry.js

Large diffs are not rendered by default.

3,722 changes: 1,865 additions & 1,857 deletions dist/entry.min.js

Large diffs are not rendered by default.

Binary file added images/block_icon/text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions src/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ Entry.Container.prototype.moveElementByBlock = function(currentIndex, targetInde
* generate list for blockly dropdown dynamic
* @param {string} menuName
*/
Entry.Container.prototype.getDropdownList = function(menuName) {
Entry.Container.prototype.getDropdownList = function(menuName, object) {
var result = [];
switch (menuName) {
case 'sprites':
Expand Down Expand Up @@ -538,9 +538,9 @@ Entry.Container.prototype.getDropdownList = function(menuName) {
result.push([Lang.Blocks.wall_left, 'wall_left']);
break;
case 'pictures':
if (!Entry.playground.object)
break;
var pictures = Entry.playground.object.pictures;
var object = Entry.playground.object || object;
if (!object) break;
var pictures = object.pictures;
for (var i = 0; i<pictures.length; i++) {
var picture = pictures[i];
result.push([picture.name, picture.id]);
Expand All @@ -557,7 +557,9 @@ Entry.Container.prototype.getDropdownList = function(menuName) {
var variables = Entry.variableContainer.variables_;
for (var i = 0; i<variables.length; i++) {
var variable = variables[i];
if (variable.object_ && variable.object_ != Entry.playground.object.id)

if (variable.object_ && Entry.playground.object &&
variable.object_ != Entry.playground.object.id)
continue;
result.push([variable.getName(), variable.getId()]);
}
Expand All @@ -581,9 +583,9 @@ Entry.Container.prototype.getDropdownList = function(menuName) {
}
break;
case 'sounds':
if (!Entry.playground.object)
break;
var sounds = Entry.playground.object.sounds;
var object = Entry.playground.object || object;
if (!object) break;
var sounds = object.sounds;
for (var i = 0; i<sounds.length; i++) {
var sound = sounds[i];
result.push([sound.name, sound.id]);
Expand Down
3 changes: 2 additions & 1 deletion src/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Entry.Func = function(func) {
Entry.Func.threads = {};

Entry.Func.registerFunction = function(func) {
if (!Entry.playground) return;
var workspace = Entry.playground.mainWorkspace;
if (!workspace) return;
var blockMenu = workspace.getBlockMenu();
Expand Down Expand Up @@ -304,8 +305,8 @@ Entry.Func.createParamBlock = function(type, blockPrototype, originalType) {
}

Entry.Func.updateMenu = function() {
if (!Entry.playground || !Entry.playground.mainWorkspace) return;
var workspace = Entry.playground.mainWorkspace;
if (!workspace) return;
var blockMenu = workspace.getBlockMenu();
if (this.targetFunc) {
if (!this.menuCode)
Expand Down
13 changes: 11 additions & 2 deletions src/util/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@
goog.provide("Entry.Loader");

Entry.Loader = {
queueCount: 0
queueCount: 0,
totalCount: 0
};

Entry.Loader.addQueue = function(type) {
if (!this.queueCount)
Entry.dispatchEvent("loadStart");
this.queueCount++;
this.totalCount++;
};

Entry.Loader.removeQueue = function(type) {
this.queueCount--;
if (!this.queueCount)
if (!this.queueCount) {
Entry.dispatchEvent("loadComplete");
this.totalCount = 0;
}
};

Entry.Loader.getLoadedPercent = function() {
if (this.totalCount === 0) return 1;
else return this.queueCount / this.totalCount;
};
57 changes: 57 additions & 0 deletions src/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,63 @@ Entry.Utils.stopProjectWithToast = function(block, message) {
throw new Error(message);
};

Entry.Utils.isChrome = function() {
return /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
};

Entry.Utils.waitForWebfonts = function(fonts, callback) {
var loadedFonts = 0;
for(var i = 0, l = fonts.length; i < l; ++i) {
(function(font) {
var node = document.createElement('span');
// Characters that vary significantly among different fonts
node.innerHTML = 'giItT1WQy@!-/#';
// Visible - so we can measure it - but not on the screen
node.style.position = 'absolute';
node.style.left = '-10000px';
node.style.top = '-10000px';
// Large font size makes even subtle changes obvious
node.style.fontSize = '300px';
// Reset any font properties
node.style.fontFamily = 'sans-serif';
node.style.fontVariant = 'normal';
node.style.fontStyle = 'normal';
node.style.fontWeight = 'normal';
node.style.letterSpacing = '0';
document.body.appendChild(node);

// Remember width with no applied web font
var width = node.offsetWidth;

node.style.fontFamily = font;

var interval;
function checkFont() {
// Compare current width with original width
if(node && node.offsetWidth != width) {
++loadedFonts;
node.parentNode.removeChild(node);
node = null;
}

// If all fonts have been loaded
if(loadedFonts >= fonts.length) {
if(interval) {
clearInterval(interval);
}
if(loadedFonts == fonts.length) {
callback();
return true;
}
}
};

if(!checkFont()) {
interval = setInterval(checkFont, 50);
}
})(fonts[i]);
}
};
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down
7 changes: 4 additions & 3 deletions src/variable_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -1328,11 +1328,11 @@ Entry.VariableContainer.prototype.getVariableJSON = function() {
}

if (Entry.engine.projectTimer)
json.push(Entry.engine.projectTimer);
json.push(Entry.engine.projectTimer.toJSON());

var answer = Entry.container.inputValue;
if (!Entry.isEmpty(answer))
json.push(answer);
json.push(answer.toJSON());
return json;
};

Expand Down Expand Up @@ -2184,7 +2184,7 @@ Entry.VariableContainer.prototype.updateCloudVariables = function() {
};

Entry.VariableContainer.prototype.addRef = function(type, block) {
if (!this.view_ ||
if (!this.view_ || !Entry.playground.mainWorkspace ||
Entry.playground.mainWorkspace.getMode() !== Entry.Workspace.MODE_BOARD)
return;

Expand Down Expand Up @@ -2240,6 +2240,7 @@ Entry.VariableContainer.prototype.addRef = function(type, block) {
};

Entry.VariableContainer.prototype.removeRef = function(type, block) {
if (!Entry.playground.mainWorkspace) return;
var wsMode = Entry.playground.mainWorkspace.getMode();
if (wsMode !== Entry.Workspace.MODE_BOARD) return;

Expand Down
34 changes: 29 additions & 5 deletions src/workspace/block_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -14390,6 +14390,11 @@ Entry.block = {
{
"type": "Block",
"accept": "string"
},
{
"type": "Indicator",
"img": "block_icon/text.png",
"size": 12
}
],
"events": {},
Expand All @@ -14398,7 +14403,8 @@ Entry.block = {
{
"type": "text",
"params": [ Lang.Blocks.entry ]
}
},
null
],
"type": "text_write"
},
Expand All @@ -14422,6 +14428,11 @@ Entry.block = {
{
"type": "Block",
"accept": "string"
},
{
"type": "Indicator",
"img": "block_icon/text.png",
"size": 12
}
],
"events": {},
Expand All @@ -14430,7 +14441,8 @@ Entry.block = {
{
"type": "text",
"params": [ Lang.Blocks.entry ]
}
},
null
],
"type": "text_append"
},
Expand All @@ -14454,6 +14466,11 @@ Entry.block = {
{
"type": "Block",
"accept": "string"
},
{
"type": "Indicator",
"img": "block_icon/text.png",
"size": 12
}
],
"events": {},
Expand All @@ -14462,7 +14479,8 @@ Entry.block = {
{
"type": "text",
"params": [ Lang.Blocks.entry ]
}
},
null
],
"type": "text_prepend"
},
Expand All @@ -14482,10 +14500,16 @@ Entry.block = {
"color": "#FFCA36",
"skeleton": "basic",
"statements": [],
"params": [],
"params": [
{
"type": "Indicator",
"img": "block_icon/text.png",
"size": 12
}
],
"events": {},
"def": {
"params": [],
"params": [null],
"type": "text_flush"
},
"class": "text",
Expand Down
Loading

0 comments on commit 470affe

Please sign in to comment.