Skip to content

Commit

Permalink
MDL-53293 core: Add destructor phases to core-dragdrop
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed May 11, 2016
1 parent e4b5a06 commit a321eb0
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 32 deletions.
41 changes: 31 additions & 10 deletions lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,59 @@ Y.extend(DRAGDROP, Y.Base, {
*/
lastdroptarget: null,

/**
* Listeners.
*
* @property listeners
* @type Array
* @default null
*/
listeners: null,

/**
* The initializer which sets up the move action.
*
* @method initializer
* @protected
*/
initializer: function() {
this.listeners = [];

// Listen for all drag:start events.
Y.DD.DDM.on('drag:start', this.global_drag_start, this);
this.listeners.push(Y.DD.DDM.on('drag:start', this.global_drag_start, this));

// Listen for all drag:end events.
Y.DD.DDM.on('drag:end', this.global_drag_end, this);
this.listeners.push(Y.DD.DDM.on('drag:end', this.global_drag_end, this));

// Listen for all drag:drag events.
Y.DD.DDM.on('drag:drag', this.global_drag_drag, this);
this.listeners.push(Y.DD.DDM.on('drag:drag', this.global_drag_drag, this));

// Listen for all drop:over events.
Y.DD.DDM.on('drop:over', this.global_drop_over, this);
this.listeners.push(Y.DD.DDM.on('drop:over', this.global_drop_over, this));

// Listen for all drop:hit events.
Y.DD.DDM.on('drop:hit', this.global_drop_hit, this);
this.listeners.push(Y.DD.DDM.on('drop:hit', this.global_drop_hit, this));

// Listen for all drop:miss events.
Y.DD.DDM.on('drag:dropmiss', this.global_drag_dropmiss, this);
this.listeners.push(Y.DD.DDM.on('drag:dropmiss', this.global_drag_dropmiss, this));

// Add keybaord listeners for accessible drag/drop
Y.one(Y.config.doc.body).delegate('key', this.global_keydown,
'down:32, enter, esc', '.' + MOVEICON.cssclass, this);
this.listeners.push(Y.one(Y.config.doc.body).delegate('key', this.global_keydown,
'down:32, enter, esc', '.' + MOVEICON.cssclass, this));

// Make the accessible drag/drop respond to a single click.
Y.one(Y.config.doc.body).delegate('click', this.global_keydown,
'.' + MOVEICON.cssclass , this);
this.listeners.push(Y.one(Y.config.doc.body).delegate('click', this.global_keydown,
'.' + MOVEICON.cssclass , this));
},

/**
* The destructor to shut down the instance of the dragdrop system.
*
* @method destructor
* @protected
*/
destructor: function() {
new Y.EventHandle(this.listeners).detach();
},

/**
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 31 additions & 10 deletions lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,59 @@ Y.extend(DRAGDROP, Y.Base, {
*/
lastdroptarget: null,

/**
* Listeners.
*
* @property listeners
* @type Array
* @default null
*/
listeners: null,

/**
* The initializer which sets up the move action.
*
* @method initializer
* @protected
*/
initializer: function() {
this.listeners = [];

// Listen for all drag:start events.
Y.DD.DDM.on('drag:start', this.global_drag_start, this);
this.listeners.push(Y.DD.DDM.on('drag:start', this.global_drag_start, this));

// Listen for all drag:end events.
Y.DD.DDM.on('drag:end', this.global_drag_end, this);
this.listeners.push(Y.DD.DDM.on('drag:end', this.global_drag_end, this));

// Listen for all drag:drag events.
Y.DD.DDM.on('drag:drag', this.global_drag_drag, this);
this.listeners.push(Y.DD.DDM.on('drag:drag', this.global_drag_drag, this));

// Listen for all drop:over events.
Y.DD.DDM.on('drop:over', this.global_drop_over, this);
this.listeners.push(Y.DD.DDM.on('drop:over', this.global_drop_over, this));

// Listen for all drop:hit events.
Y.DD.DDM.on('drop:hit', this.global_drop_hit, this);
this.listeners.push(Y.DD.DDM.on('drop:hit', this.global_drop_hit, this));

// Listen for all drop:miss events.
Y.DD.DDM.on('drag:dropmiss', this.global_drag_dropmiss, this);
this.listeners.push(Y.DD.DDM.on('drag:dropmiss', this.global_drag_dropmiss, this));

// Add keybaord listeners for accessible drag/drop
Y.one(Y.config.doc.body).delegate('key', this.global_keydown,
'down:32, enter, esc', '.' + MOVEICON.cssclass, this);
this.listeners.push(Y.one(Y.config.doc.body).delegate('key', this.global_keydown,
'down:32, enter, esc', '.' + MOVEICON.cssclass, this));

// Make the accessible drag/drop respond to a single click.
Y.one(Y.config.doc.body).delegate('click', this.global_keydown,
'.' + MOVEICON.cssclass , this);
this.listeners.push(Y.one(Y.config.doc.body).delegate('click', this.global_keydown,
'.' + MOVEICON.cssclass , this));
},

/**
* The destructor to shut down the instance of the dragdrop system.
*
* @method destructor
* @protected
*/
destructor: function() {
new Y.EventHandle(this.listeners).detach();
},

/**
Expand Down
Loading

0 comments on commit a321eb0

Please sign in to comment.