Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1116)

Unified Diff: app/subapps/browser/browser.js

Issue 8910043: Adds search functionality
Patch Set: Adds search functionality Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/modules-debug.js ('k') | app/subapps/browser/templates/search.handlebars » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/subapps/browser/browser.js
=== modified file 'app/subapps/browser/browser.js'
--- app/subapps/browser/browser.js 2013-04-22 17:11:25 +0000
+++ app/subapps/browser/browser.js 2013-04-23 13:18:01 +0000
@@ -59,9 +59,14 @@
if (this._viewState.charmID) {
urlParts.push(this._viewState.charmID);
}
-
- // Always end on a /
- return urlParts.join('/');
+ var url = urlParts.join('/');
+ if (this._viewState.querystring) {
+ url = Y.Lang.sub('{ url }?{ qs }', {
+ url: url,
+ qs: this._viewState.querystring
+ });
+ }
+ return url;
},
/**
@@ -197,7 +202,7 @@
this._viewState.viewmode = params.viewmode;
// Check for a charm id in the request.
- if (params.id) {
+ if (params.id && params.id !== 'search') {
this._viewState.charmID = params.id;
} else {
this._viewState.charmID = null;
@@ -264,9 +269,9 @@
},
/**
- * Render the sidebar view of a specific charm to the client.
+ * Render the charm details view
*
- * @method sidebarCharm
+ * @method renderCharmDetails
* @param {Request} req current request object.
* @param {Response} res current response object.
* @param {function} next callable for the next route in the chain.
@@ -314,7 +319,6 @@
renderEditorial: function(req, res, next) {
// If loading the interesting content then it's not a search going on.
var container = this.get('container'),
- editorialContainer,
extraCfg = {};
if (this._viewState.viewmode === 'fullscreen') {
@@ -343,11 +347,35 @@
},
/**
- Place holder for a method to render out search so we can test url parsing
-
- */
+ * Render search results
+ *
+ * @method renderSearchResults
+ * @param {Request} req current request object.
+ * @param {Response} res current response object.
+ * @param {function} next callable for the next route in the chain.
+ */
renderSearchResults: function(req, res, next) {
- console.log('rendered search results.');
+ var container = this.get('container'),
+ extraCfg = {},
+ query;
+ if (this._viewState.querystring) {
+ query = Y.QueryString.parse(this._viewState.querystring);
+ } else {
+ // If there's no querystring, we need a default "empty" search.
+ query = {text: ''};
+ }
+
+ if (req.params.viewmode === 'fullscreen') {
+ extraCfg.renderTo = container.one('.bws-view-data');
+ extraCfg.isFullscreen = true;
+ } else {
+ extraCfg.renderTo = container.one('.bws-content');
+ }
+ extraCfg.text = query.text;
+ this._search = new Y.juju.browser.views.BrowserSearchView(
+ this._getViewCfg(extraCfg));
+ this._search.render();
+ this._search.addTarget(this);
},
/**
@@ -539,10 +567,12 @@
requires: [
'juju-charm-store',
'juju-models',
+ 'querystring-parse',
'sub-app',
'subapp-browser-charmview',
'subapp-browser-editorial',
'subapp-browser-fullscreen',
+ 'subapp-browser-searchview',
'subapp-browser-sidebar'
]
});
« no previous file with comments | « app/modules-debug.js ('k') | app/subapps/browser/templates/search.handlebars » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b