author | Michael Krelin <hacker@klever.net> | 2006-10-01 20:31:31 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-10-01 20:31:31 (UTC) |
commit | d9372f72e080857d52ef7e60b99d95b3b3cb6ad3 (patch) (unidiff) | |
tree | b54d61a4c39c6182da8a5c76e0e9b8c44958903e | |
parent | fa83ec27570f4d397aefeaa11e1f74b49b8d9402 (diff) | |
download | fireflix-d9372f72e080857d52ef7e60b99d95b3b3cb6ad3.zip fireflix-d9372f72e080857d52ef7e60b99d95b3b3cb6ad3.tar.gz fireflix-d9372f72e080857d52ef7e60b99d95b3b3cb6ad3.tar.bz2 |
scroll newly obtained search results to the top
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@174 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | content/fireflix.js | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/content/fireflix.js b/content/fireflix.js index 6681303..0f01d26 100644 --- a/content/fireflix.js +++ b/content/fireflix.js | |||
@@ -687,128 +687,129 @@ var fireflix = { | |||
687 | fireflix: null, | 687 | fireflix: null, |
688 | init: function(f) { | 688 | init: function(f) { |
689 | this.fireflix = f; | 689 | this.fireflix = f; |
690 | pull_elements(this,document,[ | 690 | pull_elements(this,document,[ |
691 | 'search_for','search_tags','search_mine', | 691 | 'search_for','search_tags','search_mine', |
692 | 'searchresult_props','search_photo', | 692 | 'searchresult_props','search_photo', |
693 | 'searchresult_title','searchresult_description' | 693 | 'searchresult_title','searchresult_description' |
694 | ]); | 694 | ]); |
695 | document.getElementById('searchresults').view = this; | 695 | document.getElementById('searchresults').view = this; |
696 | }, | 696 | }, |
697 | photos: new Array(), | 697 | photos: new Array(), |
698 | rowCount: 0, | 698 | rowCount: 0, |
699 | getCellText: function(r,c) { | 699 | getCellText: function(r,c) { |
700 | var p = this.photos[r]; | 700 | var p = this.photos[r]; |
701 | if(c.id=='sr_title') return p.title; | 701 | if(c.id=='sr_title') return p.title; |
702 | return c.id; | 702 | return c.id; |
703 | }, | 703 | }, |
704 | setTree: function(t) { this.tree = t }, | 704 | setTree: function(t) { this.tree = t }, |
705 | isContainer: function(r) { return false }, | 705 | isContainer: function(r) { return false }, |
706 | isSeparator: function(r) { return false }, | 706 | isSeparator: function(r) { return false }, |
707 | isSorted: function(r) { return false }, | 707 | isSorted: function(r) { return false }, |
708 | getLevel: function(r) { return 0 }, | 708 | getLevel: function(r) { return 0 }, |
709 | getImageSrc: function(r,c) { return null }, | 709 | getImageSrc: function(r,c) { return null }, |
710 | getRowProperties: function(r,p) { }, | 710 | getRowProperties: function(r,p) { }, |
711 | getCellProperties: function(cid,cel,p) { }, | 711 | getCellProperties: function(cid,cel,p) { }, |
712 | getColumnProperties: function(cid,cel,p) { }, | 712 | getColumnProperties: function(cid,cel,p) { }, |
713 | cycleHeader: function(cid,e) { }, | 713 | cycleHeader: function(cid,e) { }, |
714 | getParentIndex: function(r) { return -1 }, | 714 | getParentIndex: function(r) { return -1 }, |
715 | drop: function(r,o) { }, | 715 | drop: function(r,o) { }, |
716 | canDropBeforeAfter: function(r,b) { return false }, | 716 | canDropBeforeAfter: function(r,b) { return false }, |
717 | 717 | ||
718 | importXPR: function(xp) { | 718 | importXPR: function(xp) { |
719 | this.selection.clearSelection(); | 719 | this.selection.clearSelection(); |
720 | this.selection.currentIndex = -1; | 720 | this.selection.currentIndex = -1; |
721 | this.searchresult_props.hidden = true; | 721 | this.searchresult_props.hidden = true; |
722 | this.tree.beginUpdateBatch(); | 722 | this.tree.beginUpdateBatch(); |
723 | this.photos = new Array(); | 723 | this.photos = new Array(); |
724 | var n; while(n=xp.iterateNext()) { | 724 | var n; while(n=xp.iterateNext()) { |
725 | this.photos.push(new Photo(n)); | 725 | this.photos.push(new Photo(n)); |
726 | } | 726 | } |
727 | this.rowCount = this.photos.length; | 727 | this.rowCount = this.photos.length; |
728 | this.tree.endUpdateBatch(); | 728 | this.tree.endUpdateBatch(); |
729 | }, | 729 | }, |
730 | search_photos: function() { | 730 | search_photos: function() { |
731 | var pars = { | 731 | var pars = { |
732 | method: 'flickr.photos.search', | 732 | method: 'flickr.photos.search', |
733 | auth_token: 'default', | 733 | auth_token: 'default', |
734 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo' | 734 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo' |
735 | }; | 735 | }; |
736 | if(this.search_mine.checked) | 736 | if(this.search_mine.checked) |
737 | pars.user_id='me'; | 737 | pars.user_id='me'; |
738 | if(this.search_tags.checked) { | 738 | if(this.search_tags.checked) { |
739 | pars.tags=this.search_for.value.split(/ +/).join(','); | 739 | pars.tags=this.search_for.value.split(/ +/).join(','); |
740 | }else{ | 740 | }else{ |
741 | pars.text=this.search_for.value; | 741 | pars.text=this.search_for.value; |
742 | } | 742 | } |
743 | var _this = this; | 743 | var _this = this; |
744 | this.fireflix.flickr.api_call( pars, | 744 | this.fireflix.flickr.api_call( pars, |
745 | function(xr) { | 745 | function(xr) { |
746 | var x = xr.responseXML; | 746 | var x = xr.responseXML; |
747 | var xp = x.evaluate( | 747 | var xp = x.evaluate( |
748 | '/rsp/photos/photo', x, null, | 748 | '/rsp/photos/photo', x, null, |
749 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); | 749 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); |
750 | _this.importXPR(xp); | 750 | _this.importXPR(xp); |
751 | _this.tree.ensureRowIsVisible(0); | ||
751 | _this.on_select(); | 752 | _this.on_select(); |
752 | }, function(x,s,c,m) { | 753 | }, function(x,s,c,m) { |
753 | _this.fireflix.flickr_failure(x,s,c,m); | 754 | _this.fireflix.flickr_failure(x,s,c,m); |
754 | } | 755 | } |
755 | ); | 756 | ); |
756 | }, | 757 | }, |
757 | render_description_frame: function(content) { | 758 | render_description_frame: function(content) { |
758 | if(!content) { | 759 | if(!content) { |
759 | this.searchresult_description.innerHTML = ''; | 760 | this.searchresult_description.innerHTML = ''; |
760 | }else{ | 761 | }else{ |
761 | this.searchresult_description.innerHTML = content?content:''; | 762 | this.searchresult_description.innerHTML = content?content:''; |
762 | /* of all linking elements flickr only allows a */ | 763 | /* of all linking elements flickr only allows a */ |
763 | var as = this.searchresult_description.getElementsByTagName('a'); | 764 | var as = this.searchresult_description.getElementsByTagName('a'); |
764 | for(var a=0;a<as.length;++a) | 765 | for(var a=0;a<as.length;++a) |
765 | as.item(a).setAttribute('target','_blank'); | 766 | as.item(a).setAttribute('target','_blank'); |
766 | } | 767 | } |
767 | }, | 768 | }, |
768 | on_select: function() { | 769 | on_select: function() { |
769 | if(this.selection.currentIndex<0) { | 770 | if(this.selection.currentIndex<0) { |
770 | this.searchresult_props.hidden = true; | 771 | this.searchresult_props.hidden = true; |
771 | }else{ | 772 | }else{ |
772 | var p = this.photos[this.selection.currentIndex]; | 773 | var p = this.photos[this.selection.currentIndex]; |
773 | if(!p) { | 774 | if(!p) { |
774 | this.searchresult_props.hidden = true; | 775 | this.searchresult_props.hidden = true; |
775 | }else{ | 776 | }else{ |
776 | this.search_photo.src = this.fireflix.flickr.make_photo_url(p,'t'); | 777 | this.search_photo.src = this.fireflix.flickr.make_photo_url(p,'t'); |
777 | this.searchresult_title.value = p.title; | 778 | this.searchresult_title.value = p.title; |
778 | this.render_description_frame(null); | 779 | this.render_description_frame(null); |
779 | if(p.description==null && p.description==undefined) { | 780 | if(p.description==null && p.description==undefined) { |
780 | var pid = p.id; | 781 | var pid = p.id; |
781 | var ci = this.selection.currentIndex; | 782 | var ci = this.selection.currentIndex; |
782 | var _this = this; | 783 | var _this = this; |
783 | this.fireflix.flickr.api_call( | 784 | this.fireflix.flickr.api_call( |
784 | { | 785 | { |
785 | method: 'flickr.photos.getInfo', | 786 | method: 'flickr.photos.getInfo', |
786 | auth_token: 'default', | 787 | auth_token: 'default', |
787 | photo_id: p.id, | 788 | photo_id: p.id, |
788 | secret: p.secret | 789 | secret: p.secret |
789 | }, function(xr) { | 790 | }, function(xr) { |
790 | var pp = _this.photos[ci]; | 791 | var pp = _this.photos[ci]; |
791 | if(ci==_this.selection.currentIndex && pp.id==pid) { | 792 | if(ci==_this.selection.currentIndex && pp.id==pid) { |
792 | var n = xp_node('/rsp/photo',xr.responseXML); | 793 | var n = xp_node('/rsp/photo',xr.responseXML); |
793 | pp.fromNode_(n); | 794 | pp.fromNode_(n); |
794 | _this.render_description_frame(pp.description); | 795 | _this.render_description_frame(pp.description); |
795 | } | 796 | } |
796 | }, function(x,s,c,m) { | 797 | }, function(x,s,c,m) { |
797 | _this.fireflix.flickr_failure(x,s,c,m); | 798 | _this.fireflix.flickr_failure(x,s,c,m); |
798 | } | 799 | } |
799 | ); | 800 | ); |
800 | this.searchresult_props.hidden = false; | 801 | this.searchresult_props.hidden = false; |
801 | }else{ | 802 | }else{ |
802 | this.render_description_frame(p.description); | 803 | this.render_description_frame(p.description); |
803 | } | 804 | } |
804 | } | 805 | } |
805 | } | 806 | } |
806 | }, | 807 | }, |
807 | on_cmd_open: function(ev) { | 808 | on_cmd_open: function(ev) { |
808 | if(this.selection.currentIndex<0) | 809 | if(this.selection.currentIndex<0) |
809 | return; | 810 | return; |
810 | var p = this.photos[this.selection.currentIndex]; | 811 | var p = this.photos[this.selection.currentIndex]; |
811 | if(!p.id) | 812 | if(!p.id) |
812 | return; | 813 | return; |
813 | this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p')); | 814 | this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p')); |
814 | } | 815 | } |