Socket
Socket
Sign inDemoInstall

bbop-widget-solr-autocomplete

Package Overview
Dependencies
18
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.8 to 0.0.9

examples/angularjs/angular-example-compiled.js

231

lib/bbop-widget-solr-autocomplete.js

@@ -6,139 +6,124 @@ var jQuery = require('jquery')

(function(factory) {
// If there is a variable named module and it has an exports property,
// then we're working in a Node-like environment. Use require to load
// the jQuery object that the module system is using and pass it in.
// Otherwise, we're working in a browser, so just pass in the global jQuery object.
if (typeof module === "object" && typeof module.exports === "object") {
module.exports = factory(require("jquery"), window, document);
} else {
factory(jQuery, window, document);
}
}
var createSolrAutocompleteForElement = function(element, options) {
var jqElement = jQuery(element);
//console.log('Creating solr-autocomplete widget for ' + element);
jqElement.solrautocomplete(options);
};
(function(jQuery, window, document, __undefined__) {
var createSolrAutocompleteForElement = function(element, options) {
var jqElement = jQuery(element);
console.log('Creating solr-autocomplete widget for ' + element);
jqElement.solrautocomplete(options);
};
window.Solrautocomplete = {
createSolrAutocompleteForElement: createSolrAutocompleteForElement
};
window.Solrautocomplete = {
createSolrAutocompleteForElement: createSolrAutocompleteForElement
};
// Depends on selectize
jQuery.widget('bbop-widget.solrautocomplete', {
options: {
webserviceUrl: "http://localhost:8983/solr/select",
onChange: console.log,
required: false,
optionDisplay: null,
itemDisplay: null,
valueField: null,
searchField: null,
queryData: null,
golrManager: null,
maxItems: 1
},
jQuery.widget('bbop-widget.solrautocomplete', {
options: {
webserviceUrl: "http://localhost:8983/solr/select",
onChange: console.log,
required: false,
optionDisplay: null,
itemDisplay: null,
valueField: null,
searchField: null,
queryData: null,
golrManager: null,
maxItems: 1
},
_create: function() {
// redefine the variables to avoid conflicts with selectize's scope
var widgetOnChange = this.options.onChange;
var widgetWebservicerUrl = this.options.webserviceUrl;
var widgetRequired = this.options.required;
var widgetOptionDisplay = this.options.optionDisplay;
var widgetItemDisplay = this.options.itemDisplay;
var widgetValueField = this.options.valueField;
var widgetSearchField = this.options.searchField;
var widgetQueryData = this.options.queryData;
var widgetGolrManager = this.options.golrManager;
var widgetMaxItems = this.options.maxItems;
var _currentValue = null;
_create: function() {
// redefine the variables to avoid conflicts with selectize's scope
var widgetOnChange = this.options.onChange;
var widgetWebservicerUrl = this.options.webserviceUrl;
var widgetRequired = this.options.required;
var widgetOptionDisplay = this.options.optionDisplay;
var widgetItemDisplay = this.options.itemDisplay;
var widgetValueField = this.options.valueField;
var widgetSearchField = this.options.searchField;
var widgetQueryData = this.options.queryData;
var widgetGolrManager = this.options.golrManager;
var widgetMaxItems = this.options.maxItems;
var _currentValue = null;
// Right label for user feedback
var feedbackLabel = jQuery('<div style="width:130px;padding-left:15px;"></div>');
this.element.after(feedbackLabel);
// Right label for user feedback
var feedbackLabel = jQuery('<div style="width:130px;padding-left:15px;"></div>');
this.element.after(feedbackLabel);
var selectized = this.element.selectize({
valueField: widgetValueField,
searchField: widgetSearchField,
create: false,
render: {
option: widgetOptionDisplay,
item: widgetItemDisplay
},
load: function(query, callback) {
if (!query.length) return callback();
var selectized = this.element.selectize({
valueField: widgetValueField,
searchField: widgetSearchField,
create: false,
render: {
option: widgetOptionDisplay,
item: widgetItemDisplay
},
load: function(query, callback) {
if (!query.length) return callback();
var customCallBack = function(res) {
_updateHits(res._raw.response.numFound);
callback(res._raw.response.docs);
};
widgetGolrManager.register('search', 'foo', customCallBack);
widgetGolrManager.set_query(widgetQueryData(query));
widgetGolrManager.search();
var customCallBack = function(res) {
_updateHits(res._raw.response.numFound);
callback(res._raw.response.docs);
};
widgetGolrManager.register('search', 'foo', customCallBack);
widgetGolrManager.set_query(widgetQueryData(query));
widgetGolrManager.search();
// jQuery.ajax({
// url: widgetWebservicerUrl,
// data: widgetQueryData(query),
// dataType: 'jsonp',
// jsonp: 'json.wrf',
// error: function() {
// callback();
// },
// success: function(res) {
// _updateHits(res.response.numFound);
// //TODO load underscore.js
// //var uniq_only = _.uniq(res.response.docs) // remove potential duplicates
// //callback(uniq_only);
// callback(res.response.docs);
// }
// });
},
onChange: function(value) {
widgetOnChange(value);
_checkSanity(value);
_currentValue = value;
},
onType: function(str) {
if (widgetMaxItems == 1) {
_clearCache(); // in order to request the server at each typing, only for single items
}
},
onBlur: function() {
_checkSanity(_currentValue);
},
maxItems: widgetMaxItems
});
// jQuery.ajax({
// url: widgetWebservicerUrl,
// data: widgetQueryData(query),
// dataType: 'jsonp',
// jsonp: 'json.wrf',
// error: function() {
// callback();
// },
// success: function(res) {
// _updateHits(res.response.numFound);
// //TODO load underscore.js
// //var uniq_only = _.uniq(res.response.docs) // remove potential duplicates
// //callback(uniq_only);
// callback(res.response.docs);
// }
// });
},
onChange: function(value) {
widgetOnChange(value);
_checkSanity(value);
_currentValue = value;
},
onType: function(str) {
if (widgetMaxItems == 1) {
_clearCache(); // in order to request the server at each typing, only for single items
}
},
onBlur: function() {
_checkSanity(_currentValue);
},
maxItems: widgetMaxItems
});
var _checkSanity = function(value) {
if (widgetRequired && (value == null || value == "")) {
feedbackLabel.text('Cannot be empty!');
} else {
feedbackLabel.text('');
}
var _checkSanity = function(value) {
if (widgetRequired && (value == null || value == "")) {
feedbackLabel.text('Cannot be empty!');
} else {
feedbackLabel.text('');
}
}
var _clearCache = function() {
selectized[0].selectize.clearCache("option");
selectized[0].selectize.clearOptions();
};
var _clearCache = function() {
selectized[0].selectize.clearCache("option");
selectized[0].selectize.clearOptions();
};
var _updateHits = function(h) {
feedbackLabel.text(h + ' hits');
};
var _updateHits = function(h) {
feedbackLabel.text(h + ' hits');
};
},
},
_destroy: function() {
selectized[0].selectize.destroy();
},
_destroy: function() {
selectized[0].selectize.destroy();
},
_setOptions: function(options) {
this._super(options);
this.refresh();
}
});
}));
_setOptions: function(options) {
this._super(options);
this.refresh();
}
});
{
"name": "bbop-widget-solr-autocomplete",
"version": "0.0.8",
"version": "0.0.9",
"license": "BSD-2-Clause",

@@ -5,0 +5,0 @@ "description": "Autocomplete widget for Solr.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc