|
10 __coverage__['build/app-content/app-content.js'] = {"path":"build/app-content/app-content.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0,0],"7":[0,0],"8":[0,0],"9":[0,0,0],"10":[0,0],"11":[0,0],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":42}}},"2":{"name":"AppContent","line":57,"loc":{"start":{"line":57,"column":0},"end":{"line":57,"column":22}}},"3":{"name":"(anonymous_3)","line":116,"loc":{"start":{"line":116,"column":17},"end":{"line":116,"column":55}}},"4":{"name":"(anonymous_4)","line":196,"loc":{"start":{"line":196,"column":19},"end":{"line":196,"column":45}}},"5":{"name":"(anonymous_5)","line":207,"loc":{"start":{"line":207,"column":66},"end":{"line":207,"column":78}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":234,"column":57}},"2":{"start":{"line":11,"column":0},"end":{"line":11,"column":32}},"3":{"start":{"line":57,"column":0},"end":{"line":59,"column":1}},"4":{"start":{"line":58,"column":4},"end":{"line":58,"column":39}},"5":{"start":{"line":72,"column":0},"end":{"line":72,"column":52}},"6":{"start":{"line":74,"column":0},"end":{"line":221,"column":2}},"7":{"start":{"line":118,"column":8},"end":{"line":118,"column":33}},"8":{"start":{"line":121,"column":8},"end":{"line":124,"column":9}},"9":{"start":{"line":122,"column":12},"end":{"line":122,"column":43}},"10":{"start":{"line":123,"column":12},"end":{"line":123,"column":28}},"11":{"start":{"line":129,"column":8},"end":{"line":129,"column":52}},"12":{"start":{"line":131,"column":8},"end":{"line":135,"column":55}},"13":{"start":{"line":139,"column":8},"end":{"line":139,"column":28}},"14":{"start":{"line":144,"column":8},"end":{"line":148,"column":9}},"15":{"start":{"line":147,"column":12},"end":{"line":147,"column":48}},"16":{"start":{"line":153,"column":8},"end":{"line":170,"column":9}},"17":{"start":{"line":154,"column":12},"end":{"line":154,"column":32}},"18":{"start":{"line":156,"column":12},"end":{"line":156,"column":57}},"19":{"start":{"line":159,"column":12},"end":{"line":160,"column":65}},"20":{"start":{"line":163,"column":12},"end":{"line":163,"column":68}},"21":{"start":{"line":164,"column":12},"end":{"line":164,"column":48}},"22":{"start":{"line":169,"column":12},"end":{"line":169,"column":38}},"23":{"start":{"line":173,"column":8},"end":{"line":173,"column":65}},"24":{"start":{"line":177,"column":8},"end":{"line":177,"column":70}},"25":{"start":{"line":197,"column":8},"end":{"line":199,"column":29}},"26":{"start":{"line":202,"column":8},"end":{"line":202,"column":58}},"27":{"start":{"line":202,"column":42},"end":{"line":202,"column":56}},"28":{"start":{"line":204,"column":8},"end":{"line":210,"column":9}},"29":{"start":{"line":207,"column":12},"end":{"line":209,"column":15}},"30":{"start":{"line":208,"column":16},"end":{"line":208,"column":42}},"31":{"start":{"line":212,"column":8},"end":{"line":212,"column":39}},"32":{"start":{"line":215,"column":8},"end":{"line":217,"column":9}},"33":{"start":{"line":216,"column":12},"end":{"line":216,"column":38}},"34":{"start":{"line":219,"column":8},"end":{"line":219,"column":15}},"35":{"start":{"line":224,"column":0},"end":{"line":224,"column":63}},"36":{"start":{"line":227,"column":0},"end":{"line":227,"column":47}},"37":{"start":{"line":230,"column":0},"end":{"line":230,"column":27}},"38":{"start":{"line":231,"column":0},"end":{"line":231,"column":32}}},"branchMap":{"1":{"line":121,"type":"if","locations":[{"start":{"line":121,"column":8},"end":{"line":121,"column":8}},{"start":{"line":121,"column":8},"end":{"line":121,"column":8}}]},"2":{"line":131,"type":"binary-expr","locations":[{"start":{"line":131,"column":25},"end":{"line":131,"column":37}},{"start":{"line":131,"column":41},"end":{"line":131,"column":43}}]},"3":{"line":132,"type":"cond-expr","locations":[{"start":{"line":132,"column":52},"end":{"line":132,"column":56}},{"start":{"line":132,"column":59},"end":{"line":132,"column":68}}]},"4":{"line":133,"type":"cond-expr","locations":[{"start":{"line":133,"column":52},"end":{"line":133,"column":63}},{"start":{"line":133,"column":66},"end":{"line":133,"column":68}}]},"5":{"line":144,"type":"if","locations":[{"start":{"line":144,"column":8},"end":{"line":144,"column":8}},{"start":{"line":144,"column":8},"end":{"line":144,"column":8}}]},"6":{"line":144,"type":"binary-expr","locations":[{"start":{"line":144,"column":12},"end":{"line":144,"column":19}},{"start":{"line":144,"column":23},"end":{"line":144,"column":43}},{"start":{"line":145,"column":16},"end":{"line":145,"column":54}}]},"7":{"line":153,"type":"if","locations":[{"start":{"line":153,"column":8},"end":{"line":153,"column":8}},{"start":{"line":153,"column":8},"end":{"line":153,"column":8}}]},"8":{"line":153,"type":"binary-expr","locations":[{"start":{"line":153,"column":12},"end":{"line":153,"column":19}},{"start":{"line":153,"column":23},"end":{"line":153,"column":52}}]},"9":{"line":156,"type":"binary-expr","locations":[{"start":{"line":156,"column":20},"end":{"line":156,"column":28}},{"start":{"line":156,"column":32},"end":{"line":156,"column":45}},{"start":{"line":156,"column":50},"end":{"line":156,"column":56}}]},"10":{"line":159,"type":"cond-expr","locations":[{"start":{"line":160,"column":20},"end":{"line":160,"column":57}},{"start":{"line":160,"column":60},"end":{"line":160,"column":64}}]},"11":{"line":202,"type":"if","locations":[{"start":{"line":202,"column":8},"end":{"line":202,"column":8}},{"start":{"line":202,"column":8},"end":{"line":202,"column":8}}]},"12":{"line":202,"type":"binary-expr","locations":[{"start":{"line":202,"column":14},"end":{"line":202,"column":21}},{"start":{"line":202,"column":25},"end":{"line":202,"column":37}}]},"13":{"line":204,"type":"if","locations":[{"start":{"line":204,"column":8},"end":{"line":204,"column":8}},{"start":{"line":204,"column":8},"end":{"line":204,"column":8}}]},"14":{"line":204,"type":"binary-expr","locations":[{"start":{"line":204,"column":12},"end":{"line":204,"column":25}},{"start":{"line":204,"column":29},"end":{"line":204,"column":32}}]},"15":{"line":215,"type":"if","locations":[{"start":{"line":215,"column":8},"end":{"line":215,"column":8}},{"start":{"line":215,"column":8},"end":{"line":215,"column":8}}]}},"code":["(function () { YUI.add('app-content', function (Y, NAME) {","","/**","`Y.App` extension that provides pjax-style content fetching and handling.","","@module app","@submodule app-content","@since 3.7.0","**/","","var PjaxContent = Y.PjaxContent;","","/**","`Y.App` extension that provides pjax-style content fetching and handling.","","This makes it easy to fetch server rendered content for URLs using Ajax. The","HTML content returned from the server will be view-ified and set as the app's","main content, making it seamless to use a mixture of server and client rendered","views.","","When the `\"app-content\"` module is used, it will automatically mix itself into","`Y.App`, and it provides three main features:",""," - **`Y.App.Content.route`**: A stack of middleware which forms a pjax-style"," content route.",""," - **`loadContent()`**: Route middleware which load content from a server. This"," makes an Ajax request for the requested URL, parses the returned content and"," puts it on the route's response object.",""," - **`showContent()`**: Method which provides an easy way to view-ify HTML"," content which should be shown as an app's active/visible view.","","The following is an example of how these features can be used:",""," // Creates a new app and registers the `\"post\"` view."," var app = new Y.App({"," views: {"," post: {type: Y.PostView}"," }"," });",""," // Uses a simple server rendered content route for the About page."," app.route('/about/', Y.App.Content.route);",""," // Uses the `loadContent()` middleware to fetch the contents of the post"," // from the server and shows that content in a `\"post\"` view."," app.route('/posts/:id/', 'loadContent', function (req, res, next) {"," this.showContent(res.content.node, {view: 'post'});"," });","","@class App.Content","@uses PjaxContent","@extensionfor App","@since 3.7.0","**/","function AppContent() {"," PjaxContent.apply(this, arguments);","}","","/**","A stack of middleware which forms a pjax-style content route.","","This route will load the rendered HTML content from the server, then create and","show a new view using those contents.","","@property route","@type Array","@static","@since 3.7.0","**/","AppContent.route = ['loadContent', '_contentRoute'];","","AppContent.prototype = {"," // -- Public Methods -------------------------------------------------------",""," /**"," Sets this app's `activeView` attribute using the specified `content`.",""," This provides an easy way to view-ify HTML content which should be shown as"," this app's active/visible view. This method will determine the appropriate"," view `container` node based on the specified `content`. By default, a new"," `Y.View` instance will be created unless `options.view` is specified.",""," Under the hood, this method calls the `showView()` method, so refer to its"," docs for more information.",""," @method showContent"," @param {HTMLElement|Node|String} content The content to show, it may be"," provided as a selector string, a DOM element, or a `Y.Node` instance."," @param {Object} [options] Optional objects containing any of the following"," properties in addition to any `showView()` options:",""," @param {Object|String} [options.view] The name of a view defined in this"," app's `views`, or an object with the following properties:",""," @param {String} options.view.name The name of a view defined in this"," app's `views`."," @param {Object} [options.view.config] Optional configuration to use when"," creating the new view instance. This config object can also be used"," to update an existing or preserved view's attributes when"," `options.update` is `true`. **Note:** If a `container` is specified,"," it will be overridden by the `content` specified in the first"," argument.",""," @param {Function} [callback] Optional callback function to call after the"," new `activeView` is ready to use. **Note:** this will override"," `options.callback` and it can be specified as either the second or third"," argument. The function will be passed the following:",""," @param {View} callback.view A reference to the new `activeView`.",""," @since 3.7.0"," @see App.showView()"," **/"," showContent: function (content, options, callback) {"," // Makes sure we have a node instance, and will query selector strings."," content = Y.one(content);",""," // Support the callback function being either the second or third arg."," if (typeof options === 'function') {"," options = {callback: options};"," callback = null;"," }",""," // Mix in default option to *not* render the view because presumably we"," // have pre-rendered content here. This also creates a copy so we can"," // modify the object."," options = Y.merge({render: false}, options);",""," var view = options.view || '',"," viewName = typeof view === 'string' ? view : view.name,"," viewConfig = typeof view !== 'string' ? view.config : {},"," viewInfo = this.getViewInfo(viewName),"," container, template, type, ViewConstructor;",""," // Remove `view` from the `options` which will be passed along to the"," // `showView()` method."," delete options.view;",""," // When the specified `content` is a document fragment, we want to see"," // if it only contains a single node, and use that as the content. This"," // checks `childNodes` which will include text nodes."," if (content && content.isFragment() &&"," content.get('childNodes').size() === 1) {",""," content = content.get('firstChild');"," }",""," // When the `content` is an element node (`nodeType` 1), we can use it"," // as-is for the `container`. Otherwise, we'll construct a new container"," // based on the `options.view`'s `containerTemplate`."," if (content && content.get('nodeType') === 1) {"," container = content;"," } else {"," type = (viewInfo && viewInfo.type) || Y.View;",""," // Looks for a namespaced constructor function on `Y`."," ViewConstructor = typeof type === 'string' ?"," Y.Object.getValue(Y, type.split('.')) : type;",""," // Find the correct node template for the view."," template = ViewConstructor.prototype.containerTemplate;"," container = Y.Node.create(template);",""," // Append the document fragment to the newly created `container`"," // node. This is the worst case where we have to create a wrapper"," // node around the `content`."," container.append(content);"," }",""," // Makes sure the view is created using _our_ `container` node."," viewConfig = Y.merge(viewConfig, {container: container});",""," // Finally switch to the new `activeView`. We want to make sure `view`"," // is a string if it's falsy, that way a new view will be created."," return this.showView(viewName, viewConfig, options, callback);"," },",""," // -- Protected Methods ----------------------------------------------------",""," /**"," Provides a default content route which will show a server rendered view.",""," **Note:** This route callback assumes that it's called after the"," `loadContent()` middleware.",""," @method _contentRoute"," @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.7.0"," @see Y.App.Content.route"," **/"," _contentRoute: function (req, res, next) {"," var content = res.content,"," doc = Y.config.doc,"," activeViewHandle;",""," // We must have some content to work with."," if (!(content && content.node)) { return next(); }",""," if (content.title && doc) {"," // Make sure the `activeView` does actually change before we go"," // messing with the page title."," activeViewHandle = this.onceAfter('activeViewChange', function () {"," doc.title = content.title;"," });"," }",""," this.showContent(content.node);",""," // Detach the handle just in case."," if (activeViewHandle) {"," activeViewHandle.detach();"," }",""," next();"," }","};","","// Mix statics.","AppContent.ATTRS = Y.Attribute.protectAttrs(PjaxContent.ATTRS);","","// Mix prototype.","Y.mix(AppContent, PjaxContent, false, null, 1);","","// -- Namespace ----------------------------------------------------------------","Y.App.Content = AppContent;","Y.Base.mix(Y.App, [AppContent]);","","","}, '3.10.3', {\"requires\": [\"app-base\", \"pjax-content\"]});","","}());"]}; |