1
1
'use strict' ;
2
2
/*
3
- * VERY FIRST DEFINES AND LEGACY
3
+ * VERY FIRST DEFINES AND POLYFILLS
4
4
*/
5
5
6
+ if ( typeof document !== "undefined" && ! document . currentScript ) {
7
+ document . currentScript = ( function ( ) {
8
+ var scripts = document . getElementsByTagName ( 'script' ) ;
9
+ return scripts [ scripts . length - 1 ] ;
10
+ } ) ( ) ;
11
+ }
12
+
6
13
var __global = typeof window === 'object' ? window : global ;
7
14
8
15
var hwc_conf = { paths : { } } ;
9
16
10
- hwc_conf . path_core = __global . hwc_path ? __global . hwc_path : "modules/hw-code" ;
17
+ function retrieveCorePath ( ) {
18
+ // TODO: implement without hacks
19
+ // for now set hwc_path global variable
20
+ var hwc_path = document . currentScript . getAttribute ( 'data-hwc-path' ) ;
21
+ return hwc_path ? hwc_path : "module/hw-core"
22
+ }
23
+
24
+ hwc_conf . path_core = __global . hwc_path ? __global . hwc_path : retrieveCorePath ( ) ;
11
25
12
26
hwc_conf . paths . hwc_js_kernel = hwc_conf . path_core + "js-kernel/index" ;
13
27
hwc_conf . paths . hwc_js_modules_path = hwc_conf . path_core + "js-modules/" ;
@@ -17,14 +31,8 @@ hwc_conf.paths.hwc_js_modules_jquery = hwc_conf.paths.hwc_js_modules_path + "jqu
17
31
hwc_conf . paths . hwc_js_modules_requirenode = hwc_conf . paths . hwc_js_modules_path + "requirejs/r/index" ;
18
32
hwc_conf . paths . hwc_js_modules_requirejs = hwc_conf . paths . hwc_js_modules_path + "requirejs/requirejs/index" ;
19
33
20
-
21
34
__global . hwc_conf = hwc_conf ;
22
35
23
-
24
- //if (typeof __webpack_require__ === "function") {
25
- // require("../js-modules/requirejs/requirejs/require.js");
26
- //}
27
-
28
36
// ONLY FOR IE8-
29
37
if ( ! Array . prototype . indexOf ) {
30
38
Array . prototype . indexOf = function ( what , i ) {
@@ -403,16 +411,12 @@ if (!Function.prototype.bind) {
403
411
_loadSync ( hwc_conf . paths . hwc_js_modules_requirejs + '.js' ) ;
404
412
}
405
413
406
- hwc . __requirejs = requirejs ;
407
-
408
- hwc . __requirejs . config ( {
414
+ requirejs . config ( {
409
415
paths : hwc_conf . paths
410
416
} ) ;
411
417
} ;
412
418
413
419
pub . initNode = function ( ) {
414
- hwc . __requirejs = global . requirejs ;
415
-
416
420
setGlobals ( global , true ) ;
417
421
}
418
422
@@ -427,12 +431,17 @@ if (!Function.prototype.bind) {
427
431
428
432
hwc . Core = HWCore ;
429
433
434
+ // some aliases for requirejs
430
435
if ( this . defines . IN_BROWSER ) {
431
436
this . initBrowser ( ) ;
432
437
} else {
433
438
this . initNode ( ) ;
434
439
}
435
440
441
+ hwc . require = hwc . include = hwc . module = hwc . __requirejs = requirejs ;
442
+
443
+ hwc . define = define ;
444
+
436
445
HWCore . const = hwc . const = this . defines ;
437
446
438
447
hwc . __core = hwc . Core . I ( callback ) ;
@@ -445,7 +454,7 @@ if (!Function.prototype.bind) {
445
454
446
455
function _loadSync ( url ) {
447
456
// get some kind of XMLHttpRequest
448
- var xhrObj = createXMLHTTPObject ( ) ;
457
+ var xhrObj = new XMLHttpRequest ( ) ;
449
458
// open and send a synchronous request
450
459
xhrObj . open ( 'GET' , url , false ) ;
451
460
xhrObj . send ( '' ) ;
@@ -535,7 +544,7 @@ if (!Function.prototype.bind) {
535
544
536
545
} ) ( ) ;
537
546
538
- define ( [ "hwc_js_modules_rsvp" ] , function ( RSVP ) {
547
+ define ( "hwc_js_kernel" , [ "hwc_js_modules_rsvp" ] , function ( RSVP ) {
539
548
hwc . __core . loading = false ;
540
549
hwc . __defineLoader ( hwc , RSVP ) ;
541
550
0 commit comments