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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -139,6 +139,6 @@ like `` `this` ``.
Violets are blue. Violets are blue.
</code></pre> </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>
</div> </div>

View File

@ -56,7 +56,8 @@ define([
// Apply template to the current document // Apply template to the current document
publisher.applyTemplate = function(fileDesc, publishAttributes, html) { publisher.applyTemplate = function(fileDesc, publishAttributes, html) {
try { try {
return _.template(settings.template, { var template = (publishAttributes && publishAttributes.customTmpl) || settings.template;
return _.template(template, {
documentTitle: fileDesc.title, documentTitle: fileDesc.title,
documentMarkdown: fileDesc.content, documentMarkdown: fileDesc.content,
documentHTML: html, documentHTML: html,
@ -72,7 +73,10 @@ define([
// Used to get content to publish // Used to get content to publish
function getPublishContent(fileDesc, publishAttributes, html) { function getPublishContent(fileDesc, publishAttributes, html) {
if(publishAttributes.format === undefined) { 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") { if(publishAttributes.format == "markdown") {
return fileDesc.content; return fileDesc.content;
@ -176,7 +180,9 @@ define([
// Reset fields // Reset fields
utils.resetModalInputs(); 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 // Load preferences
var publishPreferences = utils.retrieveIgnoreError(provider.providerId + ".publishPreferences"); var publishPreferences = utils.retrieveIgnoreError(provider.providerId + ".publishPreferences");
@ -185,6 +191,8 @@ define([
utils.setInputValue("#input-publish-" + inputId, publishPreferences[inputId]); utils.setInputValue("#input-publish-" + inputId, publishPreferences[inputId]);
}); });
utils.setInputRadio("radio-publish-format", publishPreferences.format); 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 // Open dialog box
@ -219,6 +227,7 @@ define([
publishPreferences[inputId] = document.getElementById("input-publish-" + inputId).value; publishPreferences[inputId] = document.getElementById("input-publish-" + inputId).value;
}); });
publishPreferences.format = publishAttributes.format; publishPreferences.format = publishAttributes.format;
publishPreferences.customTmpl = publishAttributes.customTmpl;
localStorage[provider.providerId + ".publishPreferences"] = JSON.stringify(publishPreferences); localStorage[provider.providerId + ".publishPreferences"] = JSON.stringify(publishPreferences);
} }
@ -254,6 +263,16 @@ define([
// //
$(".action-process-publish").click(performNewLocation); $(".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 // Save As menu items
$(".action-download-md").click(function() { $(".action-download-md").click(function() {

View File

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

View File

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