[extensions-web/filter-sort-ui: 1/20] js: Don't error out when we don't have the plugin working



commit b6552b867ad201ef5dcbee5aa28227213a39b4d7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Dec 27 21:36:38 2011 -0500

    js: Don't error out when we don't have the plugin working
    
    Instead, stub out the latest additions to the extensions API

 sweettooth/static/js/extensions.js |  120 +++++++++++++++++++-----------------
 1 files changed, 63 insertions(+), 57 deletions(-)
---
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index dbac306..764747d 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -30,63 +30,6 @@ function($, messages, dbusProxy, extensionUtils) {
         });
     };
 
-    $.fn.addOutOfDateIndicator = function() {
-        return this.each(function() {
-            var svm = $(this).data('svm');
-            if (!svm)
-                return;
-
-            var vpk = extensionUtils.grabProperExtensionVersion(svm, dbusProxy.ShellVersion);
-            if (vpk === null) {
-                $(this).
-                    addClass('out-of-date').
-                    attr('title', "This extension is incompatible with your version of GNOME").
-                    tipsy({ gravity: 'c', fade: true });
-            }
-        });
-    };
-
-    $.fn.checkForUpdates = function() {
-        return this.each(function() {
-            var $elem = $(this);
-            var svm = $elem.data('svm');
-            var uuid = $elem.data('uuid');
-            if (!svm)
-                return;
-
-            var vpk = extensionUtils.grabProperExtensionVersion(svm, dbusProxy.ShellVersion);
-
-            if (vpk === null)
-                return;
-
-            function upgrade() {
-                dbusProxy.UninstallExtension(uuid).done(function() {
-                    dbusProxy.InstallExtension(uuid, vpk.version.toString());
-                });
-            }
-
-            dbusProxy.GetExtensionInfo(uuid).done(function(meta) {
-                var extensionName = $elem.find('.extension-name').text();
-                var $upgradeMe = $elem.find('.upgrade-me');
-                if (!meta)
-                    return;
-
-                if (vpk.version > meta.version) {
-                    var msg = "You have version " + meta.version + " of";
-                    msg += "\"" + extensionName + "\"";
-                    msg += ". The latest version is version " + vpk.version;
-                    msg += ". Click here to upgrade.";
-
-                    $upgradeMe.append($('<a>', { href: '#' }).txt(msg).click(upgrade));
-                } else if (vpk.version == meta.version) {
-                    var msg = "You have the latest version of ";
-                    msg += "\"" + extensionName + "\"";
-                    $upgradeMe.text(msg);
-                }
-            });
-        });
-    };
-
     // While technically we shouldn't have mismatched API versions,
     // the plugin doesn't check whether the Shell matches, so if someone
     // is running with an old Shell version but a newer plugin, error out.
@@ -118,6 +61,12 @@ function($, messages, dbusProxy, extensionUtils) {
             $hidden.val('');
         };
 
+        $.fn.addOutOfDateIndicator = function() {
+        };
+
+        $.fn.checkForUpdates = function() {
+        };
+
         return;
     }
 
@@ -376,4 +325,61 @@ function($, messages, dbusProxy, extensionUtils) {
         });
     };
 
+    $.fn.addOutOfDateIndicator = function() {
+        return this.each(function() {
+            var svm = $(this).data('svm');
+            if (!svm)
+                return;
+
+            var vpk = extensionUtils.grabProperExtensionVersion(svm, dbusProxy.ShellVersion);
+            if (vpk === null) {
+                $(this).
+                    addClass('out-of-date').
+                    attr('title', "This extension is incompatible with your version of GNOME").
+                    tipsy({ gravity: 'c', fade: true });
+            }
+        });
+    };
+
+    $.fn.checkForUpdates = function() {
+        return this.each(function() {
+            var $elem = $(this);
+            var svm = $elem.data('svm');
+            var uuid = $elem.data('uuid');
+            if (!svm)
+                return;
+
+            var vpk = extensionUtils.grabProperExtensionVersion(svm, dbusProxy.ShellVersion);
+
+            if (vpk === null)
+                return;
+
+            function upgrade() {
+                dbusProxy.UninstallExtension(uuid).done(function() {
+                    dbusProxy.InstallExtension(uuid, vpk.version.toString());
+                });
+            }
+
+            dbusProxy.GetExtensionInfo(uuid).done(function(meta) {
+                var extensionName = $elem.find('.extension-name').text();
+                var $upgradeMe = $elem.find('.upgrade-me');
+                if (!meta)
+                    return;
+
+                if (vpk.version > meta.version) {
+                    var msg = "You have version " + meta.version + " of";
+                    msg += "\"" + extensionName + "\"";
+                    msg += ". The latest version is version " + vpk.version;
+                    msg += ". Click here to upgrade.";
+
+                    $upgradeMe.append($('<a>', { href: '#' }).txt(msg).click(upgrade));
+                } else if (vpk.version == meta.version) {
+                    var msg = "You have the latest version of ";
+                    msg += "\"" + extensionName + "\"";
+                    $upgradeMe.text(msg);
+                }
+            });
+        });
+    };
+
 });



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]