Forked from DougPuchalski/gist:328763e1de3cb08bc0b8
Last active
August 29, 2015 14:17
-
-
Save joshlevinson/1f451a039e357fad2fc6 to your computer and use it in GitHub Desktop.
Revisions
-
aceofspades revised this gist
Feb 2, 2015 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,9 +51,8 @@ export default Ember.Mixin.create({ }, // Trigger action explicitly delegateAction(actionName, ...contexts) { 'use strict'; Ember.Logger.debug("delegateAction", actionName, contexts); this.triggerAction({ action: actionName, -
aceofspades revised this gist
Feb 2, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,18 +33,18 @@ export default Ember.Mixin.create({ if (!this._actions || !this._actions[actionName]) { if (this.get('delegateAllActions')) { // Delegate all actions Ember.Logger.debug(`Action delegated implicitly by ${this.toString()}:`, actionName); return this.delegateAction.apply(this, arguments); } else { Ember.Logger.warn(`Actions not delegated by ${this.toString()}:`, actionName); } var delegatedActions = this.get('_delegatedActions'); if (delegatedActions.contains(actionName) && this.sendAction) { Ember.Logger.info(`Action delegated by ${this.toString()}:`, actionName); return this.delegateAction.apply(this, arguments); } else { Ember.Logger.warn(`Action not delegated by ${this.toString()}:`, actionName); } } return this._super.apply(this, arguments); -
aceofspades created this gist
Feb 2, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ /* jshint esnext: true */ import Ember from 'ember'; // When mixed into an Ember.Component class, actions can be explicitly or implicitly delegated to the parent. // In general this makes the most sense for an app-level component, where actions are not mututated as they bubble // up to higher levels. export default Ember.Mixin.create({ // When true, all actions will be implicitly passed on to the parent delegateAllActions: false, // Explicitly delegated actions // example: delegatedActions: ['select', 'show', 'edit', 'destroy'] // May also be declared a as a comma-separated attribute in your template // Example: {{my-component delegatedActions="select,show,edit"}} delegatedActions: [], _delegatedActions: Ember.computed('delegatedActions', function() { 'use strict'; var delegatedActions = this.get('delegatedActions'); if (typeof(delegatedActions) === 'string') { return delegatedActions.split(',').map(s => s.trim()); } else { return delegatedActions; } }), // Override send to call delegatedActions as appropriate // If an action handler is defined, event will not be delegated send(actionName) { 'use strict'; if (!this._actions || !this._actions[actionName]) { if (this.get('delegateAllActions')) { // Delegate all actions Ember.Logger.debug("Action delegated implicitly by #{this.toString()}:", actionName); return this.delegateAction.apply(this, arguments); } else { Ember.Logger.warn("Actions not delegated by #{this.toString()}:", actionName); } var delegatedActions = this.get('_delegatedActions'); if (delegatedActions.contains(actionName) && this.sendAction) { Ember.Logger.info("Action delegated by #{this.toString()}:", actionName); return this.delegateAction.apply(this, arguments); } else { Ember.Logger.warn("Action not delegated by #{this.toString()}:", actionName); } } return this._super.apply(this, arguments); }, // Trigger action explicitly delegateAction(actionName) { 'use strict'; var contexts = Array.prototype.slice.call(arguments, 1); Ember.Logger.debug("delegateAction", actionName, contexts); this.triggerAction({ action: actionName, actionContext: contexts }); return; } });