joseph / Monocle

A silky, tactile browser-based ebook JavaScript library.
http://monocle.inventivelabs.com.au
MIT License
743 stars 200 forks source link

Popover control #189

Closed rafaelekol closed 11 years ago

rafaelekol commented 11 years ago

Hi, I want to add dictionary to Monocle reader. The most appropriate way for this I think is using Popover control. I inspected the way popover works with Contents, but still couldn't figure out how I can show custom html with popover control window in Monocle reader.

lmvco commented 11 years ago

You need to create a custom control (documentation available at https://github.com/joseph/Monocle/wiki/Controls)

For instance, in Dickens test - http://test.monoclejs.com/test/showcase/02-dickens/index.html - there's a custom control for chapter title (see file http://test.monoclejs.com/test/showcase/02-dickens/test.js)

/* CHAPTER TITLE RUNNING HEAD */ var chapterTitle = { runners: [], createControlElements: function (page) { var cntr = document.createElement('div'); cntr.className = "chapterTitle"; var runner = document.createElement('div'); runner.className = "runner"; cntr.appendChild(runner); this.runners.push(runner); this.update(page); return cntr; }, update: function (page) { } } reader.addControl(chapterTitle, 'page');

joseph commented 11 years ago

Thanks for answering this @lmvco.