简体   繁体   中英

iBooks Widgets: Parameters and shared assets

Consider a text book made with iBooks Author, using HTML widgets for interactive features, for example a quiz at the end of every chapter. You end up with a lot of widgets (one per chapter) that share a lot of assets (image files, javascript libraries).

Casual use of iBooks Author seems to indicate that every widget is its own independent bundle that gets copied into the book. This would be horribly wasteful in this scenario.

  1. Can I include the same bundle multiple times (so that is appears in many locations, but does not take up redundant disk space)?

  2. Can I pass parameters to the widget (so that I can tell it which chapter's data to display)?

  3. If 1+2 don't work, can a widget refer to assets stored in a shared location somewhere else in the same book (so that I can produce fifty lean widgets that don't have to contain images and Javascript themselves)?

Just have an answer for 3., still trying to figure out the other two.

The ibooks file created by IBA is basically an EPUB document. Because this is the case, you can refer to files within the package itself with HTML from your widgets.

IBA creates an assets folder where it stores all the images, widgets, and other items.

For example, <img src='../../images/image.jpg' /> in the HTML in your widget will display image.jpg .

To see and add images, js, whatever to the iBook after it is generated, unzip your iBooks file.

  1. You can include the same bundle multiple times, but I believe it doesn't share all the assets so each copy takes up space.
  2. You can't pass parameters to the widget as far as I can tell. I wrote this somewhere else, too, but we built a quiz widget that was at the end of each chapter and we ended up just cloning code for the widget and setting all the variables via JSON. That turned out to be the easiest way.
  3. localstorage is shared between all the widgets, so you can store shared information there (base-64 encode the images?).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM