Revision a18cc1f1
Added by Tomer Brisker over 7 years ago
app/assets/javascripts/application.js | ||
---|---|---|
$('.nav-pills .tab-error').first().click();
|
||
errorFields.first().find('.form-control').focus();
|
||
|
||
|
||
//set the tooltips
|
||
$('a[rel="popover"]').popover();
|
||
$('[rel="twipsy"]').tooltip({ container: 'body' });
|
||
$('.ellipsis').tooltip({ container: 'body',
|
||
title: function(){return (this.scrollWidth > this.clientWidth) ? this.textContent : null;}
|
||
});
|
||
$('*[title]').not('*[rel]').tooltip({ container: 'body' });
|
||
tfm.tools.activateTooltips();
|
||
tfm.tools.activateDatatables();
|
||
|
||
// Prevents all links with the disabled attribute set to "disabled"
|
||
... | ... | |
success: function(request) {
|
||
$('#puppet_klasses').html(request);
|
||
reload_puppetclass_params();
|
||
$('[rel="twipsy"]').tooltip();
|
||
tfm.tools.activateTooltips();
|
||
},
|
||
complete: function() {
|
||
reloadOnAjaxComplete(element);
|
||
... | ... | |
loading_power_state.text(__('Unknown power state'));
|
||
}
|
||
power_actions.hide();
|
||
$('[rel="twipsy"]').tooltip();
|
||
tfm.tools.activateTooltips();
|
||
}
|
||
|
||
function toggle_input_group(item) {
|
||
... | ... | |
|
||
function reloadOnAjaxComplete(element) {
|
||
tfm.tools.hideSpinner()
|
||
$('[rel="twipsy"]').tooltip();
|
||
tfm.tools.activateTooltips();
|
||
activate_select2(':root');
|
||
}
|
||
|
app/assets/javascripts/dashboard.js | ||
---|---|---|
gridster.register_widget(widget);
|
||
fill_restore_list();
|
||
}
|
||
|
||
function widgetLoaded(widget){
|
||
refreshCharts();
|
||
tfm.tools.activateTooltips($(widget));
|
||
}
|
app/views/dashboard/index.html.erb | ||
---|---|---|
<a class='minimize'>−</a>
|
||
</div>
|
||
<div class="widget <%= widget.name.parameterize %>">
|
||
<div data-ajax-url="<%= widget_path(widget, params.slice(:search)) %>" data-on-complete="refreshCharts">
|
||
<div data-ajax-url="<%= widget_path(widget, params.slice(:search)) %>" data-on-complete="widgetLoaded">
|
||
<%= spinner(_("%s widget loading...") % widget.name) %>
|
||
</div>
|
||
</div>
|
webpack/assets/javascripts/foreman_tools.js | ||
---|---|---|
$(this).parents('.dropdown').find('.btn').html($(this).text() + ' <span class="caret"></span>');
|
||
});
|
||
}
|
||
|
||
export function activateTooltips(el = $('body')) {
|
||
el.find('[rel="twipsy"]').tooltip({ container: 'body' });
|
||
el.find('.ellipsis').tooltip({ container: 'body', title: () => {
|
||
return (this.scrollWidth > this.clientWidth ?
|
||
this.textContent : null);
|
||
}
|
||
});
|
||
el.find('*[title]').not('*[rel]').tooltip({ container: 'body' });
|
||
}
|
webpack/assets/javascripts/foreman_tools.test.js | ||
---|---|---|
});
|
||
});
|
||
});
|
||
|
||
describe('activateTooltips', () => {
|
||
it('calls $.fn.tooltip on all matching elements', () => {
|
||
const $ = require('jquery');
|
||
const elements = `
|
||
<div rel='twipsy'></div>
|
||
<div class='ellipsis'></div>
|
||
<div title='test'></div>
|
||
<div title='test' rel='popover'></div>
|
||
`;
|
||
|
||
$.fn.tooltip = jest.fn();
|
||
tools.activateTooltips($(elements));
|
||
expect($.fn.tooltip).toHaveBeenCalledTimes(3);
|
||
});
|
||
});
|
Also available in: Unified diff
Fixes #17501 - Display tooltips on dashboard widgets (#4067)