box / viewer.js

A viewer for documents converted with the Box View API
Apache License 2.0
336 stars 99 forks source link

Insert advertisement banner between pages #97

Open devphp90 opened 10 years ago

devphp90 commented 10 years ago

Hi all,

I want to add some image banners for advertising. Example:

How can I do that.

I have read the document but no idea to custom.

Regards

lakenen commented 10 years ago

You could do this in the presentation layout by listening for pagefocus events and when you get to page 4, hide the document and show an ad until the user clicks "next" or something (then show the document and page 4).

For example:

var lastPage;
viewer.on('pagefocus', function (event) {
    if (event.data.page === 4 && lastPage === 3) {
        //hide viewer, show ad
    }
    lastPage = event.data.page;
});

There's not really a simple way to do this (yet) for scrollable layouts. You could write your own layout that does this, but it would not be trivial to implement. I have been toying around with some ideas on how to do page manipulation (adding/removing/reordering, etc) as a first-class API on the viewer, but haven't had a chance to implement anything like that yet.

devphp90 commented 10 years ago

Hi Lakenen, thank for your response, let me try that.

Regards,

esoftcard commented 10 years ago

how can i start to edit my own layout please ? it mean, what exactly file i have to edit ? thank you

lakenen commented 10 years ago

There's not yet very good documentation on how each of the built-in modes works, but you can find some examples if you look at the other layout modes section. Otherwise, you might want to check out the built in layouts (src/js/components/layout*).

esoftcard commented 10 years ago

I found this : src/js/component/view-base.js

should i add a add ads function here link : function ads() { }