From c336c080c584dc02faab8be8e868707b77a70e42 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 27 Jun 2011 19:09:36 +0200 Subject: [PATCH] Change $.hide & $.show by using the hidden attribute. --- 4chan_x.user.js | 23 +++++++++++------------ script.coffee | 27 +++++++++++++-------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8ce8f4b93..e8ed00593 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -354,10 +354,10 @@ return root.parentNode.replaceChild(el, root); }, hide: function(el) { - return el.style.display = 'none'; + return el.hidden = true; }, show: function(el) { - return el.style.display = ''; + return el.hidden = false; }, addClass: function(el, className) { return el.className += ' ' + className; @@ -984,7 +984,7 @@ threads: [], getThread: function(full) { var bottom, i, rect, thread, _len, _ref; - nav.threads = $$('div.thread:not([style])'); + nav.threads = $$('div.thread:not([hidden])'); _ref = nav.threads; for (i = 0, _len = _ref.length; i < _len; i++) { thread = _ref[i]; @@ -1054,7 +1054,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, hidingul, html, input, key, li, link, main, obj, overlay, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "

"; + html = "

"; dialog = $.el('div', { id: 'options', innerHTML: html @@ -1104,11 +1104,10 @@ $.bind(input, 'keydown', options.cb.keybind); } /* - https://bugzilla.mozilla.org/show_bug.cgi?id=579776 - position:fixed and position:absolute shouldn't turn display:-moz-box into display:block + Two parent divs are necessary to center on all browsers. - to harmonize, position:fixed and display:-moz-box have to be set on different elements - - #overlay and #options, respectively. + Only one when Firefox and Opera will support flexboxes correctly. + https://bugzilla.mozilla.org/show_bug.cgi?id=579776 */ overlay = $.el('div', { id: 'overlay' @@ -1513,7 +1512,7 @@ } }, toggle: function(thread) { - if (thread.className.indexOf('stub') !== -1 || thread.style.display === 'none') { + if (thread.className.indexOf('stub') !== -1 || thread.hidden) { return threadHiding.show(thread); } else { return threadHiding.hide(thread); @@ -2559,14 +2558,14 @@ _results = []; for (_i = 0, _len = thumbs.length; _i < _len; _i++) { thumb = thumbs[_i]; - _results.push(!thumb.style.display ? imgExpand.expand(thumb) : void 0); + _results.push(!thumb.hidden ? imgExpand.expand(thumb) : void 0); } return _results; } else { _results2 = []; for (_j = 0, _len2 = thumbs.length; _j < _len2; _j++) { thumb = thumbs[_j]; - _results2.push(thumb.style.display ? imgExpand.contract(thumb) : void 0); + _results2.push(thumb.hidden ? imgExpand.contract(thumb) : void 0); } return _results2; } @@ -2592,7 +2591,7 @@ toggle: function(a) { var thumb; thumb = a.firstChild; - if (thumb.style.display) { + if (thumb.hidden) { return imgExpand.contract(thumb); } else { return imgExpand.expand(thumb); diff --git a/script.coffee b/script.coffee index f1282f8b4..d9eebf3d3 100644 --- a/script.coffee +++ b/script.coffee @@ -235,9 +235,9 @@ $.extend $, replace: (root, el) -> root.parentNode.replaceChild el, root hide: (el) -> - el.style.display = 'none' + el.hidden = true show: (el) -> - el.style.display = '' + el.hidden = false addClass: (el, className) -> el.className += ' ' + className removeClass: (el, className) -> @@ -717,7 +717,7 @@ nav = threads: [] getThread: (full) -> - nav.threads = $$ 'div.thread:not([style])' + nav.threads = $$ 'div.thread:not([hidden])' for thread, i in nav.threads rect = thread.getBoundingClientRect() {bottom} = rect @@ -795,8 +795,8 @@ options =
- -