Labs/Jetpack/Reboot/JEP/110: Difference between revisions

make the set of changes discussed in the forum
(make the set of changes discussed in the forum)
Line 18: Line 18:
tabs is an immutable array of Tab objects
tabs is an immutable array of Tab objects
**/
**/
tabs = require("tabs");
tabs = require("tabs").tabs;
 
When the following methods are called, the "this" of the method is the tab in question.
 
/**
A method called when a tab is shown.
@param event {Event} the event
**/
tabs.onShow(event)


/**
/**
  These are global callbacks that come into affect when
  A method called when a tab is hidden.
any of these happen to any tab.
  @param event {Event} the event
  @param eventName {string}
        Is one of focus, blur, close, open, load, domready, mozafterpaint,
        move
@param callback {function}
        The function gets passed an "event" object and the the "this" of
        that function is the tab in question.
**/
**/
tabs.bind( eventName, callback );
tabs.onHide(event)


/**
/**
  Unbinds the event handler
  A method called when a tab is opened.
Without any arguments, all bound events are removed. You can also unbind
  @param event {Event} the event
custom events registered with bind. If the type is provided, all bound
events of that type are removed. If the function that was passed to bind is
provided as the second argument, only that specific event handler is  
removed.
  @param [eventName] {string}
@param [func] {function}
**/
**/
tabs.unbind( eventName, func );
tabs.onOpen(event)


/**
/**
  This causes an event to occur or a message to be sent to all tabs.
  A method called when a tab is closed.
  @param eventName {string}
  @param event {Event} the event
        The event to trigger. For now this is only "open"
@param data {string|object}
        In the case of open this is the URL, if this is a dictionary
        then otherData won't be needed.
@param [otherData] {object}
        Other data to be passed to the event handler.
**/
**/
tabs.trigger( eventName, data, otherData )
tabs.onClose(event)
 
/**
A method called when a tab's content is loaded.
@param event {Event} the event
**/
tabs.onLoad(event)
 
/**
A method called when a tab's content is ready.
@param event {Event} the event
**/
tabs.onDOMReady(event)
 
/**
A method called when a tab's content has been painted.
@param event {Event} the event
**/
tabs.onMozAfterPaint(event)
 
/**
Open a new tab.
@param url {URL} the URL to load in the tab; optional;
        if not provided, about:blank will be loaded in the tab
@param window {Window} the window in which to open the tab;
        optional; if not provided, the tab will be opened
        in the most recent application window
**/
tabs.open(url, window)


/**
/**
Line 67: Line 85:


/**
/**
  Same as for tabs, but effects the particular tab in question.
  A method called when the tab is shown.
@param event {Event} the event
**/
**/
tab.bind( eventName, callback )
tab.onShow(event)


/**
/**
  Same as for tabs, but effects the particular tab in question.
  A method called when the tab is hidden.
@param event {Event} the event
**/
**/
tab.unbind( eventName, callback )
tab.onHide(event)


/**
/**
  Mostly the same as for the tabs case, the only difference being:
  A method called when the tab is closed.
  @param eventName {string}
  @param event {Event} the event
        Is one of focus, close, load, move
**/
**/
tab.trigger( eventName, data, otherData )
tab.onClose(event)
 
/**
A method called when the tab's content is loaded.
@param event {Event} the event
**/
tab.onLoad(event)
 
/**
A method called when the tab's content is ready.
@param event {Event} the event
**/
tab.onDOMReady(event)
 
/**
A method called when the tab's content has been painted.
@param event {Event} the event
**/
tab.onPaint(event)
 
/**
Make this the active tab.
**/
tab.activate()
 
/**
Close the tab.
**/
tab.close()
 
/**
Load a URL in the tab.
@param url {URL} the URL to load in the tab
**/
tab.load(url)
 
/**
Move the tab to a new location in the tab set.
@param index {Number} the new location in the tab set
@param window {Window}
        the new window; optional if moving to a new location
        within the existing window
**/
tab.move(index, window)


/**
/**
Line 95: Line 157:
  @prop contentWindow {window}
  @prop contentWindow {window}
  @prop [ownerWindow] {jetpack window} The window the tab belongs to
  @prop [ownerWindow] {jetpack window} The window the tab belongs to
  @prop [thumbnail] {canvas} A thumbnail of the currently displayed page  
  @prop [thumbnail] {canvas} A thumbnail of the currently displayed page
@prop onShow {Function} event handler to call when a tab is activated
@prop onHide {Function} event handler to call when a tab is deactivated
**/
**/
tab.property
tab.property


</pre>
== Sugar Functions ==
<pre class="brush:js">
// Sugar for tabs.on functionality
tabs.onFocus( function )
tabs.onBlur( function )
tabs.onClose( function )
tabs.onOpen( function )
tabs.onLoad( function )
tabs.onDomReady( function )
...
// and the same for each Tab instance.
// Sugar for tabs.trigger functionality
tabs.open( url, options )
...
// And the same for each Tab instance, plus
tab.move( index, options )
// index = absolute index, "+3"/"-1" for relative
// options for moving to other windows
</pre>
</pre>


canmove, Confirmed users
2,056

edits