helpers.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. define("amber/helpers", ["amber_vm/smalltalk", "amber_vm/globals", "require"], function (vm, globals, require) {
  2. var exports = Object.create(globals);
  3. // API
  4. exports.popupHelios = function () {
  5. window.open(require.toUrl('amber_helios/html/helios.html'), "Helios", "menubar=no, status=no, scrollbars=no, menubar=no, width=1000, height=600");
  6. };
  7. Object.defineProperty(exports, "vm", {
  8. value: vm,
  9. enumerable: true, configurable: true, writable: false
  10. });
  11. Object.defineProperty(exports, "globals", {
  12. value: globals,
  13. enumerable: true, configurable: true, writable: false
  14. });
  15. exports.initialize = function (options) {
  16. var settings = globals.SmalltalkSettings || {};
  17. settings['vm.defaultAmdNamespace'] = vm.defaultAmdNamespace;
  18. // TODO load saved contents from localStorage
  19. if (exports.defaultAmdNamespace) {
  20. console.warn("`smalltalk.defaultAmdNamespace = 'namespace';` is deprecated. Please use `smalltalk.initialize({'vm.defaultAmdNamespace': 'namespace'});` instead.");
  21. settings['vm.defaultAmdNamespace'] = settings['vm.defaultAmdNamespace'] || exports.defaultAmdNamespace;
  22. }
  23. Object.keys(options).forEach(function (key) {
  24. settings[key] = options[key];
  25. });
  26. console.warn("smalltalk.ClassName is deprecated. Please use smalltalk.globals.ClassName instead.");
  27. globals.SmalltalkSettings = settings;
  28. return vm.initialize();
  29. };
  30. // Backward compatibility, deprecated
  31. Object.defineProperty(exports, "smalltalk", {
  32. value: vm,
  33. enumerable: true, configurable: true, writable: false
  34. });
  35. exports.defaultAmdNamespace = null;
  36. // Exports
  37. return exports;
  38. });