Permalink
Browse files

Item14388: Generate correct URLs

  • Loading branch information...
gac410 committed May 3, 2017
1 parent 3f7c5f2 commit 17f1ed4da420417758b6684b6e9eea8df978bec3
Showing with 26 additions and 10 deletions.
  1. +26 −10 NatEditPlugin/pub/System/NatEditPlugin/jquery.natedit.uncompressed.js
@@ -482,7 +482,11 @@ $.NatEditor.prototype.initGui = function() {
onDeselect: updateDetails,
onClear: updateDetails,
onReset: updateDetails,
- autocomplete: self.opts.scriptUrl + "/view/" + self.opts.systemWeb + "/JQueryAjaxHelper?section=user;skin=text;contenttype=application/json"
+ autocomplete: foswiki.getScriptUrl('view', self.opts.systemWeb, 'JQueryAjaxHelper', {
+ section: 'user',
+ skin: 'text',
+ contenttype: 'application/json'
+ })
});
function setPermissionSet(data) {
@@ -537,7 +541,10 @@ $.NatEditor.prototype.switchToWYSIWYG = function(ev) {
$.NatEditor.prototype.initToolbar = function() {
var self = this,
$txtarea = $(self.txtarea),
- url = self.opts.scriptUrl+"/rest/JQueryPlugin/tmpl?topic="+self.opts.web+"."+self.opts.topic+"&load="+self.opts.toolbar;
+ url = foswiki.getScriptUrl('rest', "JQueryPlugin", "tmpl", {
+ topic: self.opts.web+"."+self.opts.topic,
+ load: self.opts.toolbar
+ });
// load toolbar
$.loadTemplate({
@@ -914,7 +921,7 @@ $.NatEditor.prototype.initForm = function() {
self.form.submit();
} else {
self.form.ajaxSubmit({
- url: self.opts.scriptUrl + '/rest/NatEditPlugin/save', // SMELL: use this one for REST as long as the normal save can't cope with REST
+ url: foswiki.getScriptUrl( 'rest', 'NatEditPlugin', 'save'), // SMELL: use this one for REST as long as the normal save can't cope with REST
beforeSubmit: function() {
self.hideMessages();
document.title = "Saving ...";
@@ -965,7 +972,7 @@ $.NatEditor.prototype.initForm = function() {
self.beforeSubmit("preview");
self.form.ajaxSubmit({
- url: self.opts.scriptUrl + '/rest/NatEditPlugin/save', // SMELL: use this one for REST as long as the normal save can't cope with REST
+ url: foswiki.getScriptUrl( 'rest', 'NatEditPlugin', 'save'), // SMELL: use this one for REST as long as the normal save can't cope with REST
beforeSubmit: function() {
self.hideMessages();
$.blockUI({
@@ -1853,7 +1860,12 @@ $.NatEditor.prototype.dialog = function(opts) {
}
if (typeof(opts.url) === 'undefined' && typeof(opts.name) !== 'undefined') {
- opts.url = self.opts.scriptUrl+"/rest/JQueryPlugin/tmpl?topic="+self.opts.web+"."+self.opts.topic+"&load=editdialog&name="+opts.name;
+ opts.url = foswiki.getScriptUrl( 'rest', 'JQueryPlugin', 'tmpl', {
+ topic: self.opts.web+"."+self.opts.topic,
+ load: 'editdialog',
+ name: opts.name
+ });
+
}
opts = $.extend({}, defaults, opts);
@@ -2284,7 +2296,11 @@ $.NatEditor.prototype.initLinkDialog = function(elem, data) {
$dialog.find("input[name='web']").each(function() {
$(this).autocomplete({
- source: self.opts.scriptUrl+"/view/"+self.opts.systemWeb+"/JQueryAjaxHelper?section=web&skin=text&contenttype=application/json"
+ source: foswiki.getScriptUrl('view', self.opts.systemWeb, 'JQueryAjaxHelper', {
+ section: 'web',
+ skin: 'text',
+ contenttype: 'application/json'
+ })
});
});
@@ -2295,7 +2311,7 @@ $.NatEditor.prototype.initLinkDialog = function(elem, data) {
xhr.abort();
}
xhr = $.ajax({
- url: self.opts.scriptUrl+"/view/"+self.opts.systemWeb+"/JQueryAjaxHelper",
+ url: foswiki.getScriptUrl('view', self.opts.systemWeb, 'JQueryAjaxHelper'),
data: $.extend(request, {
section: 'topic',
skin: 'text',
@@ -2328,9 +2344,10 @@ $.NatEditor.prototype.initLinkDialog = function(elem, data) {
xhr.abort();
}
xhr = $.ajax({
- url: self.opts.scriptUrl+"/rest/NatEditPlugin/attachments",
+ url: foswiki.getScriptUrl('rest', 'NatEditPlugin', 'attachments'),
data: $.extend(request, {
- topic: $container.find("input[name='web']").val()+'.'+$container.find("input[name='topic']").val()
+ // The topic autocomplete actually returns the Web.Topic
+ topic: $container.find("input[name='topic']").val()
}),
dataType: "json",
autocompleteRequest: ++requestIndex,
@@ -2369,7 +2386,6 @@ $.NatEditor.prototype.initLinkDialog = function(elem, data) {
}
};
});
-
if (typeof(data.type) !== 'undefined') {
tabId = $dialog.find(".jqTab."+data.type).attr("id");

0 comments on commit 17f1ed4

Please sign in to comment.