1 // $Id$ 2 3 /** 4 * A parameter store that stores the values of exposed parameters using the YUI 5 * History Manager to maintain the application's state. Don't forget to add the 6 * following inside your <tt>head</tt> tag: 7 * 8 * <pre> 9 * <script src="http://yui.yahooapis.com/2.9.0/build/yahoo/yahoo-min.js"></script> 10 * <script src="http://yui.yahooapis.com/2.9.0/build/event/event-min.js"></script> 11 * <script src="http://yui.yahooapis.com/2.9.0/build/history/history-min.js"></script> 12 * </pre> 13 * 14 * And the following inside your <tt>body</tt> tag: 15 * 16 * <pre> 17 * <iframe id="yui-history-iframe" src="path-to-existing-asset" style="position:absolute;top:0;left:0;width:1px;height:1px;visibility:hidden"></iframe> 18 * <input id="yui-history-field" type="hidden"> 19 * </pre> 20 * 21 * @see http://developer.yahoo.com/yui/history/ 22 * @class ParameterYUIStore 23 * @augments AjaxSolr.ParameterStore 24 */ 25 AjaxSolr.ParameterYUIStore = AjaxSolr.ParameterStore.extend( 26 /** @lends AjaxSolr.ParameterYUIStore.prototype */ 27 { 28 29 /** 30 * The name of the YUI History Manager module to use for the parameter store. 31 * 32 * @field 33 * @public 34 * @type String 35 * @default 'q' 36 */ 37 module: 'q', 38 39 /** 40 * Whether the YUI History Manager is initialized. 41 * 42 * @field 43 * @private 44 * @type Boolean 45 * @default false 46 */ 47 initialized: false, 48 49 /** 50 * Initializes the YUI History Manager. 51 */ 52 init: function () { 53 if (this.exposed.length) { 54 var self = this; 55 YAHOO.util.History.register(this.module, YAHOO.util.History.getBookmarkedState(this.module) || this.exposedString(), function () { 56 self.load(); 57 self.manager.doRequest(); 58 }); 59 YAHOO.util.History.onReady(function () { 60 self.initialized = true; 61 self.load(); 62 self.manager.doRequest(); 63 }); 64 YAHOO.util.History.initialize('yui-history-field', 'yui-history-iframe'); 65 } 66 }, 67 68 /** 69 * Stores the values of the exposed parameters in the YUI History Manager. 70 */ 71 save: function () { 72 YAHOO.util.History.navigate(this.module, this.exposedString()); 73 }, 74 75 /** 76 * @see ParameterStore#storedString() 77 */ 78 storedString: function () { 79 return this.initialized ? YAHOO.util.History.getCurrentState(this.module) : this.exposedString(); 80 } 81 }); 82