1212
1313"use strict" ;
1414
15-
1615// Static imports
1716// ==============
1817// These imports are (we assume) needed by all pages. However, it would be much better to load these in the modules that actually use them.
@@ -40,6 +39,7 @@ import "./runestone/common/css/runestone-custom-sphinx-bootstrap.css";
4039// Misc
4140import "./runestone/common/js/bookfuncs.js" ;
4241import "./runestone/common/js/user-highlights.js" ;
42+ import "./runestone/common/js/pretext.js" ;
4343
4444// These belong in dynamic imports for the obvious component; however, these components don't include a ``data-component`` attribute.
4545import "./runestone/matrixeq/css/matrixeq.css" ;
@@ -50,7 +50,6 @@ import { getSwitch, switchTheme } from "./runestone/common/js/theme.js";
5050import "./runestone/common/js/presenter_mode.js" ;
5151import "./runestone/common/css/presenter_mode.css" ;
5252
53-
5453// Dynamically loaded components
5554// =============================
5655// This provides a list of modules that components can dynamically import. Webpack will create a list of imports for each based on its analysis.
@@ -61,7 +60,8 @@ const module_map = {
6160 activecode : ( ) => import ( "./runestone/activecode/js/acfactory.js" ) ,
6261 ble : ( ) => import ( "./runestone/cellbotics/js/ble.js" ) ,
6362 // Always import the timed version of a component if available, since the timed components also define the component's factory and include the component as well. Note that ``acfactory`` imports the timed components of ActiveCode, so it follows this pattern.
64- clickablearea : ( ) => import ( "./runestone/clickableArea/js/timedclickable.js" ) ,
63+ clickablearea : ( ) =>
64+ import ( "./runestone/clickableArea/js/timedclickable.js" ) ,
6565 codelens : ( ) => import ( "./runestone/codelens/js/codelens.js" ) ,
6666 datafile : ( ) => import ( "./runestone/datafile/js/datafile.js" ) ,
6767 dragndrop : ( ) => import ( "./runestone/dragndrop/js/timeddnd.js" ) ,
@@ -75,7 +75,8 @@ const module_map = {
7575 quizly : ( ) => import ( "./runestone/quizly/js/quizly.js" ) ,
7676 reveal : ( ) => import ( "./runestone/reveal/js/reveal.js" ) ,
7777 selectquestion : ( ) => import ( "./runestone/selectquestion/js/selectone.js" ) ,
78- shortanswer : ( ) => import ( "./runestone/shortanswer/js/timed_shortanswer.js" ) ,
78+ shortanswer : ( ) =>
79+ import ( "./runestone/shortanswer/js/timed_shortanswer.js" ) ,
7980 showeval : ( ) => import ( "./runestone/showeval/js/showEval.js" ) ,
8081 simple_sensor : ( ) => import ( "./runestone/cellbotics/js/simple_sensor.js" ) ,
8182 spreadsheet : ( ) => import ( "./runestone/spreadsheet/js/spreadsheet.js" ) ,
@@ -85,35 +86,41 @@ const module_map = {
8586 // TODO: since this isn't in a ``data-component``, need to trigger an import of this code manually.
8687 webwork : ( ) => import ( "./runestone/webwork/js/webwork.js" ) ,
8788 youtube : ( ) => import ( "./runestone/video/js/runestonevideo.js" ) ,
88- }
89+ } ;
8990
9091// .. _dynamic import machinery:
9192//
9293// Dynamic import machinery
9394// ========================
9495// Fulfill a promise when the Runestone pre-login complete event occurs.
95- let pre_login_complete_promise = new Promise ( resolve => $ ( document ) . bind ( "runestone:pre-login-complete" , resolve ) ) ;
96+ let pre_login_complete_promise = new Promise ( ( resolve ) =>
97+ $ ( document ) . bind ( "runestone:pre-login-complete" , resolve )
98+ ) ;
9699let loadedComponents ;
97100// Provide a simple function to import the JS for all components on the page.
98101export function runestone_auto_import ( ) {
99102 // Create a set of ``data-component`` values, to avoid duplication.
100103 const s = new Set (
101104 // All Runestone components have a ``data-component`` attribute.
102- $ ( "[data-component]" ) . map (
103- // Extract the value of the data-component attribute.
104- ( index , element ) => $ ( element ) . attr ( "data-component" )
105- // Switch from a jQuery object back to an array, passing that to the Set constructor.
106- ) . get ( )
105+ $ ( "[data-component]" )
106+ . map (
107+ // Extract the value of the data-component attribute.
108+ ( index , element ) => $ ( element ) . attr ( "data-component" )
109+ // Switch from a jQuery object back to an array, passing that to the Set constructor.
110+ )
111+ . get ( )
107112 ) ;
108113
109114 // Load JS for each of the components found.
110- const a = [ ...s ] . map ( value =>
115+ const a = [ ...s ] . map ( ( value ) =>
111116 // If there's no JS for this component, return an empty Promise.
112117 ( module_map [ value ] || ( ( ) => Promise . resolve ( ) ) ) ( )
113118 ) ;
114119
115120 // Send the Runestone login complete event when all JS is loaded and the pre-login is also complete.
116- Promise . all ( [ pre_login_complete_promise , ...a ] ) . then ( ( ) => $ ( document ) . trigger ( "runestone:login-complete" ) ) ;
121+ Promise . all ( [ pre_login_complete_promise , ...a ] ) . then ( ( ) =>
122+ $ ( document ) . trigger ( "runestone:login-complete" )
123+ ) ;
117124}
118125
119126// Load component JS when the document is ready.
@@ -133,9 +140,11 @@ async function popupScratchAC() {
133140 // activecode. If its not defined then we need to get it ready to toggle
134141 if ( ! eBookConfig . scratchDiv ) {
135142 window . ACFactory . createScratchActivecode ( ) ;
136- let divid = eBookConfig . scratchDiv
137- window . edList [ divid ] = ACFactory . createActiveCode ( $ ( `#${ divid } ` ) [ 0 ] ,
138- eBookConfig . acDefaultLanguage ) ;
143+ let divid = eBookConfig . scratchDiv ;
144+ window . edList [ divid ] = ACFactory . createActiveCode (
145+ $ ( `#${ divid } ` ) [ 0 ] ,
146+ eBookConfig . acDefaultLanguage
147+ ) ;
139148 if ( eBookConfig . isLoggedIn ) {
140149 window . edList [ divid ] . enableSaveLoad ( ) ;
141150 }
@@ -145,8 +154,10 @@ async function popupScratchAC() {
145154
146155// Set the directory containing this script as the `path <https://webpack.js.org/guides/public-path/#on-the-fly>`_ for all webpacked scripts.
147156const script_src = document . currentScript . src ;
148- __webpack_public_path__ = script_src . substring ( 0 , script_src . lastIndexOf ( '/' ) + 1 ) ;
149-
157+ __webpack_public_path__ = script_src . substring (
158+ 0 ,
159+ script_src . lastIndexOf ( "/" ) + 1
160+ ) ;
150161
151162// Manual exports
152163// ==============
0 commit comments