Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add routes for help sections #5667

Merged
merged 3 commits into from Feb 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/assets/javascripts/app/router.js
Expand Up @@ -2,6 +2,8 @@

app.Router = Backbone.Router.extend({
routes: {
"help/:section": "help",
"help/": "help",
"help": "help",
"contacts": "contacts",
"conversations": "conversations",
Expand Down Expand Up @@ -36,10 +38,10 @@ app.Router = Backbone.Router.extend({
this.route(/^bookmarklet(?:\?(.*))?/, "bookmarklet");
},

help: function() {
help: function(section) {
app.help = new app.views.Help();
$("#help").prepend(app.help.el);
app.help.render();
app.help.render(section);
},

contacts: function() {
Expand Down
37 changes: 28 additions & 9 deletions app/assets/javascripts/app/views/help_view.js
Expand Up @@ -9,7 +9,7 @@ app.views.Help = app.views.StaticContentView.extend({
"click .faq-link-sharing" : "sharing",
"click .faq-link-posts-and-posting" : "postsAndPosting",
"click .faq-link-tags": "tags",
"click .faq-link-keyboard-shortcuts" : "keyboardShortcuts",
"click .faq-link-keyboard-shortcuts" : "keyboardShortcuts"
},

initialize : function() {
Expand All @@ -19,19 +19,19 @@ app.views.Help = app.views.StaticContentView.extend({
get_support_a_tutorials: { tutorials: this.linkHtml("https://diasporafoundation.org/tutorials", Diaspora.I18n.t( 'tutorials' ))},
get_support_a_wiki: { link: this.linkHtml("https://wiki.diasporafoundation.org/Special:Search", Diaspora.I18n.t( 'wiki' ))},
get_support_a_irc: { irc: this.linkHtml("https://wiki.diasporafoundation.org/How_We_Communicate#IRC", Diaspora.I18n.t( 'irc' ))},
get_support_a_hashtag: { question: this.linkHtml("/tags/question", "#question")},
get_support_a_hashtag: { question: this.linkHtml("/tags/question", "#question")}
};

this.POSTS_AND_POSTING_SUBS = {
format_text_a: {
markdown: this.linkHtml("http://diasporafoundation.org/formatting", Diaspora.I18n.t( 'markdown' )),
here: this.linkHtml("http://daringfireball.net/projects/markdown/syntax", Diaspora.I18n.t( 'here' )),
here: this.linkHtml("http://daringfireball.net/projects/markdown/syntax", Diaspora.I18n.t( 'here' ))
}
};

this.TAGS_SUBS = {
filter_tags_a: {
third_party_tools: this.linkHtml("https://wiki.diasporafoundation.org/Tools_to_use_with_Diaspora", Diaspora.I18n.t( 'third_party_tools' )),
third_party_tools: this.linkHtml("https://wiki.diasporafoundation.org/Tools_to_use_with_Diaspora", Diaspora.I18n.t( 'third_party_tools' ))
}
};

Expand All @@ -51,20 +51,23 @@ app.views.Help = app.views.StaticContentView.extend({
title_sharing: Diaspora.I18n.t( 'sharing.title' ),
title_tags: Diaspora.I18n.t( 'tags.title' ),
title_keyboard_shortcuts: Diaspora.I18n.t( 'keyboard_shortcuts.title' ),
title_miscellaneous: Diaspora.I18n.t( 'miscellaneous.title' ),
title_miscellaneous: Diaspora.I18n.t( 'miscellaneous.title' )
};

return this;
},

render: function(){
var section = app.views.Base.prototype.render.apply(this, arguments);
render: function(section){
var html = app.views.Base.prototype.render.apply(this, arguments);

// After render actions
this.resetMenu(true);
this.renderStaticSection("getting_help", "faq_getting_help", this.GETTING_HELP_SUBS);

return section;
var elTarget = this.findSection(section);
if(elTarget !== null){ $(elTarget).click(); }

return html;
},

showItems: function(el) {
Expand Down Expand Up @@ -107,8 +110,12 @@ app.views.Help = app.views.StaticContentView.extend({

menuClicked: function(e) {
this.resetMenu();

$(e.target).hide();
$(e.target).next().show();

var data = $(e.target).data('section');
app.router.navigate('help/' + data);
},

clearItems: function() {
Expand All @@ -133,6 +140,18 @@ app.views.Help = app.views.StaticContentView.extend({
this.$('#faq').append(help_section.render().el);
},

/**
* Returns The section title whose data-section property equals the given query
* Returns null if nothing found
* @param dataValue Value for the data-section to find
* @returns {jQuery}
*/
findSection: function(data){
var res = this.$('a[data-section=' + data + ']');
if(res.length === 0){ return null; }
return res;
},

gettingHelp: function(e) {
this.renderStaticSection("getting_help", "faq_getting_help", this.GETTING_HELP_SUBS);
this.menuClicked(e);
Expand Down Expand Up @@ -170,6 +189,6 @@ app.views.Help = app.views.StaticContentView.extend({

linkHtml: function(url, text) {
return "<a href=\"" + url + "\" target=\"_blank\">" + text + "</a>";
},
}
});
// @license-end
1 change: 1 addition & 0 deletions config/.jshint.json
Expand Up @@ -58,6 +58,7 @@
"factory",
"stubView",
"exports",
"spyOn",

"app",
"Diaspora",
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -223,6 +223,7 @@

# Help
get 'help' => 'help#faq', :as => 'help'
get 'help/:topic' => 'help#faq'

#Protocol Url
get 'protocol' => redirect("http://wiki.diasporafoundation.org/Federation_Protocol_Overview")
Expand Down
47 changes: 47 additions & 0 deletions spec/javascripts/app/views/help_view_spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.