Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix comments, whitespace

  • Loading branch information...
commit 119b0eb71d29db2edb47da641929fb9dada0ea5c 1 parent 6e8d344
James McKinney jpmckinney authored
Showing with 15 additions and 20 deletions.
  1. +4 −7 core/ParameterHashStore.js
  2. +11 −13 widgets/ParameterHistoryStore.js
11 core/ParameterHashStore.js
View
@@ -59,10 +59,8 @@ AjaxSolr.ParameterHashStore = AjaxSolr.ParameterStore.extend(
*/
init: function () {
if (this.exposed.length) {
- // Check if the browser supports the onhashchange event
- // IE 8 and 9 in compatibility mode report that they support onhashchange when they
- // really don't - Check document.documentMode to ensure it's undefined or greater
- // than 7.
+ // Check if the browser supports the onhashchange event. IE 8 and 9 in compatibility mode
+ // incorrectly report support for onhashchange.
if ('onhashchange' in window && (!document.documentMode || document.documentMode > 7)) {
if (window.addEventListener) {
window.addEventListener('hashchange', this.intervalFunction(this), false);
@@ -75,7 +73,6 @@ AjaxSolr.ParameterHashStore = AjaxSolr.ParameterStore.extend(
}
}
else {
- // No onhashchange event so fall back to timer
this.intervalId = window.setInterval(this.intervalFunction(this), this.interval);
}
}
@@ -88,11 +85,11 @@ AjaxSolr.ParameterHashStore = AjaxSolr.ParameterStore.extend(
save: function () {
this.hash = this.exposedString();
if (this.storedString()) {
- // make a new history entry
+ // Make a new history entry.
window.location.hash = this.hash;
}
else {
- // replace the old history entry
+ // Replace the old history entry.
window.location.replace(window.location.href.replace('#', '') + '#' + this.hash);
}
},
24 widgets/ParameterHistoryStore.js
View
@@ -25,15 +25,14 @@
{
init: function () {
if (this.exposed.length) {
- // Ensure History.js is loaded
if (!history) {
- throw new Error('ParameterHistoryStore requires History.js to be loaded');
+ throw 'ParameterHistoryStore requires History.js';
}
-
+
history.Adapter.bind(window, 'statechange', this.stateChangeFunction(this));
}
},
-
+
/**
* Stores the values of the exposed parameters in both the local hash and History.js
* No other code should be made to change these two values.
@@ -42,19 +41,19 @@
this.hash = this.exposedString();
history.pushState({ params: this.hash }, null, '?' + this.hash);
},
-
+
/**
* @see ParameterStore#storedString()
*/
storedString: function () {
var state = history.getState();
-
- // Check for state in the history object
+
+ // Load the state from the History object.
if (state.data && state.data.params) {
return state.data.params;
}
-
- // No state (eg. initial load), get state from URL
+
+ // If initial load, load the state from the URL.
var url = state.cleanUrl, index = url.indexOf('?');
if (index == -1) {
return '';
@@ -63,7 +62,7 @@
return url.substr(index + 1);
}
},
-
+
/**
* Called when History.js detects a state change. Checks if state is different to previous state,
* and if so, sends a request to Solr. This needs to check if the state has changed since it also
@@ -72,8 +71,7 @@
stateChangeFunction: function (self) {
return function () {
var hash = self.storedString();
-
- // Check if URL has changed since last request (ie. using back/forward navigation)
+
if (self.hash != hash) {
self.load();
self.manager.doRequest();
@@ -81,4 +79,4 @@
}
}
});
-})(window.History);
+})(window.History);
Please sign in to comment.
Something went wrong with that request. Please try again.