New revs


  • Dadman with a boy
  • Posts: 16,061
Re: New revs
« Reply #1230, on December 29th, 2011, 10:55 PM »
rev 1230
(1 file, 1kb)

- Once again committed my work-in-progress of sbox.js, most of which will soon go to the trashcan... Sorry, sorry! (sbox.js)
Re: New revs
« Reply #1231, on December 31st, 2011, 06:30 PM »Last edited on January 1st, 2012, 08:35 PM by Nao
rev 1231
(10 files, 12kb)

* Rewrote layout of post buttons/shortcuts in Post and PM pages. Moved all related CSS to editor.css. Will commit the PM template as soon as I'm done with its onfocus bugs. (Class-Editor.php, Post.template.php, editor.css, index.css, sections.css, post.js)

+ Added an Opera specific shortcut string (its behavior being different and all). (Post.language.php)

! Fixed missing focus loss in post editor when choosing an option through a select box. Also rewrote the editor JS a bit to fix some rare init bug I've had with jQuery. (editor.js, post.js, suggest.js)

* Rewrote smart tag closer (quote splitter) to require holding the Shift key when pressing Enter. This may be temporary, but as of now I'm not sure I'd rather have it enabled by default. (post.js, Post.language.php)

! Fixed font size on thought privacy select box. (index.css)

@ This commit may (or may not) be broken, because I'm splitting my work in half to do a final 2011 commit.

:edit: from January 1st -- LOL -- rev 1231, committed on 12/31. Totally coincidental!
Re: New revs
« Reply #1232, on January 1st, 2012, 08:16 PM »
rev 1232
(4 files, 2kb)

! When changing minification option in the admin area, the cache purge would generate an error if one of cache's sub-folders had a name similar to what it would purge. Granted, it probably won't happen outside of a test environment... (ManageServer.php)

! Fixed undefined index in post editor. (Class-Editor.php)

- $txt['shortcuts'] and $txt['shortcuts_firefox'] are duplicated in the index language files. They're only used in a context where the Post language files are loaded... (index.language.php)
Re: New revs
« Reply #1233, on January 1st, 2012, 08:34 PM »
rev 1233 (one, two, three... three?)
(4 files, 10kb)

+ Added a 'fixed' class that does the same as setting o.fixed to true. Also inverted the meaning of o.fixed, actually, because it didn't make any sense... Added the fixed class to a few select boxes in the PM area that looked bad when resized on the fly. (PersonalMessage.template.php, script.js, sbox.js)

+ Added a 'focus' option to .sb() when reloading an item. It feels a bit hackish, but I still haven't found a way to automatically discover the call is being made from the onfocus event, and Wedge only does this on two occasions so what the hell... This should be used each time a focus event wants to refresh a select box, to avoid an infinite loop because the reload process does trigger the original focus event again. (PersonalMessage.template.php, script.js, sbox.js)

* Now disabling current board's entry in Quick Access select box, instead of changing its background color. I'd say it feels more natural... (script.js)

- Removed maxWidth option from select boxes. It didn't work properly, and the same can be achieved with a 'max-width' setting on .sbox classes in CSS files, plus it's more flexible. (index.css, script.js, sbox.js)

* Many, MANY minor fixes related to selected items. Really, I don't know where to begin... (sbox.js)
  - Cleaned up some unneeded class additions/removals (focused and selected), and some duplicate calls like a double positionSB().
  * openSB's parameter is now focus-related, because we can perfectly determine if it needs an animation by testing whether it's already opened...
  * Display area's text can no longer be empty, it should at least be an unbreakable space (for styling reasons.)
  * Devised a hack to disable event handlers before triggering a native event (focusOriginal()). I'm actually amazed that it works. Heck, this should be made into a native jQuery function, too...
  * The current selection is now cached into $selected.

@ Forgot to log the current size for sbox.js: 2167 bytes. The native event trigger function is the main reason why it went up a bit, rather than dramatically down.
Re: New revs
« Reply #1234, on January 4th, 2012, 12:32 PM »
rev 1-2-3-4 (could have waited for 12:34 for even more fun but... depends on your idea of fun...)
(8 files +2-2, 20kb)

@ The NIGHTMARE commit... Just because of a couple of onclick and onfocus events in the entire Wedge codebase. I should have removed them instead... Again, many many fixes to the select box system. Keyboard navigation should now properly trigger the click event when using arrows (which a regular select box would never do -- and yes, onclick is only used ONCE in all of Wedge but I'm like that.) Focus and click events had various glitches that I believe I managed to fix entirely. Well, I thought that MANY times and then discovered that it broke every other right click in Iceland when temperature is above 67°C, so I went for a rewrite every time and it would break something else. What fun. I don't want to touch events ever again.

- Removed original's class from $display and $items, because it feels more natural to style ".custom_class .items" than ".items.custom_class". Plus it's compatible with IE6... (sbox.js)

- Removed the .sb("focus") and focusOriginal() hacks. Should work okay without these now... (PersonalMessage.template.php, script.js, sbox.js)

* Ensuring that clicks on select box display area to close it will keep focus on it. (sbox.js)

* Ensuring that selected items are always valid (i.e. they still exist now and haven't been deleted by a refresh.) (sbox.js)

* Rewrote inline event attribution for select boxes by moving event declaration around in the template file, so that they're always available for the plugin to extract from. That way, we fix (okay, I fix) this insane bug where inline events aren't available on select boxes after a refresh. (sbox.js, index.template.php, Subs-Template.php)

+ Implemented or restored (can't exactly remember) instantOpen parameter on OpenSB(), for resizing purposes mainly. (sbox.js)

! Clicking the select box to close it should now properly cancel the current selection. (sbox.js)

! Fixed broken select box widths in IE6 where optgroups were being used. (index.ie6.css)

* Replaced .is(".class") with .hasClass("class"). Gzipped/minified takes 4 extra bytes, but it should be a tad faster to execute. And semantically correct. (sbox.js)

* Moved positioning code inside OpenSB(), since it's only used there. Saves about 20 bytes and compensates for hasClass... (sbox.js)

@ Total size is 2204 bytes (+37). There's only one remaining bug as far as I can tell, which wasn't there a few hours ago. Running a refresh from a focus() event will break the tabindex flow on it, meaning if you tab out, you'll switch to the first element on the page and will have to ctrl-tab backwards to where you want to go. Tested in various browsers, and this only happens in Opera so... I'll live with it for now. Considering the nightmare it was to make this commit work across all browsers and navigation types, I consider such a small glitch to be a victory.

[b)Non-select box changes:[/b]

! theme_base_js() and theme_base_css() were always called through an echo, and yet they insisted on echoing their contents themselves, resulting in misplaced code, opening the door to more bugs. Ouch. (Subs-Cache.php)

+ Added styling for footnotes on printable pages. (Printpage.template.php)

* Renamed other/wip to other/attic, as I consider these snippets to be 'things too interesting not to be committed somewhere', rather than 'things I'm planning to include in Wedge later'. (other/attic)

+ Added a very short snippet inspired by jQuery-tie, which overloads jQuery methods with a new event. I liked the concept, but I'd rather check for all select boxes individually and fix them as needed, rather than relying on a clever hack. (other/attic/Unused-tie.js)

+ Added another very short snippet showing how to import a DOM element's event data into another element. (other/attic/Unused-events.js)
Re: New revs
« Reply #1235, on January 4th, 2012, 07:21 PM »
rev 1235
(3 files, 3kb)

* Made setSelected() a bit faster. And as a fine geek, I also added comments with performance comparisons. Don't mind me. (sbox.js)

! Fixed select box display area being too wide when the default selection has a details pane. (sbox.js)

! Fixed the $here bug where using it on a local Windows install would generate URLS like ..\Hello/world.png, which browsers don't like. It's a bit hackish but at least it's short and fast. And no, it doesn't seem to have anything to do with plugin directories... (Thanks John!) (Subs-Cache.php)

* All these quotes in PM headers looked odd to me. (PersonalMessage.template.php)
Re: New revs
« Reply #1236, on January 6th, 2012, 02:22 PM »
rev 1236
(8 files, 3kb)

+ Added Ctrl-Enter combination to auto-split quotes in the editor, in addition to the (documented) Shift-Enter combination. And no, I don't have fat fingers... I just type too fast sometimes. (post.js)

- $txt['calendar_month'] and $txt['calendar_day'] are only used in the subscription interface, and don't need to clutter the index language files. (index.language.php, ManagePaid.language.php, ManagePaid.template.php)

+ Added an animation to subscription type switching. (ManagePaid.template.php)

! Adding a subscription for a user uses the 'Add subscription' language string, rather than 'Add user to subscription', in the visible headers. (ManagePaid.template.php)

! Per-user language selection requires password authentication. (Profile-Modify.php)

! Looks odd, but we don't need to put "new Image()" into a var before setting its src attribute... (Themes.template.php)
Re: New revs
« Reply #1237, on January 6th, 2012, 09:11 PM »
rev 1237
(7 files, 16kb)

- Removed selectRadioByName, which is barely ever used in the Wedge codebase, and replaced it with shorter inline jQuery replacements. Fixed a couple of minor bugs in the process. (ManageBans.template.php, ManageSearch.template.php, Profile.template.php, script.js)

- Removed onBeforeUpdate callback from auto-suggest code. onfocus() does just as well, you know! (ManageBans.template.php, suggest.js)

- Removed the 'temporary fix' on Opera when using code tags. It's a very old fix now, and this bug doesn't show up in current versions, no need to bother users with that... (install.sql)

! Fixed search method layout. (admin.css)

+ Added basic JavaScript recognition of iPads (is_tablet). As in, "a device with a screen large enough, but that still relies on touch events." I don't know of any other tablet UAs anyway... (script.js)

* A massive overall rewrite of the main script file, resulting in a 4999-byte gzipped/minified script.js, a 10% improvement. And that 10% share is also the size of Wedge's script file compared with a stock copy of SMF's on a server with mod_deflate off. (script.js)

  - 'vers' is useless, just use $.browser.version directly. And it compresses better to just repeat that...

  * It's cleaner to have one is_* browser declaration per line, instead of several.

  - Removed removeEntities prototype -- only used in one place, and I doubt any plugin would use it. Well, if they do... They can always reproduce it.

  - Removed we_itemPos -- as indicated, it wasn't used anywhere. Plugin authors should use $(item).offset() instead.

  - Removed Thought.getText prototype, only used once in the code, moved it there directly.

  - Removed the "Safari 1.3 Beta" bug fix. Seriously, it was released back in 2005, when work on SMF 2.0 wasn't even started...

  * Replaced every single for () loop with an $.each() call. Saves an awful lot.

  * Replaced most 'something in container' tests, replaced with 'container.something' or something else depending on the context. While the 'in' solution is important in some specific cases, it isn't here. (Not sure about document.cookie, but apparently it's always there.)

  - Removed bIgnoreDisabled flag from invertAll. Only used once in Wedge -- and it's going away since it's in the Package code.

  - Removed bActOnElement flag from weSelectText. I couldn't find it used anywhere in Wedge (and probably in SMF, either.)

  - Used regular show_ajax/hide_ajax on ajaxRating, rather than the custom loader. Although it can be seen as a regression...

  - There's no need to declare a local variable if you're assigning directly to "new images().src". I know -- it's awkward!

  @ Good to know for later: sometimes, there's a chance that declaring local variables as fake parameters will save space. (See weSaveEntities and Thought.edit)

  * Replaced JumpTo's big object with a simple array. I just added the equivalent variable names in comments.

  * Converted weCookie, weToggle and Thought classes to use this.method in constructor, rather than prototypes. Since they're not usually called thousands of times per page, there's virtually no drawback to this, and it allows declaring local variables for everything instead of using the this keyword.
Re: New revs
« Reply #1238, on January 6th, 2012, 09:17 PM »
rev 1238
(6 files, 2kb)

* Decided to update the entire sbox file to use single quotes instead of double quotes. This 'tiny' change ended up saving 50+ bytes at compression time. While I'm not ready to commit sbox yet, I've applied the same technique to all other JS files. Well, whatever I could find, at least. Well, that compensates my disappointment when I tried shortening "new Object()" calls to "new Object" and didn't notice any benefits -- sometimes it even made the file larger... (editor.js, post.js, sha1.js, spellcheck.js, topic.js, up.js)
Re: New revs
« Reply #1239, on January 7th, 2012, 12:01 AM »
rev 1239
(2 files, 3kb)

+ And here's the big scrollbar commit... So, it's ugly (needs some CSS love!), it has bugs (double-clicking, clicking the scrollbar without dragging, etc.), but it works as expected. And although it also works on touch devices, it's so slow and user-unfriendly that I've disabled it. (sbox.js, index.css)

* As you can see, all single and double quotes are now swapped, and it does save 50+ bytes when concatenated with another files that uses single quotes everywhere, such as script.js. (sbox.js)

@ Current sbox size: 2946 bytes, so that's a 750+ byte increase due to the addition of the scrollbar code, but you may want to remove from that the 600+ bytes I saved in earlier commits today. So, the final gzipped, minified and concatenated file is only about 100 bytes larger than before. Then again -- if I remove the scrollbar code, we'll definitely save 750 bytes. What's best..?
Re: New revs
« Reply #1240, on January 7th, 2012, 12:37 PM »Last edited on January 7th, 2012, 03:06 PM by Nao
rev 1240
(1 file, 8kb)

* Hardcoded maximum select box height to 250 pixels instead of 500. Looks like a good compromise between usability and comfort. (sbox.js)

* sbox is down to 2734, over 200 bytes saved in an hour or two. (sbox.js)

  - Finally removed the options object, with the understanding that Wedge is better off with *consistent* styling, and shouldn't allow for different animation speeds or maximum heights across multiple boxes on a page.

  - Removed .sc() object and instead assigned a scrollbar object directly to the individual dropdowns.

  - Removed a few unused (or barely used) variables. Removed touch events, as hinted yesterday.

  * Added a "e.wheelDelta || -e.details" hack, which hopefully will work...

  * And cleaned up the creation process, which used two different variables for exactly the same object...

@ To do: merge the SelectBox and ScrollBar objects, and see if it helps with compression or makes it worse. I reckon it won't be any better, but I've seen more surprising things happen.
Re: New revs
« Reply #1241, on January 7th, 2012, 08:25 PM »
rev 1241
(6 files +2, 9kb)

* Improved thumb styling in select box scrollbars. (index.css)

* More space optimizations... Reached 2707 bytes, another 27 bytes less. As you can imagine though -- it's going to be pretty much impossible to go below 2700 bytes at this point. But it's okay, the code looks great. (sbox.js)

! Fixed select box closing itself when clicking on the scrollbar outside the thumb (instead of actually moving the thumb to that position.) Note to self: that 'return false' in drag() was important, it just needed to be moved to another event type... (sbox.js)

! Fixed IE6's tendency to enlarge select boxes to full width. (index.ie6.css)

! Fixed broken button layout in IE6 and IE7. Copied the .inline-block method to the editor CSS files, since they can't inherit from index.css (not the same final cache file), and said method is solid enough. (editor.css, editor.ie6.css, editor.ie7.css, index.ie7.css)

@ Note: scrollbars are broken in IE6, most likely because of a bug when calculating the required height. Should I care about that...? I'm thinking not... Also, releasing the mouse button outside of a select box after dragging its thumb will close the select box in IE 6/7/8/9. Dunno why, but it seems to doesn't take the 'return false' into account (yeah, the one mentioned above), as it bubbles up the DOM tree.
Re: New revs
« Reply #1242, on January 8th, 2012, 12:47 PM »
rev 1242
(2 files, 2kb)

* $(document).click() is now $(document).mousedown(), thus $ no longer needs to return false. (sbox.js)

* Select box entries are now clickable through .mousedown() instead of .click(), which fixes a problem with IE 6/7 when dragging the scrollbar and releasing the mouse button outside of the select box (guess what, it would close it.) (sbox.js)

! ...And the fix above caused IE 6/7/8 to select the item text in some cases, so I added an onselectstart event that adds 12 bytes to the gzipped file, which I compensated in other areas to retain the exact same final size. I am absolutely mental. Please help me. (sbox.js)

- Got rid of setting maxHeight in dropdown CSS, to add support for scrollbars in IE6. It's ongoing though, so it still actually doesn't work in IE6 but it'll be done soon enough. (sbox.js)

- Select box 'text' class doesn't need to be an inline block, really. Also, 'items' class (unordered list) behaves better as inline. (index.css)

+ Added a hover effect on select box scrollbar thumbs. (index.css)
Re: New revs
« Reply #1243, on January 8th, 2012, 07:33 PM »
rev 1243
(3 files, 2kb)

* Simplified the HTML markup for the scrollbar. Gone is the track div (the scrollbar div itself does the job perfectly), the thumb div loses its class, and viewport/scrollbar are now floated instead of absolutely-positioned (note to self: .viewport doesn't need to be floated, it just makes the file shorter), which makes for simpler code in the end, and this actually... (index.css)

! ...Fixed the scrollbar in IE6. Phew, at last. Tested final code on IE 6/7/8/9, Safari 5.1, Chrome 17, Firefox 9 and Opera 12. Works flawlessly everywhere (except for the odd margins on IE 6/7, probably due to an issue in styling unordered lists.) (sbox.js, index.css)

* The credits page needed a small update. (Credits.php)

@ 2669 bytes. Need I say more, ladies and gentlemen...? (sbox.js)
Re: New revs
« Reply #1244, on January 10th, 2012, 02:30 PM »
rev 1244
(3 files, 4kb)

! Auto-suggest would gladly show the same name twice if you entered it again by mistake. I'm not exactly sure why. Ensuring this doesn't happen. (suggest.js)

- Removed unused hooks from auto-suggest code. (suggest.js)

! Fixed auto-suggest not working at all in PM mode. (pm.js, suggest.js)

* Also rewrote PM To/Bcc auto-suggest handling to use cleaner code. (PersonalMessage.template.php, pm.js)