moved call to help backbone view init to separate file included only on faq view.
extending loaded js locales. cleaned up unused routes. removed some comments. loading help locales only on help view. removed afterRender from backbone views. extended load_javascript_locales method to take a section.
This commit is contained in:
parent
55efa82756
commit
1561690303
13 changed files with 34 additions and 53 deletions
|
|
@ -39,7 +39,6 @@ var app = {
|
||||||
this.setupHeader();
|
this.setupHeader();
|
||||||
this.setupBackboneLinks();
|
this.setupBackboneLinks();
|
||||||
this.setupGlobalViews();
|
this.setupGlobalViews();
|
||||||
this.setupHelpViews();
|
|
||||||
this.setupDisabledLinks();
|
this.setupDisabledLinks();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -104,13 +103,6 @@ var app = {
|
||||||
app.sidebar = new app.views.Sidebar();
|
app.sidebar = new app.views.Sidebar();
|
||||||
},
|
},
|
||||||
|
|
||||||
setupHelpViews: function() {
|
|
||||||
//TODO RS: Is this the right place from here?
|
|
||||||
app.help = new app.views.Help();
|
|
||||||
$("#help").prepend(app.help.el);
|
|
||||||
app.help.render();
|
|
||||||
},
|
|
||||||
|
|
||||||
/* mixpanel wrapper function */
|
/* mixpanel wrapper function */
|
||||||
instrument : function(type, name, object, callback) {
|
instrument : function(type, name, object, callback) {
|
||||||
if(!window.mixpanel) { return }
|
if(!window.mixpanel) { return }
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ app.views.Base = Backbone.View.extend({
|
||||||
this.renderSubviews()
|
this.renderSubviews()
|
||||||
this.renderPluginWidgets()
|
this.renderPluginWidgets()
|
||||||
this.removeTooltips()
|
this.removeTooltips()
|
||||||
this.afterRender()
|
|
||||||
|
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
|
@ -101,10 +100,6 @@ app.views.Base = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
afterRender: function(){
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.views.StaticContentView = app.views.Base.extend({
|
app.views.StaticContentView = app.views.Base.extend({
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,15 @@ app.views.FaqQuestionView = app.views.Base.extend({
|
||||||
return this.data;
|
return this.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
afterRender: function(){
|
render: function(){
|
||||||
var el = $(this.el)
|
var section = app.views.Base.prototype.render.apply(this, arguments);
|
||||||
|
|
||||||
|
// After render actions
|
||||||
|
var el = $(this.el);
|
||||||
el.find('.question.collapsible').removeClass('opened').addClass('collapsed');
|
el.find('.question.collapsible').removeClass('opened').addClass('collapsed');
|
||||||
el.find('.answer').hide();
|
el.find('.answer').hide();
|
||||||
|
|
||||||
|
return section;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggled: function(e) {
|
toggled: function(e) {
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,16 @@ app.views.HelpSectionView = app.views.StaticContentView.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
afterRender: function() {
|
render: function(){
|
||||||
// Hide all questions
|
var section = app.views.Base.prototype.render.apply(this, arguments);
|
||||||
|
|
||||||
|
// After render actions
|
||||||
$(this.el).find('.question.collapsible').removeClass('opened').addClass('collapsed');
|
$(this.el).find('.question.collapsible').removeClass('opened').addClass('collapsed');
|
||||||
$(this.el).find('.answer.hideable').hide();
|
$(this.el).find('.answer.hideable').hide();
|
||||||
|
|
||||||
// Show first question
|
|
||||||
$(this.el).find('.question.collapsible :first').addClass('opened').removeClass('collapsed');
|
$(this.el).find('.question.collapsible :first').addClass('opened').removeClass('collapsed');
|
||||||
$(this.el).find('.answer.hideable :first').show();
|
$(this.el).find('.answer.hideable :first').show();
|
||||||
|
|
||||||
|
return section;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggled: function(e) {
|
toggled: function(e) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
//TODO RS: Would be nice to have #faq as the root elem or something
|
|
||||||
app.views.Help = app.views.StaticContentView.extend({
|
app.views.Help = app.views.StaticContentView.extend({
|
||||||
templateName : "help",
|
templateName : "help",
|
||||||
|
|
||||||
|
|
@ -10,14 +9,13 @@ app.views.Help = app.views.StaticContentView.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function(options) {
|
initialize : function(options) {
|
||||||
// TODO RS: Hard coded links are not nice. Should be in a config or something.
|
|
||||||
this.GETTING_HELP_SUBS = {
|
this.GETTING_HELP_SUBS = {
|
||||||
getting_started_a: { tutorial_series: this.linkHtml("http://diasporafoundation.org/getting_started/sign_up", Diaspora.I18n.t( 'getting_started_tutorial' )) },
|
getting_started_a: { tutorial_series: this.linkHtml("http://diasporafoundation.org/getting_started/sign_up", Diaspora.I18n.t( 'getting_started_tutorial' )) },
|
||||||
get_support_a_website: { link: this.linkHtml("https://diasporafoundation.org/", Diaspora.I18n.t( 'foundation_website' ))},
|
get_support_a_website: { link: this.linkHtml("https://diasporafoundation.org/", Diaspora.I18n.t( 'foundation_website' ))},
|
||||||
get_support_a_tutorials: { tutorials: this.linkHtml("https://diasporafoundation.org/tutorials", Diaspora.I18n.t( 'tutorials' ))},
|
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_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_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")}, // TODO RS: Is this definitely hard coded?
|
get_support_a_hashtag: { question: this.linkHtml("/tags/question", "#question")},
|
||||||
};
|
};
|
||||||
|
|
||||||
this.POSTS_AND_POSTING_SUBS = {
|
this.POSTS_AND_POSTING_SUBS = {
|
||||||
|
|
@ -47,10 +45,14 @@ app.views.Help = app.views.StaticContentView.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
afterRender: function() {
|
render: function(){
|
||||||
this.resetMenu(true);
|
var section = 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);
|
this.renderStaticSection("getting_help", "faq_getting_help", this.GETTING_HELP_SUBS);
|
||||||
|
|
||||||
|
return section;
|
||||||
},
|
},
|
||||||
|
|
||||||
showItems: function(el) {
|
showItems: function(el) {
|
||||||
|
|
|
||||||
5
app/assets/javascripts/help.js
Normal file
5
app/assets/javascripts/help.js
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
$(document).ready(function() {
|
||||||
|
app.help = new app.views.Help();
|
||||||
|
$("#help").prepend(app.help.el);
|
||||||
|
app.help.render();
|
||||||
|
});
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
locale: {},
|
locale: {},
|
||||||
|
|
||||||
loadLocale: function(locale, language) {
|
loadLocale: function(locale, language) {
|
||||||
this.locale = locale;
|
this.locale = $.extend(this.locale, locale);
|
||||||
this.language = language;
|
this.language = language;
|
||||||
rule = this.t('pluralization_rule');
|
rule = this.t('pluralization_rule');
|
||||||
if (rule === "")
|
if (rule === "")
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ module LanguageHelper
|
||||||
options.sort_by { |o| o[0] }
|
options.sort_by { |o| o[0] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_javascript_strings_for(language)
|
def get_javascript_strings_for(language, section)
|
||||||
defaults = I18n.t('javascripts', :locale => DEFAULT_LANGUAGE)
|
defaults = I18n.t(section, :locale => DEFAULT_LANGUAGE)
|
||||||
|
|
||||||
if language != DEFAULT_LANGUAGE
|
if language != DEFAULT_LANGUAGE
|
||||||
translations = I18n.t('javascripts', :locale => language)
|
translations = I18n.t('javascripts', :locale => language)
|
||||||
|
|
@ -20,17 +20,6 @@ module LanguageHelper
|
||||||
defaults
|
defaults
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_diaspora_section_strings_for(section, language)
|
|
||||||
defaults = I18n.t(section, :locale => DEFAULT_LANGUAGE)
|
|
||||||
|
|
||||||
if language != DEFAULT_LANGUAGE
|
|
||||||
translations = I18n.t(section, :locale => language)
|
|
||||||
defaults.deep_merge!(translations)
|
|
||||||
end
|
|
||||||
|
|
||||||
defaults
|
|
||||||
end
|
|
||||||
|
|
||||||
def direction_for(string)
|
def direction_for(string)
|
||||||
return '' unless string.respond_to?(:cleaned_is_rtl?)
|
return '' unless string.respond_to?(:cleaned_is_rtl?)
|
||||||
string.cleaned_is_rtl? ? 'rtl' : 'ltr'
|
string.cleaned_is_rtl? ? 'rtl' : 'ltr'
|
||||||
|
|
|
||||||
|
|
@ -28,19 +28,10 @@ module LayoutHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_javascript_locales
|
def load_javascript_locales(section = 'javascripts')
|
||||||
content_tag(:script) do
|
content_tag(:script) do
|
||||||
<<-JS.html_safe
|
<<-JS.html_safe
|
||||||
Diaspora.I18n.loadLocale(#{get_javascript_strings_for(I18n.locale).to_json}, "#{I18n.locale}");
|
Diaspora.I18n.loadLocale(#{get_javascript_strings_for(I18n.locale, section).to_json}, "#{I18n.locale}");
|
||||||
Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}";
|
|
||||||
JS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def load_section_javascript_locales(section)
|
|
||||||
content_tag(:script) do
|
|
||||||
<<-JS.html_safe
|
|
||||||
Diaspora.I18n.loadLocale(#{get_diaspora_section_strings_for(section, I18n.locale).to_json}, "#{I18n.locale}");
|
|
||||||
Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}";
|
Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}";
|
||||||
JS
|
JS
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
= load_javascript_locales("help")
|
||||||
|
= javascript_include_tag 'help'
|
||||||
|
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('_help')
|
= t('_help')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@
|
||||||
- unless @landing_page
|
- unless @landing_page
|
||||||
= javascript_include_tag :main, :templates
|
= javascript_include_tag :main, :templates
|
||||||
= load_javascript_locales
|
= load_javascript_locales
|
||||||
= load_section_javascript_locales("help")
|
|
||||||
|
|
||||||
= set_asset_host
|
= set_asset_host
|
||||||
= translation_missing_warnings
|
= translation_missing_warnings
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
%br
|
%br
|
||||||
%p
|
%p
|
||||||
!= t('aspects.index.help.tutorials_and_wiki',
|
!= t('aspects.index.help.tutorials_and_wiki',
|
||||||
:faq => link_to(t('_help'), faq_getting_help_path),
|
:faq => link_to(t('_help'), help_path),
|
||||||
:tutorial => link_to(t('aspects.index.help.tutorial_link_text'), "https://diasporafoundation.org/tutorials", :target => '_blank'),
|
:tutorial => link_to(t('aspects.index.help.tutorial_link_text'), "https://diasporafoundation.org/tutorials", :target => '_blank'),
|
||||||
:wiki => link_to('Wiki','http://wiki.diasporafoundation.org', :target => '_blank'), :target => '_blank')
|
:wiki => link_to('Wiki','http://wiki.diasporafoundation.org', :target => '_blank'), :target => '_blank')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,8 +206,6 @@ Diaspora::Application.routes.draw do
|
||||||
get 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile'
|
get 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile'
|
||||||
|
|
||||||
# help
|
# help
|
||||||
get 'help/faq' => 'help#faq', :as => 'faq_getting_help'
|
|
||||||
get 'help/faq' => 'help#faq', :as => 'faq'
|
|
||||||
get 'help' => 'help#faq', :as => 'help'
|
get 'help' => 'help#faq', :as => 'help'
|
||||||
|
|
||||||
#Protocol Url
|
#Protocol Url
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue