" )
.addClass( "settings-title" )
.text( module.name );
var $settingsText = $( "
" )
.addClass( "settings-text" )
.text( module.description );
var $settingsLink = $( "" )
.addClass( moduleName + "-settings-block menu-section" )
.prop( "id", moduleName + "-settings-block" )
.data( "module", module )
.append( $settingsTitle )
.append( $settingsText );
$settingsMenuItems.append( $settingsLink );
$settingsLink.on( "click", function () {
var module = $( this ).data( "module" );
module.render();
$( this ).addClass( 'active' );
} );
if ( active ) {
module.render();
$settingsLink.addClass( 'active' );
}
},
show: function () {
if ( !this.initialized ) {
this.render();
this.initialized = true;
var pos = $.extend( {}, this.$element.offset(), {
height: this.$element[0].offsetHeight
} );
var top = this.top || pos.top + pos.height;
var left = this.left || '25%';
// FIXME this is not exactly correct. position may not
// be relative to the trigger.
this.$window.css( {
top: top,
left: left
} );
}
this.$window.i18n();
this.shown = true;
this.$window.show();
},
/**
* Hide this window.
* Will be used when moving to a different context and
* need coming back.
*/
hide: function () {
this.shown = false;
this.$window.hide();
},
/**
* Close this language settings window, and
* call onClose if defined from the previous context.
*/
close: function () {
this.hide();
if ( this.options.onClose ) {
this.options.onClose();
}
},
click: function ( e ) {
if ( !this.shown ) {
this.show();
}
}
};
$.fn.languagesettings = function ( option ) {
return this.each( function () {
var $this = $( this ),
data = $this.data( "languagesettings" ),
options = typeof option === "object" && option;
if ( !data ) {
$this.data( "languagesettings", ( data = new LanguageSettings( this, options ) ) );
}
if ( typeof option === "string" ) {
data[option]();
}
} );
};
$.fn.languagesettings.modules = {};
$.fn.languagesettings.defaults = {
template: windowTemplate,
defaultModule: false, // Name of the default module
onClose: null, // An onClose event handler.
top: null, // Top position of this window
left: null // Left position of this window
};
$.fn.languagesettings.Constructor = LanguageSettings;
}( jQuery ) );