author | Michael Krelin <hacker@klever.net> | 2006-10-01 23:53:31 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-10-01 23:53:31 (UTC) |
commit | b6a122d536aef024b69d40cdf2ac0332d7c14607 (patch) (unidiff) | |
tree | 5b6f01eb73f858e6caaf22301e23d7b6b996ffea | |
parent | 455df70118b045c6053b33ae2f0318a70e4f96b8 (diff) | |
download | fireflix-b6a122d536aef024b69d40cdf2ac0332d7c14607.zip fireflix-b6a122d536aef024b69d40cdf2ac0332d7c14607.tar.gz fireflix-b6a122d536aef024b69d40cdf2ac0332d7c14607.tar.bz2 |
paginating through search results
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@179 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | content/fireflix-panel.xul | 13 | ||||
-rw-r--r-- | content/fireflix.css | 10 | ||||
-rw-r--r-- | content/fireflix.js | 50 | ||||
-rw-r--r-- | content/util.js | 7 | ||||
-rw-r--r-- | locale/en-US/fireflix.dtd | 2 | ||||
-rw-r--r-- | locale/en-US/fireflix.properties | 2 |
6 files changed, 79 insertions, 5 deletions
diff --git a/content/fireflix-panel.xul b/content/fireflix-panel.xul index 398dd78..bf6df73 100644 --- a/content/fireflix-panel.xul +++ b/content/fireflix-panel.xul | |||
@@ -50,2 +50,8 @@ | |||
50 | oncommand="fireflix.foundphotos.on_cmd_open(event)" /> | 50 | oncommand="fireflix.foundphotos.on_cmd_open(event)" /> |
51 | <command id="cmd_search_prev_page" | ||
52 | label="&panel.search.cmd_search_prev_page.label;" | ||
53 | oncommand="fireflix.foundphotos.on_cmd_prev(event)" disabled="true"/> | ||
54 | <command id="cmd_search_next_page" | ||
55 | label="&panel.search.cmd_search_next_page.label;" | ||
56 | oncommand="fireflix.foundphotos.on_cmd_next(event)" disabled="true"/> | ||
51 | </commandset> | 57 | </commandset> |
@@ -132,2 +138,9 @@ | |||
132 | </groupbox> | 138 | </groupbox> |
139 | <hbox> | ||
140 | <button command="cmd_search_prev_page"/> | ||
141 | <spacer flex="1"/> | ||
142 | <label id="search_page" hidden="true"/> | ||
143 | <spacer flex="1"/> | ||
144 | <button command="cmd_search_next_page"/> | ||
145 | </hbox> | ||
133 | <tree id="searchresults" rows="2" flex="1" | 146 | <tree id="searchresults" rows="2" flex="1" |
diff --git a/content/fireflix.css b/content/fireflix.css index 71080d1..9e7bf6b 100644 --- a/content/fireflix.css +++ b/content/fireflix.css | |||
@@ -89 +89,11 @@ div#searchresult_description { | |||
89 | } | 89 | } |
90 | |||
91 | label#search_page { | ||
92 | font-weight: bold; | ||
93 | background: white; color: #404040; | ||
94 | border-color: #c0c0c0 #404040 #404040 #c0c0c0; | ||
95 | border-style: solid; | ||
96 | border-width: 1px; | ||
97 | -moz-border-radius: 1em; | ||
98 | padding: 0.5ex 1ex; | ||
99 | } | ||
diff --git a/content/fireflix.js b/content/fireflix.js index e144aae..92c42f4 100644 --- a/content/fireflix.js +++ b/content/fireflix.js | |||
@@ -694,3 +694,4 @@ var fireflix = { | |||
694 | 'searchresult_props','search_photo', | 694 | 'searchresult_props','search_photo', |
695 | 'searchresult_title','searchresult_description' | 695 | 'searchresult_title','searchresult_description', |
696 | 'search_page','cmd_search_prev_page','cmd_search_next_page' | ||
696 | ]); | 697 | ]); |
@@ -731,2 +732,6 @@ var fireflix = { | |||
731 | }, | 732 | }, |
733 | paging: { | ||
734 | pars: null, | ||
735 | page: null, pages: null, perpage: null, total: null | ||
736 | }, | ||
732 | search_photos: function() { | 737 | search_photos: function() { |
@@ -744,11 +749,22 @@ var fireflix = { | |||
744 | } | 749 | } |
750 | this.paging.pars = new Object(); | ||
751 | this.paging.page = null; this.paging.pages = null; | ||
752 | this.paging.perpage = null; this.paging.total = null; | ||
753 | for(var p in pars) this.paging.pars[p] = pars[p]; | ||
754 | this.perform_search(pars); | ||
755 | }, | ||
756 | perform_search: function(p) { | ||
745 | var _this = this; | 757 | var _this = this; |
746 | this.fireflix.flickr.api_call( pars, | 758 | this.fireflix.flickr.api_call( p, |
747 | function(xr) { | 759 | function(xr) { |
748 | var x = xr.responseXML; | 760 | var x = xr.responseXML; |
749 | var xp = x.evaluate( | 761 | var xp = xp_nodes('/rsp/photos/photo',x); |
750 | '/rsp/photos/photo', x, null, | ||
751 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); | ||
752 | _this.importXPR(xp); | 762 | _this.importXPR(xp); |
753 | _this.tree.ensureRowIsVisible(0); | 763 | _this.tree.ensureRowIsVisible(0); |
764 | xp = xp_node('/rsp/photos',x); | ||
765 | _this.paging.page = parseInt(xp.getAttribute('page')); | ||
766 | _this.paging.pages = parseInt(xp.getAttribute('pages')); | ||
767 | _this.paging.perpage = parseInt(xp.getAttribute('perpage')); | ||
768 | _this.paging.total = parseInt(xp.getAttribute('total')); | ||
769 | _this.update_paging(); | ||
754 | _this.on_select(); | 770 | _this.on_select(); |
@@ -759,2 +775,26 @@ var fireflix = { | |||
759 | }, | 775 | }, |
776 | on_cmd_prev: function(ev) { | ||
777 | var pars = new Object(); | ||
778 | for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; | ||
779 | pars.page=this.paging.page-1; pars.per_page=this.paging.perpage; | ||
780 | this.perform_search(pars); | ||
781 | }, | ||
782 | on_cmd_next: function(ev) { | ||
783 | var pars = new Object(); | ||
784 | for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; | ||
785 | pars.page=this.paging.page+1; pars.per_page=this.paging.perpage; | ||
786 | this.perform_search(pars); | ||
787 | }, | ||
788 | update_paging: function() { | ||
789 | if(! (this.paging.pars && this.paging.page && this.paging.pages) ) { | ||
790 | this.search_page.value=''; this.search_page.hidden = true; | ||
791 | this.cmd_search_prev_page.setAttribute('disabled','true'); | ||
792 | this.cmd_search_next_page.setAttribute('disabled','true'); | ||
793 | }else{ | ||
794 | this.search_page.value=this.fireflix.loc_strings.getFormattedString('search_page',[this.paging.page,this.paging.pages]); | ||
795 | this.search_page.hidden=false; | ||
796 | this.cmd_search_prev_page.setAttribute('disabled',(this.paging.page>1)?'false':'true'); | ||
797 | this.cmd_search_next_page.setAttribute('disabled',(this.paging.page<this.paging.pages)?'false':'true'); | ||
798 | } | ||
799 | }, | ||
760 | render_description_frame: function(content) { | 800 | render_description_frame: function(content) { |
diff --git a/content/util.js b/content/util.js index c4af09e..ccc61cf 100644 --- a/content/util.js +++ b/content/util.js | |||
@@ -60,2 +60,9 @@ function xp_node(xp,x) { | |||
60 | } | 60 | } |
61 | /* | ||
62 | * extract xpath-specified ordered set of nodes | ||
63 | */ | ||
64 | function xp_nodes(xp,x) { | ||
65 | return x.evaluate( | ||
66 | xp, x, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); | ||
67 | } | ||
61 | 68 | ||
diff --git a/locale/en-US/fireflix.dtd b/locale/en-US/fireflix.dtd index f4ceb79..88ec6fb 100644 --- a/locale/en-US/fireflix.dtd +++ b/locale/en-US/fireflix.dtd | |||
@@ -37,2 +37,4 @@ | |||
37 | <!ENTITY panel.search.cmd_search_open.label "Open"> | 37 | <!ENTITY panel.search.cmd_search_open.label "Open"> |
38 | <!ENTITY panel.search.cmd_search_prev_page.label "«"> | ||
39 | <!ENTITY panel.search.cmd_search_next_page.label "»"> | ||
38 | 40 | ||
diff --git a/locale/en-US/fireflix.properties b/locale/en-US/fireflix.properties index 7caa12f..18300ff 100644 --- a/locale/en-US/fireflix.properties +++ b/locale/en-US/fireflix.properties | |||
@@ -11 +11,3 @@ urltype_o=Original image | |||
11 | urltype_p=Flickr photo URL | 11 | urltype_p=Flickr photo URL |
12 | |||
13 | search_page=Page %S of %S | ||