working requirejs example page for MKWS
authorWolfram Schneider <wosch@indexdata.dk>
Mon, 11 Aug 2014 14:54:01 +0000 (14:54 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Mon, 11 Aug 2014 14:54:01 +0000 (14:54 +0000)
examples/htdocs/mkws-widget-ru-requirejs.html

index acbeca8..dfbcd54 100644 (file)
@@ -2,11 +2,29 @@
 <head>
   <title>MKWS Reference Universe</title>
   <link rel="stylesheet" type="text/css" href="mkws-widget-ru.css" />
-  <script src="//mkws.indexdata.com/mkws-complete.js" type="text/javascript"></script>
-  <script src="mkws-widget-ru.js" type="text/javascript"></script>
 </head>
 
 <body>
+  <script src="http://requirejs.org/docs/release/2.1.14/minified/require.js" type="text/javascript"></script>
+  <script type="text/javascript">
+  require.config({
+    paths: {
+        mkws           : "//mkws-dev.indexdata.com/tools/htdocs/mkws-complete",
+        mkws_widget_ru : "mkws-widget-ru"
+    },
+    shim : {
+        mkws : {
+          exports : "mkws"
+        },
+        mkws_widget_ru : {
+          deps    : [ "mkws" ]
+        }
+    }
+  });
+
+  require(['mkws_widget_ru'], function() { mkws.init_widgets("requirejs is done"); } );
+  </script>
+
   <div style="max-width: 18em; margin: 1.5em 1.5em">
     <div class="mkwsReferenceUniverse" autosearch="sushi"></div>
   </div>