amber.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Amber package loading.
  2. Load this script as well as require.js (works in any order;
  3. either defines 'require', thus passing config, if loaded prior require.js;
  4. or calls require.config, if loaded post require.js).
  5. Usage example:
  6. require(['amber/devel'], function(smalltalk) {
  7. smallralk.initialize();
  8. smalltalk.Browser._open();
  9. });
  10. For detailed explanation of amber loading, see:
  11. https://github.com/amber-smalltalk/amber/wiki/How-to-load-amber
  12. */
  13. var require;
  14. require = function (require) {
  15. var scripts = document.getElementsByTagName("script");
  16. var src = scripts[ scripts.length - 1 ].src;
  17. var home = resolveViaDOM(src).replace(/\/[^\/]+\/[^\/]+$/, "");
  18. function resolveViaDOM(url) {
  19. var a = document.createElement("a");
  20. a.href = url;
  21. return a.href;
  22. }
  23. var config = {
  24. paths: {
  25. 'amber': home+'/support',
  26. 'amber_vm': home+'/support',
  27. 'amber_css': home+'/css',
  28. 'amber_lib': home+'/support',
  29. 'amber_core': home+'/js',
  30. 'amber_core/_source': home+'/st',
  31. 'jquery': home+'/support/jQuery/jquery-1.8.2.min',
  32. 'jquery-ui': home+'/support/jQuery/jquery-ui-1.8.16.custom.min'
  33. },
  34. map: {
  35. '*': {
  36. 'css': 'amber_lib/requirejs/require-css-0.0.6/css'
  37. },
  38. 'amber/helios': {
  39. 'jquery-ui': 'amber_lib/jQuery/jquery-ui-1.8.24.custom.min'
  40. }
  41. },
  42. shim: {
  43. 'jquery-ui': {
  44. deps: [ 'jquery' ]
  45. },
  46. 'amber_lib/bootstrap/js/bootstrap': {
  47. deps: [ 'css!amber_lib/bootstrap/css/bootstrap' ]
  48. },
  49. 'amber_lib/CodeMirror/codemirror': {
  50. deps: [ 'css!amber_lib/CodeMirror/codemirror' ]
  51. },
  52. 'amber_lib/jQuery/jquery.textarea': {
  53. deps: [ 'jquery', 'jquery-ui' ]
  54. },
  55. 'amber_lib/CodeMirror/smalltalk': {
  56. deps: [ './codemirror' ]
  57. },
  58. 'amber_lib/CodeMirror/addon/hint/show-hint': {
  59. deps: [ '../../codemirror' ]
  60. },
  61. 'ensure-console': {
  62. exports: 'console'
  63. }
  64. }
  65. };
  66. // This is to allow both alternatives of loading:
  67. // before require.js as well as after require.js
  68. // See http://requirejs.org/docs/api.html#config for details
  69. // of usage of 'require' global to allow to pre-define configuration
  70. // before require.js is loaded.
  71. if (require) {
  72. require.config(config);
  73. return require;
  74. } else {
  75. return config;
  76. }
  77. }(require);