Commit 4973db4d authored by Neil Fraser's avatar Neil Fraser

Use goog.global instead of this or window.

parent 0f8d0120
This diff is collapsed.
This diff is collapsed.
......@@ -523,6 +523,15 @@ Blockly.Block.prototype.setHelpUrl = function(url) {
this.helpUrl = url;
};
/**
* Change the tooltip text for a block.
* @param {string|!Function} newTip Text for tooltip or a parent element to
* link to for its tooltip. May be a function that returns a string.
*/
Blockly.Block.prototype.setTooltip = function(newTip) {
this.tooltip = newTip;
};
/**
* Get the colour of a block.
* @return {number} HSV hue value.
......@@ -605,15 +614,6 @@ Blockly.Block.prototype.setTitleValue = function(newValue, name) {
this.setFieldValue(newValue, name);
};
/**
* Change the tooltip text for a block.
* @param {string|!Function} newTip Text for tooltip or a parent element to
* link to for its tooltip. May be a function that returns a string.
*/
Blockly.Block.prototype.setTooltip = function(newTip) {
this.tooltip = newTip;
};
/**
* Set whether this block can chain onto the bottom of another block.
* @param {boolean} newBoolean True if there can be a previous statement.
......
......@@ -995,7 +995,7 @@ Blockly.BlockSvg.disposeUiStep_ = function(clone) {
var closure = function() {
Blockly.BlockSvg.disposeUiStep_(clone);
};
window.setTimeout(closure, 10);
setTimeout(closure, 10);
}
};
......@@ -1040,7 +1040,7 @@ Blockly.BlockSvg.connectionUiStep_ = function(ripple) {
var closure = function() {
Blockly.BlockSvg.connectionUiStep_(ripple);
};
window.setTimeout(closure, 10);
setTimeout(closure, 10);
}
};
......
......@@ -538,7 +538,7 @@ Blockly.removeAllRanges = function() {
var sel = window.getSelection();
if (sel && sel.removeAllRanges) {
sel.removeAllRanges();
window.setTimeout(function() {
setTimeout(function() {
try {
window.getSelection().removeAllRanges();
} catch (e) {
......@@ -767,9 +767,9 @@ Blockly.getMainWorkspace = function() {
};
// Export symbols that would otherwise be renamed by Closure compiler.
if (!this['Blockly']) {
this['Blockly'] = {};
if (!goog.global['Blockly']) {
goog.global['Blockly'] = {};
}
this['Blockly']['getMainWorkspace'] = Blockly.getMainWorkspace;
this['Blockly']['addChangeListener'] = Blockly.addChangeListener;
this['Blockly']['removeChangeListener'] = Blockly.removeChangeListener;
goog.global['Blockly']['getMainWorkspace'] = Blockly.getMainWorkspace;
goog.global['Blockly']['addChangeListener'] = Blockly.addChangeListener;
goog.global['Blockly']['removeChangeListener'] = Blockly.removeChangeListener;
......@@ -115,7 +115,7 @@ Blockly.Connection.prototype.connect = function(otherConnection) {
}
if (orphanBlock) {
// Unable to reattach orphan. Bump it off to the side.
window.setTimeout(function() {
setTimeout(function() {
orphanBlock.outputConnection.bumpAwayFrom_(otherConnection);
}, Blockly.BUMP_DELAY);
}
......@@ -151,7 +151,7 @@ Blockly.Connection.prototype.connect = function(otherConnection) {
}
if (orphanBlock) {
// Unable to reattach orphan. Bump it off to the side.
window.setTimeout(function() {
setTimeout(function() {
orphanBlock.previousConnection.bumpAwayFrom_(otherConnection);
}, Blockly.BUMP_DELAY);
}
......
......@@ -79,6 +79,8 @@ rtclient.FOLDER_KEY = 'folderId';
* @return {!Object} Parameter object.
*/
rtclient.getParams = function() {
// Be careful with regards to node.js which has no window or location.
var location = goog.global['location'] || {};
var params = {};
function parseParams(fragment) {
// Split up the query string and store in an object.
......@@ -88,12 +90,12 @@ rtclient.getParams = function() {
params[decodeURIComponent(paramStr[0])] = decodeURIComponent(paramStr[1]);
}
}
var hashFragment = this.location && this.location.hash;
var hashFragment = location.hash;
if (hashFragment) {
parseParams(hashFragment);
}
// Opening from Drive will encode the state in a query search parameter.
var searchFragment = this.location && this.location.search;
var searchFragment = location.search;
if (searchFragment) {
parseParams(searchFragment);
}
......
......@@ -538,7 +538,7 @@ Blockly.Realtime.afterAuth_ = function() {
// This is a workaround for the fact that the code in realtime-client-utils.js
// doesn't deal with auth timeouts correctly. So we explicitly reauthorize at
// regular intervals.
window.setTimeout(
setTimeout(
function() {
Blockly.Realtime.realtimeLoader_.authorizer.authorize(
Blockly.Realtime.afterAuth_);
......
......@@ -259,7 +259,7 @@ Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_ = function(e) {
if (node && e.type === goog.events.EventType.TOUCHSTART) {
// Fire asynchronously since onMouseDown takes long enough that the browser
// would fire the default mouse event before this method returns.
window.setTimeout(function() {
setTimeout(function() {
node.onMouseDown(e); // Same behaviour for click and touch.
}, 1);
}
......
......@@ -182,7 +182,7 @@ Blockly.Tooltip.onMouseOver_ = function(e) {
Blockly.Tooltip.element_ = element;
}
// Forget about any immediately preceeding mouseOut event.
window.clearTimeout(Blockly.Tooltip.mouseOutPid_);
clearTimeout(Blockly.Tooltip.mouseOutPid_);
};
/**
......@@ -195,12 +195,12 @@ Blockly.Tooltip.onMouseOut_ = function(e) {
// a mouseOut followed instantly by a mouseOver. Fork off the mouseOut
// event and kill it if a mouseOver is received immediately.
// This way the task only fully executes if mousing into the void.
Blockly.Tooltip.mouseOutPid_ = window.setTimeout(function() {
Blockly.Tooltip.mouseOutPid_ = setTimeout(function() {
Blockly.Tooltip.element_ = null;
Blockly.Tooltip.poisonedElement_ = null;
Blockly.Tooltip.hide();
}, 1);
window.clearTimeout(Blockly.Tooltip.showPid_);
clearTimeout(Blockly.Tooltip.showPid_);
};
/**
......@@ -232,11 +232,11 @@ Blockly.Tooltip.onMouseMove_ = function(e) {
}
} else if (Blockly.Tooltip.poisonedElement_ != Blockly.Tooltip.element_) {
// The mouse moved, clear any previously scheduled tooltip.
window.clearTimeout(Blockly.Tooltip.showPid_);
clearTimeout(Blockly.Tooltip.showPid_);
// Maybe this time the mouse will stay put. Schedule showing of tooltip.
Blockly.Tooltip.lastXY_ = Blockly.mouseToSvg(e);
Blockly.Tooltip.showPid_ =
window.setTimeout(Blockly.Tooltip.show_, Blockly.Tooltip.HOVER_MS);
setTimeout(Blockly.Tooltip.show_, Blockly.Tooltip.HOVER_MS);
}
};
......@@ -250,7 +250,7 @@ Blockly.Tooltip.hide = function() {
Blockly.Tooltip.svgGroup_.style.display = 'none';
}
}
window.clearTimeout(Blockly.Tooltip.showPid_);
clearTimeout(Blockly.Tooltip.showPid_);
};
/**
......
......@@ -288,11 +288,11 @@ Blockly.WorkspaceSvg.prototype.fireChangeEvent = function() {
return;
}
if (this.fireChangeEventPid_) {
window.clearTimeout(this.fireChangeEventPid_);
clearTimeout(this.fireChangeEventPid_);
}
var canvas = this.svgBlockCanvas_;
if (canvas) {
this.fireChangeEventPid_ = window.setTimeout(function() {
this.fireChangeEventPid_ = setTimeout(function() {
Blockly.fireUiEvent(canvas, 'blocklyWorkspaceChange');
}, 0);
}
......
......@@ -416,13 +416,13 @@ Blockly.Xml.deleteNext = function(xmlBlock) {
};
// Export symbols that would otherwise be renamed by Closure compiler.
if (!this['Blockly']) {
this['Blockly'] = {};
if (!goog.global['Blockly']) {
goog.global['Blockly'] = {};
}
if (!this['Blockly']['Xml']) {
this['Blockly']['Xml'] = {};
if (!goog.global['Blockly']['Xml']) {
goog.global['Blockly']['Xml'] = {};
}
this['Blockly']['Xml']['domToText'] = Blockly.Xml.domToText;
this['Blockly']['Xml']['domToWorkspace'] = Blockly.Xml.domToWorkspace;
this['Blockly']['Xml']['textToDom'] = Blockly.Xml.textToDom;
this['Blockly']['Xml']['workspaceToDom'] = Blockly.Xml.workspaceToDom;
goog.global['Blockly']['Xml']['domToText'] = Blockly.Xml.domToText;
goog.global['Blockly']['Xml']['domToWorkspace'] = Blockly.Xml.domToWorkspace;
goog.global['Blockly']['Xml']['textToDom'] = Blockly.Xml.textToDom;
goog.global['Blockly']['Xml']['workspaceToDom'] = Blockly.Xml.workspaceToDom;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment