TreeController.prototype.renameNode = function()

in src/main/resources/SLING-INF/libs/sling/resource-editor/static/js/tree/TreeController.js [141:169]


	TreeController.prototype.renameNode = function(e, data) {
		var thatTreeController = this;
		var newName = this.mainController.decodeFromHTML(data.text);
		var oldName = data.old;
		if (oldName!==newName){
			var currentURL = this.getPathFromLi($('#'+data.node.id));
			var unencodedURI = currentURL;
			var decodedCurrentURI = this.mainController.decodeFromHTML(unencodedURI);
			var newURI = decodedCurrentURI.replace(oldName, newName);
			currentURL = this.mainController.encodeURL(decodedCurrentURI);
			$.ajax({
		  	  type: 'POST',
			  url: currentURL,
		  	  success: function(server_data) {
		  		  thatTreeController.mainController.redirectTo(newURI);
			  },
		  	  error: function(errorJson) {
		  		  thatTreeController.mainController.displayAlert(errorJson);
			  },
			  dataType: "json",
			  contentType : 'application/x-www-form-urlencoded; charset=UTF-8',
		  	  data: { 
		  		":operation": "move",
		  		"_charset_": "utf-8",
		  		":dest": newURI
		  		  }
		  	});
		}
	}