Moodle

We should not add JavaScript to the YAHOO namespace

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: AJAX, Quiz
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

Sorry, this one is quite big. I don't know why I did not notice it before.

We really should not be adding our code to the YAHOO library namespace. I would change

YAHOO.cats.container -> question_bank
YAHOO.quiz.container -> quiz_editor

or something like that.

<div id="module" is not very descriptive. Wouldn't something like id="questionbankcontents" be better?

Do you really want to initialise on load, would onDomReady work better?

Activity

Hide
Olli Savolainen added a comment -

Changed it to OnDOMReady.

http://www.zachleat.com/web/2007/08/09/yui-code-review-yahoonamespace/

From this I understand that the YAHOO namespace is indeed intended for other uses than just Yahoo!'s. However, I am not sure if that code applies otherwise to be used in a namespace.

So I am not sure what exactly to fix about the namespaces. If you still think it is necessary, please fix it? Thanks.

Show
Olli Savolainen added a comment - Changed it to OnDOMReady. http://www.zachleat.com/web/2007/08/09/yui-code-review-yahoonamespace/ From this I understand that the YAHOO namespace is indeed intended for other uses than just Yahoo!'s. However, I am not sure if that code applies otherwise to be used in a namespace. So I am not sure what exactly to fix about the namespaces. If you still think it is necessary, please fix it? Thanks.
Hide
Tim Hunt added a comment -

OK, I'll deal with this.

(By the way, the blog post you link to is just about what is technically possible, not what is recommended. Indeed, another post from the same blog: http://www.zachleat.com/web/2007/08/28/namespacing-outside-of-the-yahoo-namespace/)

Show
Tim Hunt added a comment - OK, I'll deal with this. (By the way, the blog post you link to is just about what is technically possible, not what is recommended. Indeed, another post from the same blog: http://www.zachleat.com/web/2007/08/28/namespacing-outside-of-the-yahoo-namespace/)
Hide
Tim Hunt added a comment -

Work in progress patch. Does not work. I just want to be able to pick this up tomorrow at work.

Show
Tim Hunt added a comment - Work in progress patch. Does not work. I just want to be able to pick this up tomorrow at work.
Hide
Olli Savolainen added a comment -

Alright then. Thanks.

Though I do wonder about the following quote on the page you referred to, and about why didn't the yahoo folks then think of that, and where is the official documentation for YAHOO.namespace() (and frankly I also wonder why the snow that fell here yesterday had to melt last night), even though I don't see how two namespaces could coexist with the same name:

"I'm glad you're enjoying using YUITest. I think your point about namespacing is well-taken, but the YAHOO.namespace() function is non-destructive. If you were already using YAHOO.tool, then YAHOO.namespace() won't overwrite the existing one so all of your functionality will be safe."

Show
Olli Savolainen added a comment - Alright then. Thanks. Though I do wonder about the following quote on the page you referred to, and about why didn't the yahoo folks then think of that, and where is the official documentation for YAHOO.namespace() (and frankly I also wonder why the snow that fell here yesterday had to melt last night), even though I don't see how two namespaces could coexist with the same name: "I'm glad you're enjoying using YUITest. I think your point about namespacing is well-taken, but the YAHOO.namespace() function is non-destructive. If you were already using YAHOO.tool, then YAHOO.namespace() won't overwrite the existing one so all of your functionality will be safe."
Hide
Tim Hunt added a comment -

Well, to my mind, the whole point of namespaces is to completely avoid naming conflicts. If we keep stuff starting with YAHOO == Yahoo's code, and put Moodle code in other namespaces, then we can be sure that there will never be a name collisions caused by anything YAHOO does. Anyway, should be easy to finish fixing when I get a moment.

Show
Tim Hunt added a comment - Well, to my mind, the whole point of namespaces is to completely avoid naming conflicts. If we keep stuff starting with YAHOO == Yahoo's code, and put Moodle code in other namespaces, then we can be sure that there will never be a name collisions caused by anything YAHOO does. Anyway, should be easy to finish fixing when I get a moment.
Hide
Tim Hunt added a comment -

Right, I think I have done this, and having tested, I don't think I have broken anything. Could you give it a quick test please Olli, since you know better than me how it is supposed to work. Thanks

Show
Tim Hunt added a comment - Right, I think I have done this, and having tested, I don't think I have broken anything. Could you give it a quick test please Olli, since you know better than me how it is supposed to work. Thanks
Hide
Olli Savolainen added a comment -

The two dialogs seem to work OK. Thank you.

Show
Olli Savolainen added a comment - The two dialogs seem to work OK. Thank you.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: