1 (function (callback) { 2 if (typeof define === 'function' && define.amd) { 3 define(['core/Core'], callback); 4 } 5 else { 6 callback(); 7 } 8 }(function () { 9 10 /** 11 * Baseclass for all widgets. 12 * 13 * Provides abstract hooks for child classes. 14 * 15 * @param properties A map of fields to set. May be new or public fields. 16 * @class AbstractWidget 17 */ 18 AjaxSolr.AbstractWidget = AjaxSolr.Class.extend( 19 /** @lends AjaxSolr.AbstractWidget.prototype */ 20 { 21 /** 22 * @param {Object} attributes 23 * @param {String} attributes.id A unique identifier of this widget. 24 * @param {String} [attributes.target] The CSS selector for this widget's 25 * target HTML element, e.g. a specific <tt>div</tt> or <tt>ul</tt>. A 26 * Widget is usually implemented to perform all its UI changes relative to 27 * its target HTML element. 28 * @param {Number} [attributes.start] The offset parameter. Set this field to 29 * make the widget reset the offset parameter to the given value on each 30 * request. 31 * @param {String} [attributes.servlet] The Solr servlet for this widget. You 32 * may prepend the servlet with a core if using multiple cores. If none is 33 * set, it will default to the manager's servlet. 34 */ 35 constructor: function (attributes) { 36 AjaxSolr.extend(this, { 37 id: null, 38 target: null, 39 start: undefined, 40 servlet: undefined, 41 // A reference to the widget's manager. 42 manager: null 43 }, attributes); 44 }, 45 46 /** 47 * An abstract hook for child implementations. 48 * 49 * <p>This method should do any necessary one-time initializations.</p> 50 */ 51 init: function () {}, 52 53 /** 54 * An abstract hook for child implementations. 55 * 56 * <p>This method is executed before the Solr request is sent.</p> 57 */ 58 beforeRequest: function () {}, 59 60 /** 61 * An abstract hook for child implementations. 62 * 63 * <p>This method is executed after the Solr response is received.</p> 64 */ 65 afterRequest: function () {}, 66 67 /** 68 * A proxy to the manager's doRequest method. 69 * 70 * @param {Boolean} [start] The Solr start offset parameter. 71 * @param {String} [servlet] The Solr servlet to send the request to. 72 */ 73 doRequest: function (start, servlet) { 74 this.manager.doRequest(start || this.start, servlet || this.servlet); 75 } 76 }); 77 78 })); 79