Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
extesy committed Jan 20, 2014
0 parents commit 572e696
Show file tree
Hide file tree
Showing 187 changed files with 9,129 additions and 0 deletions.
34 changes: 34 additions & 0 deletions _locales/en/messages.json
@@ -0,0 +1,34 @@
{
"extDescription":{
"message":"Enlarge thumbnails on mouse over. Works on many sites (Facebook, Twitter, Flickr, Reddit, Amazon, Tumblr, etc).",
"description":"Extension description (max. 132 chars)"
},
"popDisableForAllSites":{
"message":"Disable for all sites",
"description":"[popup] Disables the extension"
},
"popDisableForSite1":{
"message":"Disable",
"description":"[popup] First part of 'Disable for www.example.com'"
},
"popDisableForSite2":{
"message":"for",
"description":"[popup] Second part of 'Disable for www.example.com'"
},
"popEnableForSite1":{
"message":"Enable",
"description":"[popup] First part of 'Enable for www.example.com'"
},
"popPreloadImages":{
"message":"Preload zoomed images",
"description":"[popup] Preload zoomed images"
},
"popPreloadingImages":{
"message":"Preloading...",
"description":"[popup] Preloading zoomed images"
},
"popMoreOptions":{
"message":"More options",
"description":"[popup] More options"
}
}
1,683 changes: 1,683 additions & 0 deletions css/gumby.css

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions css/style.css
@@ -0,0 +1,5 @@
#messages {
opacity: 0;
margin-top: 2em;
margin-bottom: 2em;
}
Binary file added fonts/icons/entypo.eot
Binary file not shown.
Binary file added fonts/icons/entypo.ttf
Binary file not shown.
Binary file added fonts/icons/entypo.woff
Binary file not shown.
136 changes: 136 additions & 0 deletions html/options.html
@@ -0,0 +1,136 @@
<!doctype html>
<html>
<head>
<title>Hover Zoom+ Options</title>
<link rel="stylesheet" href="../css/gumby.css"/>
<link rel="stylesheet" href="../css/style.css"/>
<script src="../js/libs/modernizr-2.7.1.min.js"></script>
</head>
<body>
<div class="pretty container">
<div class="row">
<div class="two columns text-center"><img src="../images/icon128.png"></div>
<h1 class="ten columns text-center">Hover Zoom+ Options</h1>
</div>
<section class="tabs pill">
<div class="row">
<ul class="tab-nav">
<li class="active"><a href="#">General</a></li>
<li><a href="#">Sites</a></li>
<li><a href="#">Action keys</a></li>
<li><a href="#">Advanced</a></li>
</ul>
</div>
<div class="row">
<div class="tab-content active">
<form>
<div class="field"><label class="checkbox" for="chkExtensionEnabled"><input type="checkbox" id="chkExtensionEnabled"><span></span> Enable Hover Zoom</label></div>
<fieldset>
<legend>View</legend>
<ul>
<div class="ttip" data-tooltip="If unchecked, zoomed images will be resized dynamically">
<li class="field">
<label class="checkbox" for="chkMouseUnderlap"><input type="checkbox" id="chkMouseUnderlap"><span></span> Extend zoomed images below the mouse cursor</label>
</li>
</div>
<div class="ttip" data-tooltip="Only when images can be zoomed">
<li class="field">
<label class="checkbox" for="chkPageActionEnabled"><input class="input" type="checkbox" id="chkPageActionEnabled"><span></span> Show icon in address bar</label>
</li>
</div>
<div class="ttip" data-tooltip="Captions will be shown only when available">
<li class="field">
<label class="checkbox" for="chkShowCaptions"><input type="checkbox" id="chkShowCaptions"><span></span> Show pictures captions</label>
</li>
</div>
<div class="ttip" data-tooltip="Zoomed image will be displayed before it is fully loaded">
<li class="field">
<label class="checkbox" for="chkShowWhileLoading"><input type="checkbox" id="chkShowWhileLoading"><span></span> Show zoomed pictures while loading</label>
</li>
</div>
<div class="ttip" data-tooltip="Pictures may take more time to load">
<li class="field">
<label class="checkbox" for="chkShowHighRes"><input type="checkbox" id="chkShowHighRes"><span></span> Show high resolution pictures when available</label>
</li>
</div>
</ul>
</fieldset>
<fieldset>
<legend>Delays</legend>
<ul>
<li class="append field">
<label class="inline" for="txtDisplayDelay">Delay before displaying a picture:</label> <input class="xnarrow text input" type="text" id="txtDisplayDelay"><span class="adjoined">sec</span>
</li>
<li class="append field">
<label class="inline" for="txtFadeDuration">Fading animation duration:</label> <input class="xnarrow text input" type="text" id="txtFadeDuration"><span class="adjoined">sec</span>
</li>
</ul>
</fieldset>
</form>
</div>
<div class="tab-content">
<form>
<div class="ttip" data-tooltip="Only enable Hover Zoom+ for the sites listed below">
<div class="field">
<label class="checkbox" for="chkWhiteListMode"><input type="checkbox" id="chkWhiteListMode"><span></span> White list mode</label>
</div>
</div>
<fieldset>
<legend>URLs for which Hover Zoom+ must be <span id="Dis-enabled">disabled</span></legend>
<div class="append field">
<label for="txtAddExcludedSite"></label> <input class="wide text input" type="text" id="txtAddExcludedSite" placeholder="Examples: facebook.com, google.com/reader">
<div class="medium primary btn"><a href="#" id="btnAddExcludedSite">Add</a></div>
</div>
<ul id="selExcludedSites"></ul>
<p>Be aware that domain filters can overlap. Example: if you have filtered "picasaweb.google.com" and "google.com", removing "picasaweb.google.com" will not reactivate Picasa Web Albums, as it will still be excluded by the "google.com" filter.</p>
</fieldset>
</form>
</div>
<div class="tab-content">
<table id="tableActionKeys"></table>
</div>
<div class="tab-content">
<form>
<fieldset>
<legend>Advanced options</legend>
<ul>
<li class="field"><label class="checkbox" for="chkUpdateNotifications"><input type="checkbox" id="chkUpdateNotifications"><span></span> Show update notifications (<a id="aShowUpdateNotification">show current</a>)</label></li>
<li class="field"><label class="checkbox" for="chkAddToHistory"><input type="checkbox" id="chkAddToHistory"><span></span> Add viewed pictures to the browser's history</label></li>
<li class="field"><label class="checkbox" for="chkFilterNSFW"><input type="checkbox" id="chkFilterNSFW"><span></span> Exclude NSFW images (Reddit only)</label></li>
<li class="field"><label class="checkbox" for="chkAlwaysPreload"><input type="checkbox" id="chkAlwaysPreload"><span></span> Automatically preload zoomed images</label></li>
<li class="field"><label class="checkbox" for="chkEnableGalleries"><input type="checkbox" id="chkEnableGalleries"><span></span> Enable albums support</label></li>
<li class="field"><label class="checkbox" for="chkEnableStats"><input type="checkbox" id="chkEnableStats"><span></span> Enable anonymous usage statistics</label></li>
<li class="append field"><label class="inline" for="txtPicturesOpacity">Zoomed pictures opacity:</label> <input class="xnarrow text input" type="text" id="txtPicturesOpacity"><span class="adjoined">%</span></li>
</ul>
</fieldset>
</form>
</div>
</div>
</section>
<div class="row">
<div class="push_three three columns text-center">
<div class="medium success btn icon-left entypo icon-floppy"><a href="#" id="btnSave">Save</a></div>
</div>
<div class="three columns text-center">
<div class="medium info btn icon-left entypo icon-arrows-ccw"><a href="#" id="btnReset">Reset</a></div>
</div>
</div>
<div id="messages" class="row">
<div class="four columns centered text-center">
<div class="success alert">Options saved.<br/>Some settings might need a page refresh.</div>
</div>
</div>
<div class="row">
<div class="twelve columns centered text-center">
<p><a target="_blank" href="https://github.com/extesy/hoverzoom/">Source code</a> | <a target="_blank" href="https://github.com/extesy/hoverzoom/issues">Report a bug</a></p>
<p>Version <span id="versionNumber"></span> - &copy; 2014 Oleg Anashkin</p>
</div>
</div>
</div>
<script src="../js/libs/jquery-2.0.3.min.js"></script>
<script src="../js/libs/gumby.min.js"></script>
<script src="../js/plugins.js"></script>
<script src="../js/common.js"></script>
<script src="../js/options.js"></script>
</body>
</html>
39 changes: 39 additions & 0 deletions html/popup.html
@@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../css/gumby.css"/>
<link rel="stylesheet" href="../css/style.css"/>
<style type="text/css">
body {
width: 300px;
}
</style>
<script src="../js/libs/modernizr-2.7.1.min.js"></script>
</head>
<body>
<div class="pretty container">
<div class="row">
<form>
<fieldset><legend>Hover Zoom+</legend>
<ul>
<li class="field"><label id="lblDisable" class="checkbox" for="chkExtensionDisabled"><input type="checkbox" id="chkExtensionDisabled"><span></span> Disable for all sites</label></li>
<li class="field"><label class="checkbox" for="chkExcludeSite"><input type="checkbox" id="chkExcludeSite"><span></span> <div id="dis-enable" style="display:inline">Disable</div> <div id="lblFor" style="display:inline">for</div> <div id="siteDomain" style="display:inline"></div></label></li>
</ul>
<p><a href="#" id="aPreload" style="display: none">Preload zoomed images</a></p>
<p id="lblPreloading" style="display: none"><span id="spanPreloading">Preloading...</span> <progress id="prgPreloading" style="width: 6em;"></progress></p>
</fieldset>
</form>
</div>
<div id="footer" class="row">
<div class="twelve columns text-right">
<a id="aMoreOptions" href="options.html" target="_blank">More options</a>
</div>
</div>
</div>
<script src="../js/libs/jquery-2.0.3.min.js"></script>
<script src="../js/libs/gumby.min.js"></script>
<script src="../js/plugins.js"></script>
<script src="../js/common.js"></script>
<script src="../js/popup.js"></script>
</body>
</html>
Binary file added 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 added 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 added images/icon19.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon19d.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon32.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/loading.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
168 changes: 168 additions & 0 deletions js/background.js
@@ -0,0 +1,168 @@
// True if the current version of the extension has something to show in an update notification
var hasReleaseNotes = false;

var options, _gaq, viewWindow = null;

// Performs an ajax request
function ajaxRequest(request, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
callback(xhr.responseText);
} else {
callback(null);
}
}
};
xhr.open(request.method, request.url, true);
for (var i in request.headers) {
xhr.setRequestHeader(request.headers[i].header, request.headers[i].value);
}
xhr.send(request.data);
}

function onMessage(message, sender, callback) {
switch (message.action) {
case 'ajaxGet':
ajaxRequest({url:message.url, method:'GET'}, callback);
return true;
case 'ajaxRequest':
ajaxRequest(message, callback);
return true;
case 'showPageAction':
showPageAction(sender.tab);
callback();
return true;
case 'addUrlToHistory':
chrome.history.addUrl({url:message.url});
break;
case 'getOptions':
callback(options);
return true;
case 'setOption':
options[message.name] = message.value;
localStorage.options = JSON.stringify(options);
sendOptions(message.options);
break;
case 'optionsChanged':
options = message.options;
break;
case 'saveOptions':
localStorage.options = JSON.stringify(message.options);
sendOptions(message.options);
break;
case 'setItem':
localStorage.setItem(message.id, message.data);
break;
case 'getItem':
callback(localStorage.getItem(message.id));
return true;
case 'removeItem':
localStorage.removeItem(message.id);
break;
case 'openViewWindow':
chrome.windows.create(message.createData, function (window) {
chrome.tabs.executeScript(window.tabs[0].id, {file:'js/viewWindow.js'});
});
break;
case 'openViewTab':
chrome.tabs.getSelected(null, function (currentTab) {
message.createData.index = currentTab.index;
if (!message.createData.active)
message.createData.index++;
chrome.tabs.create(message.createData, function (tab) {
chrome.tabs.executeScript(tab.id, {file:'js/viewTab.js'});
});
});
break;
case 'trackEvent':
if (options.enableStats && _gaq) {
_gaq.push(['_trackEvent', message.event.category, message.event.action, message.event.label]);
}
break;
}
}

function showPageAction(tab) {
if (!tab) {
return;
}
if (!options.extensionEnabled || isExcludedSite(tab.url)) {
chrome.pageAction.setIcon({tabId:tab.id, path:'../images/icon19d.png'});
} else {
chrome.pageAction.setIcon({tabId:tab.id, path:'../images/icon19.png'});
}
chrome.pageAction.show(tab.id);
}

// Sets up anonymous stats
function setUpStats() {
_gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-30586301-5']);
_gaq.push(['_setSampleRate', '0.1']);
_gaq.push(['_trackPageview']);

(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
}

// Report options stats
// No user data (browser history, etc) is reported
function optionsStats() {
_gaq.push(['_trackEvent', 'Options', 'extensionEnabled', options.extensionEnabled.toString()]);
_gaq.push(['_trackEvent', 'Options', 'pageActionEnabled', options.pageActionEnabled.toString()]);
_gaq.push(['_trackEvent', 'Options', 'updateNotifications', options.updateNotifications.toString()]);
_gaq.push(['_trackEvent', 'Options', 'mouseUnderlap', options.mouseUnderlap.toString()]);
_gaq.push(['_trackEvent', 'Options', 'showCaptions', options.showCaptions.toString()]);
_gaq.push(['_trackEvent', 'Options', 'showHighRes', options.showHighRes.toString()]);
_gaq.push(['_trackEvent', 'Options', 'addToHistory', options.addToHistory.toString()]);
_gaq.push(['_trackEvent', 'Options', 'alwaysPreload', options.alwaysPreload.toString()]);
_gaq.push(['_trackEvent', 'Options', 'showWhileLoading', options.showWhileLoading.toString()]);
_gaq.push(['_trackEvent', 'Options', 'whiteListMode', options.whiteListMode.toString()]);
_gaq.push(['_trackEvent', 'Options', 'displayDelay', options.displayDelay.toString()]);
_gaq.push(['_trackEvent', 'Options', 'fadeDuration', options.fadeDuration.toString()]);
_gaq.push(['_trackEvent', 'Options', 'picturesOpacity', options.picturesOpacity.toString()]);
}

// Report miscellaneous stats
// No user data (browser history, etc) is reported
function miscStats() {
_gaq.push(['_trackEvent', 'Misc', 'extensionVersion', chrome.app.getDetails().version]);
_gaq.push(['_trackEvent', 'Misc', 'downloadedFrom', 'Chrome Web Store']);
}

// Checks if the extension has been updated.
// Displays a notification if necessary.
function checkUpdate() {
var currVersion = chrome.app.getDetails().version,
prevVersion = localStorage.hzVersion;
if (hasReleaseNotes && options.updateNotifications && currVersion != prevVersion && typeof prevVersion != 'undefined') {
showUpdateNotification();
}
localStorage.hzVersion = currVersion;
}

function init() {
// Load options
options = loadOptions();

// Bind events
chrome.runtime.onMessage.addListener(onMessage);

// Anonymous stats
if (options.enableStats && navigator.appVersion.indexOf("RockMelt") == -1) {
setUpStats();
miscStats();
optionsStats();
}

checkUpdate();
}

init();

0 comments on commit 572e696

Please sign in to comment.