Permalink
Browse files

Merge pull request #32 from rwldrn/trackevent-invariant

Update Plugin API docs to include up-to-date docs for Track Invariant
  • Loading branch information...
2 parents 0247ebb + e844c26 commit ae344c08165a6b6ae202ddc93528acfe68aa30a0 @dseif dseif committed Dec 21, 2012
Showing with 186 additions and 72 deletions.
  1. +186 −72 addon-development/_posts/2012-12-12-plugins.md
@@ -32,18 +32,73 @@ Popcorn also offers a plugin factory. Popcorn plugins are a way for developers t
{% highlight js linenos %}
// Pattern 1
// Provide a function that returns an object
- (function (Popcorn) {
+ (function( Popcorn ) {
Popcorn.plugin( "pluginName" , function( options ) {
// do stuff
// this refers to the popcorn object
// You are required to return an object
// with a start and end property
return {
- start: function(){...},
- end: function(){...},
- frame: function(){...},
- toString: function(){...}
+ _setup: function( track ) {
+ // setup code, fire on initialization
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ _update: function( track ) {
+ // update code, fire on update/modification of a plugin created track event.
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ _teardown: function( track ) {
+ // teardown code, fire on removal of plugin or destruction of instance
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ start: function( event, track ) {
+ // fire on track.start
+
+ // |event| refers to the event object
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ end: function( event, track ) {
+ // fire on track.end
+
+ // |event| refers to the event object
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ frame: function( event, track ) {
+ // when frameAnimation is enabled, fire on every frame between start and end
+
+ // |event| refers to the event object
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ toString: function() {
+ // provide a custom toString method for each plugin
+ // defaults to return start, end, id, and target
+ // this refers to the popcorn object
+ }
};
});
})(Popcorn);
@@ -52,81 +107,140 @@ Popcorn also offers a plugin factory. Popcorn plugins are a way for developers t
// Pattern 2
// Provide an object
// Popcorn will manage the events
- (function (Popcorn) {
+ (function( Popcorn ) {
Popcorn.plugin( "pluginName" , {
- _setup : function( options ) {
- // setup code, fire on initialization
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
+ _setup: function( track ) {
+ // setup code, fire on initialization
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
},
- start: function( event, options ){
- // fire on options.start
- // event refers to the event object
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
+ _update: function( track ) {
+ // update code, fire on update/modification of a plugin created track event.
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ _teardown: function( track ) {
+ // teardown code, fire on removal of plugin or destruction of instance
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ start: function( event, track ) {
+ // fire on track.start
+
+ // |event| refers to the event object
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
},
- end: function( event, options ){
- // fire on options.end
- // event refers to the event object
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
+ end: function( event, track ) {
+ // fire on track.end
+
+ // |event| refers to the event object
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
},
- frame: function( event, options ) {
- // when frameAnimation is enabled, fire on every frame between start and end
- // event refers to the event object
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
+ frame: function( event, track ) {
+ // when frameAnimation is enabled, fire on every frame between start and end
+
+ // |event| refers to the event object
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
},
- toString: function( event, options ) {
- // provide a custom toString method for each plugin
- // defaults to return start, end, id, and target
- // event refers to the event object
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
- }
+ toString: function() {
+ // provide a custom toString method for each plugin
+ // defaults to return start, end, id, and target
+ // this refers to the popcorn object
+ }
});
})(Popcorn);
// Pattern 3
// Provide an object with a plugin wide name space
// Popcorn will manage the events
- (function (Popcorn) {
- Popcorn.plugin( "pluginName", (function(){
-
+ (function( Popcorn ) {
+ Popcorn.plugin( "pluginName", (function() {
+
// Define plugin wide variables out here
-
+
return {
- _setup : function( options ) {
- // setup code, fire on initialization
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
+ _setup: function( track ) {
+ // setup code, fire on initialization
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ _update: function( track ) {
+ // update code, fire on update/modification of a plugin created track event.
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
},
- start: function( event, options ){
- // fire on options.start
- // event refers to the event object
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
+ _teardown: function( track ) {
+ // teardown code, fire on removal of plugin or destruction of instance
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
},
- end: function( event, options ){
- // fire on options.end
- // event refers to the event object
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
+ start: function( event, track ) {
+ // fire on track.start
+
+ // |event| refers to the event object
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
},
- frame: function( event, options ) {
- // when frameAnimation is enabled, fire on every frame between start and end
- // event refers to the event object
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
+ end: function( event, track ) {
+ // fire on track.end
+
+ // |event| refers to the event object
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
},
- toString: function( event, options ) {
- // provide a custom toString method for each plugin
- // defaults to return start, end, id, and target
- // event refers to the event object
- // options refers to the options passed into the plugin on init
- // this refers to the popcorn object
- }
+ frame: function( event, track ) {
+ // when frameAnimation is enabled, fire on every frame between start and end
+
+ // |event| refers to the event object
+
+ // |track| refers to the TrackEvent created by the options passed
+ // into the plugin on init
+
+ // this refers to the popcorn object
+ },
+ toString: function() {
+ // provide a custom toString method for each plugin
+ // defaults to return start, end, id, and target
+ // this refers to the popcorn object
+ }
+ };
})();
})(Popcorn);
{% endhighlight %}
@@ -139,29 +253,29 @@ Butter, popcorn’s point and click authoring tool offers plugin authors a turnk
// Pattern 3
// Provide a plugin manifest with your plugin
// This allows for butter to register your plugin
- (function (Popcorn) {
- Popcorn.plugin( "pluginName", (function(){
-
+ (function( Popcorn ) {
+ Popcorn.plugin( "pluginName", (function() {
+
// Define plugin wide variables out here
-
+
return {
// Define a manifest for the butter authoring tool to use
manifest: {
// Plugin meta data
// will be used in the butter ui
- about:{
+ about: {
name: "name of plugin",
version: "semantic version",
author: "author name",
website: "author url"
},
// Object representation of the plugin options
// a form will be constructed against this object
- options:{
- start : {elem:'input', type:'text', label:'In'},
- end : {elem:'input', type:'text', label:'Out'},
- target : 'id-selector',
- text : {elem:'input', type:'text', label:'Text'}
+ options: {
+ start: { elem: "input", type: "text", label: "In" },
+ end: { elem: "input", type: "text", label: "Out" },
+ target: "id-selector",
+ text: { elem: "input", type: "text", label: "Text" }
}
},
_setup: function( options ){...},

0 comments on commit ae344c0

Please sign in to comment.