[wp-trac] [WordPress Trac] #26086: Fix "moby6"
WordPress Trac
noreply at wordpress.org
Mon Nov 18 16:42:06 UTC 2013
#26086: Fix "moby6"
----------------------------+--------------------
Reporter: azaozz | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.8
Component: Administration | Version: trunk
Severity: normal | Resolution:
Keywords: ui-focus |
----------------------------+--------------------
Comment (by azaozz):
Yep, it's starting to look a lot better. Some more thoughts:
- `responsive` still sounds too "global". I'm not that good at naming too
but maybe something like `touch-helper` (`touchHelper` in JS), or maybe
`wp-touch-menus` as it deals primarily with touch devices and the menu.
Maybe @helen would have a better idea :)
- Consider merging "moby6" and stickyMenu. They both deal with similar
things and share cached elements.
- Not sure we need to include underscore.js on absolutely all admin pages
just for a simple timing function. On one side Underscore is small and has
many useful utility functions, on the other side most of these functions
are also in jQuery which is already available everywhere. The "fire once
at end of window resize" (BTW why fire this on window.scroll, doesn't do
anything) is pretty easy to do with fixed timeout and callback, something
like:
{{{
// `i` is just for testing, paste in the browser console and try it
var timeout, timerSet, i = 0;
function fireOnce() {
if ( timerSet ) {
clearTimeout( timeout );
}
timeout = setTimeout( function() { i++; timerSet = false;
console.log('run = '+i); }, 200 );
timerSet = true;
}
jQuery(window).resize( fireOnce );
}}}
- When adding custom events to jQuery, best is to add them on
`$(document)` and name them descriptively. Namespacing is also a very good
idea (would say "required") but only when attaching to events, not when
adding them. So
`$(document.documentElement).trigger('activate.responsive');` would be
better as `$(document).trigger('wp-touch-menus-activate');` or whatever
name we end up choosing. Also, are these custom events needed elsewhere?
If not, perhaps they can be simple callbacks scoped in the wrapper
function.
- Perhaps the scope can be managed better by declaring all cached jQuery
elements outside the mixin. That would also share them with `stickyMenu`
if we decide not to merge these two.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/26086#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list