[extensions-web] Revert "js: Defer adding plugin to body until after the DOM has been loaded"
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Revert "js: Defer adding plugin to body until after the DOM has been loaded"
- Date: Fri, 23 Mar 2012 16:00:09 +0000 (UTC)
commit 7668437323192e68ea486134f55583b6698a0e1b
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Mar 23 12:59:56 2012 -0300
Revert "js: Defer adding plugin to body until after the DOM has been loaded"
This reverts commit 6e28454400f8cfb6ea21c54c9b6990e52d49bab8.
This broke the site in Firefox, so, let's revert it until I can figure
out what's going on. Too bad Firebug is completely worthless right now...
sweettooth/static/js/dbus.js | 86 ++++++++++++++++++++++--------------------
1 files changed, 45 insertions(+), 41 deletions(-)
---
diff --git a/sweettooth/static/js/dbus.js b/sweettooth/static/js/dbus.js
index 4a1c55e..0a26c90 100644
--- a/sweettooth/static/js/dbus.js
+++ b/sweettooth/static/js/dbus.js
@@ -10,52 +10,56 @@
define({
load: function(name, req, onLoad, config) {
req(['jquery'], function ($) {
- $(document).ready(function() {
- if (!('SweetTooth' in window)) {
- try {
- var MIME_TYPE = 'application/x-gnome-shell-integration';
- var $plg = $('<embed>', { type: MIME_TYPE });
-
- // Netscape plugins are strange: if you make them invisible with
- // CSS or give them 0 width/height, they won't load. Just smack it
- // off-screen so it isn't visible, but still works.
- $plg.css({ position: 'absolute',
- left: '-1000em',
- top: '-1000em' });
-
- $(document.body).append($plg);
-
- // The API is defined on the plugin itself.
- window.SweetTooth = $plg[0];
- } catch (e) {
- // In this case we probably failed the origin checks and
- // the NPAPI plugin spat out an error. Explicitly set the
- // plugin to NULL
- window.SweetTooth = null;
- }
+ if (!('SweetTooth' in window)) {
+ try {
+ var MIME_TYPE = 'application/x-gnome-shell-integration';
+ var $plg = $('<embed>', { type: MIME_TYPE });
+
+ // Netscape plugins are strange: if you make them invisible with
+ // CSS or give them 0 width/height, they won't load. Just smack it
+ // off-screen so it isn't visible, but still works.
+ $plg.css({ position: 'absolute',
+ left: '-1000em',
+ top: '-1000em' });
+
+ // TODO: this may not work if the DOM is not ready
+ // when this call is made. Depending on browsers
+ // you want to support, either listen to
+ // DOMContentLoaded, event, or use $(function(){}), but in
+ // those cases, the full body of this load action should
+ // be in that call.
+ $(document.body).append($plg);
+
+ // The API is defined on the plugin itself.
+ window.SweetTooth = $plg[0];
+ } catch (e) {
+ // In this case we probably failed the origin checks and
+ // the NPAPI plugin spat out an error. Explicitly set the
+ // plugin to NULL
+ window.SweetTooth = null;
}
+ }
- if (name == "API") {
- onLoad(window.SweetTooth);
- return;
+ if (name == "API") {
+ onLoad(window.SweetTooth);
+ return;
+ }
+
+ var apiVersion = undefined;
+
+ try {
+ if (window.SweetTooth) {
+ apiVersion = window.SweetTooth.apiVersion;
}
+ } catch (e) { }
- var apiVersion = undefined;
+ if (!apiVersion)
+ apiVersion = 'dummy';
- try {
- if (window.SweetTooth) {
- apiVersion = window.SweetTooth.apiVersion;
- }
- } catch (e) { }
-
- if (!apiVersion)
- apiVersion = 'dummy';
-
- var scriptname = './versions/' + apiVersion + '/main';
- // requirejs caches response.
- req([scriptname], function(module) {
- onLoad(module);
- });
+ var scriptname = './versions/' + apiVersion + '/main';
+ // requirejs caches response.
+ req([scriptname], function(module) {
+ onLoad(module);
});
});
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]