Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
javascript
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 May 2012 at 22:51 UTC
Updated:
29 Jul 2014 at 20:41 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nod_Ok first try.
It's pretty different style of code but that's what it takes to clean it up. tableheader is a library, take a look at yui source, openlayers and co to see how it's usually done.
works IE8+ and the rest, it could actually work on IE7, didn't want to go to the trouble of testing.
This superseeds #1417378: Remove eval() from tableHeader JavaScript. Profiling this rewrite give a significantly better perf than the current code (and about twice better than the previous patch).
Should be commented enough. It's easier to read the patched file, pretty much everything changed. I've put a good number of named function because profiling is useless otherwise.
(edit) I've fixed a super annoying 1-2px offset that was driving me crazy too.
Comment #2
nod_forgot 2 lines
Comment #3
nod_small tweak to for mobile positioning onscroll
Comment #4
nod_We should introduce throttle and debounce for scroll and resize events respectively. http://benalman.com/projects/jquery-throttle-debounce-plugin/ as well as for autocomplete.
Forgot about the toolbar toggle button. Fixed.
Comment #5
andypostdoes not woks in overlay
EDIT: IE9(8) and ff14a2 works fine without overlay
Comment #6
nod_indeed, have not changed anything for overlay. Just waiting for some feedback on this before finishing it.
(edit) It's no big trouble to make overlay work, just got lazy towards the end.
Comment #7
kiphaas7 commentedSlightly offtopic: saw the change from .once() to .one(). Since this was already in jQuery 1.1, why have we (by we I mean drupal) been using .once() exclusively in the past? There must have been a good reason... Drupal 6 already came with jQuery 1.2.
+ for (var i = 0, il = tables.length; i < il; i += 1) {Not as a complaint, but genuinely interested: why are you using i += 1 instead if i++?
+function tableHeaderReizeHandler(e) {Why global functions? Backwards compatibility?
+ attach: function(context, settings) {No de-attach/unattach-ish property?
Big +1 for .debounce() and .throttle() in core as a library, incredibly useful, and very small size.
I've not been following core issues for some months, but is that something that was already agreed upon for D8 js? i.e. use yui source/openlayers and co codingstyle?
Comment #8
nod_.once and .one don't do the same thing. For drupal use, .one won't work, think of new AJAX content. .one would have been triggered with the old elements not the new ones. Same thing if you delegate.
i += 1, see jslint/hint configuration options. We decided not to go with that later on, it was unclear at the time of the patch though. should be i++ to be consistent with the rest of core.
they are not global functions, they are in the closure scope. Naming them helps with debugging/profiling so it's better than anonymous function for that purpose and don't really hinder readability, for me it actually helps.
detach: totally right, missed that part. it should be done properly :)
Still nothing deceided on that level about code style.
:)
Comment #9
kiphaas7 commentedOuch, can't believe I missed that. :)
Thanks for the update!
Comment #10
kiphaas7 commented(also needs a reroll, doesn't apply against toolbar.js anymore)
Comment #11
kiphaas7 commentedSorry for the third post in a row, but found this typo:
function tableHeaderReizeHandler(e) {ReizeHandler -> ResizeHandler. Typo is consistent (e.g. you named it ReizeHandler everywhere), probably why you didn't notice it.
Comment #12
nod_It's all constructive feedback, don't worry. Nice to know someone is reviewing :) Hopefully I'll have some time to reroll soon.
Comment #13
nod_Closed #1728122: Sticky Table header tables don't inherit parent table's outer width and #1724534: Sticky Table header rows incorrectly sized if browser resized between detachments since the patch fixes both issues.
Reroll of the patch, overlay works too.
Comment #14
lorique commentedTest OK. Code is sane.
The tableheader has been prototyped correctly, and there is no longer any unnecessary computing going on during scrolling.
Comment #15
dries commentedCommitted to 8.x. Thanks.
Comment #16
kiphaas7 commentedThink this was all introduced in this patch, therefore re-opening.
See screenshots:
Comment #17
kiphaas7 commentedSo I talked a little bit with nod_ about this, and he said the sticky table creation upon scroll is on purpose, to delay execution as much as possible.
A middleground might be to execute
tableHeaderInitHandlerunconditionally on attach. Move the 'on scroll' bind tocreateSticky, after which we can test forcheckStickyVisible: if it returns true, trigger scroll on the table.This way the actual creation and insertion of the sticky table, which I think is the most costly operation, is still delayed if the table is not visible.
If that sounds good, I'll try to whip up a patch.
Comment #18
nod_No but seriously, make a new bug report please.
Comment #19
kiphaas7 commented#1764912: Fix regressions and further improve tableheader.js