NFL.com Flash Video Players
NFL Fantasy Mobile
Yay! JavaScript
Photo by ElvertBarnes
Photo by mike 23
var MyClass = Class.create({ initialize: function () { // the rest is up to you } });
NFL.com | Fantasy | Club Sites |
---|---|---|
|
||
Prototype | YUI | jQuery |
Launched: 1 week after home page launch
Super Bowl promo with slide implementation
// Prototype 1.6.0.3 // Non-standard array sugar Array.prototype.reduce = function() { return this.length > 1 ? this : this[0]; }; // YUI // Standard method defined in JavaScript 1.8 Y.Array.reduce = Array.prototype.reduce ? NATIVE_REDUCE : CUSTOM_REDUCE;
// Just make sure you `use()` this when Prototype is on the page. YUI.add("prototype-compat", function (Y) { var arrayProto = Array.prototype; arrayProto._protoReduce = arrayProto.reduce; arrayProto.reduce = function () { if (arguments.length) { return CUSTOM_REDUCE.apply(this, arguments); } else { return this._protoReduce(); } }; });
Y.Node.prototype.one = function (sel) { var newNode = Element.down(this._node, sel); return Y.one(newNode); };
<div id="my-element"> <div class="child"> <div class="descendent"></div> </div> </div>
// YUI node.one(">div"); // div.child // Prototype Element.down(node._node, ">div"); // div.descendent!
Y.Node.prototype.one = function (sel) { var parent = Element.up(this._node), newNode = parent.down("#" + this.get("id") + " " + sel)); return Y.one(newNode); };
YUI().use('event-custom', function (Y) { var publisher = new Y.EventTarget(); Object.extend(document, { _fire: Element.Methods.fire.methodize(), fire: function (eventName, memo) { var evt = document._fire(eventName, memo); // publish and fire a YUI custom event return evt; } }); });
Broadcast prototype custom events to YUI.
var flashVars:Object = this.loaderInfo.parameters, // these flashVars available to any swf // embedded with Y.SWF var yId:String = flashVars.yId; var swfId:String = flashVars.YUISwfId; var callback:String = flashVars.YUIBridgeCallback; ExternalInterface.call("YUI.applyTo", yId, callback, [swfId, { type: "flash:frob", // make sure it has a ":" memo: { frobs: 7 } // any valid JSON data types }]);
Fire YUI events from a SWF.
YUI({ modules: { "scorestrip-iframe": { condition: { trigger: "scorestrip", test: function (Y) { var loc = Y.config.win.location, domain = [loc.protocol, loc.host].join("//"); return "http://www.nfl.com/" !== domain; }, when: "instead" } }}).use(...);
var SSTile = Y.Base.create("scorestrip-tile", Y.Widget, [Y.WidgetChild], { bindUI: function () { this.after("isRedZoneChange", this._afterRedZoneChange); } }, { ATTRS: { isRedZone: { value: false } } });
initializer: function(config) { this.publish("update", { broadcast: 2 }); }
var MyClass = Class.create({ initialize: function () { // the rest is up to you } });
var MyClass = Y.Base.generate("my-class", Y.Widget, EXTENSIONS, { // prepare non-DOM elements initializer: function (config) {}, // create DOM renderUI: function() {}, // set event listeners bindUI: function() {}, // set up UI based on current state syncUI: function() {}, // clean up after yourself destructor: function () {} }, { // properties that require mutation events ATTRS: {}, // properties to be parsed from HTML HTML_PARSER: {} });
/* set up positioning, metrics, etc. */ .yui3-my-class {} /* set background, padding, borders */ .yui3-my-class-content {} /* handle the hidden state */ .yui3-my-class-hidden {} /* handle the focused static */ .yui3-my-class-focused {} /* namespace your internal DOM */ .yui3-my-class-heading {} .yui3-my-class li {}
bindUI: function () { var header = this.get("boundingBox").one(".header"); header.on("click", this._onHeaderClick, this); this.after("openedChange", this._afterOpenedChange); }, _onHeaderClick: function (event) { event.halt(); this.set("opened", !this.get("opened")); }, _afterOpenedChange: function (event) { if (event.newVal) { // change the view to opened state } else { // change the view to closed state } }
Minify: http://code.google.com/p/minify/
var YUI_config = { comboBase: "http://www.nfl.com/yui/combo/index.php?b=yui3&f=", comboSep: ",", combine: true, maxURLLength: 1000, groups: { nfl: { base: "http://j.nflcdn.com/scripts/", combine: false, modules: { /* NFL module definitions */ } } } };
YUI({ modules: { "video-swf" : { condition: { test: function (Y) { return Y.SWFDetect.hasFlashVersion(10, 2, 0); } } } }});
<!-- direct reference --> <link href="/audio-player/assets/skins/sam/audio-player.css" /> <!-- combined --> <link href="/combo/?f=audio-player/assets/skins/sam/audio-player.css" />
Relative paths get confused.
©2011 Ryan Cannon