started implementing tooltips, and upgraded behaviour, also trying to fix some bugs with data content attribute

This commit is contained in:
Zanz2 2018-08-17 16:03:49 +02:00
parent e1cadfc75e
commit 8c492e1491
9 changed files with 33 additions and 12 deletions

View file

@ -4,14 +4,23 @@
$(document).ready(function() {
//if( user has popovers turned on from settings ){
$('.popover_v2').each(function(i,obj) {
var link = $(obj).data('popover-link')
var link = $(obj).data('popoverlink')
var text_data = $(obj).data('content')
var needed_attribute = $(obj).attr("data-content");
if (typeof needed_attribute !== typeof undefined && needed_attribute !== false && needed_attribute !== "") {
// Do nothing, will negate the above logic later
}else{
$(obj).attr( "data-content","content" )
// without a data-content attribute in its parent element, the popover will NEVER render
// it assumes it is empty because I fill data trough the template.
}
$(obj).popover({
html: true,
container: 'body',
placement: 'auto right',
trigger: 'manual',
template: '<div class="popover popover_'+i+'_window" role="tooltip" style="background-color:#F0F0F0;font-family:Lato;font-size:14px;" color="#000000" ><div class="popover-body" >' +
$(obj).data('content') +
text_data +
'</div><br><br><br><div class="popover-footer" style="position:absolute;bottom:5px;right:5px;background-color:#E8E8E8;border-radius: 3px;">' +
'<a style="color:grey;" class="btn btn-link text-nowrap" href="'+link+'">Read more&nbsp;&nbsp;&nbsp;<i class="fas fa-external-link-alt"></i></a></div></div>'
}).on("mouseenter", function () {
@ -37,6 +46,8 @@
$(obj).popover("hide")
}
}, 500);
}).on('shown', function(){
// hide all other popovers
});
})
//}
@ -44,5 +55,5 @@
}());
/* copy and paste shortcut
<button class="btn btn-default popover_v2" data-popover-link="popover_test.link" data-content="<%= I18n.t('popover_test.text') %>">
<button class="btn btn-default popover_v2" data-popoverlink="<%= I18n.t('popover_test.link.') %>" data-popovercontent="<%= I18n.t('popover_test.text.') %>">
*/

View file

@ -1,7 +1,7 @@
<div class="tags-container pull-right">
<% tags2 = my_module.tags[0..3] %>
<% tags2.each do |tag| %>
<div style="color: <%= tag.color %>" class="<%= "last" if tag == tags2[-1] %>" title="<%= tag.name %>">
<div style="color: <%= tag.color %>" class="<%= "last" if tag == tags2[-1] %> popover_v2" data-popoverlink="<%= I18n.t('popover_test.link.task.color_tag') %>" data-popovercontent="<%= I18n.t('popover_test.text.task.color_tag') %>" title="<%= tag.name %>">
<span class="fas fa-tag"></span>
</div>
<% end %>

View file

@ -16,14 +16,18 @@
clone_modal_experiment_url(experiment),
remote: true,
type: 'button',
class: 'clone-experiment' %></li>
class: 'clone-experiment popover_v2',
data: { popoverlink: I18n.t('popover_test.link.experiment.copy'), popovercontent: I18n.t('popover_test.text.experiment.copy') }
%></li>
<% end %>
<% if can_move_experiment?(experiment) %>
<li><%= link_to t('experiments.move.label_title'),
move_modal_experiment_url(experiment),
remote: true,
type: 'button',
class: 'move-experiment' %></li>
class: 'move-experiment popover_v2',
data: { popoverlink: I18n.t('popover_test.link.experiment.move'), popovercontent: I18n.t('popover_test.text.experiment.move') }
%></li>
<% end %>
<% if can_manage_experiment?(experiment) %>
<li><%= link_to t('experiments.archive.label_title'),

View file

@ -9,7 +9,7 @@
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-4">
<div class="col-xs-6 col-sm-6 col-md-4 popover_v2" data-popoverlink="<%= I18n.t('popover_test.link.task.due_date') %>" data-popovercontent="<%= I18n.t('popover_test.text.task.due_date') %>">
<div class="badge-icon">
<% if can_manage_module?(@my_module) %>
<%= link_to due_date_my_module_path(@my_module, format: :json), remote: true, class: "due-date-link", style: "color: inherit" do %>

View file

@ -19,7 +19,8 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.cancel" %></button>
<%= f.submit t("projects.index.modal_new_project.create"), class: "btn btn-success" %>
<%= f.submit t("projects.index.modal_new_project.create"), class: "btn btn-success popover_v2",
data: { popoverlink: I18n.t('popover_test.link.new_project'), popovercontent: I18n.t('popover_test.text.new_project')} %>
</div>
</div>
</div>

View file

@ -39,7 +39,7 @@
<% end %>
</div>
<% end %>
<span>
<span class="popover_v2" data-popoverlink="<%= I18n.t('popover_test.link.experiment.dates') %>" data-popovercontent="<%= I18n.t('popover_test.text.experiment.dates') %>">
<span class="glyphicon glyphicon-calendar" aria-hidden="true"></span>
<%= localize(experiment.created_at, format: t('time.formats.full_date')) %> - <%= localize(experiment.updated_at, format: t('time.formats.full_date')) %>
</span>

View file

@ -115,7 +115,7 @@ invite_to_team = type.in?(%w(invite_to_team invite_to_team_with_role))
</button>
<div class="btn-group" data-role="invite-with-role-div">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" data-id="invite-btn" aria-haspopup="true" aria-expanded="false" data-role="invite-with-role-btn" disabled="disabled">
<button type="button" class="btn btn-success dropdown-toggle popover_v2" data-popoverlink="<%= I18n.t('popover_test.link.invite_to_sci') %>" data-popovercontent="<%= I18n.t('popover_test.text.invite_to_sci') %>" data-toggle="dropdown" data-id="invite-btn" aria-haspopup="true" aria-expanded="false" data-role="invite-with-role-btn" disabled="disabled">
<%= t('invite_users.invite_btn') %>
&nbsp;
<span class="caret"></span>

View file

@ -10,8 +10,12 @@
<div>
<% if @member_of > 0 %>
<%= t("users.settings.teams.index.description_label") %>
<br><br>
<%= t("users.settings.teams.index.member_of", count: @member_of) %>
<% else %>
<%= t("users.settings.teams.index.description_label") %>
<br><br>
<em><%= t("users.settings.teams.index.no_teams") %></em>
<% end %>
<% if can_create_teams? %>

View file

@ -1424,9 +1424,10 @@ en:
all: "All teams"
new_team: "New team"
index:
description_label: "Team is a group of SciNote users who are working on the same projects and share the inventories."
member_of:
one: "You are member of %{count} team."
other: "You are member of %{count} teams."
one: "Currently you are member of %{count} team."
other: "Currently you are member of %{count} teams."
no_teams: "You are not a member of any team."
new_team: "New Team"
thead_name: "Team"