//>>built
define("dojox/widget/FeedPortlet",["dijit","dojo","dojox","dojo/require!dojox/widget/Portlet,dijit/Tooltip,dijit/form/TextBox,dijit/form/Button,dojox/data/GoogleFeedStore"],function(g,a,h){a.provide("dojox.widget.FeedPortlet");a.require("dojox.widget.Portlet");a.require("dijit.Tooltip");a.require("dijit.form.TextBox");a.require("dijit.form.Button");a.require("dojox.data.GoogleFeedStore");a.declare("dojox.widget.FeedPortlet",h.widget.Portlet,{local:!1,maxResults:5,url:"",openNew:!0,showFeedTitle:!0,
postCreate:function(){this.inherited(arguments);if(this.local&&!h.data.AtomReadStore)throw Error(this.declaredClass+": To use local feeds, you must include dojox.data.AtomReadStore on the page.");},onFeedError:function(){this.containerNode.innerHTML="Error accessing the feed."},addChild:function(b){this.inherited(arguments);var d=b.attr("feedPortletUrl");d&&this.set("url",d)},_getTitle:function(b){b=this.store.getValue(b,"title");return this.local?b.text:b},_getLink:function(b){b=this.store.getValue(b,
"link");return this.local?b.href:b},_getContent:function(b){b=this.store.getValue(b,"summary");if(!b)return null;this.local&&(b=b.text);b=b.split("\x3cscript").join("\x3c!--").split("\x3c/script\x3e").join("--\x3e");return b=b.split("\x3ciframe").join("\x3c!--").split("\x3c/iframe\x3e").join("--\x3e")},_setUrlAttr:function(b){this.url=b;this._started&&this.load()},startup:function(){if(!this.started&&!this._started){this.inherited(arguments);if(!this.url||""==this.url)throw Error(this.id+": A URL must be specified for the feed portlet");
this.url&&""!=this.url&&this.load()}},load:function(){this._resultList&&a.destroy(this._resultList);if(this.local){var b=new h.data.AtomReadStore({url:this.url});var d={}}else b=new h.data.GoogleFeedStore,d={url:this.url};d={query:d,count:this.maxResults,onComplete:a.hitch(this,function(c){if(this.showFeedTitle&&b.getFeedValue){var e=this.store.getFeedValue("title");e&&this.set("title",e.text?e.text:e)}this.generateResults(c)}),onError:a.hitch(this,"onFeedError")};this.store=b;b.fetch(d)},generateResults:function(b){var d,
c=this._resultList=a.create("ul",{"class":"dojoxFeedPortletList"},this.containerNode);a.forEach(b,a.hitch(this,function(e){var f=a.create("li",{innerHTML:'\x3ca href\x3d"'+this._getLink(e)+'"'+(this.openNew?' target\x3d"_blank"':"")+"\x3e"+this._getTitle(e)+"\x3c/a\x3e"},c);a.connect(f,"onmouseover",a.hitch(this,function(m){d&&clearTimeout(d);d=setTimeout(a.hitch(this,function(){d=null;var k=this._getContent(e);k&&(k='\x3cdiv class\x3d"dojoxFeedPortletPreview"\x3e'+k+"\x3c/div\x3e",a.query("li",c).forEach(function(l){l!=
m.target&&g.hideTooltip(l)}),g.showTooltip(k,f.firstChild,!this.isLeftToRight()))}),500)}));a.connect(f,"onmouseout",function(){d&&(clearTimeout(d),d=null);g.hideTooltip(f.firstChild)})}));this.resize()}});a.declare("dojox.widget.ExpandableFeedPortlet",h.widget.FeedPortlet,{onlyOpenOne:!1,generateResults:function(b){var d=this._resultList=a.create("ul",{"class":"dojoxFeedPortletExpandableList"},this.containerNode);a.forEach(b,a.hitch(this,a.hitch(this,function(c){var e=a.create("li",{"class":"dojoxPortletItemCollapsed"},
d),f=a.create("div",{style:"width: 100%;"},e);a.create("div",{"class":"dojoxPortletItemSummary",innerHTML:this._getContent(c)},e);a.create("span",{"class":"dojoxPortletToggleIcon",innerHTML:"\x3cimg src\x3d'"+a.config.baseUrl+"/resources/blank.gif'\x3e"},f);c=a.create("a",{href:this._getLink(c),innerHTML:this._getTitle(c)},f);this.openNew&&a.attr(c,"target","_blank")})));a.connect(d,"onclick",a.hitch(this,function(c){if(a.hasClass(c.target,"dojoxPortletToggleIcon")||a.hasClass(c.target.parentNode,
"dojoxPortletToggleIcon")){a.stopEvent(c);for(var e=c.target.parentNode;"LI"!=e.tagName;)e=e.parentNode;this.onlyOpenOne&&a.query("li",d).filter(function(f){return f!=e}).removeClass("dojoxPortletItemOpen").addClass("dojoxPortletItemCollapsed");c=a.hasClass(e,"dojoxPortletItemOpen");a.toggleClass(e,"dojoxPortletItemOpen",!c);a.toggleClass(e,"dojoxPortletItemCollapsed",c)}}))}});a.declare("dojox.widget.PortletFeedSettings",h.widget.PortletSettings,{"class":"dojoxPortletFeedSettings",urls:null,selectedIndex:0,
buildRendering:function(){if(this.urls&&0<this.urls.length){var b=a.create("select");this.srcNodeRef&&(a.place(b,this.srcNodeRef,"before"),a.destroy(this.srcNodeRef));this.srcNodeRef=b;a.forEach(this.urls,function(c){a.create("option",{value:c.url||c,innerHTML:c.label||c},b)})}if("SELECT"==this.srcNodeRef.tagName){this.text=this.srcNodeRef;var d=a.create("div",{},this.srcNodeRef,"before");d.appendChild(this.text);this.srcNodeRef=d;a.query("option",this.text).filter("return !item.value;").forEach("item.value \x3d item.innerHTML");
this.text.value||(this.content&&0==this.text.options.length&&this.text.appendChild(this.content),a.attr(b||this.text,"value",this.text.options[this.selectedIndex].value))}this.inherited(arguments)},_setContentAttr:function(){},postCreate:function(){if(!this.text){var b=this.text=new g.form.TextBox({});a.create("span",{innerHTML:"Choose Url: "},this.domNode);this.addChild(b)}this.addChild(new g.form.Button({label:"Load",onClick:a.hitch(this,function(){this.portlet.attr("url","SELECT"==this.text.tagName?
this.text.value:this.text.attr("value"));"SELECT"==this.text.tagName&&a.some(this.text.options,a.hitch(this,function(d,c){return d.selected?(this.set("selectedIndex",c),!0):!1}));this.toggle()})}));this.addChild(new g.form.Button({label:"Cancel",onClick:a.hitch(this,"toggle")}));this.inherited(arguments)},startup:function(){if(!this._started){this.inherited(arguments);if(!this.portlet)throw Error(this.declaredClass+": A PortletFeedSettings widget cannot exist without a Portlet.");"SELECT"==this.text.tagName&&
a.forEach(this.text.options,a.hitch(this,function(d,c){a.attr(d,"selected",c==this.selectedIndex)}));var b=this.portlet.attr("url");b?"SELECT"==this.text.tagName?!this.urls&&1>a.query("option[value\x3d'"+b+"']",this.text).length&&a.place(a.create("option",{value:b,innerHTML:b,selected:"true"}),this.text,"first"):this.text.attr("value",b):this.portlet.attr("url",this.get("feedPortletUrl"))}},_getFeedPortletUrlAttr:function(){return this.text.value}})});