decidim-core 0.30.0.rc1 → 0.30.0.rc3
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/app/cells/decidim/amendable/amendments/show.erb +1 -1
- data/app/cells/decidim/profile_actions/show.erb +1 -1
- data/app/cells/decidim/report_button/already_reported_modal.erb +2 -2
- data/app/cells/decidim/report_button/flag_modal.erb +13 -27
- data/app/cells/decidim/report_button_cell.rb +2 -8
- data/app/cells/decidim/report_user_button/already_reported_modal.erb +11 -0
- data/app/cells/decidim/report_user_button/flag_modal.erb +46 -0
- data/app/cells/decidim/report_user_button/show.erb +2 -0
- data/app/cells/decidim/report_user_button_cell.rb +59 -0
- data/app/cells/decidim/resource_types_filter/show.erb +1 -1
- data/app/cells/decidim/resource_types_filter_cell.rb +6 -6
- data/app/cells/decidim/user_activity/show.erb +1 -1
- data/app/commands/decidim/create_omniauth_registration.rb +14 -8
- data/app/controllers/decidim/profiles_controller.rb +2 -2
- data/app/controllers/decidim/user_activities_controller.rb +1 -1
- data/app/forms/decidim/account_form.rb +2 -2
- data/app/helpers/decidim/orders_helper.rb +2 -1
- data/app/helpers/decidim/participatory_space_helpers.rb +1 -1
- data/app/jobs/decidim/hide_child_resources_job.rb +24 -0
- data/app/jobs/decidim/migrate/paper_trail_job.rb +33 -0
- data/app/models/decidim/report.rb +1 -1
- data/app/models/decidim/user.rb +0 -4
- data/app/models/decidim/user_base_entity.rb +4 -0
- data/app/packs/src/decidim/map/provider/here.js +1 -1
- data/app/packs/src/decidim/sticky_footer.js +19 -0
- data/app/packs/stylesheets/decidim/_cards.scss +4 -0
- data/app/packs/stylesheets/decidim/_content_blocks.scss +1 -1
- data/app/packs/stylesheets/decidim/_hashtags.scss +5 -0
- data/app/packs/stylesheets/decidim/_login.scss +4 -0
- data/app/packs/stylesheets/decidim/_modal_authorization.scss +1 -1
- data/app/packs/stylesheets/decidim/_profile.scss +1 -1
- data/app/packs/stylesheets/decidim/application.scss +1 -0
- data/app/resolvers/decidim/meta_image_url_resolver.rb +1 -0
- data/app/services/decidim/static_map_generator.rb +1 -1
- data/app/views/decidim/devise/registrations/new.html.erb +1 -1
- data/app/views/decidim/devise/sessions/new.html.erb +1 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +1 -1
- data/app/views/decidim/last_activities/index.html.erb +1 -1
- data/app/views/decidim/open_data/index.html.erb +1 -1
- data/app/views/decidim/shared/_orders.html.erb +2 -2
- data/config/locales/ar.yml +12 -25
- data/config/locales/bg.yml +8 -22
- data/config/locales/ca.yml +22 -34
- data/config/locales/cs.yml +24 -31
- data/config/locales/de.yml +17 -21
- data/config/locales/el.yml +8 -13
- data/config/locales/en.yml +4 -16
- data/config/locales/eo.yml +2 -0
- data/config/locales/es-MX.yml +16 -28
- data/config/locales/es-PY.yml +21 -33
- data/config/locales/es.yml +22 -34
- data/config/locales/eu.yml +61 -75
- data/config/locales/fi-plain.yml +20 -27
- data/config/locales/fi.yml +22 -29
- data/config/locales/fr-CA.yml +60 -20
- data/config/locales/fr.yml +60 -20
- data/config/locales/ga-IE.yml +2 -4
- data/config/locales/gl.yml +22 -13
- data/config/locales/hu.yml +7 -21
- data/config/locales/id-ID.yml +22 -13
- data/config/locales/is-IS.yml +10 -0
- data/config/locales/it.yml +22 -20
- data/config/locales/ja.yml +120 -21
- data/config/locales/lb.yml +19 -19
- data/config/locales/lt.yml +5 -17
- data/config/locales/lv.yml +16 -13
- data/config/locales/nl.yml +20 -17
- data/config/locales/no.yml +16 -16
- data/config/locales/pl.yml +4 -18
- data/config/locales/pt-BR.yml +8 -21
- data/config/locales/pt.yml +16 -16
- data/config/locales/ro-RO.yml +39 -20
- data/config/locales/ru.yml +23 -8
- data/config/locales/sk.yml +27 -16
- data/config/locales/sv.yml +46 -25
- data/config/locales/tr-TR.yml +21 -20
- data/config/locales/uk.yml +12 -1
- data/config/locales/zh-CN.yml +16 -13
- data/config/locales/zh-TW.yml +6 -16
- data/db/migrate/20240722215500_change_object_changes_on_versions.rb +4 -24
- data/lib/decidim/content_parsers/user_parser.rb +1 -1
- data/lib/decidim/core/test/shared_examples/reports_examples.rb +51 -0
- data/lib/decidim/core/test/shared_examples/social_share_examples.rb +21 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/maintenance/import_models/category.rb +40 -8
- data/lib/decidim/maintenance/taxonomy_importer.rb +10 -0
- data/lib/decidim/map/provider/dynamic_map/here.rb +1 -40
- data/lib/decidim/map/provider/static_map/here.rb +34 -0
- data/lib/decidim/moderation_tools.rb +15 -2
- data/lib/decidim/nicknamizable.rb +1 -1
- data/lib/tasks/decidim_taxonomies.rake +6 -1
- data/lib/tasks/upgrade/clean_hidden_resources.rake +33 -0
- data/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake +23 -20
- data/lib/tasks/upgrade/migrations.rake +4 -1
- metadata +14 -14
- data/app/cells/decidim/author/flag.erb +0 -6
- data/app/cells/decidim/author/flag_user.erb +0 -14
- data/app/cells/decidim/flag_modal/flag_user.erb +0 -34
- data/app/cells/decidim/flag_modal/show.erb +0 -52
- data/app/cells/decidim/flag_modal_cell.rb +0 -56
- data/app/cells/decidim/profile_sidebar/show.erb +0 -167
- data/app/cells/decidim/profile_sidebar_cell.rb +0 -68
- data/app/packs/src/decidim/vendor/leaflet-tilelayer-here.js +0 -212
@@ -1,167 +0,0 @@
|
|
1
|
-
<div class="card profile--sidebar">
|
2
|
-
<%= image_tag profile_user.avatar_url(:profile), class: "card__image card__image--larger", alt: "avatar #{profile_user.name}" %>
|
3
|
-
<div>
|
4
|
-
<h1>
|
5
|
-
<strong><%= profile_user.name %></strong>
|
6
|
-
<br>
|
7
|
-
<span>
|
8
|
-
<%= profile_user.nickname %> <br>
|
9
|
-
</span>
|
10
|
-
<% if user_flaggable? %>
|
11
|
-
<span class="user-report_link">
|
12
|
-
<%== cell("decidim/author", profile_user, from:profile_user).flag_user %>
|
13
|
-
</span>
|
14
|
-
|
15
|
-
<% end %>
|
16
|
-
<% if can_contact_user? %>
|
17
|
-
<span>
|
18
|
-
<%= link_to_current_or_new_conversation_with(profile_holder) %>
|
19
|
-
</span>
|
20
|
-
<% end %>
|
21
|
-
</h1>
|
22
|
-
<div>
|
23
|
-
<small><%= decidim_html_escape(profile_user.about.to_s) %></small>
|
24
|
-
</div>
|
25
|
-
<% if profile_user.personal_url.present? %>
|
26
|
-
<%= link_to html_truncate(profile_user.personal_url.gsub(%r{https?\:\/\/}, ""), length: 30), profile_user.personal_url, rel: "nofollow noopener noreferrer ugc" %>
|
27
|
-
<% end %>
|
28
|
-
</div>
|
29
|
-
<% if profile_user.badge.present? %>
|
30
|
-
<div>
|
31
|
-
<span>
|
32
|
-
<%= icon profile_user.badge, class: "author__verified", aria_label: t("decidim.profiles.show.officialized"), role: "img" %>
|
33
|
-
</span>
|
34
|
-
<span>
|
35
|
-
<%= officialization_text %>
|
36
|
-
</span>
|
37
|
-
</div>
|
38
|
-
<% end %>
|
39
|
-
<%= render_hook(:user_profile_bottom) %>
|
40
|
-
<div>
|
41
|
-
<div class="text-center">
|
42
|
-
<% if profile_user_can_follow? %>
|
43
|
-
<div>
|
44
|
-
<%= link_to profile_followers_path(nickname: profile_holder.nickname) do %>
|
45
|
-
<%= t("decidim.profiles.show.followers") %>
|
46
|
-
<div><strong><%= profile_user.followers_count %></strong></div>
|
47
|
-
<% end %>
|
48
|
-
</div>
|
49
|
-
<div>
|
50
|
-
<%= link_to profile_following_path(nickname: profile_holder.nickname) do %>
|
51
|
-
<%= t("decidim.profiles.show.following") %>
|
52
|
-
<div><strong><%= profile_user.following_count %></strong></div>
|
53
|
-
<% end %>
|
54
|
-
</div>
|
55
|
-
<% else %>
|
56
|
-
<div>
|
57
|
-
<%= link_to profile_followers_path(nickname: profile_holder.nickname) do %>
|
58
|
-
<%= t("decidim.profiles.show.followers") %>
|
59
|
-
<div><%= profile_user.followers_count %></div>
|
60
|
-
<% end %>
|
61
|
-
</div>
|
62
|
-
<div>
|
63
|
-
<%= link_to profile_members_path(nickname: profile_holder.nickname) do %>
|
64
|
-
<%= t("decidim.profiles.show.members") %>
|
65
|
-
<div><%= profile_user.members_count %></div>
|
66
|
-
<% end %>
|
67
|
-
</div>
|
68
|
-
<% end %>
|
69
|
-
</div>
|
70
|
-
</div>
|
71
|
-
|
72
|
-
<% if current_organization.badges_enabled? && badge_statuses.any? %>
|
73
|
-
<div>
|
74
|
-
<div>
|
75
|
-
<div class="row column">
|
76
|
-
<strong><%= t("decidim.profiles.sidebar.badges.title") %></strong>
|
77
|
-
<div>
|
78
|
-
<div data-tooltip data-position="top" title="<%= t("decidim.profiles.sidebar.badges.info") %>" data-yeti-box="badges-tooltip" data-toggle="badges-tooltip" data-resize="badges-tooltip" data-events="resize">
|
79
|
-
<%= icon "info", class: "icon--small", role: "img", "aria-hidden": true %>
|
80
|
-
</div>
|
81
|
-
</div>
|
82
|
-
</div>
|
83
|
-
<div class="row collapse">
|
84
|
-
<% badge_statuses.each do |status| %>
|
85
|
-
<div class="column">
|
86
|
-
<div>
|
87
|
-
<%= cell("decidim/badge", profile_holder, badge: status.badge, status:).call(:small) %>
|
88
|
-
</div>
|
89
|
-
</div>
|
90
|
-
<% end %>
|
91
|
-
</div>
|
92
|
-
</div>
|
93
|
-
</div>
|
94
|
-
<% end %>
|
95
|
-
</div>
|
96
|
-
|
97
|
-
<div class="row">
|
98
|
-
<div class="column">
|
99
|
-
<% if own_profile? %>
|
100
|
-
<div class="text-center">
|
101
|
-
<%= link_to decidim.account_path, class: "button" do %>
|
102
|
-
<span>
|
103
|
-
<%= t("decidim.profiles.user.edit_profile") %>
|
104
|
-
</span>
|
105
|
-
<% end %>
|
106
|
-
</div>
|
107
|
-
<% if user_groups_enabled? %>
|
108
|
-
<div class="text-center">
|
109
|
-
<%= link_to decidim.new_group_path, class: "button hollow" do %>
|
110
|
-
<span>
|
111
|
-
<%= t("decidim.profiles.user.create_user_group") %>
|
112
|
-
</span>
|
113
|
-
<% end %>
|
114
|
-
</div>
|
115
|
-
<% end %>
|
116
|
-
<% elsif logged_in? %>
|
117
|
-
<%= cell "decidim/follow_button", profile_holder %>
|
118
|
-
<% end %>
|
119
|
-
|
120
|
-
<% if user_groups_enabled? %>
|
121
|
-
<% if can_edit_user_group_profile? %>
|
122
|
-
<% if user_group_email_to_be_confirmed? %>
|
123
|
-
<div class="text-center">
|
124
|
-
<%= link_to decidim.group_email_confirmation_path(model.nickname), method: :post, class: "button hollow expanded" do %>
|
125
|
-
<span>
|
126
|
-
<%= t("decidim.profiles.user.resend_email_confirmation_instructions") %>
|
127
|
-
</span>
|
128
|
-
<% end %>
|
129
|
-
</div>
|
130
|
-
<% end %>
|
131
|
-
|
132
|
-
<div class="text-center">
|
133
|
-
<%= link_to t("decidim.profiles.user.edit_user_group"), edit_group_path(profile_holder.nickname) %>
|
134
|
-
</div>
|
135
|
-
<div class="text-center">
|
136
|
-
<%= link_to t("decidim.profiles.user.manage_user_group_users"), profile_group_members_path(profile_holder.nickname) %>
|
137
|
-
</div>
|
138
|
-
<div class="text-center">
|
139
|
-
<%= link_to t("decidim.profiles.user.manage_user_group_admins"), profile_group_admins_path(profile_holder.nickname) %>
|
140
|
-
</div>
|
141
|
-
<div class="text-center">
|
142
|
-
<%= link_to t("decidim.profiles.user.invite_user"), group_invites_path(profile_holder.nickname) %>
|
143
|
-
</div>
|
144
|
-
<% end %>
|
145
|
-
|
146
|
-
<% if can_join_user_group? %>
|
147
|
-
<div class="text-center">
|
148
|
-
<%= link_to decidim.group_join_requests_path(model.nickname), method: :post, class: "button hollow expanded" do %>
|
149
|
-
<span>
|
150
|
-
<%= t("decidim.profiles.user.join_user_group") %>
|
151
|
-
</span>
|
152
|
-
<% end %>
|
153
|
-
</div>
|
154
|
-
<% end %>
|
155
|
-
|
156
|
-
<% if can_leave_group? %>
|
157
|
-
<div class="text-center">
|
158
|
-
<%= link_to decidim.leave_group_path(model.nickname), method: :delete, data: { confirm: t("decidim.groups.actions.are_you_sure") }, class: "button hollow expanded" do %>
|
159
|
-
<span>
|
160
|
-
<%= t("decidim.profiles.user.leave_user_group") %>
|
161
|
-
</span>
|
162
|
-
<% end %>
|
163
|
-
</div>
|
164
|
-
<% end %>
|
165
|
-
<% end %>
|
166
|
-
</div>
|
167
|
-
</div>
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
class ProfileSidebarCell < Decidim::ProfileCell
|
5
|
-
include Decidim::Messaging::ConversationHelper
|
6
|
-
include Decidim::ViewHooksHelper
|
7
|
-
include Decidim::CellsHelper
|
8
|
-
|
9
|
-
helper_method :profile_user
|
10
|
-
|
11
|
-
def show
|
12
|
-
render :show
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def profile_user
|
18
|
-
@profile_user ||= present(model)
|
19
|
-
end
|
20
|
-
|
21
|
-
def can_contact_user?
|
22
|
-
!current_user || (current_user && current_user != model && profile_user.can_be_contacted?)
|
23
|
-
end
|
24
|
-
|
25
|
-
def officialization_text
|
26
|
-
profile_user.officialization_text
|
27
|
-
end
|
28
|
-
|
29
|
-
def can_edit_user_group_profile?
|
30
|
-
return false unless current_user
|
31
|
-
return false if model.is_a?(Decidim::User)
|
32
|
-
|
33
|
-
Decidim::UserGroups::ManageableUserGroups.for(current_user).include?(model)
|
34
|
-
end
|
35
|
-
|
36
|
-
def profile_user_can_follow?
|
37
|
-
profile_user.can_follow?
|
38
|
-
end
|
39
|
-
|
40
|
-
def badge_statuses
|
41
|
-
Decidim::Gamification.badges.select { |badge| badge.valid_for?(profile_holder) }.map do |badge|
|
42
|
-
status = Decidim::Gamification.status_for(profile_holder, badge.name)
|
43
|
-
status.level.positive? ? status : nil
|
44
|
-
end.compact
|
45
|
-
end
|
46
|
-
|
47
|
-
def can_join_user_group?
|
48
|
-
return false unless current_user
|
49
|
-
return false if model.is_a?(Decidim::User)
|
50
|
-
|
51
|
-
Decidim::UserGroupMembership.where(user: current_user, user_group: model).empty?
|
52
|
-
end
|
53
|
-
|
54
|
-
def can_leave_group?
|
55
|
-
return false unless current_user
|
56
|
-
return false if model.is_a?(Decidim::User)
|
57
|
-
|
58
|
-
Decidim::UserGroupMembership.where(user: current_user, user_group: model).any?
|
59
|
-
end
|
60
|
-
|
61
|
-
def user_group_email_to_be_confirmed?
|
62
|
-
return false unless current_user
|
63
|
-
return false if model.is_a?(Decidim::User)
|
64
|
-
|
65
|
-
!model.confirmed?
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,212 +0,0 @@
|
|
1
|
-
/* eslint-disable */
|
2
|
-
|
3
|
-
// 🍂class TileLayer.HERE
|
4
|
-
// Tile layer for HERE maps tiles.
|
5
|
-
L.TileLayer.HERE = L.TileLayer.extend({
|
6
|
-
|
7
|
-
options: {
|
8
|
-
subdomains: '1234',
|
9
|
-
minZoom: 2,
|
10
|
-
maxZoom: 18,
|
11
|
-
|
12
|
-
// 🍂option scheme: String = 'normal.day'
|
13
|
-
// The "map scheme", as documented in the HERE API.
|
14
|
-
scheme: 'normal.day',
|
15
|
-
|
16
|
-
// 🍂option resource: String = 'maptile'
|
17
|
-
// The "map resource", as documented in the HERE API.
|
18
|
-
resource: 'maptile',
|
19
|
-
|
20
|
-
// 🍂option mapId: String = 'newest'
|
21
|
-
// Version of the map tiles to be used, or a hash of an unique map
|
22
|
-
mapId: 'newest',
|
23
|
-
|
24
|
-
// 🍂option format: String = 'png8'
|
25
|
-
// Image format to be used (`png8`, `png`, or `jpg`)
|
26
|
-
format: 'png8',
|
27
|
-
|
28
|
-
// 🍂option appId: String = ''
|
29
|
-
// Required option. The `app_id` provided as part of the HERE credentials
|
30
|
-
appId: '',
|
31
|
-
|
32
|
-
// 🍂option appCode: String = ''
|
33
|
-
// Required option. The `app_code` provided as part of the HERE credentials
|
34
|
-
appCode: '',
|
35
|
-
|
36
|
-
// 🍂option useCIT: boolean = false
|
37
|
-
// Whether to use the CIT when loading the here-maptiles
|
38
|
-
useCIT: false,
|
39
|
-
|
40
|
-
// 🍂option useHTTPS: boolean = true
|
41
|
-
// Whether to use HTTPS when loading the here-maptiles
|
42
|
-
useHTTPS: true,
|
43
|
-
|
44
|
-
// 🍂option language: String = ''
|
45
|
-
// The language of the descriptions on the maps that are loaded
|
46
|
-
language: '',
|
47
|
-
|
48
|
-
// 🍂option language: String = ''
|
49
|
-
// The second language of the descriptions on the maps that are loaded
|
50
|
-
language2: '',
|
51
|
-
},
|
52
|
-
|
53
|
-
|
54
|
-
initialize: function initialize(options) {
|
55
|
-
options = L.setOptions(this, options);
|
56
|
-
|
57
|
-
// Decide if this scheme uses the aerial servers or the basemap servers
|
58
|
-
var schemeStart = options.scheme.split('.')[0];
|
59
|
-
options.tileResolution = 256;
|
60
|
-
|
61
|
-
// {Base URL}{Path}/{resource (tile type)}/{map id}/{scheme}/{zoom}/{column}/{row}/{size}/{format}
|
62
|
-
// ?apiKey={YOUR_API_KEY}
|
63
|
-
// &{param}={value}
|
64
|
-
|
65
|
-
var params = [
|
66
|
-
'apiKey=' + encodeURIComponent(options.apiKey)
|
67
|
-
];
|
68
|
-
// Fallback to old app_id,app_code if no apiKey passed
|
69
|
-
if(!options.apiKey) {
|
70
|
-
params = [
|
71
|
-
'app_id=' + encodeURIComponent(options.appId),
|
72
|
-
'app_code=' + encodeURIComponent(options.appCode),
|
73
|
-
];
|
74
|
-
}
|
75
|
-
if(options.language) {
|
76
|
-
params.push('lg=' + encodeURIComponent(options.language));
|
77
|
-
}
|
78
|
-
if(options.language2) {
|
79
|
-
params.push('lg2=' + encodeURIComponent(options.language2));
|
80
|
-
}
|
81
|
-
var urlQuery = '?' + params.join('&');
|
82
|
-
|
83
|
-
var path = '/maptile/2.1/{resource}/{mapId}/{scheme}/{z}/{x}/{y}/{tileResolution}/{format}' + urlQuery;
|
84
|
-
var attributionPath = '/maptile/2.1/copyright/{mapId}?apiKey={apiKey}';
|
85
|
-
|
86
|
-
var baseUrl = 'maps.ls.hereapi.com';
|
87
|
-
|
88
|
-
// Old style with apiId/apiCode for compatibility
|
89
|
-
if(!options.apiKey) {
|
90
|
-
// make sure the CIT-url can be used
|
91
|
-
baseUrl = 'maps' + (options.useCIT ? '.cit' : '') + '.api.here.com';
|
92
|
-
attributionPath = '/maptile/2.1/copyright/{mapId}?app_id={appId}&app_code={appCode}';
|
93
|
-
}
|
94
|
-
|
95
|
-
var tileServer = 'base.' + baseUrl;
|
96
|
-
if (schemeStart == 'satellite' || schemeStart == 'terrain' || schemeStart == 'hybrid') {
|
97
|
-
tileServer = 'aerial.' + baseUrl;
|
98
|
-
}
|
99
|
-
if (options.scheme.indexOf('.traffic.') !== -1) {
|
100
|
-
tileServer = 'traffic' + baseUrl;
|
101
|
-
}
|
102
|
-
|
103
|
-
var protocol = 'http' + (options.useHTTPS ? 's' : '');
|
104
|
-
var tileUrl = protocol + '://{s}.' + tileServer + path;
|
105
|
-
|
106
|
-
this._attributionUrl = L.Util.template(protocol + '://1.' + tileServer + attributionPath, this.options);
|
107
|
-
|
108
|
-
L.TileLayer.prototype.initialize.call(this, tileUrl, options);
|
109
|
-
|
110
|
-
this._attributionText = '';
|
111
|
-
|
112
|
-
},
|
113
|
-
|
114
|
-
onAdd: function onAdd(map) {
|
115
|
-
L.TileLayer.prototype.onAdd.call(this, map);
|
116
|
-
|
117
|
-
if (!this._attributionBBoxes) {
|
118
|
-
this._fetchAttributionBBoxes();
|
119
|
-
}
|
120
|
-
},
|
121
|
-
|
122
|
-
onRemove: function onRemove(map) {
|
123
|
-
//
|
124
|
-
// Remove the attribution text, and clear the cached text so it will be recalculated
|
125
|
-
// if/when we are shown again.
|
126
|
-
//
|
127
|
-
this._map.attributionControl.removeAttribution(this._attributionText);
|
128
|
-
this._attributionText = '';
|
129
|
-
|
130
|
-
this._map.off('moveend zoomend resetview', this._findCopyrightBBox, this);
|
131
|
-
|
132
|
-
//
|
133
|
-
// Call the prototype last, once we have tidied up our own changes
|
134
|
-
//
|
135
|
-
L.TileLayer.prototype.onRemove.call(this, map);
|
136
|
-
},
|
137
|
-
|
138
|
-
_fetchAttributionBBoxes: function _onMapMove() {
|
139
|
-
var xmlhttp = new XMLHttpRequest();
|
140
|
-
xmlhttp.onreadystatechange = L.bind(function(){
|
141
|
-
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
142
|
-
this._parseAttributionBBoxes(JSON.parse(xmlhttp.responseText));
|
143
|
-
}
|
144
|
-
}, this);
|
145
|
-
xmlhttp.open("GET", this._attributionUrl, true);
|
146
|
-
xmlhttp.send();
|
147
|
-
},
|
148
|
-
|
149
|
-
_parseAttributionBBoxes: function _parseAttributionBBoxes(json) {
|
150
|
-
if (!this._map) { return; }
|
151
|
-
var providers = json[this.options.scheme.split('.')[0]] || json.normal;
|
152
|
-
for (var i=0; i<providers.length; i++) {
|
153
|
-
if (providers[i].boxes) {
|
154
|
-
for (var j=0; j<providers[i].boxes.length; j++) {
|
155
|
-
var box = providers[i].boxes[j];
|
156
|
-
providers[i].boxes[j] = L.latLngBounds( [ [box[0], box[1]], [box[2], box[3]] ]);
|
157
|
-
}
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
this._map.on('moveend zoomend resetview', this._findCopyrightBBox, this);
|
162
|
-
|
163
|
-
this._attributionProviders = providers;
|
164
|
-
|
165
|
-
this._findCopyrightBBox();
|
166
|
-
},
|
167
|
-
|
168
|
-
_findCopyrightBBox: function _findCopyrightBBox() {
|
169
|
-
if (!this._map) { return; }
|
170
|
-
var providers = this._attributionProviders;
|
171
|
-
var visibleProviders = [];
|
172
|
-
var zoom = this._map.getZoom();
|
173
|
-
var visibleBounds = this._map.getBounds();
|
174
|
-
|
175
|
-
for (var i=0; i<providers.length; i++) {
|
176
|
-
if (providers[i].minLevel <= zoom && providers[i].maxLevel >= zoom) {
|
177
|
-
|
178
|
-
if (!providers[i].boxes) {
|
179
|
-
// No boxes = attribution always visible
|
180
|
-
visibleProviders.push(providers[i]);
|
181
|
-
} else {
|
182
|
-
for (var j=0; j<providers[i].boxes.length; j++) {
|
183
|
-
var box = providers[i].boxes[j];
|
184
|
-
if (visibleBounds.intersects(box)) {
|
185
|
-
visibleProviders.push(providers[i]);
|
186
|
-
break;
|
187
|
-
}
|
188
|
-
}
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}
|
192
|
-
|
193
|
-
var attributions = ['<a href="https://legal.here.com/en-gb/terms" target="_blank" rel="noopener noreferrer">HERE maps</a>'];
|
194
|
-
for (var i=0; i<visibleProviders.length; i++) {
|
195
|
-
var provider = visibleProviders[i];
|
196
|
-
attributions.push('<abbr title="' + provider.alt + '">' + provider.label + '</abbr>');
|
197
|
-
}
|
198
|
-
|
199
|
-
var attributionText = '© ' + attributions.join(', ') + '. ';
|
200
|
-
|
201
|
-
if (attributionText !== this._attributionText) {
|
202
|
-
this._map.attributionControl.removeAttribution(this._attributionText);
|
203
|
-
this._map.attributionControl.addAttribution(this._attributionText = attributionText);
|
204
|
-
}
|
205
|
-
},
|
206
|
-
|
207
|
-
});
|
208
|
-
|
209
|
-
|
210
|
-
L.tileLayer.here = function(opts){
|
211
|
-
return new L.TileLayer.HERE(opts);
|
212
|
-
}
|