From 903ea7c49aa1220c16892a6eafffb696a026e7c1 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 27 Sep 2011 16:50:24 -0500 Subject: [PATCH] Reindent dialog JS and trim trailing spaces --- .../public/javascript/gollum.dialog.js | 374 +++++++++--------- 1 file changed, 187 insertions(+), 187 deletions(-) diff --git a/lib/gollum/frontend/public/javascript/gollum.dialog.js b/lib/gollum/frontend/public/javascript/gollum.dialog.js index 99cf0890..30f50b8e 100755 --- a/lib/gollum/frontend/public/javascript/gollum.dialog.js +++ b/lib/gollum/frontend/public/javascript/gollum.dialog.js @@ -4,203 +4,203 @@ * Used for dialogs. Duh. * */ - -(function($) { - - var Dialog = { - - debugOn: false, - markupCreated: false, - - attachEvents: function( evtOK ) { - $('#gollum-dialog-action-ok').click(function( e ) { - Dialog.eventOK( e, evtOK ); - }); - $('#gollum-dialog-action-cancel').click( Dialog.eventCancel ); - }, - - createFieldMarkup: function( fieldArray ) { - var fieldMarkup = '
'; - for ( var i=0; i < fieldArray.length; i++ ) { - if ( typeof fieldArray[i] == 'object' ) { - fieldMarkup += '
'; - switch ( fieldArray[i].type ) { - - // only text is supported for now - case 'text': - fieldMarkup += Dialog.createFieldText( fieldArray[i] ); - break; - - default: - break; - - } - fieldMarkup += '
'; - } - - } - fieldMarkup += '
'; - return fieldMarkup; - }, - - createFieldText: function( fieldAttributes ) { - var html = ''; - - if ( fieldAttributes.name ) { - html += ''; - } - - html += ''; - } - - return html; - }, - - createMarkup: function( title, body ) { - Dialog.markupCreated = true; - return '
' + - '
' + - '
' + - '

' + - title +'

' + - '
' + body + '
' + - '
' + - 'Cancel' + - 'OK' + - '
' + - '
' + - '
' + - '
'; - }, - - eventCancel: function( e ) { - e.preventDefault(); - debug('Cancelled dialog.'); - Dialog.hide(); - }, - - eventOK: function( e, evtOK ) { - e.preventDefault(); - - var results = []; - // get the results from each field and build them into the object - $('#gollum-dialog-dialog-body input').each(function() { - results[$(this).attr('name')] = $(this).val(); - }); - - // pass them to evtOK if it exists (which it should) - if ( evtOK && - typeof evtOK == 'function' ) { - evtOK( results ); - } - Dialog.hide(); - }, - hide: function() { - if ( $.browser.msie ) { +(function($) { + + var Dialog = { + + debugOn: false, + markupCreated: false, + + attachEvents: function( evtOK ) { + $('#gollum-dialog-action-ok').click(function( e ) { + Dialog.eventOK( e, evtOK ); + }); + $('#gollum-dialog-action-cancel').click( Dialog.eventCancel ); + }, + + createFieldMarkup: function( fieldArray ) { + var fieldMarkup = '
'; + for ( var i=0; i < fieldArray.length; i++ ) { + if ( typeof fieldArray[i] == 'object' ) { + fieldMarkup += '
'; + switch ( fieldArray[i].type ) { + + // only text is supported for now + case 'text': + fieldMarkup += Dialog.createFieldText( fieldArray[i] ); + break; + + default: + break; + + } + fieldMarkup += '
'; + } + + } + fieldMarkup += '
'; + return fieldMarkup; + }, + + createFieldText: function( fieldAttributes ) { + var html = ''; + + if ( fieldAttributes.name ) { + html += ''; + } + + html += ''; + } + + return html; + }, + + createMarkup: function( title, body ) { + Dialog.markupCreated = true; + return '
' + + '
' + + '
' + + '

' + + title +'

' + + '
' + body + '
' + + '
' + + 'Cancel' + + 'OK' + + '
' + + '
' + + '
' + + '
'; + }, + + eventCancel: function( e ) { + e.preventDefault(); + debug('Cancelled dialog.'); + Dialog.hide(); + }, + + eventOK: function( e, evtOK ) { + e.preventDefault(); + + var results = []; + // get the results from each field and build them into the object + $('#gollum-dialog-dialog-body input').each(function() { + results[$(this).attr('name')] = $(this).val(); + }); + + // pass them to evtOK if it exists (which it should) + if ( evtOK && + typeof evtOK == 'function' ) { + evtOK( results ); + } + Dialog.hide(); + }, + + hide: function() { + if ( $.browser.msie ) { $('#gollum-dialog-dialog').hide().removeClass('active'); - $('select').css('visibility', 'visible'); - } else { - $('#gollum-dialog-dialog').animate({ opacity: 0 }, { - duration: 200, + $('select').css('visibility', 'visible'); + } else { + $('#gollum-dialog-dialog').animate({ opacity: 0 }, { + duration: 200, + complete: function() { + $('#gollum-dialog-dialog').removeClass('active'); + } + }); + } + }, + + init: function( argObject ) { + var title = ''; + var body = ''; + + // bail out if necessary + if ( !argObject || + typeof argObject != 'object' ) { + debug('Editor Dialog: Cannot init; invalid init object'); + return; + } + + if ( argObject.body && typeof argObject.body == 'string' ) { + body = '

' + argObject.body + '

'; + } + + // alright, build out fields + if ( argObject.fields && typeof argObject.fields == 'object' ) { + body += Dialog.createFieldMarkup( argObject.fields ); + } + + if ( argObject.title && typeof argObject.title == 'string' ) { + title = argObject.title; + } + + if ( Dialog.markupCreated ) { + $('#gollum-dialog-dialog').remove(); + } + var $dialog = $( Dialog.createMarkup( title, body ) ); + $('body').append( $dialog ); + if ( argObject.OK && + typeof argObject.OK == 'function' ) { + Dialog.attachEvents( argObject.OK ); + } + Dialog.show(); + }, + + show: function() { + if ( !Dialog.markupCreated ) { + debug('Dialog: No markup to show. Please use init first.'); + } else { + debug('Showing dialog'); + if ( $.browser.msie ) { + $('#gollum-dialog.dialog').addClass('active'); + Dialog.position(); + $('select').css('visibility', 'hidden'); + } else { + $('#gollum-dialog.dialog').css('display', 'none'); + $('#gollum-dialog-dialog').animate({ opacity: 0 }, { + duration: 0, complete: function() { - $('#gollum-dialog-dialog').removeClass('active'); + $('#gollum-dialog-dialog').css('display', 'block'); + Dialog.position(); // position this thing + $('#gollum-dialog-dialog').animate({ opacity: 1 }, { + duration: 500 + }); } }); } - }, - - init: function( argObject ) { - var title = ''; - var body = ''; - - // bail out if necessary - if ( !argObject || - typeof argObject != 'object' ) { - debug('Editor Dialog: Cannot init; invalid init object'); - return; - } - - if ( argObject.body && typeof argObject.body == 'string' ) { - body = '

' + argObject.body + '

'; - } - - // alright, build out fields - if ( argObject.fields && typeof argObject.fields == 'object' ) { - body += Dialog.createFieldMarkup( argObject.fields ); - } - - if ( argObject.title && typeof argObject.title == 'string' ) { - title = argObject.title; - } - - if ( Dialog.markupCreated ) { - $('#gollum-dialog-dialog').remove(); - } - var $dialog = $( Dialog.createMarkup( title, body ) ); - $('body').append( $dialog ); - if ( argObject.OK && - typeof argObject.OK == 'function' ) { - Dialog.attachEvents( argObject.OK ); - } - Dialog.show(); - }, - - show: function() { - if ( !Dialog.markupCreated ) { - debug('Dialog: No markup to show. Please use init first.'); - } else { - debug('Showing dialog'); - if ( $.browser.msie ) { - $('#gollum-dialog.dialog').addClass('active'); - Dialog.position(); - $('select').css('visibility', 'hidden'); - } else { - $('#gollum-dialog.dialog').css('display', 'none'); - $('#gollum-dialog-dialog').animate({ opacity: 0 }, { - duration: 0, - complete: function() { - $('#gollum-dialog-dialog').css('display', 'block'); - Dialog.position(); // position this thing - $('#gollum-dialog-dialog').animate({ opacity: 1 }, { - duration: 500 - }); - } - }); - } - } - }, - - position: function() { - var dialogHeight = $('#gollum-dialog-dialog-inner').height(); - $('#gollum-dialog-dialog-inner') - .css('height', dialogHeight + 'px') - .css('margin-top', -1 * parseInt( dialogHeight / 2 )); - } - - }; - + } + }, + + position: function() { + var dialogHeight = $('#gollum-dialog-dialog-inner').height(); + $('#gollum-dialog-dialog-inner') + .css('height', dialogHeight + 'px') + .css('margin-top', -1 * parseInt( dialogHeight / 2 )); + } + + }; + var debug = function(m) { if ( Dialog.debugOn && typeof console != 'undefined' ) { console.log( m ); } }; - + $.GollumDialog = Dialog; - -})(jQuery); \ No newline at end of file + +})(jQuery);