{"id":7033,"date":"2014-03-13T20:49:22","date_gmt":"2014-03-14T03:49:22","guid":{"rendered":"http:\/\/blog.mozilla.org\/addons\/?p=7033"},"modified":"2014-03-18T14:03:58","modified_gmt":"2014-03-18T21:03:58","slug":"new-add-on-sdk-australis-ui-features-in-firefox-29","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/","title":{"rendered":"New Add-on SDK Australis UI features in Firefox 29"},"content":{"rendered":"<p><strong>Update: the ability to attach a panel to a button, and the ability to include buttons in toolbars, are not included in Firefox 29 (the current Beta release). Both these features are in Firefox 30 (the current Aurora release). Note that it is still possible to add frames to toolbars in Firefox 29.<\/strong><\/p>\n<hr\/>\n<p>With Australis entering Beta, I&#8217;m pleased to introduce four new APIs for building your add-on&#8217;s user interface: the <a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/SDK\/Low-Level_APIs\/ui_button_action\" rel=\"noreferrer\">action button<\/a>, the <a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/SDK\/Low-Level_APIs\/ui_button_toggle\" rel=\"noreferrer\">toggle button<\/a>, the <a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/SDK\/Low-Level_APIs\/ui_toolbar\" rel=\"noreferrer\">toolbar<\/a>, and the <a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/SDK\/Low-Level_APIs\/ui_frame\" rel=\"noreferrer\">frame<\/a>.<\/p>\n<h3>Buttons, buttons everywhere<\/h3>\n<p>First up, we have two APIs for adding buttons to Firefox: <strong>action buttons<\/strong> and <strong>toggle buttons<\/strong>.<\/p>\n<p>You give action buttons an icon, a label, and a click handler:<\/p>\n<pre lang=\"javascript\">var ui = require(\"sdk\/ui\");\r\n\r\nvar action_button = ui.ActionButton({\r\n\u00a0 id: \"my-button\",\r\n\u00a0 label: \"Action Button!\",\r\n\u00a0 icon: \".\/icon.png\",\r\n\u00a0 onClick: function(state) {\r\n\u00a0\u00a0\u00a0 console.log(\"You clicked '\" + state.label + \"'\");\r\n\u00a0 }\r\n});<\/pre>\n<p>Unless you add them to a toolbar of your own, they appear in the toolbar at the top right of the browser window:<\/p>\n<p><a href=\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-7050 aligncenter\" alt=\"action-button-toolbar\" src=\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar.png\" width=\"381\" height=\"201\" srcset=\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar.png 381w, https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar-252x132.png 252w\" sizes=\"(max-width: 381px) 100vw, 381px\" \/><\/a><\/p>\n<p>Toggle buttons are just the same, except they&#8217;re meant to represent an on\/off state, like a checkbox. So they have a &#8220;checked&#8221; property which is toggled when the user clicks the button, and the icon gets a &#8220;pressed&#8221; look when the button is checked:<\/p>\n<pre lang=\"javascript\">var ui = require(\"sdk\/ui\");\r\n\r\nvar toggle_button = ui.ToggleButton({\r\n  id: \"my-button\",\r\n  label: \"my button\",\r\n  icon: \".\/icon.png\",\r\n  onChange: function(state) {\r\n    console.log(state.label + \" checked state: \" + state.checked);\r\n  }\r\n});<\/pre>\n<p>You can also <a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/SDK\/High-Level_APIs\/panel#Attaching_panels_to_buttons\" rel=\"noreferrer\">attach panels to toggle buttons<\/a>, by passing the button into the panel&#8217;s constructor or its <code>show()<\/code> method.<\/p>\n<p><a href=\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/panel-attach.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-7051 aligncenter\" alt=\"panel-attach\" src=\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/panel-attach.png\" width=\"413\" height=\"343\" srcset=\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/panel-attach.png 413w, https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/panel-attach-252x209.png 252w\" sizes=\"(max-width: 413px) 100vw, 413px\" \/><\/a><\/p>\n<h3>Toolbars and frames<\/h3>\n<p>The toolbar API lets you create more complex persistent user interfaces. You can add buttons to a toolbar, and can also add frames, which are essentially iframes with message passing between page scripts and your main add-on code. You create a frame by specifying the local HTML content to load into it.<\/p>\n<p>Here&#8217;s an example that defines a toolbar with a single frame and three action buttons:<\/p>\n<pre lang=\"javascript\">var ui = require('sdk\/ui');\r\n\r\nvar previous = ui.ActionButton({\r\n\u00a0 id: \"previous\",\r\n\u00a0 label: \"previous\",\r\n\u00a0 icon: \".\/icons\/16-back.png\"\r\n});\r\n\r\nvar next = ui.ActionButton({\r\n\u00a0 id: \"next\",\r\n\u00a0 label: \"next\",\r\n\u00a0 icon: \".\/icons\/16-next.png\"\r\n});\r\n\r\nvar play = ui.ActionButton({\r\n\u00a0 id: \"play\",\r\n\u00a0 label: \"play\",\r\n\u00a0 icon: \".\/icons\/16-play.png\"\r\n});\r\n\r\nvar frame = ui.Frame({\r\n\u00a0 url: \".\/frame-player.html\"\r\n});\r\n\r\nvar toolbar = ui.Toolbar({\r\n\u00a0 title: \"Player\",\r\n\u00a0 items: [previous, next, play, frame]\r\n});<\/pre>\n<p>Toolbars occupy a complete strip of the browser window, just above the content window:<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/toolbar2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-7052 aligncenter\" alt=\"toolbar2\" src=\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/toolbar2-620x260.png\" width=\"620\" height=\"260\" srcset=\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/toolbar2-620x260.png 620w, https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/toolbar2-252x105.png 252w, https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/toolbar2.png 852w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<h3>Learning more<\/h3>\n<p>There&#8217;s full reference documentation on all these APIs on <a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/SDK\/High-Level_APIs\/ui\" rel=\"noreferrer\">MDN<\/a>, and I&#8217;ve created an <a href=\"https:\/\/github.com\/canuckistani\/australis-ui\" rel=\"noreferrer\">example add-on<\/a> to check out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: the ability to attach a panel to a button, and the ability to include buttons in toolbars, are not included in Firefox 29 (the current Beta release). Both these &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/\">Read more<\/a><\/p>\n","protected":false},"author":316,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,295,121,588,742],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>New Add-on SDK Australis UI features in Firefox 29  - Mozilla Add-ons Community Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Griffiths\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/\",\"url\":\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/\",\"name\":\"New Add-on SDK Australis UI features in Firefox 29 - Mozilla Add-ons Community Blog\",\"isPartOf\":{\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar.png\",\"datePublished\":\"2014-03-14T03:49:22+00:00\",\"dateModified\":\"2014-03-18T21:03:58+00:00\",\"author\":{\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/e2f4c71eb45392ea29162432c3f1d433\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#primaryimage\",\"url\":\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar.png\",\"contentUrl\":\"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar.png\",\"width\":381,\"height\":201},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.mozilla.org\/addons\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"New Add-on SDK Australis UI features in Firefox 29\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#website\",\"url\":\"https:\/\/blog.mozilla.org\/addons\/\",\"name\":\"Mozilla Add-ons Community Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.mozilla.org\/addons\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/e2f4c71eb45392ea29162432c3f1d433\",\"name\":\"Jeff Griffiths\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b07ae75dd1a5414bf30d7f773ccfc894?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b07ae75dd1a5414bf30d7f773ccfc894?s=96&d=mm&r=g\",\"caption\":\"Jeff Griffiths\"},\"description\":\"Jeff is Product Manager for the Firefox Developer Tools and occasional Open Web hacker, based in Vancouver, BC.\",\"sameAs\":[\"http:\/\/canuckistani.ca\/\",\"https:\/\/x.com\/canuckistani\"],\"url\":\"https:\/\/blog.mozilla.org\/addons\/author\/jgriffithsmozilla-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"New Add-on SDK Australis UI features in Firefox 29  - Mozilla Add-ons Community Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/","twitter_misc":{"Written by":"Jeff Griffiths","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/","url":"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/","name":"New Add-on SDK Australis UI features in Firefox 29 - Mozilla Add-ons Community Blog","isPartOf":{"@id":"https:\/\/blog.mozilla.org\/addons\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#primaryimage"},"image":{"@id":"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar.png","datePublished":"2014-03-14T03:49:22+00:00","dateModified":"2014-03-18T21:03:58+00:00","author":{"@id":"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/e2f4c71eb45392ea29162432c3f1d433"},"breadcrumb":{"@id":"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#primaryimage","url":"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar.png","contentUrl":"https:\/\/blog.mozilla.org\/addons\/files\/2014\/03\/action-button-toolbar.png","width":381,"height":201},{"@type":"BreadcrumbList","@id":"https:\/\/blog.mozilla.org\/addons\/2014\/03\/13\/new-add-on-sdk-australis-ui-features-in-firefox-29\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.mozilla.org\/addons\/"},{"@type":"ListItem","position":2,"name":"New Add-on SDK Australis UI features in Firefox 29"}]},{"@type":"WebSite","@id":"https:\/\/blog.mozilla.org\/addons\/#website","url":"https:\/\/blog.mozilla.org\/addons\/","name":"Mozilla Add-ons Community Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.mozilla.org\/addons\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/e2f4c71eb45392ea29162432c3f1d433","name":"Jeff Griffiths","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b07ae75dd1a5414bf30d7f773ccfc894?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b07ae75dd1a5414bf30d7f773ccfc894?s=96&d=mm&r=g","caption":"Jeff Griffiths"},"description":"Jeff is Product Manager for the Firefox Developer Tools and occasional Open Web hacker, based in Vancouver, BC.","sameAs":["http:\/\/canuckistani.ca\/","https:\/\/x.com\/canuckistani"],"url":"https:\/\/blog.mozilla.org\/addons\/author\/jgriffithsmozilla-com\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/posts\/7033"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/users\/316"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/comments?post=7033"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/posts\/7033\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/media?parent=7033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/categories?post=7033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/tags?post=7033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}