I have been experimenting with Trip.js but I am missing a functionality which can come handy in some use cases. For example, "exposing multiple options in a menu". I see that if you use a class shared by many elements, only the first one gets exposed.
I have edited the code in two parts, namely the methods showExposedElements and hideExposedElements
For showExposedElements I did the following change (just convert the oldCSS object to an array of objects using $.map):
if ($sel.get(0) !== undefined) {
var oldCssArray = $sel.map(function(i, v) {
return {
position: $(v).css('position'),
zIndex: $(v).css('z-Index')
};
});
var overlayZindex = this.settings.overlayZindex;
var newCssArray = oldCssArray.map(function(i,oldCSS) {
return {
position: (function() {
// NOTE: issue #63
// We can't direclty use 'relative' if the original element
// is using properties other than 'relative' because
// this would break the UI.
if (['absolute', 'fixed'].indexOf(oldCSS.position) > -1) {
return oldCSS.position;
}
else {
return 'relative';
}
}()),
// we have to make it higher than the overlay
zIndex: overlayZindex + 1
}
});
$.each($sel, function(i, elem) {
$(elem)
.data('trip-old-css', oldCssArray[i])
.css(newCssArray[i])
.addClass('trip-exposed');
});
}
And an equivalent change in hideExposedElements:
if ($exposedSel.get(0) !== undefined) {
$.each($exposedSel, function(i, elem) {
var oldCSS = $(elem).data('trip-old-css');
$(elem)
.css(oldCSS)
.removeClass('trip-exposed');
});
}
I have not addressed the issue of positioning of the trip element, which currently is relative to the first element of the exposed elements array.
Hope it is useful to somebody and/or it can get included in next updates.
I have been experimenting with Trip.js but I am missing a functionality which can come handy in some use cases. For example, "exposing multiple options in a menu". I see that if you use a class shared by many elements, only the first one gets exposed.
I have edited the code in two parts, namely the methods
showExposedElementsandhideExposedElementsFor
showExposedElementsI did the following change (just convert the oldCSS object to an array of objects using $.map):And an equivalent change in
hideExposedElements:I have not addressed the issue of positioning of the trip element, which currently is relative to the first element of the exposed elements array.
Hope it is useful to somebody and/or it can get included in next updates.