diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index c4134468a..15f36ea49 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -21,7 +21,6 @@ //= require d3 //= require c3 //= require c3ext -//= require qp //= require app //= require_tree . @@ -31,9 +30,7 @@ var initialize_modules = function() { App.Votes.initialize(); App.Tags.initialize(); App.Stats.initialize(); - App.LocaleSwitcher.initialize(); - App.DebatesOrderSelector.initialize(); - App.DebatesTagFilter.initialize(); + App.LocationChanger.initialize(); }; $(function(){ diff --git a/app/assets/javascripts/debates_order_selector.js.coffee b/app/assets/javascripts/debates_order_selector.js.coffee deleted file mode 100644 index 94002f5ac..000000000 --- a/app/assets/javascripts/debates_order_selector.js.coffee +++ /dev/null @@ -1,17 +0,0 @@ -App.DebatesOrderSelector = - - href_with_params: (query_params) -> - loc = window.location - - loc.protocol + "//" + loc.hostname + - (if loc.port then ':' + loc.port else '') + - loc.pathname + - loc.hash + - '?' + $.param(query_params) - - initialize: -> - $('.js-order-selector').on 'change', -> - query_params = window.getQueryParameters() - query_params['order'] = $(this).val() - window.location.assign(App.DebatesOrderSelector.href_with_params(query_params)) - diff --git a/app/assets/javascripts/debates_tag_filter.js.coffee b/app/assets/javascripts/debates_tag_filter.js.coffee deleted file mode 100644 index 08b8c7712..000000000 --- a/app/assets/javascripts/debates_tag_filter.js.coffee +++ /dev/null @@ -1,17 +0,0 @@ -App.DebatesTagFilter = - - href_with_params: (query_params) -> - loc = window.location - - loc.protocol + "//" + loc.hostname + - (if loc.port then ':' + loc.port else '') + - loc.pathname + - loc.hash + - '?' + $.param(query_params) - - initialize: -> - $('.js-tag-filter').on 'change', -> - query_params = window.getQueryParameters() - query_params['tag'] = $(this).val() - window.location.assign(App.DebatesTagFilter.href_with_params(query_params)) - diff --git a/app/assets/javascripts/locale_switcher.js.coffee b/app/assets/javascripts/locale_switcher.js.coffee deleted file mode 100644 index 2bd88b8ef..000000000 --- a/app/assets/javascripts/locale_switcher.js.coffee +++ /dev/null @@ -1,19 +0,0 @@ -App.LocaleSwitcher = - - href_with_params: (query_params) -> - loc = window.location - - loc.protocol + "//" + loc.hostname + - (if loc.port then ':' + loc.port else '') + - loc.pathname + - loc.hash + - '?' + $.param(query_params) - - initialize: -> - $('.js-locale-switcher').on 'change', -> - query_params = window.getQueryParameters() - query_params['locale'] = $(this).val() - window.location.assign(App.LocaleSwitcher.href_with_params(query_params)) - - - diff --git a/app/assets/javascripts/location_changer.js.coffee b/app/assets/javascripts/location_changer.js.coffee new file mode 100644 index 000000000..54693633d --- /dev/null +++ b/app/assets/javascripts/location_changer.js.coffee @@ -0,0 +1,8 @@ +App.LocationChanger = + + initialize: -> + $('.js-location-changer').on 'change', -> + window.location.assign($(this).val()) + + + diff --git a/app/assets/javascripts/qp.js b/app/assets/javascripts/qp.js deleted file mode 100644 index 5e2b4f02d..000000000 --- a/app/assets/javascripts/qp.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * getQueryParameters.js - * Copyright (c) 2014 Nicholas Ortenzio - * The MIT License (MIT) - * - */ - -window.getQueryParameters = function(str) { - str = (str || document.location.search).replace(/(^\?)/,''); - if(!str) { return {}; } - return str.split("&").reduce(function(o,n){n=n.split('=');o[n[0]]=n[1];return o},{}); -}; diff --git a/app/assets/stylesheets/participacion.scss b/app/assets/stylesheets/participacion.scss index 88a8a412b..e893d5309 100644 --- a/app/assets/stylesheets/participacion.scss +++ b/app/assets/stylesheets/participacion.scss @@ -641,7 +641,7 @@ form.locale-form { select { background-image: image-url("language_select.png"); - &.js-locale-switcher { + &.locale-switcher { background-color: transparent; border: 0; color: white; diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 084bfc1f0..85ca6d496 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -7,6 +7,7 @@ class DebatesController < ApplicationController def index @debates = Debate.search(params).page(params[:page]).for_render.send("sort_by_#{@order}") + @tags = ActsAsTaggableOn::Tag.all set_debate_votes(@debates) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 11e4cae8c..77afc1317 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -14,13 +14,10 @@ module ApplicationHelper home_page? ? '' : 'results' end - def available_locale_options_for_select - options_for_select(available_locales_array, I18n.locale) + # if current path is /debates current_path_with_query_params(foo: 'bar') returns /debates?foo=bar + # notice: if query_params have a param which also exist in current path, it "overrides" (query_params is merged last) + def current_path_with_query_params(query_parameters) + url_for(request.query_parameters.merge(query_parameters)) end - private - def available_locales_array - I18n.available_locales.map { |loc| [I18n.t('locale', locale: loc), loc] } - end - end diff --git a/app/helpers/debates_helper.rb b/app/helpers/debates_helper.rb deleted file mode 100644 index c594a8fa6..000000000 --- a/app/helpers/debates_helper.rb +++ /dev/null @@ -1,12 +0,0 @@ -module DebatesHelper - def available_options_for_order_selector(valid_orders, current_order) - options_for_select(available_order_filters_array(valid_orders), current_order) - end - - private - - def available_order_filters_array(orders) - orders.map { |f| [t("debates.index.orders.#{f}"), f] } - end - -end diff --git a/app/views/admin/comments/index.html.erb b/app/views/admin/comments/index.html.erb index 941e1e9ed..87178c66b 100644 --- a/app/views/admin/comments/index.html.erb +++ b/app/views/admin/comments/index.html.erb @@ -8,7 +8,7 @@