Fix JSLint issues in Dialog; add revert dialog on history page
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
var Dialog = {
|
||||
|
||||
debugOn: false,
|
||||
markupCreated: false,
|
||||
|
||||
attachEvents: function( evtOK ) {
|
||||
@@ -27,10 +28,11 @@
|
||||
|
||||
// only text is supported for now
|
||||
case 'text':
|
||||
case 'code':
|
||||
default:
|
||||
fieldMarkup += Dialog.createFieldText( fieldArray[i] );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
fieldMarkup += '</div>';
|
||||
@@ -126,10 +128,14 @@
|
||||
debug('Editor Dialog: Cannot init; invalid init object');
|
||||
return;
|
||||
}
|
||||
|
||||
if ( argObject.body && typeof argObject.body == 'string' ) {
|
||||
body = '<p>' + argObject.body + '</p>';
|
||||
}
|
||||
|
||||
// alright, build out fields
|
||||
if ( argObject.fields && typeof argObject.fields == 'object' ) {
|
||||
body = Dialog.createFieldMarkup( argObject.fields );
|
||||
body += Dialog.createFieldMarkup( argObject.fields );
|
||||
}
|
||||
|
||||
if ( argObject.title && typeof argObject.title == 'string' ) {
|
||||
@@ -150,7 +156,7 @@
|
||||
|
||||
show: function() {
|
||||
if ( !Dialog.markupCreated ) {
|
||||
debug('Dialog: No markup to show. Please use init first.')
|
||||
debug('Dialog: No markup to show. Please use init first.');
|
||||
} else {
|
||||
debug('Showing dialog');
|
||||
$('#gollum-dialog-dialog').animate({ opacity: 0 }, {
|
||||
@@ -168,7 +174,6 @@
|
||||
|
||||
position: function() {
|
||||
var dialogHeight = $('#gollum-dialog-dialog-inner').height();
|
||||
debug(dialogHeight);
|
||||
$('#gollum-dialog-dialog-inner')
|
||||
.css('height', dialogHeight + 'px')
|
||||
.css('margin-top', -1 * parseInt( dialogHeight / 2 ));
|
||||
@@ -176,6 +181,14 @@
|
||||
|
||||
};
|
||||
|
||||
var debug = function(m) {
|
||||
if ( Dialog.debugOn
|
||||
&& typeof console != 'undefined'
|
||||
&& typeof console.log == 'function' ) {
|
||||
console.log( m );
|
||||
}
|
||||
};
|
||||
|
||||
$.GollumDialog = Dialog;
|
||||
|
||||
})(jQuery);
|
||||
@@ -29,7 +29,27 @@ $(document).ready(function() {
|
||||
|
||||
$('#wiki-history td.revert-action a').mouseenter(highlightOn);
|
||||
$('#wiki-history td.revert-action a').mouseleave(highlightOff);
|
||||
};
|
||||
}
|
||||
|
||||
if ($('td.revert-action a').length) {
|
||||
$('td.revert-action a').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var commitSha = $(this).attr('rel');
|
||||
var truncatedSha = commitSha.toString().substr(0, 7) + "…";
|
||||
// revert action
|
||||
$.GollumDialog.init({
|
||||
title: 'Revert to ' + truncatedSha + '?',
|
||||
body: 'Are you sure you wish to revert to revision <code>' +
|
||||
truncatedSha + '</code>' +
|
||||
' ? This will overwrite any previous changes.',
|
||||
OK: function() {
|
||||
// TODO add async endpoint to revert here
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user