3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 if (typeof _yuitest_coverage == "undefined"){
8 _yuitest_coverage = {};
9 _yuitest_coverline = function(src, line){
10 var coverage = _yuitest_coverage[src];
11 if (!coverage.lines[line]){
12 coverage.calledLines++;
14 coverage.lines[line]++;
16 _yuitest_coverfunc = function(src, name, line){
17 var coverage = _yuitest_coverage[src],
18 funcId = name + ":" + line;
19 if (!coverage.functions[funcId]){
20 coverage.calledFunctions++;
22 coverage.functions[funcId]++;
25 _yuitest_coverage["build/pjax/pjax.js"] = {
32 path: "build/pjax/pjax.js",
35 _yuitest_coverage["build/pjax/pjax.js"].code=["YUI.add('pjax', function (Y, NAME) {","","/**","Provides seamless, gracefully degrading Pjax (pushState + Ajax) functionality,","which makes it easy to progressively enhance standard links on the page so that","they can be loaded normally in old browsers, or via Ajax (with HTML5 history","support) in newer browsers.","","@module pjax","@main","@since 3.5.0","**/","","/**","A stack of middleware which forms the default Pjax route.","","@property defaultRoute","@type Array","@static","@since 3.7.0","**/","var defaultRoute = ['loadContent', '_defaultRoute'],","","/**","Fired when an error occurs while attempting to load a URL via Ajax.","","@event error","@param {Object} content Content extracted from the response, if any."," @param {Node} content.node A `Y.Node` instance for a document fragment"," containing the extracted HTML content."," @param {String} [content.title] The title of the HTML page, if any,"," extracted using the `titleSelector` attribute. If `titleSelector` is"," not set or if a title could not be found, this property will be"," `undefined`.","@param {String} responseText Raw Ajax response text.","@param {Number} status HTTP status code for the Ajax response.","@param {String} url The absolute URL that failed to load.","@since 3.5.0","**/","EVT_ERROR = 'error',","","/**","Fired when a URL is successfully loaded via Ajax.","","@event load","@param {Object} content Content extracted from the response, if any."," @param {Node} content.node A `Y.Node` instance for a document fragment"," containing the extracted HTML content."," @param {String} [content.title] The title of the HTML page, if any,"," extracted using the `titleSelector` attribute. If `titleSelector` is"," not set or if a title could not be found, this property will be"," `undefined`.","@param {String} responseText Raw Ajax response text.","@param {Number} status HTTP status code for the Ajax response.","@param {String} url The absolute URL that was loaded.","@since 3.5.0","**/","EVT_LOAD = 'load';","","/**","Provides seamless, gracefully degrading Pjax (pushState + Ajax) functionality,","which makes it easy to progressively enhance standard links on the page so that","they can be loaded normally in old browsers, or via Ajax (with HTML5 history","support) in newer browsers.","","@class Pjax","@extends Router","@uses PjaxBase","@uses PjaxContent","@constructor","@param {Object} [config] Config attributes.","@since 3.5.0","**/","Y.Pjax = Y.Base.create('pjax', Y.Router, [Y.PjaxBase, Y.PjaxContent], {"," // -- Lifecycle Methods ----------------------------------------------------"," initializer: function () {"," this.publish(EVT_ERROR, {defaultFn: this._defCompleteFn});"," this.publish(EVT_LOAD, {defaultFn: this._defCompleteFn});"," },",""," // -- Protected Methods ----------------------------------------------------",""," /**"," Default Pjax route callback. Fires either the `load` or `error` event based"," on the status of the `Y.io` request made by the `loadContent()` middleware.",""," **Note:** This route callback assumes that it's called after the"," `loadContent()` middleware.",""," @method _defaultRoute"," @param {Object} req Request object."," @param {Object} res Response Object."," @param {Function} next Function to pass control to the next route callback."," @protected"," @since 3.5.0"," @see Y.Pjax.defaultRoute"," **/"," _defaultRoute: function (req, res, next) {"," var ioResponse = res.ioResponse,"," status = ioResponse.status,"," event = status >= 200 && status < 300 ? EVT_LOAD : EVT_ERROR;",""," this.fire(event, {"," content : res.content,"," responseText: ioResponse.responseText,"," status : status,"," url : req.ioURL"," });",""," next();"," },",""," // -- Event Handlers -------------------------------------------------------",""," /**"," Default event handler for both the `error` and `load` events. Attempts to"," insert the loaded content into the `container` node and update the page's"," title.",""," @method _defCompleteFn"," @param {EventFacade} e"," @protected"," @since 3.5.0"," **/"," _defCompleteFn: function (e) {"," var container = this.get('container'),"," content = e.content;",""," if (container && content.node) {"," container.setHTML(content.node);"," }",""," if (content.title && Y.config.doc) {"," Y.config.doc.title = content.title;"," }"," }","}, {"," ATTRS: {"," /**"," Node into which content should be inserted when a page is loaded via"," Pjax. This node's existing contents will be removed to make way for the"," new content.",""," If not set, loaded content will not be automatically inserted into the"," page.",""," @attribute container"," @type Node"," @default null"," @since 3.5.0"," **/"," container: {"," value : null,"," setter: Y.one"," },",""," // Inherited from Router and already documented there."," routes: {"," value: ["," {path: '*', callbacks: defaultRoute}"," ]"," }"," },",""," // Documented towards the top of this file."," defaultRoute: defaultRoute","});","","","}, '3.7.2', {\"requires\": [\"pjax-base\", \"pjax-content\"]});"];
36 _yuitest_coverage["build/pjax/pjax.js"].lines = {"1":0,"22":0,"74":0,"77":0,"78":0,"99":0,"103":0,"110":0,"126":0,"129":0,"130":0,"133":0,"134":0};
37 _yuitest_coverage["build/pjax/pjax.js"].functions = {"initializer:76":0,"_defaultRoute:98":0,"_defCompleteFn:125":0,"(anonymous 1):1":0};
38 _yuitest_coverage["build/pjax/pjax.js"].coveredLines = 13;
39 _yuitest_coverage["build/pjax/pjax.js"].coveredFunctions = 4;
40 _yuitest_coverline("build/pjax/pjax.js", 1);
41 YUI.add('pjax', function (Y, NAME) {
44 Provides seamless, gracefully degrading Pjax (pushState + Ajax) functionality,
45 which makes it easy to progressively enhance standard links on the page so that
46 they can be loaded normally in old browsers, or via Ajax (with HTML5 history
47 support) in newer browsers.
55 A stack of middleware which forms the default Pjax route.
57 @property defaultRoute
62 _yuitest_coverfunc("build/pjax/pjax.js", "(anonymous 1)", 1);
63 _yuitest_coverline("build/pjax/pjax.js", 22);
64 var defaultRoute = ['loadContent', '_defaultRoute'],
67 Fired when an error occurs while attempting to load a URL via Ajax.
70 @param {Object} content Content extracted from the response, if any.
71 @param {Node} content.node A `Y.Node` instance for a document fragment
72 containing the extracted HTML content.
73 @param {String} [content.title] The title of the HTML page, if any,
74 extracted using the `titleSelector` attribute. If `titleSelector` is
75 not set or if a title could not be found, this property will be
77 @param {String} responseText Raw Ajax response text.
78 @param {Number} status HTTP status code for the Ajax response.
79 @param {String} url The absolute URL that failed to load.
85 Fired when a URL is successfully loaded via Ajax.
88 @param {Object} content Content extracted from the response, if any.
89 @param {Node} content.node A `Y.Node` instance for a document fragment
90 containing the extracted HTML content.
91 @param {String} [content.title] The title of the HTML page, if any,
92 extracted using the `titleSelector` attribute. If `titleSelector` is
93 not set or if a title could not be found, this property will be
95 @param {String} responseText Raw Ajax response text.
96 @param {Number} status HTTP status code for the Ajax response.
97 @param {String} url The absolute URL that was loaded.
103 Provides seamless, gracefully degrading Pjax (pushState + Ajax) functionality,
104 which makes it easy to progressively enhance standard links on the page so that
105 they can be loaded normally in old browsers, or via Ajax (with HTML5 history
106 support) in newer browsers.
113 @param {Object} [config] Config attributes.
116 _yuitest_coverline("build/pjax/pjax.js", 74);
117 Y.Pjax = Y.Base.create('pjax', Y.Router, [Y.PjaxBase, Y.PjaxContent], {
118 // -- Lifecycle Methods ----------------------------------------------------
119 initializer: function () {
120 _yuitest_coverfunc("build/pjax/pjax.js", "initializer", 76);
121 _yuitest_coverline("build/pjax/pjax.js", 77);
122 this.publish(EVT_ERROR, {defaultFn: this._defCompleteFn});
123 _yuitest_coverline("build/pjax/pjax.js", 78);
124 this.publish(EVT_LOAD, {defaultFn: this._defCompleteFn});
127 // -- Protected Methods ----------------------------------------------------
130 Default Pjax route callback. Fires either the `load` or `error` event based
131 on the status of the `Y.io` request made by the `loadContent()` middleware.
133 **Note:** This route callback assumes that it's called after the
134 `loadContent()` middleware.
136 @method _defaultRoute
137 @param {Object} req Request object.
138 @param {Object} res Response Object.
139 @param {Function} next Function to pass control to the next route callback.
142 @see Y.Pjax.defaultRoute
144 _defaultRoute: function (req, res, next) {
145 _yuitest_coverfunc("build/pjax/pjax.js", "_defaultRoute", 98);
146 _yuitest_coverline("build/pjax/pjax.js", 99);
147 var ioResponse = res.ioResponse,
148 status = ioResponse.status,
149 event = status >= 200 && status < 300 ? EVT_LOAD : EVT_ERROR;
151 _yuitest_coverline("build/pjax/pjax.js", 103);
153 content : res.content,
154 responseText: ioResponse.responseText,
159 _yuitest_coverline("build/pjax/pjax.js", 110);
163 // -- Event Handlers -------------------------------------------------------
166 Default event handler for both the `error` and `load` events. Attempts to
167 insert the loaded content into the `container` node and update the page's
170 @method _defCompleteFn
171 @param {EventFacade} e
175 _defCompleteFn: function (e) {
176 _yuitest_coverfunc("build/pjax/pjax.js", "_defCompleteFn", 125);
177 _yuitest_coverline("build/pjax/pjax.js", 126);
178 var container = this.get('container'),
181 _yuitest_coverline("build/pjax/pjax.js", 129);
182 if (container && content.node) {
183 _yuitest_coverline("build/pjax/pjax.js", 130);
184 container.setHTML(content.node);
187 _yuitest_coverline("build/pjax/pjax.js", 133);
188 if (content.title && Y.config.doc) {
189 _yuitest_coverline("build/pjax/pjax.js", 134);
190 Y.config.doc.title = content.title;
196 Node into which content should be inserted when a page is loaded via
197 Pjax. This node's existing contents will be removed to make way for the
200 If not set, loaded content will not be automatically inserted into the
213 // Inherited from Router and already documented there.
216 {path: '*', callbacks: defaultRoute}
221 // Documented towards the top of this file.
222 defaultRoute: defaultRoute
226 }, '3.7.2', {"requires": ["pjax-base", "pjax-content"]});