Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
v2.4.6, allow custom messages, #77
Browse files Browse the repository at this point in the history
  • Loading branch information
Mobius1 committed Nov 6, 2018
1 parent 12c6fe2 commit b995672
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobius1-selectr",
"version": "2.4.5",
"version": "2.4.6",
"ignore": [
".gitattributes",
"README.md"
Expand Down
2 changes: 1 addition & 1 deletion dist/selectr.min.css

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

4 changes: 2 additions & 2 deletions dist/selectr.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobius1-selectr",
"version": "2.4.5",
"version": "2.4.6",
"description": "A lightweight, dependency-free, mobile-friendly javascript select box replacement.",
"main": "dist/selectr.min.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/selectr.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Selectr 2.4.5
* Selectr 2.4.6
* http://mobius.ovh/docs/selectr
*
* Released under the MIT license
Expand Down
36 changes: 22 additions & 14 deletions src/selectr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Selectr 2.4.5
* Selectr 2.4.6
* http://mobius.ovh/docs/selectr
*
* Released under the MIT license
Expand Down Expand Up @@ -98,7 +98,13 @@
* Set the tag input placeholder (@labikmartin, #21, #22)
* @type {String}
*/
tagPlaceholder: "Enter a tag..."
tagPlaceholder: "Enter a tag...",

messages: {
noResults: "No results.",
maxSelections: "A maximum of {max} items can be selected.",
tagDuplicate: "That tag is already in use",
}
};

/**
Expand Down Expand Up @@ -172,16 +178,18 @@
*/
var util = {
extend: function(src, props) {
props = props || {};
var p;
for (p in src) {
if (src.hasOwnProperty(p)) {
if (!props.hasOwnProperty(p)) {
props[p] = src[p];
for (var prop in props) {
if (props.hasOwnProperty(prop)) {
var val = props[prop];
if (val && Object.prototype.toString.call(val) === "[object Object]") {
src[prop] = src[prop] || {};
util.extend(src[prop], val);
} else {
src[prop] = val;
}
}
}
}
}
return props;
return src;
},
each: function(a, b, c) {
if ("[object Object]" === Object.prototype.toString.call(a)) {
Expand Down Expand Up @@ -1364,7 +1372,7 @@

if (!option) {
this.value = '';
that.setMessage('That tag is already in use.');
that.setMessage(that.config.messages.tagDuplicate);
} else {
that.close();
clearSearch.call(that);
Expand Down Expand Up @@ -1556,7 +1564,7 @@
}

if (this.config.maxSelections && this.tags.length === this.config.maxSelections) {
this.setMessage("A maximum of " + this.config.maxSelections + " items can be selected.", true);
this.setMessage(this.config.messages.maxSelections.replace("{max}", this.config.maxSelections), true);
return false;
}

Expand Down Expand Up @@ -1952,7 +1960,7 @@
// Append results
if ( !f.childElementCount ) {
if ( !this.config.taggable ) {
this.setMessage( "no results." );
this.setMessage( this.config.messages.noResults );
}
} else {
// Highlight top result (@binary-koan #26)
Expand Down

0 comments on commit b995672

Please sign in to comment.