summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/css/style.css48
-rw-r--r--data/js/jquery.metadata.js120
-rw-r--r--data/js/script.js106
3 files changed, 217 insertions, 57 deletions
diff --git a/data/css/style.css b/data/css/style.css
index 5f1286e82..18a8e8bb1 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;
}
@@ -81,8 +85,8 @@
@media (min-width: 768px) {
.anchor {
visibility: hidden;
- padding-top: 60px;
- margin-top: -60px;
+ padding-top: 70px;
+ margin-top: -70px;
}
#navbar-height {
@@ -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/jquery.metadata.js b/data/js/jquery.metadata.js
new file mode 100644
index 000000000..eb98e80ad
--- /dev/null
+++ b/data/js/jquery.metadata.js
@@ -0,0 +1,120 @@
+/*
+ * Metadata - jQuery plugin for parsing metadata from elements
+ *
+ * Copyright (c) 2006 John Resig, Yehuda Katz, Jörn Zaefferer, Paul McLanahan
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ */
+
+/**
+ * Sets the type of metadata to use. Metadata is encoded in JSON, and each property
+ * in the JSON will become a property of the element itself.
+ *
+ * There are three supported types of metadata storage:
+ *
+ * attr: Inside an attribute. The name parameter indicates *which* attribute.
+ *
+ * class: Inside the class attribute, wrapped in curly braces: { }
+ *
+ * elem: Inside a child element (e.g. a script tag). The
+ * name parameter indicates *which* element.
+ *
+ * The metadata for an element is loaded the first time the element is accessed via jQuery.
+ *
+ * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
+ * matched by expr, then redefine the metadata type and run another $(expr) for other elements.
+ *
+ * @name $.metadata.setType
+ *
+ * @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
+ * @before $.metadata.setType("class")
+ * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
+ * @desc Reads metadata from the class attribute
+ *
+ * @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
+ * @before $.metadata.setType("attr", "data")
+ * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
+ * @desc Reads metadata from a "data" attribute
+ *
+ * @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
+ * @before $.metadata.setType("elem", "script")
+ * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
+ * @desc Reads metadata from a nested script element
+ *
+ * @param String type The encoding type
+ * @param String name The name of the attribute to be used to get metadata (optional)
+ * @cat Plugins/Metadata
+ * @descr Sets the type of encoding to be used when loading metadata for the first time
+ * @type undefined
+ * @see metadata()
+ */
+
+(function($) {
+
+$.extend({
+ metadata : {
+ defaults : {
+ type: 'class',
+ name: 'metadata',
+ cre: /({.*})/,
+ single: 'metadata'
+ },
+ setType: function( type, name ){
+ this.defaults.type = type;
+ this.defaults.name = name;
+ },
+ get: function( elem, opts ){
+ var settings = $.extend({},this.defaults,opts);
+ // check for empty string in single property
+ if ( !settings.single.length ) settings.single = 'metadata';
+
+ var data = $.data(elem, settings.single);
+ // returned cached data if it already exists
+ if ( data ) return data;
+
+ data = "{}";
+
+ if ( settings.type == "class" ) {
+ var m = settings.cre.exec( elem.className );
+ if ( m )
+ data = m[1];
+ } else if ( settings.type == "elem" ) {
+ if( !elem.getElementsByTagName )
+ return undefined;
+ var e = elem.getElementsByTagName(settings.name);
+ if ( e.length )
+ data = $.trim(e[0].innerHTML);
+ } else if ( elem.getAttribute != undefined ) {
+ var attr = elem.getAttribute( settings.name );
+ if ( attr )
+ data = attr;
+ }
+
+ if ( data.indexOf( '{' ) <0 )
+ data = "{" + data + "}";
+
+ data = eval("(" + data + ")");
+
+ $.data( elem, settings.single, data );
+ return data;
+ }
+ }
+});
+
+/**
+ * Returns the metadata object for the first member of the jQuery object.
+ *
+ * @name metadata
+ * @descr Returns element's metadata object
+ * @param Object opts An object contianing settings to override the defaults
+ * @type jQuery
+ * @cat Plugins/Metadata
+ */
+$.fn.metadata = function( opts ){
+ return $.metadata.get( this[0], opts );
+};
+
+})(jQuery); \ No newline at end of file
diff --git a/data/js/script.js b/data/js/script.js
index ea9bac814..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() {
@@ -118,15 +126,26 @@ function fixedEncodeURIComponent (str) {
if (window.File && window.FileList) {
function checkFileUpload(evt) {
var sum = 0;
- var files = evt.target.files;
+ var filenum = 0;
+ var files = [];
+
+ $('.file-upload').each(function() {
+ for (var i = 0; i < this.files.length; i++) {
+ var file = this.files[i];
+ files.push(file);
+ }
+ });
- // TODO: check all forms, not only the one we are called from
for (var i = 0; i < files.length; i++) {
- var f = evt.target.files[i];
+ var f = files[i];
sum += f.size;
+ filenum++;
}
- if (sum > max_upload_size) {
+ if (filenum > max_files_per_upload) {
+ document.getElementById('upload_button').innerHTML = "Too many files";
+ document.getElementById('upload_button').disabled = true;
+ } else if (sum > max_upload_size) {
document.getElementById('upload_button').innerHTML = "File(s) too big";
document.getElementById('upload_button').disabled = true;
} else {
@@ -135,9 +154,25 @@ function fixedEncodeURIComponent (str) {
}
}
- $('.file-upload').bind('change', checkFileUpload);
+ $(document).on('change', '.file-upload', checkFileUpload);
}
+ $(document).on("change", '.file-upload', function() {
+ var need_new = true;
+
+ $('.file-upload').each(function() {
+ if ($(this).prop("files").length == 0) {
+ need_new = false;
+ return;
+ }
+ });
+
+ if (need_new) {
+ $(this).parent().append('<input class="file-upload" type="file" name="file[]" multiple="multiple"><br>');
+ }
+
+ });
+
if (typeof $.tablesorter !== 'undefined') {
// source: https://projects.archlinux.org/archweb.git/tree/sitestatic/archweb.js
$.tablesorter.addParser({
@@ -185,30 +220,19 @@ function fixedEncodeURIComponent (str) {
},
type: 'numeric'
});
- $.tablesorter.addParser({
- // set a unique id
- id: 'mydate',
- re: /t=([0-9]+)$/,
- is: function(s) {
- // return false so this parser is not auto detected
- return false;
- },
- format: function(s) {
- var matches = this.re.exec(s);
- if (!matches) {
- return 0;
+
+ $(".tablesorter").tablesorter({
+ textExtraction: function(node) {
+ var attr = $(node).attr('data-sort-value');
+ if (typeof attr !== 'undefined' && attr !== false) {
+ var intAttr = parseInt(attr);
+ if (!isNaN(intAttr)) {
+ return intAttr;
+ }
+ return attr;
}
- //console.log(s, matches);
- return matches[1];
- },
- type: 'numeric'
- });
- $("#upload_history:has(tbody tr)").tablesorter({
- headers: {
- 0: {sorter: false},
- 4: {sorter: "mydate"},
- },
- sortList: [[4,1]],
+ return $(node).text();
+ }
});
}