Skip to content

Commit

Permalink
Flipswitch: Add classes option
Browse files Browse the repository at this point in the history
  • Loading branch information
cgack committed Sep 26, 2014
1 parent cc1f496 commit 1aab38e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 43 deletions.
40 changes: 1 addition & 39 deletions demos/flipswitch/index.php
Expand Up @@ -134,30 +134,6 @@
</form>
</div><!-- /demo-html -->

<h2>Mini</h2>

<div data-demo-html="true">
<form>
<label for="flip-3">Flip toggle switch:</label>
<select name="flip-3" id="flip-3" data-role="flipswitch" data-mini="true">
<option value="off">Off</option>
<option value="on">On</option>
</select>
</form>
</div><!-- /demo-html -->

<h2>No corners</h2>

<div data-demo-html="true">
<form>
<label for="flip-8">Flip toggle switch:</label>
<select name="flip-8" id="flip-8" data-role="flipswitch" data-corners="false">
<option value="off">Off</option>
<option value="on">On</option>
</select>
</form>
</div><!-- /demo-html -->

This comment has been minimized.

Copy link
@arschmitz

arschmitz Sep 26, 2014

We still want the demos for this we just want to show the proper way to set them which is through the classes option

<h2>Disabled</h2>

<div data-demo-html="true">
Expand Down Expand Up @@ -195,21 +171,7 @@
</div>
</form>
</div><!-- /demo-html -->

<h2>Fieldcontain, mini</h2>

<div data-demo-html="true">
<form>
<div class="ui-field-contain">
<label for="flip-7">Flip toggle switch:</label>
<select name="flip-7" id="flip-7" data-role="flipswitch" data-mini="true">
<option value="off">Off</option>
<option value="on">On</option>
</select>
</div>
</form>
</div><!-- /demo-html -->

This comment has been minimized.

Copy link
@arschmitz

arschmitz Sep 26, 2014

Same here as above


</div><!-- /content -->

<?php include( '../jqm-navmenu.php' ); ?>
Expand Down
14 changes: 10 additions & 4 deletions js/widgets/forms/flipswitch.js
Expand Up @@ -21,12 +21,18 @@ $.widget( "mobile.flipswitch", $.extend({
offText: "Off",
theme: null,
enhanced: false,

// Deprecated in 1.5
wrapperClass: null,

// Deprecated in 1.5
corners: true,

// Deprecated in 1.5
mini: false,
classes: {
"ui-flipswitch": "",
"ui-flipswitch-on": "",
"ui-flipswitch": "ui-corner-all ui-shadow-inset ",
"ui-flipswitch-on": "ui-shadow",
"ui-flipswitch-off": "",
"ui-flipswitch-active": "",
"ui-flipswitch-input": ""
Expand Down Expand Up @@ -124,14 +130,14 @@ $.widget( "mobile.flipswitch", $.extend({
options.offText : element.find( "option" ).eq( 0 ).text();

on
.addClass( this._classes( "ui-flipswitch-on" ) + " ui-btn ui-shadow ui-btn-inherit" )
.addClass( this._classes( "ui-flipswitch-on" ) + " ui-btn ui-btn-inherit" )
.text( onText );
off
.addClass( this._classes( "ui-flipswitch-off" ) )
.text( offText );

flipswitch
.addClass( this._classes( "ui-flipswitch" ) + " ui-shadow-inset " +
.addClass( this._classes( "ui-flipswitch" ) +

This comment has been minimized.

Copy link
@arschmitz

arschmitz Sep 26, 2014

We will need some back compat logic here to proxy the deprecated options to the new classes option

"ui-bar-" + theme + " " +
( options.wrapperClass ? options.wrapperClass : "" ) + " " +
( ( element.is( ":checked" ) ||
Expand Down

0 comments on commit 1aab38e

Please sign in to comment.