merge js; annotate js

This commit is contained in:
Lu Wang 2013-10-22 15:03:07 +08:00
parent 2eb2289d01
commit cb11032563
7 changed files with 44 additions and 54 deletions

View File

@ -170,7 +170,7 @@ include(${CMAKE_SOURCE_DIR}/src/css_class_names.cmakelists.txt)
configure_file (${CMAKE_SOURCE_DIR}/src/util/css_const.h.in ${CMAKE_SOURCE_DIR}/src/util/css_const.h)
configure_file (${CMAKE_SOURCE_DIR}/share/base.css.in ${CMAKE_SOURCE_DIR}/share/base.css)
configure_file (${CMAKE_SOURCE_DIR}/share/fancy.css.in ${CMAKE_SOURCE_DIR}/share/fancy.css)
configure_file (${CMAKE_SOURCE_DIR}/share/js_src/css_class_names.js.in ${CMAKE_SOURCE_DIR}/share/js_src/css_class_names.js)
configure_file (${CMAKE_SOURCE_DIR}/share/js_src/pdf2htmlEX.js.in ${CMAKE_SOURCE_DIR}/share/js_src/pdf2htmlEX.js)
set(PDF2HTMLEX_SRC ${PDF2HTMLEX_SRC}
src/Param.h
@ -229,13 +229,11 @@ set(PDF2HTMLEX_SRC ${PDF2HTMLEX_SRC}
add_executable(pdf2htmlEX ${PDF2HTMLEX_SRC})
target_link_libraries(pdf2htmlEX ${PDF2HTMLEX_LIBS})
add_custom_target(pdf2htmlEX.js ALL DEPENDS ${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.js)
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.js
add_custom_target(pdf2htmlEX.min.js ALL DEPENDS ${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.min.js)
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.min.js
COMMAND ${CMAKE_SOURCE_DIR}/share/js_src/compile.sh
DEPENDS
${CMAKE_SOURCE_DIR}/share/js_src/css_class_names.js
${CMAKE_SOURCE_DIR}/share/js_src/header.js
${CMAKE_SOURCE_DIR}/share/js_src/viewer.js
${CMAKE_SOURCE_DIR}/share/js_src/pdf2htmlEX.js
)
install (TARGETS pdf2htmlEX DESTINATION bin)
@ -246,7 +244,7 @@ set(PDF2HTMLEX_RESOURCE
${CMAKE_SOURCE_DIR}/share/fancy.css
${CMAKE_SOURCE_DIR}/share/LICENSE
${CMAKE_SOURCE_DIR}/share/manifest
${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.js
${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.min.js
${CMAKE_SOURCE_DIR}/share/pdf2htmlEX-64x64.png
)
install (FILES ${PDF2HTMLEX_RESOURCE} DESTINATION share/pdf2htmlEX)

2
TODO
View File

@ -1,6 +1,4 @@
packaging for 13.10
merge js into one
annot for closure-compiler:https://developers.google.com/closure/compiler/docs/js-for-compiler#generics
minimize css
pdf:mobile device
pdf:miui

View File

@ -8,19 +8,20 @@
BASEDIR=$(dirname $0)
CLOSURE_COMPILER_DIR="$BASEDIR/../../3rdparty/closure-compiler"
OUTPUT="$BASEDIR/../pdf2htmlEX.js"
CLOSURE_COMPILER_JAR="$CLOSURE_COMPILER_DIR/compiler.jar"
EXTERNS="$CLOSURE_COMPILER_DIR/jquery-1.9.js"
INPUT="$BASEDIR/pdf2htmlEX.js"
OUTPUT="$BASEDIR/../pdf2htmlEX.min.js"
(echo 'Building pdf2htmlEX.js with closure-compiler...' && \
java -jar "$CLOSURE_COMPILER_DIR/compiler.jar" \
java -jar "$CLOSURE_COMPILER_JAR" \
--compilation_level ADVANCED_OPTIMIZATIONS \
--process_jquery_primitives \
--externs "$CLOSURE_COMPILER_DIR/jquery-1.9.js" \
--js "$BASEDIR/header.js" \
--js "$BASEDIR/css_class_names.js" \
--js "$BASEDIR/viewer.js" \
--js_output_file "$OUTPUT" 2>/dev/null && \
--externs "$EXTERNS" \
--js "$INPUT" \
--js_output_file "$OUTPUT" && \
echo 'Done.') || \
(echo 'Failed. Read `3rdparty/closure-compiler/README` for more detail.' && \
echo 'Fall back to naive concatenation' && \
cat "$BASEDIR/header.js" "$BASEDIR/css_class_names.js" "$BASEDIR/viewer.js" > "$OUTPUT")
echo 'Using the uncompressed version.' && \
cat "$INPUT" > "$OUTPUT")

View File

@ -1,24 +0,0 @@
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab filetype=javascript : */
/*
* css_class_names.js: declare css classes used in pdf2htmlEX
*
* Copyright 2012,2013 Lu Wang <coolwanglu@gmail.com> and other contributors
*/
/*
* Dependencies:
* jQuery
*/
'use strict';
(function(pdf2htmlEX){
pdf2htmlEX.CSS_CLASS_NAMES = {
page_frame : '@CSS_PAGE_FRAME_CN@',
page_decoration : '@CSS_PAGE_DECORATION_CN@',
page_content_box : '@CSS_PAGE_CONTENT_BOX_CN@',
page_data : '@CSS_PAGE_DATA_CN@',
background_image : '@CSS_BACKGROUND_IMAGE_CN@',
link : '@CSS_LINK_CN@',
__dummy__ : 'no comma'
};
})(window['pdf2htmlEX']);

View File

@ -1,2 +0,0 @@
/** @license pdf2htmlEX.js * Copyright 2012,2013 Lu Wang <coolwanglu@gmail.com> and other contributors * https://github.com/coolwanglu/pdf2htmlex * https://github.com/coolwanglu/pdf2htmlEX/blob/master/share/LICENSE */
window['pdf2htmlEX'] = window['pdf2htmlEX'] || {};

View File

@ -1,6 +1,7 @@
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab filetype=javascript : */
/** @license pdf2htmlEX.js * Copyright 2012,2013 Lu Wang <coolwanglu@gmail.com> and other contributors * https://github.com/coolwanglu/pdf2htmlex * https://github.com/coolwanglu/pdf2htmlEX/blob/master/share/LICENSE */
/*
* viewer.js : a simple UI for pdf2htmlEX
* pdf2htmlEX.js : a simple UI for pdf2htmlEX
*
* Copyright 2012,2013 Lu Wang <coolwanglu@gmail.com> and other contributors
*/
@ -8,7 +9,6 @@
/*
* Dependencies:
* jQuery
* css_class_names.js
*/
/*
@ -34,9 +34,19 @@
/* The namespace */
(function(pdf2htmlEX){
var CSS_CLASS_NAMES = pdf2htmlEX.CSS_CLASS_NAMES;
/** @const */
var CSS_CLASS_NAMES = {
page_frame : '@CSS_PAGE_FRAME_CN@',
page_decoration : '@CSS_PAGE_DECORATION_CN@',
page_content_box : '@CSS_PAGE_CONTENT_BOX_CN@',
page_data : '@CSS_PAGE_DATA_CN@',
background_image : '@CSS_BACKGROUND_IMAGE_CN@',
link : '@CSS_LINK_CN@',
__dummy__ : 'no comma'
};
/* always use string keys to export them in closure-compiler */
/** @const */
var DEFAULT_CONFIG = {
// id of the element to put the pages in
'container_id' : 'page-container',
@ -60,7 +70,9 @@
__dummy__ : 'no comma'
};
/** @const */
var EPS = 1e-6;
/** @const */
var invert = function(ctm) {
var det = ctm[0] * ctm[3] - ctm[1] * ctm[2];
var ictm = new Array();
@ -72,10 +84,15 @@
ictm[5] = (ctm[1] * ctm[4] - ctm[0] * ctm[5]) / det;
return ictm;
};
/** @const */
var transform = function(ctm, pos) {
return [ctm[0] * pos[0] + ctm[2] * pos[1] + ctm[4]
,ctm[1] * pos[0] + ctm[3] * pos[1] + ctm[5]];
};
/**
* @constructor
* @struct
*/
var Page = function(page, container) {
if(page == undefined) return;
@ -111,7 +128,7 @@
this.loaded = true;
}
};
$.extend(Page.prototype, {
$.extend(Page.prototype, /** @lends {Page.prototype} */ {
/* hide & show are for contents, the page frame is still there */
hide : function(){
this.$b.removeClass('opened');
@ -167,7 +184,11 @@
}
});
/* export pdf2htmlEX.Viewer */
/**
* export pdf2htmlEX.Viewer
* @constructor
* @struct
*/
var Viewer = pdf2htmlEX['Viewer'] = function(config) {
/* do nothing if jQuery is not ready */
if(!window.jQuery) return;
@ -180,7 +201,7 @@
$(function(){_.init_after_loading_content();});
};
$.extend(Viewer.prototype, {
$.extend(Viewer.prototype, /** @lends {Viewer.prototype} */ {
scale : 1,
init_before_loading_content : function() {
@ -270,8 +291,6 @@
if (successCallback) successCallback();
}
).fail(function(jqXHR, textStatus, errorThrown){
console.error('error loading page ' + idx + ': ' + textStatus);
// Reset loading token
delete _.pages_loading[idx];
@ -639,4 +658,4 @@
__last_member__ : 'no comma' /*,*/
});
})(window['pdf2htmlEX']);
})(window['pdf2htmlEX'] = window['pdf2htmlEX'] || {});

View File

@ -50,7 +50,7 @@ $css
# entry point of pdf2htmlEX.Viewer
# You can override default configuration by passing an object to the constructor of Viewer
# Refer to DEFAULT_CONFIG in viewer.js for possible keys
@pdf2htmlEX.js
@pdf2htmlEX.min.js
"""
<script>
try{