Permalink
Browse files

+ full back/forward search button support (FYI triggers a full search…

… when clicked)
  • Loading branch information...
1 parent 6bab4b2 commit e7ac35e0c95026e511a36279290ca0bee742d1fa @floere committed Feb 7, 2012

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
@@ -2,10 +2,11 @@ var PickyController = function(config) {
var view = new PickyView(this, config);
- var backends = config.backends;
- var beforeCallback = config.before || function(query, params) { };
- var successCallback = config.success || function(data, query) { };
- var afterCallback = config.after || function(data, query) { };
+ var backends = config.backends;
+ var beforeInsertCallback = config.beforeInsert || function(query) { };
+ var beforeCallback = config.before || function(query, params) { };
+ var successCallback = config.success || function(data, query) { };
+ var afterCallback = config.after || function(data, query) { };
var liveRendered = config.liveRendered || false;
var liveSearchTimerInterval = config.liveSearchInterval || 180;
@@ -103,9 +104,11 @@ var PickyController = function(config) {
liveSearchTimerId = setInterval(liveSearchTimerCallback, liveSearchTimerInterval);
clearInterval(liveSearchTimerId);
- //
+ // TODO Remove the full parameter?
//
var insert = function(query, params, full) {
+ query = beforeInsertCallback(query) || query;
+
view.insert(query);
if (full) { fullSearch(query, params); }
@@ -154,7 +157,10 @@ var PickyController = function(config) {
window.History.Adapter.bind(window, 'statechange', function() {
var state = window.History.getState();
var query = extractQuery(state.url);
- if (query && query != lastQuery()) { insert(query); }
+
+ // A back/forward is always a full query.
+ //
+ if (query && query != lastQuery()) { insert(query, {}, true); }
});
};
@@ -36,9 +36,11 @@ function Allocations(allocations) {
this.allocations.push(new_allocation);
}
this.length = this.allocations.length;
-
- this.each = function(callback) {
- return this.allocations.each(callback);
+ this.remove = function(index) {
+ this.allocations.splice(index, 1);
+ };
+ this.each = function(callback) {
+ this.allocations.each(callback);
};
};
@@ -209,11 +209,11 @@ var PickyView = function(picky_controller, config) {
// in the allocation cloud.
//
var allocationChosen = function(event) {
- var text = event.data.query;
+ var query = event.data.query;
- searchField.val(text);
+ controller.insert(query);
- controller.allocationChosen(text);
+ controller.allocationChosen(query);
};
this.allocationChosen = allocationChosen;
@@ -2,10 +2,11 @@ var PickyController = function(config) {
var view = new PickyView(this, config);
- var backends = config.backends;
- var beforeCallback = config.before || function(query, params) { };
- var successCallback = config.success || function(data, query) { };
- var afterCallback = config.after || function(data, query) { };
+ var backends = config.backends;
+ var beforeInsertCallback = config.beforeInsert || function(query) { };
+ var beforeCallback = config.before || function(query, params) { };
+ var successCallback = config.success || function(data, query) { };
+ var afterCallback = config.after || function(data, query) { };
var liveRendered = config.liveRendered || false;
var liveSearchTimerInterval = config.liveSearchInterval || 180;
@@ -103,9 +104,11 @@ var PickyController = function(config) {
liveSearchTimerId = setInterval(liveSearchTimerCallback, liveSearchTimerInterval);
clearInterval(liveSearchTimerId);
- //
+ // TODO Remove the full parameter?
//
var insert = function(query, params, full) {
+ query = beforeInsertCallback(query) || query;
+
view.insert(query);
if (full) { fullSearch(query, params); }
@@ -154,7 +157,10 @@ var PickyController = function(config) {
window.History.Adapter.bind(window, 'statechange', function() {
var state = window.History.getState();
var query = extractQuery(state.url);
- if (query && query != lastQuery()) { insert(query); }
+
+ // A back/forward is always a full query.
+ //
+ if (query && query != lastQuery()) { insert(query, {}, true); }
});
};
@@ -36,9 +36,11 @@ function Allocations(allocations) {
this.allocations.push(new_allocation);
}
this.length = this.allocations.length;
-
- this.each = function(callback) {
- return this.allocations.each(callback);
+ this.remove = function(index) {
+ this.allocations.splice(index, 1);
+ };
+ this.each = function(callback) {
+ this.allocations.each(callback);
};
};
@@ -209,11 +209,11 @@ var PickyView = function(picky_controller, config) {
// in the allocation cloud.
//
var allocationChosen = function(event) {
- var text = event.data.query;
+ var query = event.data.query;
- searchField.val(text);
+ controller.insert(query);
- controller.allocationChosen(text);
+ controller.allocationChosen(query);
};
this.allocationChosen = allocationChosen;
Oops, something went wrong.

0 comments on commit e7ac35e

Please sign in to comment.