Ticket #1468 (new defect)

Opened 6 years ago

Last modified 5 years ago

more js cleanup

Reported by: demian Assigned to: somebody
Priority: normal Milestone: 2.0
Component: not categorised Severity: open
Keywords: js namespace Cc:

Description (Last modified by demian)

  • seagull js files should be defined in sgl namespace, ie: www/js/SGL/MyClass.js, and called SGL.MyClass?.myMethod()
  • local (module-based) js files should preserve namespace, SGL.mymodule.myMethod(), and be stored in modules/$mymodule/www/js
  • global.js should be renamed to SGL.js, and load libs on demand via params, ie
<script type="text/javascript" src="/www/js/SGL.js?String, Array, ModalWindow"></script>
  • clarify namespacing
    • for entity objects
SGL.mymodule.User.getById(id)
  • for namespaced objects
SGL.mymodule.myMethod()

Change History

05/29/07 09:43:33 changed by demian

  • description changed.

05/29/07 09:44:40 changed by demian

  • description changed.

05/29/07 10:02:48 changed by jcasanova

A sample SGL.user namespaced object an the entity object going along:

/**
 *  Some methods to be used within the user module
 *  Namespaced object
 *
 */
if (typeof SGL == 'undefined') { var SGL = {}; };
SGL.user = {
    addQuickNote: function() {
        alert('Quick note ajoutée');
    }
}
/**
 *  Entity object
 *
 */
SGL.user.User = function(name) {
    this.name = name;
}
SGL.user.User.prototype = {
    giveMyName: function() {
        alert('My name is ' +this.name);
    },
    setAge: function(age) {
        this.age = age;
    },
    giveMyAge: function() {
        alert('I am ' +this.age +' years old');
    }
};
SGL.user.addQuickNote();
var currentUser = new SGL.user.User('Julien');
currentUser.giveMyName();
currentUser.setAge('29');
currentUser.giveMyAge();

05/29/07 10:03:53 changed by jcasanova

  • keywords set to js namespace.

03/23/08 08:57:19 changed by demian

  • milestone changed from 0.7.0 to 0.9.0 - polishing.

Milestone 0.7.0 deleted

06/25/08 19:20:50 changed by demian

  • milestone changed from 0.9.1 - polishing to 0.9.0 - refactoring.