123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- $(function() {
- $('select[name="document"]').change(function(e){
- console.log("document selection",this);
- $('iframe').attr('src', this.value);
- });
- $.getJSON('build/toc.json', function(data){
- console.log(data);
- for (book in data) {
- console.log(data[book]);
-
-
-
-
-
- $('[name="document"]').append(
- $('<option>')
- .attr('value', data[book].file).text(data[book].label)
- );
- }
- console.log(window.location.hash);
- var hash = parseInt(window.location.hash.replace('#',''));
- console.log(hash);
- var value = $('[name="document"] option:eq('+hash+')').attr('value');
- console.log('value', value);
- $('[name="document"]').val(value).change();
- })
-
- $('iframe').load(function() {
- initIframe();
- });
- function initIframe(){
- var doc = $("iframe").contents().find("html");
- console.log('initIframe :: doc', doc);
- $('input[name="preview"]').change(function(e) {
- console.log('Preview',e);
- if($(this).is(":checked")) {
- doc.addClass("preview");
- doc.removeClass("normal");
- } else {
- doc.removeClass("preview");
- doc.addClass("normal");
- }
- });
- if(preview){
- $('input[name="preview"]').prop('checked', true).change();
- }
- $('[name="debug"]').change(function() {
- if($(this).is(":checked")) {
- doc.addClass("debug");
- } else {
- doc.removeClass("debug");
- }
- });
- $('[name="spread"]').change(function() {
- if($(this).is(":checked")) {
- doc.addClass("spread");
- } else {
- doc.removeClass("spread");
- }
- });
- if(spread){
- $('[name="spread"]').prop('checked', true).change();
- }
-
-
-
-
-
-
-
- $('[name="zoom"]').change(function() {
- zoomLevel = $(this).val() / 100;
- doc.find("#pages").css({
- "-webkit-transform": "scale(" + zoomLevel + ")",
- "-webkit-transform-origin": "0 0"
- });
- });
-
-
-
-
- $('[name="page"]').change(function() {
- var pageNumber = $(this).val() - 1;
- var target = doc.find('.paper:eq(' + pageNumber + ')');
- var offsetTop = target.offset().top;
- doc.find('body').scrollTop(offsetTop);
- });
- $("#print").on('click', function() {
- $("iframe").get(0).contentWindow.print();
- });
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- });
-
-
-
-
|