Upgrade to Bootstrap 3

This commit is contained in:
benweet 2013-08-22 21:10:57 +02:00
parent 2009a59cc2
commit e58169d359
10 changed files with 86 additions and 46 deletions

View File

@ -47,7 +47,9 @@ define([
* finished. The optional callback parameter can be used to pass an
* onRun callback during execution, bypassing the onRun queue.
*/
var currentTaskStartTime = 0;
AsyncTask.prototype.chain = function(callback) {
currentTaskStartTime = utils.currentTime;
utils.logStackTrace();
if(this.finished === true) {
return;
@ -94,6 +96,7 @@ define([
/**
* retry() can be called in an onRun callback to restart the task
*/
var currentTaskRunning = false;
AsyncTask.prototype.retry = function(error, maxRetryCounter) {
if(this.finished === true) {
return;
@ -121,8 +124,6 @@ define([
var asyncRunning = false;
var currentTask = undefined;
var currentTaskRunning = false;
var currentTaskStartTime = 0;
// Determine if user is real by listening to his activity
var isUserReal = false;

View File

@ -707,19 +707,22 @@ define([
});
e.stopPropagation();
});
$(".tooltip-template").tooltip({
html: true,
container: '.modal-settings',
placement: 'right',
trigger: 'manual',
title: settingsTemplateTooltipHTML
}).click(function(e) {
$(this).tooltip('show');
$(document).on("click.tooltip-template", function(e) {
$(".tooltip-template").tooltip('hide');
$(document).off("click.tooltip-template");
_.each(document.querySelectorAll(".tooltip-template"), function(tooltipElt) {
var $tooltipElt = $(tooltipElt);
$tooltipElt.tooltip({
html: true,
container: $tooltipElt.parents('.modal'),
placement: 'right',
trigger: 'manual',
title: settingsTemplateTooltipHTML
}).click(function(e) {
$tooltipElt.tooltip('show');
$(document).on("click.tooltip-template", function(e) {
$(".tooltip-template").tooltip('hide');
$(document).off("click.tooltip-template");
});
e.stopPropagation();
});
e.stopPropagation();
});
// Avoid dropdown panels to close on click
@ -727,7 +730,7 @@ define([
e.stopPropagation();
});
if (viewerMode === false) {
if(viewerMode === false) {
// Load theme list
var themeOptions = _.reduce(THEME_LIST, function(themeOptions, name, value) {
return themeOptions + '<option value="' + value + '">' + name + '</option>';

View File

@ -12,7 +12,7 @@ define([
var documentSelector = new Extension("documentSelector", 'Document Selector', true, true);
documentSelector.settingsBlock = documentSelectorSettingsBlockHTML;
documentSelector.defaultConfig = {
orderBy: "title",
orderBy: "mru",
shortcutPrevious: "Ctrl+[",
shortcutNext: "Ctrl+]"
};

View File

@ -127,10 +127,6 @@ define([
connect(task);
authenticate(task);
task.onRun(function() {
if(newChangeId === 0) {
// Add time for the first synchronization
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
}
function retrievePageOfChanges() {
client.pullChanges(newChangeId, function(error, pullChanges) {
if(error) {

View File

@ -297,10 +297,6 @@ define([
authenticate(task);
task.onRun(function() {
var nextPageToken = undefined;
if(newChangeId === 0) {
// Add time for the first synchronization
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
}
function retrievePageOfChanges() {
var request = undefined;
if(nextPageToken === undefined) {

View File

@ -125,10 +125,10 @@
</div>
<ul class="nav">
<li><a href="#" data-toggle="modal"
data-target=".modal-settings"
class="action-load-settings"><i class="icon-cog"></i>
Settings</a></li>
<li><a href="#" data-toggle="modal" data-target=".modal-about"><i class="icon-help-circled"></i> About</a></li>
data-target=".modal-settings" class="action-load-settings"><i
class="icon-cog"></i> Settings</a></li>
<li><a href="#" data-toggle="modal" data-target=".modal-about"><i
class="icon-help-circled"></i> About</a></li>
</ul>
</div>
@ -411,8 +411,10 @@
<h3 class="modal-title">Export to Google Drive</h3>
</div>
<div class="modal-body">
<p>This will save "<span class="file-title"></span>" to your Google Drive
account and keep it synchronized.</p>
<p>
This will save "<span class="file-title"></span>" to your Google
Drive account and keep it synchronized.
</p>
<div class="form-horizontal">
<div class="form-group">
<label class="col-lg-3 control-label"
@ -441,7 +443,8 @@
<div class="col-lg-8">
<input type="text" id="input-sync-export-gdrive-fileid"
placeholder="FileID" class="form-control"> <span
class="help-block"> This will overwrite the existing file on the server. </span>
class="help-block"> This will overwrite the existing file
on the server. </span>
</div>
</div>
</div>
@ -477,8 +480,10 @@
<h3 class="modal-title">Export to Dropbox</h3>
</div>
<div class="modal-body">
<p>This will save "<span class="file-title"></span>" to your Dropbox account
and keep it synchronized.</p>
<p>
This will save "<span class="file-title"></span>" to your Dropbox
account and keep it synchronized.
</p>
<div class="form-horizontal">
<div class="form-group">
<label class="col-lg-3 control-label"
@ -762,6 +767,18 @@
</div>
</div>
</div>
<div class="form-group collapse publish-custom-template-collapse">
<div class="col-lg-4"></div>
<div class="col-lg-7">
<div class="checkbox">
<label> <input type="checkbox"
id="checkbox-publish-custom-template"> Custom template
</label> <a href="#" class="tooltip-template">(?)</a>
</div>
<textarea class="form-control"
id="textarea-publish-custom-template"></textarea>
</div>
</div>
</div>
</div>
<div class="modal-footer">
@ -899,8 +916,8 @@
</div>
<div class="form-group">
<label class="col-lg-4 control-label"
for="textarea-settings-publish-template">Template <a
href="#" class="tooltip-template">(?)</a>
for="textarea-settings-publish-template">Default
template <a href="#" class="tooltip-template">(?)</a>
</label>
<div class="col-lg-7">
<textarea id="textarea-settings-publish-template"
@ -949,9 +966,9 @@
</div>
<div class="modal-footer">
<a href="#" class="btn btn-default action-apply-theme" data-dismiss="modal">Cancel</a>
<a href="#" class="btn btn-primary action-apply-settings"
data-dismiss="modal">OK</a>
<a href="#" class="btn btn-default action-apply-theme"
data-dismiss="modal">Cancel</a> <a href="#"
class="btn btn-primary action-apply-settings" data-dismiss="modal">OK</a>
</div>
</div>
</div>
@ -968,8 +985,8 @@
<div class="modal-body">
<p>StackEdit has stopped because another instance was running in
the same browser.</p>
<blockquote>If you want to reopen
StackEdit, click on "Reload".</blockquote>
<blockquote>If you want to reopen StackEdit, click on
"Reload".</blockquote>
</div>
<div class="modal-footer">
<a href="javascript:window.location.reload();"

View File

@ -139,6 +139,6 @@ like `` `this` ``.
Violets are blue.
</code></pre>
<p>Based on the <a target="_blank" href="https://github.com/fletcher/MultiMarkdown/blob/master/Documentation/Markdown%20Syntax.md">Markdown syntax guide</a>, by Fletcher T. Penney.</p>
<blockquote>Based on the <a target="_blank" href="https://github.com/fletcher/MultiMarkdown/blob/master/Documentation/Markdown%20Syntax.md">Markdown syntax guide</a>, by Fletcher T. Penney.</blockquote>
</div>
</div>

View File

@ -56,7 +56,8 @@ define([
// Apply template to the current document
publisher.applyTemplate = function(fileDesc, publishAttributes, html) {
try {
return _.template(settings.template, {
var template = (publishAttributes && publishAttributes.customTmpl) || settings.template;
return _.template(template, {
documentTitle: fileDesc.title,
documentMarkdown: fileDesc.content,
documentHTML: html,
@ -72,7 +73,10 @@ define([
// Used to get content to publish
function getPublishContent(fileDesc, publishAttributes, html) {
if(publishAttributes.format === undefined) {
publishAttributes.format = $("input:radio[name=radio-publish-format]:checked").prop("value");
publishAttributes.format = utils.getInputRadio("radio-publish-format");
if(publishAttributes.format == 'template' && utils.getInputChecked("#checkbox-publish-custom-template")) {
publishAttributes.customTmpl = utils.getInputValue('#textarea-publish-custom-template');
}
}
if(publishAttributes.format == "markdown") {
return fileDesc.content;
@ -176,7 +180,9 @@ define([
// Reset fields
utils.resetModalInputs();
$("input:radio[name=radio-publish-format][value=" + defaultPublishFormat + "]").prop("checked", true);
utils.setInputRadio("radio-publish-format", defaultPublishFormat);
utils.setInputChecked("#checkbox-publish-custom-template", false);
utils.setInputValue('#textarea-publish-custom-template', settings.template);
// Load preferences
var publishPreferences = utils.retrieveIgnoreError(provider.providerId + ".publishPreferences");
@ -185,6 +191,8 @@ define([
utils.setInputValue("#input-publish-" + inputId, publishPreferences[inputId]);
});
utils.setInputRadio("radio-publish-format", publishPreferences.format);
utils.setInputChecked("#checkbox-publish-custom-template-toggle", publishPreferences.customTmpl !== undefined);
utils.setInputValue('#checkbox-publish-custom-template', publishPreferences.customTmpl || settings.template);
}
// Open dialog box
@ -219,6 +227,7 @@ define([
publishPreferences[inputId] = document.getElementById("input-publish-" + inputId).value;
});
publishPreferences.format = publishAttributes.format;
publishPreferences.customTmpl = publishAttributes.customTmpl;
localStorage[provider.providerId + ".publishPreferences"] = JSON.stringify(publishPreferences);
}
@ -255,6 +264,16 @@ define([
//
$(".action-process-publish").click(performNewLocation);
var $customTmplCollapseElt = $('.publish-custom-template-collapse').collapse();
var $customTmplTextareaElt = $('#textarea-publish-custom-template');
$("#checkbox-publish-custom-template").change(function() {
$customTmplTextareaElt.prop('disabled', !this.checked);
});
$("input:radio[name=radio-publish-format]").change(function() {
$customTmplCollapseElt.collapse(this.value == 'template' ? 'show' : 'hide');
});
// Save As menu items
$(".action-download-md").click(function() {
var content = document.getElementById("wmd-input").value;

View File

@ -689,6 +689,14 @@ body {
}
}
.publish-custom-template-collapse {
margin-bottom: 0;
textarea {
max-width: 100%;
min-height: 100px;
}
}
/*********************************
* UI Layout

View File

@ -122,7 +122,7 @@ define([
// Set checkbox state
utils.setInputChecked = function(element, checked) {
element = jqElt(element);
element.prop("checked", checked);
element.prop("checked", checked).change();
};
// Get radio button value
@ -132,7 +132,7 @@ define([
// Set radio button value
utils.setInputRadio = function(name, value) {
$("input:radio[name=" + name + "][value=" + value + "]").prop("checked", true);
$("input:radio[name=" + name + "][value=" + value + "]").prop("checked", true).change();
};
// Reset input control in all modals