Skip to content

Commit

Permalink
fixed some pixels in icon and added option to share style for current…
Browse files Browse the repository at this point in the history
… page to context menu
  • Loading branch information
ankit committed Jan 21, 2011
1 parent fd76ac8 commit 6984e1c
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
Binary file modified stylebot/images/icon128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified stylebot/images/icon16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified stylebot/images/icon48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion stylebot/js/background.js
Expand Up @@ -328,7 +328,7 @@ function loadAccordionState() {
/*** Context Menu ***/

function createContextMenu() {
if (localStorage['stylebot_option_contextMenu'] == 'true') {
if (localStorage['stylebot_option_contextMenu'] === 'true') {
contextMenuId = chrome.contextMenus.create({
title: "Stylebot",
contexts: ['all']
Expand All @@ -347,6 +347,13 @@ function createContextMenu() {
onclick: searchSocial,
parentId: contextMenuId
});

chrome.contextMenus.create({
title: "Share your style for this page...",
contexts: ['all'],
onclick: shareStyleOnSocial,
parentId: contextMenuId
});
}
}

Expand All @@ -363,6 +370,12 @@ function searchSocial() {
});
}

function shareStyleOnSocial() {
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {name: "shareStyleOnSocial"}, function(){});
});
}

function openWidget() {
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {name: "openWidget"}, function(){});
Expand Down
5 changes: 5 additions & 0 deletions stylebot/js/chrome.js
Expand Up @@ -71,5 +71,10 @@ chrome.extension.onRequest.addListener(
return;
stylebot.contextmenu.searchSocial();
}
else if (request.name === "shareStyleOnSocial") {
if (!window.top)
return;
stylebot.contextmenu.shareStyleOnSocial();
}
}
);
36 changes: 36 additions & 0 deletions stylebot/js/contextmenu.js
Expand Up @@ -24,5 +24,41 @@ stylebot.contextmenu = {

searchSocial: function() {
window.open("http://stylebot.me/playground/social/search/" + document.domain);
},

shareStyleOnSocial: function() {
// check if the current page has any styles
if (stylebot.style.rules) {

var css = CSSUtils.crunchFormattedCSS(stylebot.style.rules, false);
var url = "http://stylebot.me/playground/social/post";

// create a form and submit data
var temp_form = $('<form>', {
'method': 'post',
'action': url,
'target': '_self'
});

// site
$('<input>', {
type: 'hidden',
name: 'site',
value: stylebot.style.cache.url
}).appendTo(temp_form);

// css
$('<input>', {
type: 'hidden',
name: 'css',
value: css
}).appendTo(temp_form);

$('<submit>').appendTo(temp_form);

temp_form.submit();

temp_form.remove();
}
}
}

0 comments on commit 6984e1c

Please sign in to comment.