diff --git a/core/mutator.js b/core/mutator.js index 19a0fe86b..4bd98392b 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -118,20 +118,32 @@ Blockly.Mutator.prototype.createEditor_ = function() { var quarkXml = null; } var workspaceOptions = { + horizontalLayout: false, languageTree: quarkXml, parentWorkspace: this.block_.workspace, pathToMedia: this.block_.workspace.options.pathToMedia, RTL: this.block_.RTL, + hasCategories: false, toolboxPosition: this.block_.RTL ? Blockly.TOOLBOX_AT_RIGHT : Blockly.TOOLBOX_AT_LEFT, - horizontalLayout: false, getMetrics: this.getFlyoutMetrics_.bind(this), setMetrics: null }; this.workspace_ = new Blockly.WorkspaceSvg(workspaceOptions); this.workspace_.isMutator = true; + this.flyout_ = new Blockly.Flyout(); + this.flyout_.autoClose = false; + this.svgDialog_.appendChild(this.flyout_.createDom()); this.svgDialog_.appendChild( - this.workspace_.createDom('blocklyMutatorBackground')); + this.workspace_.createDom('blocklyMutatorBackground')); + + //when mutator bubble is clicked, do not close mutator + Blockly.bindEvent_(this.svgDialog_, 'mousedown', this.svgDialog_, + function(e) { + e.preventDefault(); + e.stopPropagation(); + }); + return this.svgDialog_; }; @@ -165,7 +177,12 @@ Blockly.Mutator.prototype.updateEditable = function() { */ Blockly.Mutator.prototype.resizeBubble_ = function() { var doubleBorderWidth = 2 * Blockly.Bubble.BORDER_WIDTH; - var workspaceSize = this.workspace_.getCanvas().getBBox(); + try { + var workspaceSize = this.workspace_.getCanvas().getBBox(); + } catch (e) { + // Firefox has trouble with hidden elements (Bug 528969). + return; + } var width; if (this.block_.RTL) { width = -workspaceSize.x; diff --git a/core/mutator.js.rej b/core/mutator.js.rej deleted file mode 100644 index 68c9f5e4c..000000000 --- a/core/mutator.js.rej +++ /dev/null @@ -1,63 +0,0 @@ -*************** -*** 80,86 **** - {'class': 'blocklyIconMark', - 'x': Blockly.Icon.RADIUS, - 'y': 2 * Blockly.Icon.RADIUS - 4}, this.iconGroup_); -- this.iconMark_.appendChild(document.createTextNode('\u2605')); - }; - - /** ---- 80,87 ---- - {'class': 'blocklyIconMark', - 'x': Blockly.Icon.RADIUS, - 'y': 2 * Blockly.Icon.RADIUS - 4}, this.iconGroup_); -+ this.iconMark_.appendChild(document.createTextNode('\u2699')); -+ //this.iconMark_.appendChild(document.createTextNode('\u2605')); - }; - - /** -*************** -*** 122,127 **** - this.flyout_.autoClose = false; - this.svgDialog_.appendChild(this.flyout_.createDom()); - this.svgDialog_.appendChild(this.workspace_.createDom()); - return this.svgDialog_; - }; - ---- 123,136 ---- - this.flyout_.autoClose = false; - this.svgDialog_.appendChild(this.flyout_.createDom()); - this.svgDialog_.appendChild(this.workspace_.createDom()); -+ -+ //when mutator bubble is clicked, do not close mutator -+ Blockly.bindEvent_(this.svgDialog_, 'mousedown', this.svgDialog_, -+ function(e) { -+ e.preventDefault(); -+ e.stopPropagation(); -+ }); -+ - return this.svgDialog_; - }; - -*************** -*** 147,153 **** - */ - Blockly.Mutator.prototype.resizeBubble_ = function() { - var doubleBorderWidth = 2 * Blockly.Bubble.BORDER_WIDTH; -- var workspaceSize = this.workspace_.getCanvas().getBBox(); - var flyoutMetrics = this.flyout_.getMetrics_(); - var width; - if (Blockly.RTL) { ---- 156,167 ---- - */ - Blockly.Mutator.prototype.resizeBubble_ = function() { - var doubleBorderWidth = 2 * Blockly.Bubble.BORDER_WIDTH; -+ try { -+ var workspaceSize = this.workspace_.getCanvas().getBBox(); -+ } catch (e) { -+ // Firefox has trouble with hidden elements (Bug 528969). -+ return; -+ } - var flyoutMetrics = this.flyout_.getMetrics_(); - var width; - if (Blockly.RTL) {