Labs/Jetpack/JEP/21: Difference between revisions

Jump to navigation Jump to search
 
Line 106: Line 106:


<pre class="brush:js;">
<pre class="brush:js;">
jetpack.toolbar.navigation // get the navBar
jetpack.future.import("toolbar");
var newButton = {id: "fooButton"}; // create obj literal to configure button
jetpack.toolbar.navigation.append(newButton) // append button
jetpack.toolbar.navigation.remove("fooButton"); // remove button


// As well as jetpack.toolbar.bookmarks .append / .remove
// Create button options. This can be done in a separate object like this,
// or passed inline to append.
var myButton = {
  id: "fooButton",
  label: "FOO!",
  tooltip: "Click on my to do something.",
  image: "http://www.mozilla.org/favicon.ico",
  click: function(event) { console.log("FOO! has been clicked") }
}


// Append the button to the toolbar
jetpack.toolbar.navigation.append(myButton);
// Remove the button from the toolbar
jetpack.toolbar.navigation.remove("fooButton");
// Create button options for the bookmarks toolbar.
var myOtherButton = {
  id: "barButton",
  label: "BAR!",
  tooltip: "Go to http://www.mozilla.org",
  image: "http://www.mozilla.org/favicon.ico",
  url: "http://www.mozilla.org"
}
// Append the button to the toolbar
jetpack.toolbar.bookmarks.append(myOtherButton);
// Remove the button from the toolbar
jetpack.toolbar.bookmarks.remove("barButton");
</pre>
</pre>
86

edits

Navigation menu