Added shortcut for synchronize button
This commit is contained in:
parent
1de9571cd3
commit
94a0f30856
@ -19,7 +19,7 @@
|
|||||||
"requirejs-text": "~2.0.10",
|
"requirejs-text": "~2.0.10",
|
||||||
"bootstrap-tour": "~0.6.0",
|
"bootstrap-tour": "~0.6.0",
|
||||||
"ace": "#51b7cb67a63998c9c0b7d089a85c60e032a7cc17",
|
"ace": "#51b7cb67a63998c9c0b7d089a85c60e032a7cc17",
|
||||||
"pagedown-ace": "git@github.com:benweet/pagedown-ace.git#master",
|
"pagedown-ace": "git@github.com:benweet/pagedown-ace.git#7805f240f343b5b2a05a5b9c0d4a3f5091e7a49b",
|
||||||
"pagedown-extra": "git@github.com:jmcmanus/pagedown-extra.git#cca554948c362affb1cbab3bacc3861e2d90d426",
|
"pagedown-extra": "git@github.com:jmcmanus/pagedown-extra.git#cca554948c362affb1cbab3bacc3861e2d90d426",
|
||||||
"crel": "git@github.com:KoryNunn/crel.git#8dbda04b129fc0aec01a2a080d1cab26816e11c1",
|
"crel": "git@github.com:KoryNunn/crel.git#8dbda04b129fc0aec01a2a080d1cab26816e11c1",
|
||||||
"waitForImages": "git@github.com:alexanderdickson/waitForImages.git#~1.4.2",
|
"waitForImages": "git@github.com:alexanderdickson/waitForImages.git#~1.4.2",
|
||||||
|
@ -24,7 +24,7 @@ var WELCOME_DOCUMENT_TITLE = "Welcome document";
|
|||||||
var DOWNLOAD_PROXY_URL = "https://stackedit-download-proxy.herokuapp.com/";
|
var DOWNLOAD_PROXY_URL = "https://stackedit-download-proxy.herokuapp.com/";
|
||||||
var PICASA_PROXY_URL = "https://stackedit-picasa-proxy.herokuapp.com/";
|
var PICASA_PROXY_URL = "https://stackedit-picasa-proxy.herokuapp.com/";
|
||||||
var SSH_PROXY_URL = "https://stackedit-ssh-proxy.herokuapp.com/";
|
var SSH_PROXY_URL = "https://stackedit-ssh-proxy.herokuapp.com/";
|
||||||
var HTMLTOPDF_URL = "http://benweet.insomnia247.nl/stackedit-htmltopdf/";
|
var HTMLTOPDF_URL = "https://stackedit-htmltopdf.herokuapp.com/";
|
||||||
|
|
||||||
// Use by Google's client.js
|
// Use by Google's client.js
|
||||||
var delayedFunction = undefined;
|
var delayedFunction = undefined;
|
||||||
|
@ -473,7 +473,9 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!lightMode) {
|
if(!lightMode) {
|
||||||
editor = new Markdown.Editor(converter);
|
editor = new Markdown.Editor(converter, undefined, {
|
||||||
|
keyStrokes: shortcutMgr.getPagedownKeyStrokes()
|
||||||
|
});
|
||||||
// Custom insert link dialog
|
// Custom insert link dialog
|
||||||
editor.hooks.set("insertLinkDialog", function(callback) {
|
editor.hooks.set("insertLinkDialog", function(callback) {
|
||||||
core.insertLinkCallback = callback;
|
core.insertLinkCallback = callback;
|
||||||
|
@ -4,21 +4,25 @@ define([
|
|||||||
"crel",
|
"crel",
|
||||||
"utils",
|
"utils",
|
||||||
"classes/Extension",
|
"classes/Extension",
|
||||||
|
"mousetrap",
|
||||||
"text!html/buttonSyncSettingsBlock.html",
|
"text!html/buttonSyncSettingsBlock.html",
|
||||||
], function($, _, crel, utils, Extension, buttonSyncSettingsBlockHTML) {
|
], function($, _, crel, utils, Extension, mousetrap, buttonSyncSettingsBlockHTML) {
|
||||||
|
|
||||||
var buttonSync = new Extension("buttonSync", 'Button "Synchronize"');
|
var buttonSync = new Extension("buttonSync", 'Button "Synchronize"', false, true);
|
||||||
buttonSync.settingsBlock = buttonSyncSettingsBlockHTML;
|
buttonSync.settingsBlock = buttonSyncSettingsBlockHTML;
|
||||||
buttonSync.defaultConfig = {
|
buttonSync.defaultConfig = {
|
||||||
syncPeriod: 180000
|
syncPeriod: 180000,
|
||||||
|
syncShortcut: 'mod+s'
|
||||||
};
|
};
|
||||||
|
|
||||||
buttonSync.onLoadSettings = function() {
|
buttonSync.onLoadSettings = function() {
|
||||||
utils.setInputValue("#input-sync-period", buttonSync.config.syncPeriod);
|
utils.setInputValue("#input-sync-period", buttonSync.config.syncPeriod);
|
||||||
|
utils.setInputValue("#input-sync-shortcut", buttonSync.config.syncShortcut);
|
||||||
};
|
};
|
||||||
|
|
||||||
buttonSync.onSaveSettings = function(newConfig, event) {
|
buttonSync.onSaveSettings = function(newConfig, event) {
|
||||||
newConfig.syncPeriod = utils.getInputIntValue("#input-sync-period", event, 0);
|
newConfig.syncPeriod = utils.getInputIntValue("#input-sync-period", event, 0);
|
||||||
|
newConfig.syncShortcut = utils.getInputTextValue("#input-sync-shortcut", event);
|
||||||
};
|
};
|
||||||
|
|
||||||
var synchronizer = undefined;
|
var synchronizer = undefined;
|
||||||
@ -45,12 +49,10 @@ define([
|
|||||||
// Run sync periodically
|
// Run sync periodically
|
||||||
var lastSync = 0;
|
var lastSync = 0;
|
||||||
buttonSync.onPeriodicRun = function() {
|
buttonSync.onPeriodicRun = function() {
|
||||||
if(viewerMode === true || !buttonSync.config.syncPeriod || lastSync + buttonSync.config.syncPeriod > utils.currentTime) {
|
if(!buttonSync.config.syncPeriod || lastSync + buttonSync.config.syncPeriod > utils.currentTime) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(synchronizer.sync() === true) {
|
synchronizer.sync() && (lastSync = utils.currentTime);
|
||||||
lastSync = utils.currentTime;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
buttonSync.onCreateButton = function() {
|
buttonSync.onCreateButton = function() {
|
||||||
@ -60,9 +62,10 @@ define([
|
|||||||
}, crel('i', {
|
}, crel('i', {
|
||||||
class: 'icon-refresh'
|
class: 'icon-refresh'
|
||||||
}));
|
}));
|
||||||
$button = $(button).click(function() {
|
$button = $(button);
|
||||||
if(!$(this).hasClass("disabled")) {
|
$button.click(function() {
|
||||||
synchronizer.sync();
|
if(!$button.hasClass("disabled")) {
|
||||||
|
synchronizer.sync() && (lastSync = utils.currentTime);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return button;
|
return button;
|
||||||
@ -85,6 +88,13 @@ define([
|
|||||||
updateButtonState();
|
updateButtonState();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
buttonSync.onReady = function() {
|
||||||
|
mousetrap.bind(buttonSync.config.syncShortcut, function(e) {
|
||||||
|
synchronizer.sync() && (lastSync = utils.currentTime);
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return buttonSync;
|
return buttonSync;
|
||||||
|
|
||||||
});
|
});
|
@ -8,4 +8,13 @@
|
|||||||
class="col-lg-5 form-control" placeholder="180000"> ms
|
class="col-lg-5 form-control" placeholder="180000"> ms
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-lg-5 control-label"
|
||||||
|
for="input-sync-shortcut">Sync
|
||||||
|
shortcut <a href="http://craig.is/killing/mice#keys" target="_blank">(?)</a></label>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<input type="text" id="input-sync-shortcut"
|
||||||
|
class="form-control">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
@ -262,6 +262,14 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
shortcutMgr.getPagedownKeyStrokes = function() {
|
||||||
|
return _.chain(shortcuts).where({
|
||||||
|
isPageDown: true
|
||||||
|
}).map(function(shortcut) {
|
||||||
|
return [shortcut.name, shortcut.bindKey];
|
||||||
|
}).object().value();
|
||||||
|
};
|
||||||
|
|
||||||
shortcutMgr.addSettingEntries = function() {
|
shortcutMgr.addSettingEntries = function() {
|
||||||
var shortcutEntries = _.reduce(shortcuts, function(result, shortcut) {
|
var shortcutEntries = _.reduce(shortcuts, function(result, shortcut) {
|
||||||
return result + _.template(settingsShortcutEntryHTML, {
|
return result + _.template(settingsShortcutEntryHTML, {
|
||||||
|
@ -171,16 +171,23 @@ a {
|
|||||||
.transition(~"background-color ease-in-out .15s, color ease-in-out .15s, z-index ease-in-out .15s");
|
.transition(~"background-color ease-in-out .15s, color ease-in-out .15s, z-index ease-in-out .15s");
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-default:hover {
|
.btn-default:hover,
|
||||||
|
.btn-default:focus,
|
||||||
|
.btn-default:active {
|
||||||
background-color: @btn-default-hover-bg;
|
background-color: @btn-default-hover-bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary:hover {
|
.btn-primary:hover,
|
||||||
|
.btn-primary:focus,
|
||||||
|
.btn-primary:active {
|
||||||
color: @btn-primary-color;
|
color: @btn-primary-color;
|
||||||
background-color: @btn-primary-hover-bg;
|
background-color: @btn-primary-hover-bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-success:hover, .open .dropdown-toggle.btn-success {
|
.btn-success:hover,
|
||||||
|
.btn-success:focus,
|
||||||
|
.btn-success:active,
|
||||||
|
.open .dropdown-toggle.btn-success {
|
||||||
color: @btn-success-color;
|
color: @btn-success-color;
|
||||||
background-color: @bg-navbar-hover !important; // important to override .nav > li > a:hover
|
background-color: @bg-navbar-hover !important; // important to override .nav > li > a:hover
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user