diff --git a/lib/gollum/frontend/public/javascript/gollum.dialog.js b/lib/gollum/frontend/public/javascript/gollum.dialog.js index 30f50b8e..b5402420 100755 --- a/lib/gollum/frontend/public/javascript/gollum.dialog.js +++ b/lib/gollum/frontend/public/javascript/gollum.dialog.js @@ -11,12 +11,23 @@ debugOn: false, markupCreated: false, + markup: '', attachEvents: function( evtOK ) { $('#gollum-dialog-action-ok').click(function( e ) { Dialog.eventOK( e, evtOK ); }); $('#gollum-dialog-action-cancel').click( Dialog.eventCancel ); + $('#gollum-dialog-dialog input[type="text"]').keydown(function( e ) { + if ( e.keyCode == 13 ) { + Dialog.eventOK( e, evtOK ); + } + }); + }, + + detachEvents: function() { + $('#gollum-dialog-action-ok').unbind('click'); + $('#gollum-dialog-action-cancel').unbind('click'); }, createFieldMarkup: function( fieldArray ) { @@ -70,21 +81,35 @@ createMarkup: function( title, body ) { Dialog.markupCreated = true; - return '
' + - '
' + - '
' + - '

' + - title +'

' + - '
' + body + '
' + - '
' + - 'Cancel' + - 'OK' + - '
' + - '
' + - '
' + - '
'; + if ($.facebox) { + return '
' + + '

' + + title +'

' + + '
' + body + '
' + + '
' + + 'Cancel' + + 'OK' + + '
' + + '
'; + } else { + return '
' + + '
' + + '
' + + '

' + + title +'

' + + '
' + body + '
' + + '
' + + 'Cancel' + + 'OK' + + '
' + + '
' + + '
' + + '
'; + } }, eventCancel: function( e ) { @@ -111,16 +136,22 @@ }, hide: function() { - if ( $.browser.msie ) { - $('#gollum-dialog-dialog').hide().removeClass('active'); - $('select').css('visibility', 'visible'); + if ( $.facebox ) { + Dialog.markupCreated = false; + $(document).trigger('close.facebox'); + Dialog.detachEvents(); } else { - $('#gollum-dialog-dialog').animate({ opacity: 0 }, { - duration: 200, - complete: function() { - $('#gollum-dialog-dialog').removeClass('active'); - } - }); + if ( $.browser.msie ) { + $('#gollum-dialog-dialog').hide().removeClass('active'); + $('select').css('visibility', 'visible'); + } else { + $('#gollum-dialog-dialog').animate({ opacity: 0 }, { + duration: 200, + complete: function() { + $('#gollum-dialog-dialog').removeClass('active'); + } + }); + } } }, @@ -149,14 +180,31 @@ } if ( Dialog.markupCreated ) { - $('#gollum-dialog-dialog').remove(); + if ($.facebox) { + $(document).trigger('close.facebox'); + } else { + $('#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.markup = Dialog.createMarkup( title, body ); + + if ($.facebox) { + $(document).bind('reveal.facebox', function() { + if ( argObject.OK && + typeof argObject.OK == 'function' ) { + Dialog.attachEvents( argObject.OK ); + $($('#facebox input[type="text"]').get(0)).focus(); + } + }); + } else { + $('body').append( Dialog.markup ); + if ( argObject.OK && + typeof argObject.OK == 'function' ) { + Dialog.attachEvents( argObject.OK ); + } } + Dialog.show(); }, @@ -165,22 +213,26 @@ 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'); + if ($.facebox) { + $.facebox( Dialog.markup ); } 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 }, { + 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 - }); - } - }); + }); + } + }); + } } } }, @@ -191,9 +243,14 @@ .css('height', dialogHeight + 'px') .css('margin-top', -1 * parseInt( dialogHeight / 2 )); } - }; + if ($.facebox) { + $(document).bind('reveal.facebox', function() { + $('#facebox img.close_image').remove(); + }); + } + var debug = function(m) { if ( Dialog.debugOn && typeof console != 'undefined' ) {