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
50 changes: 25 additions & 25 deletions jquery.fs.selecter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Selecter v3.2.3 - 2014-10-24
* A jQuery plugin for replacing default select elements. Part of the Formstone Library.
* http://formstone.it/selecter/
*
* Copyright 2014 Ben Plum; MIT Licensed
*/

/*
* Selecter v3.2.3 - 2014-10-24
* A jQuery plugin for replacing default select elements. Part of the Formstone Library.
* http://formstone.it/selecter/
*
* Copyright 2014 Ben Plum; MIT Licensed
*/
;(function ($, window) {
"use strict";

Expand Down Expand Up @@ -221,31 +221,31 @@

if (opts.external) {
opts.links = true;
}

// Grab true original index, only if selected attribute exits
var $originalOption = $select.find("[selected]").not(":disabled"),
originalOptionIndex = $select.find("option").index($originalOption);
}
// Grab true original index, only if selected attribute exits
var $originalOption = $select.find("[selected]").not(":disabled"),
originalOptionIndex = $select.find("option").index($originalOption);

if (!opts.multiple && opts.label !== "") {
$select.prepend('<option value="" class="selecter-placeholder" selected>' + opts.label + '</option>');
if (originalOptionIndex > -1) {
originalOptionIndex++;
$select.prepend('<option value="" class="selecter-placeholder" selected>' + opts.label + '</option>');
if (originalOptionIndex > -1) {
originalOptionIndex++;
}
} else {
opts.label = "";
}

// Build options array
var $allOptions = $select.find("option, optgroup"),
$options = $allOptions.filter("option");

// If we didn't actually have a selected elemtn
if (!$originalOption.length) {
$originalOption = $options.eq(0);
}

// Determine original item
$options = $allOptions.filter("option");
// If we didn't actually have a selected elemtn
if (!$originalOption.length) {
$originalOption = $options.eq(0);
}
// Determine original item
var originalIndex = (originalOptionIndex > -1) ? originalOptionIndex : 0,
originalLabel = (opts.label !== "") ? opts.label : $originalOption.text(),
wrapperTag = "div";
Expand Down Expand Up @@ -526,7 +526,7 @@
e.preventDefault();
e.stopPropagation();

if ($(e.currentTarget).parents(".selecter").length === 0) {
if ($(e.currentTarget).closest(".selecter").length === 0) {
_onClose(e);
}
}
Expand Down
Loading