1
0

amber.js 2.6 KB

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