Skip to content

Commit

Permalink
Item14388: Generate correct URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed May 3, 2017
1 parent 3f7c5f2 commit 17f1ed4
Showing 1 changed file with 26 additions and 10 deletions.
Expand Up @@ -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) {
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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 ...";
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'
})
});
});

Expand All @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -2369,7 +2386,6 @@ $.NatEditor.prototype.initLinkDialog = function(elem, data) {
}
};
});


if (typeof(data.type) !== 'undefined') {
tabId = $dialog.find(".jqTab."+data.type).attr("id");
Expand Down

0 comments on commit 17f1ed4

Please sign in to comment.