Add rename button. Fix #444.
This commit is contained in:
@@ -113,6 +113,48 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
|
||||
if ($('#minibutton-rename-page').length) {
|
||||
$('#minibutton-rename-page').removeClass('jaws');
|
||||
$('#minibutton-rename-page').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var path = $(this).data('path');
|
||||
if (path) {
|
||||
path = path + '/';
|
||||
}
|
||||
|
||||
$.GollumDialog.init({
|
||||
title: 'Rename Page',
|
||||
fields: [
|
||||
{
|
||||
id: 'name',
|
||||
name: 'Rename to',
|
||||
type: 'text',
|
||||
defaultValue: path || ''
|
||||
}
|
||||
],
|
||||
OK: function( res ) {
|
||||
var name = 'Rename Page';
|
||||
if ( res['name'] ) {
|
||||
name = res['name'];
|
||||
}
|
||||
var path = window.location.pathname;
|
||||
var oldName = path.substring(path.lastIndexOf('/')+1);
|
||||
var msg = 'Renamed ' + oldName + ' to ' + name;
|
||||
jQuery.ajax( {
|
||||
type: 'POST',
|
||||
url: '/edit/' + oldName,
|
||||
// omit path: pathName until https://github.com/github/gollum/issues/446 is fixed.
|
||||
data: { rename: name, page: oldName, message: msg },
|
||||
success: function() {
|
||||
window.location = '/' + encodeURIComponent(name);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if ($('#minibutton-new-page').length) {
|
||||
$('#minibutton-new-page').removeClass('jaws');
|
||||
$('#minibutton-new-page').click(function(e) {
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
class="action-all-pages">File View</a></li>
|
||||
<li class="minibutton" class="jaws">
|
||||
<a href="#" id="minibutton-new-page">New Page</a></li>
|
||||
<li class="minibutton" class="jaws">
|
||||
<a href="#" id="minibutton-rename-page">Rename Page</a></li>
|
||||
{{#editable}}
|
||||
<li class="minibutton"><a href="/edit/{{escaped_url_path}}"
|
||||
class="action-edit-page">Edit Page</a></li>
|
||||
|
||||
Reference in New Issue
Block a user