From 2751892e1273a0bc998084daffe476beb30757b8 Mon Sep 17 00:00:00 2001 From: Daniel Hug Date: Sat, 19 Apr 2014 00:02:03 -0700 Subject: [PATCH 1/4] CSS: Only show preview pane to printer --- public/res/styles/main.less | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/public/res/styles/main.less b/public/res/styles/main.less index f13c24b1..2ed6cb42 100644 --- a/public/res/styles/main.less +++ b/public/res/styles/main.less @@ -1375,3 +1375,29 @@ div.jGrowl { .box-shadow(none); } } + + +/************************************** + * Only show preview pane to printer + **************************************/ + +@media print { + html, body, .preview-container { + overflow: visible !important; + } + + body > :not(.preview-container) { + display: none !important; + } + + .preview-container { + width: auto !important; + height: auto !important; + position: static !important; + } + + #preview-contents { + max-width: none !important; + margin-bottom: 0 !important; + } +} From a0e9f5fc007533c6852b90599571ef61b7aa9e55 Mon Sep 17 00:00:00 2001 From: benweet Date: Mon, 21 Apr 2014 18:21:03 +0100 Subject: [PATCH 2/4] Added link to StackEdit 4 beta --- public/res/core.js | 34 +++++----- public/res/styles/main.less | 129 +++++++++++++++++++----------------- 2 files changed, 86 insertions(+), 77 deletions(-) diff --git a/public/res/core.js b/public/res/core.js index 40c89e5c..5ba1fb09 100644 --- a/public/res/core.js +++ b/public/res/core.js @@ -28,7 +28,7 @@ define([ ], function($, _, crel, ace, constants, utils, storage, settings, eventMgr, shortcutMgr, mousetrap, bodyIndexHTML, bodyViewerHTML, settingsTemplateTooltipHTML, settingsUserCustomExtensionTooltipHTML) { var core = {}; - + // Used for periodic tasks var intervalId; @@ -53,7 +53,7 @@ define([ } return userActive && windowUnique; } - + // Used to only have 1 window of the application in the same browser var windowId; function checkWindowUnique() { @@ -147,7 +147,7 @@ define([ utils.setInputValue("#input-settings-pdf-page-size", settings.pdfPageSize); // SSH proxy utils.setInputValue("#input-settings-ssh-proxy", settings.sshProxy); - + // Load shortcuts settings shortcutMgr.loadSettings(); @@ -454,7 +454,7 @@ define([ } layout.resizeAll(); } - + // Create the PageDown editor var editor; var $editorElt; @@ -551,7 +551,7 @@ define([ } documentContent = newDocumentContent; } - + var previewWrapper; if(window.lightMode) { editor = new Markdown.EditorLight(converter); @@ -578,7 +578,7 @@ define([ $(".modal-insert-image").modal(); return true; }); - + if(settings.lazyRendering === true) { previewWrapper = function(makePreview) { var debouncedMakePreview = _.debounce(makePreview, 500); @@ -658,7 +658,7 @@ define([ $("#wmd-undo-button").append($('')).appendTo($btnGroupElt); $("#wmd-redo-button").append($('')).appendTo($btnGroupElt); }; - + // Initialize multiple things and then fire eventMgr.onReady var isDocumentPanelShown = false; var isMenuPanelShown = false; @@ -675,13 +675,13 @@ define([ $leftBtnDropdown = $navbarElt.find('.left-buttons-dropdown'); $rightBtnDropdown = $navbarElt.find('.right-buttons-dropdown'); $(window).bind("resize", adjustWindow); - + // Initialize utils library utils.init(); - + // Populate shortcuts in settings shortcutMgr.addSettingEntries(); - + // Hide shortcuts settings if light mode if(window.lightMode) { $('.tab-settings-shortcuts').hide(); @@ -773,14 +773,14 @@ define([ return $('\n\n'; -}), define("text!html/buttonHtmlCodeSettingsBlock.html", [], function() { - return '

Adds a "HTML code" button over the preview.

\n
\n
\n \n
\n \n
\n
\n
'; -}), define("extensions/buttonHtmlCode", [ "jquery", "underscore", "utils", "classes/Extension", "text!html/buttonHtmlCode.html", "text!html/buttonHtmlCodeSettingsBlock.html" ], function(e, t, n, i, o, r) { - var s = new i("buttonHtmlCode", 'Button "HTML code"', !0, !0); - s.settingsBlock = r, s.defaultConfig = { - template: "<%= documentHTML %>" - }, s.onLoadSettings = function() { - n.setInputValue("#textarea-html-code-template", s.config.template); - }, s.onSaveSettings = function(e) { - e.template = n.getInputValue("#textarea-html-code-template"); - }; - var a; - s.onEventMgrCreated = function(e) { - a = e; - }, s.onCreatePreviewButton = function() { - return o; - }; - var l; - s.onFileSelected = function(e) { - l = e; - }; - var c; - return s.onPreviewFinished = function(e, n) { - try { - var i = t.template(s.config.template, { - documentTitle: l.title, - documentMarkdown: l.content, - strippedDocumentMarkdown: l.content.substring(l.frontMatter ? l.frontMatter._frontMatter.length : 0), - documentHTML: n, - documentHTMLWithComments: e, - frontMatter: l.frontMatter, - publishAttributes: void 0 - }); - c.value = i; - } catch (o) { - return a.onError(o), o.message; - } - }, s.onReady = function() { - c = document.getElementById("input-html-code"), e(".action-html-code").click(function() { - t.defer(function() { - e("#input-html-code").each(function() { - e(this).is(":hidden") || this.select(); - }); - }); - }); - }, s; -}), define("text!html/buttonViewer.html", [], function() { - return '\n \n\n'; -}), define("extensions/buttonViewer", [ "jquery", "classes/Extension", "text!html/buttonViewer.html" ], function(e, t, n) { - var i = new t("buttonViewer", 'Button "Viewer"', !0, !0); - return i.settingsBlock = '

Adds a "Viewer" button over the preview.

', i.onCreatePreviewButton = function() { - return n; - }, i; -}), !jQuery) throw new Error("Bootstrap requires jQuery"); - -+function(e) { - function t() { - var e = document.createElement("bootstrap"), t = { - WebkitTransition: "webkitTransitionEnd", - MozTransition: "transitionend", - OTransition: "oTransitionEnd otransitionend", - transition: "transitionend" - }; - for (var n in t) if (void 0 !== e.style[n]) return { - end: t[n] - }; - } - e.fn.emulateTransitionEnd = function(t) { - var n = !1, i = this; - e(this).one(e.support.transition.end, function() { - n = !0; - }); - var o = function() { - n || e(i).trigger(e.support.transition.end); - }; - return setTimeout(o, t), this; - }, e(function() { - e.support.transition = t(); - }); -}(window.jQuery), +function(e) { - var t = '[data-dismiss="alert"]', n = function(n) { - e(n).on("click", t, this.close); - }; - n.prototype.close = function(t) { - function n() { - r.trigger("closed.bs.alert").remove(); - } - var i = e(this), o = i.attr("data-target"); - o || (o = i.attr("href"), o = o && o.replace(/.*(?=#[^\s]*$)/, "")); - var r = e(o); - t && t.preventDefault(), r.length || (r = i.hasClass("alert") ? i : i.parent()), - r.trigger(t = e.Event("close.bs.alert")), t.isDefaultPrevented() || (r.removeClass("in"), - e.support.transition && r.hasClass("fade") ? r.one(e.support.transition.end, n).emulateTransitionEnd(150) : n()); - }; - var i = e.fn.alert; - e.fn.alert = function(t) { - return this.each(function() { - var i = e(this), o = i.data("bs.alert"); - o || i.data("bs.alert", o = new n(this)), "string" == typeof t && o[t].call(i); - }); - }, e.fn.alert.Constructor = n, e.fn.alert.noConflict = function() { - return e.fn.alert = i, this; - }, e(document).on("click.bs.alert.data-api", t, n.prototype.close); -}(window.jQuery), +function(e) { - var t = function(n, i) { - this.$element = e(n), this.options = e.extend({}, t.DEFAULTS, i); - }; - t.DEFAULTS = { - loadingText: "loading..." - }, t.prototype.setState = function(e) { - var t = "disabled", n = this.$element, i = n.is("input") ? "val" : "html", o = n.data(); - e += "Text", o.resetText || n.data("resetText", n[i]()), n[i](o[e] || this.options[e]), - setTimeout(function() { - "loadingText" == e ? n.addClass(t).attr(t, t) : n.removeClass(t).removeAttr(t); - }, 0); - }, t.prototype.toggle = function() { - var e = this.$element.closest('[data-toggle="buttons"]'); - if (e.length) { - var t = this.$element.find("input").prop("checked", !this.$element.hasClass("active")).trigger("change"); - "radio" === t.prop("type") && e.find(".active").removeClass("active"); - } - this.$element.toggleClass("active"); - }; - var n = e.fn.button; - e.fn.button = function(n) { - return this.each(function() { - var i = e(this), o = i.data("bs.button"), r = "object" == typeof n && n; - o || i.data("bs.button", o = new t(this, r)), "toggle" == n ? o.toggle() : n && o.setState(n); - }); - }, e.fn.button.Constructor = t, e.fn.button.noConflict = function() { - return e.fn.button = n, this; - }, e(document).on("click.bs.button.data-api", "[data-toggle^=button]", function(t) { - var n = e(t.target); - n.hasClass("btn") || (n = n.closest(".btn")), n.button("toggle"), t.preventDefault(); - }); -}(window.jQuery), +function(e) { - var t = function(t, n) { - this.$element = e(t), this.$indicators = this.$element.find(".carousel-indicators"), - this.options = n, this.paused = this.sliding = this.interval = this.$active = this.$items = null, - "hover" == this.options.pause && this.$element.on("mouseenter", e.proxy(this.pause, this)).on("mouseleave", e.proxy(this.cycle, this)); - }; - t.DEFAULTS = { - interval: 5e3, - pause: "hover", - wrap: !0 - }, t.prototype.cycle = function(t) { - return t || (this.paused = !1), this.interval && clearInterval(this.interval), this.options.interval && !this.paused && (this.interval = setInterval(e.proxy(this.next, this), this.options.interval)), - this; - }, t.prototype.getActiveIndex = function() { - return this.$active = this.$element.find(".item.active"), this.$items = this.$active.parent().children(), - this.$items.index(this.$active); - }, t.prototype.to = function(t) { - var n = this, i = this.getActiveIndex(); - return t > this.$items.length - 1 || 0 > t ? void 0 : this.sliding ? this.$element.one("slid", function() { - n.to(t); - }) : i == t ? this.pause().cycle() : this.slide(t > i ? "next" : "prev", e(this.$items[t])); - }, t.prototype.pause = function(t) { - return t || (this.paused = !0), this.$element.find(".next, .prev").length && e.support.transition.end && (this.$element.trigger(e.support.transition.end), - this.cycle(!0)), this.interval = clearInterval(this.interval), this; - }, t.prototype.next = function() { - return this.sliding ? void 0 : this.slide("next"); - }, t.prototype.prev = function() { - return this.sliding ? void 0 : this.slide("prev"); - }, t.prototype.slide = function(t, n) { - var i = this.$element.find(".item.active"), o = n || i[t](), r = this.interval, s = "next" == t ? "left" : "right", a = "next" == t ? "first" : "last", l = this; - if (!o.length) { - if (!this.options.wrap) return; - o = this.$element.find(".item")[a](); - } - this.sliding = !0, r && this.pause(); - var c = e.Event("slide.bs.carousel", { - relatedTarget: o[0], - direction: s - }); - if (!o.hasClass("active")) { - if (this.$indicators.length && (this.$indicators.find(".active").removeClass("active"), - this.$element.one("slid", function() { - var t = e(l.$indicators.children()[l.getActiveIndex()]); - t && t.addClass("active"); - })), e.support.transition && this.$element.hasClass("slide")) { - if (this.$element.trigger(c), c.isDefaultPrevented()) return; - o.addClass(t), o[0].offsetWidth, i.addClass(s), o.addClass(s), i.one(e.support.transition.end, function() { - o.removeClass([ t, s ].join(" ")).addClass("active"), i.removeClass([ "active", s ].join(" ")), - l.sliding = !1, setTimeout(function() { - l.$element.trigger("slid"); - }, 0); - }).emulateTransitionEnd(600); - } else { - if (this.$element.trigger(c), c.isDefaultPrevented()) return; - i.removeClass("active"), o.addClass("active"), this.sliding = !1, this.$element.trigger("slid"); - } - return r && this.cycle(), this; - } - }; - var n = e.fn.carousel; - e.fn.carousel = function(n) { - return this.each(function() { - var i = e(this), o = i.data("bs.carousel"), r = e.extend({}, t.DEFAULTS, i.data(), "object" == typeof n && n), s = "string" == typeof n ? n : r.slide; - o || i.data("bs.carousel", o = new t(this, r)), "number" == typeof n ? o.to(n) : s ? o[s]() : r.interval && o.pause().cycle(); - }); - }, e.fn.carousel.Constructor = t, e.fn.carousel.noConflict = function() { - return e.fn.carousel = n, this; - }, e(document).on("click.bs.carousel.data-api", "[data-slide], [data-slide-to]", function(t) { - var n, i = e(this), o = e(i.attr("data-target") || (n = i.attr("href")) && n.replace(/.*(?=#[^\s]+$)/, "")), r = e.extend({}, o.data(), i.data()), s = i.attr("data-slide-to"); - s && (r.interval = !1), o.carousel(r), (s = i.attr("data-slide-to")) && o.data("bs.carousel").to(s), - t.preventDefault(); - }), e(window).on("load", function() { - e('[data-ride="carousel"]').each(function() { - var t = e(this); - t.carousel(t.data()); - }); - }); -}(window.jQuery), +function(e) { - var t = function(n, i) { - this.$element = e(n), this.options = e.extend({}, t.DEFAULTS, i), this.transitioning = null, - this.options.parent && (this.$parent = e(this.options.parent)), this.options.toggle && this.toggle(); - }; - t.DEFAULTS = { - toggle: !0 - }, t.prototype.dimension = function() { - var e = this.$element.hasClass("width"); - return e ? "width" : "height"; - }, t.prototype.show = function() { - if (!this.transitioning && !this.$element.hasClass("in")) { - var t = e.Event("show.bs.collapse"); - if (this.$element.trigger(t), !t.isDefaultPrevented()) { - var n = this.$parent && this.$parent.find("> .panel > .in"); - if (n && n.length) { - var i = n.data("bs.collapse"); - if (i && i.transitioning) return; - n.collapse("hide"), i || n.data("bs.collapse", null); - } - var o = this.dimension(); - this.$element.removeClass("collapse").addClass("collapsing")[o](0), this.transitioning = 1; - var r = function() { - this.$element.removeClass("collapsing").addClass("in")[o]("auto"), this.transitioning = 0, - this.$element.trigger("shown.bs.collapse"); - }; - if (!e.support.transition) return r.call(this); - var s = e.camelCase([ "scroll", o ].join("-")); - this.$element.one(e.support.transition.end, e.proxy(r, this)).emulateTransitionEnd(350)[o](this.$element[0][s]); - } - } - }, t.prototype.hide = function() { - if (!this.transitioning && this.$element.hasClass("in")) { - var t = e.Event("hide.bs.collapse"); - if (this.$element.trigger(t), !t.isDefaultPrevented()) { - var n = this.dimension(); - this.$element[n](this.$element[n]())[0].offsetHeight, this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"), - this.transitioning = 1; - var i = function() { - this.transitioning = 0, this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse"); - }; - return e.support.transition ? (this.$element[n](0).one(e.support.transition.end, e.proxy(i, this)).emulateTransitionEnd(350), - void 0) : i.call(this); - } - } - }, t.prototype.toggle = function() { - this[this.$element.hasClass("in") ? "hide" : "show"](); - }; - var n = e.fn.collapse; - e.fn.collapse = function(n) { - return this.each(function() { - var i = e(this), o = i.data("bs.collapse"), r = e.extend({}, t.DEFAULTS, i.data(), "object" == typeof n && n); - o || i.data("bs.collapse", o = new t(this, r)), "string" == typeof n && o[n](); - }); - }, e.fn.collapse.Constructor = t, e.fn.collapse.noConflict = function() { - return e.fn.collapse = n, this; - }, e(document).on("click.bs.collapse.data-api", "[data-toggle=collapse]", function(t) { - var n, i = e(this), o = i.attr("data-target") || t.preventDefault() || (n = i.attr("href")) && n.replace(/.*(?=#[^\s]+$)/, ""), r = e(o), s = r.data("bs.collapse"), a = s ? "toggle" : i.data(), l = i.attr("data-parent"), c = l && e(l); - s && s.transitioning || (c && c.find('[data-toggle=collapse][data-parent="' + l + '"]').not(i).addClass("collapsed"), - i[r.hasClass("in") ? "addClass" : "removeClass"]("collapsed")), r.collapse(a); - }); -}(window.jQuery), +function(e) { - function t() { - e(i).remove(), e(o).each(function(t) { - var i = n(e(this)); - i.hasClass("open") && (i.trigger(t = e.Event("hide.bs.dropdown")), t.isDefaultPrevented() || i.removeClass("open").trigger("hidden.bs.dropdown")); - }); - } - function n(t) { - var n = t.attr("data-target"); - n || (n = t.attr("href"), n = n && /#/.test(n) && n.replace(/.*(?=#[^\s]*$)/, "")); - var i = n && e(n); - return i && i.length ? i : t.parent(); - } - var i = ".dropdown-backdrop", o = "[data-toggle=dropdown]", r = function(t) { - e(t).on("click.bs.dropdown", this.toggle); - }; - r.prototype.toggle = function(i) { - var o = e(this); - if (!o.is(".disabled, :disabled")) { - var r = n(o), s = r.hasClass("open"); - if (t(), !s) { - if ("ontouchstart" in document.documentElement && !r.closest(".navbar-nav").length && e('