Add options.onPosition and deprecate top and left (#385)
This commit is contained in:
@@ -61,12 +61,13 @@ $( '.uls-trigger' ).uls( {
|
|||||||
|
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
|-------------|---------------------|
|
|-------------|---------------------|
|
||||||
| left | Left position of ULS dialog. E.g: 100px or 20% |
|
| left | DEPRECATED: use onPosition |
|
||||||
| top | Top position of ULS dialog. E.g: 100px or 20% |
|
| top | DEPRECATED: use onPosition |
|
||||||
| onSelect | Callback function when user selects a language. |
|
| onSelect | Callback function when user selects a language. |
|
||||||
| onCancel | Callback function when the dialog is closed without selecting a language. |
|
| onCancel | Callback function when the dialog is closed without selecting a language. |
|
||||||
| onReady | Callback function when ULS has initialized. |
|
| onReady | Callback function when ULS has initialized. |
|
||||||
| onVisible | Callback function when ULS dialog is shown. |
|
| onVisible | Callback function when ULS dialog is shown. |
|
||||||
|
| onPosition | Callback for positioning the dialog. It should return an object with any of the keys `top`, `right`, `bottom` and `left`. |
|
||||||
| languages | List of selectable languages. Defaults to all known languages. |
|
| languages | List of selectable languages. Defaults to all known languages. |
|
||||||
| menuWidth | Override the automatic choice of menu width. One of narrow, medium, wide (1, 2, 4 columns respectively). |
|
| menuWidth | Override the automatic choice of menu width. One of narrow, medium, wide (1, 2, 4 columns respectively). |
|
||||||
| ulsPurpose | A string that will identify this instance of ULS. It's useful if you have several instances of ULS in your web application and you want to have a unique identifier for each of them. |
|
| ulsPurpose | A string that will identify this instance of ULS. It's useful if you have several instances of ULS in your web application and you want to have a unique identifier for each of them. |
|
||||||
|
|||||||
@@ -119,6 +119,11 @@
|
|||||||
top = this.top,
|
top = this.top,
|
||||||
left = this.left;
|
left = this.left;
|
||||||
|
|
||||||
|
if ( this.options.onPosition ) {
|
||||||
|
return this.options.onPosition.call( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default implementation (middle of the screen under the trigger)
|
||||||
if ( top === undefined ) {
|
if ( top === undefined ) {
|
||||||
pos = $.extend( {}, this.$element.offset(), {
|
pos = $.extend( {}, this.$element.offset(), {
|
||||||
height: this.$element[ 0 ].offsetHeight
|
height: this.$element[ 0 ].offsetHeight
|
||||||
@@ -380,9 +385,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.fn.uls.defaults = {
|
$.fn.uls.defaults = {
|
||||||
// CSS top position for the dialog
|
// DEPRECATED: CSS top position for the dialog
|
||||||
top: undefined,
|
top: undefined,
|
||||||
// CSS left position for the dialog
|
// DEPRECATED: CSS left position for the dialog
|
||||||
left: undefined,
|
left: undefined,
|
||||||
// Callback function when user selects a language
|
// Callback function when user selects a language
|
||||||
onSelect: undefined,
|
onSelect: undefined,
|
||||||
@@ -392,6 +397,8 @@
|
|||||||
onReady: undefined,
|
onReady: undefined,
|
||||||
// Callback function when ULS dialog is shown
|
// Callback function when ULS dialog is shown
|
||||||
onVisible: undefined,
|
onVisible: undefined,
|
||||||
|
// Callback function when ULS dialog is ready to be shown
|
||||||
|
onPosition: undefined,
|
||||||
// Languages to be used for ULS, default is all languages
|
// Languages to be used for ULS, default is all languages
|
||||||
languages: $.uls.data.getAutonyms(),
|
languages: $.uls.data.getAutonyms(),
|
||||||
// The options are wide (4 columns), medium (2 columns), and narrow (1 column).
|
// The options are wide (4 columns), medium (2 columns), and narrow (1 column).
|
||||||
|
|||||||
Reference in New Issue
Block a user