clean up price tooltips javascript

This commit is contained in:
wvengen 2013-10-09 10:35:27 +02:00
parent bdce1b5872
commit b8ff431634
6 changed files with 16 additions and 29 deletions

View file

@ -121,6 +121,20 @@ $(function() {
// Use bootstrap datepicker for dateinput
$('.datepicker').datepicker({format: 'yyyy-mm-dd', language: I18n.locale});
// bootstrap tooltips (for price)
// Extra options don't work when using selector, so override defaults
// https://github.com/twbs/bootstrap/issues/3875 . These can still be
// overridden per tooltip using data-placement attributes and the like.
$.extend($.fn.tooltip.defaults, {
html: true,
animation: false,
placement: 'left',
container: 'body'
});
$(document).tooltip({
selector: '[data-toggle~="tooltip"]',
});
// See stupidtable.js for initialization of local table sorting
});
@ -146,3 +160,5 @@ function highlightRow(checkbox) {
function setHiddenId(text, li) {
$('hidden_id').value = li.id;
}

View file

@ -61,8 +61,6 @@
return true;
}
});
enablePriceTooltips();
});
function mark_article_for_delivery(stock_article_id) {
@ -80,15 +78,6 @@
return ( 0 == $('#stock_change_stock_article_' + stock_article_id).length );
}
function enablePriceTooltips(context) {
$('[data-toggle~="tooltip"]', context).tooltip({
animation: false,
html: true,
placement: 'left',
container: 'body' // or they become a cell in the table
});
}
= simple_form_for [@supplier, @delivery], validate: true do |f|
= f.error_notification
= base_errors f.object

View file

@ -13,7 +13,6 @@
var stock_change = $(
'<%= j(render(:partial => 'stock_change', :locals => {:stock_change => @stock_change})) %>'
).addClass('success');
enablePriceTooltips(stock_change);
$('input.stock-change-quantity', stock_change).val(quantity);
$('#stock_changes').append(stock_change);

View file

@ -8,7 +8,6 @@ $('div.container-fluid').prepend(
var stock_article_for_adding = $(
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article})) %>'
).addClass('success');
enablePriceTooltips(stock_article_for_adding);
$('#stock_articles_for_adding tbody').append(stock_article_for_adding);
updateSort('#stock_articles_for_adding');

View file

@ -10,7 +10,6 @@ $('div.container-fluid').prepend(
var stock_article_for_adding = $(
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article, :delivery => @delivery})) %>'
).addClass('success');
enablePriceTooltips(stock_article_for_adding);
$('#stock_article_<%= @stock_article.id %>').replaceWith(stock_article_for_adding);
updateSort('#stock_articles_for_adding');

View file

@ -1,20 +1,5 @@
- title t('.title')
- content_for :javascript do
:javascript
$(function() {
enablePriceTooltips();
});
function enablePriceTooltips(context) {
$('[data-toggle~="tooltip"]', context).tooltip({
animation: false,
html: true,
placement: 'left',
container: 'body'
});
}
- content_for :sidebar do
%p
%i= t('.text_deviations', inv_link: link_to(t('.temp_inventory'), stock_articles_path)).html_safe