Absolute urls in plugins.

This commit is contained in:
Julia Radzhabova 2016-09-05 18:28:56 +03:00
parent f821bd04fa
commit 6bfd3d80bb
6 changed files with 15 additions and 8 deletions

View file

@ -219,8 +219,12 @@ define([
onPluginShow: function(plugin, variationIndex) { onPluginShow: function(plugin, variationIndex) {
var variation = plugin.get_Variations()[variationIndex]; var variation = plugin.get_Variations()[variationIndex];
if (variation.get_Visual()) { if (variation.get_Visual()) {
var url = variation.get_Url();
if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(url))
url = ((plugin.get_BaseUrl().length == 0) ? this.panelPlugins.pluginsPath : plugin.get_BaseUrl()) + url;
if (variation.get_InsideMode()) { if (variation.get_InsideMode()) {
this.panelPlugins.openInsideMode(plugin.get_Name(), ((plugin.get_BaseUrl().length == 0) ? this.panelPlugins.pluginsPath : plugin.get_BaseUrl()) + variation.get_Url()); this.panelPlugins.openInsideMode(plugin.get_Name(), url);
} else { } else {
var me = this, var me = this,
arrBtns = variation.get_Buttons(), arrBtns = variation.get_Buttons(),
@ -234,12 +238,11 @@ define([
}); });
} }
var _baseUrl = (plugin.get_BaseUrl().length == 0) ? me.panelPlugins.pluginsPath : plugin.get_BaseUrl();
me.pluginDlg = new Common.Views.PluginDlg({ me.pluginDlg = new Common.Views.PluginDlg({
title: plugin.get_Name(), title: plugin.get_Name(),
width: size[0], // inner width width: size[0], // inner width
height: size[1], // inner height height: size[1], // inner height
url: _baseUrl + variation.get_Url(), url: url,
buttons: newBtns, buttons: newBtns,
toolcallback: _.bind(this.onToolClose, this) toolcallback: _.bind(this.onToolClose, this)
}); });

View file

@ -65,7 +65,8 @@ define([
isUpdateOleOnResize: false, isUpdateOleOnResize: false,
buttons: [], buttons: [],
size: [800, 600], size: [800, 600],
initOnSelectionChanged: false initOnSelectionChanged: false,
isRelativeUrl: true
} }
} }
}); });

View file

@ -92,7 +92,7 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
itemTemplate: _.template([ itemTemplate: _.template([
'<div id="<%= id %>" class="item-plugins" style="display: block;">', '<div id="<%= id %>" class="item-plugins" style="display: block;">',
'<div class="plugin-icon" style="background-image: url(' + '<% if (baseUrl !=="") { %>' + '<%= baseUrl %>' + '<% } else { %>' + this.pluginsPath + '<% } %>' + '<%= variations[currentVariation].get("icons")[(window.devicePixelRatio > 1) ? 1 : 0] %>);"></div>', '<div class="plugin-icon" style="background-image: url(' + '<% if (variations[currentVariation].get("isRelativeUrl")) { if (baseUrl !=="") { %>' + '<%= baseUrl %>' + '<% } else { %>' + this.pluginsPath + '<% } } %>' + '<%= variations[currentVariation].get("icons")[(window.devicePixelRatio > 1) ? 1 : 0] %>);"></div>',
'<% if (variations.length>1) { %>', '<% if (variations.length>1) { %>',
'<div class="plugin-caret img-commonctrl"></div>', '<div class="plugin-caret img-commonctrl"></div>',
'<% } %>', '<% } %>',

View file

@ -1806,7 +1806,8 @@ define([
isUpdateOleOnResize : itemVar.isUpdateOleOnResize, isUpdateOleOnResize : itemVar.isUpdateOleOnResize,
buttons: itemVar.buttons, buttons: itemVar.buttons,
size: itemVar.size, size: itemVar.size,
initOnSelectionChanged: itemVar.initOnSelectionChanged initOnSelectionChanged: itemVar.initOnSelectionChanged,
isRelativeUrl: !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url))
})); }));
}); });
if (variationsArr.length>0) if (variationsArr.length>0)

View file

@ -1580,7 +1580,8 @@ define([
isUpdateOleOnResize : itemVar.isUpdateOleOnResize, isUpdateOleOnResize : itemVar.isUpdateOleOnResize,
buttons: itemVar.buttons, buttons: itemVar.buttons,
size: itemVar.size, size: itemVar.size,
initOnSelectionChanged: itemVar.initOnSelectionChanged initOnSelectionChanged: itemVar.initOnSelectionChanged,
isRelativeUrl: !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url))
})); }));
}); });
if (variationsArr.length>0) if (variationsArr.length>0)

View file

@ -1809,7 +1809,8 @@ define([
isUpdateOleOnResize : itemVar.isUpdateOleOnResize, isUpdateOleOnResize : itemVar.isUpdateOleOnResize,
buttons: itemVar.buttons, buttons: itemVar.buttons,
size: itemVar.size, size: itemVar.size,
initOnSelectionChanged: itemVar.initOnSelectionChanged initOnSelectionChanged: itemVar.initOnSelectionChanged,
isRelativeUrl: !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url))
})); }));
}); });
if (variationsArr.length>0) if (variationsArr.length>0)