From 7488c14cf867fecc07fbd6daaab5e19350cb207c Mon Sep 17 00:00:00 2001 From: benweet Date: Sun, 18 Aug 2013 01:02:23 +0100 Subject: [PATCH] Upgrade to Bootstrap 3 --- css/jgrowl.css | 4 +- js/core.js | 27 ++--- js/extensions/documentPanel.js | 2 +- js/extensions/documentSelector.js | 106 ++++++++---------- js/extensions/notifications.js | 2 +- js/fileMgr.js | 7 +- js/html/bodyIndex.html | 2 +- js/libs/bootstrap/bootstrap.js | 14 ++- js/libs/bootstrap/less/buttons.less | 3 +- js/libs/bootstrap/less/dropdowns.less | 7 +- js/libs/bootstrap/less/grid.less | 10 +- js/libs/bootstrap/less/mixins.less | 58 ++++------ js/libs/bootstrap/less/navbar.less | 28 ++--- js/libs/bootstrap/less/navs.less | 21 ++-- js/libs/bootstrap/less/pager.less | 2 +- js/libs/bootstrap/less/panels.less | 5 +- .../bootstrap/less/responsive-utilities.less | 49 ++++---- js/libs/bootstrap/less/tables.less | 9 ++ js/libs/bootstrap/less/variables.less | 29 +++-- js/styles/default.less | 12 +- 20 files changed, 197 insertions(+), 200 deletions(-) diff --git a/css/jgrowl.css b/css/jgrowl.css index f4502435..380aff79 100644 --- a/css/jgrowl.css +++ b/css/jgrowl.css @@ -1,6 +1,6 @@ div.jGrowl { - z-index: 1050; + z-index: 1040; color: #fff; } @@ -48,7 +48,7 @@ div.center div.jGrowl-notification, div.center div.jGrowl-closer { div.jGrowl div.jGrowl-notification, div.jGrowl div.jGrowl-closer { background-color: #777; zoom: 1; - width: 280px; + width: 260px; padding: 15px 20px; margin-top: 5px; margin-bottom: 5px; diff --git a/js/core.js b/js/core.js index 6866d755..2d5e8a85 100644 --- a/js/core.js +++ b/js/core.js @@ -195,6 +195,7 @@ define([ slidable: false, livePaneResizing: true, enableCursorHotkey: false, + resizerDblClickToggle: false, north__spacing_open: 6, north__spacing_closed: 6, spacing_open: 35, @@ -266,6 +267,7 @@ define([ var editor = undefined; var fileDesc = undefined; var documentContent = undefined; + var $editorElt = undefined; core.initEditor = function(fileDescParam) { if(fileDesc !== undefined) { eventMgr.onFileClosed(fileDesc); @@ -273,8 +275,7 @@ define([ fileDesc = fileDescParam; documentContent = undefined; var initDocumentContent = fileDesc.content; - var editorElt = $("#wmd-input"); - editorElt.val(initDocumentContent); + $editorElt.val(initDocumentContent); if(editor !== undefined) { // If the editor is already created editor.undoManager.reinit(initDocumentContent, fileDesc.editorStart, fileDesc.editorEnd, fileDesc.editorScrollTop); @@ -285,13 +286,13 @@ define([ var previewContainerElt = $(".preview-container"); // Store editor scrollTop on scroll event - editorElt.scroll(function() { + $editorElt.scroll(function() { if(documentContent !== undefined) { fileDesc.editorScrollTop = $(this).scrollTop(); } }); // Store editor selection on change - editorElt.bind("keyup mouseup", function() { + $editorElt.bind("keyup mouseup", function() { if(documentContent !== undefined) { fileDesc.editorStart = this.selectionStart; fileDesc.editorEnd = this.selectionEnd; @@ -347,7 +348,7 @@ define([ }); function checkDocumentChanges() { - var newDocumentContent = editorElt.val(); + var newDocumentContent = $editorElt.val(); if(documentContent !== undefined && documentContent != newDocumentContent) { fileDesc.content = newDocumentContent; eventMgr.onContentChanged(fileDesc); @@ -361,7 +362,7 @@ define([ return function() { if(documentContent === undefined) { makePreview(); - editorElt.scrollTop(fileDesc.editorScrollTop); + $editorElt.scrollTop(fileDesc.editorScrollTop); previewContainerElt.scrollTop(fileDesc.previewScrollTop); } else { @@ -416,7 +417,7 @@ define([ var uiLocked = false; core.lockUI = function(param) { uiLocked = param; - $("#wmd-input").prop("disabled", uiLocked); + $editorElt.prop("disabled", uiLocked); $(".navbar-inner .btn").toggleClass("blocked", uiLocked); if(uiLocked) { $(".lock-ui").removeClass("hide"); @@ -430,7 +431,6 @@ define([ var isDocumentPanelShown = false; var isMenuPanelShown = false; core.onReady = function() { - if(viewerMode === true) { $('body').html(bodyViewerHTML); } @@ -509,6 +509,7 @@ define([ // UI layout createLayout(); + $editorElt = $("#wmd-input"); // Editor's textarea $("#wmd-input, #md-section-helper").css({ @@ -519,15 +520,11 @@ define([ }); // Handle tab key - $("#wmd-input").keydown(function(e) { + $editorElt.keydown(function(e) { if(e.keyCode === 9) { - var value = $(this).val(); + var value = $editorElt.val(); var start = this.selectionStart; var end = this.selectionEnd; - // IE8 does not support selection attributes - if(start === undefined || end === undefined) { - return; - } $(this).val(value.substring(0, start) + "\t" + value.substring(end)); this.selectionStart = this.selectionEnd = start + 1; e.preventDefault(); @@ -570,7 +567,7 @@ define([ }).on('hidden.bs.modal', function() { // Focus on the editor when modal is gone isModalShown = false; - $("#wmd-input").focus(); + $editorElt.focus(); }).keyup(function(e) { // Handle enter key in modals if(e.which == 13 && !$(e.target).is("textarea")) { diff --git a/js/extensions/documentPanel.js b/js/extensions/documentPanel.js index c3b65968..fa9c9c71 100644 --- a/js/extensions/documentPanel.js +++ b/js/extensions/documentPanel.js @@ -173,7 +173,7 @@ define([ filterFiles(''); // Scroll to the active file - panelContentElt.scrollTop += documentListElt.querySelector('.file.active').getBoundingClientRect().top - 100; + panelContentElt.scrollTop += documentListElt.querySelector('.file.active').getBoundingClientRect().top - 120; } }); diff --git a/js/extensions/documentSelector.js b/js/extensions/documentSelector.js index 490835be..de11cfe8 100644 --- a/js/extensions/documentSelector.js +++ b/js/extensions/documentSelector.js @@ -1,12 +1,13 @@ define([ "jquery", "underscore", + "crel", "utils", "classes/Extension", "mousetrap", "fileSystem", "text!html/documentSelectorSettingsBlock.html", -], function($, _, utils, Extension, mousetrap, fileSystem, documentSelectorSettingsBlockHTML) { +], function($, _, crel, utils, Extension, mousetrap, fileSystem, documentSelectorSettingsBlockHTML) { var documentSelector = new Extension("documentSelector", 'Document Selector'); documentSelector.settingsBlock = documentSelectorSettingsBlockHTML; @@ -33,33 +34,45 @@ define([ fileMgr = fileMgrParameter; }; + var liEltTmpl = [ + '
  • " data-file-index="<%= fileDesc.fileIndex %>">', + ' ', + ' <%= fileDesc.composeTitle() %>', + ' ', + '
  • ' + ].join(''); + var $editorElt = undefined; var dropdownElt = undefined; - var liMap = undefined; - var liArray = undefined; + var liEltMap = undefined; + var liEltList = undefined; var sortFunction = undefined; var selectFileDesc = undefined; var buildSelector = function() { + var liListHtml = _.chain(fileSystem).sortBy(sortFunction).reduce(function(result, fileDesc) { + return result + _.template(liEltTmpl, { + fileDesc: fileDesc, + isCurrent: fileDesc === selectFileDesc + }); + }, '').value(); + dropdownElt.innerHTML = liListHtml; - liMap = {}; - dropdownElt.empty(); - _.chain(fileSystem).sortBy(sortFunction).each(function(fileDesc) { - var aElt = $('').html(fileDesc.composeTitle()); - aElt.click(function() { - if(!liMap[fileDesc.fileIndex].is(".disabled")) { + liEltList = []; + liEltMap = {}; + _.each(dropdownElt.querySelectorAll('li'), function(liElt) { + var $liElt = $(liElt); + liEltList.push($liElt); + var fileDesc = fileSystem[$liElt.data('fileIndex')]; + liEltMap[fileDesc.fileIndex] = $liElt; + $liElt.find("a").click(function() { + if(!$liElt.hasClass("disabled")) { fileMgr.selectFile(fileDesc); } else { - $("#wmd-input").focus(); + $editorElt.focus(); } }); - var liElt = $("
  • ").append(aElt); - liMap[fileDesc.fileIndex] = liElt; - if(fileDesc === selectFileDesc) { - liElt.addClass("disabled"); - } - dropdownElt.append(liElt); }); - liArray = _.values(liMap); + }; documentSelector.onFileSelected = function(fileDesc) { @@ -93,6 +106,8 @@ define([ } documentSelector.onReady = function() { + $editorElt = $("#wmd-input"); + if(documentSelector.config.orderBy == "title") { sortFunction = function(fileDesc) { return fileDesc.title.toLowerCase(); @@ -103,41 +118,16 @@ define([ return -fileDesc.selectTime; }; } - - dropdownElt = $('