Skip to content

Commit

Permalink
Merge pull request #972 from jhawthorn/bootstrap_tooltips
Browse files Browse the repository at this point in the history
Replace powerTip with bootstrap tooltips
  • Loading branch information
jhawthorn committed Mar 9, 2016
2 parents 69d88e9 + f4b788a commit d1f9ebf
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 1,398 deletions.
2 changes: 1 addition & 1 deletion backend/app/assets/javascripts/spree/backend.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//= require solidus_admin/bind-polyfill
//= require handlebars
//= require jquery
//= require jquery_ujs
//= require jquery-ui/datepicker
//= require jquery-ui/sortable
//= require jquery-ui/autocomplete
//= require jquery.cookie
//= require jquery.powertip
//= require jquery.sticky-kit.min
//= require underscore-min
//= require backbone
Expand Down
25 changes: 8 additions & 17 deletions backend/app/assets/javascripts/spree/backend/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,27 @@ Hopefully, this will evolve into a propper class.
**/

jQuery(function($) {
$('body').tooltip({selector: '.with-tip'})

// Add some tips
$('.with-tip').powerTip({
smartPlacement: true,
fadeInTime: 50,
fadeOutTime: 50,
$('body').on('inserted.bs.tooltip', function(e){
var $target = $(e.target);
var $tooltip = $("#" + $target.attr("aria-describedby"));
$tooltip.addClass("action-" + $target.data("action"));
});

$('body')
.on('powerTipPreRender', '.with-tip', function() {
$('#powerTip').addClass($(this).data('action'));
$('#powerTip').addClass($(this).data('tip-color'));
})
.on('powerTipClose', '.with-tip', function() {
$('#powerTip').removeClass($(this).data('action'));
})

// Highlight hovered table column
$('table tbody tr td.actions').find('a, button').hover(function(){
$('table').on("mouseenter", 'td.actions a, td.actions button', function(){
var tr = $(this).closest('tr');
var klass = 'highlight action-' + $(this).data('action')
tr.addClass(klass)
tr.prev().addClass('before-' + klass);
}, function(){
});
$('table').on("mouseleave", 'td.actions a, td.actions button', function(){
var tr = $(this).closest('tr');
var klass = 'highlight action-' + $(this).data('action')
tr.removeClass(klass)
tr.prev().removeClass('before-' + klass);
});

});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ $(document).ready(function () {
$('#stock_details').show();

$('button.add_variant').click(addVariant);

// Add some tips
$('.with-tip').powerTip({
smartPlacement: true,
fadeInTime: 50,
fadeOutTime: 50,
intentPollInterval: 300
});

});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ jQuery ($) ->
$(@).data('clicked', true)
mouseup: =>
@[action]()
.powerTip
smartPlacement: true
fadeInTime: 50
fadeOutTime: 50

$buttons: ->
@$actions().find(".fa-#{@action}, .fa-cancel")
Expand Down
16 changes: 0 additions & 16 deletions backend/app/assets/javascripts/spree/backend/shipments.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ $(document).ready(function () {
$('#stock_details').show();

$('button.add_variant').click(addVariantFromStockLocation);

// Add some tips
$('.with-tip').powerTip({
smartPlacement: true,
fadeInTime: 50,
fadeOutTime: 50,
intentPollInterval: 300
});

});

//handle edit click
Expand Down Expand Up @@ -237,13 +228,6 @@ startItemSplit = function(event){
$('a.cancel-split').click(cancelItemSplit);
$('a.save-split').click(completeItemSplit);

// Add some tips
$('.with-tip').powerTip({
smartPlacement: true,
fadeInTime: 50,
fadeOutTime: 50,
intentPollInterval: 300
});
$('#item_stock_location').select2({ width: 'resolve', placeholder: Spree.translations.item_stock_placeholder });
}

Expand Down
10 changes: 0 additions & 10 deletions backend/app/assets/javascripts/spree/backend/spree-select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,4 @@ jQuery(function($) {
new_taxon = taxon.text.replace('->', '<i class="fa fa-arrow-right">')
return new_taxon;
}

$("#product_taxon_ids").on({
change: function(e){
$('.select2-search-choice .with-tip').powerTip({
smartPlacement: true,
fadeInTime: 50,
fadeOutTime: 50
})
}
})
})
1 change: 0 additions & 1 deletion backend/app/assets/stylesheets/spree/backend.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*= require normalize
*= require jquery-ui/datepicker
*= require jquery-ui/autocomplete
*= require jquery.powertip
*= require select2
*= require prism
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ $grid-gutter-width: 1.875rem !default; // 30px
//
// Font, line-height, and color for body text, headings, and more.

$font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif !default;
$font-family-sans-serif: $base-font-family !default;
$font-family-serif: Georgia, "Times New Roman", Times, serif !default;
$font-family-monospace: Menlo, Monaco, Consolas, "Courier New", monospace !default;
$font-family-base: $font-family-sans-serif !default;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@mixin bootstrap-tooltip-color($color) {
.tooltip-inner{
background-color: $color;
}

&.tooltip-top,
&.bs-tether-element-attached-bottom {
.tooltip-arrow {
border-top-color: $color;
}
}

&.tooltip-right,
&.bs-tether-element-attached-left {
.tooltip-arrow {
border-right-color: $color;
}
}

&.tooltip-bottom,
&.bs-tether-element-attached-top {
.tooltip-arrow {
border-bottom-color: $color;
}
}

&.tooltip-left,
&.bs-tether-element-attached-right {
.tooltip-arrow {
border-left-color: $color;
}
}
}

.tooltip {
pointer-events: none;

&.action-edit, &.action-save, &.action-capture, &.action-add {
@include bootstrap-tooltip-color($brand-success);
}
&.action-clone {
@include bootstrap-tooltip-color($brand-warning);
}
&.action-void, &.action-failure, &.action-cancel, &.action-remove {
@include bootstrap-tooltip-color($brand-danger);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
@import 'spree/backend/components/tabs';

@import 'font-awesome';
@import 'spree/backend/plugins/powertip';
@import 'spree/backend/plugins/select2';
@import 'spree/backend/plugins/bootstrap_tooltip';

@import 'spree/backend/sections/adjustments_table';
@import 'spree/backend/sections/orders';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%- end %>

<p>
We are using <a href="http://stevenbenner.github.io/jquery-powertip/">jQuery PowerTip</a>
We are using bootstrap's tooltip library
with the class <code>.with-tip</code> as a trigger.
</p>

Expand Down
Loading

0 comments on commit d1f9ebf

Please sign in to comment.