In theory, it doesn't matter what we do right? We are the application after all, rather than a library to be used elsewhere . But I agree that in that particular case, where it's a form element with javascript that should be re-usable, it should be namespaced in some way.
Regarding the actual namespace mechanism, we did some namespace-y stuff in files like js/views.js I think. We didn't bother with most of those fields you have, there's not much point in specifying them as you won't ever want them in code - you could just whack 'em in a comment and be done with it
]]>Off course, shared javascript should be under mahara or "core" depending on whatever preference Catalyst prefers.
As an example ... this snippet of the existing javascript would be published into the page by authlist ...
function move_up(id) {
instanceArray = document.getElementById('instancePriority').value.split(',');
var outputArray = new Array();
for(i = instanceArray.length - 1; i >= 0; i--) {
if(instanceArray[i] == id) {
outputArray[i] = instanceArray[i-1];
outputArray[i-1] = instanceArray[i];
--i;
} else {
outputArray[i] = instanceArray[i];
}
}
rebuildInstanceList(outputArray);
}
As an example of namespace isolating ... this snippet from my institutiontypelist javascript would minimize conflicts (except for the case of pages want more than one of this type element ... but this is not such a pieform element).
institutiontype = new function(){
this.moduleId = "institutiontype";
this.version = "1.0.0";
this.versionDate = "24 September 2009";
this.codeStatus = "stable";
this.lastAuthor = "Ray Merrill";
this.copyright = "Copyright 2009 Accredited Portfolios LLC";
this.license = "open source GNU GPLv3";
this.doNothing = function() {};
}
institutiontype.move_up = function(id) {
instanceArray = document.getElementById('instancePriority').value.split(',');
var outputArray = new Array();
for(i = instanceArray.length - 1; i >= 0; i--) {
if(instanceArray[i] == id) {
outputArray[i] = instanceArray[i-1];
outputArray[i-1] = instanceArray[i];
--i;
} else {
outputArray[i] = instanceArray[i];
}
}
institutiontype.rebuildInstanceList(outputArray);
}