5
<title>buttons.js - Ubuntu HTML5 API</title>
6
<link rel="stylesheet" href="http://yui.yahooapis.com/3.8.0pr2/build/cssgrids/cssgrids-min.css">
7
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
8
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
9
<script src="http://yui.yahooapis.com/combo?3.8.0pr2/build/yui/yui-min.js"></script>
11
<body class="yui3-skin-sam">
14
<div id="hd" class="yui3-g header">
15
<div class="yui3-u-3-4">
16
<h1><a href="../index.html"><img src="../assets/css/logo.png">Ubuntu HTML5 API: buttons.js</a></h1>
18
<div class="yui3-u-1-4 version">
19
<em>API Docs for: HTML-14.04-dev~bzr202</em>
24
<div id="sidebar" class="yui3-u">
25
<div id="modules" class="sidebox">
27
<h2 class="no-toc">Modules</h2>
31
<li><a href="../modules/UbuntuUI.html">UbuntuUI</a>
37
<div id="classes" class="sidebox">
39
<h2 class="no-toc">Classes</h2>
43
<li><a href="../classes/UbuntuUI.html">UbuntuUI</a></li>
44
<li><a href="../classes/UbuntuUI.Button.html">UbuntuUI.Button</a></li>
45
<li><a href="../classes/UbuntuUI.Dialog.html">UbuntuUI.Dialog</a></li>
46
<li><a href="../classes/UbuntuUI.Header.html">UbuntuUI.Header</a></li>
47
<li><a href="../classes/UbuntuUI.List.html">UbuntuUI.List</a></li>
48
<li><a href="../classes/UbuntuUI.OptionSelector.html">UbuntuUI.OptionSelector</a></li>
49
<li><a href="../classes/UbuntuUI.Page.html">UbuntuUI.Page</a></li>
50
<li><a href="../classes/UbuntuUI.Pagestack.html">UbuntuUI.Pagestack</a></li>
51
<li><a href="../classes/UbuntuUI.Popover.html">UbuntuUI.Popover</a></li>
52
<li><a href="../classes/UbuntuUI.Progress.html">UbuntuUI.Progress</a></li>
53
<li><a href="../classes/UbuntuUI.Shape.html">UbuntuUI.Shape</a></li>
54
<li><a href="../classes/UbuntuUI.Tab.html">UbuntuUI.Tab</a></li>
55
<li><a href="../classes/UbuntuUI.Tabs.html">UbuntuUI.Tabs</a></li>
56
<li><a href="../classes/UbuntuUI.Toolbar.html">UbuntuUI.Toolbar</a></li>
65
<div id="fileTree" class="sidebox">
67
<h2 class="no-toc">Files</h2>
70
<ul><li>buttons.js/<ul></ul></li><li>core.js/<ul></ul></li><li>dialogs.js/<ul></ul></li><li>fast-buttons.js/<ul></ul></li><li>header.js/<ul></ul></li><li>list.js/<ul></ul></li><li>option-selector.js/<ul></ul></li><li>page.js/<ul></ul></li><li>pagestacks.js/<ul></ul></li><li>popovers.js/<ul></ul></li><li>progress.js/<ul></ul></li><li>shape.js/<ul></ul></li><li>tab.js/<ul></ul></li><li>tabs.js/<ul></ul></li><li>toolbars.js/<ul></ul></li></ul>
76
<div id="main" class="yui3-u">
77
<div class="content"><h4>buttons.js</h4>
79
<pre class="code prettyprint linenums">
81
* Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
82
* License granted by Canonical Limited
84
* This file is part of ubuntu-html5-ui-toolkit.
86
* This package is free software; you can redistribute it and/or modify
87
* it under the terms of the GNU Lesser General Public License as
88
* published by the Free Software Foundation; either version 3 of the
90
* (at your option) any later version.
92
* This package is distributed in the hope that it will be useful,
93
* but WITHOUT ANY WARRANTY; without even the implied warranty of
94
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95
* GNU General Public License for more details.
97
* You should have received a copy of the GNU Lesser General Public
98
* License along with this program. If not, see
99
* <http://www.gnu.org/licenses/>.
105
Note the Ubuntu CSS style classes: <em>positive</em>, <em>information</em>, <em>secondary</em>, and <em>negative</em>
109
* @namespace UbuntuUI
111
<button data-role="button" id="buttonID">text</button>
114
var button = UI.button("buttonID");
116
var Button = function (id) {
122
* Associate a function with the button's Click event
124
* @param {Function} callback - The function to execute on click
126
UI.button("buttonid").click(function(){
127
console.log("clicked");
130
click: function (callback) {
131
if ( ! document.getElementById(this.id)) {
132
throw "Invalid button ID: " + String(this.id);
134
new FastButton(document.getElementById(this.id), callback);
137
* Returns the DOM element associated with the id this widget is bind to.
139
* @return {DOMElement}
141
var mybutton = UI.button("buttonid").element();
143
element: function() {
144
return document.getElementById(this.id);
154
<script src="../assets/vendor/prettify/prettify-min.js"></script>
155
<script>prettyPrint();</script>
156
<script src="../assets/js/yui-prettify.js"></script>
157
<script src="../assets/js/tabs.js"></script>