Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
javascript
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 May 2012 at 18:30 UTC
Updated:
29 Jul 2014 at 20:41 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sunCould use an inline comment explaining the event magic.
Let's add some JSDoc here.
I don't think it is a good practice to store default values on the client-side.
We should only store default overrides. In turn, that would mean to actually delete the setting when toggling the button back to its default.
Comment #2
wim leers+1 for patch.
+1 sun's review, especially the last part.
Also:
- this is good for WPO. Cookies make HTTP requests slower.
- browser support is solid: http://caniuse.com/namevalue-storage. Only Opera Mini is missing. I doubt this functionality works well (as in usable) in Opera Mini in the first place, so we should be okay.
Comment #3
nod_I'm reworking a couple of things in addition to the review,
That's right, tabledrag is pretty much busted on mobile so that's not a big concern for now.
Comment #4
nod_patch add
Drupal.tableDrag.prototype.displayColumns
Drupal.tableDrag.prototype.toggleColumns
and a few things reworked. changing the type of showWeight is not an issue, the only thing reacting to columnschange is tableheader and that does not care about the actual type of the value.
Comment #5
nod_reroll.
I like it so much I waste time playing with the hide/show weights link :p
Comment #6
sunComment #7
droplet commentedwhy use JSON.parse here?
Comment #8
nod_since true/false get stored as strings, without it
showWeightwould be either'true'or'false'and they would both be true in the toggle condition.Comment #9
dries commentedShould be 'its'.
Looks like a nice clean-up to me.
Comment #10
nod_reroll
Comment #11
nod_testbot happy, back to RTBC, it was only a comment change.
Comment #12
corbacho commented+1 This is very creative way of using localstorage. I like it a lot
I'm worried about raw use of localstorage API and browser support.
IE8 doesn't trigger 'storage' event, but 'onstorage'. Has been tested there? (At least I've search for 'storage' in last jquery source code without results)
Also there is a jQuery plugin http://www.jstorage.info/ that is hosted in github, so we can see what kind of fixes brings to the table, and see in the issue queue that localstorage API has some edge cases, for example errors in (ios 5 ? What about using a wrapper ? Are we using localstorage any other place in Drupal 8 ?
Comment #13
nod_Please change status only if you have real issues with the patch, I'm only seeing speculative issues from your post:
The event is handled by jQuery, it takes care of cross-browser things. Also, see OP: tested successfully in IE8/9.
This is a very straightforward way of using localStorage. There is no edge case going on here. Also the browser support for mobile is not defined just yet. I can't test iphone/ipad browsers. If your testing shows a problem with this patch please set it back to NW.
The issue queue you're linking to contains jstorage bugs (i've read them). not localStorage bugs.
Wrapper for this seems overkill, if you want to play with the idea please see #1172670: Evaluate standardized usage of HTML5 Storage API through a library
We're not using localStorage anywhere else.
This patch shouldn't be held up by that. In case the other issue goes somewhere, the refactor would be trivial.
Back to RTBC
Comment #14
corbacho commentedThanks for the detailed answers! nothing to add
Sorry about that speculative status change, wasn't my intention to stop it ;)
Comment #15
dries commentedCommitted to 8.x. Thanks.
Comment #16
nod_Quick follow-up, I missed a bit during my reroll in #5, there is a leftover
$.cookie(), this patch removes it like it's supposed to.Nothing is visibly broken though.
Thanks.
Comment #17
dries commentedCommitted the follow-up patch. Thanks.
Comment #19
Marko B commentedWhen can this be roled to Drupal 7? Reason is, this cookie is breaking Varnish caching unless excluded by code in .vcl file.
Comment #20
nod_won't make it to D7, it's an API change.