Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add info tooltips to url bar icons, refactoring reddit API code and D…
…OM sorting.
- Loading branch information
1 parent
5886ae0
commit 8efa7db
Showing
23 changed files
with
562 additions
and
239 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,84 @@ | |||
<?xml version="1.0"?> | |||
<!DOCTYPE reddit SYSTEM "chrome://socialite/locale/reddit.dtd"> | |||
<bindings | |||
xmlns="http://www.mozilla.org/xbl" | |||
xmlns:xbl="http://www.mozilla.org/xbl" | |||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> | |||
|
|||
<binding id="reddit-site-info"> | |||
<content> | |||
<xul:vbox class="socialite-login-state" xbl:inherits="isloggedin"> | |||
<xul:grid class="socialite-logged-in"> | |||
<xul:columns> | |||
<xul:column/> | |||
<xul:column/> | |||
<xul:column/> | |||
</xul:columns> | |||
<xul:rows> | |||
<xul:row> | |||
<xul:label anonid="labelUsername" class="socialite-site-info-username">&siteInfo.loadingtext;</xul:label> | |||
<xul:spacer flex="1"/> | |||
<xul:hbox align="center" pack="end"> | |||
<xul:image anonid="imageMailIcon" src="chrome://socialite/content/reddit/mailgray.png" class="mail-icon"/> | |||
<xul:label anonid="labelMailCount" class="reddit-mail-count">?</xul:label> | |||
</xul:hbox> | |||
</xul:row> | |||
<xul:row> | |||
<xul:label>&linkKarma.label;</xul:label> | |||
<xul:spacer flex="1"/> | |||
<xul:label anonid="labelLinkKarma" class="socialite-site-info-data reddit-link-karma">...</xul:label> | |||
</xul:row> | |||
<xul:row> | |||
<xul:label>&commentKarma.label;</xul:label> | |||
<xul:spacer flex="1"/> | |||
<xul:label anonid="labelCommentKarma" class="socialite-site-info-data reddit-comment-karma">...</xul:label> | |||
</xul:row> | |||
</xul:rows> | |||
</xul:grid> | |||
<xul:vbox class="socialite-not-logged-in"> | |||
<xul:label class="socialite-site-info-username">&siteInfo.loggedout.title;</xul:label> | |||
<xul:label>&siteInfo.loggedout.label;</xul:label> | |||
</xul:vbox> | |||
</xul:vbox> | |||
</content> | |||
|
|||
<resources> | |||
<stylesheet src="chrome://socialite/skin/socialite.css"/> | |||
<stylesheet src="chrome://socialite/skin/socialite_platform.css"/> | |||
<stylesheet src="chrome://socialite/skin/reddit.css"/> | |||
</resources> | |||
|
|||
<implementation> | |||
<method name="refresh"> | |||
<body> | |||
var self = this; | |||
function setLabel(anonid, value) { | |||
var label = document.getAnonymousElementByAttribute(self, "anonid", anonid); | |||
label.value = value; | |||
} | |||
|
|||
this.site.API.auth.getAuthInfo(function(authInfo) { | |||
self.setAttribute("isloggedin", authInfo.isLoggedIn); | |||
setLabel("labelUsername", authInfo.username); | |||
}).perform(); | |||
|
|||
var messageCount = this.site.newMessages.length; | |||
setLabel("labelMailCount", messageCount); | |||
var imageMailIcon = document.getAnonymousElementByAttribute(this, "anonid", "imageMailIcon"); | |||
if (messageCount > 0) { | |||
imageMailIcon.src = "chrome://socialite/content/reddit/mail.png"; | |||
} else { | |||
imageMailIcon.src = "chrome://socialite/content/reddit/mailgray.png"; | |||
} | |||
|
|||
this.site.cached.myuserinfo( | |||
function success(r, json) { | |||
setLabel("labelLinkKarma", json.data.link_karma); | |||
setLabel("labelCommentKarma", json.data.comment_karma); | |||
} | |||
).perform(); | |||
</body> | |||
</method> | |||
</implementation> | |||
</binding> | |||
</bindings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,144 @@ | |||
<?xml version="1.0"?> | |||
<!DOCTYPE reddit SYSTEM "chrome://socialite/locale/socialite.dtd"> | |||
<bindings | |||
xmlns="http://www.mozilla.org/xbl" | |||
xmlns:xbl="http://www.mozilla.org/xbl" | |||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> | |||
|
|||
<binding id="site-info-box" extends="chrome://global/content/bindings/general.xml#basecontrol"> | |||
<content> | |||
<xul:groupbox> | |||
<xul:caption align="center" xbl:inherits="image,label=name" flex="1"/> | |||
<children/> | |||
</xul:groupbox> | |||
</content> | |||
|
|||
<resources> | |||
<stylesheet src="chrome://socialite/skin/socialite.css"/> | |||
<stylesheet src="chrome://socialite/skin/socialite_platform.css"/> | |||
</resources> | |||
|
|||
<implementation> | |||
<!-- | |||
Commented out as per urlBarIcon.xml | |||
<field name="site"/> | |||
--> | |||
<property name="siteInfo" onget="return this.childNodes[0];"/> | |||
|
|||
<property name="name" | |||
onget="return this.getAttribute('name');" | |||
onset="this.setAttribute('name', val); return val;"/> | |||
|
|||
<constructor> | |||
if (!this._constructed) { | |||
this.updateSiteName(); | |||
|
|||
var faviconWatch = Components.utils.import("resource://socialite/utils/faviconWatch.jsm", null); | |||
this._removeFaviconWatch = faviconWatch.useFaviconAsAttribute(this, "image", this.site.siteURL); | |||
this._constructed = true; | |||
} | |||
</constructor> | |||
|
|||
<destructor> | |||
this.destroySiteInfoBox(); | |||
</destructor> | |||
|
|||
<method name="destroySiteInfoBox"> | |||
<body> | |||
if (this._removeFaviconWatch) { this._removeFaviconWatch(); } | |||
</body> | |||
</method> | |||
|
|||
<method name="updateSiteName"> | |||
<body> | |||
this.name = this.site.siteName; | |||
</body> | |||
</method> | |||
|
|||
<method name="refresh"> | |||
<body> | |||
this.siteInfo.refresh(); | |||
</body> | |||
</method> | |||
</implementation> | |||
</binding> | |||
|
|||
<binding id="site-info-tooltip" extends="chrome://global/content/bindings/popup.xml#tooltip"> | |||
<content noautohide="true"> | |||
<xul:vbox> | |||
<children/> | |||
</xul:vbox> | |||
</content> | |||
|
|||
<implementation> | |||
<constructor> | |||
if (!this._constructed) { | |||
this.afterBound(); | |||
this._constructed = true; | |||
} | |||
</constructor> | |||
|
|||
<destructor> | |||
this.destroySiteInfoTooltip(); | |||
</destructor> | |||
|
|||
<method name="destroySiteInfoTooltip"> | |||
<body> | |||
Array.forEach(this.childNodes, function(siteInfoBox) { | |||
siteInfoBox.destroySiteInfoBox(); | |||
}); | |||
</body> | |||
</method> | |||
|
|||
<method name="addSite"> | |||
<parameter name="site"/> | |||
<body> | |||
var siteInfoBox = document.createElement("box"); | |||
siteInfoBox.className = "socialite-site-info-box"; | |||
siteInfoBox.site = site; | |||
siteInfoBox.setAttribute("name", site.siteName); | |||
siteInfoBox.appendChild(site.createInfoUI(document)); | |||
this.appendChild(siteInfoBox); | |||
</body> | |||
</method> | |||
|
|||
<method name="removeSite"> | |||
<parameter name="site"/> | |||
<body> | |||
<![CDATA[ | |||
for (var i=0; i<this.childNodes.length; i++) { | |||
if (this.childNodes[i].site.siteID == site.siteID) { | |||
this.childNodes[i].destroySiteInfoBox(); | |||
this.removeChild(this.childNodes[i]); | |||
} | |||
} | |||
]]> | |||
</body> | |||
</method> | |||
|
|||
<method name="updateSiteNames"> | |||
<body> | |||
Array.forEach(this.childNodes, function(siteInfoBox) { | |||
siteInfoBox.updateSiteName(); | |||
}); | |||
</body> | |||
</method> | |||
|
|||
<method name="refresh"> | |||
<body> | |||
Array.forEach(this.childNodes, function(siteInfoBox) { | |||
siteInfoBox.refresh(); | |||
}); | |||
</body> | |||
</method> | |||
</implementation> | |||
|
|||
<handlers> | |||
<handler event="popupshown"> | |||
// We must refresh site names on this event, because the XBL doesn't seem to bind until the popup is showing. | |||
this.updateSiteNames(); | |||
this.refresh(); | |||
</handler> | |||
</handlers> | |||
</binding> | |||
</bindings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.