Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JS] Split JS Helpers into several regions of usability #829

Merged
merged 1 commit into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[JS] Split JS Helpers into several regions of usability
  • Loading branch information
dpfaffenbauer committed Feb 21, 2019
commit 7a16a48dbd36d6c2237008dec849e7487961b5f9
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*
*/
//pimcore.helpers.openElement = function (id, type, subtype) {

pimcore.registerNS('coreshop.helpers.x');
pimcore.registerNS('coreshop.util.format.currency');

coreshop.helpers.long2ip = function (ip) {
if (!isFinite(ip)) {
return false
}

return [ip >>> 24, ip >>> 16 & 0xFF, ip >>> 8 & 0xFF, ip & 0xFF].join('.')
};

coreshop.helpers.createOrder = function () {
pimcore.helpers.itemselector(
Expand All @@ -40,10 +28,6 @@ coreshop.helpers.createOrder = function () {
);
};

coreshop.helpers.openProductByArticleNumber = function (articleNumber) {

};

coreshop.util.format.currency = function (currency, v) {
v = (Math.round(((v / 100) - 0) * 100)) / 100;
v = (v == Math.floor(v)) ? v + '.00' : ((v * 10 == Math.floor(v * 10)) ? v + '0' : v);
Expand Down Expand Up @@ -85,71 +69,3 @@ coreshop.helpers.showAbout = function () {

win.show();
};

coreshop.helpers.constrastColor = function (color) {
return (parseInt(color.replace('#', ''), 16) > 0xffffff / 2) ? 'black' : 'white';
};

coreshop.helpers.hexToRgb = function (hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? [
parseInt(result[1], 16),
parseInt(result[2], 16),
parseInt(result[3], 16)
] : null;
};

coreshop.helpers.openMessagingThread = function (id) {
var panelKey = 'coreshop_messaging_thread_' + id;

if (pimcore.globalmanager.exists(panelKey) == false) {

pimcore.globalmanager.add(panelKey, true);

Ext.Ajax.request({
url: '/admin/coreshop/messaging-thread/get',
params: {
id: id
},
success: function (response) {
var res = Ext.decode(response.responseText);

if (res.success) {
pimcore.globalmanager.add(panelKey, new pimcore.plugin.coreshop.messaging.thread.item(null, res.data, panelKey, panelKey, 'thread'));
} else {
Ext.Msg.alert(t('open_target'), t('problem_opening_new_target'));
}
}.bind(this)
});
} else {
var tab = pimcore.globalmanager.get('coreshop_messaging_thread_' + id);

if (Ext.isObject(tab) && Ext.isFunction(tab.activate)) {
tab.activate();
}
}
};

coreshop.helpers.requestNicePathData = function (targets, responseHandler) {
var elementData = Ext.encode(targets);

Ext.Ajax.request({
method: 'POST',
url: "/admin/coreshop/helper/get-nice-path",
params: {
targets: elementData
},
success: function (response) {
try {
var rdata = Ext.decode(response.responseText);
if (rdata.success) {

var responseData = rdata.data;
responseHandler(responseData);
}
} catch (e) {
console.log(e);
}
}.bind(this)
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ core_shop_pimcore:
pimcore_admin:
js:
broker: '/bundles/coreshoppimcore/pimcore/js/broker.js'
helpers: '/bundles/coreshoppimcore/pimcore/js/helpers.js'
clear_button: '/bundles/coreshoppimcore/pimcore/js/ext/ClearButton.js'
core_extension_tag_serializedData: '/bundles/coreshoppimcore/pimcore/js/coreExtension/tags/coreShopSerializedData.js'
core_extension_data_serializedData: '/bundles/coreshoppimcore/pimcore/js/coreExtension/data/coreShopSerializedData.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) 2015-2019 Dominik Pfaffenbauer (https://www.pfaffenbauer.at)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*
*/
//pimcore.helpers.openElement = function (id, type, subtype) {

pimcore.registerNS('coreshop.helpers.x');
pimcore.registerNS('coreshop.util.format.currency');

coreshop.helpers.long2ip = function (ip) {
if (!isFinite(ip)) {
return false
}

return [ip >>> 24, ip >>> 16 & 0xFF, ip >>> 8 & 0xFF, ip & 0xFF].join('.')
};

coreshop.helpers.constrastColor = function (color) {
return (parseInt(color.replace('#', ''), 16) > 0xffffff / 2) ? 'black' : 'white';
};

coreshop.helpers.hexToRgb = function (hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? [
parseInt(result[1], 16),
parseInt(result[2], 16),
parseInt(result[3], 16)
] : null;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ core_shop_resource:
js:
global: '/bundles/coreshopresource/pimcore/js/global.js'
plugin: '/bundles/coreshopresource/pimcore/js/plugin.js'
helpers: '/bundles/coreshopresource/pimcore/js/helpers.js'
event_manager: '/bundles/coreshopresource/pimcore/js/eventManager.js'
resource: '/bundles/coreshopresource/pimcore/js/resource.js'
resource_panel: '/bundles/coreshopresource/pimcore/js/resource/panel.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) 2015-2019 Dominik Pfaffenbauer (https://www.pfaffenbauer.at)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*
*/

coreshop.helpers.requestNicePathData = function (targets, responseHandler) {
var elementData = Ext.encode(targets);

Ext.Ajax.request({
method: 'POST',
url: "/admin/coreshop/helper/get-nice-path",
params: {
targets: elementData
},
success: function (response) {
try {
var rdata = Ext.decode(response.responseText);
if (rdata.success) {

var responseData = rdata.data;
responseHandler(responseData);
}
} catch (e) {
console.log(e);
}
}.bind(this)
});
};