design.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 BxDolStudioDesign(oOptions) {
  9. BxDolStudioModule.call(this, oOptions);
  10. this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioDesign' : oOptions.sObjName;
  11. this.sCodeMirror = oOptions.sCodeMirror == undefined ? '' : oOptions.sCodeMirror;
  12. var $this = this;
  13. $(document).ready (function () {
  14. if($this.sCodeMirror != '')
  15. $this.initCodeMirror($this.sCodeMirror);
  16. });
  17. if($this.sCodeMirror != '')
  18. $('#adm-settings-form-categorized .bx-form-collapsable').on('bx_show', function() {
  19. $this.refreshCodeMirror();
  20. });
  21. }
  22. BxDolStudioDesign.prototype = Object.create(BxDolStudioModule.prototype);
  23. BxDolStudioDesign.prototype.constructor = BxDolStudioDesign;
  24. BxDolStudioDesign.prototype.initCodeMirror = function(sSelector) {
  25. var oSelector = $(sSelector);
  26. for(var i = 0; i < oSelector.length; i++) {
  27. var e = CodeMirror.fromTextArea(oSelector.get(i), {
  28. lineNumbers: true,
  29. mode: "htmlmixed",
  30. htmlMode: true,
  31. matchBrackets: true
  32. });
  33. }
  34. };
  35. BxDolStudioDesign.prototype.refreshCodeMirror = function() {
  36. $('.CodeMirror').each(function() {
  37. this.CodeMirror.refresh();
  38. });
  39. };
  40. /** @} */