From dbaaa0c40a7a96306185f9431b008a72bc153dd5 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 14:52:44 +0100 Subject: watch.js & slugify fix --- js/watch.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/watch.js b/js/watch.js index a202130f..8ac026a7 100644 --- a/js/watch.js +++ b/js/watch.js @@ -98,6 +98,9 @@ $(function(){ else { bc.threads = bc.threads || {}; bc.threads[thread] = Date.now(); + + bc.slugs = bc.slugs || {}; + bc.slugs[thread] = document.location.pathname + document.location.search; } st[board] = bc; storage_save(st); @@ -121,7 +124,7 @@ $(function(){ var tag; if (variant == 'desktop') { - tag = $("#"+tid+""+newposts+""); + tag = $("#"+tid+""+newposts+""); tag.find(".watch-remove").mouseenter(function() { this.oldval = $(this).html(); $(this).css("min-width", $(this).width()); @@ -132,7 +135,7 @@ $(function(){ }) } else if (variant == 'mobile') { - tag = $("#"+tid+""+newposts+"" + tag = $("#"+tid+""+newposts+"" +""); } -- cgit v1.3 From e7d3097e5a0b8a07f726bd9540d678523ff2d8eb Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Wed, 11 Mar 2015 16:35:49 -0400 Subject: Removed extra space for some options --- js/forced-anon.js | 2 +- js/no-animated-gif.js | 2 +- js/toggle-images.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/forced-anon.js b/js/forced-anon.js index 5ea68199..11327ec9 100644 --- a/js/forced-anon.js +++ b/js/forced-anon.js @@ -64,7 +64,7 @@ $(document).ready(function() { if (window.Options && Options.get_tab('general')) { selector = '#forced-anon'; event = 'change'; - Options.extend_tab("general", ""); + Options.extend_tab("general", ""); } else { selector = '#forced-anon'; diff --git a/js/no-animated-gif.js b/js/no-animated-gif.js index 45a55f97..a10a6497 100644 --- a/js/no-animated-gif.js +++ b/js/no-animated-gif.js @@ -57,7 +57,7 @@ if (active_page == 'thread' || active_page == 'index' || active_page == 'ukko' | if (window.Options && Options.get_tab('general')) { selector = '#no-animated-gif>input'; event = 'change'; - Options.extend_tab("general", ""); + Options.extend_tab("general", ""); } else { selector = '#no-animated-gif'; diff --git a/js/toggle-images.js b/js/toggle-images.js index 20940ccf..b8940252 100644 --- a/js/toggle-images.js +++ b/js/toggle-images.js @@ -60,7 +60,7 @@ $(document).ready(function(){ if (window.Options && Options.get_tab('general')) { selector = '#toggle-images>input'; event = 'change'; - Options.extend_tab("general", ""); + Options.extend_tab("general", ""); } else { selector = '#toggle-images a'; -- cgit v1.3 From 158371dc64676abdffe659f9d4763745d0b77300 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 23 Mar 2015 00:33:19 +0100 Subject: switch to hotwheels' wPaint branch --- js/wPaint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/wPaint b/js/wPaint index 2c272dff..f1122003 160000 --- a/js/wPaint +++ b/js/wPaint @@ -1 +1 @@ -Subproject commit 2c272dffca0f3d7b7163bd82ba15629f54409278 +Subproject commit f11220032e7edb8349516d3751d3aaee0fd0de68 -- cgit v1.3 From 9fa320838b19506d2bfd45f995298e75766530d9 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 23 Mar 2015 01:09:16 +0100 Subject: wpaint has new dependencies – important! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/wpaint.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'js') diff --git a/js/wpaint.js b/js/wpaint.js index 9c619070..67d58fc2 100644 --- a/js/wpaint.js +++ b/js/wpaint.js @@ -13,12 +13,7 @@ * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/jquery-ui.custom.min.js'; * $config['additional_javascript'][] = 'js/ajax.js'; - * $config['additional_javascript'][] = 'js/wPaint/lib/wColorPicker.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/wPaint.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/plugins/main/wPaint.menu.main.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/plugins/text/wPaint.menu.text.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/plugins/shapes/wPaint.menu.main.shapes.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/plugins/file/wPaint.menu.main.file.min.js'; + * $config['additional_javascript'][] = 'js/wPaint/8ch.js'; * $config['additional_javascript'][] = 'js/wpaint.js'; * $config['additional_javascript'][] = 'js/upload-selection.js'; * -- cgit v1.3 From 25c2a18a71e76bc70b0b04e3e7e3aaa3738a623d Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Sun, 29 Mar 2015 22:31:38 -0400 Subject: Made quick-reply box resizable horizontally --- js/quick-reply.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/quick-reply.js b/js/quick-reply.js index 07fe4aef..6661501c 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -83,11 +83,12 @@ }\ #quick-reply textarea {\ width: 100%;\ + min-width: 100%;\ box-sizing: border-box;\ -webkit-box-sizing:border-box;\ -moz-box-sizing: border-box;\ font-size: 10pt;\ - resize: vertical;\ + resize: vertical horizontal;\ }\ #quick-reply input, #quick-reply select, #quick-reply textarea {\ margin: 0 0 1px 0;\ -- cgit v1.3 From 4083c92dbe641f81c1b92fa33dd111199d5654b0 Mon Sep 17 00:00:00 2001 From: 8chan Date: Sat, 8 Nov 2014 16:56:41 -0800 Subject: Stop double posting AJAX bug --- js/ajax.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js') diff --git a/js/ajax.js b/js/ajax.js index 61d83df2..663f4426 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -141,6 +141,7 @@ $(window).ready(function() { }; setup_form($('form[name="post"]')); $(window).on('quick-reply', function() { + $('form#quick-reply').off('submit'); setup_form($('form#quick-reply')); }); }); -- cgit v1.3 From d3cc27ff5cf598ead9d0045077f69ec73bb470c6 Mon Sep 17 00:00:00 2001 From: 8chan Date: Mon, 17 Nov 2014 05:23:41 -0800 Subject: Handle XHR errors better --- js/ajax.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'js') diff --git a/js/ajax.js b/js/ajax.js index 663f4426..1b2bf2c0 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -115,17 +115,7 @@ $(window).ready(function() { } }, error: function(xhr, status, er) { - // An error occured - do_not_ajax = true; - $(form).find('input[type="submit"]').each(function() { - var $replacement = $(''); - $replacement.attr('name', $(this).attr('name')); - $replacement.val(submit_txt); - $(this) - .after($replacement) - .replaceWith($('').val(submit_txt)); - }); - $(form).submit(); + alert(_('The server returned an error or truncated response -- your post was probably still submitted. If it wasn\'t, 8chan.co might be experiencing issues right now -- please try your post again later.')); }, data: formData, cache: false, -- cgit v1.3 From 0f1d506586c2553852cb88204a3e529abace6f78 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 11 Mar 2015 02:58:03 -0700 Subject: Change this message again Conflicts: js/ajax.js --- js/ajax.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/ajax.js b/js/ajax.js index 1b2bf2c0..56f0df5c 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -115,7 +115,10 @@ $(window).ready(function() { } }, error: function(xhr, status, er) { - alert(_('The server returned an error or truncated response -- your post was probably still submitted. If it wasn\'t, 8chan.co might be experiencing issues right now -- please try your post again later.')); + console.log(xhr); + alert(_('The server took too long to submit your post. Your post was probably still submitted. If it wasn\'t, we might be experiencing issues right now -- please try your post again later. Error information: ') + "
"); + $(form).find('input[type="submit"]').val(submit_txt); + $(form).find('input[type="submit"]').removeAttr('disabled'); }, data: formData, cache: false, -- cgit v1.3 From 48cd7438a1ca7309386a44be78cb460f4e729e01 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Sun, 15 Mar 2015 22:18:58 +0800 Subject: initial commit file-selector.js --- js/file-selector.js | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 js/file-selector.js (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js new file mode 100644 index 00000000..437e1d4a --- /dev/null +++ b/js/file-selector.js @@ -0,0 +1,187 @@ +/* + * file-selector.js - Add support for drag and drop file selection, and paste from clipbboard on supported browsers. + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/file-selector.js'; + */ + +onready(function () { + +// add options panel item +$(document).ready(function () { + if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''); + + $('#file-drag-drop>input').on('click', function() { + if ($('#file-drag-drop>input').is(':checked')) { + localStorage.file_dragdrop = 'true'; + } else { + localStorage.file_dragdrop = 'false'; + } + }); + + if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; + if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); + } +}); + +// disabled by user, or incompatible browser. +// fallback to old +if (localStorage.file_dragdrop == 'false' || !(window.FileReader || window.File)) { + $('.dropzone-wrap').remove(); + $('#upload_file').show(); + + return; +} + +// multipost not enabled +if (typeof max_images == 'undefined') { + var max_images = 1; +} + +var files = []; + +function addFile(file) { + if (files.length == max_images) + return; + + files.push(file); + addThumb(file); +} + +function removeFile(file) { + files.splice(files.indexOf(file), 1); +} + +function getThumbElement(file) { + return $('.tmb-container').filter(function(){return($(this).data('file-ref')==file);}); +} + +function addThumb(file) { + + var fileName = (file.name.length < 24) ? file.name : file.name.substr(0, 22) + '…'; + var fileType = file.type.split('/')[0]; + var fileExt = file.type.split('/')[1]; + var $fileThumb; + + $('.file-thumbs').append($('
') + .addClass('tmb-container') + .data('file-ref', file) + .append( + $('
').addClass('remove-btn').html('✖'), + $('
').addClass('file-tmb'), + $('
').addClass('tmb-filename').html(fileName) + ) + ); + + if (fileType == 'image') { + // if image file, generate thumbnail + var reader = new FileReader(); + + reader.onloadend = function () { + var dataURL = reader.result; + var $fileThumb = getThumbElement(file).find('.file-tmb'); + $fileThumb.css('background-image', 'url('+ dataURL +')'); + }; + + reader.readAsDataURL(file); + } else { + $fileThumb = getThumbElement(file).find('.file-tmb'); + $fileThumb.html('' + fileExt.toUpperCase() + ''); + } +} + +$(document).on('ajax_before_post', function (e, formData) { + var i; + + for (i=0; i 0) key += i + 1; + formData.append(key, files[i]); + } + + // clear file queue and UI + files = []; + $('.file-thumbs').empty(); +}); + +var dragCounter = 0; +var dropHandlers = { + dragenter: function (e) { + e.stopPropagation(); + e.preventDefault(); + + if (dragCounter === 0) $(this).addClass('dragover'); + dragCounter++; + }, + dragover: function (e) { + // needed for webkit to work + e.stopPropagation(); + e.preventDefault(); + }, + dragleave: function (e) { + e.stopPropagation(); + e.preventDefault(); + + dragCounter--; + if (dragCounter === 0) $(this).removeClass('dragover'); + }, + drop: function (e) { + e.stopPropagation(); + e.preventDefault(); + + $(this).removeClass('dragover'); + dragCounter = 0; + + var fileList = e.originalEvent.dataTransfer.files; + for (var i=0; i'); + + $fileSelector.on('change', function (e) { + if (this.files.length > 0) { + for (var i=0; i Date: Sun, 15 Mar 2015 23:32:53 +0800 Subject: Run on index and thread Clear file queue after upload success corrected fallback detection --- js/file-selector.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index 437e1d4a..c820db48 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -6,29 +6,28 @@ * $config['additional_javascript'][] = 'js/file-selector.js'; */ -onready(function () { +if (active_page == 'index' || active_page == 'thread') { +$(document).ready(function () { // add options panel item -$(document).ready(function () { - if (window.Options && Options.get_tab('general')) { - Options.extend_tab('general', ''); - - $('#file-drag-drop>input').on('click', function() { - if ($('#file-drag-drop>input').is(':checked')) { - localStorage.file_dragdrop = 'true'; - } else { - localStorage.file_dragdrop = 'false'; - } - }); +if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''); + + $('#file-drag-drop>input').on('click', function() { + if ($('#file-drag-drop>input').is(':checked')) { + localStorage.file_dragdrop = 'true'; + } else { + localStorage.file_dragdrop = 'false'; + } + }); - if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; - if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); - } -}); + if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; + if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); +} // disabled by user, or incompatible browser. // fallback to old -if (localStorage.file_dragdrop == 'false' || !(window.FileReader || window.File)) { +if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) { $('.dropzone-wrap').remove(); $('#upload_file').show(); @@ -93,15 +92,15 @@ function addThumb(file) { } $(document).on('ajax_before_post', function (e, formData) { - var i; - - for (i=0; i 0) key += i + 1; formData.append(key, files[i]); } +}); - // clear file queue and UI +// clear file queue and UI on success +$(document).on('ajax_after_post', function () { files = []; $('.file-thumbs').empty(); }); @@ -185,3 +184,4 @@ $(document).on('paste', function (e) { }); }); +} -- cgit v1.3 From 3bd7f94861e9a2a8b9a7f8f972f04eb6eaa45453 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Wed, 18 Mar 2015 18:44:47 +0800 Subject: Fallback for browsers that disables javascript Conflicts: stylesheets/style.css templates/post_form.html --- js/file-selector.js | 3 +- stylesheets/style.css | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ templates/post_form.html | 8 +++++ 3 files changed, 91 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index c820db48..ddae2d09 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -140,7 +140,8 @@ var dropHandlers = { } }; -$('.dropzone').css('user-select', 'none') // let jquery add browser specific prefix +$('#upload input[type=file]').hide(); // hide the original file selector +$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix // attach handlers $(document).on(dropHandlers, '.dropzone'); diff --git a/stylesheets/style.css b/stylesheets/style.css index e0ce08c5..56140561 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -959,3 +959,84 @@ span.pln { cursor: pointer; } +#youtube-size input { + width: 50px; +} + +/* File selector */ +.dropzone { + color: #000; + cursor: default; + margin: auto; + padding: 0px 4px; + text-align: center; + min-height: 50px; + max-height: 140px; + transition: 0.2s; + background-color: rgba(200, 200, 200, 0.5); + overflow-y: auto; +} +.dropzone-wrap { + width: 100%; +} +.dropzone .file-hint { + color: rgba(0, 0, 0, 0.5); + cursor: pointer; + position: relative; + margin-bottom: 5px; + padding: 10px 0px; + top: 5px; + transition: 0.2s; + border: 2px dashed rgba(125, 125, 125, 0.4); +} +.file-hint:hover, .dropzone.dragover .file-hint { + color: rgba(0, 0, 0, 1); + border-color: rgba(125, 125, 125, 0.8); +} +.dropzone.dragover { + background-color: rgba(200, 200, 200, 1); +} +.dropzone .file-thumbs { + text-align: left; + width: 100%; +} +.dropzone .tmb-container { + padding: 3px; + overflow-x: hidden; + white-space: nowrap; +} +.dropzone .file-tmb { + height: 40px; + width: 70px; + cursor: pointer; + display: inline-block; + text-align: center; + background-color: rgba(187, 187, 187, 0.5); + background-size: cover; + background-position: center; +} +.dropzone .file-tmb span { + font-weight: 600; + position: relative; + top: 13px; +} +.dropzone .tmb-filename { + display: inline-block; + vertical-align: bottom; + bottom: 12px; + position: relative; + margin-left: 5px; +} +.dropzone .remove-btn { + cursor: pointer; + color: rgba(125, 125, 125, 0.5); + display: inline-block; + vertical-align: bottom; + bottom: 10px; + position: relative; + margin-right: 5px; + font-size: 20px +} +.dropzone .remove-btn:hover { + color: rgba(125, 125, 125, 1); +} diff --git a/templates/post_form.html b/templates/post_form.html index 1846adb5..9596ee6b 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -98,6 +98,14 @@ + + + {% if config.allow_upload_by_url %}
: -- cgit v1.3 From 0005f11098890ad76c1b9963792cd686493649a9 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Wed, 18 Mar 2015 21:35:58 +0800 Subject: initialize file selector soon as it's loaded Conflicts: templates/post_form.html --- js/file-selector.js | 44 +++++++++++++++++++------------------------- templates/post_form.html | 2 ++ 2 files changed, 21 insertions(+), 25 deletions(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index ddae2d09..b4589706 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -5,34 +5,29 @@ * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/file-selector.js'; */ +function init_file_selector() { -if (active_page == 'index' || active_page == 'thread') { $(document).ready(function () { + // add options panel item + if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''); + + $('#file-drag-drop>input').on('click', function() { + if ($('#file-drag-drop>input').is(':checked')) { + localStorage.file_dragdrop = 'true'; + } else { + localStorage.file_dragdrop = 'false'; + } + }); -// add options panel item -if (window.Options && Options.get_tab('general')) { - Options.extend_tab('general', ''); - - $('#file-drag-drop>input').on('click', function() { - if ($('#file-drag-drop>input').is(':checked')) { - localStorage.file_dragdrop = 'true'; - } else { - localStorage.file_dragdrop = 'false'; - } - }); - - if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; - if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); -} + if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; + if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); + } +}); // disabled by user, or incompatible browser. -// fallback to old -if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) { - $('.dropzone-wrap').remove(); - $('#upload_file').show(); - +if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) return; -} // multipost not enabled if (typeof max_images == 'undefined') { @@ -40,6 +35,8 @@ if (typeof max_images == 'undefined') { } var files = []; +$('#upload_file').hide(); // hide the original file selector +$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix function addFile(file) { if (files.length == max_images) @@ -140,8 +137,6 @@ var dropHandlers = { } }; -$('#upload input[type=file]').hide(); // hide the original file selector -$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix // attach handlers $(document).on(dropHandlers, '.dropzone'); @@ -184,5 +179,4 @@ $(document).on('paste', function (e) { } }); -}); } diff --git a/templates/post_form.html b/templates/post_form.html index 9596ee6b..809230f0 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -106,6 +106,8 @@
+ + {% if config.allow_upload_by_url %}
: -- cgit v1.3 From 4da073b6e85aae15b8eed227b3b3b16798d2a99e Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Thu, 19 Mar 2015 19:29:48 +0800 Subject: Keep quick-reply and main form in sync Use object-url instead of data-url due to shorter length --- js/file-selector.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index b4589706..e5451f1a 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -26,7 +26,7 @@ $(document).ready(function () { }); // disabled by user, or incompatible browser. -if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) +if (localStorage.file_dragdrop == 'false' || !(window.URL.createObjectURL && window.File)) return; // multipost not enabled @@ -59,9 +59,9 @@ function addThumb(file) { var fileName = (file.name.length < 24) ? file.name : file.name.substr(0, 22) + '…'; var fileType = file.type.split('/')[0]; var fileExt = file.type.split('/')[1]; - var $fileThumb; + var $container = $('
'); - $('.file-thumbs').append($('
') + $container .addClass('tmb-container') .data('file-ref', file) .append( @@ -69,21 +69,14 @@ function addThumb(file) { $('
').addClass('file-tmb'), $('
').addClass('tmb-filename').html(fileName) ) - ); + .appendTo($('.file-thumbs')); + var $fileThumb = $container.find('.file-tmb'); if (fileType == 'image') { // if image file, generate thumbnail - var reader = new FileReader(); - - reader.onloadend = function () { - var dataURL = reader.result; - var $fileThumb = getThumbElement(file).find('.file-tmb'); - $fileThumb.css('background-image', 'url('+ dataURL +')'); - }; - - reader.readAsDataURL(file); + var objURL = window.URL.createObjectURL(file); + $fileThumb.css('background-image', 'url('+ objURL +')'); } else { - $fileThumb = getThumbElement(file).find('.file-tmb'); $fileThumb.html('' + fileExt.toUpperCase() + ''); } } @@ -144,8 +137,8 @@ $(document).on(dropHandlers, '.dropzone'); $(document).on('click', '.dropzone .remove-btn', function (e) { var file = $(e.target).parent().data('file-ref'); + getThumbElement(file).remove(); removeFile(file); - $(e.target).parent().remove(); }); $(document).on('click', '.dropzone .file-hint', function (e) { -- cgit v1.3 From 6e84a25f9a882bc4c2cbd1e376416ac34ca9943b Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Fri, 20 Mar 2015 08:53:57 +0800 Subject: Adds keyboard focus to file selector --- js/file-selector.js | 10 +++++++++- templates/post_form.html | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index e5451f1a..dbe8ea82 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -135,13 +135,21 @@ var dropHandlers = { $(document).on(dropHandlers, '.dropzone'); $(document).on('click', '.dropzone .remove-btn', function (e) { + e.stopPropagation(); + var file = $(e.target).parent().data('file-ref'); getThumbElement(file).remove(); removeFile(file); }); -$(document).on('click', '.dropzone .file-hint', function (e) { +$(document).on('keypress click', '.dropzone, .dropzone .file-hint', function (e) { + e.stopPropagation(); + + // accept mosue click or Enter + if (e.which != 1 || e.which != 13) + return; + var $fileSelector = $(''); $fileSelector.on('change', function (e) { diff --git a/templates/post_form.html b/templates/post_form.html index 809230f0..7cdcc7d3 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -100,7 +100,7 @@ - + {% if config.allow_upload_by_url %}
-- cgit v1.3 From 419d69b4eea23b1ec92762d2ba2771ac0b46a315 Mon Sep 17 00:00:00 2001 From: 8chan Date: Thu, 19 Mar 2015 20:34:54 -0700 Subject: ayylmao @marktaiwan --- js/file-selector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index 687920d0..6a7e6773 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -147,7 +147,7 @@ $(document).on('keypress click', '.dropzone, .dropzone .file-hint', function (e) e.stopPropagation(); // accept mosue click or Enter - if (e.which != 1 || e.which != 13) + if (e.which != 1 && e.which != 13) return; var $fileSelector = $(''); -- cgit v1.3 From e42ffb27684e159473320c512052246f081d04f0 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Fri, 20 Mar 2015 12:48:32 +0800 Subject: fix file selector element reference fix thumbnail image not applying to main form with quick reply open --- js/file-selector.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index 6a7e6773..9869e347 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -59,9 +59,7 @@ function addThumb(file) { var fileName = (file.name.length < 24) ? file.name : file.name.substr(0, 22) + '…'; var fileType = file.type.split('/')[0]; var fileExt = file.type.split('/')[1]; - var $container = $('
'); - - $container + var $container = $('
') .addClass('tmb-container') .data('file-ref', file) .append( @@ -69,7 +67,7 @@ function addThumb(file) { $('
').addClass('file-tmb'), $('
').addClass('tmb-filename').html(fileName) ) - .appendTo($('.file-thumbs')); + .appendTo('.file-thumbs'); var $fileThumb = $container.find('.file-tmb'); if (fileType == 'image') { -- cgit v1.3 From 6f94a0658603f3f39032655b3cebe738c2bced0d Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Sun, 22 Mar 2015 22:15:43 +0800 Subject: file selector: correct typo, click event target --- js/file-selector.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index 9869e347..fc9c83e2 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -141,11 +141,12 @@ $(document).on('click', '.dropzone .remove-btn', function (e) { removeFile(file); }); -$(document).on('keypress click', '.dropzone, .dropzone .file-hint', function (e) { +$(document).on('keypress click', '.dropzone', function (e) { e.stopPropagation(); - // accept mosue click or Enter - if (e.which != 1 && e.which != 13) + // accept mouse click or Enter + if ((e.which != 1 || e.target.className != 'file-hint') && + e.which != 13) return; var $fileSelector = $(''); -- cgit v1.3 From 765dea599bd010bc00a3a40df58953b239ec0e9d Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 06:50:05 +0200 Subject: trivial fixes to file-selector.js --- js/file-selector.js | 11 ++++++++++- js/upload-selection.js | 2 ++ templates/post_form.html | 7 ------- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index fc9c83e2..6aad9382 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -34,8 +34,16 @@ if (typeof max_images == 'undefined') { var max_images = 1; } +$(''+ +'
').prependTo('#upload td'); + var files = []; -$('#upload_file').hide(); // hide the original file selector +$('#upload_file').remove(); // remove the original file selector $('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix function addFile(file) { @@ -83,6 +91,7 @@ $(document).on('ajax_before_post', function (e, formData) { for (var i=0; i 0) key += i + 1; + if (typeof files[i] === 'undefined') break; formData.append(key, files[i]); } }); diff --git a/js/upload-selection.js b/js/upload-selection.js index e2032748..b342a134 100644 --- a/js/upload-selection.js +++ b/js/upload-selection.js @@ -25,6 +25,7 @@ $(function(){ $("#upload_url").hide(); $("#upload_embed").hide(); $(".add_image").hide(); + $(".dropzone-wrap").hide(); $('[id^=upload_file]').each(function(i, v) { $(v).val(''); @@ -40,6 +41,7 @@ $(function(){ enable_file = function() { disable_all(); $("#upload").show(); + $(".dropzone-wrap").show(); $(".file_separator").show(); $("[id^=upload_file]").show(); $(".add_image").show(); diff --git a/templates/post_form.html b/templates/post_form.html index 00390daf..d6a77452 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -99,13 +99,6 @@ - - {% if config.allow_upload_by_url %} -- cgit v1.3 From c74fc6cefb69e751ee3a8b6c65eeb22f6e499753 Mon Sep 17 00:00:00 2001 From: anonish Date: Thu, 29 Jan 2015 21:44:11 -0600 Subject: QR fix for tablet (portrait) mode in laptops Quick reply will now show up on tablets in portrait mode where width can be < 800px as originally coded (mainly 768x1280 and 800x1280) --- js/quick-reply.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/quick-reply.js b/js/quick-reply.js index 6661501c..a8145607 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -116,7 +116,7 @@ #quick-reply td.recaptcha-response {\ padding: 0 0 1px 0;\ }\ - @media screen and (max-width: 800px) {\ + @media screen and (max-width: 600px) {\ #quick-reply {\ display: none !important;\ }\ @@ -364,7 +364,7 @@ $(window).ready(function() { if (settings.get('hide_at_top', true)) { $(window).scroll(function() { - if ($(this).width() <= 800) + if ($(this).width() <= 600) return; if ($(this).scrollTop() < $origPostForm.offset().top + $origPostForm.height() - 100) $postForm.fadeOut(100); @@ -385,7 +385,7 @@ }; $(window).on('cite', function(e, id, with_link) { - if ($(this).width() <= 800) + if ($(this).width() <= 600) return; show_quick_reply(); if (with_link) { @@ -440,7 +440,7 @@ $('.quick-reply-btn').hide(); $(window).scroll(function() { - if ($(this).width() <= 800) + if ($(this).width() <= 600) return; if ($(this).scrollTop() < $('form[name="post"]:first').offset().top + $('form[name="post"]:first').height() - 100) $('.quick-reply-btn').fadeOut(100); -- cgit v1.3 From d3d54b8c764b779c6d3cf1d2a6cd49f204d60387 Mon Sep 17 00:00:00 2001 From: Anonish Date: Fri, 6 Feb 2015 20:42:13 -0600 Subject: Update quick-reply.js apparently 600 was still not allowing QR to load on portrait mode. 400 seems to work fine --- js/quick-reply.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/quick-reply.js b/js/quick-reply.js index a8145607..12cca366 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -116,7 +116,7 @@ #quick-reply td.recaptcha-response {\ padding: 0 0 1px 0;\ }\ - @media screen and (max-width: 600px) {\ + @media screen and (max-width: 400px) {\ #quick-reply {\ display: none !important;\ }\ @@ -364,7 +364,7 @@ $(window).ready(function() { if (settings.get('hide_at_top', true)) { $(window).scroll(function() { - if ($(this).width() <= 600) + if ($(this).width() <= 400) return; if ($(this).scrollTop() < $origPostForm.offset().top + $origPostForm.height() - 100) $postForm.fadeOut(100); @@ -385,7 +385,7 @@ }; $(window).on('cite', function(e, id, with_link) { - if ($(this).width() <= 600) + if ($(this).width() <= 400) return; show_quick_reply(); if (with_link) { @@ -440,7 +440,7 @@ $('.quick-reply-btn').hide(); $(window).scroll(function() { - if ($(this).width() <= 600) + if ($(this).width() <= 400) return; if ($(this).scrollTop() < $('form[name="post"]:first').offset().top + $('form[name="post"]:first').height() - 100) $('.quick-reply-btn').fadeOut(100); -- cgit v1.3 From 0e805c25d8f3044a2c6640a1e8818d3774a0ff07 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 07:20:53 +0200 Subject: file-selector.js: allow file dropping anywhere --- js/file-selector.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/file-selector.js b/js/file-selector.js index 6aad9382..207a5ae9 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -108,7 +108,7 @@ var dropHandlers = { e.stopPropagation(); e.preventDefault(); - if (dragCounter === 0) $(this).addClass('dragover'); + if (dragCounter === 0) $('.dropzone').addClass('dragover'); dragCounter++; }, dragover: function (e) { @@ -121,13 +121,13 @@ var dropHandlers = { e.preventDefault(); dragCounter--; - if (dragCounter === 0) $(this).removeClass('dragover'); + if (dragCounter === 0) $('.dropzone').removeClass('dragover'); }, drop: function (e) { e.stopPropagation(); e.preventDefault(); - $(this).removeClass('dragover'); + $('.dropzone').removeClass('dragover'); dragCounter = 0; var fileList = e.originalEvent.dataTransfer.files; @@ -139,7 +139,7 @@ var dropHandlers = { // attach handlers -$(document).on(dropHandlers, '.dropzone'); +$(document).on(dropHandlers); $(document).on('click', '.dropzone .remove-btn', function (e) { e.stopPropagation(); -- cgit v1.3 From 2f7127a3cb23d88d1b1727fc61c5c44389cc9caf Mon Sep 17 00:00:00 2001 From: Markerov Date: Sun, 2 Nov 2014 22:55:35 +0800 Subject: Catalog Search --- js/catalog-search.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 js/catalog-search.js (limited to 'js') diff --git a/js/catalog-search.js b/js/catalog-search.js new file mode 100644 index 00000000..97121e3b --- /dev/null +++ b/js/catalog-search.js @@ -0,0 +1,82 @@ +/* + * catalog-search.js + * - Search and filters threads when on catalog view + * - Optional shortcuts 's' and 'esc' to open and close the search. + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/comment-toolbar.js'; + */ +if (active_page == 'catalog') { + $(document).ready(function () { + 'use strict'; + + // 'true' = enable shortcuts + var useKeybinds = true; + + // trigger the search 400ms after last keystroke + var delay = 400; + var timeoutHandle; + + //search and hide none matching threads + function filter(search_term) { + $('.replies').each(function () { + var subject = $(this).children('.intro').text().toLowerCase(); + var comment = $(this).clone().children().remove(':lt(2)').end().text().trim().toLowerCase(); + search_term = search_term.toLowerCase(); + + if (subject.indexOf(search_term) == -1 && comment.indexOf(search_term) == -1) { + $(this).parents('div[id="Grid"]>.mix').css('display', 'none'); + } else { + $(this).parents('div[id="Grid"]>.mix').css('display', 'inline-block'); + } + }); + } + + function searchToggle() { + var button = $('#catalog_search_button')[0]; + + if (!button.dataset.expanded) { + button.dataset.expanded = '1'; + button.innerText = 'Close'; + $('.catalog_search').append(' '); + $('#search_field').focus(); + } else { + delete button.dataset.expanded; + button.innerText = 'Search'; + $('.catalog_search').children().last().remove(); + $('div[id="Grid"]>.mix').each(function () { $(this).css('display', 'inline-block'); }); + } + } + + $('.threads').before('[]'); + $('#catalog_search_button').text('Search'); + + $('#catalog_search_button').on('click', searchToggle); + $('.catalog_search').on('keyup', 'input#search_field', function (e) { + window.clearTimeout(timeoutHandle); + timeoutHandle = window.setTimeout(filter, 400, e.target.value); + }); + + if (useKeybinds) { + // 's' + $('body').on('keydown', function (e) { + if (e.which === 83 && e.target.tagName === 'BODY' && !(e.ctrlKey || e.altKey || e.shiftKey)) { + e.preventDefault(); + if ($('#search_field').length !== 0) { + $('#search_field').focus(); + } else { + searchToggle(); + } + } + }); + // 'esc' + $('.catalog_search').on('keydown', 'input#search_field', function (e) { + if (e.which === 27 && !(e.ctrlKey || e.altKey || e.shiftKey)) { + window.clearTimeout(timeoutHandle); + searchToggle(); + } + }); + } + }); +} -- cgit v1.3 From 6363d8d24721d1c3138cf3d1574f6795efe91c91 Mon Sep 17 00:00:00 2001 From: Markerov Date: Fri, 2 Jan 2015 17:13:29 +0800 Subject: change to use onready() --- js/catalog-search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/catalog-search.js b/js/catalog-search.js index 97121e3b..17a8edac 100644 --- a/js/catalog-search.js +++ b/js/catalog-search.js @@ -8,7 +8,7 @@ * $config['additional_javascript'][] = 'js/comment-toolbar.js'; */ if (active_page == 'catalog') { - $(document).ready(function () { + onready(function () { 'use strict'; // 'true' = enable shortcuts -- cgit v1.3 From 2256604dad36caca4bd3f90898f1d1040066773b Mon Sep 17 00:00:00 2001 From: topkek Date: Wed, 26 Nov 2014 21:10:27 +0000 Subject: add global option for tree view --- js/treeview.js | 71 ++++++++++++++++++++++++++++++++------------------- stylesheets/style.css | 3 ++- 2 files changed, 47 insertions(+), 27 deletions(-) (limited to 'js') diff --git a/js/treeview.js b/js/treeview.js index 78ad620b..c9bd55f8 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -11,35 +11,54 @@ * */ +if (active_page == 'thread' || active_page == 'ukko' || active_page == 'index') +$(function() { + if (window.Options && Options.get_tab('general')) { + var selector = '#treeview-global>input'; + Options.extend_tab("general", ""); + } + $(selector).on('change', function () { + if (localStorage.treeview === 'true') { + localStorage.treeview = 'false'; + } else { + localStorage.treeview = 'true'; + } + }); + if (localStorage.treeview === 'true') { + $(selector).attr('checked', 'checked'); + } +}); + if (active_page == 'thread') $(function() { + var treeview = function() { + $('.post.reply').each(function(){ + var references = []; + $(this).find('.body a').each(function(){ + if ($(this).html().match('^>>[0-9]+$')) { + references.push(parseInt($(this).html().replace('>>', ''))); + } + }); + var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0); + + var parent_post = $("#reply_"+maxref); + if (parent_post.length == 0) return; + + var margin = parseInt(parent_post.css("margin-left"))+32; + + var post = $(this); + var br = post.next(); + + post.detach().css("margin-left", margin).insertAfter(parent_post.next()); + br.detach().insertAfter(post); + }); + } + if (localStorage.treeview === 'true') { + treeview(); + } + $('hr:first').before('
'); $('div#treeview a') .text(_('Tree view')) - .click(function(e) { - e.preventDefault(); - - $('.post.reply').each(function(){ - var references = []; - $(this).find('.body a').each(function(){ - if ($(this).html().match('^>>[0-9]+$')) { - references.push(parseInt($(this).html().replace('>>', ''))); - } - }); - - var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0); - - var parent_post = $("#reply_"+maxref); - if (parent_post.length == 0) return; - - var margin = parseInt(parent_post.css("margin-left"))+32; - - var post = $(this); - var br = post.next(); - - post.detach().css("margin-left", margin).insertAfter(parent_post.next()); - br.detach().insertAfter(post); - - }); - }); + .click(function(e) { treeview(); e.preventDefault(); }); }); diff --git a/stylesheets/style.css b/stylesheets/style.css index 2565ba4f..d2cc0572 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -825,7 +825,7 @@ div.thread:hover { #options_div { width: 600px; - height: 300px; + height: 320px; } #alert_div { @@ -892,6 +892,7 @@ div.thread:hover { right: 0px; text-align: left; font-size: 12px; + overflow-y: auto; } .options_tab h2 { -- cgit v1.3 From d67351534a4d54af65b0b9d6515587c49c772934 Mon Sep 17 00:00:00 2001 From: topkek Date: Wed, 26 Nov 2014 22:48:54 +0000 Subject: toggle tree view --- js/treeview.js | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'js') diff --git a/js/treeview.js b/js/treeview.js index c9bd55f8..937ea6ff 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -31,27 +31,41 @@ $(function() { if (active_page == 'thread') $(function() { + var treeview_on = false; var treeview = function() { - $('.post.reply').each(function(){ - var references = []; - $(this).find('.body a').each(function(){ - if ($(this).html().match('^>>[0-9]+$')) { - references.push(parseInt($(this).html().replace('>>', ''))); - } - }); - var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0); - - var parent_post = $("#reply_"+maxref); - if (parent_post.length == 0) return; - - var margin = parseInt(parent_post.css("margin-left"))+32; - - var post = $(this); - var br = post.next(); + if (!treeview_on) { + treeview_on = true; + $('.post.reply').each(function(){ + var references = []; + $(this).find('.body a').each(function(){ + if ($(this).html().match('^>>[0-9]+$')) { + references.push(parseInt($(this).html().replace('>>', ''))); + } + }); + var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0); + + var parent_post = $("#reply_"+maxref); + if (parent_post.length == 0) return; + + var margin = parseInt(parent_post.css("margin-left"))+32; - post.detach().css("margin-left", margin).insertAfter(parent_post.next()); - br.detach().insertAfter(post); - }); + var post = $(this); + var br = post.next(); + + post.detach().css("margin-left", margin).insertAfter(parent_post.next()); + br.detach().insertAfter(post); + }); + } else { + treeview_on = false; + $('.post.reply').sort(function(a,b) { + return parseInt(a.id.replace('reply_', '')) > parseInt(b.id.replace('reply_', '')); + }).each(function () { + var post = $(this); + var br = post.next(); + post.detach().css('margin-left', '0').appendTo('.thread'); + br.detach().insertAfter(post); + }); + } } if (localStorage.treeview === 'true') { treeview(); -- cgit v1.3 From 1888e174b3d6ea6a506c62cc1c75c9d6acf6ff72 Mon Sep 17 00:00:00 2001 From: topkek Date: Thu, 27 Nov 2014 00:36:51 +0000 Subject: chrome fix --- js/treeview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/treeview.js b/js/treeview.js index 937ea6ff..046a9796 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -58,7 +58,7 @@ $(function() { } else { treeview_on = false; $('.post.reply').sort(function(a,b) { - return parseInt(a.id.replace('reply_', '')) > parseInt(b.id.replace('reply_', '')); + return parseInt(a.id.replace('reply_', '')) - parseInt(b.id.replace('reply_', '')); }).each(function () { var post = $(this); var br = post.next(); -- cgit v1.3 From 8de9b68f5f5386265a624678bf95214e44f9bc21 Mon Sep 17 00:00:00 2001 From: topkek Date: Fri, 28 Nov 2014 01:15:10 +0000 Subject: checkbox for tree view Conflicts: js/post-hover.js --- js/favorites.js | 1 - js/treeview.js | 21 +++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'js') diff --git a/js/favorites.js b/js/favorites.js index e325e110..daf7b732 100644 --- a/js/favorites.js +++ b/js/favorites.js @@ -54,7 +54,6 @@ if (active_page == 'thread' || active_page == 'index') { $(document).ready(function(){ var favorites = JSON.parse(localStorage.favorites); var is_board_favorite = ~$.inArray(board_name, favorites); - console.log(is_board_favorite); $('header>h1').append('\u2605'); add_favorites(); diff --git a/js/treeview.js b/js/treeview.js index 046a9796..dcd87e1e 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -31,10 +31,8 @@ $(function() { if (active_page == 'thread') $(function() { - var treeview_on = false; - var treeview = function() { - if (!treeview_on) { - treeview_on = true; + var treeview = function(enable) { + if (enable === true) { $('.post.reply').each(function(){ var references = []; $(this).find('.body a').each(function(){ @@ -56,23 +54,22 @@ $(function() { br.detach().insertAfter(post); }); } else { - treeview_on = false; $('.post.reply').sort(function(a,b) { return parseInt(a.id.replace('reply_', '')) - parseInt(b.id.replace('reply_', '')); }).each(function () { var post = $(this); var br = post.next(); - post.detach().css('margin-left', '0').appendTo('.thread'); + post.detach().css('margin-left', '').appendTo('.thread'); br.detach().insertAfter(post); }); } } + + $('hr:first').before('
'); + $('input#treeview').on('change', function(e) { treeview($(this).is(':checked')); }); + if (localStorage.treeview === 'true') { - treeview(); + treeview(true); + $('input#treeview').attr('checked', true); } - - $('hr:first').before('
'); - $('div#treeview a') - .text(_('Tree view')) - .click(function(e) { treeview(); e.preventDefault(); }); }); -- cgit v1.3 From e6da7b4682a80b63008b6f2bb550515d5c90d774 Mon Sep 17 00:00:00 2001 From: topkek Date: Fri, 28 Nov 2014 21:59:05 +0000 Subject: clean up options code --- js/treeview.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'js') diff --git a/js/treeview.js b/js/treeview.js index dcd87e1e..1709debb 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -16,16 +16,16 @@ $(function() { if (window.Options && Options.get_tab('general')) { var selector = '#treeview-global>input'; Options.extend_tab("general", ""); - } - $(selector).on('change', function () { + $(selector).on('change', function() { + if (localStorage.treeview === 'true') { + localStorage.treeview = 'false'; + } else { + localStorage.treeview = 'true'; + } + }); if (localStorage.treeview === 'true') { - localStorage.treeview = 'false'; - } else { - localStorage.treeview = 'true'; + $(selector).attr('checked', 'checked'); } - }); - if (localStorage.treeview === 'true') { - $(selector).attr('checked', 'checked'); } }); -- cgit v1.3 From d94143b6c67e1c48fee2f6ecb549fd3197a66378 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 08:58:54 +0200 Subject: fix wpaint & file-selection interaction --- js/wpaint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/wpaint.js b/js/wpaint.js index 67d58fc2..a245a22b 100644 --- a/js/wpaint.js +++ b/js/wpaint.js @@ -44,7 +44,7 @@ oekaki.init = function() { var oekaki_form = 'Oekaki
'; // Add oekaki after the file input - $('form[name="post"]:not(#quick-reply) input[type="file"]').parent().parent().after(oekaki_form); + $('form[name="post"]:not(#quick-reply) [id="upload"]').after(oekaki_form); $('').appendTo($("head")); $('').appendTo($("head")); -- cgit v1.3 From 652018f674621b13b8af0c5125cc8cf0de4b1b0f Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 7 Apr 2015 20:54:43 +0200 Subject: own-board.js: initial release --- js/own-board.js | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 js/own-board.js (limited to 'js') diff --git a/js/own-board.js b/js/own-board.js new file mode 100644 index 00000000..497c568c --- /dev/null +++ b/js/own-board.js @@ -0,0 +1,116 @@ +/***************************************************************** + * ------- WARNING! --------- * + ***************************************************************** + * This script is at the current time undocumented and * + * unsupported. It is still a work in progress and will likely * + * change. You are on your own. * + *****************************************************************/ + ++function() { + +var uniq = function(a) { + var b = {}; + var c = []; + a.forEach(function(i) { + if (!b[i]) { + c.push(i); + b[i] = true; + } + }); + return c; +}; + + +if (active_page == 'thread' || active_page == 'index') { + var board = null; + + $(function() { + board = $('input[name="board"]').first().val(); + }); + + $(document).on('ajax_after_post', function(e, r) { + var threads = JSON.parse(localStorage.obthreads || '[]'); + + var thread = null; + if (active_page == 'index') { + thread = r.id|0; + } + else { + thread = $('[id^="thread_"]').first().attr('id').replace("thread_", "")|0; + } + + threads.push([board, thread]); + threads = uniq(threads); + localStorage.obthreads = JSON.stringify(threads); + }); +} + +var loaded = false; +$(function() { + loaded = true; +}); + +var activate = function() { + if (document.location.hash != '#own') return false; + + if (loaded) late_activate(); + else $(function() { late_activate(); }); + + return true; +}; + +var late_activate = function() { + $('[id^="thread_"]').remove(); + + var threads = JSON.parse(localStorage.obthreads || '[]'); + + threads.forEach(function(v) { + var board = v[0]; + var thread = v[1]; + var url = "/"+board+"/res/"+thread+".html"; + + $.get(url, function(html) { + var s = $(html).find('[id^="thread_"]'); + + s[0].bumptime = (new Date(s.find("time").last().attr("datetime"))).getTime(); + + var added = false; + $('[id^="thread_"]').each(function() { + if (added) return; + if (s[0].bumptime > this.bumptime) { + added = true; + s.insertBefore(this); + } + }); + if (!added) { + s.appendTo('[name="postcontrols"]'); + } + + s.find('.post.reply').addClass('hidden').hide().slice(-3).removeClass('hidden').show(); + + s.find('.post.reply.hidden').next().addClass('hidden').hide(); // Hide
elements + + var posts_omitted = s.find('.post.reply.hidden').length; + var images_omitted = s.find('.post.reply.hidden img').length; + + if (posts_omitted > 0) { + var omitted = $(fmt(''+_('{0} posts and {1} images omitted.')+' '+_('Click reply to view.')+'', + [posts_omitted, images_omitted])); + + omitted.appendTo(s.find('.post.op')); + } + + var reply = $('['+_('Reply')+']').appendTo(s.find('.intro').first()); + + $(document).trigger('new_post', s[0]); + }); + }); +}; + +$(window).on("hashchange", function() { + return !activate(); +}); +activate(); + + +}(); -- cgit v1.3 From fae2e33c87d996e206e1d04dd906e667491ee8b0 Mon Sep 17 00:00:00 2001 From: ForklessAnon Date: Sat, 1 Nov 2014 04:00:45 -0500 Subject: Added script for appending thread statistics to the bottom of a thread. --- js/thread-stats.js | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 js/thread-stats.js (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js new file mode 100644 index 00000000..e6fb1142 --- /dev/null +++ b/js/thread-stats.js @@ -0,0 +1,115 @@ +/* + * thread-stats.js + * - Adds statistics of the thread below the posts area + * - Shows ID post count beside each postID on hover + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/thread-stats.js'; + */ +// THREAD STATS +if (active_page == 'thread') { + + var thread_stats_timer = 30, thread_stats_timeout; //it has to be on a timer because there I haven't found a way to hook into when the actual page updates the thread... + //check if page uses unique ID + var IDsupport = ($('.poster_id').length > 0); + var thread_id = (document.location.pathname + document.location.search).split('/'); + thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0]; + + $('form[name="postcontrols"] > .delete') + .first() + .before('
'); + var el = $('#thread_stats'); + el.prepend('Page ?'); + if (IDsupport){ + el.prepend('0 UIDs | '); + } + el.prepend('0 images | '); + el.prepend('0 replies | '); + delete el; + function update_thread_stats(force){ + var op = $('#thread_'+ thread_id +' > div.post.op:not(.post-hover):not(.inline)').first(); + var replies = $('#thread_'+ thread_id +' > div.post.reply:not(.post-hover):not(.inline)'); + // post count + $('#thread_stats_posts').text(replies.length); + // image count + $('#thread_stats_images').text(replies.filter(function(){ + return $(this).find('> .files').text().trim() != false; + }).length); + // unique ID count + if (IDsupport) { + var opID = op.find('> .intro > .poster_id').text(); + var ids = {}; + replies.each(function(){ + var cur = $(this).find('> .intro > .poster_id'); + var curID = cur.text(); + if (ids[curID] === undefined) { + ids[curID] = 0; + } + ids[curID]++; + }); + if (ids[opID] === undefined) { + ids[opID] = 0; + } + ids[opID]++; + replies.each(function(){ + var cur = $(this).find('> .intro > .poster_id'); + cur.find('+ .posts_by_id').remove(); + cur.after(' ('+ ids[cur.text()] +')'); + }); + var size = function(obj) { + var size = 0, key; + for (key in obj) { + if (obj.hasOwnProperty(key)) size++; + } + return size; + }; + $('#thread_stats_uids').text(size(ids)); + } + $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ + var found, page = 'Pruned or Deleted'; + for (var i=0;data[i];i++){ + var threads = data[i].threads; + for (var j=0; threads[j]; j++){ + if (parseInt(threads[j].no) == parseInt(thread_id)) { + page = data[i].page +1; + found = true; + break; + } + } + if (found) break; + } + $('#thread_stats_page').text(page); + if (!found) $('#thread_stats_page').css('color','red'); + }); + } + // load the current page the thread is on. + // uses ajax call so it gets loaded on a delay (depending on network resources available) + var thread_stats_page_timer = setInterval(function(){ + $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ + var found, page = 'Pruned or Deleted'; + for (var i=0;data[i];i++){ + var threads = data[i].threads; + for (var j=0; threads[j]; j++){ + if (parseInt(threads[j].no) == parseInt(thread_id)) { + page = data[i].page +1; + found = true; + break; + } + } + if (found) break; + } + $('#thread_stats_page').text(page); + if (!found) $('#thread_stats_page').css('color','red'); + }); + + },30000); + $(document).ready(function(){ + $('body').append(''); + update_thread_stats(true); + $('#update_thread').click(update_thread_stats); + MutationObserver = window.MutationObserver || window.WebKitMutationObserver; + var observer = new MutationObserver(function(mutations, observer){update_thread_stats();}); + observer.observe($('#thread_' + thread_id)[0], {childList: true}); + }); +} \ No newline at end of file -- cgit v1.3 From 8d451280306c4f05ebb966399420ae4f08831965 Mon Sep 17 00:00:00 2001 From: ForklessAnon Date: Sat, 1 Nov 2014 04:29:21 -0500 Subject: Some code cleanup on thread stats. --- js/thread-stats.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js index e6fb1142..59fed912 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -7,10 +7,7 @@ * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/thread-stats.js'; */ -// THREAD STATS if (active_page == 'thread') { - - var thread_stats_timer = 30, thread_stats_timeout; //it has to be on a timer because there I haven't found a way to hook into when the actual page updates the thread... //check if page uses unique ID var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); @@ -27,7 +24,7 @@ if (active_page == 'thread') { el.prepend('0 images | '); el.prepend('0 replies | '); delete el; - function update_thread_stats(force){ + function update_thread_stats(){ var op = $('#thread_'+ thread_id +' > div.post.op:not(.post-hover):not(.inline)').first(); var replies = $('#thread_'+ thread_id +' > div.post.reply:not(.post-hover):not(.inline)'); // post count @@ -102,14 +99,11 @@ if (active_page == 'thread') { $('#thread_stats_page').text(page); if (!found) $('#thread_stats_page').css('color','red'); }); - },30000); $(document).ready(function(){ $('body').append(''); - update_thread_stats(true); + update_thread_stats(); $('#update_thread').click(update_thread_stats); - MutationObserver = window.MutationObserver || window.WebKitMutationObserver; - var observer = new MutationObserver(function(mutations, observer){update_thread_stats();}); - observer.observe($('#thread_' + thread_id)[0], {childList: true}); + $(document).on('new_post',update_thread_stats); }); } \ No newline at end of file -- cgit v1.3 From 1aa8f6251d30545242768bf13bbe9ee89c231ca7 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 12 Nov 2014 01:19:02 -0800 Subject: Have to load onready --- js/thread-stats.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js index 59fed912..4050fb67 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -8,8 +8,9 @@ * $config['additional_javascript'][] = 'js/thread-stats.js'; */ if (active_page == 'thread') { +$(document).ready(function(){ //check if page uses unique ID - var IDsupport = ($('.poster_id').length > 0); + var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0]; @@ -100,10 +101,9 @@ if (active_page == 'thread') { if (!found) $('#thread_stats_page').css('color','red'); }); },30000); - $(document).ready(function(){ $('body').append(''); update_thread_stats(); $('#update_thread').click(update_thread_stats); $(document).on('new_post',update_thread_stats); - }); -} \ No newline at end of file +}); +} -- cgit v1.3 From fdc14c699c25131ffe25536928e0dfac990c4ae3 Mon Sep 17 00:00:00 2001 From: Forkless Date: Mon, 17 Nov 2014 03:06:56 -0600 Subject: Fix color incase page is missed and then found again. --- js/thread-stats.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js index 4050fb67..7c13d66c 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -79,6 +79,7 @@ $(document).ready(function(){ } $('#thread_stats_page').text(page); if (!found) $('#thread_stats_page').css('color','red'); + else $('#thread_stats_page').css('color',''); }); } // load the current page the thread is on. @@ -99,6 +100,7 @@ $(document).ready(function(){ } $('#thread_stats_page').text(page); if (!found) $('#thread_stats_page').css('color','red'); + else $('#thread_stats_page').css('color',''); }); },30000); $('body').append(''); -- cgit v1.3 From cf91daee7cfbdbede0e0d01b40dd7879cab88186 Mon Sep 17 00:00:00 2001 From: 8chan Date: Fri, 21 Nov 2014 23:33:42 -0800 Subject: No need to display pruned in two places...especially if server times out / errors --- js/thread-stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js index 7c13d66c..1785b79a 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -65,7 +65,7 @@ $(document).ready(function(){ $('#thread_stats_uids').text(size(ids)); } $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ - var found, page = 'Pruned or Deleted'; + var found, page = '???'; for (var i=0;data[i];i++){ var threads = data[i].threads; for (var j=0; threads[j]; j++){ @@ -86,7 +86,7 @@ $(document).ready(function(){ // uses ajax call so it gets loaded on a delay (depending on network resources available) var thread_stats_page_timer = setInterval(function(){ $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ - var found, page = 'Pruned or Deleted'; + var found, page = '???'; for (var i=0;data[i];i++){ var threads = data[i].threads; for (var j=0; threads[j]; j++){ -- cgit v1.3 From 4b782d6163d061e394e857d6c4f1a94391ddf01b Mon Sep 17 00:00:00 2001 From: Forkless Date: Sat, 22 Nov 2014 19:41:23 -0600 Subject: Fix thread stats so post count hover works on the OP's id. --- js/thread-stats.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js index 1785b79a..9b9b3cb3 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -50,9 +50,12 @@ $(document).ready(function(){ ids[opID] = 0; } ids[opID]++; + var cur = op.find('>.intro >.poster_id'); + cur.find('+.posts_by_id').remove(); + cur.after(' ('+ ids[cur.text()] +')'); replies.each(function(){ - var cur = $(this).find('> .intro > .poster_id'); - cur.find('+ .posts_by_id').remove(); + cur = $(this).find('>.intro >.poster_id'); + cur.find('+.posts_by_id').remove(); cur.after(' ('+ ids[cur.text()] +')'); }); var size = function(obj) { -- cgit v1.3 From c4fc8273328a7d4955e472e3242837a4e210adaf Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 11 Mar 2015 18:22:22 -0700 Subject: some style fixes Conflicts: templates/8chan/boards-tags.html --- js/thread-stats.js | 2 +- stylesheets/dark.css | 8 ++++++-- stylesheets/photon.css | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js index 9b9b3cb3..fb520c71 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -16,7 +16,7 @@ $(document).ready(function(){ $('form[name="postcontrols"] > .delete') .first() - .before('
'); + .before('
'); var el = $('#thread_stats'); el.prepend('Page ?'); if (IDsupport){ diff --git a/stylesheets/dark.css b/stylesheets/dark.css index 7fc4e199..beb12364 100644 --- a/stylesheets/dark.css +++ b/stylesheets/dark.css @@ -166,13 +166,13 @@ table.modlog tr th { color: #AAAAAA; } -.desktop-style div.boardlist:nth-child(1) { +.desktop-style div.boardlist:not(.bottom) { text-shadow: black 1px 1px 1px, black -1px -1px 1px, black -1px 1px 1px, black 1px -1px 1px; background-color: #666666; } -.desktop-style div.boardlist:nth-child(1):hover, .desktop-style div.boardlist:nth-child(1).cb-menu { +.desktop-style div.boardlist:not(.bottom):hover, .desktop-style div.boardlist:not(.bottom).cb-menu { background-color: rgba(30%, 30%, 30%, 0.65); } @@ -190,3 +190,7 @@ div.report { .options_tab_icon.active { color: #FFFFFF; } + +#quick-reply table { + background: none repeat scroll 0% 0% #333 !important; +} diff --git a/stylesheets/photon.css b/stylesheets/photon.css index db189d77..a487e4dd 100644 --- a/stylesheets/photon.css +++ b/stylesheets/photon.css @@ -326,6 +326,6 @@ form table tr td div { padding: 0px !important; } -.desktop-style div.boardlist:nth-child(1) { +.desktop-style div.boardlist:not(.bottom) { background-color: #DDDDDD; } -- cgit v1.3 From 0d0b2fcd7e807f50b621c17e153194cf99edef5b Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 10 Apr 2015 23:11:59 +0200 Subject: thread-stats.js: vichan fixes --- js/thread-stats.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js index fb520c71..f3b2d375 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -12,9 +12,9 @@ $(document).ready(function(){ //check if page uses unique ID var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); - thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0]; + thread_id = thread_id[thread_id.length -1].split(/+-/)[0].split('.')[0]; - $('form[name="postcontrols"] > .delete') + $('.boardlist.bottom, footer') .first() .before('
'); var el = $('#thread_stats'); @@ -67,6 +67,7 @@ $(document).ready(function(){ }; $('#thread_stats_uids').text(size(ids)); } + var board_name = $('input[name="board"]').val(); $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ var found, page = '???'; for (var i=0;data[i];i++){ @@ -88,6 +89,7 @@ $(document).ready(function(){ // load the current page the thread is on. // uses ajax call so it gets loaded on a delay (depending on network resources available) var thread_stats_page_timer = setInterval(function(){ + var board_name = $('input[name="board"]').val(); $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ var found, page = '???'; for (var i=0;data[i];i++){ -- cgit v1.3 From c4569b2ea55d162716cda443c7f28ceed672e0eb Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 10 Apr 2015 23:13:52 +0200 Subject: thread-stats.js: code typo :^) --- js/thread-stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js index f3b2d375..6035de04 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -12,7 +12,7 @@ $(document).ready(function(){ //check if page uses unique ID var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); - thread_id = thread_id[thread_id.length -1].split(/+-/)[0].split('.')[0]; + thread_id = thread_id[thread_id.length -1].split(/\+-/)[0].split('.')[0]; $('.boardlist.bottom, footer') .first() -- cgit v1.3 From bdda1613a6bc4b88dfe9027dc0f330194654ad9c Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 10 Apr 2015 23:43:07 +0200 Subject: thread-stats.js: final vichan fix, should work now --- js/thread-stats.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/thread-stats.js b/js/thread-stats.js index 6035de04..8873dbdb 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -12,18 +12,18 @@ $(document).ready(function(){ //check if page uses unique ID var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); - thread_id = thread_id[thread_id.length -1].split(/\+-/)[0].split('.')[0]; + thread_id = thread_id[thread_id.length -1].split('+')[0].split('-')[0].split('.')[0]; $('.boardlist.bottom, footer') .first() .before('
'); var el = $('#thread_stats'); - el.prepend('Page ?'); + el.prepend(_('Page')+' ?'); if (IDsupport){ el.prepend('0 UIDs | '); } - el.prepend('0 images | '); - el.prepend('0 replies | '); + el.prepend('0 '+_('images')+' | '); + el.prepend('0 '+_('replies')+' | '); delete el; function update_thread_stats(){ var op = $('#thread_'+ thread_id +' > div.post.op:not(.post-hover):not(.inline)').first(); -- cgit v1.3 From cb700e6a72602066404a38403c2f559532de26ca Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 11 Apr 2015 23:03:45 +0200 Subject: live index should refresh every 20s --- js/live-index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/live-index.js b/js/live-index.js index 463f7596..017d0c1f 100644 --- a/js/live-index.js +++ b/js/live-index.js @@ -58,7 +58,7 @@ if (active_page == 'index' && (""+document.location).match(/\/(index\.html)?(\?| update_new_threads(new_threads); }); - }, 1000); + }, 20000); }); $(document).on("new_post", function(e, post) { -- cgit v1.3 From 4131a6e5636df3afac7b0894994074cda6fa3b6b Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 11 Apr 2015 23:12:13 +0200 Subject: watch.js: slow down a little bit, let`s see how it works out --- js/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/watch.js b/js/watch.js index 8ac026a7..07c6942a 100644 --- a/js/watch.js +++ b/js/watch.js @@ -248,7 +248,7 @@ $(function(){ var st = storage(); var sched = 0; - var sched_diff = 300; + var sched_diff = 2000; for (var i in st) { if (st[i].watched) { -- cgit v1.3 From 3f029853802308ca51cc979bc01074bcbc3e9fc9 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 23 Apr 2015 07:41:36 +0200 Subject: gallery-view.js: initial commit --- js/gallery-view.js | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++ stylesheets/style.css | 55 ++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 js/gallery-view.js (limited to 'js') diff --git a/js/gallery-view.js b/js/gallery-view.js new file mode 100644 index 00000000..efe1b3b1 --- /dev/null +++ b/js/gallery-view.js @@ -0,0 +1,124 @@ +if (active_page == 'index' || active_page == 'thread') +$(function(){ + + var gallery_view = false; + + $('hr:first').before(''); + $('#gallery-view a').html(gallery_view ? _("Disable gallery mode") : _("Enable gallery mode")).click(function() { + gallery_view = !gallery_view; + $(this).html(gallery_view ? _("Disable gallery mode") : _("Enable gallery mode")); + toggle_gview(document); + }); + + var toggle_gview = function(elem) { + if (gallery_view) { + $(elem).find('img.post-image').parent().each(function() { + this.oldonclick = this.onclick; + this.onclick = handle_click; + $(this).attr('data-galid', Math.random()); + }); + } + else { + $(elem).find('img.post-image').parent().each(function() { + if (this.onclick == handle_click) this.onclick = this.oldonclick; + }); + } + }; + + $(document).on('new_post', toggle_gview); + + var gallery_opened = false; + + var handle_click = function(e) { + e.stopPropagation(); + e.preventDefault(); + + if (!gallery_opened) open_gallery(); + + gallery_setimage($(this).attr('data-galid')); + }; + + var handler, images, active, toolbar; + + var open_gallery = function() { + $('body').css('overflow', 'hidden'); + + gallery_opened = true; + + handler = $("
").hide().appendTo('body').css('text-align', 'left'); + + $("
").click(close_gallery).appendTo(handler); + + images = $("").appendTo(handler); + toolbar = $("").appendTo(handler); + active = $("").appendTo(handler); + + active.on('click', function() { + close_gallery(); + }); + + $('img.post-image').parent().each(function() { + var thumb = $(this).find('img').attr('src'); + + var i = $('').appendTo(images); + i.attr('src', thumb); + i.attr('data-galid-th', $(this).attr('data-galid')); + + i.on('click', function(e) { + gallery_setimage($(this).attr('data-galid-th')); + }); + }); + + $("
") + .click(close_gallery).appendTo(toolbar); + + handler.fadeIn(400); + }; + + var gallery_setimage = function(a) { + if (a == +1 || a == -1) { + var meth = (a == -1) ? 'prev' : 'next'; + a = $('#gallery_images img.active')[meth]().attr('data-galid-th'); + if (!a) return; + } + + $('#gallery_images img.active').removeClass('active'); + + var thumb = $('#gallery_images img[data-galid-th="'+a+'"]'); + var elem = $('a[data-galid="'+a+'"]'); + + thumb.addClass('active'); + + var topscroll = thumb.position().top + images.scrollTop(); + topscroll -= images.height() / 2; + topscroll += thumb.height() / 2; + images.animate({'scrollTop': topscroll}, 300); + + var img = elem.attr('href'); + + active.find('img').fadeOut(200, function() { $(this).remove(); }); + + var i = $(''); + i.attr('src', img); + i.appendTo(active); + i.hide(); + + i.on('load', function() { + i.css('left', 'calc(50% - '+i.width()+'px / 2)'); + i.css('top', 'calc(50% - '+i.height()+'px / 2)'); + i.fadeIn(200); + }).on('click', function(e) { + e.stopPropagation(); + gallery_setimage(+1); + }); + }; + + var close_gallery = function() { + $('body').css('overflow', 'auto'); + + gallery_opened = false; + + handler.fadeOut(400, function() { handler.remove(); }); + }; + +}); diff --git a/stylesheets/style.css b/stylesheets/style.css index 5ae23cd6..4c4c40f5 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -1060,3 +1060,58 @@ table.fileboard th, table.fileboard td { table.fileboard .intro a { margin-left: 0px; } + +/* Gallery view */ +#gallery_images { + position: absolute; + right: 0px; + bottom: 0px; + top: 0px; + width: 15%; + background-color: rgba(0, 0, 0, 0.4); + overflow: auto; +} +#gallery_toolbar { + position: absolute; + right: 15%; + left: 0px; + bottom: 0px; + height: 32px; + background-color: rgba(0, 0, 0, 0.4); + text-align: right; +} +#gallery_images img { + width: 100%; +} +#gallery_toolbar a { + font-size: 28px; + padding-right: 5px; +} +#gallery_main { + position: absolute; + left: 0px; + right: 15%; + bottom: 32px; + top: 0px; + padding: 10px; +} + +#gallery_images img { + opacity: 0.6; + -webkit-transition: all 0.5s; + transition: all 0.5s; +} +#gallery_images img:hover, #gallery_images img.active { + opacity: 1; +} +#gallery_images img.active { + -webkit-box-shadow: 0px 0px 29px 2px rgba(255,255,255,1); + -moz-box-shadow: 0px 0px 29px 2px rgba(255,255,255,1); + box-shadow: 0px 0px 29px 2px rgba(255,255,255,1); + z-index: 1; +} +#gallery_main img { + max-width: 100%; + max-height: 100%; + position: absolute; +} -- cgit v1.3 From 163a4e699c75cfa0b658e7c1e39153c2f603c483 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 23 Apr 2015 08:45:39 +0200 Subject: gallery-view: support key events (up/down/left/right) --- js/gallery-view.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js') diff --git a/js/gallery-view.js b/js/gallery-view.js index efe1b3b1..65a1e967 100644 --- a/js/gallery-view.js +++ b/js/gallery-view.js @@ -72,6 +72,17 @@ $(function(){ $("
") .click(close_gallery).appendTo(toolbar); + $('body').on('keydown.gview', function(e) { + if (e.which == 39 || e.which == 40) { // right or down arrow + gallery_setimage(+1); + e.preventDefault(); + } + else if (e.which == 37 || e.which == 38) { // left or up arrow + gallery_setimage(-1); + e.preventDefault(); + } + }); + handler.fadeIn(400); }; @@ -103,6 +114,8 @@ $(function(){ i.appendTo(active); i.hide(); + // Let's actually preload the next few images + i.on('load', function() { i.css('left', 'calc(50% - '+i.width()+'px / 2)'); i.css('top', 'calc(50% - '+i.height()+'px / 2)'); @@ -118,6 +131,8 @@ $(function(){ gallery_opened = false; + $('body').off('keydown.gview'); + handler.fadeOut(400, function() { handler.remove(); }); }; -- cgit v1.3 From 099e347e15f87ca757f206c20f77b1fdeb8e887f Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 23 Apr 2015 09:20:34 +0200 Subject: gallery-view: preloading images, webm support --- js/gallery-view.js | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/gallery-view.js b/js/gallery-view.js index 65a1e967..2d7d85b4 100644 --- a/js/gallery-view.js +++ b/js/gallery-view.js @@ -95,7 +95,7 @@ $(function(){ $('#gallery_images img.active').removeClass('active'); - var thumb = $('#gallery_images img[data-galid-th="'+a+'"]'); + var thumb = $('#gallery_images [data-galid-th="'+a+'"]'); var elem = $('a[data-galid="'+a+'"]'); thumb.addClass('active'); @@ -107,16 +107,42 @@ $(function(){ var img = elem.attr('href'); - active.find('img').fadeOut(200, function() { $(this).remove(); }); + active.find('img, video').fadeOut(200, function() { $(this).remove(); }); - var i = $(''); - i.attr('src', img); - i.appendTo(active); - i.hide(); + var i; + if (img.match(/player\.php/)) { + img = img.replace(/.*player\.php\?v=|&t=.*/g, ''); + } + if (img.match(/\.webm$|\.mp4$|\.ogv$/i)) { // We are handling video nao + i = $('