From 8c492e1491a12d8835177ccc38fec2d74d4903a7 Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Fri, 17 Aug 2018 16:03:49 +0200 Subject: [PATCH] started implementing tooltips, and upgraded behaviour, also trying to fix some bugs with data content attribute --- .../javascripts/sitewide/popover_helper.js | 17 ++++++++++++++--- app/views/canvas/_tags.html.erb | 2 +- .../experiments/_dropdown_actions.html.erb | 8 ++++++-- app/views/my_modules/_module_header.html.erb | 2 +- app/views/projects/index.html.erb | 3 ++- app/views/projects/show/_experiment.html.erb | 2 +- app/views/shared/_invite_users_modal.html.erb | 2 +- app/views/users/settings/teams/index.html.erb | 4 ++++ config/locales/en.yml | 5 +++-- 9 files changed, 33 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/sitewide/popover_helper.js b/app/assets/javascripts/sitewide/popover_helper.js index 126b5b39a..ce09be412 100644 --- a/app/assets/javascripts/sitewide/popover_helper.js +++ b/app/assets/javascripts/sitewide/popover_helper.js @@ -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: '' }).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 - - <%= 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')} %> diff --git a/app/views/projects/show/_experiment.html.erb b/app/views/projects/show/_experiment.html.erb index 22ee555b0..af928a135 100644 --- a/app/views/projects/show/_experiment.html.erb +++ b/app/views/projects/show/_experiment.html.erb @@ -39,7 +39,7 @@ <% end %> <% end %> - + <%= localize(experiment.created_at, format: t('time.formats.full_date')) %> - <%= localize(experiment.updated_at, format: t('time.formats.full_date')) %> diff --git a/app/views/shared/_invite_users_modal.html.erb b/app/views/shared/_invite_users_modal.html.erb index 34ec065c7..23e9f4006 100644 --- a/app/views/shared/_invite_users_modal.html.erb +++ b/app/views/shared/_invite_users_modal.html.erb @@ -115,7 +115,7 @@ invite_to_team = type.in?(%w(invite_to_team invite_to_team_with_role))
-