reorganize some asset directories
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
define([
|
||||
'./array',
|
||||
'../utils',
|
||||
'jquery'
|
||||
], function (ArrayAdapter, Utils, $) {
|
||||
function AjaxAdapter ($element, options) {
|
||||
this.ajaxOptions = this._applyDefaults(options.get('ajax'));
|
||||
|
||||
if (this.ajaxOptions.processResults != null) {
|
||||
this.processResults = this.ajaxOptions.processResults;
|
||||
}
|
||||
|
||||
AjaxAdapter.__super__.constructor.call(this, $element, options);
|
||||
}
|
||||
|
||||
Utils.Extend(AjaxAdapter, ArrayAdapter);
|
||||
|
||||
AjaxAdapter.prototype._applyDefaults = function (options) {
|
||||
var defaults = {
|
||||
data: function (params) {
|
||||
return $.extend({}, params, {
|
||||
q: params.term
|
||||
});
|
||||
},
|
||||
transport: function (params, success, failure) {
|
||||
var $request = $.ajax(params);
|
||||
|
||||
$request.then(success);
|
||||
$request.fail(failure);
|
||||
|
||||
return $request;
|
||||
}
|
||||
};
|
||||
|
||||
return $.extend({}, defaults, options, true);
|
||||
};
|
||||
|
||||
AjaxAdapter.prototype.processResults = function (results) {
|
||||
return results;
|
||||
};
|
||||
|
||||
AjaxAdapter.prototype.query = function (params, callback) {
|
||||
var matches = [];
|
||||
var self = this;
|
||||
|
||||
if (this._request != null) {
|
||||
// JSONP requests cannot always be aborted
|
||||
if ($.isFunction(this._request.abort)) {
|
||||
this._request.abort();
|
||||
}
|
||||
|
||||
this._request = null;
|
||||
}
|
||||
|
||||
var options = $.extend({
|
||||
type: 'GET'
|
||||
}, this.ajaxOptions);
|
||||
|
||||
if (typeof options.url === 'function') {
|
||||
options.url = options.url.call(this.$element, params);
|
||||
}
|
||||
|
||||
if (typeof options.data === 'function') {
|
||||
options.data = options.data.call(this.$element, params);
|
||||
}
|
||||
|
||||
function request () {
|
||||
var $request = options.transport(options, function (data) {
|
||||
var results = self.processResults(data, params);
|
||||
|
||||
if (self.options.get('debug') && window.console && console.error) {
|
||||
// Check to make sure that the response included a `results` key.
|
||||
if (!results || !results.results || !$.isArray(results.results)) {
|
||||
console.error(
|
||||
'Select2: The AJAX results did not return an array in the ' +
|
||||
'`results` key of the response.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
callback(results);
|
||||
}, function () {
|
||||
// Attempt to detect if a request was aborted
|
||||
// Only works if the transport exposes a status property
|
||||
if ($request.status && $request.status === '0') {
|
||||
return;
|
||||
}
|
||||
|
||||
self.trigger('results:message', {
|
||||
message: 'errorLoading'
|
||||
});
|
||||
});
|
||||
|
||||
self._request = $request;
|
||||
}
|
||||
|
||||
if (this.ajaxOptions.delay && params.term != null) {
|
||||
if (this._queryTimeout) {
|
||||
window.clearTimeout(this._queryTimeout);
|
||||
}
|
||||
|
||||
this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
|
||||
} else {
|
||||
request();
|
||||
}
|
||||
};
|
||||
|
||||
return AjaxAdapter;
|
||||
});
|
||||
@@ -0,0 +1,79 @@
|
||||
define([
|
||||
'./select',
|
||||
'../utils',
|
||||
'jquery'
|
||||
], function (SelectAdapter, Utils, $) {
|
||||
function ArrayAdapter ($element, options) {
|
||||
var data = options.get('data') || [];
|
||||
|
||||
ArrayAdapter.__super__.constructor.call(this, $element, options);
|
||||
|
||||
this.addOptions(this.convertToOptions(data));
|
||||
}
|
||||
|
||||
Utils.Extend(ArrayAdapter, SelectAdapter);
|
||||
|
||||
ArrayAdapter.prototype.select = function (data) {
|
||||
var $option = this.$element.find('option').filter(function (i, elm) {
|
||||
return elm.value == data.id.toString();
|
||||
});
|
||||
|
||||
if ($option.length === 0) {
|
||||
$option = this.option(data);
|
||||
|
||||
this.addOptions($option);
|
||||
}
|
||||
|
||||
ArrayAdapter.__super__.select.call(this, data);
|
||||
};
|
||||
|
||||
ArrayAdapter.prototype.convertToOptions = function (data) {
|
||||
var self = this;
|
||||
|
||||
var $existing = this.$element.find('option');
|
||||
var existingIds = $existing.map(function () {
|
||||
return self.item($(this)).id;
|
||||
}).get();
|
||||
|
||||
var $options = [];
|
||||
|
||||
// Filter out all items except for the one passed in the argument
|
||||
function onlyItem (item) {
|
||||
return function () {
|
||||
return $(this).val() == item.id;
|
||||
};
|
||||
}
|
||||
|
||||
for (var d = 0; d < data.length; d++) {
|
||||
var item = this._normalizeItem(data[d]);
|
||||
|
||||
// Skip items which were pre-loaded, only merge the data
|
||||
if ($.inArray(item.id, existingIds) >= 0) {
|
||||
var $existingOption = $existing.filter(onlyItem(item));
|
||||
|
||||
var existingData = this.item($existingOption);
|
||||
var newData = $.extend(true, {}, item, existingData);
|
||||
|
||||
var $newOption = this.option(newData);
|
||||
|
||||
$existingOption.replaceWith($newOption);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
var $option = this.option(item);
|
||||
|
||||
if (item.children) {
|
||||
var $children = this.convertToOptions(item.children);
|
||||
|
||||
Utils.appendMany($option, $children);
|
||||
}
|
||||
|
||||
$options.push($option);
|
||||
}
|
||||
|
||||
return $options;
|
||||
};
|
||||
|
||||
return ArrayAdapter;
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
define([
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
function BaseAdapter ($element, options) {
|
||||
BaseAdapter.__super__.constructor.call(this);
|
||||
}
|
||||
|
||||
Utils.Extend(BaseAdapter, Utils.Observable);
|
||||
|
||||
BaseAdapter.prototype.current = function (callback) {
|
||||
throw new Error('The `current` method must be defined in child classes.');
|
||||
};
|
||||
|
||||
BaseAdapter.prototype.query = function (params, callback) {
|
||||
throw new Error('The `query` method must be defined in child classes.');
|
||||
};
|
||||
|
||||
BaseAdapter.prototype.bind = function (container, $container) {
|
||||
// Can be implemented in subclasses
|
||||
};
|
||||
|
||||
BaseAdapter.prototype.destroy = function () {
|
||||
// Can be implemented in subclasses
|
||||
};
|
||||
|
||||
BaseAdapter.prototype.generateResultId = function (container, data) {
|
||||
var id = container.id + '-result-';
|
||||
|
||||
id += Utils.generateChars(4);
|
||||
|
||||
if (data.id != null) {
|
||||
id += '-' + data.id.toString();
|
||||
} else {
|
||||
id += '-' + Utils.generateChars(4);
|
||||
}
|
||||
return id;
|
||||
};
|
||||
|
||||
return BaseAdapter;
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
define([
|
||||
|
||||
], function () {
|
||||
function MaximumInputLength (decorated, $e, options) {
|
||||
this.maximumInputLength = options.get('maximumInputLength');
|
||||
|
||||
decorated.call(this, $e, options);
|
||||
}
|
||||
|
||||
MaximumInputLength.prototype.query = function (decorated, params, callback) {
|
||||
params.term = params.term || '';
|
||||
|
||||
if (this.maximumInputLength > 0 &&
|
||||
params.term.length > this.maximumInputLength) {
|
||||
this.trigger('results:message', {
|
||||
message: 'inputTooLong',
|
||||
args: {
|
||||
maximum: this.maximumInputLength,
|
||||
input: params.term,
|
||||
params: params
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
decorated.call(this, params, callback);
|
||||
};
|
||||
|
||||
return MaximumInputLength;
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
define([
|
||||
|
||||
], function (){
|
||||
function MaximumSelectionLength (decorated, $e, options) {
|
||||
this.maximumSelectionLength = options.get('maximumSelectionLength');
|
||||
|
||||
decorated.call(this, $e, options);
|
||||
}
|
||||
|
||||
MaximumSelectionLength.prototype.query =
|
||||
function (decorated, params, callback) {
|
||||
var self = this;
|
||||
|
||||
this.current(function (currentData) {
|
||||
var count = currentData != null ? currentData.length : 0;
|
||||
if (self.maximumSelectionLength > 0 &&
|
||||
count >= self.maximumSelectionLength) {
|
||||
self.trigger('results:message', {
|
||||
message: 'maximumSelected',
|
||||
args: {
|
||||
maximum: self.maximumSelectionLength
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
decorated.call(self, params, callback);
|
||||
});
|
||||
};
|
||||
|
||||
return MaximumSelectionLength;
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
define([
|
||||
|
||||
], function () {
|
||||
function MinimumInputLength (decorated, $e, options) {
|
||||
this.minimumInputLength = options.get('minimumInputLength');
|
||||
|
||||
decorated.call(this, $e, options);
|
||||
}
|
||||
|
||||
MinimumInputLength.prototype.query = function (decorated, params, callback) {
|
||||
params.term = params.term || '';
|
||||
|
||||
if (params.term.length < this.minimumInputLength) {
|
||||
this.trigger('results:message', {
|
||||
message: 'inputTooShort',
|
||||
args: {
|
||||
minimum: this.minimumInputLength,
|
||||
input: params.term,
|
||||
params: params
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
decorated.call(this, params, callback);
|
||||
};
|
||||
|
||||
return MinimumInputLength;
|
||||
});
|
||||
@@ -0,0 +1,285 @@
|
||||
define([
|
||||
'./base',
|
||||
'../utils',
|
||||
'jquery'
|
||||
], function (BaseAdapter, Utils, $) {
|
||||
function SelectAdapter ($element, options) {
|
||||
this.$element = $element;
|
||||
this.options = options;
|
||||
|
||||
SelectAdapter.__super__.constructor.call(this);
|
||||
}
|
||||
|
||||
Utils.Extend(SelectAdapter, BaseAdapter);
|
||||
|
||||
SelectAdapter.prototype.current = function (callback) {
|
||||
var data = [];
|
||||
var self = this;
|
||||
|
||||
this.$element.find(':selected').each(function () {
|
||||
var $option = $(this);
|
||||
|
||||
var option = self.item($option);
|
||||
|
||||
data.push(option);
|
||||
});
|
||||
|
||||
callback(data);
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.select = function (data) {
|
||||
var self = this;
|
||||
|
||||
data.selected = true;
|
||||
|
||||
// If data.element is a DOM node, use it instead
|
||||
if ($(data.element).is('option')) {
|
||||
data.element.selected = true;
|
||||
|
||||
this.$element.trigger('change');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.$element.prop('multiple')) {
|
||||
this.current(function (currentData) {
|
||||
var val = [];
|
||||
|
||||
data = [data];
|
||||
data.push.apply(data, currentData);
|
||||
|
||||
for (var d = 0; d < data.length; d++) {
|
||||
var id = data[d].id;
|
||||
|
||||
if ($.inArray(id, val) === -1) {
|
||||
val.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
self.$element.val(val);
|
||||
self.$element.trigger('change');
|
||||
});
|
||||
} else {
|
||||
var val = data.id;
|
||||
|
||||
this.$element.val(val);
|
||||
this.$element.trigger('change');
|
||||
}
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.unselect = function (data) {
|
||||
var self = this;
|
||||
|
||||
if (!this.$element.prop('multiple')) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.selected = false;
|
||||
|
||||
if ($(data.element).is('option')) {
|
||||
data.element.selected = false;
|
||||
|
||||
this.$element.trigger('change');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.current(function (currentData) {
|
||||
var val = [];
|
||||
|
||||
for (var d = 0; d < currentData.length; d++) {
|
||||
var id = currentData[d].id;
|
||||
|
||||
if (id !== data.id && $.inArray(id, val) === -1) {
|
||||
val.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
self.$element.val(val);
|
||||
|
||||
self.$element.trigger('change');
|
||||
});
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
this.container = container;
|
||||
|
||||
container.on('select', function (params) {
|
||||
self.select(params.data);
|
||||
});
|
||||
|
||||
container.on('unselect', function (params) {
|
||||
self.unselect(params.data);
|
||||
});
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.destroy = function () {
|
||||
// Remove anything added to child elements
|
||||
this.$element.find('*').each(function () {
|
||||
// Remove any custom data set by Select2
|
||||
$.removeData(this, 'data');
|
||||
});
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.query = function (params, callback) {
|
||||
var data = [];
|
||||
var self = this;
|
||||
|
||||
var $options = this.$element.children();
|
||||
|
||||
$options.each(function () {
|
||||
var $option = $(this);
|
||||
|
||||
if (!$option.is('option') && !$option.is('optgroup')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var option = self.item($option);
|
||||
|
||||
var matches = self.matches(params, option);
|
||||
|
||||
if (matches !== null) {
|
||||
data.push(matches);
|
||||
}
|
||||
});
|
||||
|
||||
callback({
|
||||
results: data
|
||||
});
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.addOptions = function ($options) {
|
||||
Utils.appendMany(this.$element, $options);
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.option = function (data) {
|
||||
var option;
|
||||
|
||||
if (data.children) {
|
||||
option = document.createElement('optgroup');
|
||||
option.label = data.text;
|
||||
} else {
|
||||
option = document.createElement('option');
|
||||
|
||||
if (option.textContent !== undefined) {
|
||||
option.textContent = data.text;
|
||||
} else {
|
||||
option.innerText = data.text;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.id) {
|
||||
option.value = data.id;
|
||||
}
|
||||
|
||||
if (data.disabled) {
|
||||
option.disabled = true;
|
||||
}
|
||||
|
||||
if (data.selected) {
|
||||
option.selected = true;
|
||||
}
|
||||
|
||||
if (data.title) {
|
||||
option.title = data.title;
|
||||
}
|
||||
|
||||
var $option = $(option);
|
||||
|
||||
var normalizedData = this._normalizeItem(data);
|
||||
normalizedData.element = option;
|
||||
|
||||
// Override the option's data with the combined data
|
||||
$.data(option, 'data', normalizedData);
|
||||
|
||||
return $option;
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.item = function ($option) {
|
||||
var data = {};
|
||||
|
||||
data = $.data($option[0], 'data');
|
||||
|
||||
if (data != null) {
|
||||
return data;
|
||||
}
|
||||
|
||||
if ($option.is('option')) {
|
||||
data = {
|
||||
id: $option.val(),
|
||||
text: $option.text(),
|
||||
disabled: $option.prop('disabled'),
|
||||
selected: $option.prop('selected'),
|
||||
title: $option.prop('title')
|
||||
};
|
||||
} else if ($option.is('optgroup')) {
|
||||
data = {
|
||||
text: $option.prop('label'),
|
||||
children: [],
|
||||
title: $option.prop('title')
|
||||
};
|
||||
|
||||
var $children = $option.children('option');
|
||||
var children = [];
|
||||
|
||||
for (var c = 0; c < $children.length; c++) {
|
||||
var $child = $($children[c]);
|
||||
|
||||
var child = this.item($child);
|
||||
|
||||
children.push(child);
|
||||
}
|
||||
|
||||
data.children = children;
|
||||
}
|
||||
|
||||
data = this._normalizeItem(data);
|
||||
data.element = $option[0];
|
||||
|
||||
$.data($option[0], 'data', data);
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
SelectAdapter.prototype._normalizeItem = function (item) {
|
||||
if (!$.isPlainObject(item)) {
|
||||
item = {
|
||||
id: item,
|
||||
text: item
|
||||
};
|
||||
}
|
||||
|
||||
item = $.extend({}, {
|
||||
text: ''
|
||||
}, item);
|
||||
|
||||
var defaults = {
|
||||
selected: false,
|
||||
disabled: false
|
||||
};
|
||||
|
||||
if (item.id != null) {
|
||||
item.id = item.id.toString();
|
||||
}
|
||||
|
||||
if (item.text != null) {
|
||||
item.text = item.text.toString();
|
||||
}
|
||||
|
||||
if (item._resultId == null && item.id && this.container != null) {
|
||||
item._resultId = this.generateResultId(this.container, item);
|
||||
}
|
||||
|
||||
return $.extend({}, defaults, item);
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.matches = function (params, data) {
|
||||
var matcher = this.options.get('matcher');
|
||||
|
||||
return matcher(params, data);
|
||||
};
|
||||
|
||||
return SelectAdapter;
|
||||
});
|
||||
@@ -0,0 +1,125 @@
|
||||
define([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
function Tags (decorated, $element, options) {
|
||||
var tags = options.get('tags');
|
||||
|
||||
var createTag = options.get('createTag');
|
||||
|
||||
if (createTag !== undefined) {
|
||||
this.createTag = createTag;
|
||||
}
|
||||
|
||||
var insertTag = options.get('insertTag');
|
||||
|
||||
if (insertTag !== undefined) {
|
||||
this.insertTag = insertTag;
|
||||
}
|
||||
|
||||
decorated.call(this, $element, options);
|
||||
|
||||
if ($.isArray(tags)) {
|
||||
for (var t = 0; t < tags.length; t++) {
|
||||
var tag = tags[t];
|
||||
var item = this._normalizeItem(tag);
|
||||
|
||||
var $option = this.option(item);
|
||||
|
||||
this.$element.append($option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tags.prototype.query = function (decorated, params, callback) {
|
||||
var self = this;
|
||||
|
||||
this._removeOldTags();
|
||||
|
||||
if (params.term == null || params.page != null) {
|
||||
decorated.call(this, params, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
function wrapper (obj, child) {
|
||||
var data = obj.results;
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var option = data[i];
|
||||
|
||||
var checkChildren = (
|
||||
option.children != null &&
|
||||
!wrapper({
|
||||
results: option.children
|
||||
}, true)
|
||||
);
|
||||
|
||||
var checkText = option.text === params.term;
|
||||
|
||||
if (checkText || checkChildren) {
|
||||
if (child) {
|
||||
return false;
|
||||
}
|
||||
|
||||
obj.data = data;
|
||||
callback(obj);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (child) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var tag = self.createTag(params);
|
||||
|
||||
if (tag != null) {
|
||||
var $option = self.option(tag);
|
||||
$option.attr('data-select2-tag', true);
|
||||
|
||||
self.addOptions([$option]);
|
||||
|
||||
self.insertTag(data, tag);
|
||||
}
|
||||
|
||||
obj.results = data;
|
||||
|
||||
callback(obj);
|
||||
}
|
||||
|
||||
decorated.call(this, params, wrapper);
|
||||
};
|
||||
|
||||
Tags.prototype.createTag = function (decorated, params) {
|
||||
var term = $.trim(params.term);
|
||||
|
||||
if (term === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
id: term,
|
||||
text: term
|
||||
};
|
||||
};
|
||||
|
||||
Tags.prototype.insertTag = function (_, data, tag) {
|
||||
data.unshift(tag);
|
||||
};
|
||||
|
||||
Tags.prototype._removeOldTags = function (_) {
|
||||
var tag = this._lastTag;
|
||||
|
||||
var $options = this.$element.find('option[data-select2-tag]');
|
||||
|
||||
$options.each(function () {
|
||||
if (this.selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(this).remove();
|
||||
});
|
||||
};
|
||||
|
||||
return Tags;
|
||||
});
|
||||
@@ -0,0 +1,116 @@
|
||||
define([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
function Tokenizer (decorated, $element, options) {
|
||||
var tokenizer = options.get('tokenizer');
|
||||
|
||||
if (tokenizer !== undefined) {
|
||||
this.tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
decorated.call(this, $element, options);
|
||||
}
|
||||
|
||||
Tokenizer.prototype.bind = function (decorated, container, $container) {
|
||||
decorated.call(this, container, $container);
|
||||
|
||||
this.$search = container.dropdown.$search || container.selection.$search ||
|
||||
$container.find('.select2-search__field');
|
||||
};
|
||||
|
||||
Tokenizer.prototype.query = function (decorated, params, callback) {
|
||||
var self = this;
|
||||
|
||||
function createAndSelect (data) {
|
||||
// Normalize the data object so we can use it for checks
|
||||
var item = self._normalizeItem(data);
|
||||
|
||||
// Check if the data object already exists as a tag
|
||||
// Select it if it doesn't
|
||||
var $existingOptions = self.$element.find('option').filter(function () {
|
||||
return $(this).val() === item.id;
|
||||
});
|
||||
|
||||
// If an existing option wasn't found for it, create the option
|
||||
if (!$existingOptions.length) {
|
||||
var $option = self.option(item);
|
||||
$option.attr('data-select2-tag', true);
|
||||
|
||||
self._removeOldTags();
|
||||
self.addOptions([$option]);
|
||||
}
|
||||
|
||||
// Select the item, now that we know there is an option for it
|
||||
select(item);
|
||||
}
|
||||
|
||||
function select (data) {
|
||||
self.trigger('select', {
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
params.term = params.term || '';
|
||||
|
||||
var tokenData = this.tokenizer(params, this.options, createAndSelect);
|
||||
|
||||
if (tokenData.term !== params.term) {
|
||||
// Replace the search term if we have the search box
|
||||
if (this.$search.length) {
|
||||
this.$search.val(tokenData.term);
|
||||
this.$search.focus();
|
||||
}
|
||||
|
||||
params.term = tokenData.term;
|
||||
}
|
||||
|
||||
decorated.call(this, params, callback);
|
||||
};
|
||||
|
||||
Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
|
||||
var separators = options.get('tokenSeparators') || [];
|
||||
var term = params.term;
|
||||
var i = 0;
|
||||
|
||||
var createTag = this.createTag || function (params) {
|
||||
return {
|
||||
id: params.term,
|
||||
text: params.term
|
||||
};
|
||||
};
|
||||
|
||||
while (i < term.length) {
|
||||
var termChar = term[i];
|
||||
|
||||
if ($.inArray(termChar, separators) === -1) {
|
||||
i++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
var part = term.substr(0, i);
|
||||
var partParams = $.extend({}, params, {
|
||||
term: part
|
||||
});
|
||||
|
||||
var data = createTag(partParams);
|
||||
|
||||
if (data == null) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
callback(data);
|
||||
|
||||
// Reset the term to not include the tokenized portion
|
||||
term = term.substr(i + 1) || '';
|
||||
i = 0;
|
||||
}
|
||||
|
||||
return {
|
||||
term: term
|
||||
};
|
||||
};
|
||||
|
||||
return Tokenizer;
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
define(function () {
|
||||
// Arabic
|
||||
return {
|
||||
errorLoading: function () {
|
||||
return 'لا يمكن تحميل النتائج';
|
||||
},
|
||||
inputTooLong: function (args) {
|
||||
var overChars = args.input.length - args.maximum;
|
||||
|
||||
var message = 'الرجاء حذف ' + overChars + ' عناصر';
|
||||
|
||||
return message;
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
var message = 'الرجاء إضافة ' + remainingChars + ' عناصر';
|
||||
|
||||
return message;
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'جاري تحميل نتائج إضافية...';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
var message = 'تستطيع إختيار ' + args.maximum + ' بنود فقط';
|
||||
|
||||
return message;
|
||||
},
|
||||
noResults: function () {
|
||||
return 'لم يتم العثور على أي نتائج';
|
||||
},
|
||||
searching: function () {
|
||||
return 'جاري البحث…';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
define(function () {
|
||||
// Azerbaijani
|
||||
return {
|
||||
inputTooLong: function (args) {
|
||||
var overChars = args.input.length - args.maximum;
|
||||
|
||||
return overChars + ' simvol silin';
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
return remainingChars + ' simvol daxil edin';
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'Daha çox nəticə yüklənir…';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
return 'Sadəcə ' + args.maximum + ' element seçə bilərsiniz';
|
||||
},
|
||||
noResults: function () {
|
||||
return 'Nəticə tapılmadı';
|
||||
},
|
||||
searching: function () {
|
||||
return 'Axtarılır…';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
define(function () {
|
||||
// Bulgarian
|
||||
return {
|
||||
inputTooLong: function (args) {
|
||||
var overChars = args.input.length - args.maximum;
|
||||
|
||||
var message = 'Моля въведете с ' + overChars + ' по-малко символ';
|
||||
|
||||
if (overChars > 1) {
|
||||
message += 'a';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
var message = 'Моля въведете още ' + remainingChars + ' символ';
|
||||
|
||||
if (remainingChars > 1) {
|
||||
message += 'a';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'Зареждат се още…';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
var message = 'Можете да направите до ' + args.maximum + ' ';
|
||||
|
||||
if (args.maximum > 1) {
|
||||
message += 'избора';
|
||||
} else {
|
||||
message += 'избор';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
noResults: function () {
|
||||
return 'Няма намерени съвпадения';
|
||||
},
|
||||
searching: function () {
|
||||
return 'Търсене…';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
define(function () {
|
||||
// Catalan
|
||||
return {
|
||||
errorLoading: function () {
|
||||
return 'La càrrega ha fallat';
|
||||
},
|
||||
inputTooLong: function (args) {
|
||||
var overChars = args.input.length - args.maximum;
|
||||
|
||||
var message = 'Si us plau, elimina ' + overChars + ' car';
|
||||
|
||||
if (overChars == 1) {
|
||||
message += 'àcter';
|
||||
} else {
|
||||
message += 'àcters';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
var message = 'Si us plau, introdueix ' + remainingChars + ' car';
|
||||
|
||||
if (remainingChars == 1) {
|
||||
message += 'àcter';
|
||||
} else {
|
||||
message += 'àcters';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'Carregant més resultats…';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
var message = 'Només es pot seleccionar ' + args.maximum + ' element';
|
||||
|
||||
if (args.maximum != 1) {
|
||||
message += 's';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
noResults: function () {
|
||||
return 'No s\'han trobat resultats';
|
||||
},
|
||||
searching: function () {
|
||||
return 'Cercant…';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
define(function () {
|
||||
// Czech
|
||||
function small (count, masc) {
|
||||
switch(count) {
|
||||
case 2:
|
||||
return masc ? 'dva' : 'dvě';
|
||||
case 3:
|
||||
return 'tři';
|
||||
case 4:
|
||||
return 'čtyři';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
return {
|
||||
errorLoading: function () {
|
||||
return 'Výsledky nemohly být načteny.';
|
||||
},
|
||||
inputTooLong: function (args) {
|
||||
var n = args.input.length - args.maximum;
|
||||
|
||||
if (n == 1) {
|
||||
return 'Prosím zadejte o jeden znak méně';
|
||||
} else if (n <= 4) {
|
||||
return 'Prosím zadejte o ' + small(n, true) + ' znaky méně';
|
||||
} else {
|
||||
return 'Prosím zadejte o ' + n + ' znaků méně';
|
||||
}
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var n = args.minimum - args.input.length;
|
||||
|
||||
if (n == 1) {
|
||||
return 'Prosím zadejte ještě jeden znak';
|
||||
} else if (n <= 4) {
|
||||
return 'Prosím zadejte ještě další ' + small(n, true) + ' znaky';
|
||||
} else {
|
||||
return 'Prosím zadejte ještě dalších ' + n + ' znaků';
|
||||
}
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'Načítají se další výsledky…';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
var n = args.maximum;
|
||||
|
||||
if (n == 1) {
|
||||
return 'Můžete zvolit jen jednu položku';
|
||||
} else if (n <= 4) {
|
||||
return 'Můžete zvolit maximálně ' + small(n, false) + ' položky';
|
||||
} else {
|
||||
return 'Můžete zvolit maximálně ' + n + ' položek';
|
||||
}
|
||||
},
|
||||
noResults: function () {
|
||||
return 'Nenalezeny žádné položky';
|
||||
},
|
||||
searching: function () {
|
||||
return 'Vyhledávání…';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
define(function () {
|
||||
// Danish
|
||||
return {
|
||||
errorLoading: function () {
|
||||
return 'Resultaterne kunne ikke indlæses.';
|
||||
},
|
||||
inputTooLong: function (args) {
|
||||
var overChars = args.input.length - args.maximum;
|
||||
|
||||
var message = 'Angiv venligst ' + overChars + ' tegn mindre';
|
||||
|
||||
return message;
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
var message = 'Angiv venligst ' + remainingChars + ' tegn mere';
|
||||
|
||||
return message;
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'Indlæser flere resultater…';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
var message = 'Du kan kun vælge ' + args.maximum + ' emne';
|
||||
|
||||
if (args.maximum != 1) {
|
||||
message += 'r';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
noResults: function () {
|
||||
return 'Ingen resultater fundet';
|
||||
},
|
||||
searching: function () {
|
||||
return 'Søger…';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
define(function () {
|
||||
// German
|
||||
return {
|
||||
inputTooLong: function (args) {
|
||||
var overChars = args.input.length - args.maximum;
|
||||
|
||||
return 'Bitte ' + overChars + ' Zeichen weniger eingeben';
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
return 'Bitte ' + remainingChars + ' Zeichen mehr eingeben';
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'Lade mehr Ergebnisse…';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
var message = 'Sie können nur ' + args.maximum + ' Eintr';
|
||||
|
||||
if (args.maximum === 1) {
|
||||
message += 'ag';
|
||||
} else {
|
||||
message += 'äge';
|
||||
}
|
||||
|
||||
message += ' auswählen';
|
||||
|
||||
return message;
|
||||
},
|
||||
noResults: function () {
|
||||
return 'Keine Übereinstimmungen gefunden';
|
||||
},
|
||||
searching: function () {
|
||||
return 'Suche…';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
define(function () {
|
||||
// Greek (el)
|
||||
return {
|
||||
errorLoading: function () {
|
||||
return 'Τα αποτελέσματα δεν μπόρεσαν να φορτώσουν.';
|
||||
},
|
||||
inputTooLong: function (args) {
|
||||
var overChars = args.input.length - args.maximum;
|
||||
|
||||
var message = 'Παρακαλώ διαγράψτε ' + overChars + ' χαρακτήρ';
|
||||
|
||||
if (overChars == 1) {
|
||||
message += 'α';
|
||||
}
|
||||
if (overChars != 1) {
|
||||
message += 'ες';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
var message = 'Παρακαλώ συμπληρώστε ' + remainingChars +
|
||||
' ή περισσότερους χαρακτήρες';
|
||||
|
||||
return message;
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'Φόρτωση περισσότερων αποτελεσμάτων…';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
var message = 'Μπορείτε να επιλέξετε μόνο ' + args.maximum + ' επιλογ';
|
||||
|
||||
if (args.maximum == 1) {
|
||||
message += 'ή';
|
||||
}
|
||||
|
||||
if (args.maximum != 1) {
|
||||
message += 'ές';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
noResults: function () {
|
||||
return 'Δεν βρέθηκαν αποτελέσματα';
|
||||
},
|
||||
searching: function () {
|
||||
return 'Αναζήτηση…';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
define(function () {
|
||||
// English
|
||||
return {
|
||||
errorLoading: function () {
|
||||
return 'The results could not be loaded.';
|
||||
},
|
||||
inputTooLong: function (args) {
|
||||
var overChars = args.input.length - args.maximum;
|
||||
|
||||
var message = 'Please delete ' + overChars + ' character';
|
||||
|
||||
if (overChars != 1) {
|
||||
message += 's';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
var message = 'Please enter ' + remainingChars + ' or more characters';
|
||||
|
||||
return message;
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'Loading more results…';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
var message = 'You can only select ' + args.maximum + ' item';
|
||||
|
||||
if (args.maximum != 1) {
|
||||
message += 's';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
noResults: function () {
|
||||
return 'No results found';
|
||||
},
|
||||
searching: function () {
|
||||
return 'Searching…';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
define(function () {
|
||||
// Spanish
|
||||
return {
|
||||
errorLoading: function () {
|
||||
return 'La carga falló';
|
||||
},
|
||||
inputTooLong: function (args) {
|
||||
var remainingChars = args.input.length - args.maximum;
|
||||
|
||||
var message = 'Por favor, elimine ' + remainingChars + ' car';
|
||||
|
||||
if (remainingChars == 1) {
|
||||
message += 'ácter';
|
||||
} else {
|
||||
message += 'acteres';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
inputTooShort: function (args) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
var message = 'Por favor, introduzca ' + remainingChars + ' car';
|
||||
|
||||
if (remainingChars == 1) {
|
||||
message += 'ácter';
|
||||
} else {
|
||||
message += 'acteres';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
loadingMore: function () {
|
||||
return 'Cargando más resultados…';
|
||||
},
|
||||
maximumSelected: function (args) {
|
||||
var message = 'Sólo puede seleccionar ' + args.maximum + ' elemento';
|
||||
|
||||
if (args.maximum != 1) {
|
||||
message += 's';
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
noResults: function () {
|
||||
return 'No se encontraron resultados';
|
||||
},
|
||||
searching: function () {
|
||||
return 'Buscando…';
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user