-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #1247, implement hovermenus for navigation and filters
- Loading branch information
Marc Altmann
committed
Feb 3, 2015
1 parent
9a58ce4
commit 15c6925
Showing
22 changed files
with
481 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* jQuery plugin fitIntoViewport | ||
* --------------------------- | ||
* Repositions element(s) horizontally if some parts of them are not in the | ||
* viewport. | ||
* If element | ||
* - is bigger than window -> center | ||
* - reaches over left edge -> push right | ||
* - reaches over right edge -> push left | ||
* | ||
*/ | ||
|
||
(function( $ ) { | ||
$.fn.fitIntoViewport = function() { | ||
var window_width = $(window).width(); | ||
|
||
return this.each(function() { | ||
var $this = $(this), | ||
left_offset, outer_width, offset_parent, | ||
absolute_x, relative_x; | ||
|
||
// clear target css 'left' and 'right' before calculating | ||
$this.css({ | ||
left : '', | ||
right : '' | ||
}); | ||
|
||
left_offset = $this.offset().left; | ||
outer_width = $this.outerWidth(); | ||
|
||
// recalculate x position | ||
if (outer_width > window_width) { | ||
absolute_x = Math.floor((window_width - outer_width) / 2); | ||
} | ||
else if (left_offset < 0) { | ||
absolute_x = 0; | ||
} | ||
else if (left_offset + outer_width > window_width) { | ||
absolute_x = window_width - outer_width; | ||
} | ||
else { | ||
return false; | ||
} | ||
|
||
// calculate x relative to offset parent | ||
offset_parent = left_offset - $this.position().left; | ||
relative_x = absolute_x - offset_parent; | ||
|
||
$this.css({ | ||
left : relative_x, | ||
right : 'auto' | ||
}); | ||
}); | ||
}; | ||
}( jQuery )); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
app/assets/javascripts/visual/category_dropdown_max_right.coffee
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
$ -> | ||
$('body') | ||
.on('touchstart', (e) -> | ||
$touchedElement = $(e.target).closest('.TouchHover') | ||
$('.TouchHover') | ||
.not($touchedElement) | ||
.removeClass('touched') | ||
) | ||
.on('touchstart', '.TouchHover', (e) -> | ||
$el = $(e.target).closest('.TouchHover') | ||
|
||
if $el.hasClass('touched') | ||
return true | ||
else | ||
e.preventDefault() | ||
$el.addClass('touched') | ||
$el | ||
.children('.TouchHover--hidden') | ||
.fitIntoViewport() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.