New revs


  • Dadman with a boy
  • Posts: 16,060
Re: New revs
« Reply #1200, on December 15th, 2011, 08:37 PM »
rev 1200
(3 files, 1kb) (oh, come on... It's gotta be more than that! Especially the JumpTo rewrite!)

* Rewrote the JumpTo class into a single function. Categories are no longer selectable (what's the point anyway?), and they're shown, more logically, as option groups. As a result, the code is clearer and shorter. (script.js, Xml.template.php)

! Folding out years in the stats section would never register internally, because of a wrong method name. (script.js, stats.js)

- Got rid of the 'hoverable' menu code because rev 1024's clever hack was pretty much doing the same. (script.js)

* Boolean to integer is done just by adding a + before the var name, like +is_ie8down... I should do that more often. (script.js)
Re: New revs
« Reply #1201, on December 15th, 2011, 11:09 PM »
rev 1201
(5 files, 6kb)

! WeCSS's custom 'gradient' property should now work properly in IE when using short-form RGB codes (#fff etc.) (Class-CSS.php, index.css)

* Bored with the italics... Replaced mini-logos with new ones. (minilogo.png, minilogow.png, index.css, Warm/index.css)
Re: New revs
« Reply #1202, on December 16th, 2011, 04:36 PM »
rev 1202
(2 files, 8kb)

+ Restored support for custom styling of drop-up select boxes. (sbox.js, index.css)

* And yet, the script file is now even shorter... 2585 bytes -- was 2696. Every byte saved is a victory, at this point. I pretty much cut the Proto object in half and removed the ability to set or get variables, and anything that the select box object actually doesn't need at all. Now it's pretty simple: either .sb() is empty, meaning you create a default select box, or it has an object as a param (where you specify your custom options), or a string, meaning it's a function to execute after creating the object, eg .sb('refresh'). It doesn't get any simpler. No other features were removed -- just tested dozens of ways to optimize gzipping, including code permutations, and kept everything that worked. (sbox.js)

* Renamed the fixedWidth option to fixed. I told you, every single byte... (sbox.js)

@ Note: removing ARIA features would save about 130 bytes. I'm not sure it's worth it. Removing the hardcoded 'position' and 'visibility' styles, which I can't seem to find a browser that will make use of, would save another 50 bytes. Thus, I... think the 2500 byte limit can be reached, but it's pretty pointless, I suppose. Heck, I'm startin to wonder if I shouldn't take the 3KB alternative selectbox plugin and try to reduce it to 2KB or less... ;)
Re: New revs
« Reply #1203, on December 16th, 2011, 07:06 PM »
rev 1203
(1 file, 2kb) (now that's not 2kb, it's barely 10 lines of code... I'd love to know what size this is supposed to represent.)

! I actually committed the 2530+ byte version of sbox.js, not the 2585 byte version with the extra-styling-that-I-don't-know-what-it's-for-yet. (sbox.js)

! Inverted two variables at the last minute... (sbox.js)
Re: New revs
« Reply #1204, on December 17th, 2011, 08:03 PM »
rev 1204
(2 files, 4kb)

* I believe the local avatar selector should be a square select box, rather than a dropdown. It makes more sense. (Profile.template.php)

* And on the other hand, these non-dropdowns should NOT be turned into dropdowns by our SB plugin. Might as well do something to 'style' them in the future, too... But right now, it's a no-go. (sbox.js)

+ Starting to get serious... All select boxes will now be transformed automatically. I have a feeling this will require a lot of work in the coming days, to convert everything as expected. (sbox.js)

* More code size optimizations. The Proto area is now incredibly short! But because of the extra code from above, final gzipped size is 'only' 5 bytes shorter. (sbox.js)

@ I'm pretty impressed by how much this file is 'optimizable' really...
Re: New revs
« Reply #1205, on December 19th, 2011, 12:25 AM »
rev 1205
(2 files, 7kb)

! Fixed copy-paste error in wetem::remove. Thanks Dragooon! (Subs-Template.php)

! Fixed a few very annoying bugs in the select box's keyboard handling. This was basically due to the events being registered multiple times. I'll be honest and just say I took the easy way out and unregistered the events manually before registering them. I should instead be looking into the source code to find out why the code is being called more times than needed. (sbox.js)

* Personal usability preference: using the up and down arrow keys in a select box will now loop to the other end of the list if you reach the beginning or the end. I always hated the fact that regular select boxes don't do that... (sbox.js)

* 2579 to 2386... Not bad (even went as far as 2372 at one point). Among many other things, removed a duplicate test for duplicate objects (poetic irony), and rewrote the keydown event to something more readable and IMHO actually more usable (see above.) Also, 'new object()' doesn't require the parenthesis. I learn stuff every day. (sbox.js)

@ Note: should disable submitting the form when hitting Return inside a select box... I think?! Should also remove the random ID assignments -- the original developer didn't document why he added them over at github, and I don't see any reason for doing it either. It seems to be a leftover from an older element that was removed anyway... Opinions?
Re: New revs
« Reply #1206, on December 20th, 2011, 03:31 PM »
rev 1206 (the script.js optimization commit.)
(8 files, 9kb)

* Rewrote the menu system into a closure, and initMenu() into a jQuery pseudo-plugin with the syntax $('#menu').menu(), which is a bit cooler. And saves me from dealing with uncompressed variable/function names. (GenericMenu.template.php, index.template.php, script.js)

- Oh, and closures don't systematically need a jQuery reference... That's only if we're using another library that hijacks the $ sign. It's very unlikely, so off we go. (script.js)

- Removed isEmptyText() to save bandwidth, because it's not used in a lot of places and the code can actually be shortened by not using it. For instance, "isEmptyText(this) || this.value == 0" is equivalent to "$.trim(this.value) == 0". (ManageBoards.template.php, Poll.template.php, Post.template.php, script.js, suggest.js)

* Moved we_setThemeOption into the weToggle object, as it was called only once... And I'm sure if other plugins want to use it, they can perfectly write their own. It's two lines of code. (script.js)

- From the depths of SMF: weCookie declares this.opt and never uses it. Gone. (script.js)

- weToggle's bNow was a synonym of bInit. I don't remember why I introduced that. Gone. (script.js)

- Another one from the depths of SMF: there's no point in straightening out the bInit variable if it's undefined, because it's declared and that's the least JavaScript requires to go without complaining. (script.js)

! And a very, VERY important SMF bug to finish with -- hopefully they're listening: if you collapse any item and it's saved into the database, SMF will systematically re-insert the data into the database on each page load, even if you don't touch the item anymore. Major fail. The fix is very easy: just add a (!bInit) test before the oThemeOptions test. (script.js)

- Brackenazi. (Display.template.php)
Re: New revs
« Reply #1207, on December 20th, 2011, 07:04 PM »
rev 1207
(1 file, 4kb)

! Fixed automatic quote splitter: tags like  wouldn't break correctly. (Thanks dorje for the report!) (post.js)
! Fixed automatic quote splitter: mixed case tags would sometimes fail to break. (post.js)
! Fixed automatic quote splitter, what else? Protected and closed tags would break in some situations, too. It's not perfect yet (except for closed tags), but it's close enough. If you type in broken code, it's your problem. (post.js)

@ The modified code is actually shorter than before :P Also, I commented it this time...
Re: New revs
« Reply #1208, on December 20th, 2011, 08:02 PM »
rev 1208
(1 file, 2kb) (although it's about on par with last commit's size... Don't ask.)

+ Seriously improved keyboard usability. It's actually even better than the default select box, if you'll ask me. Press space to unfold the list box (I don't know of any keyboard shortcut to do that in a default), press Tab to switch to the next HTML element -- and yes, it works correctly in both opened and closed states, and press Backspace or Return to confirm a selected entry and close the current select box without submitting the form. If the box is already closed, pressing Return will submit the form.

* Replaced select box's random number with a unique ID that gets increased as required (inside lists). (sbox.js)

* Merged selectNextItemStartsWith and selectMatchingItem. They pretty much both did the same thing... It's still buggy though, but just so you know... The original code actually didn't work at all, so it's an improvement already. (sbox.js)

- Removed select box's destroy method. There's no need for that externally, is there? (sbox.js)

* Even with all of the keyboard shortcut additions, still managed to go from 2386 to 2351... I eat bytes for breakfast. (And if you're French: I said bytes, with a y.) (sbox.js)
Re: New revs
« Reply #1209, on December 21st, 2011, 09:18 AM »
rev 1209
(1 file, 3kb)

@ And... Down to 2305 bytes. Ah ah. In order to lose the extra 46 bytes, I add to lose a few feat... Oh, sorry, I mean I fixed bugs and added stuff.

+ Custom option classes should now be correctly transferred to their HTML equivalent, in addition to their already transferred styles. (sbox.js)

! Fixed and simplified item navigation through letter typing: stroke an 'e' and it'll find the first item that starts with an e; hit 'e' again and it'll move onto the next item starting with an 'e', repeatedly until it resets to the first 'e' again. (sbox.js)
Re: New revs
« Reply #1210, on December 21st, 2011, 10:32 PM »
rev 1210
(2 files, 7kb)

* Simplified and improved select box styling. Also updated general input styles to match. Unsure about the internal padding as it may look like an extra space in the inputs, though... (index.css)

* Simplified internal HTML code when dealing with optgroups. Instead of having nested lists, everything is on a single level. (sbox.js)

! Fixed a minor bug in the original select box plugin where aria-disabled wasn't set at all. (sbox.js)

! Select box selection titles needed to be un-htmlspecialchar'ed, or whatever. (sbox.js)

@ Unfortunately, these 'simplifications' and fixes increased the final size by 22 bytes. Ah, well.
Re: New revs
« Reply #1211, on December 22nd, 2011, 01:02 AM »
rev 1211
(3 files, 3kb)

* Rewrote the way dropdowns are shown in select boxes. Instead of being attached to the body, they're now physically where they're supposed to be. In order to avoid the classic issue of an absolutely-positioned dropdown being cut off by an 'overflow: hidden' element, I've used the technique I used in the menu code, which is apparently little known: setting no relatively positioned parent, and setting the top margin instead of the top position. instead avoiding to set a position on the absolutely positioned element. The element will be naturally positioned below its owner. The drop-up code is a bit buggy but I have no time to fix it tonight. (sbox.js, index.css, sections.css)

- Removed the ctx option (because it's no longer useful), and the arrow option (because, well, WE won't change it anyway...) (sbox.js)

! Fixed an extra colon that broke JavaScript in IE7. (sbox.js)

@ As a result, the final gzipped sbox file is a whopping 110+ byte smaller than in the previous revision! :)
Re: New revs
« Reply #1212, on December 22nd, 2011, 10:49 AM »
rev 1212
(1 file, 3kb)

! Fixed drop-up positioning, as promised last night. Phew... Seems to work perfectly. Tested in Opera 12, and some old browsers like Firefox 3.6 and IE 7/8. (sbox.js)

* Replaced a few addClass calls with a more proper toggleClass. Merged the two hover functions into one. Rewrote half of PositionSB() to make use of ternary operations instead of code blocks. Down to 2194 bytes! Woohoo! (sbox.js)
Re: New revs
« Reply #1213, on December 22nd, 2011, 04:26 PM »
rev 1213
(1 file, 2kb)

! The close animation wasn't triggered when opening another select box. Used the opportunity to rewrite it to use both fading out and sliding up. If that isn't too much...?! (sbox.js)

! Fixed dirty area glitches in Opera when closing some select boxes. Still buggy in the sidebar but it's a different problem which I haven't been able to figure out for now. (sbox.js)

- Removed or simplified more sbox things... $sb's close event doesn't need a namespace (only $(document) does), the 'closing' bool was replaced by the .is('.open') test -- the trick was simply to remove that specific class *before* doing the closing animation, uh... Current file size: 2184. And I have a feeling I can actually go under 2000 now... Is it my new goal? Have I got a life? The answer next week! (sbox.js)

@ Note: at this point, I'm not even sure there'll be anything left of the original plugin in my code... :P
Re: New revs
« Reply #1214, on December 22nd, 2011, 11:29 PM »
rev 1214 -- not my finest commit, but whatever... what matters is the commitment :P
(2 files, 2kb)

* And... Down to 2147 bytes. The $ object is as small as it'll ever be. extraWidth and offsetFrom always get passed jQuery objects (since they're plugins, technically...), so they don't need to access $(this), just this. 'self' was no longer used, so there it goes. $orig and o are directly initialized by the Selectbox object function's arguments now. And that's enough to reduce the size by 40+ bytes, as you can see. (sbox.js)

+ Added support for IE6 in the select box plugin. Well, to be precise -- it's not that I want the full experience to be on IE6. It's just that I don't see why I should waste time on every browser testing for IE6 before I can create the select box object. Considering that the internal HTML structure no longer requires direct > selectors, IE6 actually behaves well in most cases. The only issue is that it doesn't support compound classes, but it's not a big deal in this case, and anyway I'll probably add some JavaScript to deal with that for it. Also fixed a related rendering glitch in profile options. (sbox.js, index.ie6.css)