Commit Graph

601 Commits

Author SHA1 Message Date
Javi Martín
936aa7af0f Simplify adding rows to sortable tables
The `append` method can handle arrays, so there's no need to loop
through each element.

There's more to improve on this method, like the `asc` variable being
global to a table instead of depending on the current column, but for
now I'm only refactoring and maintaining the current behaviour.
2019-09-11 03:14:16 +02:00
Javi Martín
4d7c124188 Remove unnecessary conditions
The code won't do anything if there are no elements, so there's no need
to check that condition.
2019-09-11 03:14:16 +02:00
Javi Martín
1cc3324468 Use each and forEach instead of for .. in
We're planning to replace CoffeeScript with JavaScript, and CoffeeScript
compiles `for .. in` to complex JavaScript code.
2019-09-11 03:14:16 +02:00
Javi Martín
3120e0aa41 Use ECMAScript 5 array and string methods
These methods were added in 2009 and are supported by 98.5% of the
browsers, including Internet Explorer 9, 10 and 11. We were already
using them in some places.
2019-09-11 03:14:16 +02:00
Javi Martín
49b4a0c71d Simplify banners JavaScript
There were functions which were just simple wrappers to common jQuery
functions.
2019-09-11 03:14:16 +02:00
Javi Martín
1f828bf4d4 Simplify code to check form changes 2019-09-11 03:14:16 +02:00
Javi Martín
eab35dc9b0 Don't call hasOwnProperty directly
Calling it directly might make it difficult to detect bugs, particularly
when we don't trust the data we receive:

https://eslint.org/docs/rules/no-prototype-builtins

If we trust the data we receive, then IMHO we shouldn't even check for
`hasOwnProperty`, since we know what we're going to receive.
2019-09-11 02:07:35 +02:00
Javi Martín
5ad41d9ac7 Add a break to avoid case fallthrough
In JavaScript, when there isn't a `break` or `return` statement inside a
`switch` case, the next case will be executed as well.

That wasn't a problem here because CoffeeScript automatically inserts a
`return` statement in this specific situation. However, since we don't
want to return the result of the `hide()` operation, it might be easy to
accidentally remove the `return` statement, causing the code to break.

I've added a test for the scenario where neither `break` nor `return`
statements are present, so we don't run into this error.
2019-09-11 02:05:04 +02:00
taitus
10a2e91f1c Fix wrong js 2019-09-11 02:05:04 +02:00
Alceu Medeiros
1f059d44cf Set current locale as default for datepicker translation 2019-09-11 02:05:04 +02:00
Javi Martín
e4985d371d Remove code added for debugging purposes 2019-09-11 01:56:27 +02:00
Javi Martín
f28a5cc49b Remove unused piwik-related code
This code requires the variable `_paq` to be set somewhere, but we never
set it.

In the past Decide Madrid added some custom JavaScript using this code.
However, in CONSUL we're using Ahoy to track events, and we don't have
any documentation about adding custom JavaScript to use piwik nor we've
got any other piwik integration.
2019-09-11 01:56:27 +02:00
Javi Martín
a9d28bee15 Remove unused code in App.Cookies
The `removeCookie` function is never called, and the `initialize`
function doesn't do anything. The only functions we use here are
`getCookie` and `saveCookie`.
2019-09-11 01:56:27 +02:00
Javi Martín
bf20c93e99 Remove legacy annotations JavaScript file
This code isn't used since commit 54e59a8a.
2019-09-11 01:56:27 +02:00
Javi Martín
457ec11e6d Remove unnecessary return false statements
The `initialize` functions don't need to return anything, since their
returned value is never used.

Returning false is a common practice in jQuery to stop an event, but in
plain JavaScript methods it doesn't have any side effects.
2019-09-11 01:56:27 +02:00
Javi Martín
36a557927a Remove unused variables 2019-09-11 01:56:27 +02:00
Javi Martín
0ef75ff199 Remove unused JavaScript banners code
The banner `update_style` method isn't used since commit 82cb8d4c.
2019-09-11 01:56:27 +02:00
Javi Martín
2af09d65c7 Remove unused JavaScript poll token code
We don't load the token message since commit 585f9ea5, so the JavaScript
to show it wasn't doing anything anymore.
2019-09-11 01:56:27 +02:00
Javi Martín
738e9ebc8b Remove code specific to Internet Explorer 8
Internet Explorer 9 was released eight years ago. Besides that, we don't
really support IE8 anyway, since we show a popup to IE8 users saying
we don't support it, we haven't maintained the IE8-specific CSS file for
years, and we don't test our JavaScript against IE8.
2019-09-10 22:43:37 +02:00
taitus
12089282c8 Align admin progress bars form fields with new translations interface
Add new js method to recover selected language to disable correctly default language fields.
2019-07-01 15:03:48 +02:00
Senén Rodero Rodríguez
721710be79 Fix script to manage visibility of progress bar translations
After markup changes we need to update DOM selector used to hide/show
translations.
2019-07-01 14:49:43 +02:00
Senén Rodero Rodríguez
05562c190f Adapt translations CS to new translation interface markup
Now we are using different html markup to render new translation interface
in a responsiveness way so we had to adapt CS to cover new behavior.
2019-07-01 14:49:43 +02:00
Senén Rodero Rodríguez
cf370cab84 Adapt suggest script for translations
Proposal, Debate, Budget Investment  and Comment will be translatable
models soon. This commit prepares suggestions script to work well with
translatable forms elements too.
2019-06-27 09:19:36 +02:00
lalo
c6e4b2480f Add public changes to create and vote Poll:Questions with votation type 2019-06-12 19:44:14 +02:00
lalo
23d36835d7 Add Admin changes to create Poll:Questions with votation type 2019-06-12 19:44:14 +02:00
German Galia
74083df10f Add historic fields to participatory budget 2019-06-12 18:03:53 +02:00
Raimond Garcia
259e05c3e0 Merge pull request #3410 from LextrendIT/report_generation
Report generation, download CSV
2019-06-12 11:45:59 +02:00
German Galia
9d1ca3bfd4 Report generation. Download csv 2019-06-12 10:17:31 +02:00
lalo
4740aeaddf Add columns selector JS component and change Rails view to use it 2019-06-11 14:33:40 +02:00
voodoorai2000
24dde9c35e Delete valuation 2019-05-31 15:43:06 +02:00
decabeza
f37a2bd0a8 Change js depending of window with 2019-05-22 12:42:00 +02:00
decabeza
13dfaedf06 Replace load to init sticky 2019-05-22 12:41:49 +02:00
Julian Herrero
2c45f178cb Reset sticky component before clicking back button on browser 2019-05-22 12:41:44 +02:00
Julian Herrero
eca4d773a0 Reset sticky component before leaving the page using Turbolinks 2019-05-22 12:41:38 +02:00
decabeza
8684835857 Adds sticky on proposals supports for mobile version 2019-05-22 12:40:12 +02:00
Javi Martín
f7d4507ebe Keep sticky elements after AJAX requests
Turbolinks doesn't get on well with Foundation's Sticky, and so we need
to manually trigger the event on Turbolinks' `page:load`.
2019-05-21 13:50:16 +02:00
Javi Martín
b4a1f0db51 Rename file to initialize Foundation
Naming it "Dropdown" was misleading.
2019-05-21 13:50:16 +02:00
Javi Martín
8094417828 Remove best_in_place
It was only used in one place, so it's best to remove it and use the
patterns we use everywhere else.
2019-04-29 12:37:28 -05:00
decabeza
5bbf325c1f Remove copy link on dashboard polls 2019-04-24 14:01:08 +02:00
decabeza
eda6ea7f12 Merge branch 'master' into dashboard 2019-03-26 16:45:48 +01:00
Senén Rodero Rodríguez
b417e9db31 Initialize new question answers coccon callback
After adding new question we need to initialize new answers
sets.
2019-03-21 14:51:17 +01:00
Senén Rodero Rodríguez
71887f2911 Initialize answers 'after-insert' callback to keep answers order
Also provide a function to initialize new set of answers 'affer-insert'
callback after adding new questions.
2019-03-21 14:51:17 +01:00
Senén Rodero Rodríguez
045c950c3b Add poll question answers script for nested fields
Set poll questions answers given_order value dinamically with JS to
allow to create multiple answers with correct given_order.
2019-03-21 14:51:17 +01:00
Julian Herrero
1ece761beb Render map properly when changing between setting tabs 2019-03-19 18:14:57 +01:00
Julian Herrero
d9eaea4ea0 Use double quotes in app/assets 2019-03-15 09:26:00 +01:00
Julian Herrero
87be6f302c Add default site customization pages
From now on these static pages:

`/privacy'
`/conditions'
`/accesibility'
`/help/faq'
`/welcome'

have been moved to the DB and can be modified easily by any
administrator in `/admin/site_customization/pages'
2019-03-14 18:35:51 +01:00
decabeza
528a4b6e8e Add default colours to admin banners 2019-03-13 13:17:42 +01:00
Javi Martín
b27855c1cf Use double quotes in CoffeeScript files
As we do in the rest of the application.

Note we cannot add a rule enforcing double quotes because CoffeeScript
Lint does not have such rule.
2019-03-06 11:41:21 +01:00
Javi Martín
9e80c75032 Use string interpolation in CoffeeScript
We use it in Ruby, and it will make it easier to change all quotes to
double quotes in CoffeeScript files.
2019-03-06 11:41:21 +01:00
Javi Martín
a6a6d50ac1 Remove trailing whitespaces 2019-03-05 21:50:13 +01:00