');
64 |
65 | if(this.input.context.type!="hidden"){
66 | var clearer = $('
×');
67 | clearer.click(this.bindToObj(function(){this.input.val(""); this.selectDate();}));
68 | this.input.after(clearer);
69 | }
70 |
71 | switch (this.date_format){
72 | case "dd/mm/YYYY":
73 | this.reg = new RegExp(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
74 | this.date_decode = "new Date(matches[3], parseInt(matches[2]-1), matches[1]);";
75 | this.date_encode = 'this.strpad(date.getDate()) + "/" + this.strpad(date.getMonth()+1) + "/" + date.getFullYear();';
76 | this.date_encode_s = 'this.strpad(date.getDate()) + "/" + this.strpad(date.getMonth()+1)';
77 | break;
78 | case "FF dd YYYY":
79 | this.reg = new RegExp(/^([a-zA-Z]+) (\d{1,2}) (\d{4})$/);
80 | this.date_decode = "new Date(matches[3], this.indexFor(this.month_names, matches[1]), matches[2]);";
81 | this.date_encode = 'this.month_names[date.getMonth()] + " " + this.strpad(date.getDate()) + " " + date.getFullYear();';
82 | this.date_encode_s = 'this.month_names[date.getMonth()] + " " + this.strpad(date.getDate());';
83 | break;
84 | case "dd MM YYYY":
85 | this.reg = new RegExp(/^(\d{1,2}) ([a-zA-Z]{3}) (\d{4})$/);
86 | this.date_decode = "new Date(matches[3], this.indexFor(this.short_month_names, matches[2]), matches[1]);";
87 | this.date_encode = 'this.strpad(date.getDate()) + " " + this.short_month_names[date.getMonth()] + " " + date.getFullYear();';
88 | this.date_encode_s = 'this.strpad(date.getDate()) + " " + this.short_month_names[date.getMonth()];';
89 | break;
90 | case "MM dd YYYY":
91 | this.reg = new RegExp(/^([a-zA-Z]{3}) (\d{1,2}) (\d{4})$/);
92 | this.date_decode = "new Date(matches[3], this.indexFor(this.short_month_names, matches[1]), matches[2]);";
93 | this.date_encode = 'this.short_month_names[date.getMonth()] + " " + this.strpad(date.getDate()) + " " + date.getFullYear();';
94 | this.date_encode_s = 'this.short_month_names[date.getMonth()] + " " + this.strpad(date.getDate());';
95 | break;
96 | case "dd FF YYYY":
97 | this.reg = new RegExp(/^(\d{1,2}) ([a-zA-Z]+) (\d{4})$/);
98 | this.date_decode = "new Date(matches[3], this.indexFor(this.month_names, matches[2]), matches[1]);";
99 | this.date_encode = 'this.strpad(date.getDate()) + " " + this.month_names[date.getMonth()] + " " + date.getFullYear();';
100 | this.date_encode_s = 'this.strpad(date.getDate()) + " " + this.month_names[date.getMonth()];';
101 | break;
102 | case "YYYY/mm/dd":
103 | default:
104 | this.reg = new RegExp(/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/);
105 | this.date_decode = "new Date(matches[1], parseInt(matches[2]-1), matches[3]);";
106 | this.date_encode = 'date.getFullYear() + "/" + this.strpad(date.getMonth()+1) + "/" + this.strpad(date.getDate());';
107 | this.date_encode_s = 'this.strpad(date.getMonth()+1) + "/" + this.strpad(date.getDate());';
108 | break;
109 | }
110 |
111 | if(this.date_max != "" && this.date_max.match(this.reg)){
112 | var matches = this.date_max.match(this.reg);
113 | this.date_max = eval(this.date_decode);
114 | }else
115 | this.date_max = "";
116 |
117 | if(this.date_min != "" && this.date_min.match(this.reg)){
118 | var matches = this.date_min.match(this.reg);
119 | this.date_min = eval(this.date_decode);
120 | }else
121 | this.date_min = "";
122 |
123 | var monthNav = $('
' +
124 | '«' +
125 | ' ' +
126 | '»' +
127 | '
');
128 |
129 | this.monthNameSpan = $(".month_name", monthNav);
130 | $(".prev", monthNav).click(this.bindToObj(function() { this.moveMonthBy(-1); }));
131 | $(".next", monthNav).click(this.bindToObj(function() { this.moveMonthBy(1); }));
132 |
133 | this.monthNameSpan.dblclick(this.bindToObj(function(){
134 | this.monthNameSpan.empty().append(this.getMonthSelect());
135 | $('select', this.monthNameSpan).change(this.bindToObj(function(){
136 | this.moveMonthBy(parseInt($('select :selected', this.monthNameSpan).val()) - this.currentMonth.getMonth());
137 | }));
138 | }));
139 |
140 | var yearNav = $('
' +
141 | '«' +
142 | ' ' +
143 | '»' +
144 | '
');
145 |
146 | this.yearNameSpan = $(".year_name", yearNav);
147 | $(".prev", yearNav).click(this.bindToObj(function() { this.moveMonthBy(-12); }));
148 | $(".next", yearNav).click(this.bindToObj(function() { this.moveMonthBy(12); }));
149 |
150 | this.yearNameSpan.dblclick(this.bindToObj(function(){
151 |
152 | if($('.year_name input', this.rootLayers).length==0){
153 | var initialDate = this.yearNameSpan.html();
154 |
155 | var yearNameInput = $('
');
156 | this.yearNameSpan.empty().append(yearNameInput);
157 |
158 | $(".year_input", yearNav).keyup(this.bindToObj(function(){
159 | if($('input',this.yearNameSpan).val().length == 4 && $('input',this.yearNameSpan).val() != initialDate && parseInt($('input',this.yearNameSpan).val()) == $('input',this.yearNameSpan).val()){
160 | this.moveMonthBy(parseInt(parseInt(parseInt($('input',this.yearNameSpan).val()) - initialDate)*12));
161 | }else if($('input',this.yearNameSpan).val().length>4)
162 | $('input',this.yearNameSpan).val($('input',this.yearNameSpan).val().substr(0, 4));
163 | }));
164 |
165 | $('input',this.yearNameSpan).focus();
166 | $('input',this.yearNameSpan).select();
167 | }
168 |
169 | }));
170 |
171 | var error_msg = $('
');
172 |
173 | var nav = $('
').append(error_msg, monthNav, yearNav);
174 |
175 | var tableShell = "
";
176 |
177 | if(this.show_week == 1) tableShell +='| '+(this.week_label)+' | ';
178 |
179 | $(this.adjustDays(this.short_day_names)).each(function() {
180 | tableShell += "" + this + " | ";
181 | });
182 |
183 | tableShell += "
";
184 |
185 | var style = (this.input.context.type=="hidden")?' style="display:block; position:static; margin:0 auto"':'';
186 |
187 | this.dateSelector = this.rootLayers = $('
').append(nav, tableShell).insertAfter(this.input);
188 |
189 | if ($.browser.msie && $.browser.version < 7) {
190 |
191 | this.ieframe = $('
').insertBefore(this.dateSelector);
192 | this.rootLayers = this.rootLayers.add(this.ieframe);
193 |
194 | $(".button", nav).mouseover(function() { $(this).addClass("hover"); });
195 | $(".button", nav).mouseout(function() { $(this).removeClass("hover"); });
196 | };
197 |
198 | this.tbody = $("tbody", this.dateSelector);
199 |
200 | this.input.change(this.bindToObj(function() { this.selectDate(); }));
201 | this.selectDate();
202 |
203 | },
204 |
205 | selectMonth: function(date) {
206 | var newMonth = new Date(date.getFullYear(), date.getMonth(), date.getDate());
207 | if(this.isNewDateAllowed(newMonth)){
208 | if (!this.currentMonth || !(this.currentMonth.getFullYear() == newMonth.getFullYear() &&
209 | this.currentMonth.getMonth() == newMonth.getMonth())) {
210 |
211 | this.currentMonth = newMonth;
212 |
213 | var rangeStart = this.rangeStart(date), rangeEnd = this.rangeEnd(date);
214 | var numDays = this.daysBetween(rangeStart, rangeEnd);
215 | var dayCells = "";
216 |
217 | for (var i = 0; i <= numDays; i++) {
218 | var currentDay = new Date(rangeStart.getFullYear(), rangeStart.getMonth(), rangeStart.getDate() + i, 12, 00);
219 |
220 | if (this.isFirstDayOfWeek(currentDay)){
221 |
222 | var firstDayOfWeek = currentDay;
223 | var lastDayOfWeek = new Date(currentDay.getFullYear(), currentDay.getMonth(), currentDay.getDate()+6, 12, 00);
224 |
225 | if(this.select_week && this.isNewDateAllowed(firstDayOfWeek))
226 | dayCells += "
";
227 | else
228 | dayCells += "
";
229 |
230 | if(this.show_week==1)
231 | dayCells += '| '+this.getWeekNum(currentDay)+' | ';
232 | }
233 | if ((this.select_week == 0 && currentDay.getMonth() == date.getMonth() && this.isNewDateAllowed(currentDay) && !this.isHoliday(currentDay)) || (this.select_week==1 && currentDay.getMonth() == date.getMonth() && this.isNewDateAllowed(firstDayOfWeek))) {
234 | dayCells += '' + currentDay.getDate() + ' | ';
235 | } else {
236 | dayCells += '' + currentDay.getDate() + ' | ';
237 | };
238 |
239 | if (this.isLastDayOfWeek(currentDay)) dayCells += "
";
240 | };
241 | this.tbody.empty().append(dayCells);
242 |
243 | this.monthNameSpan.empty().append(this.monthName(date));
244 | this.yearNameSpan.empty().append(this.currentMonth.getFullYear());
245 |
246 | if(this.select_week == 0){
247 | $(".selectable_day", this.tbody).click(this.bindToObj(function(event) {
248 | this.changeInput($(event.target).attr("date"));
249 | }));
250 | }else{
251 | $(".selectable_week", this.tbody).click(this.bindToObj(function(event) {
252 | this.changeInput($(event.target.parentNode).attr("date"));
253 | }));
254 | }
255 |
256 | $("td[date=\"" + this.dateToString(new Date()) + "\"]", this.tbody).addClass("today");
257 | if(this.select_week == 1){
258 | $("tr", this.tbody).mouseover(function() { $(this).addClass("hover"); });
259 | $("tr", this.tbody).mouseout(function() { $(this).removeClass("hover"); });
260 | }else{
261 | $("td.selectable_day", this.tbody).mouseover(function() { $(this).addClass("hover"); });
262 | $("td.selectable_day", this.tbody).mouseout(function() { $(this).removeClass("hover"); });
263 | }
264 | };
265 |
266 | $('.selected', this.tbody).removeClass("selected");
267 | $('td[date="' + this.selectedDateString + '"], tr[date="' + this.selectedDateString + '"]', this.tbody).addClass("selected");
268 | }else
269 | this.show_error(this.error_out_of_range);
270 | },
271 |
272 | selectDate: function(date) {
273 | if (typeof(date) == "undefined") {
274 | date = this.stringToDate(this.input.val());
275 | };
276 | if (!date) date = new Date();
277 |
278 | if(this.select_week == 1 && !this.isFirstDayOfWeek(date))
279 | date = new Date(date.getFullYear(), date.getMonth(), (date.getDate() - date.getDay() + this.start_of_week), 12, 00);
280 |
281 | if(this.isNewDateAllowed(date)){
282 | this.selectedDate = date;
283 | this.selectedDateString = this.dateToString(this.selectedDate);
284 | this.selectMonth(this.selectedDate);
285 | }else if((this.date_min) && this.daysBetween(this.date_min, date)<0){
286 | this.selectedDate = this.date_min;
287 | this.selectMonth(this.date_min);
288 | this.input.val(" ");
289 | }else{
290 | this.selectMonth(this.date_max);
291 | this.input.val(" ");
292 | }
293 | },
294 |
295 | isNewDateAllowed: function(date){
296 | return ((!this.date_min) || this.daysBetween(this.date_min, date)>=0) && ((!this.date_max) || this.daysBetween(date, this.date_max)>=0);
297 | },
298 |
299 | isHoliday: function(date){
300 | return ((this.indexFor(this.selectable_days, date.getDay())===false || this.indexFor(this.non_selectable, this.dateToString(date))!==false) || this.indexFor(this.rec_non_selectable, this.dateToShortString(date))!==false);
301 | },
302 |
303 | changeInput: function(dateString) {
304 | this.input.val(dateString).change();
305 | if(this.input.context.type!="hidden")
306 | this.hide();
307 | },
308 |
309 | show: function() {
310 | $('.error_msg', this.rootLayers).css('display', 'none');
311 | this.rootLayers.fadeIn();
312 | $([window, document.body]).click(this.hideIfClickOutside);
313 | this.input.unbind("click", this.show);
314 | this.input.attr('readonly', true);
315 | $(document.body).keydown(this.keydownHandler);
316 | this.setPosition();
317 | return false;
318 | },
319 |
320 | hide: function() {
321 | if(this.input.context.type!="hidden"){
322 | this.input.removeAttr('readonly');
323 | this.rootLayers.fadeOut();
324 | $([window, document.body]).unbind("click", this.hideIfClickOutside);
325 | this.input.click(this.show);
326 | $(document.body).unbind("keydown", this.keydownHandler);
327 | }
328 | },
329 |
330 | hideIfClickOutside: function(event) {
331 | if (event.target != this.input[0] && !this.insideSelector(event)) {
332 | this.hide();
333 | };
334 | },
335 |
336 | insideSelector: function(event) {
337 | var offset = this.dateSelector.offset();
338 | offset.right = offset.left + this.dateSelector.outerWidth();
339 | offset.bottom = offset.top + this.dateSelector.outerHeight();
340 |
341 | return event.pageY < offset.bottom &&
342 | event.pageY > offset.top &&
343 | event.pageX < offset.right &&
344 | event.pageX > offset.left;
345 | },
346 |
347 | keydownHandler: function(event) {
348 | switch (event.keyCode)
349 | {
350 | case 9:
351 | case 27:
352 | this.hide();
353 | return;
354 | break;
355 | case 13:
356 | if(this.isNewDateAllowed(this.stringToDate(this.selectedDateString)) && !this.isHoliday(this.stringToDate(this.selectedDateString)))
357 | this.changeInput(this.selectedDateString);
358 | break;
359 | case 33:
360 | this.moveDateMonthBy(event.ctrlKey ? -12 : -1);
361 | break;
362 | case 34:
363 | this.moveDateMonthBy(event.ctrlKey ? 12 : 1);
364 | break;
365 | case 38:
366 | this.moveDateBy(-7);
367 | break;
368 | case 40:
369 | this.moveDateBy(7);
370 | break;
371 | case 37:
372 | if(this.select_week == 0) this.moveDateBy(-1);
373 | break;
374 | case 39:
375 | if(this.select_week == 0) this.moveDateBy(1);
376 | break;
377 | default:
378 | return;
379 | }
380 | event.preventDefault();
381 | },
382 |
383 | stringToDate: function(string) {
384 | var matches;
385 |
386 | if (matches = string.match(this.reg)) {
387 | if(matches[3]==0 && matches[2]==0 && matches[1]==0)
388 | return null;
389 | else
390 | return eval(this.date_decode);
391 | } else {
392 | return null;
393 | };
394 | },
395 |
396 | dateToString: function(date) {
397 | return eval(this.date_encode);
398 | },
399 |
400 | dateToShortString: function(date){
401 | return eval(this.date_encode_s);
402 | },
403 |
404 | setPosition: function() {
405 | var position = this.input.position();
406 | this.rootLayers.css({
407 | top: position.top + this.input.outerHeight(),
408 | left: position.left
409 | });
410 |
411 | if (this.ieframe) {
412 | this.ieframe.css({
413 | width: this.dateSelector.outerWidth(),
414 | height: this.dateSelector.outerHeight()
415 | });
416 | };
417 | },
418 |
419 | moveDateBy: function(amount) {
420 | var newDate = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth(), this.selectedDate.getDate() + amount);
421 | this.selectDate(newDate);
422 | },
423 |
424 | moveDateMonthBy: function(amount) {
425 | var newDate = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth() + amount, this.selectedDate.getDate());
426 | if (newDate.getMonth() == this.selectedDate.getMonth() + amount + 1) {
427 | newDate.setDate(0);
428 | };
429 | this.selectDate(newDate);
430 | },
431 |
432 | moveMonthBy: function(amount) {
433 | if(amount<0)
434 | var newMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + amount+1, -1);
435 | else
436 | var newMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + amount, 1);
437 | this.selectMonth(newMonth);
438 | },
439 |
440 | monthName: function(date) {
441 | return this.month_names[date.getMonth()];
442 | },
443 |
444 | getMonthSelect:function(){
445 | var month_select = '
';
453 |
454 | return month_select;
455 | },
456 |
457 | bindToObj: function(fn) {
458 | var self = this;
459 | return function() { return fn.apply(self, arguments) };
460 | },
461 |
462 | bindMethodsToObj: function() {
463 | for (var i = 0; i < arguments.length; i++) {
464 | this[arguments[i]] = this.bindToObj(this[arguments[i]]);
465 | };
466 | },
467 |
468 | indexFor: function(array, value) {
469 | for (var i = 0; i < array.length; i++) {
470 | if (value == array[i]) return i;
471 | };
472 | return false;
473 | },
474 |
475 | monthNum: function(month_name) {
476 | return this.indexFor(this.month_names, month_name);
477 | },
478 |
479 | shortMonthNum: function(month_name) {
480 | return this.indexFor(this.short_month_names, month_name);
481 | },
482 |
483 | shortDayNum: function(day_name) {
484 | return this.indexFor(this.short_day_names, day_name);
485 | },
486 |
487 | daysBetween: function(start, end) {
488 | start = Date.UTC(start.getFullYear(), start.getMonth(), start.getDate());
489 | end = Date.UTC(end.getFullYear(), end.getMonth(), end.getDate());
490 | return (end - start) / 86400000;
491 | },
492 |
493 | changeDayTo: function(dayOfWeek, date, direction) {
494 | var difference = direction * (Math.abs(date.getDay() - dayOfWeek - (direction * 7)) % 7);
495 | return new Date(date.getFullYear(), date.getMonth(), date.getDate() + difference);
496 | },
497 |
498 | rangeStart: function(date) {
499 | return this.changeDayTo(this.start_of_week, new Date(date.getFullYear(), date.getMonth()), -1);
500 | },
501 |
502 | rangeEnd: function(date) {
503 | return this.changeDayTo((this.start_of_week - 1) % 7, new Date(date.getFullYear(), date.getMonth() + 1, 0), 1);
504 | },
505 |
506 | isFirstDayOfWeek: function(date) {
507 | return date.getDay() == this.start_of_week;
508 | },
509 |
510 | getWeekNum:function(date){
511 | date_week= new Date(date.getFullYear(), date.getMonth(), date.getDate()+6);
512 | var firstDayOfYear = new Date(date_week.getFullYear(), 0, 1, 12, 00);
513 | var n = parseInt(this.daysBetween(firstDayOfYear, date_week)) + 1;
514 | return Math.floor((date_week.getDay() + n + 5)/7) - Math.floor(date_week.getDay() / 5);
515 | },
516 |
517 | isLastDayOfWeek: function(date) {
518 | return date.getDay() == (this.start_of_week - 1) % 7;
519 | },
520 |
521 | show_error: function(error){
522 | $('.error_msg', this.rootLayers).html(error);
523 | $('.error_msg', this.rootLayers).fadeIn(400, function(){
524 | setTimeout("$('.error_msg', this.rootLayers).fadeOut(200);", 2000);
525 | });
526 | },
527 |
528 | adjustDays: function(days) {
529 | var newDays = [];
530 | for (var i = 0; i < days.length; i++) {
531 | newDays[i] = days[(i + this.start_of_week) % 7];
532 | };
533 | return newDays;
534 | },
535 |
536 | strpad: function(num){
537 | if(parseInt(num)<10) return "0"+parseInt(num);
538 | else return parseInt(num);
539 | }
540 |
541 | };
542 |
543 | $.fn.jdPicker = function(opts) {
544 | return this.each(function() { new jdPicker(this, opts); });
545 | };
546 | $.jdPicker = { initialize: function(opts) {
547 | $("input.jdpicker").jdPicker(opts);
548 | } };
549 |
550 | return jdPicker;
551 | })(jQuery);
552 |
553 | $($.jdPicker.initialize);
554 |
--------------------------------------------------------------------------------
/digitalpaper/static/digitalpaper/js/reader.js:
--------------------------------------------------------------------------------
1 | var libeReader = function() {
2 | var _publicationId, _bookName, _publication, _selectedBook, _pages,
3 | _displayedPage, _displayedBook, _zoomWindow, _winHeight, _winWidth,
4 | _numberOfPages, _isZoomed, _zoomedPageHeight, _zoomedPageWidth,
5 | _zoomMouseInit, _zoomPosInit, _zoomedPages, _zoomMouseDown, _step,
6 | _HDgridContainer;
7 |
8 | _step = 21;
9 |
10 | function bindButtons() {
11 | jQuery('#previousButton, #previousCorner').click(showPreviousPage);
12 | jQuery('#nextButton, #nextCorner').click(showNextPage);
13 | jQuery('#firstButton').click(showFirstPage);
14 | jQuery('#lastButton').click(showLastPage);
15 | jQuery('#evenSide, #oddSide').click(zoom);
16 | }
17 |
18 | function unbindButtons() {
19 | jQuery('#previousButton, #previousCorner').unbind("click", showPreviousPage);
20 | jQuery('#nextButton, #nextCorner').unbind("click", showNextPage);
21 | jQuery('#firstButton').unbind("click", showFirstPage);
22 | jQuery('#lastButton').unbind("click", showLastPage);
23 | jQuery('#evenSide, #oddSide').unbind("click");
24 | }
25 |
26 | function bindKeyboard() {
27 | jQuery(document).bind('keydown', keyboardCallback);
28 | }
29 |
30 | function unbindKeyboard() {
31 | jQuery(document).unbind('keydown', keyboardCallback);
32 | }
33 |
34 | function zoom(event) {
35 | var offset = jQuery(this).offset();
36 | if (!offset) {
37 | offset = {
38 | 'left': 0,
39 | 'top': 0
40 | };
41 | }
42 | var x = event.pageX - offset.left;
43 | var y = event.pageY - offset.top;
44 |
45 | var previousElement = jQuery(this).prev();
46 | if (previousElement) {
47 | x = x + previousElement.width();
48 | }
49 | zoomAtCoordinates(x, y);
50 | return false;
51 | }
52 |
53 | function zoomAtCoordinates(x, y) {
54 | if (!libeConfig.canZoom()) {
55 | libeConfig.restrictedAccess();
56 | return false;
57 | }
58 | if (_isZoomed) {
59 | return false;
60 | }
61 |
62 | jQuery(document).trigger('page-beforezoom', [_displayedPage]);
63 |
64 | x = x * libeConfig.zoomFactor;
65 | y = y * libeConfig.zoomFactor;
66 |
67 | _zoomedPageHeight = libeConfig.pageHeight * libeConfig.zoomFactor;
68 | _zoomedPageWidth = libeConfig.pageWidth * libeConfig.zoomFactor;
69 |
70 | jQuery('#pagesSlider').hide();
71 | jQuery('#bookSwitcher').hide();
72 |
73 | var height = jQuery(window).height();
74 | jQuery(document.body).css({'overflow': 'hidden', 'height': height });
75 | document.body.scrollTop = 0;
76 | document.documentElement.scrollTop = 0;
77 |
78 | _zoomWindow = jQuery(document.createElement('div'));
79 | _zoomWindow.attr('id', 'zoomWindow');
80 | _zoomWindow.addClass('grab');
81 |
82 | zoomResize();
83 |
84 | _zoomedPages = jQuery(document.createElement('div'));
85 | _zoomedPages.attr('id', 'zoomedPages');
86 |
87 | _numberOfPages = 0;
88 | if (_pages[_displayedPage]) {
89 | var leftPage = jQuery(document.createElement('img'));
90 | leftPage.attr({'id': 'leftPageZoomed', 'src': _pages[_displayedPage].imageSource});
91 | _zoomedPages.append(leftPage);
92 | _numberOfPages++;
93 | }
94 | if (_pages[_displayedPage + 1]) {
95 | var rightPage = jQuery(document.createElement('img'));
96 | rightPage.attr({'id': 'rightPageZoomed', 'src': _pages[_displayedPage + 1].imageSource});
97 | _zoomedPages.append(rightPage);
98 | _numberOfPages++;
99 | }
100 | if (_numberOfPages == 1) {
101 | _zoomedPages.children().first().css('width', '100%');
102 | }
103 |
104 | var top = y - (_winHeight / 2);
105 | top = zoomTopInArea(top);
106 |
107 | if (_numberOfPages == 1 && x > _zoomedPageWidth) {
108 | x = x - _zoomedPageWidth;
109 | }
110 | var left = x - (_winWidth / 2);
111 | left = zoomLeftInArea(left);
112 | _zoomedPages.css({'height': _zoomedPageHeight, 'width': _numberOfPages * _zoomedPageWidth, 'top': -top, 'left': -left});
113 |
114 | _zoomWindow.append(_zoomedPages);
115 | _zoomWindow.dblclick(quitZoom);
116 |
117 | _zoomWindow.mousedown(zoomMouseDown);
118 | _zoomWindow.mouseup(zoomMouseUp);
119 | _zoomWindow.mousemove(zoomMouseMove);
120 | jQuery(document.body).mouseleave(zoomMouseUp);
121 | jQuery(document.body).bind('mousewheel', zoomMouseWheel);
122 | jQuery(document.body).addClass('zoomed');
123 | jQuery(window).bind('resize', zoomResize);
124 |
125 | jQuery(document.body).append(_zoomWindow);
126 |
127 | // Just for Apple touch, jQuery suxx and delete e.touches
128 | var zw = document.getElementById('zoomWindow');
129 | if (zw && zw.addEventListener) {
130 | zw.addEventListener('touchstart', zoomMouseDown, true);
131 | zw.addEventListener('touchend', zoomMouseUp, true);
132 | zw.addEventListener('touchmove', zoomMouseMove, true);
133 | }
134 |
135 | zoomInitHDGrid(top, left);
136 | _isZoomed = true;
137 | jQuery('#zoomButton').addClass('unzoom');
138 | jQuery(document).trigger('page-afterzoom', [_displayedPage]);
139 | }
140 |
141 | function zoomInitHDGrid(top, left) {
142 | _HDgridContainer = jQuery(document.createElement('div'));
143 | _HDgridContainer.css({'height': _zoomedPageHeight, 'width': _numberOfPages * _zoomedPageWidth, 'top': -top, 'left': -left});
144 | _HDgridContainer.attr('id', 'HDGrid');
145 |
146 | var nbZones = _numberOfPages * libeConfig.imagesPerRow * libeConfig.imagesPerColumn;
147 | var xRowSize = Math.floor(_zoomedPageWidth / libeConfig.imagesPerRow);
148 | var yColumnSize = Math.floor(_zoomedPageHeight / libeConfig.imagesPerColumn);
149 |
150 | for (var i = 0; i < nbZones; i++) {
151 | var img = jQuery(document.createElement('img'));
152 | img.addClass('grid');
153 | img.css({'height': yColumnSize, 'width': xRowSize});
154 | _HDgridContainer.append(img);
155 | }
156 | _zoomWindow.append(_HDgridContainer);
157 |
158 | zoomHighDefAtCoordinates(left, top);
159 | }
160 |
161 | function quitZoom() {
162 | jQuery(document).trigger('page-leavezoom', [_displayedPage]);
163 | jQuery(_zoomWindow).detach();
164 | jQuery(window).unbind('resize', zoomResize);
165 | jQuery(document.body).unbind('mousewheel');
166 | jQuery(document.body).removeClass('zoomed');
167 | jQuery('#pagesSlider').show();
168 | jQuery('#bookSwitcher').show();
169 | jQuery(document.body).css({'overflow': 'visible', 'height': 'auto' });
170 | _isZoomed = false;
171 | jQuery('#zoomButton').removeClass('unzoom');
172 | return false;
173 | }
174 |
175 | function zoomResize() {
176 | var win = jQuery(window);
177 | _winHeight = win.height();
178 | _winWidth = win.width();
179 | }
180 |
181 | function keyboardCallback(e) {
182 | if (jQuery('#DOMWindow').length <= 0) {
183 | if (_isZoomed) {
184 | return zoomedKeyboardCallback(e);
185 | } else {
186 | return normalKeyboardCallback(e);
187 | }
188 | }
189 | }
190 |
191 | function normalKeyboardCallback(e) {
192 | if (e.ctrlKey) {
193 | switch (e.which) {
194 | case 109: // -
195 | case 40: // bottom
196 | e.preventDefault();
197 | break;
198 | case 61: // =
199 | case 107: // +
200 | case 38: // up
201 | zoom(e);
202 | e.preventDefault();
203 | break;
204 | case 35: // end
205 | showLastPage(e);
206 | break;
207 | case 36: // home
208 | showFirstPage(e);
209 | break;
210 | case 37: // left
211 | showPreviousPage(e);
212 | break;
213 | case 39: // right
214 | showNextPage(e);
215 | break;
216 | default:
217 | break;
218 | }
219 | }
220 | }
221 |
222 | function zoomedKeyboardCallback(e) {
223 | _zoomLoadPosInit();
224 | var x = 0;
225 | var y = 0;
226 | if (e.ctrlKey) {
227 | switch (e.which) {
228 | case 27: // esc
229 | case 109: // -
230 | case 40: // bottom
231 | quitZoom();
232 | e.preventDefault();
233 | break;
234 | default:
235 | break;
236 | }
237 | } else {
238 | switch (e.which) {
239 | case 27: // esc
240 | quitZoom();
241 | e.preventDefault();
242 | break;
243 | case 37: // left
244 | x = -_step;
245 | break;
246 | case 38: // up
247 | y = -_step;
248 | break;
249 | case 39: // right
250 | x = _step;
251 | break;
252 | case 40: // bottom
253 | y = _step;
254 | break;
255 | default:
256 | break;
257 | }
258 | }
259 | if (x || y) {
260 | zoomBy(x, y);
261 | e.preventDefault();
262 | }
263 | }
264 |
265 | function _zoomLoadPosInit() {
266 | _zoomPosInit = {x: -parseInt(_zoomedPages.css('left'), 10), y: -parseInt(_zoomedPages.css('top'), 10)};
267 | }
268 |
269 | function zoomMouseDown(e) {
270 | // iPhone/iPad
271 | if (e.touches) {
272 | e.preventDefault();
273 | e = e.touches[0];
274 | } else {
275 | e.preventDefault();
276 | }
277 |
278 | _zoomMouseDown = true;
279 | _zoomLoadPosInit();
280 | _zoomMouseInit = {x: e.clientX, y: e.clientY};
281 | _zoomWindow.addClass('grabbing');
282 | _zoomWindow.removeClass('grab');
283 | }
284 |
285 | function zoomMouseUp(e) {
286 | _zoomMouseDown = false;
287 | _zoomWindow.addClass('grab');
288 | _zoomWindow.removeClass('grabbing');
289 | e.preventDefault();
290 |
291 | zoomHighDefAtCoordinates(-parseInt(_zoomedPages.css('left'), 10), -parseInt(_zoomedPages.css('top'), 10));
292 | }
293 |
294 | function zoomMouseMove(e) {
295 | if (_zoomMouseDown !== true) {
296 | return;
297 | }
298 |
299 | // iPhone/iPad
300 | if (e.touches) {
301 | e.preventDefault();
302 | e = e.touches[0];
303 | } else {
304 | e.preventDefault();
305 | }
306 |
307 | zoomBy(_zoomMouseInit.x - e.clientX, _zoomMouseInit.y - e.clientY);
308 | }
309 |
310 | function zoomMouseWheel(e, deltaX, deltaY) {
311 | _zoomLoadPosInit();
312 | zoomBy(-_step * deltaX, -_step * deltaY);
313 | e.preventDefault();
314 | }
315 |
316 | function zoomBy(x, y) {
317 | var newLeft = _zoomPosInit.x + (x);
318 | var newTop = _zoomPosInit.y + (y);
319 |
320 | newLeft = zoomLeftInArea(newLeft);
321 | newTop = zoomTopInArea(newTop);
322 |
323 | _zoomedPages.css({'left': -newLeft, 'top': -newTop});
324 | _HDgridContainer.css({'left': -newLeft, 'top': -newTop});
325 | }
326 |
327 | function zoomLeftInArea(left) {
328 | if (left < 0) {
329 | left = 0;
330 | }
331 | if (left > _numberOfPages * _zoomedPageWidth - _winWidth) {
332 | left = _numberOfPages * _zoomedPageWidth - _winWidth;
333 | }
334 |
335 | return left;
336 | }
337 | function zoomTopInArea(top) {
338 | if (top < 0) {
339 | top = 0;
340 | }
341 | if (top > _zoomedPageHeight - _winHeight)
342 | {
343 | top = _zoomedPageHeight - _winHeight;
344 | }
345 | return top;
346 | }
347 |
348 | function zoomHighDefAtCoordinates(x, y) {
349 | x = x + (_winWidth / 2);
350 | y = y + (_winHeight / 2);
351 |
352 | var xRowSize = _zoomedPageWidth / libeConfig.imagesPerRow;
353 | var yColumnSize = _zoomedPageHeight / libeConfig.imagesPerColumn;
354 |
355 | var xRow = Math.floor(x / xRowSize);
356 | var yColumn = Math.floor(y / yColumnSize);
357 | getZoomImage(xRow, yColumn);
358 |
359 | for (var i = 0; i < _numberOfPages * libeConfig.imagesPerRow + libeConfig.imagesPerColumn; i++) {
360 | for (var j = 0; j < i; j++) {
361 | var plop = i - j;
362 | getZoomImage(xRow - j, yColumn - plop);
363 | getZoomImage(xRow + j, yColumn + plop);
364 | getZoomImage(xRow - plop, yColumn + j);
365 | getZoomImage(xRow + plop, yColumn - j);
366 | }
367 | }
368 | }
369 |
370 | function getZoomImage(xRow, yColumn) {
371 | if (xRow < 0 || yColumn < 0) {
372 | return;
373 | }
374 |
375 | if (yColumn >= libeConfig.imagesPerColumn) {
376 | return;
377 | }
378 |
379 | if (_displayedPage === 0) {
380 | // If _displayedPage is 0, it means we are displaying the first page,
381 | // which is alone on the *right* hand side.
382 | // Constraints need to change in that case, to allow the coordinates
383 | // on the right (where the first page is) and disallow the ones on the left
384 | // (where there isn't any page)
385 | if (xRow >= 2 * libeConfig.imagesPerRow || xRow < libeConfig.imagesPerRow) {
386 | return;
387 | }
388 | } else {
389 | if (xRow >= _numberOfPages * libeConfig.imagesPerRow) {
390 | return;
391 | }
392 | }
393 |
394 | var imgIndex = 0;
395 | if (_displayedPage === 0) {
396 | // Another hack for the first page: there are only half the number of images,
397 | // the indexing need to be changed. (Note: we don't want to change xRow and yColumn
398 | // directly, the web services expect x to be > imagesPerRow on the right page,
399 | // even if it's the first one!)
400 | imgIndex = yColumn * libeConfig.imagesPerRow + xRow - libeConfig.imagesPerRow;
401 | } else {
402 | imgIndex = yColumn * libeConfig.imagesPerRow * _numberOfPages + xRow;
403 | }
404 |
405 | var img = _HDgridContainer.children().eq(imgIndex);
406 | if (!img) {
407 | return;
408 | }
409 |
410 | if (img.attr('src')) {
411 | return;
412 | }
413 |
414 | var currentPage = _pages[_displayedPage + Math.floor(xRow / libeConfig.imagesPerRow)];
415 | if (!currentPage) {
416 | return;
417 | }
418 |
419 | if (currentPage.pageId <= 0) {
420 | img.css({'visibility' : 'hidden'});
421 | } else {
422 | var replaces = {
423 | '{format}': 'png',
424 | '{id}': currentPage.pageId,
425 | '{crop}': libeConfig.imagesPerRow + 'x' + libeConfig.imagesPerColumn,
426 | '{x}': xRow,
427 | '{y}': yColumn
428 | };
429 |
430 | var src = libeConfig.webservices.paper_page_cropped;
431 | var k;
432 | for (k in replaces) {
433 | src = src.replace(k, replaces[k]);
434 | }
435 | img.attr('src', src);
436 | }
437 | }
438 |
439 | function showHoverCorner() {
440 | jQuery(this).css('opacity', 1);
441 | }
442 | function hideHoverCorner() {
443 | jQuery(this).css('opacity', 0);
444 | }
445 |
446 | function displayPagination() {
447 | var previousButtons = jQuery('#previousCorner, #pagesBefore');
448 | if (_displayedPage - 2 >= 0) {
449 | previousButtons.show();
450 | } else {
451 | previousButtons.hide();
452 | }
453 |
454 | var nextButtons = jQuery('#nextCorner, #pagesAfter');
455 | if (_displayedPage + 2 <= _selectedBook.pagination) {
456 | nextButtons.show();
457 | } else {
458 | nextButtons.hide();
459 | }
460 | readerSlider.moveIntoView(_displayedPage);
461 | }
462 |
463 | function showPage(number) {
464 | var newDisplayedPage = number - number % 2;
465 |
466 | // Non-existant page, nothing to do
467 | if (!_pages[newDisplayedPage] && !_pages[newDisplayedPage + 1]) {
468 | return;
469 | }
470 |
471 | jQuery('#oddSide .pageInfo, #evenSide .pageInfo').fadeOut();
472 |
473 | unbindButtons();
474 | unbindKeyboard();
475 |
476 | var evenSide = jQuery('#evenSide');
477 | var oddSide = jQuery('#oddSide');
478 | var finalWidth = evenSide.width();
479 | var height = evenSide.parent().height();
480 | var position = evenSide.position();
481 |
482 | var leftPage = jQuery(document.createElement('div'));
483 | leftPage.addClass('leftPage');
484 | if (_pages[newDisplayedPage]) {
485 | evenSide.css({'visibility' : 'visible'});
486 | leftPage.css('background-image', 'url(' + _pages[newDisplayedPage].imageSource + ')');
487 | } else {
488 | evenSide.css({'visibility' : 'hidden'});
489 | }
490 |
491 | var rightPage = jQuery(document.createElement('div'));
492 | rightPage.addClass('rightPage');
493 | if (_pages[newDisplayedPage + 1]) {
494 | oddSide.css({'visibility' : 'visible'});
495 | rightPage.css('background-image', 'url(' + _pages[newDisplayedPage + 1].imageSource + ')');
496 | } else {
497 | oddSide.css({'visibility' : 'hidden'});
498 | }
499 |
500 | var transitionElement = jQuery(document.createElement('div'));
501 | transitionElement.addClass('transitionPage');
502 | transitionElement.css('height', height);
503 | if (_displayedPage > newDisplayedPage) {
504 | transitionElement.css('left', 0);
505 | } else {
506 | transitionElement.css('right', 0);
507 | }
508 | transitionElement.append(leftPage);
509 | transitionElement.append(rightPage);
510 |
511 | var transitionContainerElement = jQuery(document.createElement('div'));
512 | transitionContainerElement.addClass('transitionContainer');
513 | transitionContainerElement.css({'width': 2 * finalWidth, 'height': height,
514 | 'left': position.left});
515 | transitionContainerElement.append(transitionElement);
516 | evenSide.parent().append(transitionContainerElement);
517 |
518 | transitionElement.animate({'width': 2 * finalWidth}, function() {
519 | cleanAfterShowPage(number);
520 | jQuery(this).parent().detach();
521 | });
522 | }
523 |
524 | function _hideOldPages() {
525 | if (typeof _displayedPage != "undefined") {
526 | if (_pages[_displayedPage]) {
527 | _pages[_displayedPage].hide();
528 | }
529 | if (_pages[_displayedPage + 1]) {
530 | _pages[_displayedPage + 1].hide();
531 | }
532 | }
533 | unHighlightCurrentPages();
534 | }
535 |
536 | function displayPage(number) {
537 | var page = _pages[number];
538 | page.show();
539 | highlightCurrentPages(_displayedBook, number);
540 | var elm = jQuery('#' + ((page.pageNumber % 2 === 0) ? 'even' : 'odd') + 'Side .pageInfo');
541 | elm.html(page.getPageInfo());
542 | elm.fadeIn();
543 | }
544 |
545 | function bookDisplayed() {
546 | return _displayedBook;
547 | }
548 |
549 | function pageDisplayed() {
550 | return _displayedPage;
551 | }
552 |
553 | function cleanAfterShowPage(number) {
554 | _hideOldPages();
555 |
556 | var newDisplayedPage = number - number % 2;
557 | if (_pages[newDisplayedPage] || _pages[newDisplayedPage + 1]) {
558 | _displayedPage = newDisplayedPage;
559 | window.location.hash = "#!/" + _displayedBook + '_' + _displayedPage;
560 | }
561 |
562 | var showRestrictedAccess = false;
563 | var shownPages = [];
564 | if (_pages[_displayedPage]) {
565 | shownPages.push(_displayedPage);
566 | displayPage(_displayedPage);
567 | if (!_pages[newDisplayedPage].canAccess()) {
568 | showRestrictedAccess = true;
569 | }
570 | }
571 | if (_pages[_displayedPage + 1]) {
572 | shownPages.push(_displayedPage + 1);
573 | displayPage(_displayedPage + 1);
574 | if (!_pages[newDisplayedPage + 1].canAccess()) {
575 | showRestrictedAccess = true;
576 | }
577 | }
578 |
579 | if (showRestrictedAccess) {
580 | // show "access restricted" lightbox if the displayed page
581 | // is restricted - the user will be able to close it,
582 | // it's just to remind him the page isn't free
583 | libeConfig.restrictedAccess();
584 | }
585 | displayPagination();
586 | bindButtons();
587 | bindKeyboard();
588 | jQuery(document).trigger('pages-shown', [_displayedBook, shownPages]);
589 | }
590 |
591 | function showSelectedPage(e) {
592 | e.preventDefault();
593 | var tmp = _parseHashtoGetParams(this.href.split('#!/')[1]);
594 | var newDisplayedBook = tmp[0];
595 | var newDisplayedPage = tmp[1] - tmp[1] % 2;
596 |
597 | if (newDisplayedBook != _displayedBook) {
598 | showBook(newDisplayedBook, newDisplayedPage);
599 | } else if (newDisplayedPage != _displayedPage) {
600 | showPage(newDisplayedPage);
601 | }
602 | }
603 |
604 | function showPreviousPage(e) {
605 | e.preventDefault();
606 | showPage(_displayedPage - 2);
607 | }
608 | function showNextPage(e) {
609 | e.preventDefault();
610 | showPage(_displayedPage + 2);
611 | }
612 |
613 | function showFirstPage(e) {
614 | e.preventDefault();
615 | showPage(0);
616 | }
617 | function showLastPage(e) {
618 | e.preventDefault();
619 | showPage(_selectedBook.pagination);
620 | }
621 |
622 | function sizeKnown(e) {
623 | var sides = jQuery('#evenSide, #oddSide');
624 | sides.width(libeConfig.pageWidth);
625 | sides.css('max-height', libeConfig.pageHeight + 'px');
626 | var parent = sides.parent();
627 | if (parent) {
628 | parent.width(sides.outerWidth() * 2);
629 | }
630 | jQuery(window).unbind(e);
631 | }
632 |
633 | function unHighlightHoveredPages(e) {
634 | jQuery('#pagesList a.hovered').removeClass('hovered');
635 | }
636 |
637 | function unHighlightCurrentPages(e) {
638 | jQuery('#pagesList a.current').removeClass('current');
639 | }
640 |
641 | function highlightCurrentPages(book, page) {
642 | var current = jQuery('#thumb_' + book + '_' + page);
643 | current.addClass('current');
644 | }
645 |
646 | function highlightHoveredPages(e) {
647 | // remove old highlight
648 | unHighlightHoveredPages();
649 |
650 | var hovered = jQuery(this);
651 | var neighbour = jQuery();
652 |
653 | // if it's an even page, find the one on the right if it exists
654 | if (hovered.hasClass('even')) {
655 | neighbour = hovered.next();
656 | }
657 | // if it's an odd page, find the one on the left if it exists
658 | if (hovered.hasClass('odd')) {
659 | neighbour = hovered.prev();
660 | }
661 |
662 | // highlight the relevant pages
663 | hovered.addClass('hovered');
664 | neighbour.addClass('hovered');
665 | }
666 |
667 | function _changeBook(newBook) {
668 | if (newBook > _publication.books.length) {
669 | newBook = 0;
670 | }
671 | if (_displayedBook != newBook) {
672 | jQuery('#pagesList').empty();
673 | jQuery('#pagesList').css({'left' : 0 });
674 | jQuery('#bookSwitcher a').removeClass('selected');
675 | jQuery('#bookThumb-' + parseInt(newBook, 10)).addClass('selected');
676 | }
677 | _selectedBook = _publication.books[newBook];
678 | _displayedBook = newBook;
679 |
680 | if (typeof _selectedBook == 'undefined' || !_selectedBook.pagination) {
681 | libeConfig.defaultError({'status' : 418});
682 | return false;
683 | }
684 | return true;
685 | }
686 |
687 | function showBook(bookToShow, possiblePage) {
688 |
689 | _hideOldPages();
690 | if (!_changeBook(bookToShow)) {
691 | return false;
692 | }
693 |
694 | var pageToShow = 0;
695 | if (possiblePage >= 0 && possiblePage <= _selectedBook.pagination) {
696 | pageToShow = possiblePage;
697 | }
698 |
699 | jQuery(window).bind('size-known', sizeKnown);
700 |
701 | _pages = new Array(parseInt(_selectedBook.pagination, 10));
702 | var i;
703 | for (i = 0, il = _selectedBook.pages.length; i < il ; i++) {
704 | var page = _selectedBook.pages[i];
705 | _pages[page.page_number] = libePage(page.page_number, page.id, page.paper_channel, page.maps);
706 | }
707 | for (i = 1; i <= _selectedBook.pagination; i++) {
708 | if (!_pages[i]) {
709 | _pages[i] = libePage(i);
710 | }
711 | var a = _pages[i].getThumbnailForList(_displayedBook, 'smallest');
712 | a.attr({'id' : 'thumb_' + _displayedBook + '_' + i});
713 | jQuery('#pagesList').append(a);
714 | a.bind('click', showSelectedPage);
715 | a.bind('mouseover', highlightHoveredPages);
716 | }
717 | jQuery(document).trigger('book-load', [_selectedBook, _displayedBook]);
718 | showPage(pageToShow);
719 | }
720 |
721 | function findPageFromId(id) {
722 | var len = _publication.books.length;
723 | for (var i = 0; i < len; i++) {
724 | var book = _publication.books[i];
725 | var plen = book.pages.length;
726 | for (var j = 0; j < plen; j++) {
727 | var page = book.pages[j];
728 | if (page.id == id) {
729 | return [i, page.page_number]; // don't trust j! book might be incomplete
730 | }
731 | }
732 | }
733 | return null;
734 | }
735 |
736 | function _parseHashtoGetParams(hash) {
737 | if (!hash) {
738 | return [0, 0];
739 | }
740 | if (hash[0] == 'p') {
741 | // if hash starts with "p", try to find a page with this id
742 | var result = findPageFromId(parseInt(hash.substr(1), 10));
743 | if (result) {
744 | return result;
745 | }
746 | }
747 | var bookToShow = parseInt(hash.split('_')[0], 10);
748 | var possiblePage = parseInt(hash.split('_')[1], 10);
749 | return [bookToShow, possiblePage];
750 | }
751 |
752 | function handlePublication(data) {
753 | _publication = data;
754 |
755 | // If the publication data contains an access level, use it as the new
756 | // access level needed.
757 | if (typeof data.access !== 'undefined') {
758 | libeConfig.changeAccessLevelNeeded(parseInt(data.access, 10));
759 | }
760 |
761 | jQuery('#pagesList').bind('mouseout', unHighlightHoveredPages);
762 |
763 | // Trigger a first event before showing any pages
764 | jQuery(document).trigger('publication-beforeload', [_publication, _publicationId]);
765 |
766 | var tmp = [0, 0];
767 | if (location.hash !== "") {
768 | tmp = _parseHashtoGetParams(location.hash.split('#!/')[1]);
769 | }
770 |
771 | showBookList(); // call first, so that we can play with the list in showBook()
772 | showBook((tmp[0] || 0), (tmp[1] || 0));
773 |
774 | jQuery(document).trigger('publication-load', [data, _publicationId]);
775 | }
776 |
777 | function init(publicationId) {
778 | _publicationId = publicationId;
779 |
780 | var url = libeConfig.webservices.publication.replace('{format}', 'json').replace('{id}', publicationId);
781 |
782 | jQuery.ajax({url: url, dataType: "json", success: handlePublication, error: libeConfig.defaultError});
783 |
784 | jQuery('#zoomButton').click(function (e) {
785 | if (_isZoomed) {
786 | quitZoom();
787 | } else {
788 | zoomAtCoordinates(0, 0);
789 | }
790 | return false;
791 | });
792 | jQuery('#previousCorner, #nextCorner').hover(showHoverCorner, hideHoverCorner);
793 | }
794 |
795 | function showBookList() {
796 | var len = _publication.books.length;
797 | for (var i = 0; i < len; i++) {
798 | var page = _publication.books[i].pages[0];
799 | var obj;
800 | if (typeof page == 'undefined' || !page || page.page_number > 1) {
801 | // First page should always be numbered 1. If it's non existant
802 | // or if it's not numbered 1, then the first page is still in
803 | // construction... Fake it.
804 | obj = libePage(1);
805 | } else {
806 | obj = libePage(page.page_number, page.id, page.paper_channel, page.maps);
807 | }
808 |
809 | var a = obj.getThumbnailForList(i);
810 | a.attr('id', "bookThumb-" + i);
811 | a.append('
' + _publication.books[i].name + '');
812 | jQuery('#bookSwitcher').append(a);
813 | a.bind('click', showSelectedPage);
814 | }
815 | }
816 |
817 | return {
818 | init: init,
819 | showPage: showPage,
820 | showPreviousPage: showPreviousPage,
821 | showNextPage: showNextPage,
822 | showSelectedPage: showSelectedPage,
823 | showBook: showBook,
824 | bookDisplayed : bookDisplayed,
825 | pageDisplayed: pageDisplayed
826 | };
827 | }();
828 |
--------------------------------------------------------------------------------