amber.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. 'amber_html': home,
  32. 'jquery': home+'/support/jQuery/jquery-1.8.2.min',
  33. 'jquery-ui': home+'/support/jQuery/jquery-ui-1.8.24.custom.min'
  34. },
  35. map: {
  36. '*': {
  37. 'css': 'amber_lib/requirejs/require-css-0.0.6/css'
  38. }
  39. },
  40. shim: {
  41. 'jquery-ui': {
  42. deps: [ 'jquery' ]
  43. },
  44. 'amber_lib/bootstrap/js/bootstrap': {
  45. deps: [ 'css!amber_lib/bootstrap/css/bootstrap' ]
  46. },
  47. 'amber_lib/CodeMirror/codemirror': {
  48. deps: [ 'css!amber_lib/CodeMirror/codemirror' ]
  49. },
  50. 'amber_lib/jQuery/jquery.textarea': {
  51. deps: [ 'jquery', 'jquery-ui' ]
  52. },
  53. 'amber_lib/CodeMirror/smalltalk': {
  54. deps: [ './codemirror' ]
  55. },
  56. 'amber_lib/CodeMirror/addon/hint/show-hint': {
  57. deps: [ '../../codemirror' ]
  58. },
  59. 'ensure-console': {
  60. exports: 'console'
  61. }
  62. }
  63. };
  64. // This is to allow both alternatives of loading:
  65. // before require.js as well as after require.js
  66. // See http://requirejs.org/docs/api.html#config for details
  67. // of usage of 'require' global to allow to pre-define configuration
  68. // before require.js is loaded.
  69. if (require) {
  70. require.config(config);
  71. return require;
  72. } else {
  73. return config;
  74. }
  75. }(require);