diff options
Diffstat (limited to 'bandwagon/content/ui/bindings/bandwagon.xml')
-rw-r--r-- | bandwagon/content/ui/bindings/bandwagon.xml | 279 |
1 files changed, 150 insertions, 129 deletions
diff --git a/bandwagon/content/ui/bindings/bandwagon.xml b/bandwagon/content/ui/bindings/bandwagon.xml index 600d9f3..ac31bcf 100644 --- a/bandwagon/content/ui/bindings/bandwagon.xml +++ b/bandwagon/content/ui/bindings/bandwagon.xml @@ -44,7 +44,7 @@ xmlns:xbl="http://www.mozilla.org/xbl" xmlns:html="http://www.w3.org/1999/xhtml"> - <binding id="bandwagon-feed" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem"> + <binding id="bandwagon-collection" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem"> <resources> <stylesheet src="chrome://bandwagon/skin/extensionsOverlay.css"/> @@ -59,13 +59,13 @@ </content> <implementation> - <field name="feed"/> + <field name="collection"/> <field name="controller"/> <constructor> <![CDATA[ - if (this.feed) - this.setFeed(this.feed); + if (this.collection) + this.setCollection(this.collection); setTimeout(this.controller.bindingsReady, 100); ]]> @@ -86,7 +86,7 @@ onset="this.setAttribute('preview', val);" /> - <property name="editable" + <property name="writable" onget="return !document.getAnonymousElementByAttribute(this, 'anonid', 'star').collapsed;" onset="document.getAnonymousElementByAttribute(this, 'anonid', 'star').collapsed = !val;" /> @@ -96,16 +96,16 @@ onset="document.getAnonymousElementByAttribute(this, 'anonid', 'unread').value = val; document.getAnonymousElementByAttribute(this, 'anonid', 'unread').collapsed = (val == 0);" /> - <method name="setFeed"> - <parameter name="feed"/> + <method name="setCollection"> + <parameter name="collection"/> <body> <![CDATA[ - this.feed = feed; - this.name = (feed.name && feed.name !=""?feed.name:feed.url); - this.url = feed.url; - this.preview = feed.preview; - this.editable = feed.editable; - this.unread = feed.getUnreadFeedItems().length; + this.collection = collection; + this.name = (collection.name && collection.name !=""?collection.name:collection.resourceURL); + this.url = collection.resourceURL; + this.preview = collection.preview; + this.writable = collection.writable; + this.unread = collection.getUnreadAddons().length; ]]> </body> </method> @@ -114,14 +114,14 @@ </binding> - <binding id="bandwagon-feeditem" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem"> + <binding id="bandwagon-addon" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem"> <resources> <stylesheet src="chrome://bandwagon/skin/extensionsOverlay.css"/> </resources> <content> - <xul:stringbundle src="chrome://bandwagon/locale/bandwagonFeedItem.properties" + <xul:stringbundle src="chrome://bandwagon/locale/bandwagonAddon.properties" anonid="stringbundle"/> <xul:hbox flex="1"> @@ -144,13 +144,13 @@ </content> <implementation> - <field name="feedItem"/> + <field name="addon"/> <field name="_stringBundle">document.getAnonymousElementByAttribute(this, "anonid", "stringbundle");</field> <constructor> <![CDATA[ - if (this.feedItem) - this.setFeedItem(this.feedItem); + if (this.addon) + this.setAddon(this.addon); ]]> </constructor> @@ -197,15 +197,43 @@ </setter> </property> - <property name="author" - onget="return (document.getAnonymousElementByAttribute(this, 'anonid', 'author')?document.getAnonymousElementByAttribute(this, 'anonid', 'author').value:'')" - onset="if (document.getAnonymousElementByAttribute(this, 'anonid', 'author')) document.getAnonymousElementByAttribute(this, 'anonid', 'author').value = this._stringBundle.getFormattedString('bandwagon.feeditem.author', [val])" - /> + <property name="authors" + onget="return (document.getAnonymousElementByAttribute(this, 'anonid', 'author')?document.getAnonymousElementByAttribute(this, 'anonid', 'author').value:'')"> + <setter> + <![CDATA[ + if (document.getAnonymousElementByAttribute(this, 'anonid', 'authors')) + { + var authors = ""; + + if (!val || val.length == 0) + { + authors = "?"; + } + else + { + for each (var item in val) + { + authors += item + ", "; + } + if (authors.substring(authors.length-2) == ", ") + { + authors = authors.substring(0, authors.length-2); + } + } + + document.getAnonymousElementByAttribute(this, 'anonid', 'authors').value = this._stringBundle.getFormattedString('bandwagon.addon.author', [authors]); + } + ]]> + </setter> + </property> + + <!-- <property name="category" onget="return (document.getAnonymousElementByAttribute(this, 'anonid', 'category')?document.getAnonymousElementByAttribute(this, 'anonid', 'category').value:'')" - onset="if (document.getAnonymousElementByAttribute(this, 'anonid', 'category')) document.getAnonymousElementByAttribute(this, 'anonid', 'category').value = this._stringBundle.getFormattedString('bandwagon.feeditem.category', [val])" + onset="if (document.getAnonymousElementByAttribute(this, 'anonid', 'category')) document.getAnonymousElementByAttribute(this, 'anonid', 'category').value = this._stringBundle.getFormattedString('bandwagon.addon.category', [val])" /> + --> <property name="read" onget="return this.getAttribute('read')" @@ -226,36 +254,36 @@ if (diff < 60) { - sbString = "bandwagon.feeditem.added.justnow"; + sbString = "bandwagon.addon.added.justnow"; } else if (diff < 60 * 60) { - sbString = "bandwagon.feeditem.added.minute"; + sbString = "bandwagon.addon.added.minute"; sbVal = Math.ceil(diff/60); } else if (diff < 60 * 60 * 24) { - sbString = "bandwagon.feeditem.added.hour"; + sbString = "bandwagon.addon.added.hour"; sbVal = Math.floor(diff/60/60); } else if (diff < 60 * 60 * 24 * 7) { - sbString = "bandwagon.feeditem.added.day"; + sbString = "bandwagon.addon.added.day"; sbVal = Math.floor(diff/60/60/24); } else if (diff < 60 * 60 * 24 * 30) { - sbString = "bandwagon.feeditem.added.week"; + sbString = "bandwagon.addon.added.week"; sbVal = Math.floor(diff/60/60/24/7); } else if (diff < 60 * 60 * 24 * 356) { - sbString = "bandwagon.feeditem.added.month"; + sbString = "bandwagon.addon.added.month"; sbVal = Math.floor(diff/60/60/24/30); } else { - sbString = "bandwagon.feeditem.added.year"; + sbString = "bandwagon.addon.added.year"; sbVal = Math.floor(diff/60/60/24/356); } @@ -284,31 +312,31 @@ > <setter> <![CDATA[ - if (document.getAnonymousElementByAttribute(this, 'anonid', 'commentdesc')) document.getAnonymousElementByAttribute(this, 'anonid', 'commentdesc').firstChild.nodeValue = this._stringBundle.getFormattedString('bandwagon.feeditem.comment.description', [val.comment]); - if (document.getAnonymousElementByAttribute(this, 'anonid', 'commentauthor')) document.getAnonymousElementByAttribute(this, 'anonid', 'commentauthor').value = this._stringBundle.getFormattedString('bandwagon.feeditem.comment.author', [val.author]); + if (document.getAnonymousElementByAttribute(this, 'anonid', 'commentdesc')) document.getAnonymousElementByAttribute(this, 'anonid', 'commentdesc').firstChild.nodeValue = this._stringBundle.getFormattedString('bandwagon.addon.comment.description', [val.comment]); + if (document.getAnonymousElementByAttribute(this, 'anonid', 'commentauthor')) document.getAnonymousElementByAttribute(this, 'anonid', 'commentauthor').value = this._stringBundle.getFormattedString('bandwagon.addon.comment.author', [val.author]); ]]> </setter> </property> - <method name="setFeedItem"> - <parameter name="feedItem"/> + <method name="setAddon"> + <parameter name="addon"/> <body> <![CDATA[ - this.feedItem = feedItem; - this.name = feedItem.name; - this.guid = feedItem.guid; - this.summary = feedItem.summary; - this.description = feedItem.summary; // Use summary and not description - this.iconURL = feedItem.icon; - this.thumbnailURL = feedItem.thumbnail; - this.author = (feedItem.author?feedItem.author:"Unknown"); - this.category = (feedItem.category?feedItem.category:"Unknown"); - this.dateAdded = feedItem.dateAdded; - this.read = feedItem.read; - - if (feedItem.comments.length > 0) + this.addon = addon; + this.name = addon.name; + this.guid = addon.guid; + this.summary = addon.summary; + this.description = addon.summary; // Use summary and not description + this.iconURL = addon.icon; + this.thumbnailURL = addon.thumbnail; + this.authors = addon.authors; + //this.category = (addon.category?addon.category:"Unknown"); + this.dateAdded = addon.dateAdded; + this.read = addon.read; + + if (addon.comments.length > 0) { - this.comment = feedItem.comments[0]; + this.comment = addon.comments[0]; } else { @@ -319,7 +347,7 @@ } } - var canInstall = feedItem.canInstall(Bandwagon.Util.getHostEnvironmentInfo()); + var canInstall = addon.canInstall(Bandwagon.Util.getHostEnvironmentInfo()); this.showVersionHelper(canInstall.type, canInstall.requiredVersion); if (document.getAnonymousElementByAttribute(this, 'anonid', 'publish')) @@ -339,7 +367,7 @@ if (publishButton) { publishButton.emailAddresses = Bandwagon.Controller.ExtensionsOverlay._getEmailAddresses(); - publishButton.writableFeeds = Bandwagon.Controller.ExtensionsOverlay._getWritableFeeds(); + publishButton.writableCollections = Bandwagon.Controller.ExtensionsOverlay._getWritableCollections(); publishButton.invalidate(); } ]]> @@ -354,44 +382,44 @@ if (document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefox') && document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefoxwarning')) { - if (type == Bandwagon.Model.FeedItem.INSTALL_YES) + if (type == Bandwagon.Model.Addon.INSTALL_YES) { document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefox').disabled = false; document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefoxwarning').collapsed = true; } else { - if (type == Bandwagon.Model.FeedItem.INSTALL_NO_ADDON_IS_FOR_OLDER_VERSION) + if (type == Bandwagon.Model.Addon.INSTALL_NO_ADDON_IS_FOR_OLDER_VERSION) { document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefoxwarning').appendChild( - document.createTextNode(this._stringBundle.getString("bandwagon.feeditem.olderversionsoffirefox"))); + document.createTextNode(this._stringBundle.getString("bandwagon.addon.olderversionsoffirefox"))); } - else if (type == Bandwagon.Model.FeedItem.INSTALL_NO_UPGRADE_TO_USE_THIS_VERSION) + else if (type == Bandwagon.Model.Addon.INSTALL_NO_UPGRADE_TO_USE_THIS_VERSION) { var atffwl = document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefoxwarninglink'); - atffwl.value = this._stringBundle.getFormattedString("bandwagon.feeditem.upgradetofirefoxn1", [version]); + atffwl.value = this._stringBundle.getFormattedString("bandwagon.addon.upgradetofirefoxn1", [version]); atffwl.collapsed = false; - atffwl.addEventListener("click", function() { Bandwagon.Controller.FeedsPane.doUpgradeToFirefoxN(version); }, true); + atffwl.addEventListener("click", function() { Bandwagon.Controller.CollectionsPane.doUpgradeToFirefoxN(version); }, true); document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefoxwarning').appendChild( - document.createTextNode(this._stringBundle.getString("bandwagon.feeditem.upgradetofirefoxn2"))); + document.createTextNode(this._stringBundle.getString("bandwagon.addon.upgradetofirefoxn2"))); } - else if (type == Bandwagon.Model.FeedItem.INSTALL_NO_MUST_DOWNLOAD_BETA) + else if (type == Bandwagon.Model.Addon.INSTALL_NO_MUST_DOWNLOAD_BETA) { document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefoxwarning').appendChild( - document.createTextNode(this._stringBundle.getFormattedString("bandwagon.feeditem.requiresfirefoxbeta1", [version]))); + document.createTextNode(this._stringBundle.getFormattedString("bandwagon.addon.requiresfirefoxbeta1", [version]))); var atffwl = document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefoxwarninglink'); - atffwl.value = this._stringBundle.getFormattedString("bandwagon.feeditem.requiresfirefoxbeta2", [version]); + atffwl.value = this._stringBundle.getFormattedString("bandwagon.addon.requiresfirefoxbeta2", [version]); atffwl.collapsed = false; - atffwl.addEventListener("click", function() { Bandwagon.Controller.FeedsPane.doDownloadFirefoxNBeta(version); }, true); + atffwl.addEventListener("click", function() { Bandwagon.Controller.CollectionsPane.doDownloadFirefoxNBeta(version); }, true); document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefoxwarning').appendChild(atffwl); } - else if (type == Bandwagon.Model.FeedItem.INSTALL_NO_NOT_COMPATIBLE_OS) + else if (type == Bandwagon.Model.Addon.INSTALL_NO_NOT_COMPATIBLE_OS) { document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefoxwarning').appendChild( - document.createTextNode(this._stringBundle.getFormattedString("bandwagon.feeditem.notcompatible", [version]))); + document.createTextNode(this._stringBundle.getFormattedString("bandwagon.addon.notcompatible", [version]))); } document.getAnonymousElementByAttribute(this, 'anonid', 'addtofirefox').disabled = true; @@ -447,10 +475,10 @@ </implementation> </binding> - <binding id="bandwagon-feeditem-expanded" extends="chrome://bandwagon/content/ui/bindings/bandwagon.xml#bandwagon-feeditem"> + <binding id="bandwagon-addon-expanded" extends="chrome://bandwagon/content/ui/bindings/bandwagon.xml#bandwagon-addon"> <content> - <xul:stringbundle src="chrome://bandwagon/locale/bandwagonFeedItem.properties" + <xul:stringbundle src="chrome://bandwagon/locale/bandwagonAddon.properties" anonid="stringbundle"/> <xul:hbox flex="1"> @@ -466,15 +494,17 @@ <xul:label anonid="dateadded"/> </xul:hbox> <xul:hbox anonid="byline" flex="1"> - <xul:label anonid="author"/> + <xul:label anonid="authors"/> <xul:spacer flex="1"/> - <xul:label anonid="category"/> + <!--<xul:label anonid="category"/>--> </xul:hbox> + <xul:label anonid="commentauthor" flex="1"/> + <xul:description anonid="commentdesc"> </xul:description> </xul:vbox> </xul:hbox> <xul:hbox align="stretch" anonid="fulldesc" - class="feed-item-details" + class="collection-item-details" flex="1"> <xul:vbox pack="start"> <xul:hbox anonid="bandwagonThumbnailContainer" @@ -485,15 +515,13 @@ </xul:hbox> </xul:vbox> <xul:vbox flex="1"> - <xul:description anonid="commentdesc"> </xul:description> - <xul:label anonid="commentauthor" flex="1" class="right"/> <xul:description anonid="description"> - <xul:label anonid="learnmore" class="text-link" value="&feeditem.moreinfo;" onclick="Bandwagon.Controller.FeedsPane.doMoreInfo()"/> + <xul:label anonid="learnmore" class="text-link" value="&addon.moreinfo;" onclick="Bandwagon.Controller.CollectionsPane.doMoreInfo()"/> </xul:description> <xul:spacer flex="1"/> <xul:hbox pack="end" class="publishButton"> <xul:bandwagonPublishButton anonid="publish" label="&publishto.label;"/> - <xul:button anonid="addtofirefox" label="&feeditem.addtofirefox;" oncommand="Bandwagon.Controller.FeedsPane.doAddToFirefox()"/> + <xul:button anonid="addtofirefox" label="&addon.addtofirefox;" oncommand="Bandwagon.Controller.CollectionsPane.doAddToFirefox()"/> </xul:hbox> <xul:description anonid="addtofirefoxwarning" class="right"> <xul:label anonid="addtofirefoxwarninglink" class="text-link" collapsed="true"/> @@ -530,43 +558,32 @@ <content> <xul:button label="&publishto.label;" type="menu" - anonid="publishButton1" + anonid="publishButton" class="publishButton" collapsed="true"> - <xul:menupopup anonid="writableFeeds"> - <!-- writable feeds go here --> - <xul:menuseparator anonid="writableFeedSeparator"/> - <xul:menu label="&email.address.label;" anonid="emailAddressMenu1"> - <xul:menupopup anonid="emailAddresses1"> + <xul:menupopup anonid="writableCollections"> + <!-- writable collections go here --> + <xul:menuitem label="&new.collection.label;" oncommand="Bandwagon.Controller.ExtensionsOverlay.doNewCollection();" anonid="newCollection"/> + <xul:menuseparator anonid="writableCollectionSeparator"/> + <xul:menu label="&email.address.label;" anonid="emailAddressMenu"> + <xul:menupopup anonid="emailAddresses"> <!-- email addresses go here --> - <xul:menuseparator anonid="emailAddressSeparator1"/> + <xul:menuseparator anonid="emailAddressSeparator"/> <xul:menuitem label="&new.email.address.label;" oncommand="Bandwagon.Controller.ExtensionsOverlay.doAddNewShareEmail();"/> </xul:menupopup> </xul:menu> </xul:menupopup> </xul:button> - <xul:button label="&publishto.label;" - type="menu" - anonid="publishButton2" - class="publishButton" - collapsed="true"> - <xul:menupopup anonid="emailAddresses2"> - <!-- email addresses go here --> - <xul:menuseparator anonid="emailAddressSeparator2"/> - <xul:menuitem label="&new.email.address.label;"/> - </xul:menupopup> - </xul:button> - </content> <implementation> <field name="emailAddresses"/> - <field name="writableFeeds"/> + <field name="writableCollections"/> <constructor> <![CDATA[ - if (this.emailAddresses && this.writableFeeds) + if (this.emailAddresses && this.writableCollections) { this.invalidate(); } @@ -578,21 +595,18 @@ <![CDATA[ const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - var elemWritableFeedsPopup = document.getAnonymousElementByAttribute(this, "anonid", "writableFeeds"); - var elemWritableFeedSeparator = document.getAnonymousElementByAttribute(this, "anonid", "writableFeedSeparator"); - var elemEmailAddressesPopup1 = document.getAnonymousElementByAttribute(this, "anonid", "emailAddresses1"); - var elemEmailAddressesPopup2 = document.getAnonymousElementByAttribute(this, "anonid", "emailAddresses2"); - var elemEmailAddressSeparator1 = document.getAnonymousElementByAttribute(this, "anonid", "emailAddressSeparator1"); - var elemEmailAddressSeparator2 = document.getAnonymousElementByAttribute(this, "anonid", "emailAddressSeparator2"); - var elemEmailAddressMenu1 = document.getAnonymousElementByAttribute(this, "anonid", "emailAddressMenu1"); - var elemEmailAddressMenu2 = document.getAnonymousElementByAttribute(this, "anonid", "emailAddressMenu2"); - var elemPublishButton1 = document.getAnonymousElementByAttribute(this, "anonid", "publishButton1"); - var elemPublishButton2 = document.getAnonymousElementByAttribute(this, "anonid", "publishButton2"); + var elemWritableCollectionsPopup = document.getAnonymousElementByAttribute(this, "anonid", "writableCollections"); + var elemWritableCollectionSeparator = document.getAnonymousElementByAttribute(this, "anonid", "writableCollectionSeparator"); + var elemEmailAddressesPopup = document.getAnonymousElementByAttribute(this, "anonid", "emailAddresses"); + var elemEmailAddressSeparator = document.getAnonymousElementByAttribute(this, "anonid", "emailAddressSeparator"); + var elemEmailAddressMenu = document.getAnonymousElementByAttribute(this, "anonid", "emailAddressMenu"); + var elemPublishButton = document.getAnonymousElementByAttribute(this, "anonid", "publishButton"); + var elemNewCollection = document.getAnonymousElementByAttribute(this, "anonid", "newCollection"); // populate the email address menu - var activeEmailMenu = (this.writableFeeds.length==0?elemEmailAddressesPopup2:elemEmailAddressesPopup1); - var activeEmailAddressSeparator = (this.writableFeeds.length==0?elemEmailAddressSeparator2:elemEmailAddressSeparator1); + var activeEmailMenu = elemEmailAddressesPopup; + var activeEmailAddressSeparator = elemEmailAddressSeparator; if (this.emailAddresses.length) { @@ -621,40 +635,47 @@ activeEmailAddressSeparator.collapsed = true; } - if (this.writableFeeds.length) + // populate the collections menu + + function createAddToCollectionCallbackFunction(collection) { - // populate the feeds menu + return function() { Bandwagon.Controller.ExtensionsOverlay.doPublishToCollection(collection); } + } - function createFeedCallbackFunction(feed) - { - return function() { Bandwagon.Controller.ExtensionsOverlay.doPublishToFeed(feed); } - } + function createRemoveFromCollectionCallbackFunction(collection) + { + return function() { Bandwagon.Controller.ExtensionsOverlay.doRemoveFromCollection(collection); } + } - for (var i=0; i<this.writableFeeds.length; i++) - { - var feed = this.writableFeeds[i]; + for (var i=0; i<this.writableCollections.length; i++) + { + var collection = this.writableCollections[i]; - if (document.getAnonymousElementByAttribute(this, "anonid", "bandwagon-feed-" + feed.url)) - continue; + if (document.getAnonymousElementByAttribute(this, "anonid", "bandwagon-collection-" + collection.resourceURL)) + continue; - var callback = createFeedCallbackFunction(feed); + var callbackAdd = createAddToCollectionCallbackFunction(collection); + var callbackRemove = createRemoveFromCollectionCallbackFunction(collection); - var elemWritableFeed = document.createElementNS(XULNS, "menuitem"); - elemWritableFeed.setAttribute("label", (feed.name?feed.name:feed.url)); - elemWritableFeed.setAttribute("anonid", "bandwagon-feed-" + feed.url); - elemWritableFeed.addEventListener("command", callback, true); + var elemWritableCollection = document.createElementNS(XULNS, "menuitem"); + elemWritableCollection.setAttribute("label", (collection.name?collection.name:collection.resourceURL)); + elemWritableCollection.setAttribute("anonid", "bandwagon-collection-" + collection.resourceURL); - elemWritableFeedsPopup.insertBefore(elemWritableFeed, elemWritableFeedSeparator); + if (collection.__containsCurrentlySelectedExtension) + { + elemWritableCollection.setAttribute("checked", "true"); + elemWritableCollection.setAttribute("autocheck", "false"); + elemWritableCollection.addEventListener("command", callbackRemove, true); + } + else + { + elemWritableCollection.addEventListener("command", callbackAdd, true); } - elemPublishButton1.collapsed = false; - elemPublishButton2.collapsed = true; - } - else - { - elemPublishButton1.collapsed = true; - elemPublishButton2.collapsed = false; + elemWritableCollectionsPopup.insertBefore(elemWritableCollection, elemNewCollection); } + + elemPublishButton.collapsed = false; ]]> </body> </method> |