- md5
- 15c3422933ef75c14392398851de15ca
- sha1
- 64d00261dfc77a3fa39a7b042cc0469a7c640f82
- sha256
- b7e8f8574a90b73c233ec49c665eb9db56a3139a38ad99ddc8d7c3540e5c1a62
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
if (!window.jQuery) {
throw new Error('WebInstaller plugin requires jQuery');
}
if (!Joomla) {
throw new Error('Joomla API is not properly initialised');
}
(function (window, document, Joomla, jQuery) {
'use strict';
var webInstallerOptions = {
view: 'dashboard',
id: 0,
ordering: '',
list: 0,
options: Joomla.getOptions('plg_installer_webinstaller', {})
};
var instance = void 0;
var WebInstaller = function () {
function WebInstaller() {
_classCallCheck(this, WebInstaller);
}
_createClass(WebInstaller, [{
key: 'initialise',
value: function initialise() {
webInstallerOptions.loaded = 1;
if (document.getElementById('myTabContent')) {
var webTab = document.getElementById('web');
var cancelButton = document.getElementById('uploadform-web-cancel');
cancelButton.addEventListener('click', function () {
document.getElementById('uploadform-web').classList.add('hidden');
// jQuery('#jed-container').slideDown(300);
if (webInstallerOptions.list && document.querySelector('.list-view')) {
document.querySelector('.list-view').click();
}
});
webTab.insertAdjacentHTML('afterbegin', '<div id="appsloading" class="ifw-loading-container"></div>');
webTab.style.position = 'absolute';
jQuery('#appsloading').on('ajaxStart', function () {
document.body.classList.add('ifw-busy');
document.getElementById('appsloading').classList.remove('hidden');
}).on('ajaxStop', function () {
document.getElementById('appsloading').classList.add('hidden');
document.body.classList.remove('ifw-busy');
});
}
this.loadweb(webInstallerOptions.options.base_url + 'index.php?format=json&option=com_apps&view=dashboard');
this.clickforlinks();
}
}, {
key: 'loadweb',
value: function loadweb(url) {
var _this = this;
if (!url) {
return false;
}
var pattern1 = new RegExp(webInstallerOptions.options.base_url);
var pattern2 = new RegExp('^index.php');
if (!(pattern1.test(url) || pattern2.test(url))) {
window.open(url, '_blank');
return false;
}
var requestUrl = url + '&product=' + webInstallerOptions.options.product + '&release=' + webInstallerOptions.options.release + '&dev_level=' + webInstallerOptions.options.dev_level + '&list=' + (webInstallerOptions.list ? 'list' : 'grid') + '&lang=' + webInstallerOptions.options.language;
if (webInstallerOptions.ordering !== '' && document.getElementById('com-apps-ordering').value) {
webInstallerOptions.ordering = document.getElementById('com-apps-ordering').value;
requestUrl += '&ordering=' + webInstallerOptions.ordering;
}
// jQuery('html, body').animate({ scrollTop: 0 }, 0);
if (document.getElementById('myTabContent')) {
var element = document.getElementById('appsloading');
element.style.position = 'absolute';
element.style.left = '0';
element.style.top = '0';
element.style.width = '100%';
element.style.height = '100%';
var web = document.getElementById('web');
web.style.position = 'relative';
web.appendChild(element);
jQuery('#appsloading').trigger('ajaxStart');
}
// @todo convert to vanilla, (why JSONP?)
jQuery.ajax({
url: requestUrl,
dataType: 'jsonp',
cache: true,
jsonpCallback: 'jedapps_jsonpcallback',
timeout: 20000,
success: function success(response) {
if (document.getElementById('web-loader')) {
document.getElementById('web-loader').classList.add('hidden');
}
var jedContainer = document.getElementById('jed-container');
jedContainer.innerHTML = response.data.html;
document.getElementById('com-apps-searchbox').addEventListener('keypress', function (event) {
if (event.which === 13) {
_this.initiateSearch();
}
});
document.getElementById('search-extensions').addEventListener('click', function () {
_this.initiateSearch();
});
document.getElementById('search-reset').addEventListener('click', function () {
var searchBox = document.getElementById('com-apps-searchbox');
searchBox.value = '';
_this.initiateSearch();
});
var orderingSelect = document.getElementById('com-apps-ordering');
if (orderingSelect) {
orderingSelect.addEventListener('change', function () {
var index = orderingSelect.selectedIndex;
webInstallerOptions.ordering = orderingSelect.options[index].value;
_this.installfromwebajaxsubmit();
});
}
if (webInstallerOptions.options.installfrom_url !== '') {
WebInstaller.installfromweb(webInstallerOptions.options.installfrom_url);
}
},
fail: function fail() {
if (document.getElementById('web-loader')) {
document.getElementById('web-loader').classList.add('hidden');
document.getElementById('web-loader-error').classList.remove('hidden');
}
},
complete: function complete() {
var installAtField = document.getElementById('joomlaapsinstallatinput');
if (installAtField) {
installAtField.value = webInstallerOptions.options.installat_url;
}
_this.clickforlinks();
WebInstaller.clicker();
if (webInstallerOptions.view !== 'extension') {
[].slice.call(document.querySelectorAll('div.load-extension')).forEach(function (element) {
element.addEventListener('click', function (event) {
event.preventDefault();
_this.processLinkClick(element.getAttribute('data-url'));
});
element.setAttribute('href', '#');
});
}
if (webInstallerOptions.view === 'extension') {
var installExtensionButton = document.getElementById('install-extension');
var installExtensionFromExternalButton = document.getElementById('install-extension-from-external');
if (installExtensionButton) {
installExtensionButton.addEventListener('click', function () {
WebInstaller.installfromweb(installExtensionButton.getAttribute('data-downloadurl'), installExtensionButton.getAttribute('data-name'));
});
}
if (installExtensionFromExternalButton) {
// @todo Migrate this handler's confirm to a CE dialog
installExtensionFromExternalButton.addEventListener('click', function () {
var redirectUrl = installExtensionFromExternalButton.getAttribute('data-downloadurl');
var redirectConfirm = window.confirm(Joomla.JText._('PLG_INSTALLER_WEBINSTALLER_REDIRECT_TO_EXTERNAL_SITE_TO_INSTALL').replace('[SITEURL]', redirectUrl));
if (redirectConfirm !== true) {
return;
}
document.getElementById('adminForm').setAttribute('action', redirectUrl);
document.querySelector('input[name=task]').setAttribute('disabled', true);
document.querySelector('input[name=install_directory]').setAttribute('disabled', true);
document.querySelector('input[name=install_url]').setAttribute('disabled', true);
document.querySelector('input[name=installtype]').setAttribute('disabled', true);
document.querySelector('input[name=filter_search]').setAttribute('disabled', true);
document.getElementById('adminForm').submit();
});
}
}
if (webInstallerOptions.list && document.querySelector('.list-view')) {
document.querySelector('.list-view').click();
}
if (document.getElementById('myTabContent')) {
jQuery('#appsloading').trigger('ajaxStop');
}
},
error: function error(request) {
var errorContainer = document.getElementById('web-loader-error');
var loaderContainer = document.getElementById('web-loader');
if (request.responseText && errorContainer) {
errorContainer.innerHTML = request.responseText;
}
if (loaderContainer) {
loaderContainer.classList.add('hidden');
errorContainer.classList.remove('hidden');
}
}
});
return true;
}
}, {
key: 'clickforlinks',
value: function clickforlinks() {
var _this2 = this;
[].slice.call(document.querySelectorAll('a.transcode')).forEach(function (element) {
var ajaxurl = element.getAttribute('href');
element.addEventListener('click', function (event) {
event.preventDefault();
_this2.processLinkClick(ajaxurl);
});
element.setAttribute('href', '#');
});
}
}, {
key: 'initiateSearch',
value: function initiateSearch() {
webInstallerOptions.view = 'dashboard';
this.installfromwebajaxsubmit();
}
}, {
key: 'installfromwebajaxsubmit',
value: function installfromwebajaxsubmit() {
var tail = '&view=' + webInstallerOptions.view;
if (webInstallerOptions.id) {
tail += '&id=' + webInstallerOptions.id;
}
if (document.getElementById('com-apps-searchbox').value) {
var value = encodeURI(document.getElementById('com-apps-searchbox').value.toLowerCase().replace(/ +/g, '_').replace(/[^a-z0-9-_]/g, '').trim());
tail += '&filter_search=' + value;
}
if (webInstallerOptions.ordering !== '' && document.getElementById('com-apps-ordering').value) {
webInstallerOptions.ordering = document.getElementById('com-apps-ordering').value;
}
if (webInstallerOptions.ordering) {
tail += '&ordering=' + webInstallerOptions.ordering;
}
this.loadweb(webInstallerOptions.options.base_url + 'index.php?format=json&option=com_apps' + tail);
}
}, {
key: 'processLinkClick',
value: function processLinkClick(url) {
var pattern1 = new RegExp(webInstallerOptions.options.base_url);
var pattern2 = new RegExp('^index.php');
if (pattern1.test(url) || pattern2.test(url)) {
webInstallerOptions.view = url.replace(/^.+[&?]view=(\w+).*$/, '$1');
if (webInstallerOptions.view === 'dashboard') {
webInstallerOptions.id = 0;
} else if (webInstallerOptions.view === 'category') {
webInstallerOptions.id = url.replace(/^.+[&?]id=(\d+).*$/, '$1');
}
this.loadweb(webInstallerOptions.options.base_url + url);
} else {
this.loadweb(url);
}
}
}], [{
key: 'clicker',
value: function clicker() {
if (document.querySelector('.grid-view')) {
document.querySelector('.grid-view').addEventListener('click', function () {
webInstallerOptions.list = 0;
document.querySelector('.list-container').classList.add('hidden');
document.querySelector('.grid-container').classList.remove('hidden');
document.getElementById('btn-list-view').classList.remove('active');
document.getElementById('btn-grid-view').classList.remove('active');
});
}
if (document.querySelector('.list-view')) {
document.querySelector('.list-view').addEventListener('click', function () {
webInstallerOptions.list = 1;
document.querySelector('.grid-container').classList.add('hidden');
document.querySelector('.list-container').classList.remove('hidden');
document.getElementById('btn-grid-view').classList.remove('active');
document.getElementById('btn-list-view').classList.add('active');
});
}
}
/**
* @param {string} installUrl
* @param {string} name
* @returns {boolean}
* @todo Migrate this function's alert to a CE dialog
*/
}, {
key: 'installfromweb',
value: function installfromweb(installUrl) {
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (!installUrl) {
alert(Joomla.JText._('PLG_INSTALLER_WEBINSTALLER_CANNOT_INSTALL_EXTENSION_IN_PLUGIN'));
return false;
}
var installUrlField = document.getElementById('install_url');
var uploadUrlContainer = document.getElementById('uploadform-web-url');
installUrlField.value = installUrl;
uploadUrlContainer.innerHTML = installUrl;
if (name) {
var nameElement = document.getElementById('uploadform-web-name');
nameElement.innerHTML = name;
document.getElementById('uploadform-web-name-label').classList.remove('hidden');
} else {
document.getElementById('uploadform-web-name-label').classList.add('hidden');
}
// jQuery('#jed-container').slideUp(300);
document.getElementById('uploadform-web').classList.remove('hidden');
return true;
}
}]);
return WebInstaller;
}();
jQuery(function ($) {
var link = $('#myTabTabs').find('a[href="#web"]');
if (webInstallerOptions.options.installfromon) {
link.click();
}
if (link.hasClass('active')) {
if (!instance) {
instance = new WebInstaller();
instance.initialise();
}
}
link.closest('li').click(function () {
if (!instance) {
instance = new WebInstaller();
instance.initialise();
}
});
if (webInstallerOptions.options.installfrom_url !== '') {
link.closest('li').click();
}
link.on('shown.bs.tab', function () {
if (!instance) {
instance = new WebInstaller();
instance.initialise();
}
});
});
})(window, document, Joomla, window.jQuery);
No other release has this exact content. See every version of this file.