author | Michael Krelin <hacker@klever.net> | 2006-09-30 18:27:38 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-09-30 18:27:38 (UTC) |
commit | 01fbc99cb713a0c4656f33949b2949bf7403656b (patch) (unidiff) | |
tree | 2ee9c07db4c6c7c329f97e56615672ca2fc3e462 | |
parent | 4f5e775ff24baf34b3425e93bfeac4a436b4b525 (diff) | |
download | fireflix-01fbc99cb713a0c4656f33949b2949bf7403656b.zip fireflix-01fbc99cb713a0c4656f33949b2949bf7403656b.tar.gz fireflix-01fbc99cb713a0c4656f33949b2949bf7403656b.tar.bz2 |
more code beauty/performance enhancements
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@171 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | content/photoset-props.js | 38 | ||||
-rw-r--r-- | content/photoset-props.xul | 1 |
2 files changed, 18 insertions, 21 deletions
diff --git a/content/photoset-props.js b/content/photoset-props.js index 43dc1b9..7c816be 100644 --- a/content/photoset-props.js +++ b/content/photoset-props.js | |||
@@ -1,81 +1,77 @@ | |||
1 | 1 | ||
2 | var psetprops = { | 2 | var psetprops = { |
3 | fireflix: null, | 3 | fireflix: null, |
4 | photoset: null, | 4 | photoset: null, |
5 | pripic: null, | 5 | pripic: null, |
6 | 6 | ||
7 | settitle: null, setdesc: null, | ||
8 | primarypic: null, | ||
9 | photos: new Array(), | 7 | photos: new Array(), |
10 | init: function() { | 8 | init: function() { |
11 | this.fireflix = window.arguments[0]; | 9 | this.fireflix = window.arguments[0]; |
12 | this.photoset = window.arguments[1]; | 10 | this.photoset = window.arguments[1]; |
13 | this.settitle = document.getElementById('set_title'); | 11 | pull_elements(this,document,[ |
14 | this.settitle.value = this.photoset.title; | 12 | 'set_title','set_desc','primary_picture', |
15 | this.setdesc = document.getElementById('set_desc'); | 13 | 'primary_picture_list' |
16 | this.setdesc.value = this.photoset.description; | 14 | ]); |
17 | this.primarypic = document.getElementById('primary_picture'); | 15 | this.set_title.value = this.photoset.title; |
18 | this.primarypic.src = | 16 | this.set_desc.value = this.photoset.description; |
17 | this.primary_picture.src = | ||
19 | this.fireflix.flickr.get_image_url( this.photoset, 't' ); | 18 | this.fireflix.flickr.get_image_url( this.photoset, 't' ); |
20 | this.primarypic.hidden = false; | 19 | this.primary_picture.hidden = false; |
21 | this.picslist = document.getElementById('primary_picture_list'); | ||
22 | 20 | ||
23 | var _this = this; | 21 | var _this = this; |
24 | this.fireflix.flickr.api_call( | 22 | this.fireflix.flickr.api_call( |
25 | { | 23 | { |
26 | method: 'flickr.photosets.getPhotos', | 24 | method: 'flickr.photosets.getPhotos', |
27 | auth_token: 'default', | 25 | auth_token: 'default', |
28 | photoset_id: this.photoset.id | 26 | photoset_id: this.photoset.id |
29 | }, function(xr) { | 27 | }, function(xr) { |
30 | var x = xr.responseXML; | 28 | var x = xr.responseXML; |
31 | var xp = x.evaluate( | 29 | var xp = x.evaluate( |
32 | '/rsp/photoset/photo', x, null, | 30 | '/rsp/photoset/photo', x, null, |
33 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); | 31 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); |
34 | _this.picslist.removeAllItems(); _this.photos= new Array(); | 32 | _this.primary_picture_list.removeAllItems(); _this.photos= new Array(); |
35 | var n; while(n=xp.iterateNext()) { | 33 | var n; while(n=xp.iterateNext()) { |
36 | _this.photos.push( | 34 | _this.photos.push( |
37 | { | 35 | { |
38 | id: n.getAttribute('id'), | 36 | id: n.getAttribute('id'), |
39 | secret: n.getAttribute('secret'), | 37 | secret: n.getAttribute('secret'), |
40 | server: n.getAttribute('server') | 38 | server: n.getAttribute('server') |
41 | } | 39 | } |
42 | ); | 40 | ); |
43 | var ni = _this.picslist.appendItem( | 41 | var ni = _this.primary_picture_list.appendItem( |
44 | n.getAttribute('title'), _this.photos.length-1 | 42 | n.getAttribute('title'), _this.photos.length-1 |
45 | ); | 43 | ); |
46 | ni.setAttribute('command','cmd_select_picture'); | 44 | ni.setAttribute('command','cmd_select_picture'); |
47 | if(n.getAttribute('isprimary')==1) { | 45 | if(n.getAttribute('isprimary')==1) { |
48 | _this.picslist.selectedItem = ni; | 46 | _this.primary_picture_list.selectedItem = ni; |
49 | _this.pripic = _this.photos[_this.photos.length-1]; | 47 | _this.pripic = _this.photos[_this.photos.length-1]; |
50 | } | 48 | } |
51 | } | 49 | } |
52 | _this.picslist.hidden = false; | 50 | _this.primary_picture_list.hidden = false; |
53 | }, function() { } | 51 | }, function() { } |
54 | ); | 52 | ); |
55 | }, | 53 | }, |
56 | on_select_picture: function(ev) { | 54 | on_select_picture: function(ev) { |
57 | var epic = ev.explicitOriginalTarget; | 55 | var epic = ev.explicitOriginalTarget; |
58 | this.picslist.selectedItem = epic; | 56 | this.primary_picture_list.selectedItem = epic; |
59 | var pic = this.photos[this.picslist.selectedItem.value]; | 57 | var pic = this.photos[this.primary_picture_list.selectedItem.value]; |
60 | this.pripic = pic; | 58 | this.pripic = pic; |
61 | this.primarypic.src = | 59 | this.primary_picture.src = |
62 | this.fireflix.flickr.get_photo_url( | 60 | this.fireflix.flickr.get_photo_url( |
63 | pic.server, | 61 | pic.server, |
64 | pic.id, | 62 | pic.id, |
65 | pic.secret, | 63 | pic.secret, |
66 | 't' | 64 | 't' |
67 | ); | 65 | ); |
68 | }, | 66 | }, |
69 | on_accept: function() { | 67 | on_accept: function() { |
70 | this.photoset.title = | 68 | this.photoset.title = this.set_title.value; |
71 | document.getElementById('set_title').value; | 69 | this.photoset.description = this.set_desc.value; |
72 | this.photoset.description = | ||
73 | document.getElementById('set_desc').value; | ||
74 | this.photoset.server = this.pripic.server; | 70 | this.photoset.server = this.pripic.server; |
75 | this.photoset.primary = this.pripic.id; | 71 | this.photoset.primary = this.pripic.id; |
76 | this.photoset.secret = this.pripic.secret; | 72 | this.photoset.secret = this.pripic.secret; |
77 | this.photoset.dirty = true; | 73 | this.photoset.dirty = true; |
78 | return; | 74 | return; |
79 | } | 75 | } |
80 | }; | 76 | }; |
81 | 77 | ||
diff --git a/content/photoset-props.xul b/content/photoset-props.xul index e8f6d13..2efa9e6 100644 --- a/content/photoset-props.xul +++ b/content/photoset-props.xul | |||
@@ -1,38 +1,39 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> | 2 | <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> |
3 | <?xsml-stylesheet href="fireflix.css" type="text/css"?> | 3 | <?xsml-stylesheet href="fireflix.css" type="text/css"?> |
4 | <!DOCTYPE dialog SYSTEM "chrome://fireflix/locale/fireflix.dtd"> | 4 | <!DOCTYPE dialog SYSTEM "chrome://fireflix/locale/fireflix.dtd"> |
5 | <dialog | 5 | <dialog |
6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
7 | id="photoset_props" | 7 | id="photoset_props" |
8 | buttons="accept,cancel" | 8 | buttons="accept,cancel" |
9 | defaultbutton="accept" | 9 | defaultbutton="accept" |
10 | title="&photosetprops.title;" | 10 | title="&photosetprops.title;" |
11 | onload="psetprops.init()" | 11 | onload="psetprops.init()" |
12 | ondialogaccept="psetprops.on_accept()" | 12 | ondialogaccept="psetprops.on_accept()" |
13 | > | 13 | > |
14 | 14 | ||
15 | <script src="util.js" type="application/x-javascript"/> | ||
15 | <script src="photoset-props.js" type="application/x-javascript"/> | 16 | <script src="photoset-props.js" type="application/x-javascript"/> |
16 | 17 | ||
17 | <commandset> | 18 | <commandset> |
18 | <command id="cmd_select_picture" | 19 | <command id="cmd_select_picture" |
19 | oncommand="psetprops.on_select_picture(event)"/> | 20 | oncommand="psetprops.on_select_picture(event)"/> |
20 | </commandset> | 21 | </commandset> |
21 | 22 | ||
22 | <hbox class="wholething"> | 23 | <hbox class="wholething"> |
23 | <vbox> | 24 | <vbox> |
24 | <menulist id="primary_picture_list" hidden="true" sizetopopup="always"/> | 25 | <menulist id="primary_picture_list" hidden="true" sizetopopup="always"/> |
25 | <hbox pack="center"> | 26 | <hbox pack="center"> |
26 | <box width="100" pack="center"> | 27 | <box width="100" pack="center"> |
27 | <image id="primary_picture" hidden="true"/> | 28 | <image id="primary_picture" hidden="true"/> |
28 | </box> | 29 | </box> |
29 | </hbox> | 30 | </hbox> |
30 | </vbox> | 31 | </vbox> |
31 | <vbox flex="1" minwidth="300"> | 32 | <vbox flex="1" minwidth="300"> |
32 | <label control="set_title" value="&photosetprops.set_title.label;"/> | 33 | <label control="set_title" value="&photosetprops.set_title.label;"/> |
33 | <textbox id="set_title" /> | 34 | <textbox id="set_title" /> |
34 | <label control="set_desc" value="&photosetprops.set_desc.label;"/> | 35 | <label control="set_desc" value="&photosetprops.set_desc.label;"/> |
35 | <textbox id="set_desc" multiline="true" rows="5" /> | 36 | <textbox id="set_desc" multiline="true" rows="5" /> |
36 | </vbox> | 37 | </vbox> |
37 | </hbox> | 38 | </hbox> |
38 | </dialog> | 39 | </dialog> |