polyglot.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup UnaStudio UNA Studio
  6. * @{
  7. */
  8. function BxDolStudioPolyglot(oOptions) {
  9. this.sActionsUrl = oOptions.sActionUrl;
  10. this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioPolyglot' : oOptions.sObjName;
  11. this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
  12. this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
  13. this.sCodeMirror = oOptions.sCodeMirror == undefined ? '' : oOptions.sCodeMirror;
  14. this.sPage = oOptions.sPage == undefined ? 'general' : oOptions.sPage;
  15. }
  16. BxDolStudioPolyglot.prototype.enableEditor = function(oSource) {
  17. var oDate = new Date();
  18. $.post(
  19. this.sActionsUrl, {
  20. pgt_action: 'enable-editor',
  21. pgt_value: $(oSource).prop('checked') ? 1 : 0,
  22. _t:oDate.getTime()
  23. },
  24. function(oData) {
  25. processJsonData(oData);
  26. },
  27. 'json'
  28. );
  29. return true;
  30. };
  31. /**
  32. * Is needed if AJAX is used to change (reload) pages.
  33. */
  34. BxDolStudioPolyglot.prototype.changePage = function(sType, iStart, iLength) {
  35. var oDate = new Date();
  36. var $this = this;
  37. var oParams = {
  38. pgt_action: 'get-page-by-type',
  39. pgt_value: sType,
  40. _t:oDate.getTime()
  41. };
  42. if(sType == 'keys') {
  43. oParams.pgt_category = $('#pgt-keys-category').val();
  44. oParams.pgt_language = $('#pgt-keys-language').val();
  45. oParams.pgt_keyword = $('#pgt-keys-keyword').val();
  46. if(iStart)
  47. oParams.pgt_start = iStart;
  48. if(iLength)
  49. oParams.pgt_length = iLength;
  50. }
  51. $.get(
  52. this.sActionsUrl,
  53. oParams,
  54. function(oData) {
  55. if(oData.code != 0) {
  56. bx_alert(oData.message);
  57. return true;
  58. }
  59. $('#bx-std-pc-menu > .bx-std-pmi-active').removeClass('bx-std-pmi-active');
  60. $('#bx-std-pmi-' + sType).addClass('bx-std-pmi-active');
  61. $('#bx-std-pc-content').bx_anim('hide', $this.sAnimationEffect, $this.iAnimationSpeed, function() {
  62. $(this).html(oData.content).bx_anim('show', $this.sAnimationEffect, $this.iAnimationSpeed);
  63. });
  64. },
  65. 'json'
  66. );
  67. return true;
  68. };
  69. /** @} */