Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed some pixels in icon and added option to share style for current…

… page to context menu
  • Loading branch information...
commit 6984e1c430a3ac4819d61cf76ea5b3d4b7726967 1 parent fd76ac8
Ankit Ahuja ankit authored
BIN  stylebot/images/icon128.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  stylebot/images/icon16.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  stylebot/images/icon48.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 stylebot/js/background.js
View
@@ -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']
@@ -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
+ });
}
}
@@ -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(){});
5 stylebot/js/chrome.js
View
@@ -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 stylebot/js/contextmenu.js
View
@@ -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();
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.