activeadmin-globalize-2 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/app/assets/javascripts/active_admin/active_admin_globalize.js +206 -0
- data/app/assets/stylesheets/active_admin/active_admin_globalize_mixins.sass +0 -8
- data/lib/active_admin/globalize/version.rb +1 -1
- metadata +14 -14
- data/app/assets/javascripts/active_admin/active_admin_globalize.js.coffee +0 -159
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 539edd35240f1a3962b48faa32e88c2634eb6bbc6ab2c4541f82389c59ec5a94
|
4
|
+
data.tar.gz: c232427c88e4f5661779dda77125c0955f8689ed26483c2dcfacd5b9902a244d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a67d05a9769a2942e727df1dfa828e8fe33d6a1d398e723af2730a42064311dbabaa84009b9730b86c7fa6eff7aea9d4b3370d39007da8ad59b2cde5e8e0880
|
7
|
+
data.tar.gz: 85b3d67dff8eb03b719cef29fb8bf43e2ae180aa64647da70bf5a394f3c307c93bdf84cbf908b5c7f5d3ceb78bd9c43e33b16545578ec056ffdc4495fe6c175a
|
data/README.md
CHANGED
@@ -3,13 +3,14 @@
|
|
3
3
|
Makes it easy to translate your resource fields.
|
4
4
|
|
5
5
|
[](http://badge.fury.io/rb/activeadmin-globalize-2)
|
6
|
+
[](https://travis-ci.org/Celkee/activeadmin-globalize-2)
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
|
-
Current version targets Rails
|
10
|
+
Current version targets Rails >= 5.2 and ActiveAdmin >= 1.3.0.
|
10
11
|
|
11
12
|
```ruby
|
12
|
-
gem 'activeadmin-globalize-2', '~>
|
13
|
+
gem 'activeadmin-globalize-2', '~> 2.0.0'
|
13
14
|
```
|
14
15
|
|
15
16
|
## Require Assets
|
@@ -0,0 +1,206 @@
|
|
1
|
+
$(
|
2
|
+
function () {
|
3
|
+
var translations = function () {
|
4
|
+
// Hides or shows the + button and the remove button.
|
5
|
+
var updateLocaleButtonsStatus = function ($dom) {
|
6
|
+
var $localeList = $dom.find(".add-locale ul li:not(.hidden)");
|
7
|
+
var $localeAdd = $dom.find(".add-locale");
|
8
|
+
return $localeList.length === 0 ?
|
9
|
+
$localeAdd.hide()
|
10
|
+
: $localeAdd.show();
|
11
|
+
};
|
12
|
+
|
13
|
+
// Hides or shows the locale tab and its corresponding element in the add menu.
|
14
|
+
var toggleTab = function ($tab, active) {
|
15
|
+
var $addButton = $tab.parents("ul").find('.add-locale li:has(a[href="' + $tab.attr("href") + '"])');
|
16
|
+
if (active) {
|
17
|
+
$tab.addClass("hidden").show().removeClass("hidden");
|
18
|
+
return $addButton.hide().addClass("hidden");
|
19
|
+
} else {
|
20
|
+
$tab.addClass("hidden").hide().addClass("hidden");
|
21
|
+
return $addButton.show().removeClass("hidden");
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
return $(".activeadmin-translations > ul").each(
|
26
|
+
function () {
|
27
|
+
var $dom = $(this);
|
28
|
+
// true when tabs are used in show action, false in form
|
29
|
+
var showAction = $dom.hasClass("locale-selector");
|
30
|
+
|
31
|
+
if (!$dom.data("ready")) {
|
32
|
+
$dom.data("ready", true);
|
33
|
+
var $tabs = $("li > a", this);
|
34
|
+
// content to toggle is different according to current action
|
35
|
+
var $contents = $(this).siblings(showAction ? "div.field-translation" : "fieldset");
|
36
|
+
|
37
|
+
$tabs.click(
|
38
|
+
function (event) {
|
39
|
+
var $tab = $(this);
|
40
|
+
$tabs.not($tab).removeClass("active");
|
41
|
+
$tab.addClass("active");
|
42
|
+
$contents.hide();
|
43
|
+
$contents.filter($tab.attr("href")).show();
|
44
|
+
return event.preventDefault();
|
45
|
+
}
|
46
|
+
);
|
47
|
+
|
48
|
+
$tabs.eq(0).click();
|
49
|
+
|
50
|
+
// Add button and other behavior is not needed in show action
|
51
|
+
if (showAction) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
|
55
|
+
// Collect tha available locales.
|
56
|
+
var availableLocales = [];
|
57
|
+
$tabs.not(".default").each(
|
58
|
+
function () {
|
59
|
+
return availableLocales.push($("<li></li>").append($(this).clone().removeClass("active")));
|
60
|
+
}
|
61
|
+
);
|
62
|
+
|
63
|
+
// Create a new tab as the root of the drop down menu.
|
64
|
+
var $addLocaleButton = $('<li class="add-locale"><a href="#">+</a></li>');
|
65
|
+
$addLocaleButton.append($("<ul></ul>").append(availableLocales));
|
66
|
+
|
67
|
+
// Handle locale addition
|
68
|
+
$addLocaleButton.find("ul a").click(
|
69
|
+
function (event) {
|
70
|
+
var href = $(this).attr("href");
|
71
|
+
var $tab = $tabs.filter('[href="' + href + '"]');
|
72
|
+
toggleTab($tab, true);
|
73
|
+
$tab.click();
|
74
|
+
updateLocaleButtonsStatus($dom);
|
75
|
+
return event.preventDefault();
|
76
|
+
}
|
77
|
+
);
|
78
|
+
|
79
|
+
// Remove a locale from the tab.
|
80
|
+
var $removeButton = $('<span class="remove">x</span>').click(
|
81
|
+
function (event) {
|
82
|
+
event.stopImmediatePropagation();
|
83
|
+
event.preventDefault();
|
84
|
+
var $tab = $(this).parent();
|
85
|
+
toggleTab($tab, false);
|
86
|
+
if ($tab.hasClass("active")) {
|
87
|
+
$tabs.not(".hidden").eq(0).click();
|
88
|
+
}
|
89
|
+
|
90
|
+
return updateLocaleButtonsStatus($dom);
|
91
|
+
}
|
92
|
+
);
|
93
|
+
|
94
|
+
// Add the remove button to every tab.
|
95
|
+
$tabs.not(".default").append($removeButton);
|
96
|
+
|
97
|
+
// Add the new button at the end of the locale list.
|
98
|
+
$dom.append($addLocaleButton);
|
99
|
+
|
100
|
+
$tabs.each(
|
101
|
+
function () {
|
102
|
+
var $tab = $(this);
|
103
|
+
var $content = $contents.filter($tab.attr("href"));
|
104
|
+
var containsErrors = $content.find(".input.error").length > 0;
|
105
|
+
$tab.toggleClass("error", containsErrors);
|
106
|
+
// Find those tabs that are in use.
|
107
|
+
var hide = true;
|
108
|
+
// We will not hide the tabs that have any error.
|
109
|
+
if ($tab.hasClass("error") || $tab.hasClass("default")) {
|
110
|
+
hide = false;
|
111
|
+
} else {
|
112
|
+
// Check whether the input fields are empty or not.
|
113
|
+
$content.find("[name]").not('[type="hidden"]').each(
|
114
|
+
function () {
|
115
|
+
if ($(this).val()) {
|
116
|
+
// We will not hide the tab because it has some data.
|
117
|
+
hide = false;
|
118
|
+
return false;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
);
|
122
|
+
}
|
123
|
+
|
124
|
+
return toggleTab($tab, !hide);
|
125
|
+
}
|
126
|
+
);
|
127
|
+
|
128
|
+
// Remove the fields of hidden locales before form submission.
|
129
|
+
var $form = $dom.parents("form");
|
130
|
+
if (!$form.data("ready")) {
|
131
|
+
$form.data("ready");
|
132
|
+
$form.submit(
|
133
|
+
function () {
|
134
|
+
// Get all translations (the nested ones too).
|
135
|
+
return $(".activeadmin-translations > ul").each(
|
136
|
+
function () {
|
137
|
+
// Get the corresponding fieldsets.
|
138
|
+
var $fieldsets = $(this).siblings("fieldset");
|
139
|
+
return $("li:not(.add-locale) > a", this).each(
|
140
|
+
function () {
|
141
|
+
var $tab = $(this);
|
142
|
+
// Remove them if the locale is hidden.
|
143
|
+
if ($tab.hasClass("hidden")) {
|
144
|
+
var localeClassSelector = $tab.attr("href");
|
145
|
+
// check if it's an existing translation otherwise remove it
|
146
|
+
var $currentFieldset = $("fieldset" + localeClassSelector);
|
147
|
+
var $translationId = $("input[id$=_id]", $currentFieldset);
|
148
|
+
if ($translationId.val()) {
|
149
|
+
// mark it for database removal appending a _destroy element
|
150
|
+
var $destroy = $("<input/>").attr({
|
151
|
+
type: "hidden",
|
152
|
+
name: $translationId.attr("name").replace("[id]", "[_destroy]"),
|
153
|
+
id: $translationId.attr("id").replace("_id", "_destroy"),
|
154
|
+
value: "1"
|
155
|
+
});
|
156
|
+
return $destroy.appendTo($currentFieldset);
|
157
|
+
} else {
|
158
|
+
// remove the fieldset from dom so it won't be submitted
|
159
|
+
return $fieldsets.filter(localeClassSelector).remove();
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
);
|
164
|
+
}
|
165
|
+
);
|
166
|
+
}
|
167
|
+
);
|
168
|
+
}
|
169
|
+
|
170
|
+
// Initially update the buttons' status
|
171
|
+
updateLocaleButtonsStatus($dom);
|
172
|
+
return $tabs.filter(".default").click();
|
173
|
+
}
|
174
|
+
}
|
175
|
+
);
|
176
|
+
};
|
177
|
+
|
178
|
+
// this is to handle elements created with has_many
|
179
|
+
$("a").on(
|
180
|
+
"click",
|
181
|
+
function () {
|
182
|
+
return setTimeout(
|
183
|
+
function () {
|
184
|
+
return translations();
|
185
|
+
},
|
186
|
+
50
|
187
|
+
);
|
188
|
+
}
|
189
|
+
);
|
190
|
+
|
191
|
+
// Used to toggle translations values for inline fields
|
192
|
+
$("a.ui-translation-trigger").click(
|
193
|
+
function (event) {
|
194
|
+
var $locale = $(this).data("locale");
|
195
|
+
var $td = $(this).closest("td");
|
196
|
+
$(".field-translation", $td).hide();
|
197
|
+
$(".locale-" + $locale, $td).show();
|
198
|
+
$(this).parent().children("a.ui-translation-trigger").removeClass("active");
|
199
|
+
$(this).addClass("active");
|
200
|
+
return event.preventDefault();
|
201
|
+
}
|
202
|
+
);
|
203
|
+
|
204
|
+
return translations();
|
205
|
+
}
|
206
|
+
);
|
@@ -1,27 +1,19 @@
|
|
1
1
|
@mixin border-top-radius($radius)
|
2
|
-
-webkit-border-top-right-radius: $radius
|
3
2
|
border-top-right-radius: $radius
|
4
|
-
-webkit-border-top-left-radius: $radius
|
5
3
|
border-top-left-radius: $radius
|
6
4
|
background-clip: padding-box
|
7
5
|
|
8
6
|
@mixin border-right-radius($radius)
|
9
|
-
-webkit-border-bottom-right-radius: $radius
|
10
7
|
border-bottom-right-radius: $radius
|
11
|
-
-webkit-border-top-right-radius: $radius
|
12
8
|
border-top-right-radius: $radius
|
13
9
|
background-clip: padding-box
|
14
10
|
|
15
11
|
@mixin border-bottom-radius($radius)
|
16
|
-
-webkit-border-bottom-right-radius: $radius
|
17
12
|
border-bottom-right-radius: $radius
|
18
|
-
-webkit-border-bottom-left-radius: $radius
|
19
13
|
border-bottom-left-radius: $radius
|
20
14
|
background-clip: padding-box
|
21
15
|
|
22
16
|
@mixin border-left-radius($radius)
|
23
|
-
-webkit-border-bottom-left-radius: $radius
|
24
17
|
border-bottom-left-radius: $radius
|
25
|
-
-webkit-border-top-left-radius: $radius
|
26
18
|
border-top-left-radius: $radius
|
27
19
|
background-clip: padding-box
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin-globalize-2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-06-
|
13
|
+
date: 2022-06-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activeadmin
|
@@ -18,54 +18,54 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
21
|
+
version: '1.3'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
24
|
+
version: '3.0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '1.
|
31
|
+
version: '1.3'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '3.0'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: globalize
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: '5.2'
|
42
42
|
- - "<"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
44
|
+
version: '7.0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version:
|
51
|
+
version: '5.2'
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '7.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.0.2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.0.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description: Handles globalize translations in ActiveAdmin 1.
|
83
|
+
description: Handles globalize translations in ActiveAdmin >=1.3 and Rails >=5.2
|
84
84
|
email:
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
@@ -89,7 +89,7 @@ files:
|
|
89
89
|
- MIT-LICENSE
|
90
90
|
- README.md
|
91
91
|
- app/assets/images/active_admin/flags.png
|
92
|
-
- app/assets/javascripts/active_admin/active_admin_globalize.js
|
92
|
+
- app/assets/javascripts/active_admin/active_admin_globalize.js
|
93
93
|
- app/assets/stylesheets/active_admin/active_admin_globalize.sass
|
94
94
|
- app/assets/stylesheets/active_admin/active_admin_globalize_flags.sass
|
95
95
|
- app/assets/stylesheets/active_admin/active_admin_globalize_mixins.sass
|
@@ -1,159 +0,0 @@
|
|
1
|
-
$ ->
|
2
|
-
|
3
|
-
translations = ->
|
4
|
-
|
5
|
-
# Hides or shows the + button and the remove button.
|
6
|
-
updateLocaleButtonsStatus = ($dom) ->
|
7
|
-
$localeList = $dom.find('.add-locale ul li:not(.hidden)')
|
8
|
-
if $localeList.length == 0
|
9
|
-
$dom.find('.add-locale').hide()
|
10
|
-
else
|
11
|
-
$dom.find('.add-locale').show()
|
12
|
-
|
13
|
-
|
14
|
-
# Hides or shows the locale tab and its corresponding element in the add menu.
|
15
|
-
toggleTab = ($tab, active) ->
|
16
|
-
$addButton = $tab.parents('ul').find('.add-locale li:has(a[href="' + $tab.attr('href') + '"])')
|
17
|
-
if active
|
18
|
-
$tab.addClass('hidden').show().removeClass('hidden')
|
19
|
-
$addButton.hide().addClass('hidden')
|
20
|
-
else
|
21
|
-
$tab.addClass('hidden').hide().addClass('hidden')
|
22
|
-
$addButton.show().removeClass('hidden')
|
23
|
-
|
24
|
-
$(".activeadmin-translations > ul").each ->
|
25
|
-
$dom = $(this)
|
26
|
-
# true when tabs are used in show action, false in form
|
27
|
-
showAction = $dom.hasClass('locale-selector')
|
28
|
-
|
29
|
-
if !$dom.data("ready")
|
30
|
-
$dom.data("ready", true)
|
31
|
-
$tabs = $("li > a", this)
|
32
|
-
# content to toggle is different according to current action
|
33
|
-
$contents = if showAction then $(this).siblings("div.field-translation") else $(this).siblings("fieldset")
|
34
|
-
|
35
|
-
$tabs.click (e) ->
|
36
|
-
$tab = $(this)
|
37
|
-
$tabs.not($tab).removeClass("active")
|
38
|
-
$tab.addClass("active")
|
39
|
-
$contents.hide()
|
40
|
-
$contents.filter($tab.attr("href")).show()
|
41
|
-
e.preventDefault()
|
42
|
-
|
43
|
-
$tabs.eq(0).click()
|
44
|
-
|
45
|
-
# Add button and other behavior is not needed in show action
|
46
|
-
return if showAction
|
47
|
-
|
48
|
-
# Collect tha available locales.
|
49
|
-
availableLocales = []
|
50
|
-
$tabs.not('.default').each ->
|
51
|
-
availableLocales.push($('<li></li>').append($(this).clone().removeClass('active')))
|
52
|
-
|
53
|
-
# Create a new tab as the root of the drop down menu.
|
54
|
-
$addLocaleButton = $('<li class="add-locale"><a href="#">+</a></li>')
|
55
|
-
$addLocaleButton.append($('<ul></ul>').append(availableLocales))
|
56
|
-
|
57
|
-
# Handle locale addition
|
58
|
-
$addLocaleButton.find('ul a').click (e) ->
|
59
|
-
href = $(this).attr('href')
|
60
|
-
$tab = $tabs.filter('[href="' + href + '"]')
|
61
|
-
toggleTab($tab, true)
|
62
|
-
$tab.click()
|
63
|
-
updateLocaleButtonsStatus($dom)
|
64
|
-
e.preventDefault()
|
65
|
-
|
66
|
-
# Remove a locale from the tab.
|
67
|
-
$removeButton = $('<span class="remove">x</span>').click (e) ->
|
68
|
-
e.stopImmediatePropagation()
|
69
|
-
e.preventDefault()
|
70
|
-
$tab = $(this).parent()
|
71
|
-
toggleTab($tab, false)
|
72
|
-
if $tab.hasClass('active')
|
73
|
-
$tabs.not('.hidden').eq(0).click()
|
74
|
-
|
75
|
-
updateLocaleButtonsStatus($dom)
|
76
|
-
|
77
|
-
# Add the remove button to every tab.
|
78
|
-
$tabs.not('.default').append($removeButton)
|
79
|
-
|
80
|
-
# Add the new button at the end of the locale list.
|
81
|
-
$dom.append($addLocaleButton)
|
82
|
-
|
83
|
-
$tabs.each ->
|
84
|
-
$tab = $(@)
|
85
|
-
$content = $contents.filter($tab.attr("href"))
|
86
|
-
containsErrors = $content.find(".input.error").length > 0
|
87
|
-
$tab.toggleClass("error", containsErrors)
|
88
|
-
# Find those tabs that are in use.
|
89
|
-
hide = true
|
90
|
-
# We will not hide the tabs that have any error.
|
91
|
-
if $tab.hasClass('error') || $tab.hasClass('default')
|
92
|
-
hide = false
|
93
|
-
else
|
94
|
-
# Check whether the input fields are empty or not.
|
95
|
-
$content.find('[name]').not('[type="hidden"]').each ->
|
96
|
-
if $(this).val()
|
97
|
-
# We will not hide the tab because it has some data.
|
98
|
-
hide = false
|
99
|
-
return false
|
100
|
-
|
101
|
-
if hide
|
102
|
-
toggleTab($tab, false)
|
103
|
-
else
|
104
|
-
toggleTab($tab, true)
|
105
|
-
|
106
|
-
# Remove the fields of hidden locales before form submission.
|
107
|
-
$form = $dom.parents('form')
|
108
|
-
if !$form.data('ready')
|
109
|
-
$form.data('ready')
|
110
|
-
$form.submit ->
|
111
|
-
# Get all translations (the nested ones too).
|
112
|
-
$('.activeadmin-translations > ul').each ->
|
113
|
-
# Get the corresponding fieldsets.
|
114
|
-
$fieldsets = $(this).siblings('fieldset')
|
115
|
-
$("li:not(.add-locale) > a", this).each ->
|
116
|
-
# Remove them if the locale is hidden.
|
117
|
-
if $(this).hasClass('hidden')
|
118
|
-
# check if it's an existing translation otherwise remove it
|
119
|
-
$currentFieldset = $("fieldset#{$(this).attr('href')}")
|
120
|
-
$translationId = $('input[id$=_id]', $currentFieldset)
|
121
|
-
if $translationId.val()
|
122
|
-
# mark it for database removal appending a _destroy element
|
123
|
-
$destroy = $('<input/>').attr(
|
124
|
-
type: 'hidden',
|
125
|
-
name: $translationId.attr('name').replace('[id]', '[_destroy]'),
|
126
|
-
id: $translationId.attr('id').replace('_id', '_destroy'),
|
127
|
-
value: '1'
|
128
|
-
)
|
129
|
-
$destroy.appendTo($currentFieldset)
|
130
|
-
else
|
131
|
-
# remove the fieldset from dom so it won't be submitted
|
132
|
-
$fieldsets.filter($(this).attr('href')).remove()
|
133
|
-
|
134
|
-
#Initially update the buttons' status
|
135
|
-
updateLocaleButtonsStatus($dom)
|
136
|
-
$tabs.filter('.default').click()
|
137
|
-
|
138
|
-
$a = $("a")
|
139
|
-
# jQuery 1.7 introduced "on" and deprecated "bind"
|
140
|
-
# AA 1.2 bumps jquery-rails to >= 4.2, so we can drop "bind" once AA req is bumped
|
141
|
-
bindingMethod = if ("on" of $a && typeof $a.on == 'function') then "on" else "bind"
|
142
|
-
# this is to handle elements created with has_many
|
143
|
-
$a[bindingMethod] "click", ->
|
144
|
-
setTimeout(
|
145
|
-
-> translations()
|
146
|
-
50
|
147
|
-
)
|
148
|
-
|
149
|
-
# Used to toggle translations values for inline fields
|
150
|
-
$('a.ui-translation-trigger').click (e) ->
|
151
|
-
$locale = $(this).data('locale')
|
152
|
-
$td = $(this).closest('td')
|
153
|
-
$('.field-translation', $td).hide()
|
154
|
-
$(".locale-#{$locale}", $td).show()
|
155
|
-
$(this).parent().children('a.ui-translation-trigger').removeClass('active')
|
156
|
-
$(this).addClass('active')
|
157
|
-
e.preventDefault()
|
158
|
-
|
159
|
-
translations()
|