YAHOO.namespace('MRSKIN'); (function(){ var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event, Lang = YAHOO.lang, Get = YAHOO.util.Get, CSS_PREFIX = 'mrskin_widget_', CSS_MODULE_PREFIX = 'mrskin_updates_', MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];; var ContentUpdates = function(oConfigs) { ContentUpdates.superclass.constructor.call(this, document.createElement('div'), oConfigs); }; // By copying a reference to it to to a variable rooted in the global namespace, we make it public YAHOO.MRSKIN.ContentUpdates = ContentUpdates; // now we are actually doing the inheritance part. Lang.extend(ContentUpdates,YAHOO.util.Element, { // here we override it with out own so we can add out own configuration properties initAttributes: function (oConfigs) { // First of all we call the base class initAttributes so Element has its predefined configuration attributes ContentUpdates.superclass.initAttributes.call(this, oConfigs); // The Element constructor will already put our component container along the attributes var container = this.get('element'); this.setAttributeConfig("dataObject",{ validator: Lang.isObject, value: oConfigs.dataObject }); this.setAttributeConfig("limit",{ validator: Lang.isNumber, value: oConfigs.limit || 0 }); this.setAttributeConfig("affiliateCode",{ validator: Lang.isString, value: oConfigs.affiliateCode || '' }); this.setAttributeConfig("campaign",{ validator: Lang.isString, value: oConfigs.campaign || '' }); this.setAttributeConfig("urlPath",{ validator: Lang.isString, value: oConfigs.urlPath }); this.setAttributeConfig("css",{ validator: Lang.isString, value: oConfigs.css || '' }); this.setAttributeConfig("heading",{ validator: Lang.isString, value: oConfigs.heading || 'Content Updates' }); this.setAttributeConfig("showDate",{ validator: Lang.isBoolean, value: oConfigs.showDate || false }); this.setAttributeConfig("dateString",{ validator: Lang.isString, value: oConfigs.dateString || 'today' }); this.setAttributeConfig("linkTarget",{ validator: Lang.isString, value: oConfigs.linkTarget }); }, /* * parentEl optional if no target is defined one will be * created and appended to the body */ render: function (parentEl) { parentEl = Dom.get(parentEl); if (!parentEl) { YAHOO.log('Missing mandatory argument in ContentUpdates: parentEl','error'); return null; } var css = this.get('css'); if (css) Get.css(css); var containerEl = this.get('element'); Dom.addClass(containerEl,CSS_MODULE_PREFIX+"container "+CSS_PREFIX+"container"); parentEl.appendChild(containerEl); this.getData(); }, destroy: function () { var el = this.get('element'); Event.purgeElement(el, true); el.parentNode.removeChild(el); }, getData: function () { var dateString = this.get('dateString'); var limit = this.get('limit'); if (limit) { limit = '&options[limit]='+limit; } else { limit = ''; } var dsScriptNode = new YAHOO.util.ScriptNodeDataSource('http://www.mrskin.com/feeds/updates/json'); dsScriptNode.responseSchema = { resultsList: "resultsList", fields: ["star", "title", "picCount", "nudePicCount", "clipCount", "nudeClipCount"], metaFields: {timestamp:"timestamp"} }; dsScriptNode.scriptCallbackParam = 'options[callback]'; dsScriptNode.sendRequest('?options[date]='+dateString+limit,function (oResp, results) { this.set('dataObject',results); this._renderMarkUp(); },this); }, getCampaign: function (){ var ret = ''; var camp = this.get('campaign'); if (camp) { ret = "?autocamp="+camp; } return ret; }, _renderMarkUp: function () { var containerEl = this.get('element'); var path = this.get('urlPath'), aff = this.get('affiliateCode'), campaign = this.getCampaign(), obj = this.get('dataObject'), heading = this.get('heading'), linkTarget = this.get('linkTarget'), tpl = []; linkTarget = linkTarget ? ' target="'+linkTarget+'"' : ''; tpl.push('