main.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. function BxDevMain(oOptions) {
  2. this._sActionUrl = oOptions.sActionUrl;
  3. this._sObjName = oOptions.sObjName == undefined ? 'oBxDevMain' : oOptions.sObjName;
  4. this._sTxtExportType = oOptions.sTxtExportType == undefined ? '' : oOptions.sTxtExportType;
  5. this._sTxtBasic = oOptions.sTxtBasic == undefined ? '' : oOptions.sTxtBasic;
  6. this._sTxtFull = oOptions.sTxtFull == undefined ? '' : oOptions.sTxtFull;
  7. this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'slide' : oOptions.sAnimationEffect;
  8. this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
  9. }
  10. BxDevMain.prototype.import = function(oButton, sType) {
  11. this.performAction(oButton, 'import', {type: sType});
  12. };
  13. BxDevMain.prototype.onImport = function(oData) {
  14. document.location.href = document.location.href;
  15. };
  16. BxDevMain.prototype.export = function(oButton, sType) {
  17. this.performAction(oButton, 'export', {type: sType});
  18. };
  19. BxDevMain.prototype.onExport = function(oData) {
  20. bx_confirm(this._sTxtExportType, function() {
  21. document.location.href = bx_append_url_params(oData.url, {full: 0});
  22. }, function() {
  23. document.location.href = bx_append_url_params(oData.url, {full: 1});
  24. }, {
  25. yes: {
  26. title: this._sTxtBasic
  27. },
  28. no: {
  29. title: this._sTxtFull
  30. }
  31. });
  32. };
  33. BxDevMain.prototype.performAction = function(oSource, sAction, aParams, bConfirm) {
  34. var $this = this;
  35. var oDate = new Date();
  36. bx_loading(oSource, true);
  37. var oPerform = function() {
  38. $.post(
  39. $this._sActionUrl + sAction,
  40. $.extend({}, aParams, {_t: oDate.getTime()}),
  41. function (oData) {
  42. bx_loading(oSource, false);
  43. processJsonData(oData);
  44. },
  45. 'json'
  46. );
  47. };
  48. if(bConfirm != undefined && parseInt(bConfirm) == 1)
  49. bx_confirm('', oPerform);
  50. else
  51. oPerform();
  52. };