Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<!-- Le jquery switch-->
<link href="jquery.switch/jquery.switch.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="jquery.switch/jquery.switch.min.js"></script>
<script type="text/javascript" src="jquery.switch/jquery.switch.js"></script>

<script>
$(function() {
Expand Down Expand Up @@ -105,14 +105,6 @@ <h1>
</header>

<section>
<div class="row">
<div class="span16">
<iframe style="width: 100%; height: 600px; border: solid 1px black;" src="http://jsfiddle.net/6twenty/3Uw2s/" frameborder="0"></iframe>
</div>
<div class="span16">
<p><a href="http://jsfiddle.net/6twenty/3Uw2s/" target="_blank">Go to this fiddle</a></p>
</div>
</div><!-- /row -->

<div class="page-header" style="margin-top:50px;">
<h1>Demos <small>cut to the chase</small></h1>
Expand Down Expand Up @@ -141,16 +133,16 @@ <h3>The code <small>the defaults</small></h3>
<div class="span4">
<h3>Custom values/labels</h3>
<select class="example-2">
<option value="a">True</option>
<option value="b">False</option>
<option value="a">Option one</option>
<option value="b">Option two</option>
</select>
</div>

<div class="span12">
<h3>The code <small>custom values/labels</small></h3>
<pre class="prettyprint linenums">&lt;select&gt;
&lt;option value="a"&gt;True&lt;/option&gt;
&lt;option value="b"&gt;False&lt;/option&gt;
&lt;option value="a"&gt;Option one&lt;/option&gt;
&lt;option value="b"&gt;Option two&lt;/option&gt;
&lt;/select&gt;</pre>
<pre class="prettyprint linenums">$('select').switchify();</pre>
</div>
Expand Down
95 changes: 15 additions & 80 deletions jquery.switch/jquery.switch.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
.ui-switch {
display: inline-block;
border: solid 1px #777;
position: relative;
cursor: pointer;
font-family: Helvetica, Arial, sans-serif;

-moz-border-radius: 18px;
-webkit-border-radius: 18px;
border-radius: 18px;

}

.ui-switch:focus {
Expand All @@ -25,15 +21,11 @@
}

.ui-switch-middle {
height: 20px; width: 60px;
border: solid 7px white;
height: 34px;
width: 60px;
position: relative;
margin-top: -34px;
z-index: 100;

-moz-border-radius: 17px;
-webkit-border-radius: 17px;
border-radius: 17px;
}

.ui-switch-mask {
Expand All @@ -57,15 +49,13 @@

.ui-switch-handle {
display: block;
height: 30px; width: 30px;
height: 25px;
width: 25px;
position: absolute;
top: -4px; left: -15px;
background: url(jquery.switch.png);
background: #fff;
background-size: 30px 30px;

-moz-border-radius: 15px;
-webkit-border-radius: 15px;
border-radius: 15px;
border: 1px solid #000;
}

.ui-switch-.disabled .ui-switch-handle:after {
Expand All @@ -75,16 +65,7 @@
top: 0; left: 0;
height: 30px; width: 30px;
background: white;

-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; /* IE 8 */
filter: alpha(opacity=50); /* IE 5-7 */
-moz-opacity: 0.5; /* Mozilla */
-khtml-opacity: 0.5; /* Safari 1.x */
opacity: 0.5; /* Good browsers */

-moz-border-radius: 15px;
-webkit-border-radius: 15px;
border-radius: 15px;

}

.ui-switch-lower {
Expand All @@ -105,82 +86,32 @@
line-height: 18px;
font-size: 12px;
color: white;
background: green;
padding: 0 10px;
border: solid 1px black;
text-align: center;
font-weight: bold;
text-decoration: none;

text-shadow: 0 1px 1px rgba(0,0,0,0.5);

-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
white-space: nowrap;
}

.ui-switch-on {
border-right: none;
border-color: #006600;
padding-right: 20px;

-moz-border-radius-topright: 0;
-moz-border-radius-bottomright: 0;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-right-radius: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;

background: #0b9a15; /* Old browsers */
background: -moz-linear-gradient(top, #0b9a15 0%, #167309 2%, #1e9a0e 10%, #20a20f 12%, #23aa11 17%, #3ec52c 93%, #3dbe2c 98%, #0b9a15 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0b9a15), color-stop(2%,#167309), color-stop(10%,#1e9a0e), color-stop(12%,#20a20f), color-stop(17%,#23aa11), color-stop(93%,#3ec52c), color-stop(98%,#3dbe2c), color-stop(100%,#0b9a15)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0b9a15 0%,#167309 2%,#1e9a0e 10%,#20a20f 12%,#23aa11 17%,#3ec52c 93%,#3dbe2c 98%,#0b9a15 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0b9a15 0%,#167309 2%,#1e9a0e 10%,#20a20f 12%,#23aa11 17%,#3ec52c 93%,#3dbe2c 98%,#0b9a15 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0b9a15 0%,#167309 2%,#1e9a0e 10%,#20a20f 12%,#23aa11 17%,#3ec52c 93%,#3dbe2c 98%,#0b9a15 100%); /* IE10+ */
background: linear-gradient(top, #0b9a15 0%,#167309 2%,#1e9a0e 10%,#20a20f 12%,#23aa11 17%,#3ec52c 93%,#3dbe2c 98%,#0b9a15 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0b9a15', endColorstr='#0b9a15',GradientType=0 ); /* IE6-9 */
background: green;
}

.ui-switch-off {
border-left: none;
border-color: #660000;
padding-left: 20px;

-moz-border-radius-topleft: 0;
-moz-border-radius-bottomleft: 0;
-webkit-border-top-left-radius: 0;
-webkit-border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;

background: #9c1010; /* Old browsers */
background: -moz-linear-gradient(top, #9c1010 0%, #750a0a 2%, #850d0d 5%, #9c1010 10%, #a51111 12%, #ae1313 17%, #c92f2f 93%, #c72e2e 98%, #9c1010 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#9c1010), color-stop(2%,#750a0a), color-stop(5%,#850d0d), color-stop(10%,#9c1010), color-stop(12%,#a51111), color-stop(17%,#ae1313), color-stop(93%,#c92f2f), color-stop(98%,#c72e2e), color-stop(100%,#9c1010)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #9c1010 0%,#750a0a 2%,#850d0d 5%,#9c1010 10%,#a51111 12%,#ae1313 17%,#c92f2f 93%,#c72e2e 98%,#9c1010 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #9c1010 0%,#750a0a 2%,#850d0d 5%,#9c1010 10%,#a51111 12%,#ae1313 17%,#c92f2f 93%,#c72e2e 98%,#9c1010 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #9c1010 0%,#750a0a 2%,#850d0d 5%,#9c1010 10%,#a51111 12%,#ae1313 17%,#c92f2f 93%,#c72e2e 98%,#9c1010 100%); /* IE10+ */
background: linear-gradient(top, #9c1010 0%,#750a0a 2%,#850d0d 5%,#9c1010 10%,#a51111 12%,#ae1313 17%,#c92f2f 93%,#c72e2e 98%,#9c1010 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9c1010', endColorstr='#9c1010',GradientType=0 ); /* IE6-9 */
background: red;
}

.ui-switch.disabled .ui-switch-on,
.ui-switch.disabled .ui-switch-off {
border-color: #333;

-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; /* IE 8 */
filter: alpha(opacity=50); /* IE 5-7 */
-moz-opacity: 0.5; /* Mozilla */
-khtml-opacity: 0.5; /* Safari 1.x */
opacity: 0.5; /* Good browsers */

background: #525252; /* Old browsers */
background: -moz-linear-gradient(top, #525252 0%, #3e3e3e 2%, #545454 10%, #5d5d5d 17%, #787878 90%, #757575 98%, #525252 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#525252), color-stop(2%,#3e3e3e), color-stop(10%,#545454), color-stop(17%,#5d5d5d), color-stop(90%,#787878), color-stop(98%,#757575), color-stop(100%,#525252)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #525252 0%,#3e3e3e 2%,#545454 10%,#5d5d5d 17%,#787878 90%,#757575 98%,#525252 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #525252 0%,#3e3e3e 2%,#545454 10%,#5d5d5d 17%,#787878 90%,#757575 98%,#525252 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #525252 0%,#3e3e3e 2%,#545454 10%,#5d5d5d 17%,#787878 90%,#757575 98%,#525252 100%); /* IE10+ */
background: linear-gradient(top, #525252 0%,#3e3e3e 2%,#545454 10%,#5d5d5d 17%,#787878 90%,#757575 98%,#525252 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#525252', endColorstr='#525252',GradientType=0 ); /* IE6-9 */
}

.ui-switch-on:hover,
Expand All @@ -194,4 +125,8 @@
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
}

.ui-switch-width {
width: 54px;
}
7 changes: 4 additions & 3 deletions jquery.switch/jquery.switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</div> \n\
</div> \n\
<div class="ui-switch-middle"></div> \n\
<div class="ui-switch-width"></div> \n\
</div>';

// helpers to indicate when the mouse button
Expand Down Expand Up @@ -76,8 +77,8 @@
on: options.on || opts.first().val(),
off: options.off || opts.last().val()
}, text = {
on: opts.filter('[value=' + values.on + ']').text(),
off: opts.filter('[value=' + values.off + ']').text()
on: opts.filter('[value="' + values.on + '"]').text(),
off: opts.filter('[value="' + values.off + '"]').text()
};

// assign the <select>'s val as a class on the switch
Expand All @@ -99,7 +100,7 @@
labelMaxWidth = Math.max(linkWidths[0], linkWidths[1]);

// adjust the switch widths
$switch.find('.ui-switch-middle').width(labelMaxWidth + 43);
$switch.find('.ui-switch-middle').width(labelMaxWidth + $switch.find('.ui-switch-width').width());
$switch.find('a').width(labelMaxWidth);

// cache the "off" and "on" positions
Expand Down