Skip to content

Commit

Permalink
version 3.1.3
Browse files Browse the repository at this point in the history
 - added support for drag-n-drop tabs into saved sessions
 - added option: reverse restore order
 - added context menu for SessionList
 - bugfixes: favicon-service, open edit menu on window save, homepage initialization
  • Loading branch information
ReDEnergy committed Jan 16, 2019
1 parent f52047a commit 501bee1
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 33 deletions.
5 changes: 5 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"test": {
"message": "Restore in new window"
}
}
24 changes: 14 additions & 10 deletions data/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function load() {
bullets = document.getElementById('bullets');
tooltip = document.getElementById('tooltip');

bullets.addEventListener('mouseleave', function(e) {
bullets.addEventListener('mouseleave', function() {
tooltip.removeAttribute('active');
});

Expand Down Expand Up @@ -47,17 +47,20 @@ var initTutorial = function initTutorial() {
size = TutorialEntries.init();

initCarousel();
updateActiveBullet(bullets.firstElementChild);
updateActiveBullet(bullets.firstElementChild.firstElementChild);

};

function updateActiveBullet(node) {
console.log(node);
if (activeBullet) {
activeBullet.removeAttribute('active');
}

activeBullet = node;
activeBullet.setAttribute('active', '');

if (activeBullet) {
activeBullet.setAttribute('active', '');
}
}

function setCarouselTo(index)
Expand All @@ -80,13 +83,13 @@ function advanceCarousel(offset)
}
Carousel.style.left = -position + '%';
Carousel.setAttribute('advance', position);
updateActiveBullet(offset > 0 ? activeBullet.nextElementSibling : activeBullet.previousElementSibling);
updateActiveBullet(TutorialEntries.getEntryByIndex(position / 100).bullet);
}

function initCarousel()
{
var moveLeft = document.getElementById("scroll-left");
var moveRight = document.getElementById("scroll-right");
var moveLeft = document.getElementById('scroll-left');
var moveRight = document.getElementById('scroll-right');

moveLeft.addEventListener('click', advanceCarousel.bind(null, -100));
moveRight.addEventListener('click', advanceCarousel.bind(null, 100));
Expand Down Expand Up @@ -120,16 +123,16 @@ function HelpEntry(options)

// Bullet
var reference = document.createElement('a');
reference.href = '#' + options.info;
reference.href = '#' + options.key;

var bullet = document.createElement('div');
bullet.className = 'bullet';
bullet.setAttribute('left', options.index);
bullet.setAttribute('tooltip', options.title);
bullet.addEventListener('click', function(e) {
bullet.addEventListener('click', function() {
setCarouselTo(options.index);
});
bullet.addEventListener('mouseover', function(e) {
bullet.addEventListener('mouseover', function() {
var pos = bullet.getBoundingClientRect();
tooltip.setAttribute('active', '');
tooltip.style.left = pos.x + pos.width / 2 + 'px';
Expand Down Expand Up @@ -224,6 +227,7 @@ var TutorialEntries = (function TutorialEntries()
bullets.appendChild(entry.link);
index++;
});
return entryList.length;
}

function getEntryByKey(key) {
Expand Down
2 changes: 1 addition & 1 deletion data/lazy/lazy.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="message"> If the page was not loaded automatically please check that lazy loading is enabled in addon configuration panel. </div>
<div class="separator"></div>
<div class="message">
<div class="highlight">Firefox Addon API prevents loading certain URL types. This is not an addon issue.</div>
<div class="highlight">Sadly, Firefox Addon API prevents loading certain URL types. This is not an addon issue but and API limitation.</div>
<ul>
<li>chrome: URLs</li>
<li>javascript: URLs</li>
Expand Down
8 changes: 8 additions & 0 deletions data/scripts/components/config-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ define(function(require, exports) {
offState: 'Disabled',
});

ToggleOptionConfig({
parent: section,
name: 'Reverse restore order',
key: 'restore.reverse.order',
onState: 'Enabled',
offState: 'Disabled',
});

})();

// ------------------------
Expand Down
22 changes: 18 additions & 4 deletions data/scripts/components/session-bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,10 @@ define(function(require, exports) {
}
else
{
var targeType = getTargetType(e);
if (targeType === 'folder')
if (getTargetType(e) === 'folder')
{
var sessionID = getSessionID(e);
if (sessionID != null && SessionSyncModel.bookmarks[sessionID] != undefined) {
console.log(e.target, sessionID, bookmarkContext);
SessionSyncModel.moveBookmarkTo(bookmarkContext.bookmarkID, sessionID);
}
}
Expand All @@ -330,7 +328,8 @@ define(function(require, exports) {
let tabID = getTabID(e);
let tabContext = SyncModel.tabs[tabID];

if (tabContext) {
if (tabContext)
{
if (tabContext != bookmarkContext)
{
SessionManager.moveTab(bookmarkContext.tab.id, tabContext.tab.index, tabContext.tab.windowId);
Expand All @@ -346,6 +345,21 @@ define(function(require, exports) {
}
}
}
else
{
if (getTargetType(e) === 'folder')
{
var savingSessionID = getSessionID(e);
if (savingSessionID != null) {
BookmarkManager.createBookmarkFromTab(bookmarkContext.tab, savingSessionID)
.then(function() {
WindowEvents.emit(document, 'Notification', {
message: 'Saved',
});
});
}
}
}
}
}

Expand Down
14 changes: 10 additions & 4 deletions data/scripts/components/session-folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,16 @@ define(function(require, exports) {

var folderContextMenu = function folderContextMenu(e)
{
WindowEvents.emit(document, 'SessionContextMenu-Open', {
context: bookmarkContext.bookmark.id,
event: e
});
if (bookmarkContext)
{
WindowEvents.emit(document, 'SessionContextMenu-Open', {
context: bookmarkContext.bookmark.id,
event: e
});
}
else {
WindowEvents.emit(document, 'SessionListMenu-Open', { event: e });
}
};

var sessionDblClick = function sessionDblClick(e)
Expand Down
28 changes: 27 additions & 1 deletion data/scripts/components/session-header-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,29 @@ define(function(require, exports) {

// ------------------------------------------------------------------------
// Dev actions
if (AppConfig.devMode())

var DebugMode = {
init: AppConfig.devMode(),
manualTrigger: 0,
triggerDate: new Date(),
action : function () {
if (this.init == false)
{
if (new Date() - this.triggerDate < 5000) {
this.manualTrigger++;
if (this.manualTrigger > 10) {
this.init = true;
initDevMode();
}
}
else {
this.manualTrigger = 0;
}
}
}
};

function initDevMode()
{
var devMenu = DomElem('div', {class: 'menu-row'});

Expand Down Expand Up @@ -233,6 +255,8 @@ define(function(require, exports) {
menuArea.appendChild(devMenu);
}

if (AppConfig.devMode())
initDevMode();

// ------------------------------------------------------------------------
// Events
Expand All @@ -259,6 +283,8 @@ define(function(require, exports) {
if (newState == 1) {
document.addEventListener('click', closeOnMiss);
}

DebugMode.action();
}
});

Expand Down
1 change: 1 addition & 0 deletions data/scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ define(function(require, exports) {
getConfigValue('bookmark.click.newTab', false);
getConfigValue('bookmark.middleClick.newTab', true);
getConfigValue('restore.lazy.loading', true);
getConfigValue('restore.reverse.order', false);

// General settings
getConfigValue('context.menu.icons', true);
Expand Down
4 changes: 4 additions & 0 deletions data/scripts/session-sync-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ define(function(require, exports) {
SM.addMenuEntry({value: 'Create new session', callback: SessionManager.createNewSession, icon: 'new-session', separator: 'top'});
content.appendChild(SM.DOMRoot);

var SLM = new ContextMenu({name : 'SessionListMenu'});
SLM.addMenuEntry({value: 'Create new session', callback: SessionManager.createNewSession, icon: 'new-session'});
content.appendChild(SLM.DOMRoot);

// History List Context Menu
var confirmDeleteAll = function confirmDeleteAll(context, event)
{
Expand Down
10 changes: 10 additions & 0 deletions data/scripts/session/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ define(function(require, exports) {
});
};

var getWindowTab = function getWindowTab(tabIndex, windowId, callback)
{
browser.tabs.query({index: tabIndex, windowId: windowId})
.then(function(tabs) {
callback(tabs[0]);
});
};

var getCurrentWindow = function getCurrentWindow(callback) {
browser.windows.getCurrent({ populate: true })
.then(callback);
Expand Down Expand Up @@ -92,6 +100,7 @@ define(function(require, exports) {
var sessionTitle = (new Date()).toLocaleString();
saveWindowSession(mozWindow, sessionTitle, function onSuccess(folder) {
sessionID = folder.id;
sessionCount++;
updateOnSave();
});
}
Expand Down Expand Up @@ -302,6 +311,7 @@ define(function(require, exports) {
activateTab: activateTab,
tabTracking: tabTracking,
activateWindow: activateWindow,
getWindowTab: getWindowTab,
getCurrentTab: getCurrentTab,
getCurrentWindow: getCurrentWindow,
getAllWindows: getAllWindows,
Expand Down
1 change: 1 addition & 0 deletions data/scripts/utils/field-edit-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ define(function(require, exports) {
document.addEventListener('keydown', keyBoardShortcut);
WindowEvents.emit(document, 'FieldWidgetInvoked', widgetID);
first_field.focus();
first_field.select();
}

function saveValues()
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Session Sync",
"version": "3.1.0",
"version": "3.1.3beta",
"author": "Gabriel Ivanica",
"description": "Save sessions as bookmarks and sync them through Firefox Sync (or any other sync engine).\nPowerful session management - organize, edit, change, save, restore, etc\n",
"homepage_url": "https://github.com/ReDEnergy/SessionSync",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "session-sync",
"author": "Gabriel Ivanica",
"url": "https://github.com/ReDEnergy/SessionSync",
"version": "3.0.1",
"version": "3.1.1",
"description": "Save sessions as bookmarks and sync them through any sync engine.\nManage sessions, edit, save, restore.\nSession-Sync will automatically update sessions across multiple machines",
"license": "MPL-2.0",
"devDependencies": {
Expand Down
7 changes: 1 addition & 6 deletions scripts/favicon-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,8 @@ var FaviconService = (function FaviconService() {
{
if (tab.favIconUrl)
{
if (tab.favIconUrl.startsWith('data:image'))
{
return;
}

getFaviconUrl(tab.url, function (value) {
if (value === undefined) {
if (value === undefined || tab.url != value) {
var key = '@favIconUrl:' + getHostName(tab.url);
setFaviconUrl(key, tab.favIconUrl)
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var Commands = {
};

browser.runtime.onInstalled.addListener(function (startInfo) {
if (startInfo.reason === 'install') {
checkEvent(Commands.openTutorial);
if (startInfo.reason == 'install') {
SessionSync.checkEvent(Commands.openTutorial);
}
});

Expand Down
Loading

0 comments on commit 501bee1

Please sign in to comment.