Permalink
Browse files

*Added Grigory Zarubin to credits

*tidied whitespace
*updated minified version
*updated jquery version to 1.7
*updated version number
  • Loading branch information...
1 parent 1ec9930 commit ff69f8eaa713581b46303a0a4c40961e948f7430 @scottdarby committed Feb 29, 2012
Showing with 65 additions and 62 deletions.
  1. +20 −20 index.html
  2. +36 −35 jquery.stylish-select.js
  3. +8 −6 jquery.stylish-select.min.js
  4. +1 −1 stylish-select.css
View
@@ -1,11 +1,11 @@
<!DOCTYPE html>
<html>
<head>
- <title>jQuery Stylish Select 0.4.8 plugin examples</title>
+ <title>jQuery Stylish Select 0.4.9 plugin examples</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="stylish-select.css" />
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="jquery.stylish-select.js" type="text/javascript"></script>
<script type="text/javascript">
@@ -46,7 +46,7 @@
</head>
<body>
<form action="" method="post">
- <h1>Stylish Select 0.4.8</h1>
+ <h1>Stylish Select 0.4.9</h1>
<h2>A cross-browser, accessible alternative to the standard form element which can be fully customised with CSS</h2>
<p>Stylish Select attempts to replicate the functionality of the browser default select box as closely as possible with support for keyboard navigation, and intelligent positioning.</p>
<p>Stylish Select aims to have a minimal code footprint and weighs in at just over 3KB when minified.</p>
@@ -56,7 +56,7 @@
<p>The plugin can be used to replace any select with the following:</p>
<pre class="brush: javascript">
$(document).ready(function(){
- $('#my-dropdown').sSelect();
+$('#my-dropdown').sSelect();
});
</pre>
<div class="selCont">
@@ -65,7 +65,7 @@
<select id="my-dropdown" name="my-dropdown">
<option value="1">A cappella</option>
<option value="test">Acid Jazz</option>
- <option value="3" selected="selected">Big Band</option>
+ <option value="3">Big Band</option>
<option value="4">Big Beat</option>
<option value="5">Cakewalk</option>
<option value="6">Calenda</option>
@@ -106,7 +106,7 @@
<optgroup label="A Tribe Called Quest">
<option value="5">People's Instinctive Travels and the Paths of Rhythm</option>
<option value="6">The Low End Theory</option>
- <option selected="7" value="mercedes">Midnight Marauders</option>
+ <option selected="selected" value="7">Midnight Marauders</option>
<option value="8">Beats, Rhymes and Life</option>
<option value="9">The Love Movement</option>
</optgroup>
@@ -117,12 +117,12 @@
<pre class="brush: javascript">
//set value
$('#setVal').click(function(){
- $('#my-dropdown5').getSetSSValue(4);
+$('#my-dropdown5').getSetSSValue(4);
});
//get value
$('#getVal').click(function(){
- alert('The value is: '+$('#my-dropdown5').getSetSSValue());
+alert('The value is: '+$('#my-dropdown5').getSetSSValue());
});
</pre>
<p><a id="setVal" href="javascript:void(0)">Set value to 4</a></p>
@@ -142,7 +142,7 @@
<pre class="brush: javascript">
//add options to select and update
$('#addOptions').click(function(){
- $('#my-dropdown6').append('&lt;option value="newOpt">New Option&lt;/option&gt;').resetSS();
+$('#my-dropdown6').append('&lt;option value="newOpt">New Option&lt;/option&gt;').resetSS();
});
</pre>
<p>If you add or remove options from the initial select element on the page, be sure to call the .resetSS() method on the select to update the Stylish Select replacement.</p>
@@ -161,7 +161,7 @@
<option value="7">Adipiscing</option>
</select>
</div>
- <div id="update" class="selCont">
+ <div class="selCont">
<h2>Max-height for large lists</h2>
<pre class="brush: javascript">
$('#my-dropdown').sSelect({ddMaxHeight: '300px'});
@@ -274,21 +274,21 @@
<div class="selCont">
<h2>Disabled Select</h2>
<select disabled="disabled" id="my-dropdown7" name="my-dropdown">
- <option value="1">Opiate</option>
- <option value="2">Undertow</option>
- <option value="3">Aenima</option>
- <option value="4">Lateralus</option>
- <option value="9">The Love Movement</option>
+ <option value="1">Opiate</option>
+ <option value="2">Undertow</option>
+ <option value="3">Aenima</option>
+ <option value="4">Lateralus</option>
+ <option value="9">The Love Movement</option>
</select>
</div>
<div class="selCont">
<h2>Disabled Options</h2>
<select id="my-dropdown8" name="my-dropdown">
- <option value="1">Opiate</option>
- <option disabled="disabled" value="2">Undertow</option>
- <option value="3">Aenima</option>
- <option selected="selected" value="4">Lateralus</option>
- <option value="9">The Love Movement</option>
+ <option value="1">Opiate</option>
+ <option disabled="disabled" value="2">Undertow</option>
+ <option value="3">Aenima</option>
+ <option selected="selected" value="4">Lateralus</option>
+ <option value="9">The Love Movement</option>
</select>
</div>
<div class="selCont">
View
@@ -1,10 +1,12 @@
/**
-* Stylish Select 0.4.8 - jQuery plugin to replace a select drop down box with a stylable unordered list
+* Stylish Select 0.4.9 - jQuery plugin to replace a select drop down box with a stylable unordered list
* http://github.com/scottdarby/Stylish-Select
*
* Requires: jQuery 1.3 or newer
*
-* Contributions from Justin Beasley: http://www.harvest.org/ Anatoly Ressin: http://www.artazor.lv/ Wilfred Hughes: https://github.com/Wilfred
+* Contributions from Justin Beasley: http://www.harvest.org/
+* Anatoly Ressin: http://www.artazor.lv/ Wilfred Hughes: https://github.com/Wilfred
+* Grigory Zarubin: https://github.com/Craigy-
*
* Dual licensed under the MIT and GPL licenses.
*/
@@ -61,10 +63,10 @@
//added by Justin Beasley
resetSS: function(){
var oldOpts = $(this).data('ssOpts');
- $this = $(this);
- $this.next().remove();
- //unbind all events and redraw
- $this.unbind('.sSelect').sSelect(oldOpts);
+ $this = $(this);
+ $this.next().remove();
+ //unbind all events and redraw
+ $this.unbind('.sSelect').sSelect(oldOpts);
}
});
@@ -79,17 +81,17 @@
//initial variables
var opts = $.extend(defaults, options),
- $input = $(this),
- $containerDivText = $('<div class="selectedTxt"></div>'),
- $containerDiv = $('<div class="newListSelected ' + opts.containerClass + ($input.is(':disabled') ? 'newListDisabled' : '') + '"></div>'),
- $containerDivWrapper = $('<div class="SSContainerDivWrapper" style="visibility:hidden;"></div>'),
- $newUl = $('<ul class="newList"></ul>'),
- currentIndex = -1,
- prevIndex = -1,
- keys = [],
- prevKey = false,
- prevented = false,
- $newLi;
+ $input = $(this),
+ $containerDivText = $('<div class="selectedTxt"></div>'),
+ $containerDiv = $('<div class="newListSelected ' + opts.containerClass + ($input.is(':disabled') ? 'newListDisabled' : '') + '"></div>'),
+ $containerDivWrapper = $('<div class="SSContainerDivWrapper" style="visibility:hidden;"></div>'),
+ $newUl = $('<ul class="newList"></ul>'),
+ currentIndex = -1,
+ prevIndex = -1,
+ keys = [],
+ prevKey = false,
+ prevented = false,
+ $newLi;
//added by Justin Beasley
$(this).data('ssOpts',options);
@@ -112,9 +114,9 @@
//add one item to list
function addItem(item, container) {
- var option = $(item).text();
- var key = $(item).val();
- var isDisabled = $(item).is(':disabled');
+ var option = $(item).text(),
+ key = $(item).val(),
+ isDisabled = $(item).is(':disabled');
if (!isDisabled && !$(item).parents().is(':disabled')) {
//add first letter of each word to array
@@ -134,14 +136,15 @@
$optGroup = $('<li class="newListOptionTitle ' + ($(this).is(':disabled') ? 'newListOptionDisabled' : '') + '">'+optionTitle+'</li>'),
$optGroupList = $('<ul></ul>');
- $optGroup.appendTo($newUl);
- $optGroupList.appendTo($optGroup);
+ $optGroup.appendTo($newUl);
+ $optGroupList.appendTo($optGroup);
- $(this).children().each(function(){
- addItem(this, $optGroupList);
- });
+ $(this).children().each(function(){
+ addItem(this, $optGroupList);
+ });
}
});
+
//cache list items object
$newLi = $newUl.find('li a:not(.newListItemDisabled)').not(function(){
return $(this).parents().hasClass('newListOptionDisabled');
@@ -155,12 +158,10 @@
}
});
-
//get heights of new elements for use later
var newUlHeight = $newUl.height(),
- containerHeight = $containerDiv.height(),
- newLiLength = $newLi.length;
-
+ containerHeight = $containerDiv.height(),
+ newLiLength = $newLi.length;
//check if a value is selected
if (currentIndex != -1){
@@ -173,8 +174,8 @@
//decide if to place the new list above or below the drop-down
function newUlPos(){
var containerPosY = $containerDiv.offset().top,
- docHeight = $(window).height(),
- scrollTop = $(window).scrollTop();
+ docHeight = $(window).height(),
+ scrollTop = $(window).scrollTop();
//if height of list is greater then max height, set list height to max height value
if (newUlHeight > parseInt(opts.ddMaxHeight)){
@@ -332,8 +333,8 @@
return false;
}
var $currentOpt = $targetInput.find(':selected');
- currentIndex = $targetInput.find('option').index($currentOpt);
- navigateList(currentIndex);
+ currentIndex = $targetInput.find('option').index($currentOpt);
+ navigateList(currentIndex);
});
//handle up and down keys
@@ -450,8 +451,8 @@
//select next form element in document
function nextFormElement() {
- var fields = $('body').find('button,input,textarea,select');
- var index = fields.index($input);
+ var fields = $('body').find('button,input,textarea,select'),
+ index = fields.index($input);
if (index > -1 && (index + 1) < fields.length) {
fields.eq(index + 1).focus();
}
Oops, something went wrong.

0 comments on commit ff69f8e

Please sign in to comment.