Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
bdc4795f
Commit
bdc4795f
authored
Mar 06, 2015
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify workspace construction.
parent
0d6a3bf9
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
38 deletions
+44
-38
blockly_compressed.js
blockly_compressed.js
+14
-13
core/blockly.js
core/blockly.js
+3
-6
core/flyout.js
core/flyout.js
+1
-3
core/inject.js
core/inject.js
+2
-10
core/mutator.js
core/mutator.js
+1
-4
core/workspace_svg.js
core/workspace_svg.js
+22
-1
javascript_compressed.js
javascript_compressed.js
+1
-1
No files found.
blockly_compressed.js
View file @
bdc4795f
This diff is collapsed.
Click to expand it.
core/blockly.js
View file @
bdc4795f
...
...
@@ -715,12 +715,9 @@ Blockly.setMainWorkspaceMetrics_ = function(xyRatio) {
Blockly
.
mainWorkspace
.
scrollY
=
-
metrics
.
contentHeight
*
xyRatio
.
y
-
metrics
.
contentTop
;
}
var
translation
=
'
translate(
'
+
(
Blockly
.
mainWorkspace
.
scrollX
+
metrics
.
absoluteLeft
)
+
'
,
'
+
(
Blockly
.
mainWorkspace
.
scrollY
+
metrics
.
absoluteTop
)
+
'
)
'
;
Blockly
.
mainWorkspace
.
getCanvas
().
setAttribute
(
'
transform
'
,
translation
);
Blockly
.
mainWorkspace
.
getBubbleCanvas
().
setAttribute
(
'
transform
'
,
translation
);
Blockly
.
mainWorkspace
.
translate
(
Blockly
.
mainWorkspace
.
scrollX
+
metrics
.
absoluteLeft
,
Blockly
.
mainWorkspace
.
scrollY
+
metrics
.
absoluteTop
);
};
/**
...
...
core/flyout.js
View file @
bdc4795f
...
...
@@ -191,9 +191,7 @@ Blockly.Flyout.prototype.setMetrics_ = function(yRatio) {
this
.
workspace_
.
scrollY
=
-
metrics
.
contentHeight
*
yRatio
.
y
-
metrics
.
contentTop
;
}
var
y
=
this
.
workspace_
.
scrollY
+
metrics
.
absoluteTop
;
this
.
workspace_
.
getCanvas
().
setAttribute
(
'
transform
'
,
'
translate(0,
'
+
y
+
'
)
'
);
this
.
workspace_
.
translate
(
0
,
this
.
workspace_
.
scrollY
+
metrics
.
absoluteTop
);
};
/**
...
...
core/inject.js
View file @
bdc4795f
...
...
@@ -268,6 +268,7 @@ Blockly.createDom_ = function(container) {
{
'
width
'
:
10
,
'
height
'
:
10
,
'
fill
'
:
'
#aaa
'
},
pattern
);
Blockly
.
createSvgElement
(
'
path
'
,
{
'
d
'
:
'
M 0 0 L 10 10 M 10 0 L 0 10
'
,
'
stroke
'
:
'
#cc0
'
},
pattern
);
Blockly
.
mainWorkspace
=
new
Blockly
.
WorkspaceSvg
(
Blockly
.
getMainWorkspaceMetrics_
,
Blockly
.
setMainWorkspaceMetrics_
);
...
...
@@ -280,16 +281,7 @@ Blockly.createDom_ = function(container) {
if
(
Blockly
.
hasCategories
)
{
Blockly
.
mainWorkspace
.
toolbox_
=
new
Blockly
.
Toolbox
(
svg
,
container
);
}
else
if
(
Blockly
.
languageTree
)
{
/**
* @type {!Blockly.Flyout}
* @private
*/
Blockly
.
mainWorkspace
.
flyout_
=
new
Blockly
.
Flyout
();
var
flyout
=
Blockly
.
mainWorkspace
.
flyout_
;
var
flyoutSvg
=
flyout
.
createDom
();
flyout
.
autoClose
=
false
;
// Insert the flyout behind the workspace so that blocks appear on top.
goog
.
dom
.
insertSiblingBefore
(
flyoutSvg
,
Blockly
.
mainWorkspace
.
svgGroup_
);
Blockly
.
mainWorkspace
.
addFlyout
();
}
if
(
!
Blockly
.
hasScrollbars
)
{
var
workspaceChanged
=
function
()
{
...
...
core/mutator.js
View file @
bdc4795f
...
...
@@ -107,7 +107,6 @@ Blockly.Mutator.prototype.createEditor_ = function() {
/* Create the editor. Here's the markup that will be generated:
<svg>
<rect class="blocklyMutatorBackground" />
[Flyout]
[Workspace]
</svg>
*/
...
...
@@ -120,10 +119,8 @@ Blockly.Mutator.prototype.createEditor_ = function() {
var
mutator
=
this
;
this
.
workspace_
=
new
Blockly
.
WorkspaceSvg
(
function
()
{
return
mutator
.
getFlyoutMetrics_
();},
null
);
this
.
workspace_
.
flyout_
=
new
Blockly
.
Flyout
();
this
.
workspace_
.
flyout_
.
autoClose
=
false
;
this
.
svgDialog_
.
appendChild
(
this
.
workspace_
.
flyout_
.
createDom
());
this
.
svgDialog_
.
appendChild
(
this
.
workspace_
.
createDom
());
this
.
workspace_
.
addFlyout
();
return
this
.
svgDialog_
;
};
...
...
core/workspace_svg.js
View file @
bdc4795f
...
...
@@ -102,7 +102,7 @@ Blockly.WorkspaceSvg.prototype.scrollbar = null;
Blockly
.
WorkspaceSvg
.
prototype
.
createDom
=
function
()
{
/*
<g>
[Trashcan may go here]
[Trashcan
and/or flyout
may go here]
<g></g> // Block canvas
<g></g> // Bubble canvas
[Scrollbars may go here]
...
...
@@ -151,6 +151,16 @@ Blockly.WorkspaceSvg.prototype.addTrashcan = function() {
}
};
/**
* Add a flyout.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
addFlyout
=
function
()
{
this
.
flyout_
=
new
Blockly
.
Flyout
();
this
.
flyout_
.
autoClose
=
false
;
var
svgFlyout
=
this
.
flyout_
.
createDom
();
this
.
svgGroup_
.
insertBefore
(
svgFlyout
,
this
.
svgBlockCanvas_
);
};
/**
* Get the SVG element that forms the drawing surface.
* @return {!Element} SVG element.
...
...
@@ -167,6 +177,17 @@ Blockly.WorkspaceSvg.prototype.getBubbleCanvas = function() {
return
this
.
svgBubbleCanvas_
;
};
/**
* Translate this workspace to new coordinates.
* @param {number} x Horizontal translation.
* @param {number} y Vertical translation.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
translate
=
function
(
x
,
y
)
{
var
translation
=
'
translate(
'
+
x
+
'
,
'
+
y
+
'
)
'
;
this
.
svgBlockCanvas_
.
setAttribute
(
'
transform
'
,
translation
);
this
.
svgBubbleCanvas_
.
setAttribute
(
'
transform
'
,
translation
);
};
/**
* Add a block to the list of top blocks.
* @param {!Blockly.Block} block Block to remove.
...
...
javascript_compressed.js
View file @
bdc4795f
...
...
@@ -89,7 +89,7 @@ Blockly.JavaScript.text_getSubstring=function(a){var b=Blockly.JavaScript.valueT
"
function getAt(where, at) {
"
,
"
if (where == 'FROM_START') {
"
,
"
at--;
"
,
"
} else if (where == 'FROM_END') {
"
,
"
at = text.length - at;
"
,
"
} else if (where == 'FIRST') {
"
,
"
at = 0;
"
,
"
} else if (where == 'LAST') {
"
,
"
at = text.length - 1;
"
,
"
} else {
"
,
"
throw 'Unhandled option (text_getSubstring).';
"
,
"
}
"
,
"
return at;
"
,
"
}
"
,
"
at1 = getAt(where1, at1);
"
,
"
at2 = getAt(where2, at2) + 1;
"
,
"
return text.slice(at1, at2);
"
,
"
}
"
])
+
"
(
"
+
b
+
"
, '
"
+
c
+
"
',
"
+
e
+
"
, '
"
+
d
+
"
',
"
+
a
+
"
)
"
,
Blockly
.
JavaScript
.
ORDER_FUNCTION_CALL
]};
Blockly
.
JavaScript
.
text_changeCase
=
function
(
a
){
var
b
=
{
UPPERCASE
:
"
.toUpperCase()
"
,
LOWERCASE
:
"
.toLowerCase()
"
,
TITLECASE
:
null
}[
a
.
getFieldValue
(
"
CASE
"
)];
b
?(
a
=
Blockly
.
JavaScript
.
valueToCode
(
a
,
"
TEXT
"
,
Blockly
.
JavaScript
.
ORDER_MEMBER
)
||
"
''
"
,
a
+=
b
):(
b
=
Blockly
.
JavaScript
.
provideFunction_
(
"
text_toTitleCase
"
,[
"
function
"
+
Blockly
.
JavaScript
.
FUNCTION_NAME_PLACEHOLDER_
+
"
(str) {
"
,
"
return str.replace(/
\\
S+/g,
"
,
"
function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});
"
,
"
}
"
]),
a
=
Blockly
.
JavaScript
.
valueToCode
(
a
,
"
TEXT
"
,
Blockly
.
JavaScript
.
ORDER_NONE
)
||
"
''
"
,
a
=
b
+
"
(
"
+
a
+
"
)
"
);
return
[
a
,
Blockly
.
JavaScript
.
ORDER_FUNCTION_CALL
]};
Blockly
.
JavaScript
.
text_trim
=
function
(
a
){
var
b
=
{
LEFT
:
"
.
trimLeft()
"
,
RIGHT
:
"
.trimRight(
)
"
,
BOTH
:
"
.trim()
"
}[
a
.
getFieldValue
(
"
MODE
"
)];
return
[(
Blockly
.
JavaScript
.
valueToCode
(
a
,
"
TEXT
"
,
Blockly
.
JavaScript
.
ORDER_MEMBER
)
||
"
''
"
)
+
b
,
Blockly
.
JavaScript
.
ORDER_FUNCTION_CALL
]};
"
TEXT
"
,
Blockly
.
JavaScript
.
ORDER_NONE
)
||
"
''
"
,
a
=
b
+
"
(
"
+
a
+
"
)
"
);
return
[
a
,
Blockly
.
JavaScript
.
ORDER_FUNCTION_CALL
]};
Blockly
.
JavaScript
.
text_trim
=
function
(
a
){
var
b
=
{
LEFT
:
"
.
replace(/^[
\\
s
\\
xa0]+/, '')
"
,
RIGHT
:
"
.replace(/[
\\
s
\\
xa0]+$/, ''
)
"
,
BOTH
:
"
.trim()
"
}[
a
.
getFieldValue
(
"
MODE
"
)];
return
[(
Blockly
.
JavaScript
.
valueToCode
(
a
,
"
TEXT
"
,
Blockly
.
JavaScript
.
ORDER_MEMBER
)
||
"
''
"
)
+
b
,
Blockly
.
JavaScript
.
ORDER_FUNCTION_CALL
]};
Blockly
.
JavaScript
.
text_print
=
function
(
a
){
return
"
window.alert(
"
+
(
Blockly
.
JavaScript
.
valueToCode
(
a
,
"
TEXT
"
,
Blockly
.
JavaScript
.
ORDER_NONE
)
||
"
''
"
)
+
"
);
\n
"
};
Blockly
.
JavaScript
.
text_prompt
=
function
(
a
){
var
b
=
"
window.prompt(
"
+
Blockly
.
JavaScript
.
quote_
(
a
.
getFieldValue
(
"
TEXT
"
))
+
"
)
"
;
"
NUMBER
"
==
a
.
getFieldValue
(
"
TYPE
"
)
&&
(
b
=
"
parseFloat(
"
+
b
+
"
)
"
);
return
[
b
,
Blockly
.
JavaScript
.
ORDER_FUNCTION_CALL
]};
Blockly
.
JavaScript
.
text_prompt_ext
=
function
(
a
){
var
b
=
"
window.prompt(
"
+
(
Blockly
.
JavaScript
.
valueToCode
(
a
,
"
TEXT
"
,
Blockly
.
JavaScript
.
ORDER_NONE
)
||
"
''
"
)
+
"
)
"
;
"
NUMBER
"
==
a
.
getFieldValue
(
"
TYPE
"
)
&&
(
b
=
"
parseFloat(
"
+
b
+
"
)
"
);
return
[
b
,
Blockly
.
JavaScript
.
ORDER_FUNCTION_CALL
]};
// Copyright 2012 Google Inc. Apache License 2.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment