form_offer.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup Ads Ads
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. function BxAdsFormOffer(oOptions) {
  11. this._sActionsUri = oOptions.sActionUri;
  12. this._sActionsUrl = oOptions.sActionUrl;
  13. this._sObjName = oOptions.sObjName == undefined ? 'BxAdsFormOffer' : oOptions.sObjName;
  14. this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'slide' : oOptions.sAnimationEffect;
  15. this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
  16. this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
  17. this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams;
  18. }
  19. BxAdsFormOffer.prototype.updateTotal = function(oSource, sAmountId, sQuantityId, sTotalId) {
  20. var oForm = jQuery(oSource).parents('.bx-form-advanced:first');
  21. var oAmount = oForm.find("[name='" + sAmountId + "']");
  22. var fAmount = parseFloat(oAmount.val());
  23. if(!fAmount)
  24. fAmount = 0;
  25. var oQuantity = oForm.find("[name='" + sQuantityId + "']");
  26. var iQuantity = parseInt(oQuantity.val());
  27. if(!iQuantity)
  28. iQuantity = 0;
  29. oForm.find("[name='" + sTotalId + "']").val(fAmount * iQuantity);
  30. };
  31. BxAdsFormOffer.prototype.loadingInBlock = function(e, bShow) {
  32. var oParent = $(e).length ? $(e).parents('.bx-db-container:first') : $('body');
  33. bx_loading(oParent, bShow);
  34. };
  35. BxAdsFormOffer.prototype._getDefaultData = function() {
  36. var oDate = new Date();
  37. return jQuery.extend({}, this._oRequestParams, {_t:oDate.getTime()});
  38. };
  39. /** @} */