Permalink
Browse files

Refactored in buffer-extension-shared

  • Loading branch information...
1 parent 7161ad1 commit fb7d4df27e2601a35c9c1d0e6067c46fe51805d0 @tgvashworth tgvashworth committed May 8, 2012
Showing with 14 additions and 1,993 deletions.
  1. +3 −0 .gitmodules
  2. +9 −9 safari/buffer.safariextension/Info.plist
  3. +0 −171 safari/buffer.safariextension/data/buffer-overlay.js
  4. +0 −4 safari/buffer.safariextension/data/css/buffer-image.css
  5. +0 −224 safari/buffer.safariextension/data/embeds/buffer-facebook.js
  6. +0 −230 safari/buffer.safariextension/data/embeds/buffer-google-reader.js
  7. +0 −71 safari/buffer.safariextension/data/embeds/buffer-hn.js
  8. +0 −13 safari/buffer.safariextension/data/embeds/buffer-hotkey.js
  9. +0 −201 safari/buffer.safariextension/data/embeds/buffer-image.js
  10. +0 −74 safari/buffer.safariextension/data/embeds/buffer-reddit.js
  11. +0 −372 safari/buffer.safariextension/data/embeds/buffer-twitter.js
  12. +0 −4 safari/buffer.safariextension/data/image/buffer-image.css
  13. +0 −201 safari/buffer.safariextension/data/image/buffer-image.js
  14. BIN safari/buffer.safariextension/data/img/buffer-icon-sprite.png
  15. BIN safari/buffer.safariextension/data/img/buffer_twitter_small.png
  16. BIN safari/buffer.safariextension/data/img/google-reader-logo-small-grey.png
  17. BIN safari/buffer.safariextension/data/img/google-reader-logo-small-white.png
  18. BIN safari/buffer.safariextension/data/img/twttr-sprite-small.png
  19. BIN safari/buffer.safariextension/data/img/twttr-sprite.png
  20. +0 −4 safari/buffer.safariextension/data/libs/jquery-1.7.2.min.js
  21. +0 −414 safari/buffer.safariextension/data/libs/postmessage.js
  22. +1 −1 safari/buffer.safariextension/data/safari/buffer-safari-data-wrapper.js
  23. +1 −0 safari/buffer.safariextension/data/shared
View
@@ -0,0 +1,3 @@
+[submodule "safari/buffer.safariextension/data/shared"]
+ path = safari/buffer.safariextension/data/shared
+ url = git@github.com:bufferapp/buffer-extension-shared.git
@@ -42,19 +42,19 @@
<dict>
<key>End</key>
<array>
- <string>data/buffer-overlay.js</string>
- <string>data/embeds/buffer-hotkey.js</string>
+ <string>data/shared/buffer-overlay.js</string>
+ <string>data/shared/embeds/buffer-hotkey.js</string>
<string>data/safari/buffer-safari.js</string>
- <string>data/embeds/buffer-twitter.js</string>
- <string>data/embeds/buffer-hn.js</string>
- <string>data/embeds/buffer-google-reader.js</string>
- <string>data/embeds/buffer-reddit.js</string>
- <string>data/embeds/buffer-facebook.js</string>
+ <string>data/shared/embeds/buffer-twitter.js</string>
+ <string>data/shared/embeds/buffer-hn.js</string>
+ <string>data/shared/embeds/buffer-google-reader.js</string>
+ <string>data/shared/embeds/buffer-reddit.js</string>
+ <string>data/shared/embeds/buffer-facebook.js</string>
</array>
<key>Start</key>
<array>
- <string>data/libs/jquery-1.7.2.min.js</string>
- <string>data/libs/postmessage.js</string>
+ <string>data/shared/libs/jquery-1.7.2.min.js</string>
+ <string>data/shared/libs/postmessage.js</string>
<string>data/safari/buffer-safari-data-wrapper.js</string>
<string>data/safari/buffer-safari-port-wrapper.js</string>
<string>data/safari/buffer-safari-embed.js</string>
@@ -1,171 +0,0 @@
-var bufferOverlay = function(data, config, doneCallback) {
-
- if( ! doneCallback ) doneCallback = function () {};
- if( ! config ) return;
-
- var buildSrc = function() {
- var src = config.overlay.endpoint;
- if( data.local ) src = config.overlay.localendpoint;
-
- // Add button attributes
- var first = true, count = 0;
- for(var i=0, l=config.attributes.length; i < l; i++) {
- var a = config.attributes[i];
- if( ! data[a.name] ) continue;
- if( first ) { src += '?'; first = false; }
- count += 1;
- if( count > 1 ) src += '&';
- src += a.name + '=' + a.encode(data[a.name])
- }
-
- return src;
- };
-
- var temp = document.createElement('iframe');
-
- temp.allowtransparency = 'true';
- temp.scrolling = 'no';
- temp.id = 'buffer_overlay';
- temp.name = 'buffer_overlay';
- temp.style.cssText = config.overlay.getCSS();
-
- temp.src = buildSrc();
-
- document.body.appendChild(temp);
-
- // Bind close listener
- bufferpm.bind("buffermessage", function(overlaydata) {
- document.body.removeChild(temp);
- bufferpm.unbind("buffermessage");
- setTimeout(function () {
- doneCallback(overlaydata);
- }, 0);
- });
-
-};
-
-var bufferData = function (port, postData) {
-
- if (window.top !== window) {
- return;
- }
-
- var config = {};
- config.local = false;
- config.googleReader = false;
- if( window.location.href.indexOf("google") != -1 && window.location.href.indexOf("reader") != -1 ) config.googleReader = true;
- config.attributes = [
- {
- name: "url",
- get: function (cb) {
- if( ! config.googleReader ) {
- cb(window.location.href);
- } else {
- var href = $("#current-entry .entry-container a.entry-title-link").attr('href');
- if( ! href ) href = $('.entry').first().find(".entry-container a.entry-title-link").attr('href');
- cb(href);
- }
- },
- encode: function (val) {
- return encodeURIComponent(val);
- }
- },
- {
- name: "text",
- get: function (cb) {
- if( config.googleReader ) {
- var text = $("#current-entry .entry-container a.entry-title-link").text();
- if( ! text ) text = $('.entry').first().find(".entry-container a.entry-title-link").text();
- cb(text);
- } else if(document.getSelection() != false) {
- cb('"' + document.getSelection().toString() + '"');
- } else {
- cb(document.title);
- }
- },
- encode: function (val) {
- return encodeURIComponent(val);
- }
- },
- {
- name: "picture",
- get: function (cb) {
- cb(postData.image);
- },
- encode: function (val) {
- return encodeURIComponent(val);
- }
- },
- {
- name: "embed",
- get: function (cb) {
- cb(postData.embed);
- },
- encode: function (val) {
- return encodeURIComponent(val);
- }
- },
- {
- name: "local",
- get: function (cb) {
- cb(config.local);
- },
- encode: function (val) {
- return encodeURIComponent(val);
- }
- }
- ];
- config.overlay = {
- endpoint: (config.local ? 'http:' : document.location.protocol) + '//bufferapp.com/add/',
- localendpoint: (config.local ? 'http:' : document.location.protocol) + '//local.bufferapp.com/add/',
- getCSS: function () { return "border:none;height:100%;width:100%;position:fixed;z-index:99999999;top:0;left:0;"; }
- };
-
- var executeAfter = function(done, count, data, cb) {
- if(done === count) {
- setTimeout(function(){
- cb(data)
- }, 0);
- }
- };
-
- var getData = function (cb) {
- var count = config.attributes.length;
- var done = 0;
- var data = {};
- for(var i=0; i < count; i++) {
- // Wrapped in a self-executing function to ensure we don't overwrite ‘a’
- // and that the correct ‘i’ is used
- (function (i) {
- var a = config.attributes[i];
- a.get(function(d) {
- done += 1;
- data[a.name] = d;
- executeAfter(done, count, data, cb);
- });
- }(i));
- }
- };
-
- var createOverlay = function (data) {
- if( data.embed ) {
- if( typeof data.embed === "object" ) {
- data.text = data.embed.text;
- data.url = data.embed.url;
- data.picture = data.embed.image;
- data.embed = null;
- } else {
- data.text = data.embed;
- data.url = null;
- data.embed = null;
- }
- }
- bufferOverlay(data, config, function (overlaydata) {
- port.emit("buffer_done", overlaydata);
- });
- };
-
- getData(createOverlay);
-
-};
-
@@ -1,4 +0,0 @@
-.buffer-image{position:absolute;width:55px;height:21px;background-color:transparent;box-shadow:0 0 5px rgba(0,0,0,.3);opacity:0.2;border-radius:4px;}
-.buffer-image:hover{box-shadow:0 0 5px rgba(0,0,0,.3);}
-.buffer-image:active{background-position:0 -40px;}
-.buffer-image iframe{border-radius:5px;}
Oops, something went wrong.

0 comments on commit fb7d4df

Please sign in to comment.