Browse Source

toolbar button behavior back to previous one

Michael 10 năm trước cách đây
mục cha
commit
22ca4a34fa
33 tập tin đã thay đổi với 95 bổ sung121 xóa
  1. 10 3
      src/allplatforms/classes/SuperGlue.js
  2. 6 0
      src/allplatforms/injections/notSGpage.js
  3. 1 17
      src/chromium/background.js
  4. 21 18
      src/chromium/content_probeForSG.js
  5. BIN
      src/chromium/icon-19-powerOff.png
  6. 0 0
      src/chromium/icon-19.png
  7. BIN
      src/chromium/icon-38-powerOff.png
  8. 0 0
      src/chromium/icon-38.png
  9. 3 10
      src/chromium/manifest.json
  10. 21 21
      src/firefox/data/content_probeForSG.js
  11. BIN
      src/firefox/data/icon-16-powerOff.png
  12. 0 0
      src/firefox/data/icon-16.png
  13. BIN
      src/firefox/data/icon-32-powerOff.png
  14. 0 0
      src/firefox/data/icon-32.png
  15. BIN
      src/firefox/data/icon-64-powerOff.png
  16. 0 0
      src/firefox/data/icon-64.png
  17. 33 52
      src/firefox/lib/main.js
  18. BIN
      tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/__init__.pyc
  19. BIN
      tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/_version.pyc
  20. BIN
      tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/bunch.pyc
  21. BIN
      tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/manifest.pyc
  22. BIN
      tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/packaging.pyc
  23. BIN
      tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/preflight.pyc
  24. BIN
      tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/rdf.pyc
  25. BIN
      tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/util.pyc
  26. BIN
      tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/xpi.pyc
  27. BIN
      tools/firefox-addon-sdk-1.16/python-lib/jetpack_sdk_env.pyc
  28. BIN
      tools/firefox-addon-sdk-1.16/python-lib/mozrunner/__init__.pyc
  29. BIN
      tools/firefox-addon-sdk-1.16/python-lib/mozrunner/killableprocess.pyc
  30. BIN
      tools/firefox-addon-sdk-1.16/python-lib/simplejson/__init__.pyc
  31. BIN
      tools/firefox-addon-sdk-1.16/python-lib/simplejson/decoder.pyc
  32. BIN
      tools/firefox-addon-sdk-1.16/python-lib/simplejson/encoder.pyc
  33. BIN
      tools/firefox-addon-sdk-1.16/python-lib/simplejson/scanner.pyc

+ 10 - 3
src/allplatforms/classes/SuperGlue.js

@@ -112,11 +112,18 @@ SC.loadPackage({ 'SuperGlue': {
                         '************************************************',
                         '   SuperGlue editor has successfully started!',
                         '',
-                        '   To access the running system for live',
-                        '   development, enter',
+                        '   To access the running system\'s code',
+                        '   open the bystem browser, just enter',
                         '   > SC.do(\'SCSystemBrowser\', \'open\')',
                         '************************************************'
-                    ].join('\n'))
+                    ].join('\n'));
+
+
+                    // Flash the outlines
+                    SuperGlue.get('document').set({ showOutlines: true });
+                    window.setTimeout(function(){
+                        SuperGlue.get('document').set({ showOutlines: false });
+                    }, 700);
 
                     
                 } catch(error) {

+ 6 - 0
src/allplatforms/injections/notSGpage.js

@@ -0,0 +1,6 @@
+/*
+* I am injected by the browser add-on to signal to the user that the page is not a Superglue page
+*
+*/
+
+alert('This site was not made with SuperGlue.\n\nNavigate to the adress of your Superglue server to get started.')

+ 1 - 17
src/chromium/background.js

@@ -1,7 +1,4 @@
 
-var powerSwitch = false;
-
-
 
 chrome.runtime.onMessage.addListener(
     function(request, sender, sendResponse) {
@@ -45,19 +42,6 @@ chrome.runtime.onMessage.addListener(
 
 chrome.browserAction.onClicked.addListener(function(tab){
 
-    powerSwitch = !powerSwitch;
-
-    chrome.tabs.query({} ,function(tabs){
-        for (var i = 0; i < tabs.length; i++) {
-            chrome.tabs.executeScript(tabs[i].id, { file: 'content_probeForSG.js' });
-        }
-    });
-
-    chrome.browserAction.setIcon({ path: 
-        {
-            '19': 'icon-19' + (powerSwitch ? '-powerOn' : '-powerOff') + '.png',
-            '38': 'icon-38' + (powerSwitch ? '-powerOn' : '-powerOff') + '.png'
-        }
-    });
+    chrome.tabs.executeScript(null, { file: 'content_probeForSG.js' });
 
 });

+ 21 - 18
src/chromium/content_probeForSG.js

@@ -148,8 +148,6 @@
     var activateSuperGlue = function(){
 
 
-
-
         var clipboardCss = document.createElement("link");
         clipboardCss.setAttribute("data-superglue", "editing-interface");
         clipboardCss.setAttribute("rel", "stylesheet");
@@ -216,36 +214,41 @@
         script.setAttribute("src", chrome.extension.getURL("superglue-client/injections/init.js") );
         document.head.appendChild(script);
 
-    };
-
-
     
 
-    
+    };
 
-    chrome.runtime.sendMessage({ contentProbeForSG: "isPowerOn?" }, function(response) {
 
-        if(response.powerOn){
+    var notSGpage = function(){
 
-            // check if page is superglue page
-            if(     document.querySelectorAll('meta[name=generator]').length > 0 
-                &&  document.querySelector('meta[name=generator]').getAttribute('content') === 'SuperGlue'){
+        var script = document.createElement("script");
+        script.setAttribute("data-superglue", "editing-interface");
+        script.setAttribute("type", "text/javascript");
+        script.async = false;
+        script.setAttribute("src", chrome.extension.getURL("superglue-client/injections/notSGpage.js") );
+        document.head.appendChild(script);
+        document.head.removeChild(script);
 
-                // check if editing is active
-                if(     document.querySelectorAll('meta[name=superglue-mode]').length === 0
-                    ||  document.querySelector('meta[name=superglue-mode]').getAttribute('content') !== 'editing'){
+    };
 
-                    activateSuperGlue();
 
-                }
+    // check if page is superglue page
+    if(     document.querySelectorAll('meta[name=generator]').length > 0 
+        &&  document.querySelector('meta[name=generator]').getAttribute('content') === 'SuperGlue'){
+
+        // check if editing is active
+        if(     document.querySelectorAll('meta[name=superglue-mode]').length === 0
+            ||  document.querySelector('meta[name=superglue-mode]').getAttribute('content') !== 'editing'){
 
-            } 
+            activateSuperGlue();
 
         }
 
+    } else { // page is not a superglue page
 
+        notSGpage();
 
-    });
+    }
 
 
     

BIN
src/chromium/icon-19-powerOff.png


+ 0 - 0
src/chromium/icon-19-powerOn.png → src/chromium/icon-19.png


BIN
src/chromium/icon-38-powerOff.png


+ 0 - 0
src/chromium/icon-38-powerOn.png → src/chromium/icon-38.png


+ 3 - 10
src/chromium/manifest.json

@@ -20,8 +20,8 @@
 
     "browser_action": {
         "default_icon": {
-            "19": "icon-19-powerOff.png",
-            "38": "icon-38-powerOff.png"
+            "19": "icon-19.png",
+            "38": "icon-38.png"
         },
         "default_title": "SuperGlue"
     },
@@ -29,14 +29,7 @@
     "background": {
         "scripts":      [ "background.js" ],
         "persistent":   true
-    },
-
-    "content_scripts": [
-        {
-          "matches":    [ "<all_urls>" ],
-          "js":         ["content_probeForSG.js"]
-        }
-    ]
+    }
 
     
 

+ 21 - 21
src/firefox/data/content_probeForSG.js

@@ -205,42 +205,42 @@
         script.setAttribute("src", self.options.dataPath + "injections/init.js" );
         document.head.appendChild(script);
 
+
     };
 
 
-    
+    var notSGpage = function(){
 
-    self.port.on('SuperGlue', function(message) {
-        
+        var script = document.createElement("script");
+        script.setAttribute("data-superglue", "editing-interface");
+        script.setAttribute("type", "text/javascript");
+        script.async = false;
+        script.setAttribute("src", self.options.dataPath + "injections/notSGpage.js" );
+        document.head.appendChild(script);
+        document.head.removeChild(script);
 
-        if(message.powerOn){
+    };
 
-            // check if page is superglue page
-            if(     document.querySelectorAll('meta[name=generator]').length > 0 
-                &&  document.querySelector('meta[name=generator]').getAttribute('content') === 'SuperGlue'){
 
-                // check if editing is active
-                if(     document.querySelectorAll('meta[name=superglue-mode]').length === 0
-                    ||  document.querySelector('meta[name=superglue-mode]').getAttribute('content') !== 'editing'){
 
-                    activateSuperGlue();
+    // check if page is superglue page
+    if(     document.querySelectorAll('meta[name=generator]').length > 0 
+        &&  document.querySelector('meta[name=generator]').getAttribute('content') === 'SuperGlue'){
 
-                }
+        // check if editing is active
+        if(     document.querySelectorAll('meta[name=superglue-mode]').length === 0
+            ||  document.querySelector('meta[name=superglue-mode]').getAttribute('content') !== 'editing'){
 
-            } 
+            activateSuperGlue();
 
         }
 
+    } else { // page is not a superglue page
 
-    });
-    
-    self.port.on('SuperGlueState', function(message){
-        if(message.contentProbeForSG === 'updateStatusOfSG'){
-            self.port.emit('SuperGlue', { contentProbeForSG: 'isPowerOn?' });
-        }
-    })
+        notSGpage();
+
+    }
 
-    self.port.emit('SuperGlue', { contentProbeForSG: 'isPowerOn?' });
 
 
 

BIN
src/firefox/data/icon-16-powerOff.png


+ 0 - 0
src/firefox/data/icon-16-powerOn.png → src/firefox/data/icon-16.png


BIN
src/firefox/data/icon-32-powerOff.png


+ 0 - 0
src/firefox/data/icon-32-powerOn.png → src/firefox/data/icon-32.png


BIN
src/firefox/data/icon-64-powerOff.png


+ 0 - 0
src/firefox/data/icon-64-powerOn.png → src/firefox/data/icon-64.png


+ 33 - 52
src/firefox/lib/main.js

@@ -4,20 +4,8 @@ var buttons     = require('sdk/ui/button/action'),
     self        = require('sdk/self'),
     pageMod     = require('sdk/page-mod'),
     clipboard   = require('sdk/clipboard'),
-    iconsOn     =   {
-                        '16': './icon-16-powerOn.png',
-                        '32': './icon-32-powerOn.png',
-                        '64': './icon-64-powerOn.png'
-                    },
-    iconsOff    =   {
-                        '16': './icon-16-powerOff.png',
-                        '32': './icon-32-powerOff.png',
-                        '64': './icon-64-powerOff.png'
-                    },
-
-    workers     = [],
 
-    powerSwitch = false;
+    workers     = [];
 
 
 function detachWorker(worker, workerArray) {
@@ -27,59 +15,52 @@ function detachWorker(worker, workerArray) {
     }
 }
 
-pageMod.PageMod({
-    include:                [ '*', 'file://*' ],
-    contentScriptFile:      self.data.url('content_probeForSG.js'),
-    contentScriptOptions:   {'dataPath' : self.data.url('superglue-client') + '/'},
-    onAttach: function(worker){
 
-        workers.push(worker);
 
-        worker.port.on('SuperGlue', function(request) {
-            if(request.contentProbeForSG === 'isPowerOn?'){
-                worker.port.emit('SuperGlue', { powerOn: powerSwitch })
-            }
-        });
 
-        worker.port.on('SuperGlueClipboard', function(message){
-
-            if(message.action === 'copy'){
-                clipboard.set(message.value);
-            }
+var button = buttons.ActionButton({
 
-            if(message.action === 'paste'){
-                worker.port.emit('SuperGlueClipboard', {
-                    action: 'pasteResponse',
-                    value:  clipboard.get()
-                })
-            }
+        id:         'superglue-button',
+        label:      'SuperGlue',
+        icon:       {
+                        "16": "./icon-16.png",
+                        "32": "./icon-32.png",
+                        "64": "./icon-64.png"
+                    },
+        onClick:    function() {
 
-        });
+            
+            var worker = tabs.activeTab.attach({
+                contentScriptFile:      self.data.url("content_probeForSG.js"),
+                contentScriptOptions:   { "dataPath" : self.data.url("superglue-client") + "/" }
+            });
 
-        worker.on('detach', function () {
-            detachWorker(this, workers);
-        });
+            
+            workers.push(worker);
 
-    }
-});
+            
 
+            worker.port.on('SuperGlueClipboard', function(message){
 
-var button = buttons.ActionButton({
+                if(message.action === 'copy'){
+                    clipboard.set(message.value);
+                }
 
-        id:         'superglue-button',
-        label:      'SuperGlue',
-        icon:       iconsOff,
-        onClick:    function() {
+                if(message.action === 'paste'){
+                    worker.port.emit('SuperGlueClipboard', {
+                        action: 'pasteResponse',
+                        value:  clipboard.get()
+                    })
+                }
 
-            powerSwitch = !powerSwitch;
+            });
 
-            for(var i = 0, l = workers.length; i < l; i++){
-                workers[i].port.emit('SuperGlueState', { contentProbeForSG: 'updateStatusOfSG' })
-            }
+            worker.on('detach', function () {
+                detachWorker(this, workers);
+            });
 
-            button.state(button, { icon: powerSwitch ? iconsOn : iconsOff });
-            
 
         }
+
     });
 

BIN
tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/__init__.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/_version.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/bunch.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/manifest.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/packaging.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/preflight.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/rdf.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/util.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/cuddlefish/xpi.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/jetpack_sdk_env.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/mozrunner/__init__.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/mozrunner/killableprocess.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/simplejson/__init__.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/simplejson/decoder.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/simplejson/encoder.pyc


BIN
tools/firefox-addon-sdk-1.16/python-lib/simplejson/scanner.pyc