summaryrefslogtreecommitdiff
path: root/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js')
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js72
1 files changed, 35 insertions, 37 deletions
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js b/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
index f6d86d78..907b0485 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
@@ -42,8 +42,8 @@ $.wikiEditor.modules.dialogs = {
},
openDialog: function ( context, module ) {
if ( module in $.wikiEditor.modules.dialogs.modules ) {
- var mod = $.wikiEditor.modules.dialogs.modules[module];
- var $dialog = $( '#' + mod.id );
+ var mod = $.wikiEditor.modules.dialogs.modules[module],
+ $dialog = $( '#' + mod.id );
if ( $dialog.length === 0 ) {
$.wikiEditor.modules.dialogs.fn.reallyCreate( context, mod, module );
$dialog = $( '#' + mod.id );
@@ -77,12 +77,12 @@ $.wikiEditor.modules.dialogs = {
create: function ( context, config ) {
var mod, module, filtered, i, $existingDialog;
- // Defer building of modules, but do check whether they need the iframe rightaway
+ // Defer building of modules, unless they require immediate creation
for ( mod in config ) {
module = config[mod];
// Only create the dialog if it's supported, isn't filtered and doesn't exist yet
filtered = false;
- if ( typeof module.filters != 'undefined' ) {
+ if ( typeof module.filters !== 'undefined' ) {
for ( i = 0; i < module.filters.length; i++ ) {
if ( $( module.filters[i] ).length === 0 ) {
filtered = true;
@@ -92,17 +92,13 @@ $.wikiEditor.modules.dialogs = {
}
// If the dialog already exists, but for another textarea, simply remove it
$existingDialog = $( '#' + module.id );
- if ( $existingDialog.length > 0 && $existingDialog.data( 'context' ).$textarea != context.$textarea ) {
+ if ( $existingDialog.length > 0 && $existingDialog.data( 'context' ).$textarea !== context.$textarea ) {
$existingDialog.remove();
}
// Re-select from the DOM, we might have removed the dialog just now
$existingDialog = $( '#' + module.id );
if ( !filtered && $.wikiEditor.isSupported( module ) && $existingDialog.length === 0 ) {
$.wikiEditor.modules.dialogs.modules[mod] = module;
- // If this dialog requires the iframe, set it up
- if ( typeof context.$iframe === 'undefined' && $.wikiEditor.isRequired( module, 'iframe' ) ) {
- context.fn.setupIframe();
- }
context.$textarea.trigger( 'wikiEditor-dialogs-setup-' + mod );
// If this dialog requires immediate creation, create it now
if ( typeof module.immediateCreate !== 'undefined' && module.immediateCreate ) {
@@ -119,13 +115,13 @@ $.wikiEditor.modules.dialogs = {
* @param {String} name Dialog name (key in $.wikiEditor.modules.dialogs.modules)
*/
reallyCreate: function ( context, module, name ) {
- var msg,
+ var msg, dialogDiv,
configuration = module.dialog;
// Add some stuff to configuration
configuration.bgiframe = true;
configuration.autoOpen = false;
// By default our dialogs are modal, unless explicitely defined in their specific configuration.
- if( typeof configuration.modal == "undefined" ) {
+ if ( typeof configuration.modal === 'undefined' ) {
configuration.modal = true;
}
configuration.title = $.wikiEditor.autoMsg( module, 'title' );
@@ -138,7 +134,7 @@ $.wikiEditor.modules.dialogs = {
}
configuration.buttons = configuration.newButtons;
// Create the dialog <div>
- var dialogDiv = $( '<div>' )
+ dialogDiv = $( '<div>' )
.attr( 'id', module.id )
.html( module.html )
.data( 'context', context )
@@ -152,9 +148,9 @@ $.wikiEditor.modules.dialogs = {
dialogDiv
.bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize )
.find( '.ui-tabs' ).bind( 'tabsshow', function () {
- $(this).closest( '.ui-dialog-content' ).each(
+ $( this ).closest( '.ui-dialog-content' ).each(
$.wikiEditor.modules.dialogs.fn.resize );
- });
+ } );
}
dialogDiv.bind( 'dialogclose', function () {
context.fn.restoreSelection();
@@ -171,36 +167,38 @@ $.wikiEditor.modules.dialogs = {
* NOTE: This function assumes $.ui.dialog has already been loaded
*/
resize: function () {
- var wrapper = $(this).closest( '.ui-dialog' );
- var oldWidth = wrapper.width();
- // Make sure elements don't wrapped so we get an accurate idea of whether they really fit. Also temporarily show
- // hidden elements. Work around jQuery bug where <div style="display: inline;"/> inside a dialog is both
- // :visible and :hidden
- var oldHidden = $(this).find( '*' ).not( ':visible' );
+ var oldWS, thisWidth, wrapperWidth,
+ wrapper = $( this ).closest( '.ui-dialog' ),
+ oldWidth = wrapper.width(),
+ // Make sure elements don't wrapped so we get an accurate idea of whether they really fit. Also temporarily show
+ // hidden elements. Work around jQuery bug where <div style="display: inline;"/> inside a dialog is both
+ // :visible and :hidden
+ oldHidden = $( this ).find( '*' ).not( ':visible' );
+
// Save the style attributes of the hidden elements to restore them later. Calling hide() after show() messes up
// for elements hidden with a class
oldHidden.each( function () {
- $(this).data( 'oldstyle', $(this).attr( 'style' ) );
- });
+ $( this ).data( 'oldstyle', $( this ).attr( 'style' ) );
+ } );
oldHidden.show();
- var oldWS = $(this).css( 'white-space' );
- $(this).css( 'white-space', 'nowrap' );
- if ( wrapper.width() <= $(this).get(0).scrollWidth ) {
- var thisWidth = $(this).data( 'thisWidth' ) ? $(this).data( 'thisWidth' ) : 0;
- thisWidth = Math.max( $(this).get(0).width, thisWidth );
- $(this).width( thisWidth );
- $(this).data( 'thisWidth', thisWidth );
- var wrapperWidth = $(this).data( 'wrapperWidth' ) ? $(this).data( 'wrapperWidth' ) : 0;
- wrapperWidth = Math.max( wrapper.get(0).scrollWidth, wrapperWidth );
+ oldWS = $( this ).css( 'white-space' );
+ $( this ).css( 'white-space', 'nowrap' );
+ if ( wrapper.width() <= $( this ).get( 0 ).scrollWidth ) {
+ thisWidth = $( this ).data( 'thisWidth' ) ? $( this ).data( 'thisWidth' ) : 0;
+ thisWidth = Math.max( $( this ).get( 0 ).width, thisWidth );
+ $( this ).width( thisWidth );
+ $( this ).data( 'thisWidth', thisWidth );
+ wrapperWidth = $( this ).data( 'wrapperWidth' ) ? $( this ).data( 'wrapperWidth' ) : 0;
+ wrapperWidth = Math.max( wrapper.get( 0 ).scrollWidth, wrapperWidth );
wrapper.width( wrapperWidth );
- $(this).data( 'wrapperWidth', wrapperWidth );
- $(this).dialog( { 'width': wrapper.width() } );
+ $( this ).data( 'wrapperWidth', wrapperWidth );
+ $( this ).dialog( { 'width': wrapper.width() } );
wrapper.css( 'left', parseInt( wrapper.css( 'left' ), 10 ) - ( wrapper.width() - oldWidth ) / 2 );
}
- $(this).css( 'white-space', oldWS );
+ $( this ).css( 'white-space', oldWS );
oldHidden.each( function () {
- $(this).attr( 'style', $(this).data( 'oldstyle' ) );
- });
+ $( this ).attr( 'style', $( this ).data( 'oldstyle' ) );
+ } );
},
/**
* Set the right tabindexes on elements in a dialog
@@ -210,7 +208,7 @@ $.wikiEditor.modules.dialogs = {
// Get the highest tab index
var tabIndex = $( document ).lastTabIndex() + 1;
$elements.each( function () {
- $(this).attr( 'tabindex', tabIndex++ );
+ $( this ).attr( 'tabindex', tabIndex++ );
} );
}
},