lib/gollum/frontend/public/gollum/javascript/gollum.js in gollum-2.0.0 vs lib/gollum/frontend/public/gollum/javascript/gollum.js in gollum-2.1.0
- old
+ new
@@ -1,7 +1,18 @@
// ua
$(document).ready(function() {
+ $('#delete-link').click( function(e) {
+ var ok = confirm($(this).data('confirm'));
+ if ( ok ) {
+ var loc = window.location;
+ loc = baseUrl + 'delete' + loc.pathname
+ window.location = loc;
+ }
+ // Don't navigate on cancel.
+ e.preventDefault();
+ } );
+
var nodeSelector = {
node1: null,
node2: null,
selectNodeRange: function( n1, n2 ) {
@@ -95,30 +106,81 @@
} else if ($.browser.version == "8.0") {
$('body').addClass('ie8');
}
}
+ if ($('#minibutton-rename-page').length) {
+ $('#minibutton-rename-page').removeClass('jaws');
+ $('#minibutton-rename-page').click(function(e) {
+ e.preventDefault();
+
+ // Path name without the leading slash.
+ var pathname = window.location.pathname.substr(1);
+ var slashIndex = pathname.lastIndexOf('/');
+ var oldName = pathname.substr(slashIndex + 1)
+ var path = pathname.substr(0, slashIndex);
+
+ $.GollumDialog.init({
+ title: 'Rename Page',
+ fields: [
+ {
+ id: 'name',
+ name: 'Rename to',
+ type: 'text',
+ defaultValue: oldName || ''
+ }
+ ],
+ OK: function( res ) {
+ var newName = 'Rename Page';
+ if ( res['name'] ) {
+ newName = res['name'];
+ }
+
+ var msg = 'Renamed ' + oldName + ' to ' + newName;
+ jQuery.ajax( {
+ type: 'POST',
+ url: baseUrl + 'edit/' + oldName,
+ data: { path: path, rename: newName, page: oldName, message: msg },
+ success: function() {
+ window.location = baseUrl + encodeURIComponent(newName);
+ }
+ });
+ }
+ });
+ });
+ }
+
if ($('#minibutton-new-page').length) {
$('#minibutton-new-page').removeClass('jaws');
$('#minibutton-new-page').click(function(e) {
e.preventDefault();
+
+ var path = location.pathname;
+ // ensure there's more than one slash in pathname.
+ if (path.split('/').length > 2) {
+ path = path.substr(path.lastIndexOf('/')+1) + '/';
+ } else {
+ path = '';
+ }
+
$.GollumDialog.init({
- title: 'Create New Page',
- fields: [
- {
- id: 'name',
- name: 'Page Name',
- type: 'text'
- }
- ],
- OK: function( res ) {
- var n = 'New Page';
- if ( res['name'] )
- var n = res['name'];
- n = encodeURIComponent( n );
- window.location = '/' + n;
- }
- });
+ title: 'Create New Page',
+ fields: [
+ {
+ id: 'name',
+ name: 'Page Name',
+ type: 'text',
+ defaultValue: path || ''
+ }
+ ],
+ OK: function( res ) {
+ var name = 'New Page';
+ if ( res['name'] ) {
+ name = res['name'];
+ }
+ window.location = baseUrl + encodeURIComponent(name);
+ }
+ });
});
}
if ($('#wiki-wrapper').hasClass('history')) {
$('#wiki-history td.checkbox input').each(function() {