Upgrade to Bootstrap 3

This commit is contained in:
benweet 2013-08-09 00:32:03 +01:00
parent 917675a66d
commit 623332347b
3 changed files with 51 additions and 14 deletions

View File

@ -1,6 +1,7 @@
define([ define([
"jquery", "jquery",
"underscore", "underscore",
"crel",
"utils", "utils",
"settings", "settings",
"eventMgr", "eventMgr",
@ -13,7 +14,7 @@ define([
"config", "config",
"libs/layout", "libs/layout",
"libs/Markdown.Editor" "libs/Markdown.Editor"
], function($, _, utils, settings, eventMgr, mousetrap, bodyIndexHTML, bodyViewerHTML, settingsTemplateTooltipHTML, settingsUserCustomExtensionTooltipHTML) { ], function($, _, crel, utils, settings, eventMgr, mousetrap, bodyIndexHTML, bodyViewerHTML, settingsTemplateTooltipHTML, settingsUserCustomExtensionTooltipHTML) {
var core = {}; var core = {};
@ -171,6 +172,17 @@ define([
documentPanelElt.show(); documentPanelElt.show();
} }
} }
// Set the preview button visibility
var previewButtonsElt = undefined;
function setPreviewButtonsVisibility(forceHide) {
if(forceHide === true || layout.state.east.isClosed) {
previewButtonsElt.hide();
}
else {
previewButtonsElt.show();
}
}
// Create the layout // Create the layout
function createLayout() { function createLayout() {
@ -183,6 +195,7 @@ define([
slidable: false, slidable: false,
livePaneResizing: true, livePaneResizing: true,
enableCursorHotkey: false, enableCursorHotkey: false,
resizerDblClickToggle: false,
spacing_open: 15, spacing_open: 15,
spacing_closed: 15, spacing_closed: 15,
togglerLength_open: 90, togglerLength_open: 90,
@ -192,26 +205,30 @@ define([
center__minHeight: 200, center__minHeight: 200,
onopen: function() { onopen: function() {
setPanelVisibility(); setPanelVisibility();
setPreviewButtonsVisibility();
}, },
onclose_start: function(paneName) { onclose_start: function(paneName) {
if(paneName == 'north') { if(paneName == 'north') {
setPanelVisibility(true); setPanelVisibility(true);
} }
else if(paneName == 'east') {
setPreviewButtonsVisibility(true);
}
}, },
}; };
eventMgr.onLayoutConfigure(layoutGlobalConfig); eventMgr.onLayoutConfigure(layoutGlobalConfig);
if(settings.layoutOrientation == "horizontal") { if(settings.layoutOrientation == "horizontal") {
$(".ui-layout-south").remove(); $(".ui-layout-south").remove();
$(".preview-container").html('<div id="extension-preview-buttons"></div><div id="preview-contents"><div id="wmd-preview" class="preview-content"></div></div>'); $(".preview-container").html('<div id="preview-contents"><div id="wmd-preview" class="preview-content"></div></div>');
layout = $('body').layout($.extend(layoutGlobalConfig, { layout = $('body').layout($.extend(layoutGlobalConfig, {
east__resizable: true, east__resizable: true,
east__size: .5, east__size: .5,
east__minSize: 200 east__minSize: 250
})); }));
} }
else if(settings.layoutOrientation == "vertical") { else if(settings.layoutOrientation == "vertical") {
$(".ui-layout-east").remove(); $(".ui-layout-east").remove();
$(".preview-container").html('<div id="extension-preview-buttons"></div><div id="preview-contents"><div id="wmd-preview" class="preview-content"></div></div>'); $(".preview-container").html('<div id="preview-contents"><div id="wmd-preview" class="preview-content"></div></div>');
layout = $('body').layout($.extend(layoutGlobalConfig, { layout = $('body').layout($.extend(layoutGlobalConfig, {
south__resizable: true, south__resizable: true,
south__size: .5, south__size: .5,
@ -221,10 +238,21 @@ define([
$(".navbar").click(function() { $(".navbar").click(function() {
layout.allowOverflow('north'); layout.allowOverflow('north');
}); });
$(".ui-layout-toggler-north").addClass("btn btn-info").append($("<b>").addClass("caret")); $(".ui-layout-toggler-north").addClass("btn btn-info").html('<b class="caret"></b>');
$(".ui-layout-toggler-south").addClass("btn btn-info").append($("<b>").addClass("caret")); $(".ui-layout-toggler-south").addClass("btn btn-info").html('<b class="caret"></b>');
$(".ui-layout-toggler-east").addClass("btn btn-info").append($("<b>").addClass("caret")); $(".ui-layout-toggler-east").addClass("btn btn-info").html('<b class="caret"></b>');
// We attach the preview buttons to the UI layout resizer in order to have fixed position
previewButtonsElt = $('<div class="extension-preview-buttons">');
if(settings.layoutOrientation == "horizontal") {
$('.ui-layout-resizer-north').append(previewButtonsElt);
}
else {
$('.ui-layout-resizer-south').append(previewButtonsElt);
}
setPanelVisibility(); setPanelVisibility();
setPreviewButtonsVisibility();
eventMgr.onLayoutCreated(layout); eventMgr.onLayoutCreated(layout);
} }

View File

@ -238,14 +238,23 @@ define([
logger.log("onCreatePreviewButton"); logger.log("onCreatePreviewButton");
var onCreatePreviewButtonListenerList = getExtensionListenerList("onCreatePreviewButton"); var onCreatePreviewButtonListenerList = getExtensionListenerList("onCreatePreviewButton");
var extensionPreviewButtonsFragment = document.createDocumentFragment(); var extensionPreviewButtonsFragment = document.createDocumentFragment();
var previewButtonsElt = crel('div', {
class: 'extension-preview-buttons'
});
extensionPreviewButtonsFragment.appendChild(previewButtonsElt);
_.each(onCreatePreviewButtonListenerList, function(listener) { _.each(onCreatePreviewButtonListenerList, function(listener) {
previewButtonsElt.appendChild(createBtn(listener)); extensionPreviewButtonsFragment.appendChild(createBtn(listener));
}); });
document.querySelector('.ui-layout-resizer-north').appendChild(extensionPreviewButtonsFragment); var previewButtonsElt = document.querySelector('.extension-preview-buttons');
previewButtonsElt.appendChild(extensionPreviewButtonsFragment);
// A bit of jQuery...
previewButtonsElt = $(previewButtonsElt);
var previewButtonsWidth = previewButtonsElt.width();
previewButtonsElt.find('.btn-group').each(function() {
var btnGroupElt = $(this);
// Align dropdown to the left of the screen
btnGroupElt.find('.dropdown-menu').css({
right: -previewButtonsWidth + btnGroupElt.width() + btnGroupElt.position().left
});
});
} }
// Call onReady listeners // Call onReady listeners

View File

@ -388,7 +388,7 @@ Override Bootstrap
z-index: 1; z-index: 1;
font-size: 14px; font-size: 14px;
.dropdown-menu { .dropdown-menu {
border: 0 !important; border: 0;
margin-top: 1px; margin-top: 1px;
} }
.btn { .btn {