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
3bce3681
Commit
3bce3681
authored
Jan 07, 2016
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify workspace options by removing svg property.
parent
1facefc3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
23 deletions
+38
-23
core/block_svg.js
core/block_svg.js
+2
-2
core/blockly.js
core/blockly.js
+2
-2
core/inject.js
core/inject.js
+1
-2
core/mutator.js
core/mutator.js
+0
-1
core/scrollbar.js
core/scrollbar.js
+1
-1
core/toolbox.js
core/toolbox.js
+3
-4
core/utils.js
core/utils.js
+1
-2
core/workspace_svg.js
core/workspace_svg.js
+28
-9
No files found.
core/block_svg.js
View file @
3bce3681
...
...
@@ -1154,7 +1154,7 @@ Blockly.BlockSvg.prototype.disposeUiEffect = function() {
clone
.
translateY_
=
xy
.
y
;
clone
.
setAttribute
(
'
transform
'
,
'
translate(
'
+
clone
.
translateX_
+
'
,
'
+
clone
.
translateY_
+
'
)
'
);
this
.
workspace
.
options
.
svg
.
appendChild
(
clone
);
this
.
workspace
.
getParentSvg
()
.
appendChild
(
clone
);
clone
.
bBox_
=
clone
.
getBBox
();
// Start the animation.
Blockly
.
BlockSvg
.
disposeUiStep_
(
clone
,
this
.
RTL
,
new
Date
(),
...
...
@@ -1212,7 +1212,7 @@ Blockly.BlockSvg.prototype.connectionUiEffect = function() {
var
ripple
=
Blockly
.
createSvgElement
(
'
circle
'
,
{
'
cx
'
:
xy
.
x
,
'
cy
'
:
xy
.
y
,
'
r
'
:
0
,
'
fill
'
:
'
none
'
,
'
stroke
'
:
'
#888
'
,
'
stroke-width
'
:
10
},
this
.
workspace
.
options
.
svg
);
this
.
workspace
.
getParentSvg
()
);
// Start the animation.
Blockly
.
BlockSvg
.
connectionUiStep_
(
ripple
,
new
Date
(),
this
.
workspace
.
scale
);
};
...
...
core/blockly.js
View file @
3bce3681
...
...
@@ -254,7 +254,7 @@ Blockly.svgResize = function(workspace) {
while
(
mainWorkspace
.
options
.
parentWorkspace
)
{
mainWorkspace
=
mainWorkspace
.
options
.
parentWorkspace
;
}
var
svg
=
mainWorkspace
.
options
.
svg
;
var
svg
=
mainWorkspace
.
getParentSvg
()
;
var
div
=
svg
.
parentNode
;
if
(
!
div
)
{
// Workspace deteted, or something.
...
...
@@ -517,7 +517,7 @@ Blockly.hideChaff = function(opt_allowToolbox) {
* @this Blockly.WorkspaceSvg
*/
Blockly
.
getMainWorkspaceMetrics_
=
function
()
{
var
svgSize
=
Blockly
.
svgSize
(
this
.
options
.
svg
);
var
svgSize
=
Blockly
.
svgSize
(
this
.
getParentSvg
()
);
if
(
this
.
toolbox_
)
{
svgSize
.
width
-=
this
.
toolbox_
.
width
;
}
...
...
core/inject.js
View file @
3bce3681
...
...
@@ -328,7 +328,6 @@ Blockly.createDom_ = function(container, options) {
// x1, y1, x1, x2 properties will be set later in updateGridPattern_.
}
options
.
gridPattern
=
gridPattern
;
options
.
svg
=
svg
;
return
svg
;
};
...
...
@@ -411,7 +410,7 @@ Blockly.createMainWorkspace_ = function(svg, options) {
*/
Blockly
.
init_
=
function
(
mainWorkspace
)
{
var
options
=
mainWorkspace
.
options
;
var
svg
=
mainWorkspace
.
options
.
svg
;
var
svg
=
mainWorkspace
.
getParentSvg
()
;
// Supress the browser's context menu.
Blockly
.
bindEvent_
(
svg
,
'
contextmenu
'
,
null
,
function
(
e
)
{
...
...
core/mutator.js
View file @
3bce3681
...
...
@@ -102,7 +102,6 @@ Blockly.Mutator.prototype.iconClick_ = function(e) {
Blockly
.
Mutator
.
prototype
.
createEditor_
=
function
()
{
/* Create the editor. Here's the markup that will be generated:
<svg>
<rect class="blocklyMutatorBackground" />
[Workspace]
</svg>
*/
...
...
core/scrollbar.js
View file @
3bce3681
...
...
@@ -369,7 +369,7 @@ Blockly.Scrollbar.prototype.onMouseDownBar_ = function(e) {
e
.
stopPropagation
();
return
;
}
var
mouseXY
=
Blockly
.
mouseToSvg
(
e
,
this
.
workspace_
.
options
.
svg
);
var
mouseXY
=
Blockly
.
mouseToSvg
(
e
,
this
.
workspace_
.
getParentSvg
()
);
var
mouseLocation
=
this
.
horizontal_
?
mouseXY
.
x
:
mouseXY
.
y
;
var
knobXY
=
Blockly
.
getSvgXY_
(
this
.
svgKnob_
,
this
.
workspace_
);
...
...
core/toolbox.js
View file @
3bce3681
...
...
@@ -116,8 +116,7 @@ Blockly.Toolbox.prototype.init = function() {
var
workspaceOptions
=
{
disabledPatternId
:
workspace
.
options
.
disabledPatternId
,
parentWorkspace
:
workspace
,
RTL
:
workspace
.
RTL
,
svg
:
workspace
.
options
.
svg
RTL
:
workspace
.
RTL
};
/**
* @type {!Blockly.Flyout}
...
...
@@ -162,7 +161,7 @@ Blockly.Toolbox.prototype.position = function() {
// Not initialized yet.
return
;
}
var
svg
=
this
.
workspace_
.
options
.
svg
;
var
svg
=
this
.
workspace_
.
getParentSvg
()
;
var
svgPosition
=
goog
.
style
.
getPageOffset
(
svg
);
var
svgSize
=
Blockly
.
svgSize
(
svg
);
if
(
this
.
workspace_
.
RTL
)
{
...
...
@@ -296,7 +295,7 @@ Blockly.Toolbox.prototype.getRect = function() {
// Assumes that the toolbox is on the SVG edge. If this changes
// (e.g. toolboxes in mutators) then this code will need to be more complex.
if
(
this
.
workspace_
.
RTL
)
{
var
svgSize
=
Blockly
.
svgSize
(
this
.
workspace_
.
options
.
svg
);
var
svgSize
=
Blockly
.
svgSize
(
this
.
workspace_
.
getParentSvg
()
);
var
x
=
svgSize
.
width
-
this
.
width
;
}
else
{
var
x
=
-
BIG_NUM
;
...
...
core/utils.js
View file @
3bce3681
...
...
@@ -318,7 +318,7 @@ Blockly.getSvgXY_ = function(element, workspace) {
x
+=
xy
.
x
*
scale
;
y
+=
xy
.
y
*
scale
;
element
=
element
.
parentNode
;
}
while
(
element
&&
element
!=
workspace
.
options
.
svg
);
}
while
(
element
&&
element
!=
workspace
.
getParentSvg
()
);
return
new
goog
.
math
.
Coordinate
(
x
,
y
);
};
...
...
@@ -591,4 +591,3 @@ Blockly.genUid.crypto_ = this.crypto;
*/
Blockly
.
genUid
.
soup_
=
'
!#$%()*+,-./:;=?@[]^_`{|}~
'
+
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
'
;
core/workspace_svg.js
View file @
3bce3681
...
...
@@ -165,8 +165,8 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
if
(
opt_backgroundClass
)
{
/** @type {SVGElement} */
this
.
svgBackground_
=
Blockly
.
createSvgElement
(
'
rect
'
,
{
'
height
'
:
'
100%
'
,
'
width
'
:
'
100%
'
,
'
class
'
:
opt_backgroundClass
},
this
.
svgGroup_
);
{
'
height
'
:
'
100%
'
,
'
width
'
:
'
100%
'
,
'
class
'
:
opt_backgroundClass
},
this
.
svgGroup_
);
if
(
opt_backgroundClass
==
'
blocklyMainBackground
'
)
{
this
.
svgBackground_
.
style
.
fill
=
'
url(#
'
+
this
.
options
.
gridPattern
.
id
+
'
)
'
;
...
...
@@ -242,7 +242,7 @@ Blockly.WorkspaceSvg.prototype.dispose = function() {
}
if
(
!
this
.
options
.
parentWorkspace
)
{
// Top-most workspace. Dispose of the SVG too.
goog
.
dom
.
removeNode
(
this
.
options
.
svg
);
goog
.
dom
.
removeNode
(
this
.
getParentSvg
()
);
}
};
...
...
@@ -340,6 +340,25 @@ Blockly.WorkspaceSvg.prototype.getBubbleCanvas = function() {
return
this
.
svgBubbleCanvas_
;
};
/**
* Get the SVG element that forms the bubble surface.
* @return {!Element} SVG element.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
getParentSvg
=
function
()
{
if
(
this
.
getParentSvg
.
cachedParentSvg_
)
{
return
this
.
getParentSvg
.
cachedParentSvg_
;
}
var
element
=
this
.
svgGroup_
;
while
(
element
)
{
if
(
element
.
tagName
==
'
svg
'
)
{
this
.
getParentSvg
.
cachedParentSvg_
=
element
;
return
element
;
}
element
=
element
.
parentNode
;
}
return
null
;
};
/**
* Translate this workspace to new coordinates.
* @param {number} x Horizontal translation.
...
...
@@ -389,7 +408,7 @@ Blockly.WorkspaceSvg.prototype.getWidth = function() {
* @param {boolean} isVisible True if workspace should be visible.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
setVisible
=
function
(
isVisible
)
{
this
.
options
.
svg
.
style
.
display
=
isVisible
?
'
block
'
:
'
none
'
;
this
.
getParentSvg
()
.
style
.
display
=
isVisible
?
'
block
'
:
'
none
'
;
if
(
this
.
toolbox_
)
{
// Currently does not support toolboxes in mutators.
this
.
toolbox_
.
HtmlDiv
.
style
.
display
=
isVisible
?
'
block
'
:
'
none
'
;
...
...
@@ -562,7 +581,7 @@ Blockly.WorkspaceSvg.prototype.recordDeleteAreas = function() {
*/
Blockly
.
WorkspaceSvg
.
prototype
.
isDeleteArea
=
function
(
e
)
{
var
isDelete
=
false
;
var
mouseXY
=
Blockly
.
mouseToSvg
(
e
,
Blockly
.
mainWorkspace
.
options
.
svg
);
var
mouseXY
=
Blockly
.
mouseToSvg
(
e
,
Blockly
.
mainWorkspace
.
getParentSvg
()
);
var
xy
=
new
goog
.
math
.
Coordinate
(
mouseXY
.
x
,
mouseXY
.
y
);
if
(
this
.
deleteAreaTrash_
)
{
if
(
this
.
deleteAreaTrash_
.
contains
(
xy
))
{
...
...
@@ -640,7 +659,7 @@ Blockly.WorkspaceSvg.prototype.onMouseDown_ = function(e) {
*/
Blockly
.
WorkspaceSvg
.
prototype
.
startDrag
=
function
(
e
,
x
,
y
)
{
// Record the starting offset between the bubble's location and the mouse.
var
point
=
Blockly
.
mouseToSvg
(
e
,
this
.
options
.
svg
);
var
point
=
Blockly
.
mouseToSvg
(
e
,
this
.
getParentSvg
()
);
// Fix scale of mouse event.
point
.
x
/=
this
.
scale
;
point
.
y
/=
this
.
scale
;
...
...
@@ -654,7 +673,7 @@ Blockly.WorkspaceSvg.prototype.startDrag = function(e, x, y) {
* @return {!goog.math.Coordinate} New location of object.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
moveDrag
=
function
(
e
)
{
var
point
=
Blockly
.
mouseToSvg
(
e
,
this
.
options
.
svg
);
var
point
=
Blockly
.
mouseToSvg
(
e
,
this
.
getParentSvg
()
);
// Fix scale of mouse event.
point
.
x
/=
this
.
scale
;
point
.
y
/=
this
.
scale
;
...
...
@@ -672,7 +691,7 @@ Blockly.WorkspaceSvg.prototype.onMouseWheel_ = function(e) {
// TODO: Remove terminateDrag and compensate for coordinate skew during zoom.
Blockly
.
terminateDrag_
();
var
delta
=
e
.
deltaY
>
0
?
-
1
:
1
;
var
position
=
Blockly
.
mouseToSvg
(
e
,
this
.
options
.
svg
);
var
position
=
Blockly
.
mouseToSvg
(
e
,
this
.
getParentSvg
()
);
this
.
zoom
(
position
.
x
,
position
.
y
,
delta
);
e
.
preventDefault
();
};
...
...
@@ -966,7 +985,7 @@ Blockly.WorkspaceSvg.prototype.markFocused = function() {
Blockly
.
WorkspaceSvg
.
prototype
.
zoom
=
function
(
x
,
y
,
type
)
{
var
speed
=
this
.
options
.
zoomOptions
.
scaleSpeed
;
var
metrics
=
this
.
getMetrics
();
var
center
=
this
.
options
.
svg
.
createSVGPoint
();
var
center
=
this
.
getParentSvg
()
.
createSVGPoint
();
center
.
x
=
x
;
center
.
y
=
y
;
center
=
center
.
matrixTransform
(
this
.
getCanvas
().
getCTM
().
inverse
());
...
...
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