Last modified: 2014-02-12 23:52:35 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T38379, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 36379 - MobileFrontend uses too many global variables
MobileFrontend uses too many global variables
Status: RESOLVED FIXED
Product: MobileFrontend
Classification: Unclassified
stable (Other open bugs)
unspecified
All All
: Low normal
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-01 12:35 UTC by Jon
Modified: 2014-02-12 23:52 UTC (History)
11 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jon 2012-05-01 12:35:30 UTC
As pointed out in bug 36007

MobileFrontend's bigger issues, is "using awfully generic names and titles all in the main namespace".

These include:
- global function `wm_toggle_section` (which is present for the purpose of the Wikipedia Mobile app versions below 1.2
- id's on elements - we should at least where needed insert a mfe- prefix on these
Comment 1 Krinkle 2012-05-01 17:20:39 UTC
Just a small note to suggest "mw-mf" or even "mw-mobilefrontend" even instead of "mfe" as prefix.
Comment 2 Max Semenik 2012-05-01 17:37:40 UTC
Sice there are plans to merge this thing with core, why not mw-?
Comment 3 Jon 2012-05-14 18:25:04 UTC
I've started addressing this is the implementation of the new navigation. Are we agreed on a prefix? I'm currently using 'mw-mf-'

Please shout quickly if a different one should be used
Comment 4 Krinkle 2012-05-15 09:13:05 UTC
mw-mf- sounds good. Even when it is part of core, it will still be in a certain module. Putting everything in the root context would be wrong.

Stuff for foo in component x in core is named like mw-x-foo.
Comment 5 Krinkle 2012-05-15 09:25:17 UTC
I'm assuming that is for CSS classes and IDs, right? For javascript modules you wouldn't use dashes since that would make the variable still global. It'd instead be something like this:

( function ( $, mw ) {
    mw.mobileFrontend = {
        foo: 'bar'
    };

}( jQuery, mediaWiki ) );


( function ( $, mw ) {
    var mf = mw.mobileFrontend;

    $( '#mw-mf-foo' ).text( mf.foo );

}( jQuery, mediaWiki ) );
Comment 6 Jon 2012-05-15 09:30:43 UTC
Yes of course.

Javascript modules currently use the MobileFrontend as the only global variable (although there is a single bit of legacy code that I am trying to throw away)

Changing the name of the MobileFrontend global variable is going to be slightly more problematic and may take a bit more time as it would also require changes to the app (but it's on my plate :-)).
Comment 7 Jon 2012-06-02 10:42:24 UTC
https://gerrit.wikimedia.org/r/9743

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links