Skip to content

Commit

Permalink
Merge branch 'master' into koenpunt-chosen-destroy
Browse files Browse the repository at this point in the history
Conflicts:
	coffee/chosen.jquery.coffee
  • Loading branch information
pfiller committed Jul 24, 2013
2 parents 2985704 + 6638dd7 commit 165de1b
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 61 deletions.
4 changes: 4 additions & 0 deletions chosen.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
{
"name": "Ken Earley",
"url": "https://github.com/kenearley"
},
{
"name": "Koen Punt",
"url": "https://github.com/koenpunt"
}
],
"download": "https://github.com/harvesthq/chosen/releases",
Expand Down
14 changes: 7 additions & 7 deletions coffee/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Chosen extends AbstractChosen
if @is_multiple
@container.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>'
else
@container.html '<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
@container.html '<a class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'

@form_field_jq.hide().after @container
@dropdown = @container.find('div.chzn-drop').first()
Expand Down Expand Up @@ -246,10 +246,10 @@ class Chosen extends AbstractChosen


set_tab_index: (el) ->
if @form_field_jq.attr "tabindex"
ti = @form_field_jq.attr "tabindex"
@form_field_jq.attr "tabindex", -1
@search_field.attr "tabindex", ti
if @form_field.tabIndex
ti = @form_field.tabIndex
@form_field.tabIndex = -1
@search_field[0].tabIndex = ti

set_label_behavior: ->
@form_field_label = @form_field_jq.parents("label") # first check for a parent label
Expand Down Expand Up @@ -287,7 +287,7 @@ class Chosen extends AbstractChosen
if item.disabled
choice.addClass 'search-choice-disabled'
else
close_link = $('<a />', { href: '#', class: 'search-choice-close', rel: item.array_index })
close_link = $('<a />', { class: 'search-choice-close', 'data-option-array-index': item.array_index })
close_link.bind 'click.chosen', (evt) => this.choice_destroy_link_click(evt)
choice.append close_link

Expand All @@ -299,7 +299,7 @@ class Chosen extends AbstractChosen
this.choice_destroy $(evt.target) unless @is_disabled

choice_destroy: (link) ->
if this.result_deselect (link.attr "rel")
if this.result_deselect( link[0].getAttribute("data-option-array-index") )
this.show_search_field_default()

this.results_hide() if @is_multiple and this.choices_count() > 0 and @search_field.val().length < 1
Expand Down
2 changes: 1 addition & 1 deletion coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class @Chosen extends AbstractChosen
super()

# HTML Templates
@single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
@single_temp = new Template('<a class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>')
@no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')

Expand Down
6 changes: 5 additions & 1 deletion coffee/lib/abstract-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ class AbstractChosen

@browser_is_supported: ->
if window.navigator.appName == "Microsoft Internet Explorer"
return null isnt document.documentMode >= 8
return document.documentMode >= 8
if /iP(od|hone)/i.test(window.navigator.userAgent)
return false
if /Android/i.test(window.navigator.userAgent)
return false if /Mobile/i.test(window.navigator.userAgent)
return true

@default_multiple_text: "Select Some Options"
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
{
"name": "Ken Earley",
"url": "https://github.com/kenearley"
},
{
"name": "Koen Punt",
"url": "https://github.com/koenpunt"
}
],
"download": "https://github.com/harvesthq/chosen/releases",
Expand Down
17 changes: 15 additions & 2 deletions public/docsupport/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav,

blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ""; content: none; }
ins { background-color: #ff9; color: #000; text-decoration: none; }
ins { background-color: #ff9; color: #000; text-decoration: none; }
mark { background-color: #ff9; color: #000; font-style: italic; font-weight: bold; }
del { text-decoration: line-through; }
abbr[title], dfn[title] { border-bottom: 1px dotted; cursor: help; }
Expand Down Expand Up @@ -133,7 +133,7 @@ strong { font-weight: bold; }
border: 0;
margin-top: -10px;
display: block;
height: 58px;
height: 58px;
background: #F36C00 url(oss-credit.png) no-repeat 20px 22px;
padding: 22px 20px 12px 20px;
text-indent: 120%; /* stupid padding */
Expand Down Expand Up @@ -186,3 +186,16 @@ strong { font-weight: bold; }
font-size: 12px;
padding: 2px 4px;
}

.anchor {
color: inherit;
position: relative;
}

.anchor:hover {
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSI3Ij48ZyBmaWxsPSIjNDE0MDQyIj48cGF0aCBkPSJNOS44IDdoLS45bC0uOS0uMWMtLjctLjMtMS40LS43LTEuOC0xLjMtLjItLjEtLjMtLjMtLjMtLjVsLS4zLS40Yy0uMS0uNC0uMi0uOC0uMi0xLjIgMC0uNC4xLS44LjItMS4yaDEuN2MtLjMuNC0uNC44LS40IDEuMiAwIC40LjEuOC4zIDEuMS4xLjIuMi4zLjQuNC4xLjEuMi4yLjQuMy4zLjIuNy4zIDEgLjNoMy40YzEuMiAwIDIuMi0uOSAyLjItMi4xcy0xLTIuMS0yLjItMi4xaC0xLjRjLS4zLS42LS43LTEtMS4yLTEuNGgyLjZjMiAwIDMuNiAxLjYgMy42IDMuNXMtMS42IDMuNS0zLjYgMy41aC0yLjZ6TTguNCAyYy0uMS0uMS0uMi0uMy0uNC0uMy0uMy0uMi0uNy0uMy0xLS4zaC0zLjRjLTEuMiAwLTIuMi45LTIuMiAyLjEgMCAxLjIgMSAyLjEgMi4yIDIuMWgxLjRjLjMuNS43IDEgMS4yIDEuNGgtMi42Yy0yIDAtMy42LTEuNi0zLjYtMy41czEuNi0zLjUgMy42LTMuNWgzLjUwMDAwMDAwMDAwMDAwMDRsLjkuMWMuNy4yIDEuNC43IDEuOCAxLjMuMS4xLjIuMy4zLjUuMS4xLjIuMy4yLjUuMS40LjIuOC4yIDEuMiAwIC40LS4xLjgtLjIgMS4yaC0xLjZjLjMtLjUuNC0uOS40LTEuM3MtLjEtLjgtLjMtMS4xYy0uMS0uMi0uMi0uMy0uNC0uNHoiLz48L2c+PC9zdmc+) 0 50% no-repeat;
background-size: 21px 9px;
margin-left: -27px;
padding-left: 27px;
text-decoration: none;
}
50 changes: 25 additions & 25 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1>Chosen</h1>
<a class="button" href="https://github.com/harvesthq/chosen/blob/master/contributing.md">Contribute</a>
</p>

<h2>Standard Select</h2>
<h2><a name="standard-select" class="anchor" href="#standard-select">Standard Select</a></h2>
<div class="side-by-side clearfix">
<div>
<em>Turns This</em>
Expand Down Expand Up @@ -544,7 +544,7 @@ <h2>Standard Select</h2>
</div>
</div>

<h2>Multiple Select</h2>
<h2><a name="multiple-select" class="anchor" href="#multiple-select">Multiple Select</a></h2>
<div class="side-by-side clearfix">
<div>
<em>Turns This</em>
Expand Down Expand Up @@ -1062,7 +1062,7 @@ <h2>Multiple Select</h2>
</div>
</div>

<h2>&lt;optgroup&gt; Support</h2>
<h2><a name="optgroup-support" class="anchor" href="#optgroup-support">&lt;optgroup&gt; Support</a></h2>
<div class="side-by-side clearfix">
<div>
<em>Single Select with Groups</em>
Expand Down Expand Up @@ -1174,7 +1174,7 @@ <h2>&lt;optgroup&gt; Support</h2>
</div>
</div>

<h2>Selected and Disabled Support</h2>
<h2><a name="selected-and-disabled-support" class="anchor" href="#selected-and-disabled-support">Selected and Disabled Support</a></h2>
<div class="side-by-side clearfix">
<p>Chosen automatically highlights selected options and removes disabled options.</p>
<div>
Expand Down Expand Up @@ -1207,7 +1207,7 @@ <h2>Selected and Disabled Support</h2>
</div>
</div>

<h2>Hide Search on Single Select</h2>
<h2><a name="hide-search-on-single-select" class="anchor" href="#hide-search-on-single-select">Hide Search on Single Select</a></h2>
<div class="side-by-side clearfix">
<p>The disable_search_threshold option can be specified to hide the search input on single selects if there are fewer than (n) options.</p>
<pre><code class="language-javascript">$(".chzn-select").chosen({disable_search_threshold: 10});</code></pre>
Expand All @@ -1228,14 +1228,14 @@ <h2>Hide Search on Single Select</h2>
</div>
</div>

<h2>Default Text Support</h2>
<h2><a name="default-text-support" class="anchor" href="#default-text-support">Default Text Support</a></h2>
<div class="side-by-side clearfix">
<p>Chosen automatically sets the default field text ("Choose a country...") by reading the select element's data-placeholder value. If no data-placeholder value is present, it will default to "Select an Option" or "Select Some Options" depending on whether the select is single or multiple. You can change these elements in the plugin js file as you see fit.</p>
<pre><code class="language-markup">&lt;select <strong>data-placeholder="Choose a country..."</strong> style="width:350px;" multiple class="chzn-select"&gt;</code></pre>
<p><strong>Note:</strong> on single selects, the first element is assumed to be selected by the browser. To take advantage of the default text support, you will need to include a blank option as the first element of your select list.</p>
</div>

<h2>No Results Text Support</h2>
<h2><a name="no-results-text-support" class="anchor" href="#no-results-text-support">No Results Text Support</a></h2>
<div class="side-by-side clearfix">
<p>Setting the "No results" search text is as easy as passing an option when you create Chosen:</p>
<pre><code class="language-javascript"> $(".chzn-select").chosen({no_results_text: "Oops, nothing found!"}); </code></pre>
Expand Down Expand Up @@ -1270,15 +1270,15 @@ <h2>No Results Text Support</h2>
</div>
</div>

<h2>Limit Selected Options in Multiselect</h2>
<h2><a name="limit-selected-options-in-multiselect" class="anchor" href="#limit-selected-options-in-multiselect">Limit Selected Options in Multiselect</a></h2>
<div class="side-by-side clearfix">
<p>You can easily limit how many options the user can select:</p>
<pre><code class="language-javascript">$(".chzn-select").chosen({max_selected_options: 5});</code></pre>
<p>If you try to select another option with limit reached <code class="language-javascript">liszt:maxselected</code> event is triggered:</p>
<pre><code class="language-javascript"> $(".chzn-select").bind("liszt:maxselected", function () { ... }); </code></pre>
</div>

<h2>Allow Deselect on Single Selects</h2>
<h2><a name="allow-deselect-on-single-selects" class="anchor" href="#allow-deselect-on-single-selects">Allow Deselect on Single Selects</a></h2>
<div class="side-by-side clearfix">
<p>When a single select box isn't a required field, you can set <code class="language-javascript">allow_single_deselect: true</code> and Chosen will add a UI element for option deselection. This will only work if the first option has blank text.</p>
<div class="side-by-side clearfix">
Expand All @@ -1296,7 +1296,7 @@ <h2>Allow Deselect on Single Selects</h2>
</div>
</div>

<h2>Right to Left Support</h2>
<h2><a name="right-to-left-support" class="anchor" href="#right-to-left-support">Right to Left Support</a></h2>
<div class="side-by-side clearfix">
<p>Chosen supports right to left select boxes too. just add <code class="language-javascript">"chzn-rtl"</code> in addition to <code class="language-javascript">"chzn-select"</code> to your select tags and you are good to go.</p>
<pre><code class="language-markup">&lt;select class="chzn-select <strong>chzn-rtl</strong>"&gt;</code></pre>
Expand Down Expand Up @@ -1326,7 +1326,7 @@ <h2>Right to Left Support</h2>
</div>
</div>

<h2>Change / Update Events</h2>
<h2><a name="change-update-events" class="anchor" href="#change-update-events">Change / Update Events</a></h2>
<div class="side-by-side clearfix">
<ul>
<li>
Expand All @@ -1342,7 +1342,7 @@ <h3>Updating Chosen Dynamically</h3>
</ul>
</div>

<h2>Custom Width Support</h2>
<h2><a name="custom-width-support" class="anchor" href="#custom-width-support">Custom Width Support</a></h2>
<div class="side-by-side clearfix">
<p>Using a custom width with Chosen is as easy as passing an option when you create Chosen:</p>
<pre><code class="language-javascript"> $(".chzn-select").chosen({width: "95%"}); </code></pre>
Expand Down Expand Up @@ -1376,7 +1376,7 @@ <h2>Custom Width Support</h2>
</div>
</div>

<h2>Labels work, too</h2>
<h2><a name="labels-work-too" class="anchor" href="#labels-work-too">Labels work, too</a></h2>
<div class="side-by-side clearfix">
<p>Use labels just like you would a standard select</p>
<p></p>
Expand Down Expand Up @@ -1410,45 +1410,45 @@ <h2>Labels work, too</h2>
</div>
</div>

<h2>Setup</h2>
<h2><a name="setup" class="anchor" href="#setup">Setup</a></h2>
<p>Using Chosen is easy as can be.</p>
<ol>
<li><a href="https://github.com/harvesthq/chosen/releases">Download</a> the plugin and copy the chosen files to your app.</li>
<li>Activate the plugin on the select boxes of your choice: <code class="language-javascript">$(".chzn-select").chosen()</code></li>
<li><a href="http://www.youtube.com/watch?feature=player_detailpage&v=UkSPUDpe0U8#t=11s">Disco</a>.</li>
</ol>

<h2>FAQs</h2>
<h2><a name="faqs" class="anchor" href="#faqs">FAQs</a></h2>
<ul class="faqs">
<li>
<h3>Do you have all the available options documented somewhere?</h3>
<p>Yes! You can find them on <a href="options.html">the options page</a>.</p>
</li>
<li>
<h3>Something doesn't work. Can you fix it?</h3>
<p>Yes! Please report all issues using the <a href="https://github.com/harvesthq/chosen/issues">GitHub issue tracking tool</a>. Please include the plugin version (jQuery or Prototype), browser and OS. The more information provided, the easier it is to fix a problem.</p>
<h3>Something doesn't work. Can you fix it?</h3>
<p>Yes! Please report all issues using the <a href="https://github.com/harvesthq/chosen/issues">GitHub issue tracking tool</a>. Please include the plugin version (jQuery or Prototype), browser and OS. The more information provided, the easier it is to fix a problem.</p>
</li>
<li>
<h3>What browsers are supported?</h3>
<p>All modern browsers are supported (Firefox, Chrome, Safari and IE9). Legacy support for IE8 is also enabled.</p>
<h3>What browsers are supported?</h3>
<p>All modern browsers are supported (Firefox, Chrome, Safari and IE9). Legacy support for IE8 is also enabled.</p>
</li>
<li>
<h3>Didn't there used to be a Prototype version of Chosen?</h3>
<p><a href="index.proto.html">There still is!</a></p>
</li>
</ul>

<h2>Credits</h2>
<h2><a name="credits" class="anchor" href="#credits">Credits</a></h2>

<ul class="credits">
<li>Concept and development by <a href="http://patrickfiller.com">Patrick Filler</a> for <a href="https://getharvest.com">Harvest</a>.</li>
<li>Design and CSS by <a href="http://matthewlettini.com">Matthew Lettini</a>.</li>
<li>Repository maintained by <a href="https://github.com/pfiller">@pfiller</a>, <a href="https://github.com/kenearley">@kenearley</a>, and <a href="https://github.com/stof">@stof</a>.</li>
<li>Chosen includes <a href="https://github.com/harvesthq/chosen/contributors">contributions by many fine folks</a>.</li>
<li>Concept and development by <a href="http://patrickfiller.com">Patrick Filler</a> for <a href="https://getharvest.com">Harvest</a>.</li>
<li>Design and CSS by <a href="http://matthewlettini.com">Matthew Lettini</a>.</li>
<li>Repository maintained by <a href="https://github.com/pfiller">@pfiller</a>, <a href="https://github.com/kenearley">@kenearley</a>, <a href="https://github.com/stof">@stof</a> and <a href="https://github.com/koenpunt">@koenpunt</a>.</li>
<li>Chosen includes <a href="https://github.com/harvesthq/chosen/contributors">contributions by many fine folks</a>.</li>
</ul>

<footer>
&copy; 2011 <a href="http://www.getharvest.com/">Harvest</a> - Chosen is licensed under the <a href="http://en.wikipedia.org/wiki/MIT_License">MIT license</a>.
&copy; 2011&ndash;2013 <a href="http://www.getharvest.com/">Harvest</a>. Chosen is licensed under the <a href="https://github.com/harvesthq/chosen/blob/master/LICENSE.md">MIT license</a>.
</footer>

</div>
Expand Down
Loading

0 comments on commit 165de1b

Please sign in to comment.