: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
for (var methodName in proto) {
var m = proto[methodName];
if (typeof m !== 'function') {
if (methodName === 'constructor') {
methods.push(methodName);
Utils.Decorate = function (SuperClass, DecoratorClass) {
var decoratedMethods = getMethods(DecoratorClass);
var superMethods = getMethods(SuperClass);
function DecoratedClass () {
var unshift = Array.prototype.unshift;
var argCount = DecoratorClass.prototype.constructor.length;
var calledConstructor = SuperClass.prototype.constructor;
unshift.call(arguments, SuperClass.prototype.constructor);
calledConstructor = DecoratorClass.prototype.constructor;
calledConstructor.apply(this, arguments);
DecoratorClass.displayName = SuperClass.displayName;
this.constructor = DecoratedClass;
DecoratedClass.prototype = new ctr();
for (var m = 0; m < superMethods.length; m++) {
var superMethod = superMethods[m];
DecoratedClass.prototype[superMethod] =
SuperClass.prototype[superMethod];
var calledMethod = function (methodName) {
// Stub out the original method if it's not decorating an actual method
var originalMethod = function () {};
if (methodName in DecoratedClass.prototype) {
originalMethod = DecoratedClass.prototype[methodName];
var decoratedMethod = DecoratorClass.prototype[methodName];
var unshift = Array.prototype.unshift;
unshift.call(arguments, originalMethod);
return decoratedMethod.apply(this, arguments);
for (var d = 0; d < decoratedMethods.length; d++) {
var decoratedMethod = decoratedMethods[d];
DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
var Observable = function () {
Observable.prototype.on = function (event, callback) {
this.listeners = this.listeners || {};
if (event in this.listeners) {
this.listeners[event].push(callback);
this.listeners[event] = [callback];
Observable.prototype.trigger = function (event) {
var slice = Array.prototype.slice;
this.listeners = this.listeners || {};
if (event in this.listeners) {
this.invoke(this.listeners[event], slice.call(arguments, 1));
if ('*' in this.listeners) {
this.invoke(this.listeners['*'], arguments);
Observable.prototype.invoke = function (listeners, params) {
for (var i = 0, len = listeners.length; i < len; i++) {
listeners[i].apply(this, params);
Utils.Observable = Observable;
Utils.generateChars = function (length) {
for (var i = 0; i < length; i++) {
var randomChar = Math.floor(Math.random() * 36);
chars += randomChar.toString(36);
Utils.bind = function (func, context) {
func.apply(context, arguments);
Utils._convertData = function (data) {
for (var originalKey in data) {
var keys = originalKey.split('-');
for (var k = 0; k < keys.length; k++) {
// Lowercase the first letter
// By default, dash-separated becomes camelCase
key = key.substring(0, 1).toLowerCase() + key.substring(1);
if (!(key in dataLevel)) {
if (k == keys.length - 1) {
dataLevel[key] = data[originalKey];
dataLevel = dataLevel[key];
delete data[originalKey];
Utils.hasScroll = function (index, el) {
// Adapted from the function created by @ShadowScripter
// and adapted by @BillBarry on the Stack Exchange Code Review website.
// The original code can be found at
// http://codereview.stackexchange.com/q/13338
// and was designed to be used with the Sizzle selector engine.
var overflowX = el.style.overflowX;
var overflowY = el.style.overflowY;
//Check both x and y declarations
if (overflowX === overflowY &&
(overflowY === 'hidden' || overflowY === 'visible')) {
if (overflowX === 'scroll' || overflowY === 'scroll') {
return ($el.innerHeight() < el.scrollHeight ||
$el.innerWidth() < el.scrollWidth);
Utils.escapeMarkup = function (markup) {
// Do not try to escape the markup if it's not a string
if (typeof markup !== 'string') {
return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
return replaceMap[match];
// Append an array of jQuery nodes to a given element.
Utils.appendMany = function ($element, $nodes) {
// jQuery 1.7.x does not support $.fn.append() with an array
// Fall back to a jQuery object collection using $.fn.add()
if ($.fn.jquery.substr(0, 3) === '1.7') {
$.map($nodes, function (node) {
$jqNodes = $jqNodes.add(node);
S2.define('pumselect2/results',[
function Results ($element, options, dataAdapter) {
this.$element = $element;
Results.__super__.constructor.call(this);
Utils.Extend(Results, Utils.Observable);
Results.prototype.render = function () {
'<ul class="pumselect2-results__options" role="tree"></ul>'
if (this.options.get('multiple')) {
$results.attr('aria-multiselectable', 'true');
this.$results = $results;
Results.prototype.clear = function () {
Results.prototype.displayMessage = function (params) {
var escapeMarkup = this.options.get('escapeMarkup');
'<li role="treeitem" aria-live="assertive"' +
' class="pumselect2-results__option"></li>'
var message = this.options.get('translations').get(params.message);
$message[0].className += ' pumselect2-results__message';
this.$results.append($message);
Results.prototype.hideMessages = function () {
this.$results.find('.pumselect2-results__message').remove();
Results.prototype.append = function (data) {
if (data.results == null || data.results.length === 0) {
if (this.$results.children().length === 0) {
this.trigger('results:message', {
data.results = this.sort(data.results);
for (var d = 0; d < data.results.length; d++) {
var item = data.results[d];
var $option = this.option(item);
this.$results.append($options);
Results.prototype.position = function ($results, $dropdown) {
var $resultsContainer = $dropdown.find('.pumselect2-results');
$resultsContainer.append($results);
Results.prototype.sort = function (data) {
var sorter = this.options.get('sorter');
Results.prototype.setClasses = function () {
this.data.current(function (selected) {
var selectedIds = $.map(selected, function (s) {
var $options = self.$results
.find('.pumselect2-results__option[aria-selected]');
$options.each(function () {
var item = $.data(this, 'data');
// id needs to be converted to a string when comparing
if ((item.element != null && item.element.selected) ||
(item.element == null && $.inArray(id, selectedIds) > -1)) {
$option.attr('aria-selected', 'true');
$option.attr('aria-selected', 'false');
var $selected = $options.filter('[aria-selected=true]');
// Check if there are any selected options
if ($selected.length > 0) {
// If there are selected options, highlight the first
$selected.first().trigger('mouseenter');
// If there are no selected options, highlight the first option
$options.first().trigger('mouseenter');
Results.prototype.showLoading = function (params) {
var loadingMore = this.options.get('translations').get('searching');
text: loadingMore(params)
var $loading = this.option(loading);
$loading.className += ' loading-results';
this.$results.prepend($loading);
Results.prototype.hideLoading = function () {
this.$results.find('.loading-results').remove();
Results.prototype.option = function (data) {
var option = document.createElement('li');
option.className = 'pumselect2-results__option';
delete attrs['aria-selected'];
attrs['aria-disabled'] = 'true';
delete attrs['aria-selected'];
if (data._resultId != null) {
option.id = data._resultId;
option.title = data.title;
attrs['aria-label'] = data.text;
delete attrs['aria-selected'];
for (var attr in attrs) {
option.setAttribute(attr, val);
var label = document.createElement('strong');
label.className = 'pumselect2-results__group';
this.template(data, label);
for (var c = 0; c < data.children.length; c++) {
var child = data.children[c];
var $child = this.option(child);
var $childrenContainer = $('<ul></ul>', {
'class': 'pumselect2-results__options pumselect2-results__options--nested'
$childrenContainer.append($children);
$option.append($childrenContainer);
this.template(data, option);
$.data(option, 'data', data);
Results.prototype.bind = function (container, $container) {
var id = container.id + '-results';
this.$results.attr('id', id);
container.on('results:all', function (params) {
self.append(params.data);
if (container.isOpen()) {
container.on('results:append', function (params) {
self.append(params.data);
if (container.isOpen()) {
container.on('query', function (params) {
self.showLoading(params);
container.on('select', function () {
if (!container.isOpen()) {