that.set_sortOrder = function(val) { m_state.sort = val };
that.set_perpage = function(val) { m_state.size = val };
+ m_state.sort = config.sort_default;
+ m_state.size = config.perpage_default;
+
+ var m_default = $.extend(true, {}, m_state);
+ var tmp = m_default.filters;
+ delete m_default.filters;
+ $.extend(m_default, tmp.fragmentItems());
+
+ that.urlFragment = function(overrides) {
+ var s;
+
+ // Expand the filterSet into a set of key=value properties
+ var state = $.extend(true, {}, m_state);
+ $.extend(state, overrides ? overrides : {});
+ var tmp = state.filters;
+ delete state.filters;
+ $.extend(state, tmp.fragmentItems());
+
+ for (var key in state) {
+ if (state.hasOwnProperty(key) &&
+ state[key] != m_default[key]) {
+ if (!s) {
+ var s = 'mkws';
+ if (m_teamName !== 'AUTO') s += m_teamName;
+ s += '=';
+ } else {
+ s += "@";
+ }
+
+ // ### how do we need to quote this?
+ s += key + '=' + state[key];
+ }
+ }
+
+ return s;
+ }
+
+ // ### what quoting do we need to undo? Complement of previous function
+ that.parseFragment = function(s) {
+ var x = {};
+
+ var list = s.split('@');
+ for (var i in list) {
+ var a = list[i].split('=');
+ x[a[0]] = a[1];
+ }
+
+ return x;
+ }
+
+ that.handleChanges = function(oldState, newState) {
+ for (var key in newState) {
+ var val = newState[key];
+ if (newState.hasOwnProperty(key) &&
+ (!oldState || val != oldState[key])) {
+ that.warn("changed property " + key + ": " +
+ (oldState ? ("'" + oldState[key] + "'") : "undefined") +
+ " -> '" + val + "'");
+ if (key === 'page') {
+ that.showPage(parseInt(val));
+ } else if (key === 'sort') {
+ that.set_sortOrder(val);
+ if (that.submitted()) {
+ that.reShow();
+ }
+ } else if (key === 'size') {
+ that.set_perpage(val);
+ if (that.submitted()) {
+ that.reShow();
+ }
+ }
+ }
+ }
+ };
+
// The following PubSub code is modified from the jQuery manual:
// http://api.jquery.com/jQuery.Callbacks/
that.info("making new widget team");
- m_state.sort = config.sort_default;
- m_state.size = config.perpage_default;
-
// pz2.js event handlers:
function onInit() {
that.info("init");
that.showPage = function(pageNum) {
m_state.page = pageNum;
m_paz.showPage(m_state.page - 1);
+ that.warn("fragment: " + that.urlFragment());
};
if (m_totalRecordCount - m_state.size * m_state.page > 0) {
m_paz.showNext();
m_state.page++;
+ that.warn("fragment: " + that.urlFragment());
}
};
that.pagerPrev = function() {
- if (m_paz.showPrev() != false)
+ if (m_paz.showPrev() != false) {
m_state.page--;
+ that.warn("fragment: " + that.urlFragment());
+ }
};
that.reShow = function() {
resetPage();
m_paz.show(0, m_state.size, m_state.sort);
+ // ### not really the right place for this but it will do for now.
+ that.warn("fragment: " + that.urlFragment());
};
m_paz.search(m_state.query, m_state.size, m_state.sort, pp2filter, undefined, params);
queue("searchtriggered").publish();
+
+ // ### not really the right place for this but it will do for now.
+ that.warn("fragment: " + that.urlFragment());
}
// fetch record details to be retrieved from the record queue
that.fetchDetails = function(recId) {
that.info("fetchDetails() requesting record '" + recId + "'");
m_paz.record(recId);
+ that.warn("fragment: " + that.urlFragment());
};