-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from AtlasOfLivingAustralia/dev
Preparing v6.1
- Loading branch information
Showing
12 changed files
with
368 additions
and
213 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 |
---|---|---|
|
@@ -18,7 +18,7 @@ plugins { | |
} | ||
|
||
|
||
version "6.0" | ||
version "6.1-SNAPSHOT" | ||
group "org.grails.plugins" | ||
|
||
apply plugin:"eclipse" | ||
|
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
94 changes: 94 additions & 0 deletions
94
grails-app/assets/javascripts/select2-dropdown-placement-override.js
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,94 @@ | ||
/** | ||
* This file overrides the default dropdown placement for select2 to support opening the dropdown on the right side | ||
* of the select2 element. This is useful for select2 elements that are placed on the right side of the page. | ||
* To use the right alignment, add the dropdown-right class to the select element with select2 binding applied. | ||
*/ | ||
$.fn.select2.amd.require(["select2/utils",'select2/dropdown/attachBody'], function(Utils, AttachBody) { | ||
|
||
AttachBody.prototype._positionDropdown = function () { | ||
var $window = $(window); | ||
|
||
var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above'); | ||
var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below'); | ||
|
||
var newDirection = null; | ||
|
||
var offset = this.$container.offset(); | ||
|
||
offset.bottom = offset.top + this.$container.outerHeight(false); | ||
|
||
var container = { | ||
height: this.$container.outerHeight(false) | ||
}; | ||
|
||
container.top = offset.top; | ||
container.bottom = offset.top + container.height; | ||
|
||
var dropdown = { | ||
height: this.$dropdown.outerHeight(false) | ||
}; | ||
|
||
var viewport = { | ||
top: $window.scrollTop(), | ||
bottom: $window.scrollTop() + $window.height() | ||
}; | ||
|
||
var enoughRoomAbove = viewport.top < (offset.top - dropdown.height); | ||
var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height); | ||
|
||
var containerWidth = this.$container.outerWidth() | ||
var right = ($("body").outerWidth() - (offset.left + containerWidth)); | ||
|
||
if (this.$element.hasClass("dropdown-right")) { | ||
var css = { | ||
right: right, | ||
top: container.bottom | ||
}; | ||
} else { | ||
var css = { | ||
left: offset.left, | ||
top: container.bottom | ||
}; | ||
} | ||
|
||
// Determine what the parent element is to use for calciulating the offset | ||
var $offsetParent = this.$dropdownParent; | ||
|
||
// For statically positoned elements, we need to get the element | ||
// that is determining the offset | ||
if ($offsetParent.css('position') === 'static') { | ||
$offsetParent = $offsetParent.offsetParent(); | ||
} | ||
|
||
var parentOffset = $offsetParent.offset(); | ||
|
||
css.top -= parentOffset.top; | ||
css.left -= parentOffset.left; | ||
|
||
if (!isCurrentlyAbove && !isCurrentlyBelow) { | ||
newDirection = 'below'; | ||
} | ||
|
||
if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) { | ||
newDirection = 'above'; | ||
} else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) { | ||
newDirection = 'below'; | ||
} | ||
|
||
if (newDirection == 'above' || | ||
(isCurrentlyAbove && newDirection !== 'below')) { | ||
css.top = container.top - parentOffset.top - dropdown.height; | ||
} | ||
|
||
if (newDirection != null) { | ||
this.$dropdown | ||
.removeClass('select2-dropdown--below select2-dropdown--above') | ||
.addClass('select2-dropdown--' + newDirection); | ||
this.$container | ||
.removeClass('select2-container--below select2-container--above') | ||
.addClass('select2-container--' + newDirection); | ||
} | ||
|
||
this.$dropdownContainer.css(css); | ||
}; | ||
}); |
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.