Skip to main content
Version: 4.5

YUI Namespacing

Deprecated 2.9
caution

As of Moodle 2.9 we are transitioning away from YUI to AMD modules. This transition will take a long time, but it is important because the YUI team have stopped all new development on the YUI library. See JavaScript Modules for more information.

Introduction and Rationale

One of the many fantastic features of YUI is that it supports sandboxing of individual modules. This means that a third-party plugin cannot interfere with core plugins in such a way that will have undesired consequences to anything using the core code.

As an example, a plugin could modify Y.Node to add a new function, or overwrite an existing function. This may be desirable for one instance of that Node, but undesirable for all others. For anyone wishing to use the additional function, they should depend upon the plugin instead which adds this functionality.

To benefit from this sandboxing fully however, we must write our YUI modules under the Y namespace.

To keep things consistent and clear, all Moodle-specific modules should be under a single Namespace. Ideally this namespace should be short, but still clear that it relates to Moodle.

Proposed namespace

The proposed namespace fits into:

Y.M.<plugin_or_system_type>[_<component>].<YUI_modulename>[.<YUI_submodule>]

The plugin_or_system_type should match the list defined in lib/classes/component.php in fetch_subsystems, with the additional 'core' subsytem used to for items within lib.

The optional component will be the plugin name where relevant

The ** YUI_modulename** should match module name

The optional YUI_submodule should match the submodule if relevant

Examples

YUI ModuleNamespace
moodle-core-dockY.M.core.dock
moodle-core-dock-loaderY.M.core.dock.loader
moodle-course-toolboxesY.M.course.toolboxes
moodle-mod_forum-inlinereplyY.M.mod_forum.inlinereply
moodle-block_navigation-navigationY.M.block_navigation.navigation
moodle-mod_assign-historyY.M.mod_assign.history
moodle-form-dateselectorY.M.form.dateselector
moodle-form-listingY.M.form.listing