dock javascript NOBUG Add missing ;s that were causing Eclipse warnings.

I thought they were also breaking things in Firefox, but I was wrong about that.
Still, seems worth comitting this code clean-up.
This commit is contained in:
Tim Hunt 2010-08-03 16:17:49 +00:00
parent 113065d2fa
commit edc858dcce

View file

@ -11,7 +11,7 @@ M.core_dock = {
initialised : false, // True once thedock has been initialised initialised : false, // True once thedock has been initialised
delayedevent : null, // Will be an object if there is a delayed event in effect delayedevent : null, // Will be an object if there is a delayed event in effect
preventevent : null // Will be an eventtype if there is an eventyoe to prevent preventevent : null // Will be an eventtype if there is an eventyoe to prevent
} };
/** /**
* Namespace containing the nodes that relate to the dock * Namespace containing the nodes that relate to the dock
* @namespace * @namespace
@ -20,7 +20,7 @@ M.core_dock.nodes = {
dock : null, // The dock itself dock : null, // The dock itself
body : null, // The body of the page body : null, // The body of the page
panel : null // The docks panel panel : null // The docks panel
} };
/** /**
* Configuration parameters used during the initialisation and setup * Configuration parameters used during the initialisation and setup
* of dock and dock items. * of dock and dock items.
@ -34,7 +34,7 @@ M.core_dock.cfg = {
orientation:'vertical', // vertical || horizontal determines if we change the title orientation:'vertical', // vertical || horizontal determines if we change the title
spacebeforefirstitem: 10, // Space between the top of the dock and the first item spacebeforefirstitem: 10, // Space between the top of the dock and the first item
removeallicon: M.util.image_url('t/dock_to_block', 'moodle') removeallicon: M.util.image_url('t/dock_to_block', 'moodle')
} };
/** /**
* CSS classes to use with the dock * CSS classes to use with the dock
* @namespace * @namespace
@ -48,7 +48,7 @@ M.core_dock.css = {
dockeditemcontainer:'dockeditem_container', dockeditemcontainer:'dockeditem_container',
dockedtitle:'dockedtitle', // CSS class added to the item's title in each dock dockedtitle:'dockedtitle', // CSS class added to the item's title in each dock
activeitem:'activeitem' // CSS class added to the active item activeitem:'activeitem' // CSS class added to the active item
} };
/** /**
* Augments the classes as required and processes early bindings * Augments the classes as required and processes early bindings
*/ */
@ -182,7 +182,7 @@ M.core_dock.init = function(Y) {
runningcount++; runningcount++;
} }
} }
} };
})(Y).init(); })(Y).init();
// Attach the required event listeners // Attach the required event listeners
@ -200,7 +200,7 @@ M.core_dock.init = function(Y) {
// Inform everyone the dock has been initialised // Inform everyone the dock has been initialised
this.fire('dock:initialised'); this.fire('dock:initialised');
return true; return true;
} };
/** /**
* Get the panel docked blocks will be shown in and initialise it if we havn't already. * Get the panel docked blocks will be shown in and initialise it if we havn't already.
*/ */
@ -231,7 +231,7 @@ M.core_dock.getPanel = function() {
this.removeClass('dockitempanel_hidden'); this.removeClass('dockitempanel_hidden');
this.fire('dockpanel:shown'); this.fire('dockpanel:shown');
this.fire('dockpanel:visiblechange'); this.fire('dockpanel:visiblechange');
} };
// Add a hide event // Add a hide event
dockpanel.hide = function() { dockpanel.hide = function() {
this.fire('dockpanel:beforehide'); this.fire('dockpanel:beforehide');
@ -239,7 +239,7 @@ M.core_dock.getPanel = function() {
this.addClass('dockitempanel_hidden'); this.addClass('dockitempanel_hidden');
this.fire('dockpanel:hidden'); this.fire('dockpanel:hidden');
this.fire('dockpanel:visiblechange'); this.fire('dockpanel:visiblechange');
} };
// Add a method to set the header content // Add a method to set the header content
dockpanel.setHeader = function(content) { dockpanel.setHeader = function(content) {
this.contentHeader.setContent(content); this.contentHeader.setContent(content);
@ -248,11 +248,11 @@ M.core_dock.getPanel = function() {
this.contentHeader.append(arguments[i]); this.contentHeader.append(arguments[i]);
} }
} }
} };
// Add a method to set the body content // Add a method to set the body content
dockpanel.setBody = function(content) { dockpanel.setBody = function(content) {
this.contentBody.setContent(content); this.contentBody.setContent(content);
} };
// Add a method to set the top of the panel position // Add a method to set the top of the panel position
dockpanel.setTop = function(newtop) { dockpanel.setTop = function(newtop) {
this.setY(newtop); this.setY(newtop);
@ -262,7 +262,7 @@ M.core_dock.getPanel = function() {
return true; return true;
} }
this.setStyle('top', newtop+'px'); this.setStyle('top', newtop+'px');
} };
// Put the dockpanel in the body // Put the dockpanel in the body
parent.append(dockpanel); parent.append(dockpanel);
// Return it // Return it
@ -273,7 +273,7 @@ M.core_dock.getPanel = function() {
this.fire('dock:panelgenerated'); this.fire('dock:panelgenerated');
} }
return this.nodes.panel; return this.nodes.panel;
} };
/** /**
* Handles a generic event within the dock * Handles a generic event within the dock
* @param {Y.Event} e * @param {Y.Event} e
@ -319,7 +319,7 @@ M.core_dock.handleEvent = function(e, options) {
} }
} }
return true; return true;
} };
/** /**
* This function delays an event and then fires it providing the cursor if either * This function delays an event and then fires it providing the cursor if either
* within or outside of the original target (options.iscontained=true|false) * within or outside of the original target (options.iscontained=true|false)
@ -337,7 +337,7 @@ M.core_dock.delayEvent = function(event, options, target) {
self.delayedevent.target = e.target; self.delayedevent.target = e.target;
}), }),
timeout : null timeout : null
} };
})(self); })(self);
self.delayedevent.timeout = setTimeout(function(){ self.delayedevent.timeout = setTimeout(function(){
self.delayedevent.timeout = null; self.delayedevent.timeout = null;
@ -347,7 +347,7 @@ M.core_dock.delayEvent = function(event, options, target) {
} }
}, options.delay*1000); }, options.delay*1000);
return true; return true;
} };
/** /**
* Corrects the orientation of the title, which for the default * Corrects the orientation of the title, which for the default
* dock just means making it vertical * dock just means making it vertical
@ -382,7 +382,7 @@ M.core_dock.fixTitleOrientation = function(item, title, text) {
if (Y.UA.ie > 7) { if (Y.UA.ie > 7) {
// IE8 can flip the text via CSS but not handle SVG // IE8 can flip the text via CSS but not handle SVG
title.setContent(text) title.setContent(text);
title.setAttribute('style', 'writing-mode: tb-rl; filter: flipV flipH;display:inline;'); title.setAttribute('style', 'writing-mode: tb-rl; filter: flipV flipH;display:inline;');
title.addClass('filterrotate'); title.addClass('filterrotate');
return title; return title;
@ -413,14 +413,14 @@ M.core_dock.fixTitleOrientation = function(item, title, text) {
svg.setAttribute('width', width); svg.setAttribute('width', width);
svg.appendChild(txt); svg.appendChild(txt);
title.append(svg) title.append(svg);
item.on('dockeditem:drawcomplete', function(txt, title){ item.on('dockeditem:drawcomplete', function(txt, title){
txt.setAttribute('fill', Y.one(title).getStyle('color')); txt.setAttribute('fill', Y.one(title).getStyle('color'));
}, item, txt, title); }, item, txt, title);
return title; return title;
} };
/** /**
* Resizes the space that contained blocks if there were no blocks left in * Resizes the space that contained blocks if there were no blocks left in
* it. e.g. if all blocks have been moved to the dock * it. e.g. if all blocks have been moved to the dock
@ -464,7 +464,7 @@ M.core_dock.resizeBlockSpace = function(node) {
bodynode.removeClass(blockregions[i].bodyclass); bodynode.removeClass(blockregions[i].bodyclass);
} }
} }
} };
/** /**
* Adds a dock item into the dock * Adds a dock item into the dock
* @function * @function
@ -478,14 +478,14 @@ M.core_dock.add = function(item) {
this.items[item.id].draw(); this.items[item.id].draw();
this.fire('dock:itemadded', item); this.fire('dock:itemadded', item);
this.fire('dock:itemschanged', item); this.fire('dock:itemschanged', item);
} };
/** /**
* Appends a dock item to the dock * Appends a dock item to the dock
* @param {YUI.Node} docknode * @param {YUI.Node} docknode
*/ */
M.core_dock.append = function(docknode) { M.core_dock.append = function(docknode) {
this.nodes.container.append(docknode); this.nodes.container.append(docknode);
} };
/** /**
* Initialises a generic block object * Initialises a generic block object
* @param {YUI} Y * @param {YUI} Y
@ -496,7 +496,7 @@ M.core_dock.init_genericblock = function(Y, id) {
this.init(Y); this.init(Y);
} }
new this.genericblock(id).init(Y, Y.one('#inst'+id)); new this.genericblock(id).init(Y, Y.one('#inst'+id));
} };
/** /**
* Removes the node at the given index and puts it back into conventional page sturcture * Removes the node at the given index and puts it back into conventional page sturcture
* @function * @function
@ -513,7 +513,7 @@ M.core_dock.remove = function(uid) {
this.fire('dock:itemremoved', uid); this.fire('dock:itemremoved', uid);
this.fire('dock:itemschanged', uid); this.fire('dock:itemschanged', uid);
return true; return true;
} };
/** /**
* Ensures the the first item in the dock has the correct class * Ensures the the first item in the dock has the correct class
*/ */
@ -522,7 +522,7 @@ M.core_dock.resetFirstItem = function() {
if (this.nodes.dock.one('.'+this.css.dockeditem)) { if (this.nodes.dock.one('.'+this.css.dockeditem)) {
this.nodes.dock.one('.'+this.css.dockeditem).addClass('firstdockitem'); this.nodes.dock.one('.'+this.css.dockeditem).addClass('firstdockitem');
} }
} };
/** /**
* Removes all nodes and puts them back into conventional page sturcture * Removes all nodes and puts them back into conventional page sturcture
* @function * @function
@ -533,7 +533,7 @@ M.core_dock.remove_all = function() {
this.remove(i); this.remove(i);
} }
return true; return true;
} };
/** /**
* Hides the active item * Hides the active item
*/ */
@ -542,7 +542,7 @@ M.core_dock.hideActive = function() {
if (item) { if (item) {
item.hide(); item.hide();
} }
} };
/** /**
* Checks wether the dock should be shown or hidden * Checks wether the dock should be shown or hidden
*/ */
@ -557,7 +557,7 @@ M.core_dock.checkDockVisibility = function() {
this.nodes.body.addClass(this.css.body); this.nodes.body.addClass(this.css.body);
this.fire('dock:shown'); this.fire('dock:shown');
} }
} };
/** /**
* This smart little function allows developers to attach event listeners before * This smart little function allows developers to attach event listeners before
* the dock has been augmented to allows event listeners. * the dock has been augmented to allows event listeners.
@ -569,7 +569,7 @@ M.core_dock.checkDockVisibility = function() {
*/ */
M.core_dock.on = function(event, callback) { M.core_dock.on = function(event, callback) {
this.earlybinds.push({event:event,callback:callback}); this.earlybinds.push({event:event,callback:callback});
} };
/** /**
* This function takes all early binds and attaches them as listeners properly * This function takes all early binds and attaches them as listeners properly
* This should only be called once augmentation is complete. * This should only be called once augmentation is complete.
@ -580,7 +580,7 @@ M.core_dock.applyBinds = function() {
this.on(bind.event, bind.callback); this.on(bind.event, bind.callback);
} }
this.earlybinds = []; this.earlybinds = [];
} };
/** /**
* This function checks the size and position of the panel and moves/resizes if * This function checks the size and position of the panel and moves/resizes if
* required to keep it within the bounds of the window. * required to keep it within the bounds of the window.
@ -614,7 +614,7 @@ M.core_dock.resize = function() {
} }
this.fire('dock:resizepanelcomplete'); this.fire('dock:resizepanelcomplete');
return; return;
} };
/** /**
* Returns the currently active dock item or false * Returns the currently active dock item or false
*/ */
@ -625,7 +625,7 @@ M.core_dock.getActiveItem = function() {
} }
} }
return false; return false;
} };
/** /**
* This class represents a generic block * This class represents a generic block
* @class M.core_dock.genericblock * @class M.core_dock.genericblock
@ -683,7 +683,7 @@ M.core_dock.genericblock.prototype = {
// Move the block straight to the dock if required // Move the block straight to the dock if required
if (node.hasClass('dock_on_load')) { if (node.hasClass('dock_on_load')) {
node.removeClass('dock_on_load') node.removeClass('dock_on_load');
this.skipsetposition = true; this.skipsetposition = true;
this.move_to_dock(null, commands); this.move_to_dock(null, commands);
} }
@ -701,7 +701,7 @@ M.core_dock.genericblock.prototype = {
} }
var Y = this.Y; var Y = this.Y;
var dock = M.core_dock var dock = M.core_dock;
var node = Y.one('#inst'+this.id); var node = Y.one('#inst'+this.id);
var blockcontent = node.one('.content'); var blockcontent = node.one('.content');
@ -746,12 +746,12 @@ M.core_dock.genericblock.prototype = {
// check the contents block [editing=off] // check the contents block [editing=off]
this.contents.all('.moveto').on('returntoblock|click', function(e){ this.contents.all('.moveto').on('returntoblock|click', function(e){
e.halt(); e.halt();
dock.remove(this.id) dock.remove(this.id);
}, this); }, this);
// check the commands block [editing=on] // check the commands block [editing=on]
this.commands.all('.moveto').on('returntoblock|click', function(e){ this.commands.all('.moveto').on('returntoblock|click', function(e){
e.halt(); e.halt();
dock.remove(this.id) dock.remove(this.id);
}, this); }, this);
// Add a close icon // Add a close icon
// Must set the image src seperatly of we get an error with XML strict headers // Must set the image src seperatly of we get an error with XML strict headers
@ -802,7 +802,7 @@ M.core_dock.genericblock.prototype = {
this.isdocked = false; this.isdocked = false;
return true; return true;
} }
} };
/** /**
* This class represents an item in the dock * This class represents an item in the dock
@ -839,12 +839,12 @@ M.core_dock.item = function(Y, uid, title, contents, commands, blockclass){
this.commands = commands; this.commands = commands;
} }
if (blockclass && this.blockclass==null) { if (blockclass && this.blockclass==null) {
this.blockclass = blockclass this.blockclass = blockclass;
} }
this.nodes = (function(){ this.nodes = (function(){
return {docktitle : null, dockitem : null, container: null} return {docktitle : null, dockitem : null, container: null};
})(); })();
} };
/** /**
* *
*/ */
@ -922,4 +922,4 @@ M.core_dock.item.prototype = {
this.nodes.dockitem.remove(); this.nodes.dockitem.remove();
this.fire('dockeditem:itemremoved'); this.fire('dockeditem:itemremoved');
} }
} };