From d7621c2c01074bdcabd6a8c1a8e95c95d00319bf Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 29 Aug 2014 17:41:33 +0200 Subject: add multipaste support Signed-off-by: Florian Pritz --- data/css/style.css | 44 ++++++++++++++++++++++++++++++-------------- data/js/script.js | 34 +++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 27 deletions(-) (limited to 'data') diff --git a/data/css/style.css b/data/css/style.css index 5f1286e82..cd8bfa4d2 100644 --- a/data/css/style.css +++ b/data/css/style.css @@ -62,6 +62,10 @@ width: 200px; } +.file-upload { + width: 100%; +} + .navbar-nav > li > .dropdown-menu { margin-top: 2px; } @@ -119,6 +123,11 @@ textarea.text-upload { word-wrap: normal; } +.alert-wide { + text-align: center; + border-radius: 0; +} + code, pre, textarea { font-family: "Dejavu sans mono", Monaco, monospace; } @@ -184,13 +193,23 @@ body { padding-left: 0; } -.paste-container { - padding-top: 40px; - background: #eee; - padding: 3px; +.container-wide { + padding: 0; max-width: 100%; margin-left: 20px; margin-right: 20px; + margin-bottom: 20px; +} + +.simple-container { + margin-left: 20px; + margin-right: 20px; + margin-bottom: 20px; +} + +.paste-container { + padding: 3px; + background: #eee; } .code pre { @@ -265,9 +284,6 @@ body { .highlight_line { background: #ffffcc; } -#file-info { - display: none; -} .ui-autocomplete { z-index: 1500; @@ -276,29 +292,29 @@ body { .popover { word-break: break-word; word-wrap: normal; + max-width: 400px; } -.upload_history_thumbnails { +.upload_thumbnails { margin: 0 auto; - padding-bottom: 50px; } -.upload_history_thumbnails img.thumb, -.upload_history_thumbnails a { +.upload_thumbnails img.thumb, +.upload_thumbnails a { width: 150px; height: 150px; } -.upload_history_thumbnails a { +.upload_thumbnails a { margin: 1px; display: inline-block; } -.upload_history_thumbnails .marked { +.upload_thumbnails .marked { background: red; } -.upload_history_thumbnails .marked img { +.upload_thumbnails .marked img { opacity: 0.4; } diff --git a/data/js/script.js b/data/js/script.js index 2c4969685..77336a88e 100644 --- a/data/js/script.js +++ b/data/js/script.js @@ -10,7 +10,7 @@ function fixedEncodeURIComponent (str) { $('.highlight_line').removeClass("highlight_line"); - if (hash.match(/^#n\d+$/) === null) { + if (hash.match(/^#n(?:-.+-)?\d+$/) === null) { return; } @@ -25,22 +25,24 @@ function fixedEncodeURIComponent (str) { lexer_source.push({ label: window.lexers[key], value: key }); } - $('#language').autocomplete({ + $('[id^=language-]').autocomplete({ source: lexer_source, select: function(event, ui) { - window.location = window.paste_base + '/' + fixedEncodeURIComponent(ui.item.value); + event.preventDefault(); + window.location = $(event.target).data("base-url") + '/' + fixedEncodeURIComponent(ui.item.value); } }); - $(document).on("keyup", "#language", function(event) { + $(document).on("keyup", "[id^=language-]", function(event) { if (event.keyCode == 13) { - window.location = window.paste_base + '/' + fixedEncodeURIComponent($(this).val()); + event.preventDefault(); + window.location = $(event.target).data("base-url") + '/' + fixedEncodeURIComponent($(this).val()); } }); - $('#language-toggle').click(function() { + $('[id^=language-toggle-]').click(function(event) { setTimeout(function() { - $('#language').focus(); + $(event.target).parent().find('[id^=language-]').focus(); }, 0); }); @@ -54,7 +56,7 @@ function fixedEncodeURIComponent (str) { }); window.lines_wrapped = true; - $('#linewrap').click(function() { + $('[id^=linewrap-]').click(function() { if (window.lines_wrapped == true) { $(".highlight > pre").css("white-space", "pre"); } else { @@ -63,7 +65,7 @@ function fixedEncodeURIComponent (str) { window.lines_wrapped = !window.lines_wrapped; }); - $('.upload_history_thumbnails a').popover({ + $('.upload_thumbnails a').popover({ trigger: "hover", placement: "bottom", html: true, @@ -75,7 +77,7 @@ function fixedEncodeURIComponent (str) { window.page_mode = "normal"; $('#delete_button').hide(); $("#delete_form input[id^='delete_']").remove(); - $(".upload_history_thumbnails .marked").removeClass("marked"); + $(".upload_thumbnails .marked").removeClass("marked"); break; default: window.page_mode = "delete"; @@ -84,7 +86,7 @@ function fixedEncodeURIComponent (str) { } }); - $('.upload_history_thumbnails a').on("click", function(event) { + $('.upload_thumbnails a').on("click", function(event) { if (window.page_mode == "delete") { event.preventDefault(); var data_id = $(event.target).parent().attr("data-id"); @@ -105,8 +107,14 @@ function fixedEncodeURIComponent (str) { }); function handle_resize() { - var div = $('.upload_history_thumbnails'); - div.width(div.parent().width() - (div.parent().width() % div.find('a').outerWidth(true))); + $('.upload_thumbnails').each(function() { + var div = $(this); + + need_multiple_lines = div.parent().width() < (div.find('a').outerWidth(true) * div.find('a').size()); + + div.css('margin-left', need_multiple_lines ? "auto" : "0"); + div.width(div.parent().width() - (div.parent().width() % div.find('a').outerWidth(true))); + }); } $(window).resize(function() { -- cgit v1.2.3-24-g4f1b