Skip to content

Commit

Permalink
copy to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyjhol committed Nov 19, 2016
1 parent 06edd8a commit ca596d8
Show file tree
Hide file tree
Showing 70 changed files with 319 additions and 256 deletions.
8 changes: 4 additions & 4 deletions docs/docs/dist/css/bootstrap-select.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/docs/dist/css/bootstrap-select.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/dist/css/bootstrap-select.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

189 changes: 101 additions & 88 deletions docs/docs/dist/js/bootstrap-select.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Bootstrap-select v1.11.2 (http://silviomoreto.github.io/bootstrap-select)
* Bootstrap-select v1.12.0 (http://silviomoreto.github.io/bootstrap-select)
*
* Copyright 2013-2016 bootstrap-select
* Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
Expand All @@ -11,13 +11,13 @@
define(["jquery"], function (a0) {
return (factory(a0));
});
} else if (typeof exports === 'object') {
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("jquery"));
} else {
factory(jQuery);
factory(root["jQuery"]);
}
}(this, function (jQuery) {

Expand Down Expand Up @@ -243,29 +243,48 @@
{re: /[\xF1]/g, ch: "n"}
];
$.each(rExps, function () {
text = text.replace(this.re, this.ch);
text = text ? text.replace(this.re, this.ch) : '';
});
return text;
}


function htmlEscape(html) {
var escapeMap = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'`': '&#x60;'
// List of HTML entities for escaping.
var escapeMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'`': '&#x60;'
};

var unescapeMap = {
'&amp;': '&',
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
'&#x27;': "'",
'&#x60;': '`'
};

// Functions for escaping and unescaping strings to/from HTML interpolation.
var createEscaper = function(map) {
var escaper = function(match) {
return map[match];
};
var source = '(?:' + Object.keys(escapeMap).join('|') + ')',
testRegexp = new RegExp(source),
replaceRegexp = new RegExp(source, 'g'),
string = html == null ? '' : '' + html;
return testRegexp.test(string) ? string.replace(replaceRegexp, function (match) {
return escapeMap[match];
}) : string;
}
// Regexes for identifying a key that needs to be escaped.
var source = '(?:' + Object.keys(map).join('|') + ')';
var testRegexp = RegExp(source);
var replaceRegexp = RegExp(source, 'g');
return function(string) {
string = string == null ? '' : '' + string;
return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
};
};

var htmlEscape = createEscaper(escapeMap);
var htmlUnescape = createEscaper(unescapeMap);

var Selectpicker = function (element, options, e) {
// bootstrap-select has been initialized - revert valHooks.select.set back to its original function
Expand All @@ -292,6 +311,12 @@
this.options.title = this.$element.attr('title');
}

// Format window padding
var winPad = this.options.windowPadding;
if (typeof winPad === 'number') {
this.options.windowPadding = [winPad, winPad, winPad, winPad];
}

//Expose public methods
this.val = Selectpicker.prototype.val;
this.render = Selectpicker.prototype.render;
Expand All @@ -307,7 +332,7 @@
this.init();
};

Selectpicker.VERSION = '1.11.2';
Selectpicker.VERSION = '1.12.0';

// part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both.
Selectpicker.DEFAULTS = {
Expand Down Expand Up @@ -354,7 +379,8 @@
maxOptions: false,
mobile: false,
selectOnTab: false,
dropdownAlignRight: false
dropdownAlignRight: false,
windowPadding: 0
};

Selectpicker.prototype = {
Expand Down Expand Up @@ -516,17 +542,11 @@
},

reloadLi: function () {
//Remove all children.
this.destroyLi();
//Re build
// rebuild
var li = this.createLi();
this.$menuInner[0].innerHTML = li;
},

destroyLi: function () {
this.$menu.find('li').remove();
},

createLi: function () {
var that = this,
_li = [],
Expand Down Expand Up @@ -560,8 +580,8 @@
var generateA = function (text, classes, inline, tokens) {
return '<a tabindex="0"' +
(typeof classes !== 'undefined' ? ' class="' + classes + '"' : '') +
(typeof inline !== 'undefined' ? ' style="' + inline + '"' : '') +
(that.options.liveSearchNormalize ? ' data-normalized-text="' + normalizeToBase(htmlEscape(text)) + '"' : '') +
(inline ? ' style="' + inline + '"' : '') +
(that.options.liveSearchNormalize ? ' data-normalized-text="' + normalizeToBase(htmlEscape($(text).html())) + '"' : '') +
(typeof tokens !== 'undefined' || tokens !== null ? ' data-tokens="' + tokens + '"' : '') +
' role="option">' + text +
'<span class="' + that.options.iconBase + ' ' + that.options.tickIcon + ' check-mark"></span>' +
Expand All @@ -577,7 +597,7 @@
// Use native JS to prepend option (faster)
var element = this.$element[0];
titleOption.className = 'bs-title-option';
titleOption.appendChild(document.createTextNode(this.options.title));
titleOption.innerHTML = this.options.title;
titleOption.value = '';
element.insertBefore(titleOption, element.firstChild);
// Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option.
Expand Down Expand Up @@ -646,7 +666,7 @@
labelSubtext = typeof $parent.data('subtext') !== 'undefined' ? '<small class="text-muted">' + $parent.data('subtext') + '</small>' : '',
labelIcon = $parent.data('icon') ? '<span class="' + that.options.iconBase + ' ' + $parent.data('icon') + '"></span> ' : '';

label = labelIcon + '<span class="text">' + label + labelSubtext + '</span>';
label = labelIcon + '<span class="text">' + htmlEscape(label) + labelSubtext + '</span>';

if (index !== 0 && _li.length > 0) { // Is it NOT the first option of the select && are there elements in the dropdown?
liIndex++;
Expand Down Expand Up @@ -754,7 +774,7 @@
if (typeof $this.attr('title') !== 'undefined') {
return $this.attr('title');
} else if ($this.data('content') && that.options.showContent) {
return $this.data('content');
return $this.data('content').toString();
} else {
return icon + $this.html() + subtext;
}
Expand Down Expand Up @@ -789,8 +809,8 @@
title = typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText;
}

//strip all html-tags and trim the result
this.$button.attr('title', $.trim(title.replace(/<[^>]*>?/g, '')));
//strip all HTML tags and trim the result, then unescape any escaped tags
this.$button.attr('title', htmlUnescape($.trim(title.replace(/<[^>]*>?/g, ''))));
this.$button.children('.filter-option').html(title);

this.$element.trigger('rendered.bs.select');
Expand Down Expand Up @@ -944,10 +964,13 @@
containerPos = { top: 0, left: 0 };
}

var winPad = that.options.windowPadding;
selectOffsetTop = pos.top - containerPos.top - $window.scrollTop();
selectOffsetBot = $window.height() - selectOffsetTop - selectHeight - containerPos.top;
selectOffsetBot = $window.height() - selectOffsetTop - selectHeight - containerPos.top - winPad[2];
selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft();
selectOffsetRight = $window.width() - selectOffsetLeft - selectWidth - containerPos.left;
selectOffsetRight = $window.width() - selectOffsetLeft - selectWidth - containerPos.left - winPad[1];
selectOffsetTop -= winPad[0];
selectOffsetLeft -= winPad[3];
};

getPos();
Expand Down Expand Up @@ -1172,11 +1195,11 @@

if (this.isDisabled()) {
this.$newElement.addClass('disabled');
this.$button.addClass('disabled').attr('tabindex', -1);
this.$button.addClass('disabled').attr('tabindex', -1).attr('aria-disabled', true);
} else {
if (this.$button.hasClass('disabled')) {
this.$newElement.removeClass('disabled');
this.$button.removeClass('disabled');
this.$button.removeClass('disabled').attr('aria-disabled', false);
}

if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) {
Expand All @@ -1191,7 +1214,7 @@

togglePlaceholder: function () {
var value = this.$element.val();
this.$button.toggleClass('bs-placeholder', value === null || value === '');
this.$button.toggleClass('bs-placeholder', value === null || value === '' || (value.constructor === Array && value.length === 0));
},

tabIndex: function () {
Expand All @@ -1208,10 +1231,6 @@
var that = this,
$document = $(document);

this.$newElement.on('touchstart.dropdown', '.dropdown-menu', function (e) {
e.stopPropagation();
});

$document.data('spaceSelect', false);

this.$button.on('keyup', function (e) {
Expand Down Expand Up @@ -1406,7 +1425,7 @@
var that = this,
$no_results = $('<li class="no-results"></li>');

this.$button.on('click.dropdown.data-api touchstart.dropdown.data-api', function () {
this.$button.on('click.dropdown.data-api', function () {
that.$menuInner.find('.active').removeClass('active');
if (!!that.$searchbox.val()) {
that.$searchbox.val('');
Expand All @@ -1424,58 +1443,51 @@
});

this.$searchbox.on('input propertychange', function () {
that.$lis.not('.is-hidden').removeClass('hidden');
that.$lis.filter('.active').removeClass('active');
$no_results.remove();

if (that.$searchbox.val()) {
var $searchBase = that.$lis.not('.is-hidden').removeClass('hidden').children('a');
var $searchBase = that.$lis.not('.is-hidden, .divider, .dropdown-header'),
$hideItems;
if (that.options.liveSearchNormalize) {
$searchBase = $searchBase.not(':a' + that._searchStyle() + '("' + normalizeToBase(that.$searchbox.val()) + '")');
$hideItems = $searchBase.not(':a' + that._searchStyle() + '("' + normalizeToBase(that.$searchbox.val()) + '")');
} else {
$searchBase = $searchBase.not(':' + that._searchStyle() + '("' + that.$searchbox.val() + '")');
$hideItems = $searchBase.not(':' + that._searchStyle() + '("' + that.$searchbox.val() + '")');
}
$searchBase.parent().addClass('hidden');

that.$lis.filter('.dropdown-header').each(function () {
var $this = $(this),
optgroup = $this.data('optgroup');

if (that.$lis.filter('[data-optgroup=' + optgroup + ']').not($this).not('.hidden').length === 0) {
$this.addClass('hidden');
that.$lis.filter('[data-optgroup=' + optgroup + 'div]').addClass('hidden');
}
});
if ($hideItems.length === $searchBase.length) {
$no_results.html(that.options.noneResultsText.replace('{0}', '"' + htmlEscape(that.$searchbox.val()) + '"'));
that.$menuInner.append($no_results);
that.$lis.addClass('hidden');
} else {
$hideItems.addClass('hidden');

var $lisVisible = that.$lis.not('.hidden');
var $lisVisible = that.$lis.not('.hidden'),
$foundDiv;

// hide divider if first or last visible, or if followed by another divider
$lisVisible.each(function (index) {
var $this = $(this);
// hide divider if first or last visible, or if followed by another divider
$lisVisible.each(function (index) {
var $this = $(this);

if ($this.hasClass('divider') && (
$this.index() === $lisVisible.first().index() ||
$this.index() === $lisVisible.last().index() ||
$lisVisible.eq(index + 1).hasClass('divider'))) {
$this.addClass('hidden');
}
});
if ($this.hasClass('divider')) {
if ($foundDiv === undefined) {
$this.addClass('hidden');
} else {
if ($foundDiv) $foundDiv.addClass('hidden');
$foundDiv = $this;
}
} else if ($this.hasClass('dropdown-header') && $lisVisible.eq(index + 1).data('optgroup') !== $this.data('optgroup')) {
$this.addClass('hidden');
} else {
$foundDiv = null;
}
});
if ($foundDiv) $foundDiv.addClass('hidden');

if (!that.$lis.not('.hidden, .no-results').length) {
if (!!$no_results.parent().length) {
$no_results.remove();
}
$no_results.html(that.options.noneResultsText.replace('{0}', '"' + htmlEscape(that.$searchbox.val()) + '"')).show();
that.$menuInner.append($no_results);
} else if (!!$no_results.parent().length) {
$no_results.remove();
}
} else {
that.$lis.not('.is-hidden').removeClass('hidden');
if (!!$no_results.parent().length) {
$no_results.remove();
$searchBase.not('.hidden').first().addClass('active');
}
}

that.$lis.filter('.active').removeClass('active');
if (that.$searchbox.val()) that.$lis.not('.hidden, .divider, .dropdown-header').eq(0).addClass('active').children('a').focus();
$(this).focus();
});
},

Expand Down Expand Up @@ -1638,7 +1650,8 @@
if (/(^9$|27)/.test(e.keyCode.toString(10)) && isActive) {
e.preventDefault();
e.stopPropagation();
that.$button.click().focus();
that.$menuInner.click();
that.$button.focus();
}
// $items contains li elements when liveSearch is enabled
$items = $('[role="listbox"] li' + selector, $parent);
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dist/js/bootstrap-select.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/docs/dist/js/bootstrap-select.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit ca596d8

Please sign in to comment.