12 ms·
I've been using the original sorttable.js you reference on your GitHub page for my own product for a number of years. How does yours differ from that one in te
by orware 13y ago
I've been using the original sorttable.js you reference on your GitHub page for my own product for a number of years.
How does yours differ from that one in terms of features/capabilities?
Is it a rewrite with more modern techniques?
- afschwartz 13y agoYea, more-or-less. Here is a short summary of some of the major changes: – Tables with `data-sortable` attribute are automatically initialized. – The sort arrows are made with CSS-border triangles instead of special characters. – The sort arrows are always present but hidden for non-sorted columns so that columns don't resize when sorting. – `sorttable_`-prefixed class names are now `data-` attributes, so they are valid HTML5. – The library doesn't attempt to recognize date formats. Instead, it recommends you add `data-value="#{ timeInMillis }"` to your <td> containing a human-readable date string. I'm sure there are more that I can't think of at the moment, but that's a decent list.
- orware 13y agoThanks for the replies guys, one additional question I had which I didn't see directly answered would be the type of browsers it should be compatible with or was tested on? The main page shows some browsers listed but I think that was simply demonstration data to show off the script and wasn't actually showing the versions it was supposed to support.
- afschwartz 13y agoBrowser support is listed in the documentation (http://github.hubspot.com/sortable http://github.hubspot.com/sortable): IE8+, Firefox 4+, Current WebKit (Chrome, Safari), Opera.
- orware 13y agoGreat, thanks! The Internet Explorer one was the one I was probably most curious about. I'll have to give it a test go and see if I can go ahead and use it to supplant the older sorttable in my script ;-).
- zackbloom 13y agoI'm a little biased, but just from reading through, it looks like the original does some pretty out-of-date things. I'm annotating the copy in the new project's repo, just to allow me to link to line numbers, but this IS THE LEGACY PROJECT'S CODE: - Webdings: https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438d735967f16eef0d403ef9/sorttable.js#L103 https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438... - Using class names, rather than data attributes, for everything: https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438d735967f16eef0d403ef9/sorttable.js#L111 https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438... - Hardcoded date formats which would make localization tough: https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438d735967f16eef0d403ef9/sorttable.js#L32 https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438... - Sorting in JavaScript (not using Array.prototype.sort): https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438d735967f16eef0d403ef9/sorttable.js#L305 https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438... - Overriding event bindings in a destructive manner: https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438d735967f16eef0d403ef9/sorttable.js#L370 https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438... Not to mention stuff I just find objectionable: - Useless comments: https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438d735967f16eef0d403ef9/sorttable.js#L27 https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438... - Mistabbing: https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438d735967f16eef0d403ef9/sorttable.js#L440 https://github.com/HubSpot/sortable/blob/37894eb51bda9f0e438... It also looks like this one is 1/3 the length. To be fair though, the original was written seven years ago, and still works, so it's not really fair to criticize it by modern standards. Suffice it to say that it was time for something new.