TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Easily Customizable Toggle Buttons - jQuery Plugin

28 pointsby simontaboralmost 13 years ago

8 comments

alexyoungalmost 13 years ago
When handling options, I quite like this pattern:<p><pre><code> var settings = $.extend({ dragable: true, clickable: true, ontext: 'ON', offtext: 'OFF', on: true, animtime: 300 }, opts); </code></pre> The $.extend method still returns a suitable object even if `opts` is undefined.<p>You also might want to `return this.each` so calls can be chained.<p>All of this is covered here: <a href="http://docs.jquery.com/Plugins/Authoring" rel="nofollow">http://docs.jquery.com/Plugins/Authoring</a>
评论 #4410050 未加载
taitemsalmost 13 years ago
Hey guys, I did something similar but based off the styles of the jQuery UI slider plugin. I found while these types of standalone plugins looked okay, they were frustrating to customise or even to make them look PERFECT.<p>Check it out here: <a href="http://taitems.github.com/UX-Lab/ToggleSwitch/index.html" rel="nofollow">http://taitems.github.com/UX-Lab/ToggleSwitch/index.html</a><p>I also investigated achieving something similar using only CSS base on a :checkbox, but the browser support, even in "modern" browsers was poor: <a href="http://taitems.github.com/UX-Lab/CSSInputs/index.html" rel="nofollow">http://taitems.github.com/UX-Lab/CSSInputs/index.html</a><p>Thoughts and hacks on the above, here: <a href="http://taitems.tumblr.com/post/23099016111/css3-input-styling-a-state-of-the-union-ux-lab-009" rel="nofollow">http://taitems.tumblr.com/post/23099016111/css3-input-stylin...</a>
axiakalmost 13 years ago
This looks great! One minor suggestion: make the toggle button non selectable for dragging. <a href="http://jsfiddle.net/SWqw3/" rel="nofollow">http://jsfiddle.net/SWqw3/</a> show's a basic way of doing this.
评论 #4410060 未加载
creativenamealmost 13 years ago
These look great! Thanks for sharing.<p>One thing - I know the intent is that they can be easily customized, but it might be nice to have smaller options out of the box. I think I've been spoiled by Twitter Bootstrap, though, where they have a few preset sizes. My first thought was that they looked a little large.
评论 #4410003 未加载
tehwebguyalmost 13 years ago
It's nice to see something like this as a jQuery plugin. It would be amazing if they could be adjusted by swiping on mobile!
评论 #4409123 未加载
S_A_Palmost 13 years ago
I like these, but how do you get the "value"? Im not a javascript guru, but is there an attribute or value I need to check?
评论 #4409963 未加载
antiheroalmost 13 years ago
Suggestion - theme for Jelly Bean, then have option to automatically select theme for detected device (Android/iPhone)
munkydungalmost 13 years ago
nice work! what license is this released under?
评论 #4410108 未加载