Avoid a bit of confusing code duplication in .js code
Change-Id: I0cd203e3b2f7ad2be873b92325b80cde462124a5
This commit is contained in:
@@ -481,8 +481,7 @@
|
|||||||
// uls-ui-font-selector-label
|
// uls-ui-font-selector-label
|
||||||
// uls-content-font-selector-label
|
// uls-content-font-selector-label
|
||||||
$fontLabel = this.$template.find( '#' + target + '-font-selector-label' );
|
$fontLabel = this.$template.find( '#' + target + '-font-selector-label' );
|
||||||
$fontLabel.empty();
|
$fontLabel.empty().append( $( '<strong>' ) );
|
||||||
$fontLabel.append( $( '<strong>' ) );
|
|
||||||
|
|
||||||
// Possible messages:
|
// Possible messages:
|
||||||
// ext-uls-webfonts-select-for-ui-info
|
// ext-uls-webfonts-select-for-ui-info
|
||||||
|
|||||||
@@ -157,34 +157,34 @@ function launchULS( $trigger, languagesObject, forCLS ) {
|
|||||||
};
|
};
|
||||||
ulsConfig.onPosition = function () {
|
ulsConfig.onPosition = function () {
|
||||||
// Compact language links specific positioning with a caret
|
// Compact language links specific positioning with a caret
|
||||||
var top, left, offset, height, width, triangleWidth;
|
var left;
|
||||||
// The panel is positioned carefully so that our pointy triangle,
|
// The panel is positioned carefully so that our pointy triangle,
|
||||||
// which is implemented as a square box rotated 45 degrees with
|
// which is implemented as a square box rotated 45 degrees with
|
||||||
// rotation origin in the middle. See the corresponding style file.
|
// rotation origin in the middle. See the corresponding style file.
|
||||||
|
|
||||||
// These are for the trigger
|
// These are for the trigger
|
||||||
offset = $trigger.offset();
|
var offset = $trigger.offset(),
|
||||||
width = $trigger.outerWidth();
|
width = $trigger.outerWidth(),
|
||||||
height = $trigger.outerHeight();
|
height = $trigger.outerHeight();
|
||||||
|
|
||||||
// Triangle width is: who knows now, but this still looks fine.
|
// Triangle width is: who knows now, but this still looks fine.
|
||||||
triangleWidth = 12;
|
var triangleWidth = 12;
|
||||||
|
|
||||||
|
var isRight = offset.left > $( window ).width() / 2;
|
||||||
// selector-{left,right} control which side the caret appears.
|
// selector-{left,right} control which side the caret appears.
|
||||||
// It needs to match the positioning of the dialog.
|
// It needs to match the positioning of the dialog.
|
||||||
if ( offset.left > $( window ).width() / 2 ) {
|
this.$menu.toggleClass( 'selector-left', !isRight )
|
||||||
left = offset.left - this.$menu.outerWidth() - triangleWidth;
|
.toggleClass( 'selector-right', isRight );
|
||||||
this.$menu.removeClass( 'selector-left' ).addClass( 'selector-right' );
|
if ( isRight ) {
|
||||||
|
left = -this.$menu.outerWidth() - triangleWidth;
|
||||||
} else {
|
} else {
|
||||||
left = offset.left + width + triangleWidth;
|
left = width + triangleWidth;
|
||||||
this.$menu.removeClass( 'selector-right' ).addClass( 'selector-left' );
|
|
||||||
}
|
}
|
||||||
// Offset from the middle of the trigger
|
|
||||||
top = offset.top + ( height / 2 ) - 27;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
left: left,
|
left: offset.left + left,
|
||||||
top: top
|
// Offset from the middle of the trigger
|
||||||
|
top: offset.top + ( height / 2 ) - 27
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user