JSHint validation. Part 2.
This commit is contained in:
parent
634569f3a9
commit
f8e97cb190
@ -228,6 +228,9 @@ module.exports = function(grunt) {
|
||||
*/
|
||||
grunt.registerTask('build-js', function() {
|
||||
|
||||
// JSHint validation
|
||||
grunt.task.run('jshint');
|
||||
|
||||
// Run r.js optimization
|
||||
grunt.task.run('requirejs');
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
CACHE MANIFEST
|
||||
#Date Sun Nov 03 2013 22:25:18
|
||||
#Date Thu Nov 07 2013 23:09:02
|
||||
|
||||
CACHE:
|
||||
res/worker.js
|
||||
|
@ -3,7 +3,6 @@ define([
|
||||
"constants",
|
||||
"utils",
|
||||
"eventMgr",
|
||||
"config"
|
||||
], function(_, constants, utils, eventMgr) {
|
||||
|
||||
var taskQueue = [];
|
||||
|
@ -5,7 +5,7 @@ define([
|
||||
"fileSystem"
|
||||
], function(_, utils, storage, fileSystem) {
|
||||
|
||||
function FolderDescriptor(folderIndex, name, fileList) {
|
||||
function FolderDescriptor(folderIndex, name) {
|
||||
this.folderIndex = folderIndex;
|
||||
this._name = name || storage[folderIndex + ".name"];
|
||||
// Retrieve file list from storage
|
||||
|
@ -29,11 +29,11 @@ define([], function() {
|
||||
|
||||
// Use by Google's client.js
|
||||
window.delayedFunction = undefined;
|
||||
function runDelayedFunction() {
|
||||
window.runDelayedFunction = function() {
|
||||
if(window.delayedFunction !== undefined) {
|
||||
window.delayedFunction();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Site dependent
|
||||
constants.BASE_URL = "http://localhost/";
|
@ -1,3 +1,4 @@
|
||||
/*globals Markdown, requirejs */
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
@ -15,7 +16,6 @@ define([
|
||||
"text!html/settingsTemplateTooltip.html",
|
||||
"text!html/settingsUserCustomExtensionTooltip.html",
|
||||
"storage",
|
||||
"config",
|
||||
"uilayout",
|
||||
'pagedown-ace',
|
||||
'libs/ace_mode',
|
||||
@ -29,7 +29,7 @@ define([
|
||||
var core = {};
|
||||
|
||||
// Used for periodic tasks
|
||||
var intervalId = undefined;
|
||||
var intervalId;
|
||||
|
||||
// Used to detect user activity
|
||||
var isUserReal = false;
|
||||
@ -54,7 +54,7 @@ define([
|
||||
}
|
||||
|
||||
// Used to only have 1 window of the application in the same browser
|
||||
var windowId = undefined;
|
||||
var windowId;
|
||||
function checkWindowUnique() {
|
||||
if(isUserReal === false || windowUnique === false) {
|
||||
return;
|
||||
@ -106,13 +106,13 @@ define([
|
||||
}
|
||||
|
||||
// Load settings in settings dialog
|
||||
var $themeInputElt = undefined;
|
||||
var $themeInputElt;
|
||||
function loadSettings() {
|
||||
|
||||
// Layout orientation
|
||||
utils.setInputRadio("radio-layout-orientation", settings.layoutOrientation);
|
||||
// Theme
|
||||
utils.setInputValue($themeInputElt, theme);
|
||||
utils.setInputValue($themeInputElt, window.theme);
|
||||
$themeInputElt.change();
|
||||
// Lazy rendering
|
||||
utils.setInputChecked("#input-settings-lazy-rendering", settings.lazyRendering);
|
||||
@ -190,9 +190,9 @@ define([
|
||||
}
|
||||
|
||||
// Set the panels visibility
|
||||
var layout = undefined;
|
||||
var $menuPanelElt = undefined;
|
||||
var $documentPanelElt = undefined;
|
||||
var layout;
|
||||
var $menuPanelElt;
|
||||
var $documentPanelElt;
|
||||
function setPanelVisibility(forceHide) {
|
||||
if(forceHide === true || layout.state.north.isClosed) {
|
||||
$menuPanelElt.hide();
|
||||
@ -205,7 +205,7 @@ define([
|
||||
}
|
||||
|
||||
// Set the preview button visibility
|
||||
var $previewButtonsElt = undefined;
|
||||
var $previewButtonsElt;
|
||||
function setPreviewButtonsVisibility(forceHide) {
|
||||
if(forceHide === true || layout.state.east.isClosed) {
|
||||
$previewButtonsElt.hide();
|
||||
@ -216,7 +216,7 @@ define([
|
||||
}
|
||||
|
||||
// Create ACE editor
|
||||
var aceEditor = undefined;
|
||||
var aceEditor;
|
||||
function createAceEditor() {
|
||||
aceEditor = ace.edit("wmd-input");
|
||||
aceEditor.setOption("spellcheck", true);
|
||||
@ -277,9 +277,10 @@ define([
|
||||
}
|
||||
self.currentLine = currentLine;
|
||||
|
||||
if(startLine <= endLine)
|
||||
if(startLine <= endLine) {
|
||||
self.fireUpdateEvent(startLine, endLine);
|
||||
}
|
||||
}
|
||||
self.$worker = function() {
|
||||
self.lines.splice(0, self.lines.length);
|
||||
self.states.splice(0, self.states.length);
|
||||
@ -294,7 +295,7 @@ define([
|
||||
}
|
||||
|
||||
// Create the layout
|
||||
var $editorButtonsElt = undefined;
|
||||
var $editorButtonsElt;
|
||||
function createLayout() {
|
||||
var layoutGlobalConfig = {
|
||||
closable: true,
|
||||
@ -384,7 +385,7 @@ define([
|
||||
var $resizerDecorator = $('<div class="resizer-decorator">');
|
||||
$previewButtonsElt = $('<div class="extension-preview-buttons">');
|
||||
$editorButtonsElt = $('<div class="extension-editor-buttons">');
|
||||
if(viewerMode || settings.layoutOrientation == "horizontal") {
|
||||
if(window.viewerMode || settings.layoutOrientation == "horizontal") {
|
||||
$('.ui-layout-resizer-north').append($resizerDecorator).append($previewButtonsElt);
|
||||
$('.ui-layout-resizer-east').append($northTogglerElt).append($editorButtonsElt);
|
||||
}
|
||||
@ -400,10 +401,10 @@ define([
|
||||
}
|
||||
|
||||
// Create the PageDown editor
|
||||
var editor = undefined;
|
||||
var $editorElt = undefined;
|
||||
var fileDesc = undefined;
|
||||
var documentContent = undefined;
|
||||
var editor;
|
||||
var $editorElt;
|
||||
var fileDesc;
|
||||
var documentContent;
|
||||
var UndoManager = require("ace/undomanager").UndoManager;
|
||||
core.initEditor = function(fileDescParam) {
|
||||
if(fileDesc !== undefined) {
|
||||
@ -431,7 +432,7 @@ define([
|
||||
|
||||
var $previewContainerElt = $(".preview-container");
|
||||
|
||||
if(!lightMode) {
|
||||
if(!window.lightMode) {
|
||||
// Store editor scrollTop on scroll event
|
||||
var saveScroll = _.debounce(function() {
|
||||
if(documentContent !== undefined) {
|
||||
@ -470,7 +471,8 @@ define([
|
||||
documentContent = newDocumentContent;
|
||||
}
|
||||
|
||||
if(!lightMode) {
|
||||
var previewWrapper;
|
||||
if(!window.lightMode) {
|
||||
editor = new Markdown.Editor(converter, undefined, {
|
||||
keyStrokes: shortcutMgr.getPagedownKeyStrokes()
|
||||
});
|
||||
@ -491,41 +493,7 @@ define([
|
||||
$(".modal-insert-image").modal();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
else {
|
||||
// That's the light Markdown editor replacing the one from pagedown
|
||||
var $wmdPreviewElt = $('#wmd-preview');
|
||||
var hooks = new Markdown.HookCollection();
|
||||
hooks.addNoop("onPreviewRefresh");
|
||||
function makePreviewHtml() {
|
||||
var text = $editorElt.val();
|
||||
text = converter.makeHtml(text);
|
||||
$wmdPreviewElt.html(text);
|
||||
hooks.onPreviewRefresh();
|
||||
}
|
||||
var debouncedMakePreview = _.debounce(makePreviewHtml, 1000);
|
||||
var previewWrapper = function() {
|
||||
if(documentContent === undefined) {
|
||||
makePreviewHtml();
|
||||
eventMgr.onFileOpen(fileDesc);
|
||||
}
|
||||
else {
|
||||
debouncedMakePreview();
|
||||
}
|
||||
checkDocumentChanges();
|
||||
};
|
||||
$editorElt.on("input propertychange", previewWrapper);
|
||||
editor = {
|
||||
hooks: hooks,
|
||||
getConverter: function() {
|
||||
return converter;
|
||||
},
|
||||
run: previewWrapper,
|
||||
refreshPreview: previewWrapper
|
||||
};
|
||||
}
|
||||
|
||||
var previewWrapper;
|
||||
if(settings.lazyRendering === true) {
|
||||
previewWrapper = function(makePreview) {
|
||||
var debouncedMakePreview = _.debounce(makePreview, 500);
|
||||
@ -560,6 +528,40 @@ define([
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
// That's the light Markdown editor replacing the one from pagedown
|
||||
var $wmdPreviewElt = $('#wmd-preview');
|
||||
var hooks = new Markdown.HookCollection();
|
||||
hooks.addNoop("onPreviewRefresh");
|
||||
var makePreviewHtml = function() {
|
||||
var text = $editorElt.val();
|
||||
text = converter.makeHtml(text);
|
||||
$wmdPreviewElt.html(text);
|
||||
hooks.onPreviewRefresh();
|
||||
};
|
||||
var debouncedMakePreview = _.debounce(makePreviewHtml, 1000);
|
||||
var lightPreviewWrapper = function() {
|
||||
if(documentContent === undefined) {
|
||||
makePreviewHtml();
|
||||
eventMgr.onFileOpen(fileDesc);
|
||||
}
|
||||
else {
|
||||
debouncedMakePreview();
|
||||
}
|
||||
checkDocumentChanges();
|
||||
};
|
||||
$editorElt.on("input propertychange", lightPreviewWrapper);
|
||||
editor = {
|
||||
hooks: hooks,
|
||||
getConverter: function() {
|
||||
return converter;
|
||||
},
|
||||
run: lightPreviewWrapper,
|
||||
refreshPreview: lightPreviewWrapper
|
||||
};
|
||||
}
|
||||
|
||||
eventMgr.onPagedownConfigure(editor);
|
||||
editor.hooks.chain("onPreviewRefresh", eventMgr.onAsyncPreview);
|
||||
editor.run(aceEditor, previewWrapper);
|
||||
@ -573,24 +575,24 @@ define([
|
||||
var $btnGroupElt = $('.wmd-button-group1');
|
||||
$("#wmd-bold-button").append($('<i class="icon-bold">')).appendTo($btnGroupElt);
|
||||
$("#wmd-italic-button").append($('<i class="icon-italic">')).appendTo($btnGroupElt);
|
||||
var $btnGroupElt = $('.wmd-button-group2');
|
||||
$btnGroupElt = $('.wmd-button-group2');
|
||||
$("#wmd-link-button").append($('<i class="icon-globe">')).appendTo($btnGroupElt);
|
||||
$("#wmd-quote-button").append($('<i class="icon-indent-right">')).appendTo($btnGroupElt);
|
||||
$("#wmd-code-button").append($('<i class="icon-code">')).appendTo($btnGroupElt);
|
||||
$("#wmd-image-button").append($('<i class="icon-picture">')).appendTo($btnGroupElt);
|
||||
var $btnGroupElt = $('.wmd-button-group3');
|
||||
$btnGroupElt = $('.wmd-button-group3');
|
||||
$("#wmd-olist-button").append($('<i class="icon-list-numbered">')).appendTo($btnGroupElt);
|
||||
$("#wmd-ulist-button").append($('<i class="icon-list-bullet">')).appendTo($btnGroupElt);
|
||||
$("#wmd-heading-button").append($('<i class="icon-text-height">')).appendTo($btnGroupElt);
|
||||
$("#wmd-hr-button").append($('<i class="icon-ellipsis">')).appendTo($btnGroupElt);
|
||||
var $btnGroupElt = $('.wmd-button-group4');
|
||||
$btnGroupElt = $('.wmd-button-group4');
|
||||
$("#wmd-undo-button").append($('<i class="icon-reply">')).appendTo($btnGroupElt);
|
||||
$("#wmd-redo-button").append($('<i class="icon-forward">')).appendTo($btnGroupElt);
|
||||
};
|
||||
|
||||
// Shows a dialog to force the user to click a button before opening oauth popup
|
||||
var redirectCallbackConfirm = undefined;
|
||||
var redirectCallbackCancel = undefined;
|
||||
var redirectCallbackConfirm;
|
||||
var redirectCallbackCancel;
|
||||
core.redirectConfirm = function(message, callbackConfirm, callbackCancel) {
|
||||
redirectCallbackConfirm = callbackConfirm;
|
||||
redirectCallbackCancel = callbackCancel;
|
||||
@ -602,7 +604,7 @@ define([
|
||||
var isDocumentPanelShown = false;
|
||||
var isMenuPanelShown = false;
|
||||
core.onReady = function() {
|
||||
if(viewerMode === true) {
|
||||
if(window.viewerMode === true) {
|
||||
document.body.innerHTML = bodyViewerHTML;
|
||||
}
|
||||
else {
|
||||
@ -630,7 +632,7 @@ define([
|
||||
$menuPanelElt = $('.menu-panel').collapse({
|
||||
toggle: false
|
||||
});
|
||||
var menuPanelBackdropElt = undefined;
|
||||
var menuPanelBackdropElt;
|
||||
$menuPanelElt.on('show.bs.collapse', function(e) {
|
||||
if(e.target === $menuPanelElt[0]) {
|
||||
isMenuPanelShown = true;
|
||||
@ -658,7 +660,7 @@ define([
|
||||
$documentPanelElt = $('.document-panel').collapse({
|
||||
toggle: false
|
||||
});
|
||||
var documentPanelBackdropElt = undefined;
|
||||
var documentPanelBackdropElt;
|
||||
$documentPanelElt.on('show.bs.collapse', function(e) {
|
||||
if(e.target === $documentPanelElt[0]) {
|
||||
isDocumentPanelShown = true;
|
||||
@ -684,7 +686,7 @@ define([
|
||||
});
|
||||
|
||||
// Editor
|
||||
if(lightMode) {
|
||||
if(window.lightMode) {
|
||||
// In light mode, we replace ACE with a textarea
|
||||
$('#wmd-input').replaceWith(function() {
|
||||
return $('<textarea id="wmd-input">').addClass(this.className).addClass('form-control');
|
||||
@ -698,7 +700,7 @@ define([
|
||||
"line-height": Math.round(settings.editorFontSize * (20 / 12)) + "px"
|
||||
});
|
||||
|
||||
if(!lightMode) {
|
||||
if(!window.lightMode) {
|
||||
// ACE editor
|
||||
createAceEditor();
|
||||
|
||||
@ -715,7 +717,7 @@ define([
|
||||
intervalId = window.setInterval(function() {
|
||||
utils.updateCurrentTime();
|
||||
checkWindowUnique();
|
||||
if(isUserActive() === true || viewerMode === true) {
|
||||
if(isUserActive() === true || window.viewerMode === true) {
|
||||
eventMgr.onPeriodicRun();
|
||||
checkOnline();
|
||||
}
|
||||
@ -728,7 +730,7 @@ define([
|
||||
eventMgr.addListener("onReady", function() {
|
||||
|
||||
// In vertical mode, we have to offset the editor buttons otherwise they hide the editor buttons
|
||||
if(!viewerMode && settings.layoutOrientation == "vertical") {
|
||||
if(!window.viewerMode && settings.layoutOrientation == "vertical") {
|
||||
$previewButtonsElt.css('right', parseInt($previewButtonsElt.css('right')) + $editorButtonsElt.width());
|
||||
}
|
||||
|
||||
@ -763,7 +765,7 @@ define([
|
||||
});
|
||||
|
||||
// Configure Mousetrap
|
||||
mousetrap.stopCallback = function(e, element, combo) {
|
||||
mousetrap.stopCallback = function(e, element) {
|
||||
return isMenuPanelShown || isDocumentPanelShown || isModalShown || $(element).is("input, select, textarea:not(.ace_text-input)");
|
||||
};
|
||||
|
||||
@ -803,12 +805,12 @@ define([
|
||||
});
|
||||
|
||||
// Hot theme switcher in the settings
|
||||
var currentTheme = theme;
|
||||
var currentTheme = window.theme;
|
||||
function applyTheme(theme) {
|
||||
theme = theme || 'default';
|
||||
if(currentTheme != theme) {
|
||||
var themeModule = "less!themes/" + theme;
|
||||
if(baseDir.indexOf('-min') !== -1) {
|
||||
if(window.baseDir.indexOf('-min') !== -1) {
|
||||
themeModule = "css!themes/" + theme;
|
||||
}
|
||||
// Undefine the module in RequireJS
|
||||
@ -826,10 +828,10 @@ define([
|
||||
});
|
||||
|
||||
// Import docs and settings
|
||||
$(".action-import-docs-settings").click(function(e) {
|
||||
$(".action-import-docs-settings").click(function() {
|
||||
$("#input-file-import-docs-settings").click();
|
||||
});
|
||||
var newstorage = undefined;
|
||||
var newstorage;
|
||||
$("#input-file-import-docs-settings").change(function(evt) {
|
||||
var files = (evt.dataTransfer || evt.target).files;
|
||||
$(".modal-settings").modal("hide");
|
||||
@ -849,7 +851,7 @@ define([
|
||||
$('.modal-import-docs-settings').modal('show');
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
catch(exc) {
|
||||
eventMgr.onError("Wrong format: " + importedFile.name);
|
||||
}
|
||||
$("#input-file-import-docs-settings").val('');
|
||||
@ -858,7 +860,7 @@ define([
|
||||
reader.readAsText(file);
|
||||
});
|
||||
});
|
||||
$(".action-import-docs-settings-confirm").click(function(e) {
|
||||
$(".action-import-docs-settings-confirm").click(function() {
|
||||
storage.clear();
|
||||
var allowedKeys = /^file\.|^focusMode$|^folder\.|^publish\.|^settings$|^sync\.|^theme$|^version$|^welcomeTour$/;
|
||||
_.each(newstorage, function(value, key) {
|
||||
@ -869,7 +871,7 @@ define([
|
||||
window.location.reload();
|
||||
});
|
||||
// Export settings
|
||||
$(".action-export-docs-settings").click(function(e) {
|
||||
$(".action-export-docs-settings").click(function() {
|
||||
utils.saveAs(JSON.stringify(storage), "StackEdit local storage.json");
|
||||
});
|
||||
|
||||
@ -915,7 +917,7 @@ define([
|
||||
title: settingsUserCustomExtensionTooltipHTML
|
||||
}).click(function(e) {
|
||||
$(this).tooltip('show');
|
||||
$(document).on("click.tooltip-usercustom-extension", function(e) {
|
||||
$(document).on("click.tooltip-usercustom-extension", function() {
|
||||
tooltipOpen = false;
|
||||
$(".tooltip-usercustom-extension").tooltip('hide');
|
||||
$(document).off("click.tooltip-usercustom-extension");
|
||||
@ -933,7 +935,7 @@ define([
|
||||
title: settingsTemplateTooltipHTML
|
||||
}).click(function(e) {
|
||||
$tooltipElt.tooltip('show');
|
||||
$(document).on("click.tooltip-template", function(e) {
|
||||
$(document).on("click.tooltip-template", function() {
|
||||
tooltipOpen = false;
|
||||
$(".tooltip-template").tooltip('hide');
|
||||
$(document).off("click.tooltip-template");
|
||||
@ -970,11 +972,11 @@ define([
|
||||
var $imgElt = $(imgElt);
|
||||
var src = $imgElt.data('stackeditSrc');
|
||||
if(src) {
|
||||
$imgElt.attr('src', baseDir + '/img/' + src);
|
||||
$imgElt.attr('src', window.baseDir + '/img/' + src);
|
||||
}
|
||||
});
|
||||
|
||||
if(viewerMode === false) {
|
||||
if(window.viewerMode === false) {
|
||||
// Load theme list
|
||||
var themeOptions = _.reduce(constants.THEME_LIST, function(themeOptions, name, value) {
|
||||
return themeOptions + '<option value="' + value + '">' + name + '</option>';
|
||||
|
@ -3,6 +3,7 @@ define([
|
||||
"underscore",
|
||||
"crel",
|
||||
"utils",
|
||||
"logger",
|
||||
"classes/Extension",
|
||||
"settings",
|
||||
"text!html/settingsExtensionsAccordion.html",
|
||||
@ -38,7 +39,7 @@ define([
|
||||
"extensions/userCustom",
|
||||
"bootstrap",
|
||||
"jquery-waitforimages"
|
||||
], function($, _, crel, utils, Extension, settings, settingsExtensionsAccordionHTML) {
|
||||
], function($, _, crel, utils, logger, Extension, settings, settingsExtensionsAccordionHTML) {
|
||||
|
||||
var eventMgr = {};
|
||||
|
||||
@ -48,17 +49,17 @@ define([
|
||||
}).compact().value();
|
||||
|
||||
// Configure extensions
|
||||
extensionSettings = settings.extensionSettings || {};
|
||||
var extensionSettings = settings.extensionSettings || {};
|
||||
_.each(extensionList, function(extension) {
|
||||
// Set the extension.config attribute from settings or default
|
||||
// configuration
|
||||
extension.config = _.extend({}, extension.defaultConfig, extensionSettings[extension.extensionId]);
|
||||
if(viewerMode === true && extension.disableInViewer === true) {
|
||||
if(window.viewerMode === true && extension.disableInViewer === true) {
|
||||
// Skip enabling the extension if we are in the viewer and extension
|
||||
// doesn't support it
|
||||
extension.enabled = false;
|
||||
}
|
||||
else if(lightMode === true && extension.disableInLight === true) {
|
||||
else if(window.lightMode === true && extension.disableInLight === true) {
|
||||
// Same for light mode
|
||||
extension.enabled = false;
|
||||
}
|
||||
@ -116,7 +117,7 @@ define([
|
||||
createEventHook("onInit")();
|
||||
|
||||
// Load/Save extension config from/to settings
|
||||
eventMgr["onLoadSettings"] = function() {
|
||||
eventMgr.onLoadSettings = function() {
|
||||
logger.log("onLoadSettings");
|
||||
_.each(extensionList, function(extension) {
|
||||
utils.setInputChecked("#input-enable-extension-" + extension.extensionId, extension.enabled === true);
|
||||
@ -124,7 +125,7 @@ define([
|
||||
onLoadSettingsListener && onLoadSettingsListener();
|
||||
});
|
||||
};
|
||||
eventMgr["onSaveSettings"] = function(newExtensionSettings, event) {
|
||||
eventMgr.onSaveSettings = function(newExtensionSettings, event) {
|
||||
logger.log("onSaveSettings");
|
||||
_.each(extensionList, function(extension) {
|
||||
var newExtensionConfig = _.extend({}, extension.defaultConfig);
|
||||
@ -189,9 +190,9 @@ define([
|
||||
|
||||
var onPreviewFinished = createEventHook("onPreviewFinished");
|
||||
var onAsyncPreviewListenerList = getExtensionListenerList("onAsyncPreview");
|
||||
var previewContentsElt = undefined;
|
||||
var $previewContentsElt = undefined;
|
||||
eventMgr["onAsyncPreview"] = function() {
|
||||
var previewContentsElt;
|
||||
var $previewContentsElt;
|
||||
eventMgr.onAsyncPreview = function() {
|
||||
logger.log("onAsyncPreview");
|
||||
logger.log("Conversion time: " + (new Date() - eventMgr.previewStartTime));
|
||||
function recursiveCall(callbackList) {
|
||||
@ -216,11 +217,11 @@ define([
|
||||
};
|
||||
|
||||
var onReady = createEventHook("onReady");
|
||||
eventMgr["onReady"] = function() {
|
||||
eventMgr.onReady = function() {
|
||||
previewContentsElt = document.getElementById('preview-contents');
|
||||
$previewContentsElt = $(previewContentsElt);
|
||||
|
||||
if(viewerMode === false) {
|
||||
if(window.viewerMode === false) {
|
||||
// Create accordion in settings dialog
|
||||
var accordionHtml = _.chain(extensionList).sortBy(function(extension) {
|
||||
return extension.extensionName.toLowerCase();
|
||||
@ -235,7 +236,7 @@ define([
|
||||
document.querySelector('.accordion-extensions').innerHTML = accordionHtml;
|
||||
|
||||
// Create a button from an extension listener
|
||||
function createBtn(listener) {
|
||||
var createBtn = function(listener) {
|
||||
var buttonGrpElt = crel('div', {
|
||||
class: 'btn-group'
|
||||
});
|
||||
@ -247,7 +248,7 @@ define([
|
||||
buttonGrpElt.appendChild(btnElt);
|
||||
}
|
||||
return buttonGrpElt;
|
||||
}
|
||||
};
|
||||
|
||||
// Create extension buttons
|
||||
logger.log("onCreateButton");
|
||||
|
@ -9,7 +9,7 @@ define([
|
||||
var buttonFocusMode = new Extension("buttonFocusMode", 'Button "Focus Mode"', true, true, true);
|
||||
buttonFocusMode.settingsBlock = "When typing, scrolls automatically the editor to always have the caret centered verticaly.";
|
||||
|
||||
var aceEditor = undefined;
|
||||
var aceEditor;
|
||||
buttonFocusMode.onAceCreated = function(aceEditorParam) {
|
||||
aceEditor = aceEditorParam;
|
||||
};
|
||||
@ -25,7 +25,7 @@ define([
|
||||
aceEditor.session.setScrollTop((positionInScreen.row + 0.5) * aceEditor.renderer.lineHeight - aceEditor.renderer.$size.scrollerHeight / 2);
|
||||
}
|
||||
|
||||
var $button = undefined;
|
||||
var $button;
|
||||
buttonFocusMode.onReady = function() {
|
||||
aceEditor.getSession().selection.on('changeCursor', doFocusMode);
|
||||
aceEditor.container.addEventListener('keydown', function() {
|
||||
|
@ -17,11 +17,11 @@ define([
|
||||
utils.setInputValue("#textarea-html-code-template", buttonHtmlCode.config.template);
|
||||
};
|
||||
|
||||
buttonHtmlCode.onSaveSettings = function(newConfig, event) {
|
||||
buttonHtmlCode.onSaveSettings = function(newConfig) {
|
||||
newConfig.template = utils.getInputValue("#textarea-html-code-template");
|
||||
};
|
||||
|
||||
var eventMgr = undefined;
|
||||
var eventMgr;
|
||||
buttonHtmlCode.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
@ -30,12 +30,12 @@ define([
|
||||
return buttonHtmlCodeHTML;
|
||||
};
|
||||
|
||||
var selectedFileDesc = undefined;
|
||||
var selectedFileDesc;
|
||||
buttonHtmlCode.onFileSelected = function(fileDesc) {
|
||||
selectedFileDesc = fileDesc;
|
||||
};
|
||||
|
||||
var textareaElt = undefined;
|
||||
var textareaElt;
|
||||
buttonHtmlCode.onPreviewFinished = function(html) {
|
||||
try {
|
||||
var htmlCode = _.template(buttonHtmlCode.config.template, {
|
||||
@ -59,8 +59,9 @@ define([
|
||||
$(".action-html-code").click(function() {
|
||||
_.defer(function() {
|
||||
$("#input-html-code").each(function() {
|
||||
if($(this).is(":hidden"))
|
||||
if($(this).is(":hidden")) {
|
||||
return;
|
||||
}
|
||||
this.select();
|
||||
});
|
||||
});
|
||||
|
@ -9,8 +9,8 @@ define([
|
||||
// buttonPublish.settingsBlock = '<p>Adds a "Publish document" button in the
|
||||
// navigation bar.</p>';
|
||||
|
||||
var $button = undefined;
|
||||
var currentFileDesc = undefined;
|
||||
var $button;
|
||||
var currentFileDesc;
|
||||
var publishRunning = false;
|
||||
var hasPublications = false;
|
||||
var isOffline = false;
|
||||
@ -27,7 +27,7 @@ define([
|
||||
}
|
||||
}
|
||||
|
||||
var publisher = undefined;
|
||||
var publisher;
|
||||
buttonPublish.onPublisherCreated = function(publisherParameter) {
|
||||
publisher = publisherParameter;
|
||||
};
|
||||
|
@ -13,9 +13,9 @@ define([
|
||||
return buttonShareHTML;
|
||||
};
|
||||
|
||||
var fileDesc = undefined;
|
||||
var linkListElt = undefined;
|
||||
var $noLinkElt = undefined;
|
||||
var fileDesc;
|
||||
var linkListElt;
|
||||
var $noLinkElt;
|
||||
var refreshDocumentSharing = function(fileDescParameter) {
|
||||
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
|
@ -44,10 +44,10 @@ define([
|
||||
return _.template(buttonStatHTML, buttonStat.config);
|
||||
};
|
||||
|
||||
var previewContentsElt = undefined;
|
||||
var value1Elt = undefined;
|
||||
var value2Elt = undefined;
|
||||
var value3Elt = undefined;
|
||||
var previewContentsElt;
|
||||
var value1Elt;
|
||||
var value2Elt;
|
||||
var value3Elt;
|
||||
buttonStat.onReady = function() {
|
||||
previewContentsElt = document.getElementById('preview-contents');
|
||||
value1Elt = document.getElementById('span-stat-value1');
|
||||
|
@ -25,12 +25,12 @@ define([
|
||||
newConfig.syncShortcut = utils.getInputTextValue("#input-sync-shortcut", event);
|
||||
};
|
||||
|
||||
var synchronizer = undefined;
|
||||
var synchronizer;
|
||||
buttonSync.onSynchronizerCreated = function(synchronizerParameter) {
|
||||
synchronizer = synchronizerParameter;
|
||||
};
|
||||
|
||||
var $button = undefined;
|
||||
var $button;
|
||||
var syncRunning = false;
|
||||
var isOffline = false;
|
||||
// Enable/disable the button
|
||||
|
@ -4,7 +4,6 @@ define([
|
||||
"utils",
|
||||
"classes/Extension",
|
||||
"text!html/dialogAbout.html",
|
||||
"config"
|
||||
], function(_, constants, utils, Extension, dialogAboutHTML) {
|
||||
|
||||
var dialogAbout = new Extension("dialogAbout", 'Dialog "About"');
|
||||
@ -23,7 +22,6 @@ define([
|
||||
"Highlight.js": "http://softwaremaniacs.org/soft/highlight/en/",
|
||||
"jGrowl": "https://github.com/stanlemon/jGrowl/",
|
||||
"jQuery": "http://jquery.com/",
|
||||
"LESS": "http://lesscss.org/",
|
||||
"lz-string": "http://pieroxy.net/blog/pages/lz-string/index.html",
|
||||
"MathJax": "http://www.mathjax.org/",
|
||||
"Mousetrap": "http://craig.is/killing/mice",
|
||||
|
@ -7,15 +7,15 @@ define([
|
||||
|
||||
var dialogManagePublication = new Extension("dialogManagePublication", 'Dialog "Manage publication"', false, true);
|
||||
|
||||
var eventMgr = undefined;
|
||||
var eventMgr;
|
||||
dialogManagePublication.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
|
||||
var fileDesc = undefined;
|
||||
var publishListElt = undefined;
|
||||
var $msgPublishListElt = undefined;
|
||||
var $msgNoPublishElt = undefined;
|
||||
var fileDesc;
|
||||
var publishListElt;
|
||||
var $msgPublishListElt;
|
||||
var $msgNoPublishElt;
|
||||
var refreshDialog = function(fileDescParameter) {
|
||||
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
|
@ -7,20 +7,20 @@ define([
|
||||
|
||||
var dialogManageSynchronization = new Extension("dialogManageSynchronization", 'Dialog "Manage synchronization"', false, true);
|
||||
|
||||
var eventMgr = undefined;
|
||||
var eventMgr;
|
||||
dialogManageSynchronization.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
|
||||
var synchronizer = undefined;
|
||||
var synchronizer;
|
||||
dialogManageSynchronization.onSynchronizerCreated = function(synchronizerParameter) {
|
||||
synchronizer = synchronizerParameter;
|
||||
};
|
||||
|
||||
var fileDesc = undefined;
|
||||
var syncListElt = undefined;
|
||||
var $msgSyncListElt = undefined;
|
||||
var $msgNoSyncElt = undefined;
|
||||
var fileDesc;
|
||||
var syncListElt;
|
||||
var $msgSyncListElt;
|
||||
var $msgNoSyncElt;
|
||||
var refreshDialog = function(fileDescParameter) {
|
||||
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
|
@ -5,23 +5,22 @@ define([
|
||||
"utils",
|
||||
"classes/Extension",
|
||||
"toMarkdown",
|
||||
"config",
|
||||
], function($, _, constants, utils, Extension, toMarkdown) {
|
||||
|
||||
var dialogOpenHarddrive = new Extension("dialogOpenHarddrive", 'Dialog "Open from"');
|
||||
|
||||
var fileMgr = undefined;
|
||||
var fileMgr;
|
||||
dialogOpenHarddrive.onFileMgrCreated = function(fileMgrParameter) {
|
||||
fileMgr = fileMgrParameter;
|
||||
};
|
||||
|
||||
var eventMgr = undefined;
|
||||
var eventMgr;
|
||||
dialogOpenHarddrive.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
|
||||
var contentWrapper = undefined;
|
||||
var converter = undefined;
|
||||
var contentWrapper;
|
||||
var converter;
|
||||
var htmlContentWrapper = function(content) {
|
||||
return converter.makeMd(content);
|
||||
};
|
||||
|
@ -8,17 +8,16 @@ define([
|
||||
"classes/FolderDescriptor",
|
||||
"folderList",
|
||||
"fileSystem",
|
||||
"config"
|
||||
], function($, _, constants, utils, storage, Extension, FolderDescriptor, folderList, fileSystem) {
|
||||
|
||||
var documentManager = new Extension("documentManager", 'Document Manager', false, true);
|
||||
|
||||
var fileMgr = undefined;
|
||||
var fileMgr;
|
||||
documentManager.onFileMgrCreated = function(fileMgrParameter) {
|
||||
fileMgr = fileMgrParameter;
|
||||
};
|
||||
|
||||
var eventMgr = undefined;
|
||||
var eventMgr;
|
||||
documentManager.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
@ -53,9 +52,9 @@ define([
|
||||
'<div class="name"><%= fileDesc.composeTitle() %></div></li>',
|
||||
].join('');
|
||||
|
||||
var isVisible = false;
|
||||
var modalElt = undefined;
|
||||
var documentListElt = undefined;
|
||||
var isVisible;
|
||||
var modalElt;
|
||||
var documentListElt;
|
||||
var selectedDocumentList = [];
|
||||
var selectedFolderList = [];
|
||||
function doSelect() {
|
||||
@ -74,7 +73,7 @@ define([
|
||||
});
|
||||
}
|
||||
|
||||
var selectedDocumentListElt = undefined;
|
||||
var selectedDocumentListElt;
|
||||
function doDeleteConfirmation() {
|
||||
// Don't ask user confirmation if we delete only folders
|
||||
if(_.size(selectedDocumentList) === 0) {
|
||||
@ -114,8 +113,8 @@ define([
|
||||
eventMgr.onFoldersChanged();
|
||||
}
|
||||
|
||||
var $liMoveElt = undefined;
|
||||
var $liDeleteElt = undefined;
|
||||
var $liMoveElt;
|
||||
var $liDeleteElt;
|
||||
function doActiveButtons() {
|
||||
doSelect();
|
||||
|
||||
@ -123,9 +122,9 @@ define([
|
||||
$liDeleteElt.toggleClass('disabled', _.size(selectedFolderList) === 0 && _.size(selectedDocumentList) === 0);
|
||||
}
|
||||
|
||||
var orphanDocumentList = undefined;
|
||||
var $documentCountElt = undefined;
|
||||
var $folderCountElt = undefined;
|
||||
var orphanDocumentList;
|
||||
var $documentCountElt;
|
||||
var $folderCountElt;
|
||||
var refreshManager = function() {
|
||||
if(isVisible === false) {
|
||||
return;
|
||||
@ -212,7 +211,7 @@ define([
|
||||
$buttonElt.click(function(e) {
|
||||
e.stopPropagation();
|
||||
var $parentElt = $buttonElt.parent();
|
||||
var name = undefined;
|
||||
var name;
|
||||
var folderDesc = folderList[$parentElt.data('folderIndex')];
|
||||
var fileDesc = fileSystem[$parentElt.data('fileIndex')];
|
||||
if(folderDesc) {
|
||||
@ -311,7 +310,7 @@ define([
|
||||
|
||||
// Create folder action
|
||||
$(modalElt.querySelectorAll('.action-create-folder')).click(function() {
|
||||
var folderIndex = undefined;
|
||||
var folderIndex;
|
||||
do {
|
||||
folderIndex = "folder." + utils.randomString();
|
||||
} while (_.has(folderList, folderIndex));
|
||||
|
@ -9,7 +9,7 @@ define([
|
||||
|
||||
var documentPanel = new Extension("documentPanel", 'Document Panel');
|
||||
|
||||
var fileMgr = undefined;
|
||||
var fileMgr;
|
||||
documentPanel.onFileMgrCreated = function(fileMgrParameter) {
|
||||
fileMgr = fileMgrParameter;
|
||||
};
|
||||
@ -39,12 +39,12 @@ define([
|
||||
'</a>',
|
||||
].join('');
|
||||
|
||||
var panelElt = undefined;
|
||||
var documentListElt = undefined;
|
||||
var $documentListElt = undefined;
|
||||
var documentListFilteredElt = undefined;
|
||||
var $documentListFilteredElt = undefined;
|
||||
var selectedFileDesc = undefined;
|
||||
var panelElt;
|
||||
var documentListElt;
|
||||
var $documentListElt;
|
||||
var documentListFilteredElt;
|
||||
var $documentListFilteredElt;
|
||||
var selectedFileDesc;
|
||||
var refreshPanel = function() {
|
||||
|
||||
// List orphan documents
|
||||
@ -101,7 +101,7 @@ define([
|
||||
// Add click listeners
|
||||
_.each(panelElt.querySelectorAll('.file'), function(fileElt) {
|
||||
var $fileElt = $(fileElt);
|
||||
$fileElt.click(function(e) {
|
||||
$fileElt.click(function() {
|
||||
var fileDesc = fileSystem[$fileElt.data('fileIndex')];
|
||||
if(fileDesc && fileDesc !== selectedFileDesc) {
|
||||
fileMgr.selectFile(fileDesc);
|
||||
@ -126,7 +126,7 @@ define([
|
||||
documentPanel.onFoldersChanged = refreshPanel;
|
||||
|
||||
// Filter for search input in file selector
|
||||
var panelContentElt = undefined;
|
||||
var panelContentElt;
|
||||
var previousFilterValue = '';
|
||||
function filterFiles(filterValue) {
|
||||
if(filterValue == previousFilterValue) {
|
||||
|
@ -29,12 +29,12 @@ define([
|
||||
newConfig.shortcutNext = utils.getInputTextValue("#input-document-selector-shortcut-next", event);
|
||||
};
|
||||
|
||||
var aceEditor = undefined;
|
||||
var aceEditor;
|
||||
documentSelector.onAceCreated = function(aceEditorParam) {
|
||||
aceEditor = aceEditorParam;
|
||||
};
|
||||
|
||||
var fileMgr = undefined;
|
||||
var fileMgr;
|
||||
documentSelector.onFileMgrCreated = function(fileMgrParameter) {
|
||||
fileMgr = fileMgrParameter;
|
||||
};
|
||||
@ -46,13 +46,13 @@ define([
|
||||
' </a>',
|
||||
'</li>'
|
||||
].join('');
|
||||
var dropdownElt = undefined;
|
||||
var liEltMap = undefined;
|
||||
var liEltList = undefined;
|
||||
var sortFunction = undefined;
|
||||
var selectFileDesc = undefined;
|
||||
var selectedLi = undefined;
|
||||
var $editorElt = undefined;
|
||||
var dropdownElt;
|
||||
var liEltMap;
|
||||
var liEltList;
|
||||
var sortFunction;
|
||||
var selectFileDesc;
|
||||
var selectedLi;
|
||||
var $editorElt;
|
||||
var buildSelector = function() {
|
||||
var liListHtml = _.chain(fileSystem).sortBy(sortFunction).reduce(function(result, fileDesc) {
|
||||
return result + _.template(liEltTmpl, {
|
||||
|
@ -6,13 +6,13 @@ define([
|
||||
|
||||
var documentTitle = new Extension("documentTitle", "Document Title");
|
||||
|
||||
var layout = undefined;
|
||||
var layout;
|
||||
documentTitle.onLayoutCreated = function(layoutParameter) {
|
||||
layout = layoutParameter;
|
||||
};
|
||||
|
||||
var fileDesc = undefined;
|
||||
var $fileTitleNavbar = undefined;
|
||||
var fileDesc;
|
||||
var $fileTitleNavbar;
|
||||
var updateTitle = function(fileDescParameter) {
|
||||
if(fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
|
@ -1,3 +1,4 @@
|
||||
/*globals _gaq */
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
@ -5,7 +6,6 @@ define([
|
||||
"utils",
|
||||
"classes/Extension",
|
||||
"settings",
|
||||
"config",
|
||||
], function($, _, constants, utils, Extension, settings) {
|
||||
|
||||
var googleAnalytics = new Extension("googleAnalytics", "Google Analytics", true);
|
||||
@ -13,7 +13,7 @@ define([
|
||||
|
||||
var isLoaded = false;
|
||||
var isOffline = false;
|
||||
window["_gaq"] = [];
|
||||
window._gaq = [];
|
||||
|
||||
var init = function() {
|
||||
if(isLoaded === false && isOffline === false) {
|
||||
@ -71,7 +71,7 @@ define([
|
||||
'_trackEvent',
|
||||
"Settings",
|
||||
'theme',
|
||||
"" + theme
|
||||
"" + window.theme
|
||||
]);
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
|
@ -1,11 +1,14 @@
|
||||
/*globals Markdown */
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"utils",
|
||||
"classes/Extension",
|
||||
"text!html/markdownExtraSettingsBlock.html",
|
||||
'google-code-prettify',
|
||||
'highlightjs',
|
||||
'pagedown-extra',
|
||||
], function($, _, utils, Extension, markdownExtraSettingsBlockHTML) {
|
||||
], function($, _, utils, Extension, markdownExtraSettingsBlockHTML, prettyPrint, hljs) {
|
||||
|
||||
var markdownExtra = new Extension("markdownExtra", "Markdown Extra", true);
|
||||
markdownExtra.settingsBlock = markdownExtraSettingsBlockHTML;
|
||||
@ -36,7 +39,7 @@ define([
|
||||
utils.setInputValue("#input-markdownextra-highlighter", markdownExtra.config.highlighter);
|
||||
};
|
||||
|
||||
markdownExtra.onSaveSettings = function(newConfig, event) {
|
||||
markdownExtra.onSaveSettings = function(newConfig) {
|
||||
newConfig.extensions = [];
|
||||
utils.getInputChecked("#input-markdownextra-fencedcodegfm") && newConfig.extensions.push("fenced_code_gfm");
|
||||
utils.getInputChecked("#input-markdownextra-tables") && newConfig.extensions.push("tables");
|
||||
@ -47,7 +50,7 @@ define([
|
||||
newConfig.highlighter = utils.getInputValue("#input-markdownextra-highlighter");
|
||||
};
|
||||
|
||||
var eventMgr = undefined;
|
||||
var eventMgr;
|
||||
markdownExtra.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
|
@ -4,7 +4,7 @@ define([
|
||||
|
||||
var markdownSectionParser = new Extension("markdownSectionParser", "Markdown section parser");
|
||||
|
||||
var eventMgr = undefined;
|
||||
var eventMgr;
|
||||
markdownSectionParser.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
/*defines MathJax */
|
||||
define([
|
||||
"utils",
|
||||
"classes/Extension",
|
||||
@ -22,6 +23,7 @@ define([
|
||||
newConfig.tex2jax = utils.getInputJsValue("#input-mathjax-config-tex2jax", event);
|
||||
};
|
||||
|
||||
/*jshint ignore:start */
|
||||
mathJax.onPagedownConfigure = function(editorObject) {
|
||||
t = document.getElementById("preview-contents");
|
||||
|
||||
@ -30,7 +32,7 @@ define([
|
||||
converter.hooks.chain("postConversion", d);
|
||||
};
|
||||
|
||||
var afterRefreshCallback = undefined;
|
||||
var afterRefreshCallback;
|
||||
mathJax.onAsyncPreview = function(callback) {
|
||||
afterRefreshCallback = callback;
|
||||
j();
|
||||
@ -157,7 +159,7 @@ define([
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
/*jshint ignore:end */
|
||||
|
||||
return mathJax;
|
||||
});
|
@ -2,10 +2,11 @@ define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"utils",
|
||||
"logger",
|
||||
"classes/Extension",
|
||||
"jgrowl",
|
||||
"text!html/notificationsSettingsBlock.html",
|
||||
], function($, _, utils, Extension, jGrowl, notificationsSettingsBlockHTML) {
|
||||
], function($, _, utils, logger, Extension, jGrowl, notificationsSettingsBlockHTML) {
|
||||
|
||||
var notifications = new Extension("notifications", "Notifications");
|
||||
notifications.settingsBlock = notificationsSettingsBlockHTML;
|
||||
|
@ -8,13 +8,13 @@ define([
|
||||
var partialRendering = new Extension("partialRendering", "Partial Rendering", true);
|
||||
partialRendering.settingsBlock = partialRenderingSettingsBlockHTML;
|
||||
|
||||
var converter = undefined;
|
||||
var converter;
|
||||
var sectionCounter = 0;
|
||||
var sectionList = [];
|
||||
var linkDefinition = undefined;
|
||||
var linkDefinition;
|
||||
var sectionsToRemove = [];
|
||||
var modifiedSections = [];
|
||||
var insertBeforeSection = undefined;
|
||||
var insertBeforeSection;
|
||||
var fileChanged = false;
|
||||
function updateSectionList(newSectionList, newLinkDefinition) {
|
||||
modifiedSections = [];
|
||||
@ -107,9 +107,15 @@ define([
|
||||
updateSectionList(newSectionList, newLinkDefinition);
|
||||
};
|
||||
|
||||
var footnoteContainerElt = undefined;
|
||||
var previewContentsElt = undefined;
|
||||
var footnoteMap = {};
|
||||
// Store one footnote elt in the footnote map
|
||||
function storeFootnote(footnoteElt) {
|
||||
var id = footnoteElt.id.substring(3);
|
||||
footnoteMap[id] = footnoteElt;
|
||||
}
|
||||
|
||||
var footnoteContainerElt;
|
||||
var previewContentsElt;
|
||||
function refreshSections() {
|
||||
|
||||
// Remove outdated sections
|
||||
@ -120,8 +126,7 @@ define([
|
||||
|
||||
var wmdPreviewElt = document.getElementById("wmd-preview");
|
||||
var childNode = wmdPreviewElt.firstChild;
|
||||
var newSectionEltList = document.createDocumentFragment();
|
||||
_.each(modifiedSections, function(section) {
|
||||
function createSectionElt(section) {
|
||||
var sectionElt = crel('div', {
|
||||
id: 'wmd-preview-section-' + section.id,
|
||||
class: 'wmd-preview-section preview-content'
|
||||
@ -135,18 +140,19 @@ define([
|
||||
}
|
||||
isFirst = false;
|
||||
if(childNode.tagName == 'DIV' && childNode.className == 'footnotes') {
|
||||
_.each(childNode.querySelectorAll("ol > li"), function(footnoteElt) {
|
||||
// Store each footnote in our footnote map
|
||||
var id = footnoteElt.id.substring(3);
|
||||
footnoteMap[id] = footnoteElt;
|
||||
});
|
||||
_.each(childNode.querySelectorAll("ol > li"), storeFootnote);
|
||||
}
|
||||
else {
|
||||
sectionElt.appendChild(childNode);
|
||||
}
|
||||
childNode = nextNode;
|
||||
}
|
||||
newSectionEltList.appendChild(sectionElt);
|
||||
return sectionElt;
|
||||
}
|
||||
|
||||
var newSectionEltList = document.createDocumentFragment();
|
||||
_.each(modifiedSections, function(section) {
|
||||
newSectionEltList.appendChild(createSectionElt(section));
|
||||
});
|
||||
wmdPreviewElt.innerHTML = '';
|
||||
var insertBeforeElt = footnoteContainerElt;
|
||||
@ -179,7 +185,7 @@ define([
|
||||
|
||||
partialRendering.onPagedownConfigure = function(editor) {
|
||||
converter = editor.getConverter();
|
||||
converter.hooks.chain("preConversion", function(text) {
|
||||
converter.hooks.chain("preConversion", function() {
|
||||
var result = _.map(modifiedSections, function(section) {
|
||||
return section.text;
|
||||
});
|
||||
|
@ -8,12 +8,12 @@ define([
|
||||
var scrollLink = new Extension("scrollLink", "Scroll Link", true, true, true);
|
||||
scrollLink.settingsBlock = scrollLinkSettingsBlockHTML;
|
||||
|
||||
var aceEditor = undefined;
|
||||
var aceEditor;
|
||||
scrollLink.onAceCreated = function(aceEditorParam) {
|
||||
aceEditor = aceEditorParam;
|
||||
};
|
||||
|
||||
var sectionList = undefined;
|
||||
var sectionList;
|
||||
scrollLink.onSectionsCreated = function(sectionListParam) {
|
||||
sectionList = sectionListParam;
|
||||
};
|
||||
@ -23,14 +23,14 @@ define([
|
||||
offsetBegin = offsetBeginParam;
|
||||
};
|
||||
|
||||
var $previewElt = undefined;
|
||||
var $previewElt;
|
||||
var mdSectionList = [];
|
||||
var htmlSectionList = [];
|
||||
function pxToFloat(px) {
|
||||
return parseFloat(px.substring(0, px.length - 2));
|
||||
}
|
||||
var lastEditorScrollTop = undefined;
|
||||
var lastPreviewScrollTop = undefined;
|
||||
var lastEditorScrollTop;
|
||||
var lastPreviewScrollTop;
|
||||
var buildSections = _.debounce(function() {
|
||||
|
||||
mdSectionList = [];
|
||||
@ -96,7 +96,7 @@ define([
|
||||
var previewScrollTop = $previewElt.scrollTop();
|
||||
function getDestScrollTop(srcScrollTop, srcSectionList, destSectionList) {
|
||||
// Find the section corresponding to the offset
|
||||
var sectionIndex = undefined;
|
||||
var sectionIndex;
|
||||
var srcSection = _.find(srcSectionList, function(section, index) {
|
||||
sectionIndex = index;
|
||||
return srcScrollTop < section.endOffset;
|
||||
@ -109,12 +109,13 @@ define([
|
||||
var destSection = destSectionList[sectionIndex];
|
||||
return destSection.startOffset + destSection.height * posInSection;
|
||||
}
|
||||
var destScrollTop;
|
||||
// Perform the animation if diff > 9px
|
||||
if(isScrollEditor === true && Math.abs(editorScrollTop - lastEditorScrollTop) > 9) {
|
||||
isScrollEditor = false;
|
||||
// Animate the preview
|
||||
lastEditorScrollTop = editorScrollTop;
|
||||
var destScrollTop = getDestScrollTop(editorScrollTop, mdSectionList, htmlSectionList);
|
||||
destScrollTop = getDestScrollTop(editorScrollTop, mdSectionList, htmlSectionList);
|
||||
destScrollTop = _.min([
|
||||
destScrollTop,
|
||||
$previewElt.prop('scrollHeight') - $previewElt.outerHeight()
|
||||
@ -144,7 +145,7 @@ define([
|
||||
isScrollPreview = false;
|
||||
// Animate the editor
|
||||
lastPreviewScrollTop = previewScrollTop;
|
||||
var destScrollTop = getDestScrollTop(previewScrollTop, htmlSectionList, mdSectionList);
|
||||
destScrollTop = getDestScrollTop(previewScrollTop, htmlSectionList, mdSectionList);
|
||||
destScrollTop = _.min([
|
||||
destScrollTop,
|
||||
aceEditor.session.getScreenLength() * aceEditor.renderer.lineHeight - aceEditor.renderer.$size.scrollerHeight
|
||||
@ -198,7 +199,7 @@ define([
|
||||
}
|
||||
scrollAdjust = false;
|
||||
});
|
||||
aceEditor.session.on("changeScrollTop", function(e) {
|
||||
aceEditor.session.on("changeScrollTop", function() {
|
||||
if(isEditorMoving === false) {
|
||||
isScrollEditor = true;
|
||||
isScrollPreview = false;
|
||||
@ -207,7 +208,7 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
var $previewContentsElt = undefined;
|
||||
var $previewContentsElt;
|
||||
scrollLink.onPagedownConfigure = function(editor) {
|
||||
$previewContentsElt = $("#preview-contents");
|
||||
editor.getConverter().hooks.chain("postConversion", function(text) {
|
||||
|
@ -9,7 +9,7 @@ define([
|
||||
"text!bower-libs/lz-string/libs/lz-string-1.3.3.js",
|
||||
"text!workers/spellCheckWorker.js",
|
||||
"text!html/spellCheckSettingsBlock.html",
|
||||
], function($, _, crel, utils, Extension, XRegExp, typoJS, LZStringJS, spellCheckWorkerJS, spellCheckSettingsBlockHTML) {
|
||||
], function($, _, crel, utils, Extension, XRegExp, typoJS, LZStringJS, spellCheckWorkerJS, spellCheckSettingsBlockHTML) {
|
||||
|
||||
var spellCheck = new Extension("spellCheck", "Spell Check", true, true, true);
|
||||
spellCheck.settingsBlock = spellCheckSettingsBlockHTML;
|
||||
@ -21,11 +21,11 @@ define([
|
||||
utils.setInputValue("#select-spell-check-locale", spellCheck.config.locale);
|
||||
};
|
||||
|
||||
spellCheck.onSaveSettings = function(newConfig, event) {
|
||||
spellCheck.onSaveSettings = function(newConfig) {
|
||||
newConfig.locale = utils.getInputValue("#select-spell-check-locale");
|
||||
};
|
||||
|
||||
var worker = undefined;
|
||||
var worker;
|
||||
var isInited = false;
|
||||
spellCheck.onInit = function() {
|
||||
// Create a web worker
|
||||
@ -41,12 +41,12 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
var aceEditor = undefined;
|
||||
var aceEditor;
|
||||
var wordRegExp = XRegExp('\\p{L}+(?:\'\\p{L}+)*', 'g');
|
||||
var markers = [];
|
||||
var timeoutId = undefined;
|
||||
var timeoutId;
|
||||
|
||||
var currentRowCheck = undefined;
|
||||
var currentRowCheck;
|
||||
|
||||
function rowCheck(rowIndex) {
|
||||
var tokens = aceEditor.session.getTokens(rowIndex).slice();
|
||||
@ -128,8 +128,9 @@ define([
|
||||
timeoutId = setTimeout(check, 700);
|
||||
}
|
||||
|
||||
var dropdownElt = undefined;
|
||||
var $dropdownElt = undefined;
|
||||
/*
|
||||
var dropdownElt;
|
||||
var $dropdownElt;
|
||||
var liEltTmpl = [
|
||||
'<li>',
|
||||
' <a href="#">',
|
||||
@ -165,6 +166,7 @@ define([
|
||||
worker.postMessage(JSON.stringify(['suggest', word]));
|
||||
};
|
||||
}
|
||||
*/
|
||||
|
||||
var fileOpen = false;
|
||||
spellCheck.onFileClose = function() {
|
||||
|
@ -63,7 +63,7 @@ define([
|
||||
var tagName = "H" + level;
|
||||
var result = [];
|
||||
|
||||
var currentElement = undefined;
|
||||
var currentElement;
|
||||
function pushCurrentElement() {
|
||||
if(currentElement !== undefined) {
|
||||
if(currentElement.children.length > 0) {
|
||||
@ -73,7 +73,7 @@ define([
|
||||
}
|
||||
}
|
||||
|
||||
_.each(array, function(element, index) {
|
||||
_.each(array, function(element) {
|
||||
if(element.tagName != tagName) {
|
||||
if(currentElement === undefined) {
|
||||
currentElement = new TocElement();
|
||||
@ -90,7 +90,7 @@ define([
|
||||
}
|
||||
|
||||
// Build the TOC
|
||||
var previewContentsElt = undefined;
|
||||
var previewContentsElt;
|
||||
function buildToc() {
|
||||
var anchorList = {};
|
||||
function createAnchor(element) {
|
||||
|
@ -14,22 +14,22 @@ define([
|
||||
code: "",
|
||||
};
|
||||
|
||||
var fileMgr = undefined;
|
||||
var fileMgr;
|
||||
userCustom.onFileMgrCreated = function(fileMgrParameter) {
|
||||
fileMgr = fileMgrParameter;
|
||||
};
|
||||
|
||||
var synchronizer = undefined;
|
||||
var synchronizer;
|
||||
userCustom.onSynchronizerCreated = function(synchronizerParameter) {
|
||||
synchronizer = synchronizerParameter;
|
||||
};
|
||||
|
||||
var publisher = undefined;
|
||||
var publisher;
|
||||
userCustom.onPublisherCreated = function(publisherParameter) {
|
||||
publisher = publisherParameter;
|
||||
};
|
||||
|
||||
var eventMgr = undefined;
|
||||
var eventMgr;
|
||||
userCustom.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
@ -41,6 +41,7 @@ define([
|
||||
userCustom.onSaveSettings = function(newConfig, event) {
|
||||
newConfig.code = utils.getInputValue("#textarea-usercustom-code");
|
||||
try {
|
||||
/*jshint evil: true */
|
||||
eval(newConfig.code);
|
||||
}
|
||||
catch(e) {
|
||||
@ -52,6 +53,7 @@ define([
|
||||
|
||||
userCustom.onInit = function() {
|
||||
try {
|
||||
/*jshint evil: true */
|
||||
eval(userCustom.config.code);
|
||||
}
|
||||
catch(e) {
|
||||
|
@ -4,7 +4,7 @@ define([
|
||||
'storage',
|
||||
'classes/Extension',
|
||||
'bootstrap-tour'
|
||||
], function(_, $, storage, Extension) {
|
||||
], function(_, $, storage, Extension, Tour) {
|
||||
|
||||
var welcomeTour = new Extension('welcomeTour', 'Welcome tour', false, true);
|
||||
|
||||
@ -19,7 +19,7 @@ define([
|
||||
removeItem: function() {
|
||||
}
|
||||
},
|
||||
onEnd: function(tour) {
|
||||
onEnd: function() {
|
||||
storage.welcomeTour = 'done';
|
||||
},
|
||||
template: [
|
||||
|
@ -6,8 +6,8 @@ define([
|
||||
|
||||
var workingIndicator = new Extension("workingIndicator", "Working Indicator");
|
||||
|
||||
var $bodyElt = undefined;
|
||||
var $workingIndicatorElt = undefined;
|
||||
var $bodyElt;
|
||||
var $workingIndicatorElt;
|
||||
workingIndicator.onAsyncRunning = function(isRunning) {
|
||||
$bodyElt.toggleClass("working", isRunning);
|
||||
$workingIndicatorElt.toggleClass("show", isRunning);
|
||||
|
@ -1,16 +1,16 @@
|
||||
define([
|
||||
"classes/Extension",
|
||||
"yaml-js",
|
||||
], function(Extension, YAML) {
|
||||
], function(Extension, YAML) {
|
||||
|
||||
var yamlFrontMatterParser = new Extension("yamlFrontMatterParser", "YAML front matter");
|
||||
|
||||
var eventMgr = undefined;
|
||||
var eventMgr;
|
||||
yamlFrontMatterParser.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
|
||||
var fileDesc = undefined;
|
||||
var fileDesc;
|
||||
yamlFrontMatterParser.onFileSelected = function(fileDescParam) {
|
||||
fileDesc = fileDescParam;
|
||||
};
|
||||
|
@ -8,7 +8,6 @@ define([
|
||||
"logger",
|
||||
"eventMgr",
|
||||
"classes/AsyncTask",
|
||||
"config",
|
||||
], function($, _, constants, core, storage, logger, eventMgr, AsyncTask) {
|
||||
|
||||
var client;
|
||||
|
@ -8,7 +8,6 @@ define([
|
||||
"logger",
|
||||
"eventMgr",
|
||||
"classes/AsyncTask",
|
||||
"config"
|
||||
], function($, constants, core, utils, storage, logger, eventMgr, AsyncTask) {
|
||||
|
||||
var connected;
|
||||
|
@ -10,7 +10,6 @@ define([
|
||||
"settings",
|
||||
"eventMgr",
|
||||
"classes/AsyncTask",
|
||||
"config"
|
||||
], function(_, $, constants, core, utils, storage, logger, settings, eventMgr, AsyncTask) {
|
||||
|
||||
var connected = false;
|
||||
|
@ -82,7 +82,16 @@ requirejs.config({
|
||||
FileSaver: {
|
||||
exports: 'saveAs'
|
||||
},
|
||||
'bootstrap-tour': ['bootstrap'],
|
||||
highlightjs: {
|
||||
exports: 'hljs'
|
||||
},
|
||||
'google-code-prettify': {
|
||||
exports: 'prettyPrint'
|
||||
},
|
||||
'bootstrap-tour': {
|
||||
deps: ['bootstrap'],
|
||||
exports: 'Tour'
|
||||
},
|
||||
bootstrap: ['jquery'],
|
||||
'jquery-waitforimages': ['jquery'],
|
||||
'jquery-mousewheel': ['jquery'],
|
||||
@ -93,7 +102,7 @@ requirejs.config({
|
||||
'jquery-ui-mouse': ['jquery-ui-widget'],
|
||||
'jquery-ui-widget': ['jquery-ui-core'],
|
||||
'jquery-ui-core': ['jquery'],
|
||||
'pagedown-extra': ['pagedown-ace', 'google-code-prettify', 'highlightjs'],
|
||||
'pagedown-extra': ['pagedown-ace'],
|
||||
'pagedown-ace': ['bower-libs/pagedown-ace/Markdown.Converter']
|
||||
}
|
||||
});
|
||||
@ -125,10 +134,10 @@ window.lightMode = window.viewerMode || /(\?|&)light($|&)/.test(location.search)
|
||||
})(navigator.userAgent || navigator.vendor || window.opera);
|
||||
|
||||
// Keep the theme in a global variable
|
||||
var theme = localStorage.theme || 'default';
|
||||
var themeModule = "less!themes/" + theme;
|
||||
window.theme = localStorage.theme || 'default';
|
||||
var themeModule = "less!themes/" + window.theme;
|
||||
if (window.baseDir.indexOf('-min') !== -1) {
|
||||
themeModule = "css!themes/" + theme;
|
||||
themeModule = "css!themes/" + window.theme;
|
||||
}
|
||||
|
||||
// RequireJS entry point. By requiring synchronizer, publisher and
|
||||
|
@ -11,7 +11,6 @@ define([
|
||||
"sharing",
|
||||
"classes/Provider",
|
||||
"classes/AsyncTask",
|
||||
"config",
|
||||
"providers/bloggerProvider",
|
||||
"providers/dropboxProvider",
|
||||
"providers/gistProvider",
|
||||
|
@ -2,7 +2,6 @@ define([
|
||||
"underscore",
|
||||
"constants",
|
||||
"storage",
|
||||
"config",
|
||||
], function (_, constants, storage) {
|
||||
|
||||
var settings = {
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*jshint worker:true */
|
||||
var isConfigured = false;
|
||||
|
||||
/*jshint evil:true, unused:false */
|
||||
self.onmessage = function(e) {
|
||||
if(isConfigured === false) {
|
||||
/*jshint evil:true */
|
||||
eval(e.data);
|
||||
isConfigured = true;
|
||||
}
|
||||
@ -13,4 +13,3 @@ self.onmessage = function(e) {
|
||||
self[functionName].apply(this, data);
|
||||
}
|
||||
};
|
||||
/*jshint evil:false, unused:true */
|
||||
|
Loading…
Reference in New Issue
Block a user