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) (side-by-side diff) | |
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 @@ -655,192 +655,193 @@ var fireflix = { if(this.uploads.files[f].photoid) pids.push(this.uploads.files[f].photoid); } var pp = this.uploads.rowCount*2; if(pp>500) pp = 500; var _this = this; this.flickr.api_call( { method: 'flickr.photos.search', auth_token: 'default', extras: 'original_format', user_id: 'me', per_page: pp }, function(xr) { var x = xr.responseXML; var rv = ''; for(var pn in pids) { var p = pids[pn]; var pp = new Photo(xp_node('/rsp/photos/photo[@id='+p+']',x)); rv += _this.photo_html(pp,uti,utl)+'\n'; } _this.popup_content(rv); }, function(x,s,c,m) { _this.flickr_failure(x,s,c,m); } ); }, /* * */ foundphotos: { fireflix: null, init: function(f) { this.fireflix = f; pull_elements(this,document,[ 'search_for','search_tags','search_mine', 'searchresult_props','search_photo', 'searchresult_title','searchresult_description' ]); document.getElementById('searchresults').view = this; }, photos: new Array(), rowCount: 0, getCellText: function(r,c) { var p = this.photos[r]; if(c.id=='sr_title') return p.title; return c.id; }, setTree: function(t) { this.tree = t }, isContainer: function(r) { return false }, isSeparator: function(r) { return false }, isSorted: function(r) { return false }, getLevel: function(r) { return 0 }, getImageSrc: function(r,c) { return null }, getRowProperties: function(r,p) { }, getCellProperties: function(cid,cel,p) { }, getColumnProperties: function(cid,cel,p) { }, cycleHeader: function(cid,e) { }, getParentIndex: function(r) { return -1 }, drop: function(r,o) { }, canDropBeforeAfter: function(r,b) { return false }, importXPR: function(xp) { this.selection.clearSelection(); this.selection.currentIndex = -1; this.searchresult_props.hidden = true; this.tree.beginUpdateBatch(); this.photos = new Array(); var n; while(n=xp.iterateNext()) { this.photos.push(new Photo(n)); } this.rowCount = this.photos.length; this.tree.endUpdateBatch(); }, search_photos: function() { var pars = { method: 'flickr.photos.search', auth_token: 'default', extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo' }; if(this.search_mine.checked) pars.user_id='me'; if(this.search_tags.checked) { pars.tags=this.search_for.value.split(/ +/).join(','); }else{ pars.text=this.search_for.value; } var _this = this; this.fireflix.flickr.api_call( pars, function(xr) { var x = xr.responseXML; var xp = x.evaluate( '/rsp/photos/photo', x, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); _this.importXPR(xp); + _this.tree.ensureRowIsVisible(0); _this.on_select(); }, function(x,s,c,m) { _this.fireflix.flickr_failure(x,s,c,m); } ); }, render_description_frame: function(content) { if(!content) { this.searchresult_description.innerHTML = ''; }else{ this.searchresult_description.innerHTML = content?content:''; /* of all linking elements flickr only allows a */ var as = this.searchresult_description.getElementsByTagName('a'); for(var a=0;a<as.length;++a) as.item(a).setAttribute('target','_blank'); } }, on_select: function() { if(this.selection.currentIndex<0) { this.searchresult_props.hidden = true; }else{ var p = this.photos[this.selection.currentIndex]; if(!p) { this.searchresult_props.hidden = true; }else{ this.search_photo.src = this.fireflix.flickr.make_photo_url(p,'t'); this.searchresult_title.value = p.title; this.render_description_frame(null); if(p.description==null && p.description==undefined) { var pid = p.id; var ci = this.selection.currentIndex; var _this = this; this.fireflix.flickr.api_call( { method: 'flickr.photos.getInfo', auth_token: 'default', photo_id: p.id, secret: p.secret }, function(xr) { var pp = _this.photos[ci]; if(ci==_this.selection.currentIndex && pp.id==pid) { var n = xp_node('/rsp/photo',xr.responseXML); pp.fromNode_(n); _this.render_description_frame(pp.description); } }, function(x,s,c,m) { _this.fireflix.flickr_failure(x,s,c,m); } ); this.searchresult_props.hidden = false; }else{ this.render_description_frame(p.description); } } } }, on_cmd_open: function(ev) { if(this.selection.currentIndex<0) return; var p = this.photos[this.selection.currentIndex]; if(!p.id) return; this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p')); } }, photo_html: function(p,i,l) { // TODO: add alt/title when possible var rv = '<a href="'+this.flickr.make_photo_url(p,l)+'">' + '<img src="'+this.flickr.make_photo_url(p,i)+'" />'+ '</a>'; return rv; }, build_html: function(photos,uti,utl) { var rv = ''; for(var i in photos) { var p = photos[i]; rv += this.photo_html(p,utl,uti)+'\n'; } return rv; }, popup_content: function(s) { window.openDialog( "chrome://fireflix/content/generated-content.xul", null, "dialog,chrome", this, s ); }, copy_to_clipboard: function(s) { var ch = Components.classes["@mozilla.org/widget/clipboardhelper;1"] .getService(Components.interfaces.nsIClipboardHelper); ch.copyString(s); }, openTab: function(l) { var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService( Components.interfaces.nsIWindowMediator ); |