Upgrade to Bootstrap 3

This commit is contained in:
benweet 2013-08-21 02:16:10 +02:00
parent 32f3237463
commit 5d06c75e23
12 changed files with 137 additions and 123 deletions

View File

@ -12,23 +12,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="msvalidate.01" content="5E47EE6F67B069C17E3CDD418351A612" /> <meta name="msvalidate.01" content="5E47EE6F67B069C17E3CDD418351A612" />
<script> <script>
// Use http://.../?debug to serve original CSS/JavaScript files instead of minified // Use http://.../?debug to serve original JavaScript files instead of minified
var suffix = ""; var mainModule = "main";
if(!location.search.match(/(\?|&)debug/)) { if(!location.search.match(/(\?|&)debug/)) {
suffix = "-min"; mainModule += "-min";
}
//document.write('<link href="css/main' + suffix + '.css" rel="stylesheet">');
var theme = localStorage.theme;
if(theme) {
//document.write('<link href="themes/' + theme + '/' + theme + '.css" rel="stylesheet">');
} }
var require = { var require = {
baseUrl: "js", baseUrl: "js",
deps: [ deps: [
"main" + suffix mainModule
] ]
}; };
var viewerMode = false;
</script> </script>
<script src="js/libs/require.js"></script> <script src="js/libs/require.js"></script>
</head> </head>

View File

@ -105,7 +105,7 @@ define([
// Layout orientation // Layout orientation
utils.setInputRadio("radio-layout-orientation", settings.layoutOrientation); utils.setInputRadio("radio-layout-orientation", settings.layoutOrientation);
// Theme // Theme
utils.setInputValue($themeInputElt, localStorage.theme || 'default'); utils.setInputValue($themeInputElt, theme);
$themeInputElt.change(); $themeInputElt.change();
// Lazy rendering // Lazy rendering
utils.setInputChecked("#input-settings-lazy-rendering", settings.lazyRendering); utils.setInputChecked("#input-settings-lazy-rendering", settings.lazyRendering);
@ -188,9 +188,6 @@ define([
// Create the layout // Create the layout
function createLayout() { function createLayout() {
if(viewerMode === true) {
return;
}
var layoutGlobalConfig = { var layoutGlobalConfig = {
closable: true, closable: true,
resizable: false, resizable: false,
@ -549,12 +546,6 @@ define([
// Other initialization that are not prioritary // Other initialization that are not prioritary
eventMgr.addListener("onReady", function() { eventMgr.addListener("onReady", function() {
// Load theme list
var themeOptions = _.reduce(THEME_LIST, function(themeOptions, name, value) {
return themeOptions + '<option value="' + value + '">' + name + '</option>';
}, '');
document.getElementById('input-settings-theme').innerHTML = themeOptions;
var isModalShown = false; var isModalShown = false;
$('.modal').on('show.bs.modal', function() { $('.modal').on('show.bs.modal', function() {
// Close panel if open // Close panel if open
@ -618,7 +609,7 @@ define([
}); });
// Hot theme switcher in the settings // Hot theme switcher in the settings
var currentTheme = localStorage.theme || 'default'; var currentTheme = theme;
function applyTheme(theme) { function applyTheme(theme) {
theme = theme || 'default'; theme = theme || 'default';
if(currentTheme != theme) { if(currentTheme != theme) {
@ -736,6 +727,14 @@ define([
e.stopPropagation(); e.stopPropagation();
}); });
if (viewerMode === false) {
// Load theme list
var themeOptions = _.reduce(THEME_LIST, function(themeOptions, name, value) {
return themeOptions + '<option value="' + value + '">' + name + '</option>';
}, '');
document.getElementById('input-settings-theme').innerHTML = themeOptions;
}
}); });
return core; return core;

View File

@ -45,26 +45,31 @@ define([
// Configure extensions // Configure extensions
extensionSettings = settings.extensionSettings || {}; extensionSettings = settings.extensionSettings || {};
_.each(extensionList, function(extension) { _.each(extensionList, function(extension) {
// Set the extension.config attribute from settings or default configuration // Set the extension.config attribute from settings or default
// configuration
extension.config = _.extend({}, extension.defaultConfig, extensionSettings[extension.extensionId]); extension.config = _.extend({}, extension.defaultConfig, extensionSettings[extension.extensionId]);
if(viewerMode === true && extension.disableInViewer === true) { if(viewerMode === true && extension.disableInViewer === true) {
// Skip enabling the extension if we are in the viewer and extension doesn't support it // Skip enabling the extension if we are in the viewer and extension
// doesn't support it
extension.enabled = false; extension.enabled = false;
} }
else { else {
// Enable the extension if it's not optional or it has not been disabled by the user // Enable the extension if it's not optional or it has not been
// disabled by the user
extension.enabled = !extension.isOptional || extension.config.enabled === undefined || extension.config.enabled === true; extension.enabled = !extension.isOptional || extension.config.enabled === undefined || extension.config.enabled === true;
} }
}); });
// Returns all listeners with the specified name that are implemented in the enabled extensions // Returns all listeners with the specified name that are implemented in the
// enabled extensions
function getExtensionListenerList(eventName) { function getExtensionListenerList(eventName) {
return _.chain(extensionList).map(function(extension) { return _.chain(extensionList).map(function(extension) {
return extension.enabled && extension[eventName]; return extension.enabled && extension[eventName];
}).compact().value(); }).compact().value();
} }
// Returns a function that calls every listeners with the specified name from all enabled extensions // Returns a function that calls every listeners with the specified name
// from all enabled extensions
var eventListenerListMap = {}; var eventListenerListMap = {};
function createEventHook(eventName) { function createEventHook(eventName) {
eventListenerListMap[eventName] = getExtensionListenerList(eventName); eventListenerListMap[eventName] = getExtensionListenerList(eventName);
@ -77,7 +82,7 @@ define([
listener.apply(null, eventArguments); listener.apply(null, eventArguments);
} }
catch(e) { catch(e) {
console.error(e); console.error(_.isObject(e) ? e.stack : e);
} }
}); });
}; };
@ -92,7 +97,8 @@ define([
eventMgr.addListener = function(eventName, listener) { eventMgr.addListener = function(eventName, listener) {
try { try {
eventListenerListMap[eventName].push(listener); eventListenerListMap[eventName].push(listener);
} catch(e) { }
catch(e) {
console.error('No event listener called ' + eventName); console.error('No event listener called ' + eventName);
} }
}; };
@ -211,7 +217,7 @@ define([
extensionName: extension.extensionName, extensionName: extension.extensionName,
isOptional: extension.isOptional, isOptional: extension.isOptional,
settingsBlock: extension.settingsBlock settingsBlock: extension.settingsBlock
}): ""); }) : "");
}, "").value(); }, "").value();
document.querySelector('.accordion-extensions').innerHTML = accordionHtml; document.querySelector('.accordion-extensions').innerHTML = accordionHtml;

View File

@ -5,7 +5,7 @@ define([
"text!html/dialogManagePublicationLocation.html", "text!html/dialogManagePublicationLocation.html",
], function($, _, Extension, dialogManagePublicationLocationHTML) { ], function($, _, Extension, dialogManagePublicationLocationHTML) {
var dialogManagePublication = new Extension("dialogManagePublication", 'Dialog "Manage publication"'); var dialogManagePublication = new Extension("dialogManagePublication", 'Dialog "Manage publication"', false, true);
var eventMgr = undefined; var eventMgr = undefined;
dialogManagePublication.onEventMgrCreated = function(eventMgrParameter) { dialogManagePublication.onEventMgrCreated = function(eventMgrParameter) {

View File

@ -5,7 +5,7 @@ define([
"text!html/dialogManageSynchronizationLocation.html", "text!html/dialogManageSynchronizationLocation.html",
], function($, _, Extension, dialogManageSynchronizationLocationHTML) { ], function($, _, Extension, dialogManageSynchronizationLocationHTML) {
var dialogManageSynchronization = new Extension("dialogManageSynchronization", 'Dialog "Manage synchronization"'); var dialogManageSynchronization = new Extension("dialogManageSynchronization", 'Dialog "Manage synchronization"', false, true);
var eventMgr = undefined; var eventMgr = undefined;
dialogManageSynchronization.onEventMgrCreated = function(eventMgrParameter) { dialogManageSynchronization.onEventMgrCreated = function(eventMgrParameter) {

View File

@ -9,7 +9,7 @@ define([
"text!html/documentSelectorSettingsBlock.html", "text!html/documentSelectorSettingsBlock.html",
], function($, _, crel, utils, Extension, mousetrap, fileSystem, documentSelectorSettingsBlockHTML) { ], function($, _, crel, utils, Extension, mousetrap, fileSystem, documentSelectorSettingsBlockHTML) {
var documentSelector = new Extension("documentSelector", 'Document Selector'); var documentSelector = new Extension("documentSelector", 'Document Selector', true, true);
documentSelector.settingsBlock = documentSelectorSettingsBlockHTML; documentSelector.settingsBlock = documentSelectorSettingsBlockHTML;
documentSelector.defaultConfig = { documentSelector.defaultConfig = {
orderBy: "title", orderBy: "title",

View File

@ -1,8 +1,9 @@
<div class="navbar navbar-fixed-top ui-layout-north"> <div class="navbar navbar-fixed-top ui-layout-north">
<div class="navbar-inner"> <div class="navbar-inner">
<div class="nav right-space pull-right"></div>
<ul class="nav pull-right hide"> <ul class="nav pull-right">
<li class="btn-group"> <li class="btn-group">
<button class="btn btn-default action-edit-document hide" <button class="btn btn-default action-edit-document hide"
title="Edit this document"> title="Edit this document">
@ -10,63 +11,80 @@
</button> </button>
</li> </li>
<li class="btn-group"> <li class="btn-group">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" <button class="btn btn-default dropdown-toggle"
title="Save this document"> data-toggle="dropdown" title="Save this document">
<i class="icon-download-alt"></i> <i class="icon-download"></i>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a class="action-download-md" href="#"><i <li><a class="action-download-md" href="#"><i
class="icon-download-alt"></i> Save as Markdown</a></li> class="icon-download"></i> Save as Markdown</a></li>
<li><a class="action-download-html" href="#"><i <li><a class="action-download-html" href="#"><i
class="icon-download-alt"></i> Save as HTML</a></li> class="icon-download"></i> Save as HTML</a></li>
<li><a class="action-download-template" href="#"><i <li><a class="action-download-template" href="#"><i
class="icon-download-alt"></i> Save using template</a></li> class="icon-download"></i> Save using template</a></li>
</ul> </ul>
</li> </li>
<li class="btn-group"> </ul>
<button class="btn btn-default dropdown-toggle action-open-file" <ul class="nav pull-right">
data-toggle="dropdown" title="Open local document"> <li><span class="file-title-navbar"></span></li>
<i class="icon-folder-open"></i>
</button>
<ul id="file-selector" class="dropdown-menu">
<li class="stick">
<div class="input-prepend">
<span class="add-on"><i class="icon-search"></i></span><input
type="text" id="file-search" class="span3">
</div>
</li>
</ul>
</li>
<li class="btn-group"><button class="btn btn-default action-open-stackedit"
title="Open StackEdit">
<i class="icon-provider-stackedit"></i>
</button></li>
</ul> </ul>
<ul class="nav pull-right"> <ul class="nav pull-right">
<li><i class="working-indicator icon-none"></i></li> <li><i class="working-indicator icon-none"></i></li>
<li><span class="brand file-title-navbar"></span></li>
</ul> </ul>
</div> </div>
</div> </div>
<div id="wmd-button-bar" class="hide"></div> <div id="wmd-button-bar" class="hide"></div>
<textarea id="wmd-input" class="hide"></textarea> <textarea id="wmd-input" class="hide"></textarea>
<div class="preview-container"> <div class="ui-layout-center preview-container"></div>
<div id="preview-contents">
<div id="wmd-preview" class="preview-content"></div> <div class="menu-panel collapse width">
<button class="btn btn-success collapse-button action-open-stackedit" title="Open StackEdit">
<i class="icon-left-dir"></i> <img src="img/stackedit-64.png"
width="32" height="32" />
</button>
</div>
<div class="document-panel collapse width">
<button class="btn btn-success collapse-button" data-toggle="collapse"
data-target=".document-panel" title="Select document">
<i class="icon-folder-open"></i> <i class="icon-right-dir"></i>
</button>
<div class="search-bar clearfix">
<div class="input-group">
<span class="input-group-addon"><i class="icon-search"></i></span><input
type="text" class="form-control"></input>
<button type="button" class="close" title="clear">&times;</button>
<div class="input-group-btn">
<a data-toggle="modal" data-target=".modal-document-manager"
class="btn btn-link" title="Manage documents"><i
class="icon-layers"></i></a>
</div>
</div>
</div>
<div class="panel-content">
<div class="list-group document-list"></div>
<div class="list-group document-list-filtered hide"></div>
</div> </div>
</div> </div>
<div class="modal modal-non-unique"> <div class="modal modal-non-unique">
<div class="modal-header"> <div class="modal-dialog">
<h3>Ooops...</h3> <div class="modal-content">
</div>
<div class="modal-body"> <div class="modal-header">
<p>StackEdit has stopped because another instance was running in <h3 class="modal-title">Ooops...</h3>
the same browser.</p> </div>
<blockquote class="muted">If you want to reopen <div class="modal-body">
StackEdit, click on "Reload".</blockquote> <p>StackEdit has stopped because another instance was running in
</div> the same browser.</p>
<div class="modal-footer"> <blockquote class="muted">If you want to reopen
<a href="javascript:window.location.reload();" class="btn btn-primary">Reload</a> StackEdit, click on "Reload".</blockquote>
</div>
<div class="modal-footer">
<a href="javascript:window.location.reload();"
class="btn btn-primary">Reload</a>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -84,6 +84,7 @@ if(location.search.match(/(\?|&)console/)) {
logger = console; logger = console;
} }
var viewerMode = /(^| )viewer($| )/.test(document.body.className);
var theme = localStorage.theme || 'default'; var theme = localStorage.theme || 'default';
// RequireJS entry point. By requiring synchronizer, publisher and // RequireJS entry point. By requiring synchronizer, publisher and

View File

@ -231,25 +231,28 @@ define([
'</li>' '</li>'
].join(''); ].join('');
eventMgr.addListener("onReady", function() { eventMgr.addListener("onReady", function() {
// Add every provider in the panel menu if(viewerMode === false) {
var publishMenuElt = document.querySelector('.menu-panel .collapse-publish-on .nav'); // Add every provider in the panel menu
var publishMenuHtml = _.reduce(providerMap, function(result, provider) { var publishMenuElt = document.querySelector('.menu-panel .collapse-publish-on .nav');
return result + _.template(initPublishButtonTmpl, { var publishMenuHtml = _.reduce(providerMap, function(result, provider) {
provider: provider return result + _.template(initPublishButtonTmpl, {
provider: provider
});
}, '');
publishMenuElt.innerHTML = publishMenuHtml;
_.each(providerMap, function(provider) {
// Click on open publish dialog
$(publishMenuElt.querySelector('.action-init-publish-' + provider.providerId)).click(function() {
initNewLocation(provider);
});
// Click on perform new publication
$(".action-publish-" + provider.providerId).click(function() {
initNewLocation(provider);
});
}); });
}, ''); }
publishMenuElt.innerHTML = publishMenuHtml;
_.each(providerMap, function(provider) {
// Click on open publish dialog
$(publishMenuElt.querySelector('.action-init-publish-' + provider.providerId)).click(function() {
initNewLocation(provider);
});
// Click on perform new publication
$(".action-publish-" + provider.providerId).click(function() {
initNewLocation(provider);
});
});
//
$(".action-process-publish").click(performNewLocation); $(".action-process-publish").click(performNewLocation);
// Save As menu items // Save As menu items

View File

@ -1,3 +1,3 @@
@import "main.less" @import "main.less"
@primary-bg: #d7dee3; @primary-bg: #d5dde3;

View File

@ -225,11 +225,11 @@ body {
padding: 0; padding: 0;
.left-space { .left-space {
width: 30px; width: 30px;
height: 38px; height: @input-height-base;
} }
.right-space { .right-space {
width: 20px; width: 20px;
height: 38px; height: @input-height-base;
} }
.nav { .nav {
float: left; float: left;
@ -299,6 +299,7 @@ body {
.menu-panel, .document-panel { .menu-panel, .document-panel {
display: block; display: block;
position: absolute; position: absolute;
top: 0;
height: 100%; height: 100%;
z-index: 10; z-index: 10;
overflow: initial; overflow: initial;
@ -480,7 +481,7 @@ body {
input { input {
cursor: pointer; cursor: pointer;
margin: 0 16px; margin: 0 16px;
height: 38px; height: @input-height-base;
} }
} }
.input-rename { .input-rename {
@ -1076,21 +1077,19 @@ div.jGrowl {
*******************/ *******************/
.viewer { .viewer {
#navbar { .file-title-navbar {
position: fixed; line-height: @input-height-base;
}
.navbar-inner {
background-color: rgba(215, 215, 215, 0.75) !important;
} }
#preview-contents { #preview-contents {
max-width: 1024px; max-width: 1024px;
margin: 50px auto; margin: 0 auto;
} }
.btn-group { .document-panel .search-bar {
margin-right: 0; padding: 20px 20px 10px;
margin-left: 0; .input-group-btn {
display: none;
}
} }
} }

View File

@ -13,23 +13,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="msvalidate.01" content="5E47EE6F67B069C17E3CDD418351A612" /> <meta name="msvalidate.01" content="5E47EE6F67B069C17E3CDD418351A612" />
<script> <script>
// Use http://.../?debug to serve original CSS/JavaScript files instead of minified // Use http://.../?debug to serve original JavaScript files instead of minified
var suffix = ""; var mainModule = "main";
if(!location.search.match(/(\?|&)debug/)) { if(!location.search.match(/(\?|&)debug/)) {
suffix = "-min"; mainModule += "-min";
}
document.write('<link href="css/main' + suffix + '.css" rel="stylesheet">');
var theme = localStorage.theme;
if(theme) {
document.write('<link href="themes/' + theme + '/' + theme + '.css" rel="stylesheet">');
} }
var require = { var require = {
baseUrl: "js", baseUrl: "js",
deps: [ deps: [
"main" + suffix mainModule
] ]
}; };
var viewerMode = true;
</script> </script>
<script src="js/libs/require.js"></script> <script src="js/libs/require.js"></script>
</head> </head>