Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function ($) {
- 'use strict';
- var newComponent = function (options) {
- };
- newComponent.prototype.bindAdditionalEvents = function () {
- var self = this;
- self.$container.find('#copy_element').on('click', function (e) {
- e.preventDefault();
- var thisButton = $(this);
- var $resultContainer = $('.js-errors');
- var $chooseCopyToSale = $('#copy_sales_id');
- if (typeof $chooseCopyToSale.val() === 'undefined' || $chooseCopyToSale.val() === '') {
- alert('Вам необходимо выбрать VDS для копирования');
- return;
- }
- thisButton.prop('disabled', true);
- thisButton.addClass('ui-btn-disabled');
- $resultContainer.html('');
- $.ajax({
- url: '/local/components/gt/hl.form/templates/sales/ajax_copy_element.php',
- type: 'post',
- data: {'copy_to_sales_id': $chooseCopyToSale.val(), 'current_sales_id': $chooseCopyToSale.data('id')},
- dataType: 'json',
- success: function (data) {
- if (data['RESULT']) {
- var href = $chooseCopyToSale.data('href').replace('#ID#', $chooseCopyToSale.val());
- $resultContainer.html('Элемент успешно скопирован!<br><a target="_blank" href="' + href + '">Перейти к скопированному элементу</a>');
- } else {
- $resultContainer.html('Что то пошло не так');
- }
- }
- }).always(function () {
- thisButton.prop('disabled', false);
- thisButton.removeClass('ui-btn-disabled');
- });
- });
- };
- newComponent.prototype.isContinueSubmit = function ($currentButton) {
- if ($currentButton.attr('name') === 'DELETE') {
- if (!confirm('Вы уверены в удалении ресурса?')) {
- return false;
- }
- } else { //MODIFIED ZONE //TODO
- var $price = $('#PRICE');
- var $paymentFeature = $('#PAY_FEATURE_ID');
- if (
- (typeof $price.val() === "undefined" || parseInt($price.val()) === 0 || isNaN(parseInt($price.val()))) &&
- (typeof $paymentFeature.val() === "undefined" || parseInt($paymentFeature.val()) === 0 || isNaN(parseInt($paymentFeature.val())))
- ) {
- alert("Вы должны выбрать особенность оплаты, либо указать цену");
- return false;
- }
- var $includedInSale = $('#INCLUDED_IN_SALE');
- const $paymentFeatureIncludedInId = 3;
- if (parseInt($paymentFeature.val()) === $paymentFeatureIncludedInId) {
- if (typeof $includedInSale.val() === "undefined" || isNaN(parseInt($includedInSale.val())) || parseInt($includedInSale.val()) === 0) {
- alert('После выбора "Включено в стоимость", вы должны выбрать продажу');
- return false;
- } else {
- $price.val(0);
- }
- }
- }
- return true;
- };
- $(function () {
- $.gtSalesFormComponent = {
- extend: function (oldComponent, newOptions) {
- newComponent = function (options) {
- oldComponent.apply(this, arguments);
- };
- newComponent.prototype = Object.create(oldComponent.prototype);
- newComponent.prototype.constructor = newComponent;
- return new newComponent(newOptions);
- },
- };
- });
- })(jQuery);
- (function ($) {
- 'use strict';
- var Component = function (options) {
- var defaults = {};
- if (typeof options !== 'object') {
- options = {};
- }
- this.opts = $.extend({}, defaults, options);
- this.bindEvents();
- this.initPlugins();
- };
- Component.prototype.bindAdditionalEvents = function () {
- };
- Component.prototype.bindEvents = function () {
- var self = this;
- self.bindAdditionalEvents();
- };
- Component.prototype.isContinueSubmit = function ($currentButton) {
- };
- $(function () {
- $.gtFormComponent = {
- init: function (options) {
- return new Component(options);
- },
- getComponent: function () {
- return Component;
- }
- };
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement