summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix-panel.xul33
-rw-r--r--content/fireflix.js52
-rw-r--r--locale/en-US/fireflix.dtd10
3 files changed, 67 insertions, 28 deletions
diff --git a/content/fireflix-panel.xul b/content/fireflix-panel.xul
index 75d6c2d..70a58fe 100644
--- a/content/fireflix-panel.xul
+++ b/content/fireflix-panel.xul
@@ -23,2 +23,23 @@
+ <commandset>
+ <command id="cmd_auth_auth" label="&panel.auth.auth.label;"
+ oncommand="fireflix.on_cmd_auth()"/>
+ <command id="cmd_auth_done" label="&panel.auth.done.label;"
+ oncommand="fireflix.on_cmd_auth_done()" disabled="true"/>
+ <command id="cmd_auth_open_flickr" label="&panel.auth.flickr.label;"
+ oncommand="fireflix.openTab('htp://www.flickr.com/')" />
+ <command id="cmd_auth_unauth" label="&panel.auth.unauth.label;"
+ oncommand="fireflix.on_cmd_auth_unauth()" />
+ </commandset>
+
+ <popupset>
+ <popup id="auth_menu">
+ <menuitem command="cmd_auth_auth"/>
+ <menuitem command="cmd_auth_done" hidden="true" id="menu_auth_done"/>
+ <menuitem command="cmd_auth_unauth" />
+ <menuseparator/>
+ <menuitem command="cmd_auth_open_flickr"/>
+ </popup>
+ </popupset>
+
<commandset id="cmdset_search">
@@ -71,3 +92,3 @@
- <groupbox>
+ <groupbox context="auth_menu">
<caption label="&panel.auth_info;"/>
@@ -75,8 +96,6 @@
<label id="auth_info" value="&panel.no_auth_info;" flex="1" disabled="true"/>
- <button id="b_auth" label="&panel.auth_button;" oncommand="fireflix.on_auth()"/>
- <button id="b_auth_done" label="&panel.auth_complete_button;" hidden="true"
- oncommand="fireflix.on_auth_done()"/>
- <button label="&panel.flickr_button.label;"
- tooltiptext="&panel.flickr_button.tip;"
- oncommand="fireflix.openTab('http://www.flickr.com/')" />
+ <button id="b_auth" command="cmd_auth_auth"/>
+ <button id="b_auth_done" command="cmd_auth_done" hidden="true"/>
+ <button command="cmd_auth_open_flickr"
+ tooltiptext="&panel.auth.flickr.tip;"/>
</hbox>
diff --git a/content/fireflix.js b/content/fireflix.js
index 9518480..82c7b0c 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -14,2 +14,9 @@ var fireflix = {
init: function() {
+ this.cmd_auth_auth = document.getElementById('cmd_auth_auth');
+ this.cmd_auth_done = document.getElementById('cmd_auth_done');
+ this.cmd_auth_unauth = document.getElementById('cmd_auth_unauth');
+ this.menu_auth_done = document.getElementById('menu_auth_done');
+ this.b_auth = document.getElementById('b_auth');
+ this.b_auth_done = document.getElementById('b_auth_done');
+ this.auth_info = document.getElementById('auth_info');
this.loc_strings = document.getElementById('loc_strings');
@@ -29,12 +36,22 @@ var fireflix = {
document.getElementById('uploadlist').view = this.uploads;
- this.flickr.no_auth_info_label = document.getElementById('auth_info').value;
+ this.no_auth_info_label = this.auth_info.value;
+ this.set_auth_state(this.flickr.token,false);
if(this.flickr.token) {
this.refresh_stuff();
- document.getElementById('auth_info').value =
- this.flickr.user.fullname+' ['+this.flickr.user.username+']';
- document.getElementById('auth_info').disabled = false;
- document.getElementById('b_auth').hidden = true;
}
},
- on_auth: function() {
+ set_auth_state: function(au,inp) { /* authorized, in progress */
+ this.cmd_auth_unauth.disabled = !au;
+ this.b_auth.hidden = au || inp;
+ this.b_auth_done.hidden = !inp;
+ this.menu_auth_done.hidden = !inp;
+ this.cmd_auth_done.setAttribute('disabled',!inp);
+ this.auth_info.disabled = !au;
+ if(au) {
+ this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */
+ }else{
+ this.auth_info.value = this.no_auth_info_label;
+ }
+ },
+ on_cmd_auth: function() {
var _this = this;
@@ -42,4 +59,3 @@ var fireflix = {
function() {
- document.getElementById('b_auth').hidden = true;
- document.getElementById('b_auth_done').hidden = false;
+ _this.set_auth_state(_this.flickr.token,true);
}, function(x,s,c,m) {
@@ -49,4 +65,4 @@ var fireflix = {
},
- on_auth_done: function() {
- document.getElementById('b_auth_done').hidden = true;
+ on_cmd_auth_done: function() {
+ this.set_auth_state(this.flickr.token,false);
var _this = this;
@@ -56,7 +72,7 @@ var fireflix = {
_this.refresh_stuff();
- document.getElementById('auth_info').value =
+ _this.set_auth_state(_this.flickr.token,false);
+ _this.auth_info.value =
_this.flickr.user.fullname+' ['+_this.flickr.user.username+']';
- document.getElementById('auth_info').disabled = false;
}, function(x,s,c,m) {
- document.getElementById('b_auth').hidden = false;
+ _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */
_this.flickr_failure(x,s,c,m);
@@ -65,2 +81,6 @@ var fireflix = {
},
+ on_cmd_auth_unauth: function() {
+ this.flickr.reset_token();
+ this.set_auth_state(false,false);
+ },
@@ -868,8 +888,6 @@ var fireflix = {
this.flickr.reset_token();
- document.getElementById('auth_info').value = this.no_auth_info_label;
- document.getElementById('auth_info').disabled = true;
- document.getElementById('b_auth').hidden = false;
+ this.set_auth_state(false,false);
return;
}
- // TODO: is that beauty
+ // TODO: is that beauty?
alert('flickr api call failed\n'+c+' '+m);
diff --git a/locale/en-US/fireflix.dtd b/locale/en-US/fireflix.dtd
index 2b6e72a..f4ceb79 100644
--- a/locale/en-US/fireflix.dtd
+++ b/locale/en-US/fireflix.dtd
@@ -18,6 +18,8 @@
<!ENTITY panel.no_auth_info "No auth info available">
-<!ENTITY panel.auth_button "Authorize">
-<!ENTITY panel.auth_complete_button "Authorization complete">
-<!ENTITY panel.flickr_button.label "Flickr">
-<!ENTITY panel.flickr_button.tip "Open Flickr in new tab">
+
+<!ENTITY panel.auth.auth.label "Authorize">
+<!ENTITY panel.auth.done.label "Authorization complete">
+<!ENTITY panel.auth.flickr.label "Flickr">
+<!ENTITY panel.auth.flickr.tip "Open Flickr in new tab">
+<!ENTITY panel.auth.unauth.label "Sign off">