- Loading...
- No images or files uploaded yet.
|
|
Buttons
type: widget release: 0.0 status: in development documentation: url || N/A demo: http://jquery-ui.googlecode.com/svn/branches/labs/button/demo.html
1 - Description:
A standard set of button types that can be used across all widgets. Buttons can be basic (A1), have a menu (A2), a split button which opens a menu only when the right hand arrow is clicked (A3) or toggle buttons (A4) that behave like a radiobutton set where only one can be depressed at once. Buttons in a UI usually have different visual styles to indicate importance (A5) such in a save/cancel dialog and may need to be multiple sizes (A6).
Button content Every button should have a text label, even if it's ultimately displayed as an icon only, by hiding the text label in an accessible way.
Button types There are a range of button primitive types we need to support, each with slightly different functionality and behavior. For each button type below, they can have any of the 4 button content styles above:
Typical use cases - buttons can appear in a wide variety of contexts so we need to ensure that they can easily be added to a lot of places:
Markup, style behavior notes Support the ability to apply a button appearance to any element (div, span) with most emphasis on making this look consistent between links and button elements across browsers Styles for buttons should be carefully coded to render padding, margins, text size and other style attributes consistently across all elements (a, button, div, span) and button types (basic, button, split button, grouped buttons) so buttons of various types can be used together in toolbars and look consistent All buttons by default should have the ui-widget and ui-state-default framework classes by default. Hovering over a button should add the class ui-state-hover and clicking should add the class ui-state-active (then pop back to default if it's not a toggle??). Active state should not have a hover or focus on mouseover. Consider a way to re-map classes and events for touchscreen apps. Since these don't typically support the hover interaction and rely on a strong depressed appearance when clicked for feedback, we could have an option that maps the classes this way: ui-state-default to start, on click/mousedown swap to ui-state-hover then to ui-state-active briefly, then back to ui-state-default (if not a toggle).This might address some developer's concerns about there not being a clicked/depressed state. Consider allowing users to identify buttons that don't use the ui-state-default class for buttons so they just appear as text and/or icons then transition to the ui-state-hover appearance on mouseover. Useful for toolbars and for places where you want a more low-key button style. To provide a shift in emphasis between buttons, the ui-priority-primary class can be applied to make the text weight bold. The ui-priority-secondary class can be added to secondary buttons (cancel) which will set the button opacity to ~80% and the font weight to normal. Other than testing that all button types render well with these additional classes, no other testing or scripting is needed Buttons can be disabled. The ui-state-disabled class should be added to set the opacity to roughly 35% and make it look dimmed. In addition, any mouse and keyboard events must be killed on a disabled button. Tab index too? Buttons should auto-stretch their width to fit the length of their content. A width can optionally be set via CSS, but it is too cumbersome (and breakable) to ask developers to have to set widths on each button Buttons should be coded in ems so they will scale gracefully to fit any length fo content or text size Multiple buttons should be able to sit next to each other in a row and appear in linear order as the code source with minimum developer effort. This can be tricky to accomplish if you also want to have flexible width buttons Consider providing an optional class to make "mini" versions of all our buttons that would simply scale them down by 70-80% across the board for use in places where a more compact size is needed.
Example buttons Filament Group created an article with a core set of CSS framework buttons (not comprehensive to what we want to build for UI but a start) http://www.filamentgroup.com/lab/styling_buttons_and_toolbars_with_the_jquery_ui_css_framework/
Ext JS 3 button examples, very full set of every scenario except button groups: http://extjs.com/deploy/ext-3.0-rc1.1/examples/button/buttons.html
2 - Visual Design:
3 - Functional Specifications/Requirements:
(Detailed descrition of how the script will be structured: defaults, options, architecture, extensibility, etc.) status legends: √ - implemented ± - partially implemented / still some bugs to solve ¤ - currently under devellopment ∅ - todo / not yet implemented x - still thinking / need discussion Options:
Callbacks :
Methods:
Keyboard:
Specificiations:
4 - Markup & Style:
4.1 Initial markup examples
The most typical situation would be to transform a link or button element into a UI button but you should be able to call this on any element.
<button class="ui-button" type="submit">Button</button>
<a href="#" class="ui-button">Link</a>
<span class="ui-button-toggle-small-r-info">toggle button</span>
4.2 Recommended transformed HTML markup
See Filament group article for most basic types. Still need static mockups for the split and menu buttons - anyone want to take a stab at it? There is already menu static markup to start with.
<button class="ui-button ui-widget ui-state-default ui-corner-all" type="submit">Button</button>
<a href="#" class="ui-button ui-state-default ui-corner-all">Link</a>
<span class="ui-button-toggle-small-r-info ui-button ui-widget ui-state-default ui-corner-all ui-button-size-small ui-button-orientation-r">
<span class="ui-button-label">toggle button</span>
<span class="ui-button-icon"><span class="ui-icon ui-icon-info"/></span>/span>
</span>
4.3 Accessibility recommendation
(Detailed recommendations for ARIA, HTML markup, CSS and javascript that will contribute to universal access and full section 508 accessibility for screen readers, mobile devices and any other devices)
4.4 CSS & Theme
(Description of the CSS classes to be used for all states, how custom theming and Themeroller support will work.)
5 - Latest version of plugin:svn repository: http://jquery-ui.googlecode.com/svn/branches/labs/button/
6 - Open issues being discussed(Use this area to place things that we're hashing out like featuresand options we're not sure we should include, questions about how this fits into UI and relates to other widgets and utilities, known problems, whether features should be broken across multiple releases, etc.)
Button elements extra padding: There's still a problem to keep original button elements consistent with other original markup. Most browsers add some extra padding to button elements. We can with some css hack or browser detections achieve a better rendering of the buttons but the problem start to be more complicated when playing with the differents size (tiny,small,normal,big,huge) and original font-size of parent element. It becomes really hard to predict what padding should be used. For now this will be left as is as better rendering on buggy browsers engine will certainly break others rendering engines that does pretty good job (ie: midori, opera), ie6 and ie7 may be the most buggy and still be problematic. So any css hacker that could help on that particular problem is really welcome ;) Input elements replacement I face some trouble with input element replacement, as removing them from the body will automaticly call the destroy widget method. I'm trying at this time to do it by simply hiding them, but this lead to another problem, two elements (original one and replacement one) with the same id. This is not good. Also as said by scott on mailing list, is this a good thing to remove the original element from the document....? I'm not sure about this.
|
Comments (36)
scottjehl said
at 9:43 am on Jun 9, 2009
6. type="button" : I guess if anything, the type attribute should default to either "submit" or just nothing at all. Perhaps we can have an option for other values, such as "reset", but type="button" is meaningless on a <button> element, afaik. Thoughts?
7. Element and attribute conversion: As Todd mentioned earlier, we'd prefer that this plugin supported conversion of buttons that start out as <input type="submit" />. In other words, if you were to call the UI ".button();" method on a <input type="button" This is because button elements have some wacky behavior in many older and mobile browsers and it would be best to qualify their use through progressive enhancement.
When calling this plugin on an input type="submit", we should be sure to transfer the following attributes onto the button element:
- style
- tabindex
- title
- type (for reset, submit)?
- value
- class
- id
- name
- value (becomes the button text content)
- disabled (which should also add the class ui-state-disabled)
- accesskey
- any others??
Again, thanks for all the work you have done so far on this.
Looking forward to your thoughts and feedback on my comments.
Also, please let us know if you would like the design team to work out any markup specs for any button situations.
We're used to making static pages for every plugin being developed, and we'll need these pages made anyway for visual tests later on.
Thanks!
-Scott
David Muir said
at 11:59 pm on Sep 24, 2009
Unless I'm missing something, or missing the point of what you're saying in 6....
type="button" on a button element is not meaningless, but means that the behaviour for the button is undefined (which makes a lot of sense for button sets, as they'd rarely be used for submitting a form). But I suppose if they are buttons, then they're there to allow for graceful degradation, in which case type="submit" makes sense... Is that what you were referring to?
Todd Parker said
at 12:16 pm on Jun 10, 2009
I agree we need to review the naming and events but I think we should probably follow the html 5 spec for buttons:
http://www.w3schools.com/tags/html5_button.asp
Fabian Lau said
at 7:12 pm on Jul 14, 2009
Hi. I've been experimenting with these buttons a bit and I was wondering if there are plans to include an option for transparent backgrounds for buttons in their default state, i.e. without borders and without background. Only when hovering would you see them as buttons. That's an effect I've seen quite often for buttons in headers, for example at
http://www.digg.com.
I've uploaded a small demo here: http://arhiel.blautann.de/dummy/buttondemo/button-test.html
Don't mind the code, I probably broke some other stuff too, but I hope you get the idea. I also tried fading only the background and border colors with fadeTo() or animate() while keeping the text fully visible, but that didn't work out at all, because I've no idea what I'm doing yet or if it's even possible, or what would be the best way to go about it.
Jörn Zaefferer said
at 5:21 pm on Jul 22, 2009
Rest of the above comment (stupid 2000 characters limit):
In terms of code in SVN: the previousAttempts folder should be removed (leave a note somewhere with the revision before the delete, if you must). There should be just one ui.button.js file - if buttonset is actually complex enough to justify its own widget, it needs to be reflected here on the planning page, eg. via a Buttonset widget that builds upon Button.
The alerts need to be removed from the demo in order to actually try out the various behaviours. Replace it with an inline log, if necessary.
Jonathan Gotti said
at 1:48 pm on Jul 23, 2009
Hi all,
First of all i'm sorry if i haven't been so active thoose days, but i want to precise (as most of us here) i'm working with pleasure on jquery-ui only at my spare time. So excuse me again if i wasn't so reactive for some times.
This said i'll will work on comments / documentation here this evening (evening for me right now :)).
Some of the comments and notes inside the specs were left as is as i really think that most of them need discussion. I could have take decision for long time on my own but, i really think and hope not be the one to use that plugin so i really want feedback and advices before making decisions. I'll do my best for cleaning up this page before doing anything else don't hesitate to contact me here, or on the mailing list or even on my personal email to discuss stuffs about that plugin.
I'm glad to see there's interest on that work and promise to do my best to get it done.
Todd Parker said
at 8:10 am on Jul 23, 2009
One small design item on buttons: the grouped buttons in the current demo have double borders because there are buttons sitting right next to each other. It would look a lot better to kill one of the borders so there is only a single pixel separation. For the selected item, it needs to have both left and right borders on so there is a bit of logic needed for determining which border needs to be hidden. We may be able to use negative margins to achieve this effect too.
Jonathan Gotti said
at 1:52 pm on Jul 23, 2009
I Todd.
I'm not totally agree with you. I explain:
Yes visualy a thinner border will look better when all buttons are in the same states. But I really think that when a button is pushed down we must have asides buttons with differents border and no common one between them. It's part of the visual feedback too.
If you think of a way to achieve both of keeping all borders visible and responsive (to mouse over, button push etc..) and make it look prettier i'm on it!
This is only my opinion and if we are more to think that it would be better to have one common border for asides buttons i think it can be done pretty easily, and will do it.
scottjehl said
at 2:18 pm on Jul 23, 2009
I agree with Todd on this.
If a depressed button has only top and bottom borders matching the depressed state, that's probably enough for visual effect. The borders to the left and right of that button should be that of the buttons next to it. If two in a row are depressed, then you'll see a depressed border color between them. The only other time you'll see a vertical border with the depressed color would be if the button is on the end of the row.
I'm not saying this won't be tricky, but I bet a combination of setting border-widths to 0 or 1px, and possibly using negative right or left margins as well, can probably get us there.
Jonathan Gotti said
at 2:30 pm on Jul 23, 2009
Thank's for your so quick feedback :)
What do you think about that: at buttonset render time we simply set the left border of each buttons but the first to 0px.
Do you thinks it may be sufficient.?
Jörn Zaefferer said
at 4:20 pm on Jul 23, 2009
Sounds like the buttonset should override the border style of buttons within them. Combined with an extra class on the first button that keeps the border intact, should be enough.
Jonathan Gotti said
at 1:11 pm on Aug 9, 2009
Trying to play with borders, what do you think if finally there's no border at all separating buttons inside buttonset.
There's still top and bottom borders and focus/hover/click feedback is still good enough.
Jörn Zaefferer said
at 4:21 pm on Jul 27, 2009
Whats the status?
The div/span stuff is still there. The examples don't have any primary/secondary buttons, as in the visual design.
Nice to have the comments cleaned up, as well as the functional specification.
The OverrideDefaultState option is odd - the name doesn't match the naming convention, and I don't get its purpose.
isActive should be changed to "active", acting as both getter and setter. Not sure if toggle is then actually required, probably not.
The setactive callback seems to be only for toggle buttons. How do I handle a click on a normal button? bind("click")?
The class-metadata for icons etc. is odd, too. Assuming the widget-factory supports the metadata plugin (or will in the future), this feature should be removed completely.
Why a corners-option? Other widgets use the corner-classes, too, and the only way to disable rounded corners is by modifying the theme. That works very well.
Scott González said
at 5:51 pm on Jul 27, 2009
isActive should be changed to "active", acting as both getter and setter. Not sure if toggle is then actually required, probably not.
- The existing property from ARIA is pressed with possible values of true, false and mixed.
Jonathan Gotti said
at 1:43 am on Jul 28, 2009
Regarding ARIA property i haven't dive into this, but it's planned i have to set role and so on.
Jonathan Gotti said
at 1:42 am on Jul 28, 2009
hi,
- I thought that div/span was an extra cost for now to remove so have understood that we leave it in place... I think i've misanderstood i'll do that before the end of the week
- overrideDefaultState, i agree with the name not so good name i'm open to any proposition haven't better idea at the time i added it
- active/setActivte... ok will do it by the end of the week too seems good to me.
- regarding click, you can bind it on the orignial element like any other elements as done in the demo.
- for class metadata i really want to keep this feature it's really usefull to me. perhaps may we use it as an option / additional plugin don't know but really want that to be done.
- the corners-option is used by buttonset in fact as in this case only first and last buttons have corners set. If you think of a better way to do so... i'm open for any idea, I don't see a real need other than the one said before for that.
I'm a little overbooked thoose day but will do that before the end of the week.
Jörn Zaefferer said
at 2:48 am on Jul 28, 2009
I still don't know what overrideDefaultState is good for, can you explain that?
Class metdata: Do you have a usecase where that is really necessary and can't be replaced with the metadata plugin? "I like it" isn't enough.
Corners-option: Sounds like this shouldn't be a public option; the buttonset needs to be able to configure that, but not the user. So far the spec doesn't mention a seperation between Button and ButtonSet, so, as those are just one component for the user, there is no need for an option.
Jonathan Gotti said
at 3:02 am on Jul 28, 2009
- overrideDefaultState allow user to replace ui-state-default class by another one or none as it was proposed in the specs earlier.
- class metadata allow to have a single call for button enhancement in the page ( $('.ui-button').button()) and allow user to set most of param in the markup. This is really usefull for us here at work as it make original markup smaller, and less jquery selector calls as we don't have to set buttons one by one in js. This is a really time gain.
- corners option totally agree and regarding buttonset my opinion is that it should be another plugin that work with ui-button (it's the main reason why it's in a separate file at this time) I think it will be time soon to create a new page for that one.
Jörn Zaefferer said
at 10:20 am on Aug 5, 2009
- class metadata has to go away; the jQuery UI way for that is the metadata plugin, that we already support in via $.widget; if you need that for your projects, just add a small project-specific wrapper that implements the class metadata
Jonathan Gotti said
at 12:39 pm on Aug 5, 2009
will have a look to metadata, simply don't know that at this time.
Jörn Zaefferer said
at 10:25 am on Aug 5, 2009
- overrideDefaultState: Can't find what you are referring to, therefore that should be removed, too. I think the idea could be similar to the corner-options, where we agreed that its a matter of the theme, not of adding or removing classes
Jonathan Gotti said
at 12:44 pm on Aug 5, 2009
this was part of the original specification to allow user to override the ui-state-default class name for buttons, (notably to use them inside toolbars)
So nothing to do with the corner options at all, simply added as it was described in the spec, exactly as it was specified that any markup elements should be eligible to be turned into buttons!
In a general way i'm totally agree with the fact that most of css class tweaking must be done at a theme level, and that user should add specific class by adding their own class as elements attribute, not by plugin option. So once again the only reason for this to be supported is that it was part of specifications on that page when i started to code.
Jörn Zaefferer said
at 2:53 pm on Aug 5, 2009
(Can't "Reply" above, too deep...)
When the override is supposed to help with toolbars, then that should be mentioned somewhere, preferably with a visual design or demo. Currently that doesn't exist, so the option isn't useful. I must assume that it was removed for a reason...
The spec doesn't mention anymore that any element can be converted to a button, so, applying one of our core principles, progressive enhancement, that shouldn't be supported at all. As mentioned before, having it implemented right now is not a sufficient reason to keep it, as the cost of maintaining it later is higher then just removing it now.
About the issue with replacing input elements: Hide the original element, but don't copy the id to the new element? In the case of Spinner, the wrapper element gets an id, ala ui-spinner-[source-id], where [source-id] is the id of the input element.
Jonathan Gotti said
at 9:19 am on Aug 9, 2009
specs doesn't mentions thoose stuff anymore as i remove them on my own. There was too many text describing the plugins so i removed part of them when already implemented as i thought that the fact it was implemented and explain further will suffice.
So before the spec cleaning i made some days ago thoose was still on the spec description.
The element replacement still make me inconfortable, what should happen if i have an input type=submit make it a button() and then apply a click() callback to it. It will in many case end in a click attached to an hidden element and so never trigger...
This point still need to be discussed imho to make things work properly for end users, or at least we will have to make this very clear in the plugin documentation that enhance an input to button don't work the same way as with other elements.
Jörn Zaefferer said
at 9:31 am on Aug 9, 2009
Removing stuff from the spec after it was implemented is not going to work. For stuff going to branches/dev and trunk, only implemented features covered by the spec can be accepted.
For the click event: How about a click-callback/option? I see no reason why a native event must be supported for a custom widget.
Jonathan Gotti said
at 9:44 am on Aug 9, 2009
Ok so put back thoose specifications parts. Sorry i've done that cause i wanted to make the specifications more concise (things were still describe in the "functional" part of the spec i thought it was sufficient.
One of the reason for native click to be supported imho is that we deal with such things as submit buttons and that many users may have already bind events on them. I think that make it a button widget (that's purely a visual enhancement) mustn't change the behaviour previously defined. But that's only my own opinion. For me it will clearly be really easyer to just don't deal with thoose events, but i really don't think we want to break users defined behaviours. What do you think about.?
Jonathan Gotti said
at 12:20 pm on Aug 9, 2009
Ok so now classnameoptions is still an external class but isn't required anymore.
If the class exists then you may declare options in class attributes as before, and you can't anymore if you don't have it present.
I haven't switch to metadata as apparently it doesn't do exactly the same thing, but if i'm underestanding correctly metadata it should work with it too without too much problem if someone want to try and report me i'll be glad.
Next step (already working on it) is input elements support and then ARIA roles.
sompylasar said
at 10:53 am on Aug 15, 2009
Little note about borders of button elements in a toolbar on hover (not every border changes it's color).
I've recently made an Excel 2007 skin for tabs where they do overlap (selected tab is in front of other tabs). That is done via CSS applying z-index: 1; to the desired ui-state-* and the element sticks out. Try that with toolbar buttons on hover.
Cork said
at 12:15 pm on Sep 24, 2009
I'm missing ui.buttons as component in the bug tracker, what should i do with bugs I encounter?
Richard D. Worth said
at 12:44 pm on Sep 24, 2009
We don't use Trac for plugins until they're in a release. For something in labs, or branches/dev, like buttons (for now), any or all of:
- add to the wiki page under '6 Open issues being discussed'
- leave a comment on the wiki page
- post to the jquery-ui-dev google groups list: http://groups.google.com/group/jquery-ui-dev
Cork said
at 3:23 am on Sep 25, 2009
Ok, lest run with it then.
The button can end up in funny states if you as response to a click disables it.
That i did in my hackish way was to add:
if( value?true:false ) {
self.element.removeClass('ui-state-focus ui-state-hover ui-state-highlight');
}
to line 263 in ui.buttons.js
On top of that i found that ie8 dropes the opacity set to the <buttons>, so the icon isn't "dimmed"
Todd Parker said
at 8:33 am on Sep 28, 2009
Hi all - I wanted to give a heads up that we're changing direction a bit on the button plugin and wanted to explain why. Recently, the core UI team decided to try and fast track some of the more common plugins (button, menu, etc.) but with the overall approach of designing the most streamlined and minimal implementation that others could extend, re-use and re-mix. Looking at the button page, we noticed that there were more than 10 script options and we wanted to dramatically simplify this to make testing and maintenance easier. We also felt that we could embrace progressive enhancement to a greater extent to allow the actual HTML markup to drive what were originally options.
For example, instead of needing an option for a toggle-style button, we should really use a checkbox in the foundation markup and then have the script enhance it into a button that toggles it's state. If the checkbox's checked attribute is "checked" in the markup, it can be set to active when the plugin initializes. Instead of a disabled plugin
option, we check for the disabled attribute on a button or checkbox and disable the button to match the markup.
One big advantage of this approach is that the html markup is not only highly descriptive (which simplifies scripting options), it is also 100% usable if JS isn't present. For example, a set of divs styles to look like a single-select toggle set of buttons (like a button toggle for viewing by list or grid for example) which is un-usable without
scripts, we can have 2 radiobuttons that more closely represent this interaction in HTML, then transform it into the button toggles when
button() is called on it.
Let us know what you think. We'll be updating the page to reflect the new direction. Jorn has already done some great work on this new plugin here:
http://jquery-ui.googlecode.com/svn/branches/dev/tests/visual/button/default.html
David Muir said
at 7:27 pm on Sep 28, 2009
Please do! It would be horrendously dumb not to go the route of progressive enhancement. I wasn't actually aware that this wasn't the case, and have just started looking at using the button plugin. Jorns work looks quite good.
sompylasar said
at 2:40 pm on Sep 30, 2009
Great enhancement! I totally agree.
ninsky said
at 6:29 am on Oct 30, 2009
Hi guys,
thats a feature request: would be cool if we had a "busy button". So if the button was clicked, the user isn't motivated to submit the form another time, when the page load takes some time. Here's an example i found:
http://www.reise.de/content/images/misc/button_search.gif
http://www.reise.de/content/images/content/lapa/suche-idle.gif
lundgrenj said
at 10:20 am on Nov 17, 2009
I've noticed if the A HREF tag has an onclick event, the onclick event is fired when the button is rendered from the ANCHOR tag. Anybody know why?
You don't have permission to comment on this page.