From c3931df2ae06edf48983c5e629ba2c1b12721400 Mon Sep 17 00:00:00 2001
From: Neil Fraser
Date: Thu, 7 Apr 2016 16:24:27 -0700
Subject: [PATCH 01/10] Fix shadow block init on headless workspaces.
---
core/connection.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/core/connection.js b/core/connection.js
index 89b4aef27..8f32d746b 100644
--- a/core/connection.js
+++ b/core/connection.js
@@ -543,7 +543,9 @@ Blockly.Connection.prototype.disconnect = function() {
} else {
throw 'Child block does not have output or previous statement.';
}
- blockShadow.initSvg();
+ if (blockShadow.initSvg) {
+ blockShadow.initSvg();
+ }
blockShadow.render(false);
}
From d269f70f953fc5d5aef3090c9caa22a8cfd3716b Mon Sep 17 00:00:00 2001
From: Neil Fraser
Date: Thu, 7 Apr 2016 17:07:02 -0700
Subject: [PATCH 02/10] Don't fire 'click' events when opening bubbles. Fix
groups on context menu deletes.
---
core/events.js | 9 +++++++++
core/widgetdiv.js | 2 --
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/core/events.js b/core/events.js
index bc301ddbe..ee401c99e 100644
--- a/core/events.js
+++ b/core/events.js
@@ -145,6 +145,15 @@ Blockly.Events.filter = function(queueIn, forward) {
event1.newValue = event2.newValue;
queue.splice(j, 1);
j--;
+ } else if (event1.type == Blockly.Events.UI &&
+ event2.element == 'click' &&
+ (event1.element == 'commentOpen' ||
+ event1.element == 'mutatorOpen' ||
+ event1.element == 'warningOpen')) {
+ // Merge change events.
+ event1.newValue = event2.newValue;
+ queue.splice(j, 1);
+ j--;
}
}
}
diff --git a/core/widgetdiv.js b/core/widgetdiv.js
index 804b4fa6b..817d15bac 100644
--- a/core/widgetdiv.js
+++ b/core/widgetdiv.js
@@ -82,7 +82,6 @@ Blockly.WidgetDiv.show = function(newOwner, rtl, dispose) {
Blockly.WidgetDiv.DIV.style.top = xy.y + 'px';
Blockly.WidgetDiv.DIV.style.direction = rtl ? 'rtl' : 'ltr';
Blockly.WidgetDiv.DIV.style.display = 'block';
- Blockly.Events.setGroup(true);
};
/**
@@ -98,7 +97,6 @@ Blockly.WidgetDiv.hide = function() {
Blockly.WidgetDiv.dispose_ && Blockly.WidgetDiv.dispose_();
Blockly.WidgetDiv.dispose_ = null;
goog.dom.removeChildren(Blockly.WidgetDiv.DIV);
- Blockly.Events.setGroup(false);
}
};
From bb2214581c1bc4dc0aaf967751a08370edd691dd Mon Sep 17 00:00:00 2001
From: Neil Fraser
Date: Fri, 8 Apr 2016 18:40:20 -0700
Subject: [PATCH 03/10] Corrections to ms.
---
demos/code/msg/ms.js | 4 ++--
demos/plane/generated/ms.js | 6 +++---
demos/plane/xlf/translated_msgs_ms.xlf | 8 ++++----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/demos/code/msg/ms.js b/demos/code/msg/ms.js
index f3801cd0b..87ee8deef 100644
--- a/demos/code/msg/ms.js
+++ b/demos/code/msg/ms.js
@@ -3,7 +3,7 @@ var MSG = {
blocks: "Blok",
linkTooltip: "Simpan dan pautkan kepada blok.",
runTooltip: "Jalankan aturcara yang ditetapkan oleh blok-blok di dalam ruang kerja.",
- badCode: "Ralat atur cara:\n%1",
+ badCode: "Ralat aturcara:\n%1",
timeout: "Takat maksimum lelaran pelaksanaan dicecah.",
trashTooltip: "Buang semua Blok.",
catLogic: "Logik",
@@ -20,5 +20,5 @@ var MSG = {
linkAlert: "Kongsikan blok-blok anda dengan pautan ini:\n\n%1",
hashError: "Maaf, '%1' tidak berpadanan dengan sebarang aturcara yang disimpan.",
xmlError: "Fail simpanan anda tidak dapat dimuatkan. Jangan-jangan ia dicipta dengan versi Blockly yang berlainan?",
- badXml: "Ralat ketika menghuraian XML:\n%1\n\nPilih 'OK' untuk melucutkan suntingan anda atau 'Batal' untuk bersambung menyunting XML-nya."
+ badXml: "Ralat ketika menghuraikan XML:\n%1\n\nPilih 'OK' untuk melucutkan suntingan anda atau 'Batal' untuk bersambung menyunting XML-nya."
};
diff --git a/demos/plane/generated/ms.js b/demos/plane/generated/ms.js
index 3641f6eaa..1a9a447da 100644
--- a/demos/plane/generated/ms.js
+++ b/demos/plane/generated/ms.js
@@ -5,7 +5,7 @@ if (typeof planepage == 'undefined') { var planepage = {}; }
planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
- return '
Baris: %1baris (%1)Baris kelas pertama: %1baris kelas pertama (%1)Baris kelas ke-2: %1baris kelas ke-2 (%1)Tempat duduk: %1?tempat duduk =
';
+ return '
Baris: %1baris (%1)Baris kelas pertama: %1baris kelas pertama (%1)Baris kelas kedua: %1baris kelas kedua (%1)Tempat duduk: %1?tempat duduk =
';
};
@@ -21,10 +21,10 @@ planepage.start = function(opt_data, opt_ignored, opt_ijData) {
output += 'Sebuah kapal terbang mempunyai sebilangan baris tempat duduk penumpang. Setiap baris mengandungi empat tempat duduk.';
break;
case 2:
- output += 'Sebuah kapal terbnag mempunyai tempat duduk di kokpit (untuk juruterbang dan pembantunya) dan sebilangan baris tempat duduk penumpang. Setiap baris mengandungi empat tempat duduk.';
+ output += 'Sebuah kapal terbang mempunyai tempat duduk di kokpit (untuk juruterbang dan pembantunya) dan sebilangan baris tempat duduk penumpang. Setiap baris mengandungi empat tempat duduk.';
break;
case 3:
- output += 'Sebuah kapal terbnag mempunyai tempat duduk di kokpit (untuk juruterbang dan pembantunya) dan sebilangan baris tempat duduk penumpang kelas pertama dan kelas kedua. Setiap baris kelas pertama mengandungi empat tempat duduk. Setiap baris kelas pertama mengandungi lima tempat duduk.';
+ output += 'Sebuah kapal terbang mempunyai tempat duduk di kokpit (untuk juruterbang dan pembantunya) dan sebilangan baris tempat duduk penumpang kelas pertama dan kelas kedua. Setiap baris kelas pertama mengandungi empat tempat duduk. Setiap baris kelas pertama mengandungi lima tempat duduk.';
break;
}
output += '
Wujudkan formula (di bawah) yang mengira jumlah tempat duduk di dalam kapal terbang sedangkan baris-barisnya diubah (di atas).
Export a Blockly program into JavaScript, Python, PHP, Dart, Lua or XML.
+
Export a Blockly program into JavaScript, Python, PHP, Lua, Dart, or XML.
diff --git a/msg/js/lb.js b/msg/js/lb.js
index 226c85cb3..dcac899f4 100644
--- a/msg/js/lb.js
+++ b/msg/js/lb.js
@@ -11,7 +11,7 @@ Blockly.Msg.AUTH = "Please authorize this app to enable your work to be saved an
Blockly.Msg.CHANGE_VALUE_TITLE = "Wäert änneren:";
Blockly.Msg.CHAT = "Mat ärem Mataarbechter chatten an deem Dir an dës Këscht tippt!";
Blockly.Msg.CLEAN_UP = "Bléck opraumen";
-Blockly.Msg.COLLAPSE_ALL = "Collapse Blocks"; // untranslated
+Blockly.Msg.COLLAPSE_ALL = "Bléck zesummeklappen";
Blockly.Msg.COLLAPSE_BLOCK = "Block zesummeklappen";
Blockly.Msg.COLOUR_BLEND_COLOUR1 = "Faarf 1";
Blockly.Msg.COLOUR_BLEND_COLOUR2 = "Faarf 2";
@@ -20,7 +20,7 @@ Blockly.Msg.COLOUR_BLEND_RATIO = "ratio";
Blockly.Msg.COLOUR_BLEND_TITLE = "mëschen";
Blockly.Msg.COLOUR_BLEND_TOOLTIP = "Blends two colours together with a given ratio (0.0 - 1.0)."; // untranslated
Blockly.Msg.COLOUR_PICKER_HELPURL = "https://en.wikipedia.org/wiki/Color"; // untranslated
-Blockly.Msg.COLOUR_PICKER_TOOLTIP = "Wielt eng Faarf vun der Palette.";
+Blockly.Msg.COLOUR_PICKER_TOOLTIP = "Sicht eng Faarf an der Palette eraus.";
Blockly.Msg.COLOUR_RANDOM_HELPURL = "http://randomcolour.com"; // untranslated
Blockly.Msg.COLOUR_RANDOM_TITLE = "zoufälleg Faarf";
Blockly.Msg.COLOUR_RANDOM_TOOLTIP = "Eng zoufälleg Faarf eraussichen.";
@@ -40,7 +40,7 @@ Blockly.Msg.CONTROLS_FOREACH_HELPURL = "https://github.com/google/blockly/wiki/L
Blockly.Msg.CONTROLS_FOREACH_TITLE = "fir all Element %1 an der Lëscht %2";
Blockly.Msg.CONTROLS_FOREACH_TOOLTIP = "For each item in a list, set the variable '%1' to the item, and then do some statements."; // untranslated
Blockly.Msg.CONTROLS_FOR_HELPURL = "https://github.com/google/blockly/wiki/Loops#count-with"; // untranslated
-Blockly.Msg.CONTROLS_FOR_TITLE = "count with %1 from %2 to %3 by %4"; // untranslated
+Blockly.Msg.CONTROLS_FOR_TITLE = "zielt mat %1 vun %2 bis %3 mat %4";
Blockly.Msg.CONTROLS_FOR_TOOLTIP = "Have the variable '%1' take on the values from the start number to the end number, counting by the specified interval, and do the specified blocks."; // untranslated
Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP = "Add a condition to the if block."; // untranslated
Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP = "Add a final, catch-all condition to the if block."; // untranslated
@@ -54,19 +54,19 @@ Blockly.Msg.CONTROLS_IF_TOOLTIP_2 = "If a value is true, then do the first block
Blockly.Msg.CONTROLS_IF_TOOLTIP_3 = "If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements."; // untranslated
Blockly.Msg.CONTROLS_IF_TOOLTIP_4 = "If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements. If none of the values are true, do the last block of statements."; // untranslated
Blockly.Msg.CONTROLS_REPEAT_HELPURL = "https://en.wikipedia.org/wiki/For_loop"; // untranslated
-Blockly.Msg.CONTROLS_REPEAT_INPUT_DO = "maachen";
-Blockly.Msg.CONTROLS_REPEAT_TITLE = "%1 mol widderhuelen";
+Blockly.Msg.CONTROLS_REPEAT_INPUT_DO = "maach";
+Blockly.Msg.CONTROLS_REPEAT_TITLE = "%1-mol widderhuelen";
Blockly.Msg.CONTROLS_REPEAT_TOOLTIP = "Do some statements several times."; // untranslated
Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL = "https://github.com/google/blockly/wiki/Loops#repeat"; // untranslated
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = "widderhuele bis";
-Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE = "repeat while"; // untranslated
-Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = "While a value is false, then do some statements."; // untranslated
-Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = "While a value is true, then do some statements."; // untranslated
+Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE = "Widderhuel soulaang";
+Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = "Féiert d'Uweisungen aus, soulaang wéi de Wäert falsch ass.";
+Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = "Féiert d'Uweisungen aus, soulaang wéi de Wäert richteg ass";
Blockly.Msg.DELETE_ALL_BLOCKS = "Delete all %1 blocks?"; // untranslated
Blockly.Msg.DELETE_BLOCK = "Block läschen";
Blockly.Msg.DELETE_X_BLOCKS = "%1 Bléck läschen";
Blockly.Msg.DISABLE_BLOCK = "Block desaktivéieren";
-Blockly.Msg.DUPLICATE_BLOCK = "Duplizéieren";
+Blockly.Msg.DUPLICATE_BLOCK = "Eng Kopie maachen";
Blockly.Msg.ENABLE_BLOCK = "Block aktivéieren";
Blockly.Msg.EXPAND_ALL = "Bléck opklappen";
Blockly.Msg.EXPAND_BLOCK = "Block opklappen";
@@ -171,14 +171,14 @@ Blockly.Msg.LOGIC_OPERATION_HELPURL = "https://github.com/google/blockly/wiki/Lo
Blockly.Msg.LOGIC_OPERATION_OR = "oder";
Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND = "Return true if both inputs are true."; // untranslated
Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR = "Return true if at least one of the inputs is true."; // untranslated
-Blockly.Msg.LOGIC_TERNARY_CONDITION = "test";
+Blockly.Msg.LOGIC_TERNARY_CONDITION = "Test";
Blockly.Msg.LOGIC_TERNARY_HELPURL = "https://en.wikipedia.org/wiki/%3F:";
Blockly.Msg.LOGIC_TERNARY_IF_FALSE = "wa falsch";
Blockly.Msg.LOGIC_TERNARY_IF_TRUE = "wa wouer";
Blockly.Msg.LOGIC_TERNARY_TOOLTIP = "Check the condition in 'test'. If the condition is true, returns the 'if true' value; otherwise returns the 'if false' value."; // untranslated
Blockly.Msg.MATH_ADDITION_SYMBOL = "+"; // untranslated
Blockly.Msg.MATH_ARITHMETIC_HELPURL = "https://en.wikipedia.org/wiki/Arithmetic"; // untranslated
-Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD = "Gëtt d'Zomme vun zwou Zuelen.";
+Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD = "D'Produkt vun den zwou Zuelen zréckginn.";
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE = "Return the quotient of the two numbers."; // untranslated
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS = "Return the difference of the two numbers."; // untranslated
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY = "D'Produkt vun den zwou Zuelen zréckginn.";
@@ -195,7 +195,7 @@ Blockly.Msg.MATH_DIVISION_SYMBOL = "÷"; // untranslated
Blockly.Msg.MATH_IS_DIVISIBLE_BY = "is divisible by"; // untranslated
Blockly.Msg.MATH_IS_EVEN = "ass gerued";
Blockly.Msg.MATH_IS_NEGATIVE = "ass negativ";
-Blockly.Msg.MATH_IS_ODD = "ass net gerued";
+Blockly.Msg.MATH_IS_ODD = "ass ongerued";
Blockly.Msg.MATH_IS_POSITIVE = "ass positiv";
Blockly.Msg.MATH_IS_PRIME = "ass eng Primzuel";
Blockly.Msg.MATH_IS_TOOLTIP = "Check if a number is an even, odd, prime, whole, positive, negative, or if it is divisible by certain number. Returns true or false."; // untranslated
@@ -235,7 +235,7 @@ Blockly.Msg.MATH_ROUND_OPERATOR_ROUND = "opronnen";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN = "ofronnen";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP = "opronnen";
Blockly.Msg.MATH_ROUND_TOOLTIP = "Eng Zuel op- oder ofronnen.";
-Blockly.Msg.MATH_SINGLE_HELPURL = "https://en.wikipedia.org/wiki/Square_root";
+Blockly.Msg.MATH_SINGLE_HELPURL = "https://lb.wikipedia.org/wiki/Racine carrée";
Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE = "absolut";
Blockly.Msg.MATH_SINGLE_OP_ROOT = "Quadratwuerzel";
Blockly.Msg.MATH_SINGLE_TOOLTIP_ABS = "Return the absolute value of a number."; // untranslated
@@ -290,7 +290,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function."; //
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "inputs"; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Widderhuelen";
-Blockly.Msg.REMOVE_COMMENT = "Bemierkunge ewechhuelen";
+Blockly.Msg.REMOVE_COMMENT = "Bemierkung ewechhuelen";
Blockly.Msg.RENAME_VARIABLE = "Variabel ëmbenennen...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "All '%1' Variabelen ëmbenennen op:";
Blockly.Msg.TEXT_APPEND_APPENDTEXT = "Text drunhänken";
diff --git a/tests/generators/index.html b/tests/generators/index.html
index e168a326a..fcff572e8 100644
--- a/tests/generators/index.html
+++ b/tests/generators/index.html
@@ -38,17 +38,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -60,6 +49,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -78,7 +77,8 @@ var workspace = null;
function start() {
workspace = Blockly.inject('blocklyDiv',
- {media: '../../media/', toolbox: document.getElementById('toolbox')});
+ {media: '../../media/',
+ toolbox: document.getElementById('toolbox')});
}
function loadXml() {
@@ -161,13 +161,13 @@ function toPhp() {
setOutput(code);
}
-function toDart() {
- var code = Blockly.Dart.workspaceToCode(workspace);
+function toLua() {
+ var code = Blockly.Lua.workspaceToCode(workspace);
setOutput(code);
}
-function toLua() {
- var code = Blockly.Lua.workspaceToCode(workspace);
+function toDart() {
+ var code = Blockly.Dart.workspaceToCode(workspace);
setOutput(code);
}
@@ -303,8 +303,8 @@ h1 {
-
+
diff --git a/tests/playground.html b/tests/playground.html
index 3e5863deb..f6ac446c2 100644
--- a/tests/playground.html
+++ b/tests/playground.html
@@ -13,15 +13,6 @@
-
-
-
-
-
-
-
-
-
@@ -31,15 +22,15 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -49,6 +40,15 @@
+
+
+
+
+
+
+
+
+
@@ -578,9 +578,9 @@ h1 {
-
-
+
+
From e39a0b70692f89c83493371f141e82010f7c6e7c Mon Sep 17 00:00:00 2001
From: Katelyn Mann
Date: Mon, 11 Apr 2016 15:31:11 -0700
Subject: [PATCH 05/10] Add event preventDefault() calls to the end of zoom
button handlers so the browser doesn't try to handle them itself. This keeps
it from selecting text on double clicks.
---
core/workspace_svg.js | 1 +
core/zoom_controls.js | 2 ++
2 files changed, 3 insertions(+)
diff --git a/core/workspace_svg.js b/core/workspace_svg.js
index 311126e30..7d321ea72 100644
--- a/core/workspace_svg.js
+++ b/core/workspace_svg.js
@@ -1099,6 +1099,7 @@ Blockly.WorkspaceSvg.prototype.zoomReset = function(e) {
}
// This event has been handled. Don't start a workspace drag.
e.stopPropagation();
+ e.preventDefault();
};
/**
diff --git a/core/zoom_controls.js b/core/zoom_controls.js
index 31a0b2126..f745c9c21 100644
--- a/core/zoom_controls.js
+++ b/core/zoom_controls.js
@@ -166,10 +166,12 @@ Blockly.ZoomControls.prototype.createDom = function() {
Blockly.bindEvent_(zoominSvg, 'mousedown', null, function(e) {
workspace.zoomCenter(1);
e.stopPropagation(); // Don't start a workspace scroll.
+ e.preventDefault();
});
Blockly.bindEvent_(zoomoutSvg, 'mousedown', null, function(e) {
workspace.zoomCenter(-1);
e.stopPropagation(); // Don't start a workspace scroll.
+ e.preventDefault();
});
return this.svgGroup_;
From 1a9d66e3d4a7c6b3c5e3c5721fd3ca8ce25bb96b Mon Sep 17 00:00:00 2001
From: Neil Fraser
Date: Mon, 11 Apr 2016 17:25:48 -0700
Subject: [PATCH 06/10] Google open source policy compliance.
---
COPYING => LICENSE | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename COPYING => LICENSE (100%)
diff --git a/COPYING b/LICENSE
similarity index 100%
rename from COPYING
rename to LICENSE
From b5a2f75ceeb4831933ef4c5e4e864edeecef565f Mon Sep 17 00:00:00 2001
From: Neil Fraser
Date: Wed, 13 Apr 2016 15:54:05 -0700
Subject: [PATCH 07/10] Add tooltips to input holes in flyout.
---
core/flyout.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/core/flyout.js b/core/flyout.js
index 84bcbb810..f960bafba 100644
--- a/core/flyout.js
+++ b/core/flyout.js
@@ -426,6 +426,8 @@ Blockly.Flyout.prototype.show = function(xmlList) {
// Create an invisible rectangle under the block to act as a button. Just
// using the block as a button is poor, since blocks have holes in them.
var rect = Blockly.createSvgElement('rect', {'fill-opacity': 0}, null);
+ rect.tooltip = block;
+ Blockly.Tooltip.bindMouseEvents(rect);
// Add the rectangles under the blocks, so that the blocks' tooltips work.
this.workspace_.getCanvas().insertBefore(rect, block.getSvgRoot());
block.flyoutRect_ = rect;
From 36e0764e577397d451c2270861c3ecbff36891a6 Mon Sep 17 00:00:00 2001
From: Neil Fraser
Date: Thu, 14 Apr 2016 00:23:17 -0700
Subject: [PATCH 08/10] Fix zoomToFit if there are no scrollbars. Issue #325.
---
core/workspace_svg.js | 129 ++++++++++++++++++++++--------------------
1 file changed, 67 insertions(+), 62 deletions(-)
diff --git a/core/workspace_svg.js b/core/workspace_svg.js
index e5d758488..3614e65ed 100644
--- a/core/workspace_svg.js
+++ b/core/workspace_svg.js
@@ -1000,27 +1000,18 @@ Blockly.WorkspaceSvg.prototype.zoom = function(x, y, type) {
} else if (newScale < this.options.zoomOptions.minScale) {
scaleChange = this.options.zoomOptions.minScale / this.scale;
}
- var matrix = canvas.getCTM()
- .translate(x * (1 - scaleChange), y * (1 - scaleChange))
- .scale(scaleChange);
- // newScale and matrix.a should be identical (within a rounding error).
- if (this.scale == matrix.a) {
+ if (this.scale == newScale) {
return; // No change in zoom.
}
- this.scale = matrix.a;
- this.scrollX = matrix.e - metrics.absoluteLeft;
- this.scrollY = matrix.f - metrics.absoluteTop;
- this.updateGridPattern_();
if (this.scrollbar) {
- this.scrollbar.resize();
- } else {
- this.translate(0, 0);
- }
- Blockly.hideChaff(false);
- if (this.flyout_) {
- // No toolbox, resize flyout.
- this.flyout_.reflow();
+ var matrix = canvas.getCTM()
+ .translate(x * (1 - scaleChange), y * (1 - scaleChange))
+ .scale(scaleChange);
+ // newScale and matrix.a should be identical (within a rounding error).
+ this.scrollX = matrix.e - metrics.absoluteLeft;
+ this.scrollY = matrix.f - metrics.absoluteTop;
}
+ this.setScale(newScale);
};
/**
@@ -1038,40 +1029,27 @@ Blockly.WorkspaceSvg.prototype.zoomCenter = function(type) {
* Zoom the blocks to fit in the workspace if possible.
*/
Blockly.WorkspaceSvg.prototype.zoomToFit = function() {
- var workspaceBBox = this.svgBackground_.getBBox();
- var blocksBBox = this.svgBlockCanvas_.getBBox();
- var workspaceWidth = workspaceBBox.width - this.toolbox_.width -
- Blockly.Scrollbar.scrollbarThickness;
- var workspaceHeight = workspaceBBox.height -
- Blockly.Scrollbar.scrollbarThickness;
- var blocksWidth = blocksBBox.width;
- var blocksHeight = blocksBBox.height;
- if (blocksWidth == 0) {
+ var metrics = this.getMetrics();
+ var blocksBox = this.getBlocksBoundingBox();
+ var blocksWidth = blocksBox.width;
+ var blocksHeight = blocksBox.height;
+ if (!blocksWidth) {
return; // Prevents zooming to infinity.
}
+ var workspaceWidth = metrics.viewWidth;
+ var workspaceHeight = metrics.viewHeight;
+ if (this.flyout_) {
+ workspaceWidth -= this.flyout_.width_;
+ }
+ if (!this.scrollbar) {
+ // Orgin point of 0,0 is fixed, blocks will not scroll to center.
+ blocksWidth += metrics.contentLeft;
+ blocksHeight += metrics.contentTop;
+ }
var ratioX = workspaceWidth / blocksWidth;
var ratioY = workspaceHeight / blocksHeight;
- var ratio = Math.min(ratioX, ratioY);
- var speed = this.options.zoomOptions.scaleSpeed;
- var numZooms = Math.floor(Math.log(ratio) / Math.log(speed));
- var newScale = Math.pow(speed, numZooms);
- if (newScale > this.options.zoomOptions.maxScale) {
- newScale = this.options.zoomOptions.maxScale;
- } else if (newScale < this.options.zoomOptions.minScale) {
- newScale = this.options.zoomOptions.minScale;
- }
- this.scale = newScale;
- this.updateGridPattern_();
- this.scrollbar.resize();
- Blockly.hideChaff(false);
- if (this.flyout_) {
- // No toolbox, resize flyout.
- this.flyout_.reflow();
- }
- // Center the workspace.
- var metrics = this.getMetrics();
- this.scrollbar.set((metrics.contentWidth - metrics.viewWidth) / 2,
- (metrics.contentHeight - metrics.viewHeight) / 2);
+ this.setScale(Math.min(ratioX, ratioY));
+ this.scrollCenter_();
};
/**
@@ -1079,27 +1057,54 @@ Blockly.WorkspaceSvg.prototype.zoomToFit = function() {
* @param {!Event} e Mouse down event.
*/
Blockly.WorkspaceSvg.prototype.zoomReset = function(e) {
- this.scale = 1;
+ this.setScale(1);
+ this.scrollCenter_();
+ // This event has been handled. Don't start a workspace drag.
+ e.stopPropagation();
+};
+
+/**
+ * Center the workspace.
+ * @private
+ */
+Blockly.WorkspaceSvg.prototype.scrollCenter_ = function() {
+ if (!this.scrollbar) {
+ // Can't center a non-scrolling workspace.
+ return;
+ }
+ var metrics = this.getMetrics();
+ var x = (metrics.contentWidth - metrics.viewWidth) / 2;
+ if (this.flyout_) {
+ x -= this.flyout_.width_ / 2;
+ }
+ var y = (metrics.contentHeight - metrics.viewHeight) / 2;
+ this.scrollbar.set(x, y);
+};
+
+/**
+ * Set the workspace's zoom factor.
+ * @param {number} newScale Zoom factor.
+ */
+Blockly.WorkspaceSvg.prototype.setScale = function(newScale) {
+ if (this.options.zoomOptions.maxScale &&
+ newScale > this.options.zoomOptions.maxScale) {
+ newScale = this.options.zoomOptions.maxScale;
+ } else if (this.options.zoomOptions.minScale &&
+ newScale < this.options.zoomOptions.minScale) {
+ newScale = this.options.zoomOptions.minScale;
+ }
+ this.scale = newScale;
this.updateGridPattern_();
+ if (this.scrollbar) {
+ this.scrollbar.resize();
+ } else {
+ this.translate(this.scrollX, this.scrollY);
+ }
Blockly.hideChaff(false);
if (this.flyout_) {
// No toolbox, resize flyout.
this.flyout_.reflow();
}
- // Zoom level has changed, update the scrollbars.
- if (this.scrollbar) {
- this.scrollbar.resize();
- }
- // Center the workspace.
- var metrics = this.getMetrics();
- if (this.scrollbar) {
- this.scrollbar.set((metrics.contentWidth - metrics.viewWidth) / 2,
- (metrics.contentHeight - metrics.viewHeight) / 2);
- } else {
- this.translate(0, 0);
- }
- // This event has been handled. Don't start a workspace drag.
- e.stopPropagation();
};
/**
From 8c3de3a581ce8f61b9ea8cd32c3cfd20e40eeab5 Mon Sep 17 00:00:00 2001
From: Neil Fraser
Date: Thu, 14 Apr 2016 00:29:13 -0700
Subject: [PATCH 09/10] Routine recompile.
---
blockly_compressed.js | 635 ++++++++++++++++++++--------------------
blockly_uncompressed.js | 12 +-
msg/js/fa.js | 4 +-
msg/js/hu.js | 4 +-
msg/js/is.js | 4 +-
msg/js/lb.js | 22 +-
msg/js/zh-hans.js | 10 +-
msg/json/qqq.json | 2 +-
msg/messages.js | 4 +-
9 files changed, 348 insertions(+), 349 deletions(-)
diff --git a/blockly_compressed.js b/blockly_compressed.js
index ca3644a9f..e2fe56d2d 100644
--- a/blockly_compressed.js
+++ b/blockly_compressed.js
@@ -8,8 +8,8 @@ goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/;goog.module=function(a){if(!
goog.module.get=function(a){return goog.module.getInternal_(a)};goog.module.getInternal_=function(a){if(!COMPILED)return goog.isProvided_(a)?a in goog.loadedModules_?goog.loadedModules_[a]:goog.getObjectByName(a):null};goog.moduleLoaderState_=null;goog.isInModuleLoader_=function(){return null!=goog.moduleLoaderState_};
goog.module.declareLegacyNamespace=function(){if(!COMPILED&&!goog.isInModuleLoader_())throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module");if(!COMPILED&&!goog.moduleLoaderState_.moduleName)throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace.");goog.moduleLoaderState_.declareLegacyNamespace=!0};
goog.setTestOnly=function(a){if(goog.DISALLOW_TEST_ONLY_CODE)throw a=a||"",Error("Importing test-only code into non-debug environment"+(a?": "+a:"."));};goog.forwardDeclare=function(a){};COMPILED||(goog.isProvided_=function(a){return a in goog.loadedModules_||!goog.implicitNamespaces_[a]&&goog.isDefAndNotNull(goog.getObjectByName(a))},goog.implicitNamespaces_={"goog.module":!0});
-goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,e;e=c.shift();)if(goog.isDefAndNotNull(d[e]))d=d[e];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]};
-goog.addDependency=function(a,b,c,d){if(goog.DEPENDENCIES_ENABLED){var e;a=a.replace(/\\/g,"/");var f=goog.dependencies_;d&&"boolean"!==typeof d||(d=d?{module:"goog"}:{});for(var g=0;e=b[g];g++)f.nameToPath[e]=a,f.pathIsModule[a]="goog"==d.module;for(d=0;b=c[d];d++)a in f.requires||(f.requires[a]={}),f.requires[a][b]=!0}};goog.ENABLE_DEBUG_LOADER=!0;goog.logToConsole_=function(a){goog.global.console&&goog.global.console.error(a)};
+goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,f;f=c.shift();)if(goog.isDefAndNotNull(d[f]))d=d[f];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]};
+goog.addDependency=function(a,b,c,d){if(goog.DEPENDENCIES_ENABLED){var f;a=a.replace(/\\/g,"/");var g=goog.dependencies_;d&&"boolean"!==typeof d||(d=d?{module:"goog"}:{});for(var h=0;f=b[h];h++)g.nameToPath[f]=a,g.pathIsModule[a]="goog"==d.module;for(d=0;b=c[d];d++)a in g.requires||(g.requires[a]={}),g.requires[a][b]=!0}};goog.ENABLE_DEBUG_LOADER=!0;goog.logToConsole_=function(a){goog.global.console&&goog.global.console.error(a)};
goog.require=function(a){if(!COMPILED){goog.ENABLE_DEBUG_LOADER&&goog.IS_OLD_IE_&&goog.maybeProcessDeferredDep_(a);if(goog.isProvided_(a))return goog.isInModuleLoader_()?goog.module.getInternal_(a):null;if(goog.ENABLE_DEBUG_LOADER){var b=goog.getPathFromDeps_(a);if(b)return goog.writeScripts_(b),null}a="goog.require could not find: "+a;goog.logToConsole_(a);throw Error(a);}};goog.basePath="";goog.nullFunction=function(){};
goog.abstractMethod=function(){throw Error("unimplemented abstract method");};goog.addSingletonGetter=function(a){a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.LOAD_MODULE_USING_EVAL=!0;goog.SEAL_MODULE_EXPORTS=goog.DEBUG;goog.loadedModules_={};goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER;
goog.DEPENDENCIES_ENABLED&&(goog.dependencies_={pathIsModule:{},nameToPath:{},requires:{},visited:{},written:{},deferred:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return null!=a&&"write"in a},goog.findBasePath_=function(){if(goog.isDef(goog.global.CLOSURE_BASE_PATH))goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("SCRIPT"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d=-1==d?c.length:
@@ -19,8 +19,8 @@ goog.maybeProcessDeferredPath_(goog.basePath+a))},goog.isDeferredModule_=functio
goog.dependencies_.deferred[a];delete goog.dependencies_.deferred[a];goog.globalEval(b)}},goog.loadModuleFromUrl=function(a){goog.retrieveAndExecModule_(a)},goog.loadModule=function(a){var b=goog.moduleLoaderState_;try{goog.moduleLoaderState_={moduleName:void 0,declareLegacyNamespace:!1};var c;if(goog.isFunction(a))c=a.call(goog.global,{});else if(goog.isString(a))c=goog.loadModuleFromSource_.call(goog.global,a);else throw Error("Invalid module definition");var d=goog.moduleLoaderState_.moduleName;
if(!goog.isString(d)||!d)throw Error('Invalid module name "'+d+'"');goog.moduleLoaderState_.declareLegacyNamespace?goog.constructNamespace_(d,c):goog.SEAL_MODULE_EXPORTS&&Object.seal&&Object.seal(c);goog.loadedModules_[d]=c}finally{goog.moduleLoaderState_=b}},goog.loadModuleFromSource_=function(a){eval(a);return{}},goog.writeScriptSrcNode_=function(a){goog.global.document.write('