// pz2.js event handlers:
mkdru.pz2Init = function () {
if (mkdru.state.query) {
- mkdru.triggerSearch();
+ mkdru.search();
}
//mkdru.pz2.stat();
//mkdru.pz2.bytarget();
-// UI functions:
+//search bo handler ONLY
mkdru.submitQuery = function () {
mkdru.state.query = $('.mkdru-search input:text').attr('value');
- mkdru.resetPage();
mkdru.pollDropDowns();
+ mkdru.resetPage();
mkdru.hashFromState();
mkdru.search();
mkdru.submitted = true;
return false;
};
-mkdru.triggerSearch = function () {
- mkdru.search();
- mkdru.submitted = true;
-};
+//criteria drop-downs (perpage,sort) handler ONLY
+mkdru.submitCriteria = function () {
+ mkdru.pollDropDowns();
+ //search is not ON, do nothing
+ if (!mkdru.submitted) return false;
+ mkdru.resetPage();
+ mkdru.hashFromState();
+ mkdru.pz2.show(0, mkdru.state.perpage, mkdru.state.sort);
+ return false;
+}
mkdru.search = function () {
mkdru.pz2.search(mkdru.state.query, mkdru.state.perpage, mkdru.state.sort,
mkdru.state.filter);
+ //inform others that the search is ON
+ mkdru.submitted = true;
};
mkdru.pollDropDowns = function () {
mkdru.state.perpage = $('.mkdru-perpage').attr('value');
mkdru.state.sort = $('.mkdru-sort').attr('value');
- if (!mkdru.submitted) return false;
- mkdru.resetPage();
- mkdru.hashFromState();
- return false;
};
+//TODO it's rude to mess with user's query, we should have a breadcrumb
mkdru.limitQuery = function (field, value) {
$('.mkdru-search input:text').attr('value', function () {
return this.value += ' and ' + field + '="' + value + '"';
+ name + '</a>';
navi.innerHTML += '<hr/>';
mkdru.state.filter = 'pz:id=' + id;
- mkdru.resetPage();
mkdru.pollDropDowns();
+ mkdru.resetPage();
+ mkdru.hashFromState();
mkdru.search();
return false;
};
$(window).bind( 'hashchange', mkdru.hashChange);
$('.mkdru-search').bind('submit', mkdru.submitQuery);
$('.mkdru-search input:text').attr('value', '');
- $('.mkdu-perpage').bind('change', function () {
- mkdru.pollDropDowns();
- mkdru.pz2.show(0, mkdru.state.perpage, mkdru.state.sort);
- });
- $('.mkdru-sort').bind('change', function () {
- mkdru.pollDropDowns();
- mkdru.pz2.show(0, mkdru.state.perpage, mkdru.state.sort);
- });
+ $('.mkdru-perpage').bind('change', mkdru.submitCriteria);
+ $('.mkdru-sort').bind('change', mkdru.submitCriteria);
mkdru.pz2 = new pz2( { "onshow": mkdru.pz2Show,
"showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way
mkdru.pz2.record(mkdru.state.recid);
}
else if (mkdru.state.query) {
- mkdru.triggerSearch();
+ mkdru.search();
}
});