author | Michael Krelin <hacker@klever.net> | 2006-12-18 18:56:09 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-12-18 18:56:09 (UTC) |
commit | 71a2c8a80f3c7a99e893efb32c6bbf5080e16ff1 (patch) (side-by-side diff) | |
tree | 1f9051339dee22f5c64206568638675ca9f7636a | |
parent | 1838bc18394967371d7a1c00516db5e290f80ea3 (diff) | |
download | fireflix-71a2c8a80f3c7a99e893efb32c6bbf5080e16ff1.zip fireflix-71a2c8a80f3c7a99e893efb32c6bbf5080e16ff1.tar.gz fireflix-71a2c8a80f3c7a99e893efb32c6bbf5080e16ff1.tar.bz2 |
doubleclicking files in upload
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@241 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | content/fireflix-panel.xul | 3 | ||||
-rw-r--r-- | content/fireflix.js | 17 | ||||
-rw-r--r-- | content/flickr.js | 5 |
3 files changed, 20 insertions, 5 deletions
diff --git a/content/fireflix-panel.xul b/content/fireflix-panel.xul index 405804c..8aec0e4 100644 --- a/content/fireflix-panel.xul +++ b/content/fireflix-panel.xul @@ -231,33 +231,34 @@ <tabpanel id="tabpanel_tags"> <listbox id="tagslist" rows="8" flex="1"> <listhead> <listheader label="&panel.tagslist.tag.label;"/> </listhead> <listcols> <listcol flex="1"/> </listcols> </listbox> </tabpanel> <tabpanel id="tabpanel_upload"> <vbox flex="1"> <tree id="uploadlist" rows="2" flex="1" onselect="fireflix.uploads.selectionChanged()" - context="uploads_menu"> + context="uploads_menu" ondblclick="fireflix.uploads.on_cmd_open(event)" + onkeypress="if(event.keyCode==event.DOM_VK_RETURN) fireflix.uploads.on_cmd_open(event)" > <treecols> <treecol id="up_file" label="&panel.uploadlist.file.label;" flex="4" crop="start" align="start"/> <splitter class="tree-splitter" /> <treecol id="up_title" label="&panel.uploadlist.title.label;" flex="5" crop="end" align="start" /> <splitter class="tree-splitter" /> <treecol id="up_status" label="&panel.uploadlist.status.label;" flex="1" crop="end" align="start" /> </treecols> <treechildren/> </tree> <progressmeter id="upload_progress" mode="undetermined" hidden="true" /> <groupbox id="upload_file_props" orient="vertical" hidden="true"> <hbox> <image id="upload_file_preview" width="100" height="100" /> <vbox flex="1"> <grid> <columns> diff --git a/content/fireflix.js b/content/fireflix.js index 78e56c2..225e21c 100644 --- a/content/fireflix.js +++ b/content/fireflix.js @@ -615,32 +615,43 @@ var fireflix = { } }, on_add: function() { var ifp = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(ifp); fp.init(window, "Select a File", ifp.modeOpenMultiple); fp.appendFilters(ifp.filterImages); var rv = fp.show(); if(rv==ifp.returnOK) { var ff = fp.files; while(ff.hasMoreElements()) { var f = ff.getNext(); f.QueryInterface(Components.interfaces.nsIFile); this.add(f.path); } } + }, + on_cmd_open: function(ev) { + if(this.selection.currentIndex<0) return; + var f = this.files[this.selection.currentIndex]; + if(f.photoid) { + this.fireflix.openTab( + this.fireflix.flickr.make_uploader_edit_url(f.photoid) + ); + }else{ + this.fireflix.openTab( 'file://'+f.file); + } } }, on_set_props: function() { var pset = this.photosets.sets[this.photosets.selection.currentIndex]; window.openDialog( "chrome://fireflix/content/photoset-props.xul", null, "dependent,modal,dialog,chrome", this, pset ); if(pset.dirty) { var _this = this; this.flickr.api_call( { method: 'flickr.photosets.editMeta', auth_token: 'default', photoset_id: pset.id, @@ -900,37 +911,35 @@ var fireflix = { 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; + if(this.selection.currentIndex<0) return; var p = this.photos[this.selection.currentIndex]; - if(!p.id) - return; + 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]; diff --git a/content/flickr.js b/content/flickr.js index b8360c1..e09d5f0 100644 --- a/content/flickr.js +++ b/content/flickr.js @@ -84,32 +84,33 @@ Photo.prototype = { // TODO: notes/note/@id notes/note/@author notes/note/@authorname // TODO: notes/note/@x notes/note/@y notes/note/@w notes/note/@h // TODO: notes/note // TODO: tags/tag/@id tags/tag/@author tags/tag/@raw tags/tag // TODO: urls/url/@type urls/url } }; function Flickr() { } Flickr.prototype = { rest_url: 'http://www.flickr.com/services/rest/', auth_url: 'http://flickr.com/services/auth/', photo_url: 'http://static.flickr.com/', photos_url: 'http://www.flickr.com/photos/', upload_url: 'http://www.flickr.com/services/upload/', + uploader_edit_url: 'http://www.flickr.com/tools/uploader_edit.gne', api_sig: function(paramstr) { return MD5(toutf8(this.api_shs+paramstr)); }, api_call_url: function(params,url) { params.api_key = this.api_key; var pp = new Array(); for(var p in params) { pp.push(p); } var pstr = ''; var rv = (url?url:this.rest_url)+'?'; for(var p in pp.sort()) { var pn = pp[p]; pstr += pn+params[pn]; rv += pn+'='+params[pn]+'&'; @@ -262,32 +263,36 @@ Flickr.prototype = { if(p.owner && p.owner.nsid) o = p.owner.nsid; var rv = this.photos_url + o +'/' + p.id; return rv; }else // TODO: take owner into account? return this.photos_url + this.user.nsid + '/' + p; }, make_photo_url: function(p,sfx) { if(sfx=='p') return this.get_photo_page_url(p); else return this.get_image_url(p,sfx); }, make_photoset_url: function(ps) { // TODO: allow for using someone else's photoset? return this.photos_url+this.user.nsid+'/sets/'+ps.id; }, + make_uploader_edit_url: function(pid) { + // TODO: handle arrays + return this.uploader_edit_url+'?ids='+pid; + }, upload_file: function(f,fa,on_success,on_failure) { try { var fi = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); fi.initWithPath( f ); var st = Components.classes["@mozilla.org/network/file-input-stream;1"] .createInstance(Components.interfaces.nsIFileInputStream); st.init(fi,0x01,00004,null); var bis = Components.classes["@mozilla.org/binaryinputstream;1"] .createInstance(Components.interfaces.nsIBinaryInputStream); bis.setInputStream(st); // allocate and initialize temp storage string var pbs = Components.classes["@mozilla.org/storagestream;1"] .createInstance(Components.interfaces.nsIStorageStream); |