2019-08-14 22:22:33 -07:00
/ * *
* @ author zhixin wen < wenzhixin2010 @ gmail . com >
* version : 1.12 . 2
* https : //github.com/wenzhixin/bootstrap-table/
* /
( function ( $ ) {
'use strict' ;
// TOOLS DEFINITION
// ======================
var bootstrapVersion = 3 ;
try {
bootstrapVersion = parseInt ( $ . fn . dropdown . Constructor . VERSION , 10 ) ;
} catch ( e ) { }
var bs = {
3 : {
buttonsClass : 'default' ,
iconsPrefix : 'glyphicon' ,
icons : {
paginationSwitchDown : 'glyphicon-collapse-down icon-chevron-down' ,
paginationSwitchUp : 'glyphicon-collapse-up icon-chevron-up' ,
refresh : 'glyphicon-refresh icon-refresh' ,
toggleOff : 'glyphicon-list-alt icon-list-alt' ,
toggleOn : 'glyphicon-list-alt icon-list-alt' ,
columns : 'glyphicon-th icon-th' ,
detailOpen : 'glyphicon-plus icon-plus' ,
detailClose : 'glyphicon-minus icon-minus' ,
fullscreen : 'glyphicon-fullscreen'
} ,
pullClass : 'pull' ,
toobarDropdowHtml : [ '<ul class="dropdown-menu" role="menu">' , '</ul>' ] ,
toobarDropdowItemHtml : '<li role="menuitem"><label>%s</label></li>' ,
pageDropdownHtml : [ '<ul class="dropdown-menu" role="menu">' , '</ul>' ] ,
pageDropdownItemHtml : '<li role="menuitem" class="%s"><a href="#">%s</a></li>'
} ,
4 : {
buttonsClass : 'secondary' ,
iconsPrefix : 'fa' ,
icons : {
paginationSwitchDown : 'fa-toggle-down' ,
paginationSwitchUp : 'fa-toggle-up' ,
refresh : 'fa-refresh' ,
toggleOff : 'fa-toggle-off' ,
toggleOn : 'fa-toggle-on' ,
columns : 'fa-th-list' ,
detailOpen : 'fa-plus' ,
detailClose : 'fa-minus' ,
fullscreen : 'fa-arrows-alt'
} ,
pullClass : 'float' ,
toobarDropdowHtml : [ '<div class="dropdown-menu dropdown-menu-right">' , '</div>' ] ,
toobarDropdowItemHtml : '<label class="dropdown-item">%s</label>' ,
pageDropdownHtml : [ '<div class="dropdown-menu">' , '</div>' ] ,
pageDropdownItemHtml : '<a class="dropdown-item %s" href="#">%s</a>'
}
} [ bootstrapVersion ] ;
var cachedWidth = null ;
// it only does '%s', and return '' when arguments are undefined
var sprintf = function ( str ) {
var args = arguments ,
flag = true ,
i = 1 ;
str = str . replace ( /%s/g , function ( ) {
var arg = args [ i ++ ] ;
if ( typeof arg === 'undefined' ) {
flag = false ;
return '' ;
}
return arg ;
} ) ;
return flag ? str : '' ;
} ;
var getPropertyFromOther = function ( list , from , to , value ) {
var result = '' ;
$ . each ( list , function ( i , item ) {
if ( item [ from ] === value ) {
result = item [ to ] ;
return false ;
}
return true ;
} ) ;
return result ;
} ;
// http://jsfiddle.net/wenyi/47nz7ez9/3/
var setFieldIndex = function ( columns ) {
var i , j , k ,
totalCol = 0 ,
flag = [ ] ;
for ( i = 0 ; i < columns [ 0 ] . length ; i ++ ) {
totalCol += columns [ 0 ] [ i ] . colspan || 1 ;
}
for ( i = 0 ; i < columns . length ; i ++ ) {
flag [ i ] = [ ] ;
for ( j = 0 ; j < totalCol ; j ++ ) {
flag [ i ] [ j ] = false ;
}
}
for ( i = 0 ; i < columns . length ; i ++ ) {
for ( j = 0 ; j < columns [ i ] . length ; j ++ ) {
var r = columns [ i ] [ j ] ,
rowspan = r . rowspan || 1 ,
colspan = r . colspan || 1 ,
index = $ . inArray ( false , flag [ i ] ) ;
if ( colspan === 1 ) {
r . fieldIndex = index ;
// when field is undefined, use index instead
if ( typeof r . field === 'undefined' ) {
r . field = index ;
}
}
for ( k = 0 ; k < rowspan ; k ++ ) {
flag [ i + k ] [ index ] = true ;
}
for ( k = 0 ; k < colspan ; k ++ ) {
flag [ i ] [ index + k ] = true ;
}
}
}
} ;
var getScrollBarWidth = function ( ) {
if ( cachedWidth === null ) {
var inner = $ ( '<p/>' ) . addClass ( 'fixed-table-scroll-inner' ) ,
outer = $ ( '<div/>' ) . addClass ( 'fixed-table-scroll-outer' ) ,
w1 , w2 ;
outer . append ( inner ) ;
$ ( 'body' ) . append ( outer ) ;
w1 = inner [ 0 ] . offsetWidth ;
outer . css ( 'overflow' , 'scroll' ) ;
w2 = inner [ 0 ] . offsetWidth ;
if ( w1 === w2 ) {
w2 = outer [ 0 ] . clientWidth ;
}
outer . remove ( ) ;
cachedWidth = w1 - w2 ;
}
return cachedWidth ;
} ;
var calculateObjectValue = function ( self , name , args , defaultValue ) {
var func = name ;
if ( typeof name === 'string' ) {
// support obj.func1.func2
var names = name . split ( '.' ) ;
if ( names . length > 1 ) {
func = window ;
$ . each ( names , function ( i , f ) {
func = func [ f ] ;
} ) ;
} else {
func = window [ name ] ;
}
}
if ( typeof func === 'object' ) {
return func ;
}
if ( typeof func === 'function' ) {
return func . apply ( self , args || [ ] ) ;
}
if ( ! func && typeof name === 'string' && sprintf . apply ( this , [ name ] . concat ( args ) ) ) {
return sprintf . apply ( this , [ name ] . concat ( args ) ) ;
}
return defaultValue ;
} ;
var compareObjects = function ( objectA , objectB , compareLength ) {
// Create arrays of property names
var getOwnPropertyNames = Object . getOwnPropertyNames || function ( obj ) {
var arr = [ ] ;
for ( var k in obj ) {
if ( obj . hasOwnProperty ( k ) ) {
arr . push ( k ) ;
}
}
return arr ;
} ;
var objectAProperties = getOwnPropertyNames ( objectA ) ,
objectBProperties = getOwnPropertyNames ( objectB ) ,
propName = '' ;
if ( compareLength ) {
// If number of properties is different, objects are not equivalent
if ( objectAProperties . length !== objectBProperties . length ) {
return false ;
}
}
for ( var i = 0 ; i < objectAProperties . length ; i ++ ) {
propName = objectAProperties [ i ] ;
// If the property is not in the object B properties, continue with the next property
if ( $ . inArray ( propName , objectBProperties ) > - 1 ) {
// If values of same property are not equal, objects are not equivalent
if ( objectA [ propName ] !== objectB [ propName ] ) {
return false ;
}
}
}
// If we made it this far, objects are considered equivalent
return true ;
} ;
var escapeHTML = function ( text ) {
if ( typeof text === 'string' ) {
return text
. replace ( /&/g , '&' )
. replace ( /</g , '<' )
. replace ( />/g , '>' )
. replace ( /"/g , '"' )
. replace ( /'/g , ''' )
. replace ( /`/g , '`' ) ;
}
return text ;
} ;
var getRealDataAttr = function ( dataAttr ) {
for ( var attr in dataAttr ) {
var auxAttr = attr . split ( /(?=[A-Z])/ ) . join ( '-' ) . toLowerCase ( ) ;
if ( auxAttr !== attr ) {
dataAttr [ auxAttr ] = dataAttr [ attr ] ;
delete dataAttr [ attr ] ;
}
}
return dataAttr ;
} ;
var getItemField = function ( item , field , escape ) {
var value = item ;
if ( typeof field !== 'string' || item . hasOwnProperty ( field ) ) {
return escape ? escapeHTML ( item [ field ] ) : item [ field ] ;
}
var props = field . split ( '.' ) ;
for ( var p in props ) {
if ( props . hasOwnProperty ( p ) ) {
value = value && value [ props [ p ] ] ;
}
}
return escape ? escapeHTML ( value ) : value ;
} ;
var isIEBrowser = function ( ) {
return ! ! ( navigator . userAgent . indexOf ( "MSIE " ) > 0 || ! ! navigator . userAgent . match ( /Trident.*rv\:11\./ ) ) ;
} ;
var objectKeys = function ( ) {
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
if ( ! Object . keys ) {
Object . keys = ( function ( ) {
var hasOwnProperty = Object . prototype . hasOwnProperty ,
hasDontEnumBug = ! ( { toString : null } ) . propertyIsEnumerable ( 'toString' ) ,
dontEnums = [
'toString' ,
'toLocaleString' ,
'valueOf' ,
'hasOwnProperty' ,
'isPrototypeOf' ,
'propertyIsEnumerable' ,
'constructor'
] ,
dontEnumsLength = dontEnums . length ;
return function ( obj ) {
if ( typeof obj !== 'object' && ( typeof obj !== 'function' || obj === null ) ) {
throw new TypeError ( 'Object.keys called on non-object' ) ;
}
var result = [ ] , prop , i ;
for ( prop in obj ) {
if ( hasOwnProperty . call ( obj , prop ) ) {
result . push ( prop ) ;
}
}
if ( hasDontEnumBug ) {
for ( i = 0 ; i < dontEnumsLength ; i ++ ) {
if ( hasOwnProperty . call ( obj , dontEnums [ i ] ) ) {
result . push ( dontEnums [ i ] ) ;
}
}
}
return result ;
} ;
} ( ) ) ;
}
} ;
// BOOTSTRAP TABLE CLASS DEFINITION
// ======================
var BootstrapTable = function ( el , options ) {
this . options = options ;
this . $el = $ ( el ) ;
this . $el _ = this . $el . clone ( ) ;
this . timeoutId _ = 0 ;
this . timeoutFooter _ = 0 ;
this . init ( ) ;
} ;
BootstrapTable . DEFAULTS = {
classes : 'table table-hover' ,
sortClass : undefined ,
locale : undefined ,
height : undefined ,
undefinedText : '-' ,
sortName : undefined ,
sortOrder : 'asc' ,
sortStable : false ,
rememberOrder : false ,
striped : false ,
columns : [ [ ] ] ,
data : [ ] ,
totalField : 'total' ,
dataField : 'rows' ,
method : 'get' ,
url : undefined ,
ajax : undefined ,
cache : true ,
contentType : 'application/json' ,
dataType : 'json' ,
ajaxOptions : { } ,
queryParams : function ( params ) {
return params ;
} ,
queryParamsType : 'limit' , // undefined
responseHandler : function ( res ) {
return res ;
} ,
pagination : false ,
onlyInfoPagination : false ,
paginationLoop : true ,
sidePagination : 'client' , // client or server
totalRows : 0 , // server side need to set
pageNumber : 1 ,
pageSize : 10 ,
pageList : [ 10 , 25 , 50 , 100 ] ,
paginationHAlign : 'right' , //right, left
paginationVAlign : 'bottom' , //bottom, top, both
paginationDetailHAlign : 'left' , //right, left
paginationPreText : '‹' ,
paginationNextText : '›' ,
search : false ,
searchOnEnterKey : false ,
strictSearch : false ,
searchAlign : 'right' ,
selectItemName : 'btSelectItem' ,
showHeader : true ,
showFooter : false ,
showColumns : false ,
showPaginationSwitch : false ,
showRefresh : false ,
showToggle : false ,
showFullscreen : false ,
smartDisplay : true ,
escape : false ,
minimumCountColumns : 1 ,
idField : undefined ,
uniqueId : undefined ,
cardView : false ,
detailView : false ,
detailFormatter : function ( index , row ) {
return '' ;
} ,
detailFilter : function ( index , row ) {
return true ;
} ,
trimOnSearch : true ,
clickToSelect : false ,
singleSelect : false ,
toolbar : undefined ,
toolbarAlign : 'left' ,
buttonsToolbar : undefined ,
buttonsAlign : 'right' ,
checkboxHeader : true ,
sortable : true ,
silentSort : true ,
maintainSelected : false ,
searchTimeOut : 500 ,
searchText : '' ,
iconSize : undefined ,
buttonsClass : bs . buttonsClass ,
iconsPrefix : bs . iconsPrefix , // glyphicon or fa (font awesome)
icons : bs . icons ,
customSearch : $ . noop ,
customSort : $ . noop ,
ignoreClickToSelectOn : function ( element ) {
return $ . inArray ( element . tagName , [ 'A' , 'BUTTON' ] ) ;
} ,
rowStyle : function ( row , index ) {
return { } ;
} ,
rowAttributes : function ( row , index ) {
return { } ;
} ,
footerStyle : function ( row , index ) {
return { } ;
} ,
onAll : function ( name , args ) {
return false ;
} ,
onClickCell : function ( field , value , row , $element ) {
return false ;
} ,
onDblClickCell : function ( field , value , row , $element ) {
return false ;
} ,
onClickRow : function ( item , $element ) {
return false ;
} ,
onDblClickRow : function ( item , $element ) {
return false ;
} ,
onSort : function ( name , order ) {
return false ;
} ,
onCheck : function ( row ) {
return false ;
} ,
onUncheck : function ( row ) {
return false ;
} ,
onCheckAll : function ( rows ) {
return false ;
} ,
onUncheckAll : function ( rows ) {
return false ;
} ,
onCheckSome : function ( rows ) {
return false ;
} ,
onUncheckSome : function ( rows ) {
return false ;
} ,
onLoadSuccess : function ( data ) {
return false ;
} ,
onLoadError : function ( status ) {
return false ;
} ,
onColumnSwitch : function ( field , checked ) {
return false ;
} ,
onPageChange : function ( number , size ) {
return false ;
} ,
onSearch : function ( text ) {
return false ;
} ,
onToggle : function ( cardView ) {
return false ;
} ,
onPreBody : function ( data ) {
return false ;
} ,
onPostBody : function ( ) {
return false ;
} ,
onPostHeader : function ( ) {
return false ;
} ,
onExpandRow : function ( index , row , $detail ) {
return false ;
} ,
onCollapseRow : function ( index , row ) {
return false ;
} ,
onRefreshOptions : function ( options ) {
return false ;
} ,
onRefresh : function ( params ) {
return false ;
} ,
onResetView : function ( ) {
return false ;
} ,
onScrollBody : function ( ) {
return false ;
}
} ;
BootstrapTable . LOCALES = { } ;
BootstrapTable . LOCALES [ 'en-US' ] = BootstrapTable . LOCALES . en = {
formatLoadingMessage : function ( ) {
return 'Loading, please wait...' ;
} ,
formatRecordsPerPage : function ( pageNumber ) {
return sprintf ( '%s rows per page' , pageNumber ) ;
} ,
formatShowingRows : function ( pageFrom , pageTo , totalRows ) {
return sprintf ( 'Showing %s to %s of %s rows' , pageFrom , pageTo , totalRows ) ;
} ,
formatDetailPagination : function ( totalRows ) {
return sprintf ( 'Showing %s rows' , totalRows ) ;
} ,
formatSearch : function ( ) {
return 'Search' ;
} ,
formatNoMatches : function ( ) {
return 'No matching records found' ;
} ,
formatPaginationSwitch : function ( ) {
return 'Hide/Show pagination' ;
} ,
formatRefresh : function ( ) {
return 'Refresh' ;
} ,
formatToggle : function ( ) {
return 'Toggle' ;
} ,
formatFullscreen : function ( ) {
return 'Fullscreen' ;
} ,
formatColumns : function ( ) {
return 'Columns' ;
} ,
formatAllRows : function ( ) {
return 'All' ;
}
} ;
$ . extend ( BootstrapTable . DEFAULTS , BootstrapTable . LOCALES [ 'en-US' ] ) ;
BootstrapTable . COLUMN _DEFAULTS = {
radio : false ,
checkbox : false ,
checkboxEnabled : true ,
field : undefined ,
title : undefined ,
titleTooltip : undefined ,
'class' : undefined ,
align : undefined , // left, right, center
halign : undefined , // left, right, center
falign : undefined , // left, right, center
valign : undefined , // top, middle, bottom
width : undefined ,
sortable : false ,
order : 'asc' , // asc, desc
visible : true ,
switchable : true ,
clickToSelect : true ,
formatter : undefined ,
footerFormatter : undefined ,
events : undefined ,
sorter : undefined ,
sortName : undefined ,
cellStyle : undefined ,
searchable : true ,
searchFormatter : true ,
cardVisible : true ,
escape : false ,
showSelectTitle : false
} ;
BootstrapTable . EVENTS = {
'all.bs.table' : 'onAll' ,
'click-cell.bs.table' : 'onClickCell' ,
'dbl-click-cell.bs.table' : 'onDblClickCell' ,
'click-row.bs.table' : 'onClickRow' ,
'dbl-click-row.bs.table' : 'onDblClickRow' ,
'sort.bs.table' : 'onSort' ,
'check.bs.table' : 'onCheck' ,
'uncheck.bs.table' : 'onUncheck' ,
'check-all.bs.table' : 'onCheckAll' ,
'uncheck-all.bs.table' : 'onUncheckAll' ,
'check-some.bs.table' : 'onCheckSome' ,
'uncheck-some.bs.table' : 'onUncheckSome' ,
'load-success.bs.table' : 'onLoadSuccess' ,
'load-error.bs.table' : 'onLoadError' ,
'column-switch.bs.table' : 'onColumnSwitch' ,
'page-change.bs.table' : 'onPageChange' ,
'search.bs.table' : 'onSearch' ,
'toggle.bs.table' : 'onToggle' ,
'pre-body.bs.table' : 'onPreBody' ,
'post-body.bs.table' : 'onPostBody' ,
'post-header.bs.table' : 'onPostHeader' ,
'expand-row.bs.table' : 'onExpandRow' ,
'collapse-row.bs.table' : 'onCollapseRow' ,
'refresh-options.bs.table' : 'onRefreshOptions' ,
'reset-view.bs.table' : 'onResetView' ,
'refresh.bs.table' : 'onRefresh' ,
'scroll-body.bs.table' : 'onScrollBody'
} ;
BootstrapTable . prototype . init = function ( ) {
this . initLocale ( ) ;
this . initContainer ( ) ;
this . initTable ( ) ;
this . initHeader ( ) ;
this . initData ( ) ;
this . initHiddenRows ( ) ;
this . initFooter ( ) ;
this . initToolbar ( ) ;
this . initPagination ( ) ;
this . initBody ( ) ;
this . initSearchText ( ) ;
this . initServer ( ) ;
} ;
BootstrapTable . prototype . initLocale = function ( ) {
if ( this . options . locale ) {
var parts = this . options . locale . split ( /-|_/ ) ;
parts [ 0 ] . toLowerCase ( ) ;
if ( parts [ 1 ] ) {
parts [ 1 ] . toUpperCase ( ) ;
}
if ( $ . fn . bootstrapTable . locales [ this . options . locale ] ) {
// locale as requested
$ . extend ( this . options , $ . fn . bootstrapTable . locales [ this . options . locale ] ) ;
} else if ( $ . fn . bootstrapTable . locales [ parts . join ( '-' ) ] ) {
// locale with sep set to - (in case original was specified with _)
$ . extend ( this . options , $ . fn . bootstrapTable . locales [ parts . join ( '-' ) ] ) ;
} else if ( $ . fn . bootstrapTable . locales [ parts [ 0 ] ] ) {
// short locale language code (i.e. 'en')
$ . extend ( this . options , $ . fn . bootstrapTable . locales [ parts [ 0 ] ] ) ;
}
}
} ;
BootstrapTable . prototype . initContainer = function ( ) {
this . $container = $ ( [
'<div class="bootstrap-table">' ,
'<div class="fixed-table-toolbar"></div>' ,
this . options . paginationVAlign === 'top' || this . options . paginationVAlign === 'both' ?
'<div class="fixed-table-pagination" style="clear: both;"></div>' :
'' ,
'<div class="fixed-table-container">' ,
'<div class="fixed-table-header"><table></table></div>' ,
'<div class="fixed-table-body">' ,
'<div class="fixed-table-loading">' ,
this . options . formatLoadingMessage ( ) ,
'</div>' ,
'</div>' ,
'<div class="fixed-table-footer"><table><tr></tr></table></div>' ,
'</div>' ,
this . options . paginationVAlign === 'bottom' || this . options . paginationVAlign === 'both' ?
'<div class="fixed-table-pagination"></div>' :
'' ,
'</div>'
] . join ( '' ) ) ;
this . $container . insertAfter ( this . $el ) ;
this . $tableContainer = this . $container . find ( '.fixed-table-container' ) ;
this . $tableHeader = this . $container . find ( '.fixed-table-header' ) ;
this . $tableBody = this . $container . find ( '.fixed-table-body' ) ;
this . $tableLoading = this . $container . find ( '.fixed-table-loading' ) ;
this . $tableFooter = this . $container . find ( '.fixed-table-footer' ) ;
// checking if custom table-toolbar exists or not
if ( this . options . buttonsToolbar ) {
this . $toolbar = $ ( 'body' ) . find ( this . options . buttonsToolbar ) ;
} else {
this . $toolbar = this . $container . find ( '.fixed-table-toolbar' ) ;
}
this . $pagination = this . $container . find ( '.fixed-table-pagination' ) ;
this . $tableBody . append ( this . $el ) ;
this . $container . after ( '<div class="clearfix"></div>' ) ;
this . $el . addClass ( this . options . classes ) ;
if ( this . options . striped ) {
this . $el . addClass ( 'table-striped' ) ;
}
if ( $ . inArray ( 'table-no-bordered' , this . options . classes . split ( ' ' ) ) !== - 1 ) {
this . $tableContainer . addClass ( 'table-no-bordered' ) ;
}
} ;
BootstrapTable . prototype . initTable = function ( ) {
var that = this ,
columns = [ ] ,
data = [ ] ;
this . $header = this . $el . find ( '>thead' ) ;
if ( ! this . $header . length ) {
this . $header = $ ( '<thead></thead>' ) . appendTo ( this . $el ) ;
}
this . $header . find ( 'tr' ) . each ( function ( ) {
var column = [ ] ;
$ ( this ) . find ( 'th' ) . each ( function ( ) {
// Fix #2014 - getFieldIndex and elsewhere assume this is string, causes issues if not
if ( typeof $ ( this ) . data ( 'field' ) !== 'undefined' ) {
$ ( this ) . data ( 'field' , $ ( this ) . data ( 'field' ) + '' ) ;
}
column . push ( $ . extend ( { } , {
title : $ ( this ) . html ( ) ,
'class' : $ ( this ) . attr ( 'class' ) ,
titleTooltip : $ ( this ) . attr ( 'title' ) ,
rowspan : $ ( this ) . attr ( 'rowspan' ) ? + $ ( this ) . attr ( 'rowspan' ) : undefined ,
colspan : $ ( this ) . attr ( 'colspan' ) ? + $ ( this ) . attr ( 'colspan' ) : undefined
} , $ ( this ) . data ( ) ) ) ;
} ) ;
columns . push ( column ) ;
} ) ;
if ( ! $ . isArray ( this . options . columns [ 0 ] ) ) {
this . options . columns = [ this . options . columns ] ;
}
this . options . columns = $ . extend ( true , [ ] , columns , this . options . columns ) ;
this . columns = [ ] ;
this . fieldsColumnsIndex = [ ] ;
setFieldIndex ( this . options . columns ) ;
$ . each ( this . options . columns , function ( i , columns ) {
$ . each ( columns , function ( j , column ) {
column = $ . extend ( { } , BootstrapTable . COLUMN _DEFAULTS , column ) ;
if ( typeof column . fieldIndex !== 'undefined' ) {
that . columns [ column . fieldIndex ] = column ;
that . fieldsColumnsIndex [ column . field ] = column . fieldIndex ;
}
that . options . columns [ i ] [ j ] = column ;
} ) ;
} ) ;
// if options.data is setting, do not process tbody data
if ( this . options . data . length ) {
return ;
}
var m = [ ] ;
this . $el . find ( '>tbody>tr' ) . each ( function ( y ) {
var row = { } ;
// save tr's id, class and data-* attributes
row . _id = $ ( this ) . attr ( 'id' ) ;
row . _class = $ ( this ) . attr ( 'class' ) ;
row . _data = getRealDataAttr ( $ ( this ) . data ( ) ) ;
$ ( this ) . find ( '>td' ) . each ( function ( x ) {
var $this = $ ( this ) ,
cspan = + $this . attr ( 'colspan' ) || 1 ,
rspan = + $this . attr ( 'rowspan' ) || 1 ,
tx ,
ty ;
// skip already occupied cells in current row
for ( ; m [ y ] && m [ y ] [ x ] ; x ++ ) ;
for ( tx = x ; tx < x + cspan ; tx ++ ) { //mark matrix elements occupied by current cell with true
for ( ty = y ; ty < y + rspan ; ty ++ ) {
if ( ! m [ ty ] ) { //fill missing rows
m [ ty ] = [ ] ;
}
m [ ty ] [ tx ] = true ;
}
}
var field = that . columns [ x ] . field ;
row [ field ] = $ ( this ) . html ( ) ;
// save td's id, class and data-* attributes
row [ '_' + field + '_id' ] = $ ( this ) . attr ( 'id' ) ;
row [ '_' + field + '_class' ] = $ ( this ) . attr ( 'class' ) ;
row [ '_' + field + '_rowspan' ] = $ ( this ) . attr ( 'rowspan' ) ;
row [ '_' + field + '_colspan' ] = $ ( this ) . attr ( 'colspan' ) ;
row [ '_' + field + '_title' ] = $ ( this ) . attr ( 'title' ) ;
row [ '_' + field + '_data' ] = getRealDataAttr ( $ ( this ) . data ( ) ) ;
} ) ;
data . push ( row ) ;
} ) ;
this . options . data = data ;
if ( data . length ) this . fromHtml = true ;
} ;
BootstrapTable . prototype . initHeader = function ( ) {
var that = this ,
visibleColumns = { } ,
html = [ ] ;
this . header = {
fields : [ ] ,
styles : [ ] ,
classes : [ ] ,
formatters : [ ] ,
events : [ ] ,
sorters : [ ] ,
sortNames : [ ] ,
cellStyles : [ ] ,
searchables : [ ]
} ;
$ . each ( this . options . columns , function ( i , columns ) {
html . push ( '<tr>' ) ;
if ( i === 0 && ! that . options . cardView && that . options . detailView ) {
html . push ( sprintf ( '<th class="detail" rowspan="%s"><div class="fht-cell"></div></th>' ,
that . options . columns . length ) ) ;
}
$ . each ( columns , function ( j , column ) {
var text = '' ,
halign = '' , // header align style
align = '' , // body align style
style = '' ,
class _ = sprintf ( ' class="%s"' , column [ 'class' ] ) ,
order = that . options . sortOrder || column . order ,
unitWidth = 'px' ,
width = column . width ;
if ( column . width !== undefined && ( ! that . options . cardView ) ) {
if ( typeof column . width === 'string' ) {
if ( column . width . indexOf ( '%' ) !== - 1 ) {
unitWidth = '%' ;
}
}
}
if ( column . width && typeof column . width === 'string' ) {
width = column . width . replace ( '%' , '' ) . replace ( 'px' , '' ) ;
}
halign = sprintf ( 'text-align: %s; ' , column . halign ? column . halign : column . align ) ;
align = sprintf ( 'text-align: %s; ' , column . align ) ;
style = sprintf ( 'vertical-align: %s; ' , column . valign ) ;
style += sprintf ( 'width: %s; ' , ( column . checkbox || column . radio ) && ! width ?
( ! column . showSelectTitle ? '36px' : undefined ) :
( width ? width + unitWidth : undefined ) ) ;
if ( typeof column . fieldIndex !== 'undefined' ) {
that . header . fields [ column . fieldIndex ] = column . field ;
that . header . styles [ column . fieldIndex ] = align + style ;
that . header . classes [ column . fieldIndex ] = class _ ;
that . header . formatters [ column . fieldIndex ] = column . formatter ;
that . header . events [ column . fieldIndex ] = column . events ;
that . header . sorters [ column . fieldIndex ] = column . sorter ;
that . header . sortNames [ column . fieldIndex ] = column . sortName ;
that . header . cellStyles [ column . fieldIndex ] = column . cellStyle ;
that . header . searchables [ column . fieldIndex ] = column . searchable ;
if ( ! column . visible ) {
return ;
}
if ( that . options . cardView && ( ! column . cardVisible ) ) {
return ;
}
visibleColumns [ column . field ] = column ;
}
html . push ( '<th' + sprintf ( ' title="%s"' , column . titleTooltip ) ,
column . checkbox || column . radio ?
sprintf ( ' class="bs-checkbox %s"' , column [ 'class' ] || '' ) :
class _ ,
sprintf ( ' style="%s"' , halign + style ) ,
sprintf ( ' rowspan="%s"' , column . rowspan ) ,
sprintf ( ' colspan="%s"' , column . colspan ) ,
sprintf ( ' data-field="%s"' , column . field ) ,
j === 0 && column . fieldIndex ? ' data-not-first-th' : '' ,
'>' ) ;
html . push ( sprintf ( '<div class="th-inner %s">' , that . options . sortable && column . sortable ?
'sortable both' : '' ) ) ;
text = that . options . escape ? escapeHTML ( column . title ) : column . title ;
var title = text ;
if ( column . checkbox ) {
text = '' ;
if ( ! that . options . singleSelect && that . options . checkboxHeader ) {
text = '<input name="btSelectAll" type="checkbox" />' ;
}
that . header . stateField = column . field ;
}
if ( column . radio ) {
text = '' ;
that . header . stateField = column . field ;
that . options . singleSelect = true ;
}
if ( ! text && column . showSelectTitle ) {
text += title ;
}
html . push ( text ) ;
html . push ( '</div>' ) ;
html . push ( '<div class="fht-cell"></div>' ) ;
html . push ( '</div>' ) ;
html . push ( '</th>' ) ;
} ) ;
html . push ( '</tr>' ) ;
} ) ;
this . $header . html ( html . join ( '' ) ) ;
this . $header . find ( 'th[data-field]' ) . each ( function ( i ) {
$ ( this ) . data ( visibleColumns [ $ ( this ) . data ( 'field' ) ] ) ;
} ) ;
this . $container . off ( 'click' , '.th-inner' ) . on ( 'click' , '.th-inner' , function ( event ) {
var $this = $ ( this ) ;
if ( that . options . detailView && ! $this . parent ( ) . hasClass ( 'bs-checkbox' ) ) {
if ( $this . closest ( '.bootstrap-table' ) [ 0 ] !== that . $container [ 0 ] ) {
return false ;
}
}
if ( that . options . sortable && $this . parent ( ) . data ( ) . sortable ) {
that . onSort ( event ) ;
}
} ) ;
this . $header . children ( ) . children ( ) . off ( 'keypress' ) . on ( 'keypress' , function ( event ) {
if ( that . options . sortable && $ ( this ) . data ( ) . sortable ) {
var code = event . keyCode || event . which ;
if ( code == 13 ) { //Enter keycode
that . onSort ( event ) ;
}
}
} ) ;
$ ( window ) . off ( 'resize.bootstrap-table' ) ;
if ( ! this . options . showHeader || this . options . cardView ) {
this . $header . hide ( ) ;
this . $tableHeader . hide ( ) ;
this . $tableLoading . css ( 'top' , 0 ) ;
} else {
this . $header . show ( ) ;
this . $tableHeader . show ( ) ;
this . $tableLoading . css ( 'top' , this . $header . outerHeight ( ) + 1 ) ;
// Assign the correct sortable arrow
this . getCaret ( ) ;
$ ( window ) . on ( 'resize.bootstrap-table' , $ . proxy ( this . resetWidth , this ) ) ;
}
this . $selectAll = this . $header . find ( '[name="btSelectAll"]' ) ;
this . $selectAll . off ( 'click' ) . on ( 'click' , function ( ) {
var checked = $ ( this ) . prop ( 'checked' ) ;
that [ checked ? 'checkAll' : 'uncheckAll' ] ( ) ;
that . updateSelected ( ) ;
} ) ;
} ;
BootstrapTable . prototype . initFooter = function ( ) {
if ( ! this . options . showFooter || this . options . cardView ) {
this . $tableFooter . hide ( ) ;
} else {
this . $tableFooter . show ( ) ;
}
} ;
/ * *
* @ param data
* @ param type : append / prepend
* /
BootstrapTable . prototype . initData = function ( data , type ) {
if ( type === 'append' ) {
this . options . data = this . options . data . concat ( data ) ;
} else if ( type === 'prepend' ) {
this . options . data = [ ] . concat ( data ) . concat ( this . options . data ) ;
} else {
this . options . data = data || this . options . data ;
}
this . data = this . options . data ;
if ( this . options . sidePagination === 'server' ) {
return ;
}
this . initSort ( ) ;
} ;
BootstrapTable . prototype . initSort = function ( ) {
var that = this ,
name = this . options . sortName ,
order = this . options . sortOrder === 'desc' ? - 1 : 1 ,
index = $ . inArray ( this . options . sortName , this . header . fields ) ,
timeoutId = 0 ;
if ( this . options . customSort !== $ . noop ) {
this . options . customSort . apply ( this , [ this . options . sortName , this . options . sortOrder ] ) ;
return ;
}
if ( index !== - 1 ) {
if ( this . options . sortStable ) {
$ . each ( this . data , function ( i , row ) {
row . _position = i ;
} ) ;
}
this . data . sort ( function ( a , b ) {
if ( that . header . sortNames [ index ] ) {
name = that . header . sortNames [ index ] ;
}
var aa = getItemField ( a , name , that . options . escape ) ,
bb = getItemField ( b , name , that . options . escape ) ,
value = calculateObjectValue ( that . header , that . header . sorters [ index ] , [ aa , bb , a , b ] ) ;
if ( value !== undefined ) {
if ( that . options . sortStable && value === 0 ) {
return a . _position - b . _position ;
}
return order * value ;
}
// Fix #161: undefined or null string sort bug.
if ( aa === undefined || aa === null ) {
aa = '' ;
}
if ( bb === undefined || bb === null ) {
bb = '' ;
}
if ( that . options . sortStable && aa === bb ) {
aa = a . _position ;
bb = b . _position ;
return a . _position - b . _position ;
}
// IF both values are numeric, do a numeric comparison
if ( $ . isNumeric ( aa ) && $ . isNumeric ( bb ) ) {
// Convert numerical values form string to float.
aa = parseFloat ( aa ) ;
bb = parseFloat ( bb ) ;
if ( aa < bb ) {
return order * - 1 ;
}
return order ;
}
if ( aa === bb ) {
return 0 ;
}
// If value is not a string, convert to string
if ( typeof aa !== 'string' ) {
aa = aa . toString ( ) ;
}
if ( aa . localeCompare ( bb ) === - 1 ) {
return order * - 1 ;
}
return order ;
} ) ;
if ( this . options . sortClass !== undefined ) {
clearTimeout ( timeoutId ) ;
timeoutId = setTimeout ( function ( ) {
that . $el . removeClass ( that . options . sortClass ) ;
var index = that . $header . find ( sprintf ( '[data-field="%s"]' ,
that . options . sortName ) . index ( ) + 1 ) ;
that . $el . find ( sprintf ( 'tr td:nth-child(%s)' , index ) )
. addClass ( that . options . sortClass ) ;
} , 250 ) ;
}
}
} ;
BootstrapTable . prototype . onSort = function ( event ) {
var $this = event . type === "keypress" ? $ ( event . currentTarget ) : $ ( event . currentTarget ) . parent ( ) ,
$this _ = this . $header . find ( 'th' ) . eq ( $this . index ( ) ) ;
this . $header . add ( this . $header _ ) . find ( 'span.order' ) . remove ( ) ;
if ( this . options . sortName === $this . data ( 'field' ) ) {
this . options . sortOrder = this . options . sortOrder === 'asc' ? 'desc' : 'asc' ;
} else {
this . options . sortName = $this . data ( 'field' ) ;
if ( this . options . rememberOrder ) {
this . options . sortOrder = $this . data ( 'order' ) === 'asc' ? 'desc' : 'asc' ;
} else {
this . options . sortOrder = this . columns [ this . fieldsColumnsIndex [ $this . data ( 'field' ) ] ] . order ;
}
}
this . trigger ( 'sort' , this . options . sortName , this . options . sortOrder ) ;
$this . add ( $this _ ) . data ( 'order' , this . options . sortOrder ) ;
// Assign the correct sortable arrow
this . getCaret ( ) ;
if ( this . options . sidePagination === 'server' ) {
this . initServer ( this . options . silentSort ) ;
return ;
}
this . initSort ( ) ;
this . initBody ( ) ;
} ;
BootstrapTable . prototype . initToolbar = function ( ) {
var that = this ,
html = [ ] ,
timeoutId = 0 ,
$keepOpen ,
$search ,
switchableCount = 0 ;
if ( this . $toolbar . find ( '.bs-bars' ) . children ( ) . length ) {
$ ( 'body' ) . append ( $ ( this . options . toolbar ) ) ;
}
this . $toolbar . html ( '' ) ;
if ( typeof this . options . toolbar === 'string' || typeof this . options . toolbar === 'object' ) {
$ ( sprintf ( '<div class="bs-bars %s-%s"></div>' , bs . pullClass , this . options . toolbarAlign ) )
. appendTo ( this . $toolbar )
. append ( $ ( this . options . toolbar ) ) ;
}
// showColumns, showToggle, showRefresh
html = [ sprintf ( '<div class="columns columns-%s btn-group %s-%s">' ,
this . options . buttonsAlign , bs . pullClass , this . options . buttonsAlign ) ] ;
if ( typeof this . options . icons === 'string' ) {
this . options . icons = calculateObjectValue ( null , this . options . icons ) ;
}
if ( this . options . showPaginationSwitch ) {
html . push ( sprintf ( '<button class="btn' +
sprintf ( ' btn-%s' , this . options . buttonsClass ) +
sprintf ( ' btn-%s' , this . options . iconSize ) +
'" type="button" name="paginationSwitch" aria-label="pagination Switch" title="%s">' ,
this . options . formatPaginationSwitch ( ) ) ,
sprintf ( '<i class="%s %s"></i>' , this . options . iconsPrefix , this . options . icons . paginationSwitchDown ) ,
'</button>' ) ;
}
if ( this . options . showFullscreen ) {
this . $toolbar . find ( 'button[name="fullscreen"]' )
. off ( 'click' ) . on ( 'click' , $ . proxy ( this . toggleFullscreen , this ) ) ;
}
if ( this . options . showRefresh ) {
html . push ( sprintf ( '<button class="btn' +
sprintf ( ' btn-%s' , this . options . buttonsClass ) +
sprintf ( ' btn-%s' , this . options . iconSize ) +
'" type="button" name="refresh" aria-label="refresh" title="%s">' ,
this . options . formatRefresh ( ) ) ,
sprintf ( '<i class="%s %s"></i>' , this . options . iconsPrefix , this . options . icons . refresh ) ,
'</button>' ) ;
}
if ( this . options . showToggle ) {
html . push ( sprintf ( '<button class="btn' +
sprintf ( ' btn-%s' , this . options . buttonsClass ) +
sprintf ( ' btn-%s' , this . options . iconSize ) +
'" type="button" name="toggle" aria-label="toggle" title="%s">' ,
this . options . formatToggle ( ) ) ,
sprintf ( '<i class="%s %s"></i>' , this . options . iconsPrefix , this . options . icons . toggleOff ) ,
'</button>' ) ;
}
if ( this . options . showFullscreen ) {
html . push ( sprintf ( '<button class="btn' +
sprintf ( ' btn-%s' , this . options . buttonsClass ) +
sprintf ( ' btn-%s' , this . options . iconSize ) +
'" type="button" name="fullscreen" aria-label="fullscreen" title="%s">' ,
this . options . formatFullscreen ( ) ) ,
sprintf ( '<i class="%s %s"></i>' , this . options . iconsPrefix , this . options . icons . fullscreen ) ,
'</button>' ) ;
}
if ( this . options . showColumns ) {
html . push ( sprintf ( '<div class="keep-open btn-group" title="%s">' ,
this . options . formatColumns ( ) ) ,
'<button type="button" aria-label="columns" class="btn' +
sprintf ( ' btn-%s' , this . options . buttonsClass ) +
sprintf ( ' btn-%s' , this . options . iconSize ) +
' dropdown-toggle" data-toggle="dropdown">' ,
sprintf ( '<i class="%s %s"></i>' , this . options . iconsPrefix , this . options . icons . columns ) ,
' <span class="caret"></span>' ,
'</button>' ,
bs . toobarDropdowHtml [ 0 ] ) ;
$ . each ( this . columns , function ( i , column ) {
if ( column . radio || column . checkbox ) {
return ;
}
if ( that . options . cardView && ! column . cardVisible ) {
return ;
}
var checked = column . visible ? ' checked="checked"' : '' ;
if ( column . switchable ) {
html . push ( sprintf ( bs . toobarDropdowItemHtml ,
sprintf ( '<input type="checkbox" data-field="%s" value="%s"%s> %s' ,
column . field , i , checked , column . title ) ) ) ;
switchableCount ++ ;
}
} ) ;
html . push ( bs . toobarDropdowHtml [ 1 ] , '</div>' ) ;
}
html . push ( '</div>' ) ;
// Fix #188: this.showToolbar is for extensions
if ( this . showToolbar || html . length > 2 ) {
this . $toolbar . append ( html . join ( '' ) ) ;
}
if ( this . options . showPaginationSwitch ) {
this . $toolbar . find ( 'button[name="paginationSwitch"]' )
. off ( 'click' ) . on ( 'click' , $ . proxy ( this . togglePagination , this ) ) ;
}
if ( this . options . showRefresh ) {
this . $toolbar . find ( 'button[name="refresh"]' )
. off ( 'click' ) . on ( 'click' , $ . proxy ( this . refresh , this ) ) ;
}
if ( this . options . showToggle ) {
this . $toolbar . find ( 'button[name="toggle"]' )
. off ( 'click' ) . on ( 'click' , function ( ) {
that . toggleView ( ) ;
} ) ;
}
if ( this . options . showColumns ) {
$keepOpen = this . $toolbar . find ( '.keep-open' ) ;
if ( switchableCount <= this . options . minimumCountColumns ) {
$keepOpen . find ( 'input' ) . prop ( 'disabled' , true ) ;
}
$keepOpen . find ( 'li' ) . off ( 'click' ) . on ( 'click' , function ( event ) {
event . stopImmediatePropagation ( ) ;
} ) ;
$keepOpen . find ( 'input' ) . off ( 'click' ) . on ( 'click' , function ( ) {
var $this = $ ( this ) ;
that . toggleColumn ( $ ( this ) . val ( ) , $this . prop ( 'checked' ) , false ) ;
that . trigger ( 'column-switch' , $ ( this ) . data ( 'field' ) , $this . prop ( 'checked' ) ) ;
} ) ;
}
if ( this . options . search ) {
html = [ ] ;
html . push (
sprintf ( '<div class="%s-%s search">' , bs . pullClass , this . options . searchAlign ) ,
sprintf ( '<input class="form-control' +
sprintf ( ' input-%s' , this . options . iconSize ) +
'" type="text" placeholder="%s">' ,
this . options . formatSearch ( ) ) ,
'</div>' ) ;
this . $toolbar . append ( html . join ( '' ) ) ;
$search = this . $toolbar . find ( '.search input' ) ;
$search . off ( 'keyup drop blur' ) . on ( 'keyup drop blur' , function ( event ) {
if ( that . options . searchOnEnterKey && event . keyCode !== 13 ) {
return ;
}
if ( $ . inArray ( event . keyCode , [ 37 , 38 , 39 , 40 ] ) > - 1 ) {
return ;
}
clearTimeout ( timeoutId ) ; // doesn't matter if it's 0
timeoutId = setTimeout ( function ( ) {
that . onSearch ( event ) ;
} , that . options . searchTimeOut ) ;
} ) ;
if ( isIEBrowser ( ) ) {
$search . off ( 'mouseup' ) . on ( 'mouseup' , function ( event ) {
clearTimeout ( timeoutId ) ; // doesn't matter if it's 0
timeoutId = setTimeout ( function ( ) {
that . onSearch ( event ) ;
} , that . options . searchTimeOut ) ;
} ) ;
}
}
} ;
BootstrapTable . prototype . onSearch = function ( event ) {
var text = $ . trim ( $ ( event . currentTarget ) . val ( ) ) ;
// trim search input
if ( this . options . trimOnSearch && $ ( event . currentTarget ) . val ( ) !== text ) {
$ ( event . currentTarget ) . val ( text ) ;
}
if ( text === this . searchText ) {
return ;
}
this . searchText = text ;
this . options . searchText = text ;
this . options . pageNumber = 1 ;
this . initSearch ( ) ;
if ( event . firedByInitSearchText ) {
if ( this . options . sidePagination === 'client' ) {
this . updatePagination ( ) ;
}
} else {
this . updatePagination ( ) ;
}
this . trigger ( 'search' , text ) ;
} ;
BootstrapTable . prototype . initSearch = function ( ) {
var that = this ;
if ( this . options . sidePagination !== 'server' ) {
if ( this . options . customSearch !== $ . noop ) {
window [ this . options . customSearch ] . apply ( this , [ this . searchText ] ) ;
return ;
}
var s = this . searchText && ( this . options . escape ?
escapeHTML ( this . searchText ) : this . searchText ) . toLowerCase ( ) ;
var f = $ . isEmptyObject ( this . filterColumns ) ? null : this . filterColumns ;
// Check filter
this . data = f ? $ . grep ( this . options . data , function ( item , i ) {
for ( var key in f ) {
if ( $ . isArray ( f [ key ] ) && $ . inArray ( item [ key ] , f [ key ] ) === - 1 ||
! $ . isArray ( f [ key ] ) && item [ key ] !== f [ key ] ) {
return false ;
}
}
return true ;
} ) : this . options . data ;
this . data = s ? $ . grep ( this . data , function ( item , i ) {
for ( var j = 0 ; j < that . header . fields . length ; j ++ ) {
if ( ! that . header . searchables [ j ] ) {
continue ;
}
var key = $ . isNumeric ( that . header . fields [ j ] ) ? parseInt ( that . header . fields [ j ] , 10 ) : that . header . fields [ j ] ;
var column = that . columns [ that . fieldsColumnsIndex [ key ] ] ;
var value ;
if ( typeof key === 'string' ) {
value = item ;
var props = key . split ( '.' ) ;
for ( var prop _index = 0 ; prop _index < props . length ; prop _index ++ ) {
if ( value [ props [ prop _index ] ] != null ) {
value = value [ props [ prop _index ] ] ;
}
}
// Fix #142: respect searchForamtter boolean
if ( column && column . searchFormatter ) {
value = calculateObjectValue ( column ,
that . header . formatters [ j ] , [ value , item , i ] , value ) ;
}
} else {
value = item [ key ] ;
}
if ( typeof value === 'string' || typeof value === 'number' ) {
if ( that . options . strictSearch ) {
if ( ( value + '' ) . toLowerCase ( ) === s ) {
return true ;
}
} else {
if ( ( value + '' ) . toLowerCase ( ) . indexOf ( s ) !== - 1 ) {
return true ;
}
}
}
}
return false ;
} ) : this . data ;
}
} ;
BootstrapTable . prototype . initPagination = function ( ) {
if ( ! this . options . pagination ) {
this . $pagination . hide ( ) ;
return ;
} else {
this . $pagination . show ( ) ;
}
var that = this ,
html = [ ] ,
$allSelected = false ,
i , from , to ,
$pageList ,
$pre ,
$next ,
$number ,
data = this . getData ( ) ,
pageList = this . options . pageList ;
if ( this . options . sidePagination !== 'server' ) {
this . options . totalRows = data . length ;
}
this . totalPages = 0 ;
if ( this . options . totalRows ) {
if ( this . options . pageSize === this . options . formatAllRows ( ) ) {
this . options . pageSize = this . options . totalRows ;
$allSelected = true ;
} else if ( this . options . pageSize === this . options . totalRows ) {
// Fix #667 Table with pagination,
// multiple pages and a search that matches to one page throws exception
var pageLst = typeof this . options . pageList === 'string' ?
this . options . pageList . replace ( '[' , '' ) . replace ( ']' , '' )
. replace ( / /g , '' ) . toLowerCase ( ) . split ( ',' ) : this . options . pageList ;
if ( $ . inArray ( this . options . formatAllRows ( ) . toLowerCase ( ) , pageLst ) > - 1 ) {
$allSelected = true ;
}
}
this . totalPages = ~ ~ ( ( this . options . totalRows - 1 ) / this . options . pageSize ) + 1 ;
this . options . totalPages = this . totalPages ;
}
if ( this . totalPages > 0 && this . options . pageNumber > this . totalPages ) {
this . options . pageNumber = this . totalPages ;
}
this . pageFrom = ( this . options . pageNumber - 1 ) * this . options . pageSize + 1 ;
this . pageTo = this . options . pageNumber * this . options . pageSize ;
if ( this . pageTo > this . options . totalRows ) {
this . pageTo = this . options . totalRows ;
}
html . push (
sprintf ( '<div class="%s-%s pagination-detail">' , bs . pullClass , this . options . paginationDetailHAlign ) ,
'<span class="pagination-info">' ,
this . options . onlyInfoPagination ? this . options . formatDetailPagination ( this . options . totalRows ) :
this . options . formatShowingRows ( this . pageFrom , this . pageTo , this . options . totalRows ) ,
'</span>' ) ;
if ( ! this . options . onlyInfoPagination ) {
html . push ( '<span class="page-list">' ) ;
var pageNumber = [
sprintf ( '<span class="btn-group %s">' ,
this . options . paginationVAlign === 'top' || this . options . paginationVAlign === 'both' ?
'dropdown' : 'dropup' ) ,
'<button type="button" class="btn' +
sprintf ( ' btn-%s' , this . options . buttonsClass ) +
sprintf ( ' btn-%s' , this . options . iconSize ) +
' dropdown-toggle" data-toggle="dropdown">' ,
'<span class="page-size">' ,
$allSelected ? this . options . formatAllRows ( ) : this . options . pageSize ,
'</span>' ,
' <span class="caret"></span>' ,
'</button>' ,
bs . pageDropdownHtml [ 0 ]
] ;
if ( typeof this . options . pageList === 'string' ) {
var list = this . options . pageList . replace ( '[' , '' ) . replace ( ']' , '' )
. replace ( / /g , '' ) . split ( ',' ) ;
pageList = [ ] ;
$ . each ( list , function ( i , value ) {
pageList . push ( ( value . toUpperCase ( ) === that . options . formatAllRows ( ) . toUpperCase ( ) || value . toUpperCase ( ) === "UNLIMITED" ) ?
that . options . formatAllRows ( ) : + value ) ;
} ) ;
}
$ . each ( pageList , function ( i , page ) {
if ( ! that . options . smartDisplay || i === 0 || pageList [ i - 1 ] < that . options . totalRows ) {
var active ;
if ( $allSelected ) {
active = page === that . options . formatAllRows ( ) ? 'active' : '' ;
} else {
active = page === that . options . pageSize ? 'active' : '' ;
}
pageNumber . push ( sprintf ( bs . pageDropdownItemHtml , active , page ) ) ;
}
} ) ;
pageNumber . push ( bs . pageDropdownHtml [ 1 ] + '</span>' ) ;
html . push ( this . options . formatRecordsPerPage ( pageNumber . join ( '' ) ) ) ;
html . push ( '</span>' ) ;
html . push ( '</div>' ,
sprintf ( '<div class="%s-%s pagination">' , bs . pullClass , this . options . paginationHAlign ) ,
'<ul class="pagination' + sprintf ( ' pagination-%s' , this . options . iconSize ) + '">' ,
sprintf ( '<li class="page-item page-pre"><a class="page-link" href="#">%s</a></li>' ,
this . options . paginationPreText ) ) ;
if ( this . totalPages < 5 ) {
from = 1 ;
to = this . totalPages ;
} else {
from = this . options . pageNumber - 2 ;
to = from + 4 ;
if ( from < 1 ) {
from = 1 ;
to = 5 ;
}
if ( to > this . totalPages ) {
to = this . totalPages ;
from = to - 4 ;
}
}
if ( this . totalPages >= 6 ) {
if ( this . options . pageNumber >= 3 ) {
html . push (
sprintf ( '<li class="page-item page-first%s">' ,
1 === this . options . pageNumber ? ' active' : '' ) ,
'<a class="page-link" href="#">' , 1 , '</a>' ,
'</li>' ) ;
from ++ ;
}
if ( this . options . pageNumber >= 4 ) {
if ( this . options . pageNumber == 4 || this . totalPages == 6 || this . totalPages == 7 ) {
from -- ;
} else {
html . push ( '<li class="page-item page-first-separator disabled">' ,
'<a class="page-link" href="#">...</a>' ,
'</li>' ) ;
}
to -- ;
}
}
if ( this . totalPages >= 7 ) {
if ( this . options . pageNumber >= ( this . totalPages - 2 ) ) {
from -- ;
}
}
if ( this . totalPages == 6 ) {
if ( this . options . pageNumber >= ( this . totalPages - 2 ) ) {
to ++ ;
}
} else if ( this . totalPages >= 7 ) {
if ( this . totalPages == 7 || this . options . pageNumber >= ( this . totalPages - 3 ) ) {
to ++ ;
}
}
for ( i = from ; i <= to ; i ++ ) {
html . push ( sprintf ( '<li class="page-item%s">' ,
i === this . options . pageNumber ? ' active' : '' ) ,
'<a class="page-link" href="#">' , i , '</a>' ,
'</li>' ) ;
}
if ( this . totalPages >= 8 ) {
if ( this . options . pageNumber <= ( this . totalPages - 4 ) ) {
html . push ( '<li class="page-item page-last-separator disabled">' ,
'<a class="page-link" href="#">...</a>' ,
'</li>' ) ;
}
}
if ( this . totalPages >= 6 ) {
if ( this . options . pageNumber <= ( this . totalPages - 3 ) ) {
html . push ( sprintf ( '<li class="page-item page-last%s">' ,
this . totalPages === this . options . pageNumber ? ' active' : '' ) ,
'<a class="page-link" href="#">' , this . totalPages , '</a>' ,
'</li>' ) ;
}
}
html . push (
sprintf ( '<li class="page-item page-next"><a class="page-link" href="#">%s</a></li>' ,
this . options . paginationNextText ) ,
'</ul>' ,
'</div>' ) ;
}
this . $pagination . html ( html . join ( '' ) ) ;
if ( ! this . options . onlyInfoPagination ) {
$pageList = this . $pagination . find ( '.page-list a' ) ;
$pre = this . $pagination . find ( '.page-pre' ) ;
$next = this . $pagination . find ( '.page-next' ) ;
$number = this . $pagination . find ( '.page-item' ) . not ( '.page-next, .page-pre' ) ;
if ( this . options . smartDisplay ) {
if ( this . totalPages <= 1 ) {
this . $pagination . find ( 'div.pagination' ) . hide ( ) ;
}
if ( pageList . length < 2 || this . options . totalRows <= pageList [ 0 ] ) {
this . $pagination . find ( 'span.page-list' ) . hide ( ) ;
}
// when data is empty, hide the pagination
this . $pagination [ this . getData ( ) . length ? 'show' : 'hide' ] ( ) ;
}
if ( ! this . options . paginationLoop ) {
if ( this . options . pageNumber === 1 ) {
$pre . addClass ( 'disabled' ) ;
}
if ( this . options . pageNumber === this . totalPages ) {
$next . addClass ( 'disabled' ) ;
}
}
if ( $allSelected ) {
this . options . pageSize = this . options . formatAllRows ( ) ;
}
// removed the events for last and first, onPageNumber executeds the same logic
$pageList . off ( 'click' ) . on ( 'click' , $ . proxy ( this . onPageListChange , this ) ) ;
$pre . off ( 'click' ) . on ( 'click' , $ . proxy ( this . onPagePre , this ) ) ;
$next . off ( 'click' ) . on ( 'click' , $ . proxy ( this . onPageNext , this ) ) ;
$number . off ( 'click' ) . on ( 'click' , $ . proxy ( this . onPageNumber , this ) ) ;
}
} ;
BootstrapTable . prototype . updatePagination = function ( event ) {
// Fix #171: IE disabled button can be clicked bug.
if ( event && $ ( event . currentTarget ) . hasClass ( 'disabled' ) ) {
return ;
}
if ( ! this . options . maintainSelected ) {
this . resetRows ( ) ;
}
this . initPagination ( ) ;
if ( this . options . sidePagination === 'server' ) {
this . initServer ( ) ;
} else {
this . initBody ( ) ;
}
this . trigger ( 'page-change' , this . options . pageNumber , this . options . pageSize ) ;
} ;
BootstrapTable . prototype . onPageListChange = function ( event ) {
event . preventDefault ( ) ;
var $this = $ ( event . currentTarget ) ;
$this . parent ( ) . addClass ( 'active' ) . siblings ( ) . removeClass ( 'active' ) ;
this . options . pageSize = $this . text ( ) . toUpperCase ( ) === this . options . formatAllRows ( ) . toUpperCase ( ) ?
this . options . formatAllRows ( ) : + $this . text ( ) ;
this . $toolbar . find ( '.page-size' ) . text ( this . options . pageSize ) ;
this . updatePagination ( event ) ;
return false ;
} ;
BootstrapTable . prototype . onPagePre = function ( event ) {
event . preventDefault ( ) ;
if ( ( this . options . pageNumber - 1 ) === 0 ) {
this . options . pageNumber = this . options . totalPages ;
} else {
this . options . pageNumber -- ;
}
this . updatePagination ( event ) ;
return false ;
} ;
BootstrapTable . prototype . onPageNext = function ( event ) {
event . preventDefault ( ) ;
if ( ( this . options . pageNumber + 1 ) > this . options . totalPages ) {
this . options . pageNumber = 1 ;
} else {
this . options . pageNumber ++ ;
}
this . updatePagination ( event ) ;
return false ;
} ;
BootstrapTable . prototype . onPageNumber = function ( event ) {
event . preventDefault ( ) ;
if ( this . options . pageNumber === + $ ( event . currentTarget ) . text ( ) ) {
return ;
}
this . options . pageNumber = + $ ( event . currentTarget ) . text ( ) ;
this . updatePagination ( event ) ;
return false ;
} ;
BootstrapTable . prototype . initRow = function ( item , i , data , parentDom ) {
var that = this ,
key ,
html = [ ] ,
style = { } ,
csses = [ ] ,
data _ = '' ,
attributes = { } ,
htmlAttributes = [ ] ;
if ( $ . inArray ( item , this . hiddenRows ) > - 1 ) {
return ;
}
style = calculateObjectValue ( this . options , this . options . rowStyle , [ item , i ] , style ) ;
if ( style && style . css ) {
for ( key in style . css ) {
csses . push ( key + ': ' + style . css [ key ] ) ;
}
}
attributes = calculateObjectValue ( this . options ,
this . options . rowAttributes , [ item , i ] , attributes ) ;
if ( attributes ) {
for ( key in attributes ) {
htmlAttributes . push ( sprintf ( '%s="%s"' , key , escapeHTML ( attributes [ key ] ) ) ) ;
}
}
if ( item . _data && ! $ . isEmptyObject ( item . _data ) ) {
$ . each ( item . _data , function ( k , v ) {
// ignore data-index
if ( k === 'index' ) {
return ;
}
data _ += sprintf ( ' data-%s="%s"' , k , v ) ;
} ) ;
}
html . push ( '<tr' ,
sprintf ( ' %s' , htmlAttributes . join ( ' ' ) ) ,
sprintf ( ' id="%s"' , $ . isArray ( item ) ? undefined : item . _id ) ,
sprintf ( ' class="%s"' , style . classes || ( $ . isArray ( item ) ? undefined : item . _class ) ) ,
sprintf ( ' data-index="%s"' , i ) ,
sprintf ( ' data-uniqueid="%s"' , item [ this . options . uniqueId ] ) ,
sprintf ( '%s' , data _ ) ,
'>'
) ;
if ( this . options . cardView ) {
html . push ( sprintf ( '<td colspan="%s"><div class="card-views">' , this . header . fields . length ) ) ;
}
if ( ! this . options . cardView && this . options . detailView ) {
html . push ( '<td>' ) ;
if ( calculateObjectValue ( null , this . options . detailFilter , [ i , item ] ) ) {
html . push ( '<a class="detail-icon" href="#">' ,
sprintf ( '<i class="%s %s"></i>' , this . options . iconsPrefix , this . options . icons . detailOpen ) ,
'</a>' ) ;
}
html . push ( '</td>' ) ;
}
$ . each ( this . header . fields , function ( j , field ) {
var text = '' ,
value _ = getItemField ( item , field , that . options . escape ) ,
value = '' ,
type = '' ,
cellStyle = { } ,
id _ = '' ,
class _ = that . header . classes [ j ] ,
data _ = '' ,
rowspan _ = '' ,
colspan _ = '' ,
title _ = '' ,
column = that . columns [ j ] ;
if ( that . fromHtml && typeof value _ === 'undefined' ) {
if ( ( ! column . checkbox ) && ( ! column . radio ) ) {
return ;
}
}
if ( ! column . visible ) {
return ;
}
if ( that . options . cardView && ( ! column . cardVisible ) ) {
return ;
}
if ( column . escape ) {
value _ = escapeHTML ( value _ ) ;
}
style = sprintf ( 'style="%s"' , csses . concat ( that . header . styles [ j ] ) . join ( '; ' ) ) ;
// handle td's id and class
if ( item [ '_' + field + '_id' ] ) {
id _ = sprintf ( ' id="%s"' , item [ '_' + field + '_id' ] ) ;
}
if ( item [ '_' + field + '_class' ] ) {
class _ = sprintf ( ' class="%s"' , item [ '_' + field + '_class' ] ) ;
}
if ( item [ '_' + field + '_rowspan' ] ) {
rowspan _ = sprintf ( ' rowspan="%s"' , item [ '_' + field + '_rowspan' ] ) ;
}
if ( item [ '_' + field + '_colspan' ] ) {
colspan _ = sprintf ( ' colspan="%s"' , item [ '_' + field + '_colspan' ] ) ;
}
if ( item [ '_' + field + '_title' ] ) {
title _ = sprintf ( ' title="%s"' , item [ '_' + field + '_title' ] ) ;
}
cellStyle = calculateObjectValue ( that . header ,
that . header . cellStyles [ j ] , [ value _ , item , i , field ] , cellStyle ) ;
if ( cellStyle . classes ) {
class _ = sprintf ( ' class="%s"' , cellStyle . classes ) ;
}
if ( cellStyle . css ) {
var csses _ = [ ] ;
for ( var key in cellStyle . css ) {
csses _ . push ( key + ': ' + cellStyle . css [ key ] ) ;
}
style = sprintf ( 'style="%s"' , csses _ . concat ( that . header . styles [ j ] ) . join ( '; ' ) ) ;
}
value = calculateObjectValue ( column ,
that . header . formatters [ j ] , [ value _ , item , i , field ] , value _ ) ;
if ( item [ '_' + field + '_data' ] && ! $ . isEmptyObject ( item [ '_' + field + '_data' ] ) ) {
$ . each ( item [ '_' + field + '_data' ] , function ( k , v ) {
// ignore data-index
if ( k === 'index' ) {
return ;
}
data _ += sprintf ( ' data-%s="%s"' , k , v ) ;
} ) ;
}
if ( column . checkbox || column . radio ) {
type = column . checkbox ? 'checkbox' : type ;
type = column . radio ? 'radio' : type ;
text = [ sprintf ( that . options . cardView ?
'<div class="card-view %s">' : '<td class="bs-checkbox %s">' , column [ 'class' ] || '' ) ,
'<input' +
sprintf ( ' data-index="%s"' , i ) +
sprintf ( ' name="%s"' , that . options . selectItemName ) +
sprintf ( ' type="%s"' , type ) +
sprintf ( ' value="%s"' , item [ that . options . idField ] ) +
sprintf ( ' checked="%s"' , value === true ||
( value _ || value && value . checked ) ? 'checked' : undefined ) +
sprintf ( ' disabled="%s"' , ! column . checkboxEnabled ||
( value && value . disabled ) ? 'disabled' : undefined ) +
' />' ,
that . header . formatters [ j ] && typeof value === 'string' ? value : '' ,
that . options . cardView ? '</div>' : '</td>'
] . join ( '' ) ;
item [ that . header . stateField ] = value === true || ( ! ! value _ || value && value . checked ) ;
} else {
value = typeof value === 'undefined' || value === null ?
that . options . undefinedText : value ;
text = that . options . cardView ? [ '<div class="card-view">' ,
that . options . showHeader ? sprintf ( '<span class="title" %s>%s</span>' , style ,
getPropertyFromOther ( that . columns , 'field' , 'title' , field ) ) : '' ,
sprintf ( '<span class="value">%s</span>' , value ) ,
'</div>'
] . join ( '' ) : [ sprintf ( '<td%s %s %s %s %s %s %s>' ,
id _ , class _ , style , data _ , rowspan _ , colspan _ , title _ ) ,
value ,
'</td>'
] . join ( '' ) ;
// Hide empty data on Card view when smartDisplay is set to true.
if ( that . options . cardView && that . options . smartDisplay && value === '' ) {
// Should set a placeholder for event binding correct fieldIndex
text = '<div class="card-view"></div>' ;
}
}
html . push ( text ) ;
} ) ;
if ( this . options . cardView ) {
html . push ( '</div></td>' ) ;
}
html . push ( '</tr>' ) ;
return html . join ( ' ' ) ;
} ;
BootstrapTable . prototype . initBody = function ( fixedScroll ) {
var that = this ,
html = [ ] ,
data = this . getData ( ) ;
this . trigger ( 'pre-body' , data ) ;
this . $body = this . $el . find ( '>tbody' ) ;
if ( ! this . $body . length ) {
this . $body = $ ( '<tbody></tbody>' ) . appendTo ( this . $el ) ;
}
//Fix #389 Bootstrap-table-flatJSON is not working
if ( ! this . options . pagination || this . options . sidePagination === 'server' ) {
this . pageFrom = 1 ;
this . pageTo = data . length ;
}
var trFragments = $ ( document . createDocumentFragment ( ) ) ;
var hasTr ;
for ( var i = this . pageFrom - 1 ; i < this . pageTo ; i ++ ) {
var item = data [ i ] ;
var tr = this . initRow ( item , i , data , trFragments ) ;
hasTr = hasTr || ! ! tr ;
if ( tr && tr !== true ) {
trFragments . append ( tr ) ;
}
}
// show no records
if ( ! hasTr ) {
trFragments . append ( '<tr class="no-records-found">' +
sprintf ( '<td colspan="%s">%s</td>' ,
this . $header . find ( 'th' ) . length ,
this . options . formatNoMatches ( ) ) +
'</tr>' ) ;
}
this . $body . html ( trFragments ) ;
if ( ! fixedScroll ) {
this . scrollTo ( 0 ) ;
}
// click to select by column
this . $body . find ( '> tr[data-index] > td' ) . off ( 'click dblclick' ) . on ( 'click dblclick' , function ( e ) {
var $td = $ ( this ) ,
$tr = $td . parent ( ) ,
item = that . data [ $tr . data ( 'index' ) ] ,
index = $td [ 0 ] . cellIndex ,
fields = that . getVisibleFields ( ) ,
field = fields [ that . options . detailView && ! that . options . cardView ? index - 1 : index ] ,
column = that . columns [ that . fieldsColumnsIndex [ field ] ] ,
value = getItemField ( item , field , that . options . escape ) ;
if ( $td . find ( '.detail-icon' ) . length ) {
return ;
}
that . trigger ( e . type === 'click' ? 'click-cell' : 'dbl-click-cell' , field , value , item , $td ) ;
that . trigger ( e . type === 'click' ? 'click-row' : 'dbl-click-row' , item , $tr , field ) ;
// if click to select - then trigger the checkbox/radio click
if ( e . type === 'click' && that . options . clickToSelect && column . clickToSelect && that . options . ignoreClickToSelectOn ( e . target ) ) {
var $selectItem = $tr . find ( sprintf ( '[name="%s"]' , that . options . selectItemName ) ) ;
if ( $selectItem . length ) {
$selectItem [ 0 ] . click ( ) ; // #144: .trigger('click') bug
}
}
} ) ;
this . $body . find ( '> tr[data-index] > td > .detail-icon' ) . off ( 'click' ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
var $this = $ ( this ) ,
$tr = $this . parent ( ) . parent ( ) ,
index = $tr . data ( 'index' ) ,
row = data [ index ] ; // Fix #980 Detail view, when searching, returns wrong row
// remove and update
if ( $tr . next ( ) . is ( 'tr.detail-view' ) ) {
$this . find ( 'i' ) . attr ( 'class' , sprintf ( '%s %s' , that . options . iconsPrefix , that . options . icons . detailOpen ) ) ;
that . trigger ( 'collapse-row' , index , row , $tr . next ( ) ) ;
$tr . next ( ) . remove ( ) ;
} else {
$this . find ( 'i' ) . attr ( 'class' , sprintf ( '%s %s' , that . options . iconsPrefix , that . options . icons . detailClose ) ) ;
$tr . after ( sprintf ( '<tr class="detail-view"><td colspan="%s"></td></tr>' , $tr . find ( 'td' ) . length ) ) ;
var $element = $tr . next ( ) . find ( 'td' ) ;
var content = calculateObjectValue ( that . options , that . options . detailFormatter , [ index , row , $element ] , '' ) ;
if ( $element . length === 1 ) {
$element . append ( content ) ;
}
that . trigger ( 'expand-row' , index , row , $element ) ;
}
that . resetView ( ) ;
return false ;
} ) ;
this . $selectItem = this . $body . find ( sprintf ( '[name="%s"]' , this . options . selectItemName ) ) ;
this . $selectItem . off ( 'click' ) . on ( 'click' , function ( event ) {
event . stopImmediatePropagation ( ) ;
var $this = $ ( this ) ,
checked = $this . prop ( 'checked' ) ,
row = that . data [ $this . data ( 'index' ) ] ;
if ( $ ( this ) . is ( ':radio' ) || that . options . singleSelect ) {
$ . each ( that . options . data , function ( i , row ) {
row [ that . header . stateField ] = false ;
} ) ;
}
row [ that . header . stateField ] = checked ;
if ( that . options . singleSelect ) {
that . $selectItem . not ( this ) . each ( function ( ) {
that . data [ $ ( this ) . data ( 'index' ) ] [ that . header . stateField ] = false ;
} ) ;
that . $selectItem . filter ( ':checked' ) . not ( this ) . prop ( 'checked' , false ) ;
}
that . updateSelected ( ) ;
that . trigger ( checked ? 'check' : 'uncheck' , row , $this ) ;
} ) ;
$ . each ( this . header . events , function ( i , events ) {
if ( ! events ) {
return ;
}
// fix bug, if events is defined with namespace
if ( typeof events === 'string' ) {
events = calculateObjectValue ( null , events ) ;
}
var field = that . header . fields [ i ] ,
fieldIndex = $ . inArray ( field , that . getVisibleFields ( ) ) ;
if ( fieldIndex === - 1 ) {
return ;
}
if ( that . options . detailView && ! that . options . cardView ) {
fieldIndex += 1 ;
}
for ( var key in events ) {
that . $body . find ( '>tr:not(.no-records-found)' ) . each ( function ( ) {
var $tr = $ ( this ) ,
$td = $tr . find ( that . options . cardView ? '.card-view' : 'td' ) . eq ( fieldIndex ) ,
index = key . indexOf ( ' ' ) ,
name = key . substring ( 0 , index ) ,
el = key . substring ( index + 1 ) ,
func = events [ key ] ;
$td . find ( el ) . off ( name ) . on ( name , function ( e ) {
var index = $tr . data ( 'index' ) ,
row = that . data [ index ] ,
value = row [ field ] ;
func . apply ( this , [ e , value , row , index ] ) ;
} ) ;
} ) ;
}
} ) ;
this . updateSelected ( ) ;
this . resetView ( ) ;
this . trigger ( 'post-body' , data ) ;
} ;
BootstrapTable . prototype . initServer = function ( silent , query , url ) {
var that = this ,
data = { } ,
index = $ . inArray ( this . options . sortName , this . header . fields ) ,
params = {
searchText : this . searchText ,
sortName : this . options . sortName ,
sortOrder : this . options . sortOrder
} ,
request ;
if ( this . header . sortNames [ index ] ) {
params . sortName = this . header . sortNames [ index ] ;
}
if ( this . options . pagination && this . options . sidePagination === 'server' ) {
params . pageSize = this . options . pageSize === this . options . formatAllRows ( ) ?
this . options . totalRows : this . options . pageSize ;
params . pageNumber = this . options . pageNumber ;
}
if ( ! ( url || this . options . url ) && ! this . options . ajax ) {
return ;
}
if ( this . options . queryParamsType === 'limit' ) {
params = {
search : params . searchText ,
sort : params . sortName ,
order : params . sortOrder
} ;
if ( this . options . pagination && this . options . sidePagination === 'server' ) {
params . offset = this . options . pageSize === this . options . formatAllRows ( ) ?
0 : this . options . pageSize * ( this . options . pageNumber - 1 ) ;
params . limit = this . options . pageSize === this . options . formatAllRows ( ) ?
this . options . totalRows : this . options . pageSize ;
if ( params . limit === 0 ) {
delete params . limit ;
}
}
}
if ( ! ( $ . isEmptyObject ( this . filterColumnsPartial ) ) ) {
params . filter = JSON . stringify ( this . filterColumnsPartial , null ) ;
}
data = calculateObjectValue ( this . options , this . options . queryParams , [ params ] , data ) ;
$ . extend ( data , query || { } ) ;
// false to stop request
if ( data === false ) {
return ;
}
if ( ! silent ) {
this . $tableLoading . show ( ) ;
}
request = $ . extend ( { } , calculateObjectValue ( null , this . options . ajaxOptions ) , {
type : this . options . method ,
url : url || this . options . url ,
data : this . options . contentType === 'application/json' && this . options . method === 'post' ?
JSON . stringify ( data ) : data ,
cache : this . options . cache ,
contentType : this . options . contentType ,
dataType : this . options . dataType ,
success : function ( res ) {
res = calculateObjectValue ( that . options , that . options . responseHandler , [ res ] , res ) ;
that . load ( res ) ;
that . trigger ( 'load-success' , res ) ;
if ( ! silent ) that . $tableLoading . hide ( ) ;
} ,
error : function ( res ) {
var data = [ ] ;
if ( that . options . sidePagination === 'server' ) {
data = { } ;
data [ that . options . totalField ] = 0 ;
data [ that . options . dataField ] = [ ] ;
}
that . load ( data ) ;
that . trigger ( 'load-error' , res . status , res ) ;
if ( ! silent ) that . $tableLoading . hide ( ) ;
}
} ) ;
if ( this . options . ajax ) {
calculateObjectValue ( this , this . options . ajax , [ request ] , null ) ;
} else {
if ( this . _xhr && this . _xhr . readyState !== 4 ) {
this . _xhr . abort ( ) ;
}
this . _xhr = $ . ajax ( request ) ;
}
} ;
BootstrapTable . prototype . initSearchText = function ( ) {
if ( this . options . search ) {
this . searchText = '' ;
if ( this . options . searchText !== '' ) {
var $search = this . $toolbar . find ( '.search input' ) ;
$search . val ( this . options . searchText ) ;
this . onSearch ( { currentTarget : $search , firedByInitSearchText : true } ) ;
}
}
} ;
BootstrapTable . prototype . getCaret = function ( ) {
var that = this ;
$ . each ( this . $header . find ( 'th' ) , function ( i , th ) {
$ ( th ) . find ( '.sortable' ) . removeClass ( 'desc asc' ) . addClass ( $ ( th ) . data ( 'field' ) === that . options . sortName ? that . options . sortOrder : 'both' ) ;
} ) ;
} ;
BootstrapTable . prototype . updateSelected = function ( ) {
var checkAll = this . $selectItem . filter ( ':enabled' ) . length &&
this . $selectItem . filter ( ':enabled' ) . length ===
this . $selectItem . filter ( ':enabled' ) . filter ( ':checked' ) . length ;
this . $selectAll . add ( this . $selectAll _ ) . prop ( 'checked' , checkAll ) ;
this . $selectItem . each ( function ( ) {
$ ( this ) . closest ( 'tr' ) [ $ ( this ) . prop ( 'checked' ) ? 'addClass' : 'removeClass' ] ( 'selected' ) ;
} ) ;
} ;
BootstrapTable . prototype . updateRows = function ( ) {
var that = this ;
this . $selectItem . each ( function ( ) {
that . data [ $ ( this ) . data ( 'index' ) ] [ that . header . stateField ] = $ ( this ) . prop ( 'checked' ) ;
} ) ;
} ;
BootstrapTable . prototype . resetRows = function ( ) {
var that = this ;
$ . each ( this . data , function ( i , row ) {
that . $selectAll . prop ( 'checked' , false ) ;
that . $selectItem . prop ( 'checked' , false ) ;
if ( that . header . stateField ) {
row [ that . header . stateField ] = false ;
}
} ) ;
this . initHiddenRows ( ) ;
} ;
BootstrapTable . prototype . trigger = function ( name ) {
var args = Array . prototype . slice . call ( arguments , 1 ) ;
name += '.bs.table' ;
this . options [ BootstrapTable . EVENTS [ name ] ] . apply ( this . options , args ) ;
this . $el . trigger ( $ . Event ( name ) , args ) ;
this . options . onAll ( name , args ) ;
this . $el . trigger ( $ . Event ( 'all.bs.table' ) , [ name , args ] ) ;
} ;
BootstrapTable . prototype . resetHeader = function ( ) {
// fix #61: the hidden table reset header bug.
// fix bug: get $el.css('width') error sometime (height = 500)
clearTimeout ( this . timeoutId _ ) ;
this . timeoutId _ = setTimeout ( $ . proxy ( this . fitHeader , this ) , this . $el . is ( ':hidden' ) ? 100 : 0 ) ;
} ;
BootstrapTable . prototype . fitHeader = function ( ) {
var that = this ,
fixedBody ,
scrollWidth ,
focused ,
focusedTemp ;
if ( that . $el . is ( ':hidden' ) ) {
that . timeoutId _ = setTimeout ( $ . proxy ( that . fitHeader , that ) , 100 ) ;
return ;
}
fixedBody = this . $tableBody . get ( 0 ) ;
scrollWidth = fixedBody . scrollWidth > fixedBody . clientWidth &&
fixedBody . scrollHeight > fixedBody . clientHeight + this . $header . outerHeight ( ) ?
getScrollBarWidth ( ) : 0 ;
this . $el . css ( 'margin-top' , - this . $header . outerHeight ( ) ) ;
focused = $ ( ':focus' ) ;
if ( focused . length > 0 ) {
var $th = focused . parents ( 'th' ) ;
if ( $th . length > 0 ) {
var dataField = $th . attr ( 'data-field' ) ;
if ( dataField !== undefined ) {
var $headerTh = this . $header . find ( "[data-field='" + dataField + "']" ) ;
if ( $headerTh . length > 0 ) {
$headerTh . find ( ":input" ) . addClass ( "focus-temp" ) ;
}
}
}
}
this . $header _ = this . $header . clone ( true , true ) ;
this . $selectAll _ = this . $header _ . find ( '[name="btSelectAll"]' ) ;
this . $tableHeader . css ( {
'margin-right' : scrollWidth
} ) . find ( 'table' ) . css ( 'width' , this . $el . outerWidth ( ) )
. html ( '' ) . attr ( 'class' , this . $el . attr ( 'class' ) )
. append ( this . $header _ ) ;
focusedTemp = $ ( '.focus-temp:visible:eq(0)' ) ;
if ( focusedTemp . length > 0 ) {
focusedTemp . focus ( ) ;
this . $header . find ( '.focus-temp' ) . removeClass ( 'focus-temp' ) ;
}
// fix bug: $.data() is not working as expected after $.append()
this . $header . find ( 'th[data-field]' ) . each ( function ( i ) {
that . $header _ . find ( sprintf ( 'th[data-field="%s"]' , $ ( this ) . data ( 'field' ) ) ) . data ( $ ( this ) . data ( ) ) ;
} ) ;
var visibleFields = this . getVisibleFields ( ) ,
$ths = this . $header _ . find ( 'th' ) ;
this . $body . find ( '>tr:first-child:not(.no-records-found) > *' ) . each ( function ( i ) {
var $this = $ ( this ) ,
index = i ;
if ( that . options . detailView && ! that . options . cardView ) {
if ( i === 0 ) {
that . $header _ . find ( 'th.detail' ) . find ( '.fht-cell' ) . width ( $this . innerWidth ( ) ) ;
}
index = i - 1 ;
}
if ( index === - 1 ) {
return ;
}
var $th = that . $header _ . find ( sprintf ( 'th[data-field="%s"]' , visibleFields [ index ] ) ) ;
if ( $th . length > 1 ) {
$th = $ ( $ths [ $this [ 0 ] . cellIndex ] ) ;
}
var zoomWidth = $th . width ( ) - $th . find ( '.fht-cell' ) . width ( ) ;
$th . find ( '.fht-cell' ) . width ( $this . innerWidth ( ) - zoomWidth ) ;
} ) ;
this . horizontalScroll ( ) ;
this . trigger ( 'post-header' ) ;
} ;
BootstrapTable . prototype . resetFooter = function ( ) {
var that = this ,
data = that . getData ( ) ,
html = [ ] ;
if ( ! this . options . showFooter || this . options . cardView ) { //do nothing
return ;
}
if ( ! this . options . cardView && this . options . detailView ) {
html . push ( '<td><div class="th-inner"> </div><div class="fht-cell"></div></td>' ) ;
}
$ . each ( this . columns , function ( i , column ) {
var key ,
falign = '' , // footer align style
valign = '' ,
csses = [ ] ,
style = { } ,
class _ = sprintf ( ' class="%s"' , column [ 'class' ] ) ;
if ( ! column . visible ) {
return ;
}
if ( that . options . cardView && ( ! column . cardVisible ) ) {
return ;
}
falign = sprintf ( 'text-align: %s; ' , column . falign ? column . falign : column . align ) ;
valign = sprintf ( 'vertical-align: %s; ' , column . valign ) ;
style = calculateObjectValue ( null , that . options . footerStyle ) ;
if ( style && style . css ) {
for ( key in style . css ) {
csses . push ( key + ': ' + style . css [ key ] ) ;
}
}
html . push ( '<td' , class _ , sprintf ( ' style="%s"' , falign + valign + csses . concat ( ) . join ( '; ' ) ) , '>' ) ;
html . push ( '<div class="th-inner">' ) ;
html . push ( calculateObjectValue ( column , column . footerFormatter , [ data ] , ' ' ) || ' ' ) ;
html . push ( '</div>' ) ;
html . push ( '<div class="fht-cell"></div>' ) ;
html . push ( '</div>' ) ;
html . push ( '</td>' ) ;
} ) ;
this . $tableFooter . find ( 'tr' ) . html ( html . join ( '' ) ) ;
this . $tableFooter . show ( ) ;
clearTimeout ( this . timeoutFooter _ ) ;
this . timeoutFooter _ = setTimeout ( $ . proxy ( this . fitFooter , this ) ,
this . $el . is ( ':hidden' ) ? 100 : 0 ) ;
} ;
BootstrapTable . prototype . fitFooter = function ( ) {
var that = this ,
$footerTd ,
elWidth ,
scrollWidth ;
clearTimeout ( this . timeoutFooter _ ) ;
if ( this . $el . is ( ':hidden' ) ) {
this . timeoutFooter _ = setTimeout ( $ . proxy ( this . fitFooter , this ) , 100 ) ;
return ;
}
elWidth = this . $el . css ( 'width' ) ;
scrollWidth = elWidth > this . $tableBody . width ( ) ? getScrollBarWidth ( ) : 0 ;
this . $tableFooter . css ( {
'margin-right' : scrollWidth
} ) . find ( 'table' ) . css ( 'width' , elWidth )
. attr ( 'class' , this . $el . attr ( 'class' ) ) ;
$footerTd = this . $tableFooter . find ( 'td' ) ;
this . $body . find ( '>tr:first-child:not(.no-records-found) > *' ) . each ( function ( i ) {
var $this = $ ( this ) ;
$footerTd . eq ( i ) . find ( '.fht-cell' ) . width ( $this . innerWidth ( ) ) ;
} ) ;
this . horizontalScroll ( ) ;
} ;
BootstrapTable . prototype . horizontalScroll = function ( ) {
var that = this ;
// horizontal scroll event
// TODO: it's probably better improving the layout than binding to scroll event
that . trigger ( 'scroll-body' ) ;
this . $tableBody . off ( 'scroll' ) . on ( 'scroll' , function ( ) {
if ( that . options . showHeader && that . options . height ) {
that . $tableHeader . scrollLeft ( $ ( this ) . scrollLeft ( ) ) ;
}
if ( that . options . showFooter && ! that . options . cardView ) {
that . $tableFooter . scrollLeft ( $ ( this ) . scrollLeft ( ) ) ;
}
} ) ;
} ;
BootstrapTable . prototype . toggleColumn = function ( index , checked , needUpdate ) {
if ( index === - 1 ) {
return ;
}
this . columns [ index ] . visible = checked ;
this . initHeader ( ) ;
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initBody ( ) ;
if ( this . options . showColumns ) {
var $items = this . $toolbar . find ( '.keep-open input' ) . prop ( 'disabled' , false ) ;
if ( needUpdate ) {
$items . filter ( sprintf ( '[value="%s"]' , index ) ) . prop ( 'checked' , checked ) ;
}
if ( $items . filter ( ':checked' ) . length <= this . options . minimumCountColumns ) {
$items . filter ( ':checked' ) . prop ( 'disabled' , true ) ;
}
}
} ;
BootstrapTable . prototype . getVisibleFields = function ( ) {
var that = this ,
visibleFields = [ ] ;
$ . each ( this . header . fields , function ( j , field ) {
var column = that . columns [ that . fieldsColumnsIndex [ field ] ] ;
if ( ! column . visible ) {
return ;
}
visibleFields . push ( field ) ;
} ) ;
return visibleFields ;
} ;
// PUBLIC FUNCTION DEFINITION
// =======================
BootstrapTable . prototype . resetView = function ( params ) {
var padding = 0 ;
if ( params && params . height ) {
this . options . height = params . height ;
}
this . $selectAll . prop ( 'checked' , this . $selectItem . length > 0 &&
this . $selectItem . length === this . $selectItem . filter ( ':checked' ) . length ) ;
if ( this . options . height ) {
var toolbarHeight = this . $toolbar . outerHeight ( true ) ,
paginationHeight = this . $pagination . outerHeight ( true ) ,
height = this . options . height - toolbarHeight - paginationHeight ;
this . $tableContainer . css ( 'height' , height + 'px' ) ;
}
if ( this . options . cardView ) {
// remove the element css
this . $el . css ( 'margin-top' , '0' ) ;
this . $tableContainer . css ( 'padding-bottom' , '0' ) ;
this . $tableFooter . hide ( ) ;
return ;
}
if ( this . options . showHeader && this . options . height ) {
this . $tableHeader . show ( ) ;
this . resetHeader ( ) ;
padding += this . $header . outerHeight ( ) ;
} else {
this . $tableHeader . hide ( ) ;
this . trigger ( 'post-header' ) ;
}
if ( this . options . showFooter ) {
this . resetFooter ( ) ;
if ( this . options . height ) {
padding += this . $tableFooter . outerHeight ( ) + 1 ;
}
}
// Assign the correct sortable arrow
this . getCaret ( ) ;
this . $tableContainer . css ( 'padding-bottom' , padding + 'px' ) ;
this . trigger ( 'reset-view' ) ;
} ;
BootstrapTable . prototype . getData = function ( useCurrentPage ) {
var data = this . options . data ;
if ( this . searchText || this . options . sortName || ! $ . isEmptyObject ( this . filterColumns ) || ! $ . isEmptyObject ( this . filterColumnsPartial ) ) {
data = this . data ;
}
if ( useCurrentPage ) {
return data . slice ( this . pageFrom - 1 , this . pageTo ) ;
}
return data ;
} ;
BootstrapTable . prototype . load = function ( data ) {
var fixedScroll = false ;
// #431: support pagination
if ( this . options . pagination && this . options . sidePagination === 'server' ) {
this . options . totalRows = data [ this . options . totalField ] ;
fixedScroll = data . fixedScroll ;
data = data [ this . options . dataField ] ;
} else if ( ! $ . isArray ( data ) ) { // support fixedScroll
fixedScroll = data . fixedScroll ;
data = data . data ;
}
this . initData ( data ) ;
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initBody ( fixedScroll ) ;
} ;
BootstrapTable . prototype . append = function ( data ) {
this . initData ( data , 'append' ) ;
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initSort ( ) ;
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . prepend = function ( data ) {
this . initData ( data , 'prepend' ) ;
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initSort ( ) ;
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . remove = function ( params ) {
var len = this . options . data . length ,
i , row ;
if ( ! params . hasOwnProperty ( 'field' ) || ! params . hasOwnProperty ( 'values' ) ) {
return ;
}
for ( i = len - 1 ; i >= 0 ; i -- ) {
row = this . options . data [ i ] ;
if ( ! row . hasOwnProperty ( params . field ) ) {
continue ;
}
if ( $ . inArray ( row [ params . field ] , params . values ) !== - 1 ) {
this . options . data . splice ( i , 1 ) ;
if ( this . options . sidePagination === 'server' ) {
this . options . totalRows -= 1 ;
}
}
}
if ( len === this . options . data . length ) {
return ;
}
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initSort ( ) ;
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . removeAll = function ( ) {
if ( this . options . data . length > 0 ) {
this . options . data . splice ( 0 , this . options . data . length ) ;
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initBody ( true ) ;
}
} ;
BootstrapTable . prototype . getRowByUniqueId = function ( id ) {
var uniqueId = this . options . uniqueId ,
len = this . options . data . length ,
dataRow = null ,
i , row , rowUniqueId ;
for ( i = len - 1 ; i >= 0 ; i -- ) {
row = this . options . data [ i ] ;
if ( row . hasOwnProperty ( uniqueId ) ) { // uniqueId is a column
rowUniqueId = row [ uniqueId ] ;
} else if ( row . _data . hasOwnProperty ( uniqueId ) ) { // uniqueId is a row data property
rowUniqueId = row . _data [ uniqueId ] ;
} else {
continue ;
}
if ( typeof rowUniqueId === 'string' ) {
id = id . toString ( ) ;
} else if ( typeof rowUniqueId === 'number' ) {
if ( ( Number ( rowUniqueId ) === rowUniqueId ) && ( rowUniqueId % 1 === 0 ) ) {
id = parseInt ( id ) ;
} else if ( ( rowUniqueId === Number ( rowUniqueId ) ) && ( rowUniqueId !== 0 ) ) {
id = parseFloat ( id ) ;
}
}
if ( rowUniqueId === id ) {
dataRow = row ;
break ;
}
}
return dataRow ;
} ;
BootstrapTable . prototype . removeByUniqueId = function ( id ) {
var len = this . options . data . length ,
row = this . getRowByUniqueId ( id ) ;
if ( row ) {
this . options . data . splice ( this . options . data . indexOf ( row ) , 1 ) ;
}
if ( len === this . options . data . length ) {
return ;
}
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . updateByUniqueId = function ( params ) {
var that = this ;
var allParams = $ . isArray ( params ) ? params : [ params ] ;
$ . each ( allParams , function ( i , params ) {
var rowId ;
if ( ! params . hasOwnProperty ( 'id' ) || ! params . hasOwnProperty ( 'row' ) ) {
return ;
}
rowId = $ . inArray ( that . getRowByUniqueId ( params . id ) , that . options . data ) ;
if ( rowId === - 1 ) {
return ;
}
$ . extend ( that . options . data [ rowId ] , params . row ) ;
} ) ;
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initSort ( ) ;
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . refreshColumnTitle = function ( params ) {
if ( ! params . hasOwnProperty ( 'field' ) || ! params . hasOwnProperty ( 'title' ) ) {
return ;
}
this . columns [ this . fieldsColumnsIndex [ params . field ] ] . title =
this . options . escape ? escapeHTML ( params . title ) : params . title ;
if ( this . columns [ this . fieldsColumnsIndex [ params . field ] ] . visible ) {
var header = this . options . height !== undefined ? this . $tableHeader : this . $header ;
header . find ( 'th[data-field]' ) . each ( function ( i ) {
if ( $ ( this ) . data ( 'field' ) === params . field ) {
$ ( $ ( this ) . find ( ".th-inner" ) [ 0 ] ) . text ( params . title ) ;
return false ;
}
} ) ;
}
} ;
BootstrapTable . prototype . insertRow = function ( params ) {
if ( ! params . hasOwnProperty ( 'index' ) || ! params . hasOwnProperty ( 'row' ) ) {
return ;
}
this . options . data . splice ( params . index , 0 , params . row ) ;
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initSort ( ) ;
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . updateRow = function ( params ) {
var that = this ;
var allParams = $ . isArray ( params ) ? params : [ params ] ;
$ . each ( allParams , function ( i , params ) {
if ( ! params . hasOwnProperty ( 'index' ) || ! params . hasOwnProperty ( 'row' ) ) {
return ;
}
$ . extend ( that . options . data [ params . index ] , params . row ) ;
} ) ;
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initSort ( ) ;
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . initHiddenRows = function ( ) {
this . hiddenRows = [ ] ;
} ;
BootstrapTable . prototype . showRow = function ( params ) {
this . toggleRow ( params , true ) ;
} ;
BootstrapTable . prototype . hideRow = function ( params ) {
this . toggleRow ( params , false ) ;
} ;
BootstrapTable . prototype . toggleRow = function ( params , visible ) {
var row , index ;
if ( params . hasOwnProperty ( 'index' ) ) {
row = this . getData ( ) [ params . index ] ;
} else if ( params . hasOwnProperty ( 'uniqueId' ) ) {
row = this . getRowByUniqueId ( params . uniqueId ) ;
}
if ( ! row ) {
return ;
}
index = $ . inArray ( row , this . hiddenRows ) ;
if ( ! visible && index === - 1 ) {
this . hiddenRows . push ( row ) ;
} else if ( visible && index > - 1 ) {
this . hiddenRows . splice ( index , 1 ) ;
}
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . getHiddenRows = function ( show ) {
var that = this ,
data = this . getData ( ) ,
rows = [ ] ;
$ . each ( data , function ( i , row ) {
if ( $ . inArray ( row , that . hiddenRows ) > - 1 ) {
rows . push ( row ) ;
}
} ) ;
this . hiddenRows = rows ;
return rows ;
} ;
BootstrapTable . prototype . mergeCells = function ( options ) {
var row = options . index ,
col = $ . inArray ( options . field , this . getVisibleFields ( ) ) ,
rowspan = options . rowspan || 1 ,
colspan = options . colspan || 1 ,
i , j ,
$tr = this . $body . find ( '>tr' ) ,
$td ;
if ( this . options . detailView && ! this . options . cardView ) {
col += 1 ;
}
$td = $tr . eq ( row ) . find ( '>td' ) . eq ( col ) ;
if ( row < 0 || col < 0 || row >= this . data . length ) {
return ;
}
for ( i = row ; i < row + rowspan ; i ++ ) {
for ( j = col ; j < col + colspan ; j ++ ) {
$tr . eq ( i ) . find ( '>td' ) . eq ( j ) . hide ( ) ;
}
}
$td . attr ( 'rowspan' , rowspan ) . attr ( 'colspan' , colspan ) . show ( ) ;
} ;
BootstrapTable . prototype . updateCell = function ( params ) {
if ( ! params . hasOwnProperty ( 'index' ) ||
! params . hasOwnProperty ( 'field' ) ||
! params . hasOwnProperty ( 'value' ) ) {
return ;
}
this . data [ params . index ] [ params . field ] = params . value ;
if ( params . reinit === false ) {
return ;
}
this . initSort ( ) ;
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . updateCellById = function ( params ) {
var that = this ;
if ( ! params . hasOwnProperty ( 'id' ) ||
! params . hasOwnProperty ( 'field' ) ||
! params . hasOwnProperty ( 'value' ) ) {
return ;
}
var allParams = $ . isArray ( params ) ? params : [ params ] ;
$ . each ( allParams , function ( i , params ) {
var rowId ;
rowId = $ . inArray ( that . getRowByUniqueId ( params . id ) , that . options . data ) ;
if ( rowId === - 1 ) {
return ;
}
that . data [ rowId ] [ params . field ] = params . value ;
} ) ;
if ( params . reinit === false ) {
return ;
}
this . initSort ( ) ;
this . initBody ( true ) ;
} ;
BootstrapTable . prototype . getOptions = function ( ) {
//Deep copy
return $ . extend ( true , { } , this . options ) ;
} ;
BootstrapTable . prototype . getSelections = function ( ) {
var that = this ;
return $ . grep ( this . options . data , function ( row ) {
// fix #2424: from html with checkbox
return row [ that . header . stateField ] === true ;
} ) ;
} ;
BootstrapTable . prototype . getAllSelections = function ( ) {
var that = this ;
return $ . grep ( this . options . data , function ( row ) {
return row [ that . header . stateField ] ;
} ) ;
} ;
BootstrapTable . prototype . checkAll = function ( ) {
this . checkAll _ ( true ) ;
} ;
BootstrapTable . prototype . uncheckAll = function ( ) {
this . checkAll _ ( false ) ;
} ;
BootstrapTable . prototype . checkInvert = function ( ) {
var that = this ;
var rows = that . $selectItem . filter ( ':enabled' ) ;
var checked = rows . filter ( ':checked' ) ;
rows . each ( function ( ) {
$ ( this ) . prop ( 'checked' , ! $ ( this ) . prop ( 'checked' ) ) ;
} ) ;
that . updateRows ( ) ;
that . updateSelected ( ) ;
that . trigger ( 'uncheck-some' , checked ) ;
checked = that . getSelections ( ) ;
that . trigger ( 'check-some' , checked ) ;
} ;
BootstrapTable . prototype . checkAll _ = function ( checked ) {
var rows ;
if ( ! checked ) {
rows = this . getSelections ( ) ;
}
this . $selectAll . add ( this . $selectAll _ ) . prop ( 'checked' , checked ) ;
this . $selectItem . filter ( ':enabled' ) . prop ( 'checked' , checked ) ;
this . updateRows ( ) ;
if ( checked ) {
rows = this . getSelections ( ) ;
}
this . trigger ( checked ? 'check-all' : 'uncheck-all' , rows ) ;
} ;
BootstrapTable . prototype . check = function ( index ) {
this . check _ ( true , index ) ;
} ;
BootstrapTable . prototype . uncheck = function ( index ) {
this . check _ ( false , index ) ;
} ;
BootstrapTable . prototype . check _ = function ( checked , index ) {
var $el = this . $selectItem . filter ( sprintf ( '[data-index="%s"]' , index ) ) . prop ( 'checked' , checked ) ;
this . data [ index ] [ this . header . stateField ] = checked ;
this . updateSelected ( ) ;
this . trigger ( checked ? 'check' : 'uncheck' , this . data [ index ] , $el ) ;
} ;
BootstrapTable . prototype . checkBy = function ( obj ) {
this . checkBy _ ( true , obj ) ;
} ;
BootstrapTable . prototype . uncheckBy = function ( obj ) {
this . checkBy _ ( false , obj ) ;
} ;
BootstrapTable . prototype . checkBy _ = function ( checked , obj ) {
if ( ! obj . hasOwnProperty ( 'field' ) || ! obj . hasOwnProperty ( 'values' ) ) {
return ;
}
var that = this ,
rows = [ ] ;
$ . each ( this . options . data , function ( index , row ) {
if ( ! row . hasOwnProperty ( obj . field ) ) {
return false ;
}
if ( $ . inArray ( row [ obj . field ] , obj . values ) !== - 1 ) {
var $el = that . $selectItem . filter ( ':enabled' )
. filter ( sprintf ( '[data-index="%s"]' , index ) ) . prop ( 'checked' , checked ) ;
row [ that . header . stateField ] = checked ;
rows . push ( row ) ;
that . trigger ( checked ? 'check' : 'uncheck' , row , $el ) ;
}
} ) ;
this . updateSelected ( ) ;
this . trigger ( checked ? 'check-some' : 'uncheck-some' , rows ) ;
} ;
BootstrapTable . prototype . destroy = function ( ) {
this . $el . insertBefore ( this . $container ) ;
$ ( this . options . toolbar ) . insertBefore ( this . $el ) ;
this . $container . next ( ) . remove ( ) ;
this . $container . remove ( ) ;
this . $el . html ( this . $el _ . html ( ) )
. css ( 'margin-top' , '0' )
. attr ( 'class' , this . $el _ . attr ( 'class' ) || '' ) ; // reset the class
} ;
BootstrapTable . prototype . showLoading = function ( ) {
this . $tableLoading . show ( ) ;
} ;
BootstrapTable . prototype . hideLoading = function ( ) {
this . $tableLoading . hide ( ) ;
} ;
BootstrapTable . prototype . togglePagination = function ( ) {
this . options . pagination = ! this . options . pagination ;
var button = this . $toolbar . find ( 'button[name="paginationSwitch"] i' ) ;
if ( this . options . pagination ) {
button . attr ( "class" , this . options . iconsPrefix + " " + this . options . icons . paginationSwitchDown ) ;
} else {
button . attr ( "class" , this . options . iconsPrefix + " " + this . options . icons . paginationSwitchUp ) ;
}
this . updatePagination ( ) ;
} ;
BootstrapTable . prototype . toggleFullscreen = function ( ) {
this . $el . closest ( '.bootstrap-table' ) . toggleClass ( 'fullscreen' ) ;
} ;
BootstrapTable . prototype . refresh = function ( params ) {
if ( params && params . url ) {
this . options . url = params . url ;
}
if ( params && params . pageNumber ) {
this . options . pageNumber = params . pageNumber ;
}
if ( params && params . pageSize ) {
this . options . pageSize = params . pageSize ;
}
this . initServer ( params && params . silent ,
params && params . query , params && params . url ) ;
this . trigger ( 'refresh' , params ) ;
} ;
BootstrapTable . prototype . resetWidth = function ( ) {
if ( this . options . showHeader && this . options . height ) {
this . fitHeader ( ) ;
}
if ( this . options . showFooter && ! this . options . cardView ) {
this . fitFooter ( ) ;
}
} ;
BootstrapTable . prototype . showColumn = function ( field ) {
this . toggleColumn ( this . fieldsColumnsIndex [ field ] , true , true ) ;
} ;
BootstrapTable . prototype . hideColumn = function ( field ) {
this . toggleColumn ( this . fieldsColumnsIndex [ field ] , false , true ) ;
} ;
BootstrapTable . prototype . getHiddenColumns = function ( ) {
return $ . grep ( this . columns , function ( column ) {
return ! column . visible ;
} ) ;
} ;
BootstrapTable . prototype . getVisibleColumns = function ( ) {
return $ . grep ( this . columns , function ( column ) {
return column . visible ;
} ) ;
} ;
BootstrapTable . prototype . toggleAllColumns = function ( visible ) {
var that = this ;
$ . each ( this . columns , function ( i , column ) {
that . columns [ i ] . visible = visible ;
} ) ;
this . initHeader ( ) ;
this . initSearch ( ) ;
this . initPagination ( ) ;
this . initBody ( ) ;
if ( this . options . showColumns ) {
var $items = this . $toolbar . find ( '.keep-open input' ) . prop ( 'disabled' , false ) ;
if ( $items . filter ( ':checked' ) . length <= this . options . minimumCountColumns ) {
$items . filter ( ':checked' ) . prop ( 'disabled' , true ) ;
}
}
} ;
BootstrapTable . prototype . showAllColumns = function ( ) {
this . toggleAllColumns ( true ) ;
} ;
BootstrapTable . prototype . hideAllColumns = function ( ) {
this . toggleAllColumns ( false ) ;
} ;
BootstrapTable . prototype . filterBy = function ( columns ) {
this . filterColumns = $ . isEmptyObject ( columns ) ? { } : columns ;
this . options . pageNumber = 1 ;
this . initSearch ( ) ;
this . updatePagination ( ) ;
} ;
BootstrapTable . prototype . scrollTo = function ( value ) {
if ( typeof value === 'string' ) {
value = value === 'bottom' ? this . $tableBody [ 0 ] . scrollHeight : 0 ;
}
if ( typeof value === 'number' ) {
this . $tableBody . scrollTop ( value ) ;
}
if ( typeof value === 'undefined' ) {
return this . $tableBody . scrollTop ( ) ;
}
} ;
BootstrapTable . prototype . getScrollPosition = function ( ) {
return this . scrollTo ( ) ;
} ;
BootstrapTable . prototype . selectPage = function ( page ) {
if ( page > 0 && page <= this . options . totalPages ) {
this . options . pageNumber = page ;
this . updatePagination ( ) ;
}
} ;
BootstrapTable . prototype . prevPage = function ( ) {
if ( this . options . pageNumber > 1 ) {
this . options . pageNumber -- ;
this . updatePagination ( ) ;
}
} ;
BootstrapTable . prototype . nextPage = function ( ) {
if ( this . options . pageNumber < this . options . totalPages ) {
this . options . pageNumber ++ ;
this . updatePagination ( ) ;
}
} ;
BootstrapTable . prototype . toggleView = function ( ) {
this . options . cardView = ! this . options . cardView ;
this . initHeader ( ) ;
// Fixed remove toolbar when click cardView button.
//that.initToolbar();
var $icon = this . $toolbar . find ( 'button[name="toggle"] i' ) ;
if ( this . options . cardView ) {
$icon . removeClass ( this . options . icons . toggleOff ) ;
$icon . addClass ( this . options . icons . toggleOn ) ;
} else {
$icon . removeClass ( this . options . icons . toggleOn ) ;
$icon . addClass ( this . options . icons . toggleOff ) ;
}
this . initBody ( ) ;
this . trigger ( 'toggle' , this . options . cardView ) ;
} ;
BootstrapTable . prototype . refreshOptions = function ( options ) {
//If the objects are equivalent then avoid the call of destroy / init methods
if ( compareObjects ( this . options , options , true ) ) {
return ;
}
this . options = $ . extend ( this . options , options ) ;
this . trigger ( 'refresh-options' , this . options ) ;
this . destroy ( ) ;
this . init ( ) ;
} ;
BootstrapTable . prototype . resetSearch = function ( text ) {
var $search = this . $toolbar . find ( '.search input' ) ;
$search . val ( text || '' ) ;
this . onSearch ( { currentTarget : $search } ) ;
} ;
BootstrapTable . prototype . expandRow _ = function ( expand , index ) {
var $tr = this . $body . find ( sprintf ( '> tr[data-index="%s"]' , index ) ) ;
if ( $tr . next ( ) . is ( 'tr.detail-view' ) === ( expand ? false : true ) ) {
$tr . find ( '> td > .detail-icon' ) . click ( ) ;
}
} ;
BootstrapTable . prototype . expandRow = function ( index ) {
this . expandRow _ ( true , index ) ;
} ;
BootstrapTable . prototype . collapseRow = function ( index ) {
this . expandRow _ ( false , index ) ;
} ;
BootstrapTable . prototype . expandAllRows = function ( isSubTable ) {
if ( isSubTable ) {
var $tr = this . $body . find ( sprintf ( '> tr[data-index="%s"]' , 0 ) ) ,
that = this ,
detailIcon = null ,
executeInterval = false ,
idInterval = - 1 ;
if ( ! $tr . next ( ) . is ( 'tr.detail-view' ) ) {
$tr . find ( '> td > .detail-icon' ) . click ( ) ;
executeInterval = true ;
} else if ( ! $tr . next ( ) . next ( ) . is ( 'tr.detail-view' ) ) {
$tr . next ( ) . find ( ".detail-icon" ) . click ( ) ;
executeInterval = true ;
}
if ( executeInterval ) {
try {
idInterval = setInterval ( function ( ) {
detailIcon = that . $body . find ( "tr.detail-view" ) . last ( ) . find ( ".detail-icon" ) ;
if ( detailIcon . length > 0 ) {
detailIcon . click ( ) ;
} else {
clearInterval ( idInterval ) ;
}
} , 1 ) ;
} catch ( ex ) {
clearInterval ( idInterval ) ;
}
}
} else {
var trs = this . $body . children ( ) ;
for ( var i = 0 ; i < trs . length ; i ++ ) {
this . expandRow _ ( true , $ ( trs [ i ] ) . data ( "index" ) ) ;
}
}
} ;
BootstrapTable . prototype . collapseAllRows = function ( isSubTable ) {
if ( isSubTable ) {
this . expandRow _ ( false , 0 ) ;
} else {
var trs = this . $body . children ( ) ;
for ( var i = 0 ; i < trs . length ; i ++ ) {
this . expandRow _ ( false , $ ( trs [ i ] ) . data ( "index" ) ) ;
}
}
} ;
BootstrapTable . prototype . updateFormatText = function ( name , text ) {
if ( this . options [ sprintf ( 'format%s' , name ) ] ) {
if ( typeof text === 'string' ) {
this . options [ sprintf ( 'format%s' , name ) ] = function ( ) {
return text ;
} ;
} else if ( typeof text === 'function' ) {
this . options [ sprintf ( 'format%s' , name ) ] = text ;
}
}
this . initToolbar ( ) ;
this . initPagination ( ) ;
this . initBody ( ) ;
} ;
// BOOTSTRAP TABLE PLUGIN DEFINITION
// =======================
var allowedMethods = [
'getOptions' ,
'getSelections' , 'getAllSelections' , 'getData' ,
'load' , 'append' , 'prepend' , 'remove' , 'removeAll' ,
'insertRow' , 'updateRow' , 'updateCell' , 'updateByUniqueId' , 'removeByUniqueId' ,
'getRowByUniqueId' , 'showRow' , 'hideRow' , 'getHiddenRows' ,
'mergeCells' , 'refreshColumnTitle' ,
'checkAll' , 'uncheckAll' , 'checkInvert' ,
'check' , 'uncheck' ,
'checkBy' , 'uncheckBy' ,
'refresh' ,
'resetView' ,
'resetWidth' ,
'destroy' ,
'showLoading' , 'hideLoading' ,
'showColumn' , 'hideColumn' , 'getHiddenColumns' , 'getVisibleColumns' ,
'showAllColumns' , 'hideAllColumns' ,
'filterBy' ,
'scrollTo' ,
'getScrollPosition' ,
'selectPage' , 'prevPage' , 'nextPage' ,
'togglePagination' ,
'toggleView' ,
'refreshOptions' ,
'resetSearch' ,
'expandRow' , 'collapseRow' , 'expandAllRows' , 'collapseAllRows' ,
'updateFormatText' , 'updateCellById'
] ;
$ . fn . bootstrapTable = function ( option ) {
var value ,
args = Array . prototype . slice . call ( arguments , 1 ) ;
this . each ( function ( ) {
var $this = $ ( this ) ,
data = $this . data ( 'bootstrap.table' ) ,
options = $ . extend ( { } , BootstrapTable . DEFAULTS , $this . data ( ) ,
typeof option === 'object' && option ) ;
if ( typeof option === 'string' ) {
if ( $ . inArray ( option , allowedMethods ) < 0 ) {
throw new Error ( "Unknown method: " + option ) ;
}
if ( ! data ) {
return ;
}
value = data [ option ] . apply ( data , args ) ;
if ( option === 'destroy' ) {
$this . removeData ( 'bootstrap.table' ) ;
}
}
if ( ! data ) {
$this . data ( 'bootstrap.table' , ( data = new BootstrapTable ( this , options ) ) ) ;
}
} ) ;
return typeof value === 'undefined' ? this : value ;
} ;
$ . fn . bootstrapTable . Constructor = BootstrapTable ;
$ . fn . bootstrapTable . defaults = BootstrapTable . DEFAULTS ;
$ . fn . bootstrapTable . columnDefaults = BootstrapTable . COLUMN _DEFAULTS ;
$ . fn . bootstrapTable . locales = BootstrapTable . LOCALES ;
$ . fn . bootstrapTable . methods = allowedMethods ;
$ . fn . bootstrapTable . utils = {
bootstrapVersion : bootstrapVersion ,
sprintf : sprintf ,
compareObjects : compareObjects ,
calculateObjectValue : calculateObjectValue ,
getItemField : getItemField ,
objectKeys : objectKeys ,
isIEBrowser : isIEBrowser
} ;
// BOOTSTRAP TABLE INIT
// =======================
$ ( function ( ) {
$ ( '[data-toggle="table"]' ) . bootstrapTable ( ) ;
} ) ;
} ) ( jQuery ) ;
/ * *
* @ author zhixin wen < wenzhixin2010 @ gmail . com >
* extensions : https : //github.com/kayalshri/tableExport.jquery.plugin
* /
( function ( $ ) {
'use strict' ;
var sprintf = $ . fn . bootstrapTable . utils . sprintf ;
var TYPE _NAME = {
json : 'JSON' ,
xml : 'XML' ,
png : 'PNG' ,
csv : 'CSV' ,
txt : 'TXT' ,
sql : 'SQL' ,
doc : 'MS-Word' ,
excel : 'MS-Excel' ,
xlsx : 'MS-Excel (OpenXML)' ,
powerpoint : 'MS-Powerpoint' ,
pdf : 'PDF'
} ;
$ . extend ( $ . fn . bootstrapTable . defaults , {
showExport : false ,
exportDataType : 'basic' , // basic, all, selected
// 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'powerpoint', 'pdf'
exportTypes : [ 'json' , 'xml' , 'csv' , 'txt' , 'sql' , 'excel' ] ,
exportOptions : { }
} ) ;
$ . extend ( $ . fn . bootstrapTable . defaults . icons , {
export : 'glyphicon-export icon-share'
} ) ;
$ . extend ( $ . fn . bootstrapTable . locales , {
formatExport : function ( ) {
return 'Export data' ;
}
} ) ;
$ . extend ( $ . fn . bootstrapTable . defaults , $ . fn . bootstrapTable . locales ) ;
var BootstrapTable = $ . fn . bootstrapTable . Constructor ,
_initToolbar = BootstrapTable . prototype . initToolbar ;
BootstrapTable . prototype . initToolbar = function ( ) {
this . showToolbar = this . showToolbar || this . options . showExport ;
_initToolbar . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
if ( this . options . showExport ) {
var that = this ,
$btnGroup = this . $toolbar . find ( '>.btn-group' ) ,
$export = $btnGroup . find ( 'div.export' ) ;
if ( ! $export . length ) {
$export = $ ( [
'<div class="export btn-group">' ,
'<button class="btn' +
sprintf ( ' btn-%s' , this . options . buttonsClass ) +
sprintf ( ' btn-%s' , this . options . iconSize ) +
' dropdown-toggle" aria-label="export type" ' +
'title="' + this . options . formatExport ( ) + '" ' +
'data-toggle="dropdown" type="button">' ,
sprintf ( '<i class="%s %s"></i> ' , this . options . iconsPrefix , this . options . icons . export ) ,
'<span class="caret"></span>' ,
'</button>' ,
'<ul class="dropdown-menu" role="menu">' ,
'</ul>' ,
'</div>' ] . join ( '' ) ) . appendTo ( $btnGroup ) ;
var $menu = $export . find ( '.dropdown-menu' ) ,
exportTypes = this . options . exportTypes ;
if ( typeof this . options . exportTypes === 'string' ) {
var types = this . options . exportTypes . slice ( 1 , - 1 ) . replace ( / /g , '' ) . split ( ',' ) ;
exportTypes = [ ] ;
$ . each ( types , function ( i , value ) {
exportTypes . push ( value . slice ( 1 , - 1 ) ) ;
} ) ;
}
$ . each ( exportTypes , function ( i , type ) {
if ( TYPE _NAME . hasOwnProperty ( type ) ) {
$menu . append ( [ '<li role="menuitem" data-type="' + type + '">' ,
'<a href="javascript:void(0)">' ,
TYPE _NAME [ type ] ,
'</a>' ,
'</li>' ] . join ( '' ) ) ;
}
} ) ;
$menu . find ( 'li' ) . click ( function ( ) {
var type = $ ( this ) . data ( 'type' ) ,
doExport = function ( ) {
if ( ! ! that . options . exportFooter ) {
var data = that . getData ( ) ;
var $footerRow = that . $tableFooter . find ( "tr" ) . first ( ) ;
var footerData = { } ;
var footerHtml = [ ] ;
$ . each ( $footerRow . children ( ) , function ( index , footerCell ) {
var footerCellHtml = $ ( footerCell ) . children ( ".th-inner" ) . first ( ) . html ( ) ;
footerData [ that . columns [ index ] . field ] = footerCellHtml == ' ' ? null : footerCellHtml ;
// grab footer cell text into cell index-based array
footerHtml . push ( footerCellHtml ) ;
} ) ;
that . append ( footerData ) ;
var $lastTableRow = that . $body . children ( ) . last ( ) ;
$ . each ( $lastTableRow . children ( ) , function ( index , lastTableRowCell ) {
$ ( lastTableRowCell ) . html ( footerHtml [ index ] ) ;
} ) ;
}
that . $el . tableExport ( $ . extend ( { } , that . options . exportOptions , {
type : type ,
escape : false
} ) ) ;
if ( ! ! that . options . exportFooter ) {
that . load ( data ) ;
}
} ;
var stateField = that . header . stateField ;
if ( that . options . exportDataType === 'all' && that . options . pagination ) {
that . $el . one ( that . options . sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table' , function ( ) {
if ( stateField ) {
that . hideColumn ( stateField ) ;
}
doExport ( ) ;
that . togglePagination ( ) ;
} ) ;
that . togglePagination ( ) ;
} else if ( that . options . exportDataType === 'selected' ) {
var data = that . getData ( ) ,
selectedData = that . getSelections ( ) ;
if ( ! selectedData . length ) {
return ;
}
if ( that . options . sidePagination === 'server' ) {
var dataServer = { total : that . options . totalRows } ;
dataServer [ that . options . dataField ] = data ;
data = dataServer ;
var selectedDataServer = { total : selectedData . length } ;
selectedDataServer [ that . options . dataField ] = selectedData ;
selectedData = selectedDataServer ;
}
that . load ( selectedData ) ;
if ( stateField ) {
that . hideColumn ( stateField ) ;
}
doExport ( ) ;
that . load ( data ) ;
} else {
if ( stateField ) {
that . hideColumn ( stateField ) ;
}
doExport ( ) ;
}
if ( stateField ) {
that . showColumn ( stateField ) ;
}
} ) ;
}
}
} ;
} ) ( jQuery ) ;
/ * *
* @ author : Dennis Hernández
* @ webSite : http : //djhvscf.github.io/Blog
* @ version : v1 . 2.3
*
* @ update zhixin wen < wenzhixin2010 @ gmail . com >
* /
( function ( $ ) {
'use strict' ;
var cookieIds = {
sortOrder : 'bs.table.sortOrder' ,
sortName : 'bs.table.sortName' ,
pageNumber : 'bs.table.pageNumber' ,
pageList : 'bs.table.pageList' ,
columns : 'bs.table.columns' ,
searchText : 'bs.table.searchText' ,
filterControl : 'bs.table.filterControl'
} ;
var getCurrentHeader = function ( that ) {
var header = that . $header ;
if ( that . options . height ) {
header = that . $tableHeader ;
}
return header ;
} ;
var getCurrentSearchControls = function ( that ) {
var searchControls = 'select, input' ;
if ( that . options . height ) {
searchControls = 'table select, table input' ;
}
return searchControls ;
} ;
var cookieEnabled = function ( ) {
return ! ! ( navigator . cookieEnabled ) ;
} ;
var inArrayCookiesEnabled = function ( cookieName , cookiesEnabled ) {
var index = - 1 ;
for ( var i = 0 ; i < cookiesEnabled . length ; i ++ ) {
if ( cookieName . toLowerCase ( ) === cookiesEnabled [ i ] . toLowerCase ( ) ) {
index = i ;
break ;
}
}
return index ;
} ;
var setCookie = function ( that , cookieName , cookieValue ) {
if ( ( ! that . options . cookie ) || ( ! cookieEnabled ( ) ) || ( that . options . cookieIdTable === '' ) ) {
return ;
}
if ( inArrayCookiesEnabled ( cookieName , that . options . cookiesEnabled ) === - 1 ) {
return ;
}
cookieName = that . options . cookieIdTable + '.' + cookieName ;
switch ( that . options . cookieStorage ) {
case 'cookieStorage' :
document . cookie = [
cookieName , '=' , cookieValue ,
'; expires=' + calculateExpiration ( that . options . cookieExpire ) ,
that . options . cookiePath ? '; path=' + that . options . cookiePath : '' ,
that . options . cookieDomain ? '; domain=' + that . options . cookieDomain : '' ,
that . options . cookieSecure ? '; secure' : ''
] . join ( '' ) ;
case 'localStorage' :
localStorage . setItem ( cookieName , cookieValue ) ;
break ;
case 'sessionStorage' :
sessionStorage . setItem ( cookieName , cookieValue ) ;
break ;
default :
return false ;
}
return true ;
} ;
var getCookie = function ( that , tableName , cookieName ) {
if ( ! cookieName ) {
return null ;
}
if ( inArrayCookiesEnabled ( cookieName , that . options . cookiesEnabled ) === - 1 ) {
return null ;
}
cookieName = tableName + '.' + cookieName ;
switch ( that . options . cookieStorage ) {
case 'cookieStorage' :
var value = '; ' + document . cookie ;
var parts = value . split ( '; ' + cookieName + '=' ) ;
return parts . length === 2 ? parts . pop ( ) . split ( ';' ) . shift ( ) : null ;
case 'localStorage' :
return localStorage . getItem ( cookieName ) ;
case 'sessionStorage' :
return sessionStorage . getItem ( cookieName ) ;
default :
return null ;
}
} ;
var deleteCookie = function ( that , tableName , cookieName ) {
cookieName = tableName + '.' + cookieName ;
switch ( that . options . cookieStorage ) {
case 'cookieStorage' :
document . cookie = [
encodeURIComponent ( cookieName ) , '=' ,
'; expires=Thu, 01 Jan 1970 00:00:00 GMT' ,
that . options . cookiePath ? '; path=' + that . options . cookiePath : '' ,
that . options . cookieDomain ? '; domain=' + that . options . cookieDomain : '' ,
] . join ( '' ) ;
break ;
case 'localStorage' :
localStorage . removeItem ( cookieName ) ;
break ;
case 'sessionStorage' :
sessionStorage . removeItem ( cookieName ) ;
break ;
}
return true ;
} ;
var calculateExpiration = function ( cookieExpire ) {
var time = cookieExpire . replace ( /[0-9]*/ , '' ) ; //s,mi,h,d,m,y
cookieExpire = cookieExpire . replace ( /[A-Za-z]{1,2}/ , '' ) ; //number
switch ( time . toLowerCase ( ) ) {
case 's' :
cookieExpire = + cookieExpire ;
break ;
case 'mi' :
cookieExpire = cookieExpire * 60 ;
break ;
case 'h' :
cookieExpire = cookieExpire * 60 * 60 ;
break ;
case 'd' :
cookieExpire = cookieExpire * 24 * 60 * 60 ;
break ;
case 'm' :
cookieExpire = cookieExpire * 30 * 24 * 60 * 60 ;
break ;
case 'y' :
cookieExpire = cookieExpire * 365 * 24 * 60 * 60 ;
break ;
default :
cookieExpire = undefined ;
break ;
}
if ( ! cookieExpire ) {
return '' ;
}
var d = new Date ( ) ;
d . setTime ( d . getTime ( ) + cookieExpire * 1000 ) ;
return d . toGMTString ( ) ;
} ;
var initCookieFilters = function ( bootstrapTable ) {
setTimeout ( function ( ) {
var parsedCookieFilters = JSON . parse ( getCookie ( bootstrapTable , bootstrapTable . options . cookieIdTable , cookieIds . filterControl ) ) ;
if ( ! bootstrapTable . options . filterControlValuesLoaded && parsedCookieFilters ) {
var cachedFilters = { } ,
header = getCurrentHeader ( bootstrapTable ) ,
searchControls = getCurrentSearchControls ( bootstrapTable ) ,
applyCookieFilters = function ( element , filteredCookies ) {
$ ( filteredCookies ) . each ( function ( i , cookie ) {
if ( cookie . text !== '' ) {
$ ( element ) . val ( cookie . text ) ;
cachedFilters [ cookie . field ] = cookie . text ;
}
} ) ;
} ;
header . find ( searchControls ) . each ( function ( ) {
var field = $ ( this ) . closest ( '[data-field]' ) . data ( 'field' ) ,
filteredCookies = $ . grep ( parsedCookieFilters , function ( cookie ) {
return cookie . field === field ;
} ) ;
applyCookieFilters ( this , filteredCookies ) ;
} ) ;
bootstrapTable . initColumnSearch ( cachedFilters ) ;
bootstrapTable . options . filterControlValuesLoaded = true ;
bootstrapTable . initServer ( ) ;
}
} , 250 ) ;
} ;
$ . extend ( $ . fn . bootstrapTable . defaults , {
cookie : false ,
cookieExpire : '2h' ,
cookiePath : null ,
cookieDomain : null ,
cookieSecure : null ,
cookieIdTable : '' ,
cookiesEnabled : [
'bs.table.sortOrder' , 'bs.table.sortName' ,
'bs.table.pageNumber' , 'bs.table.pageList' ,
'bs.table.columns' , 'bs.table.searchText' ,
'bs.table.filterControl'
] ,
cookieStorage : 'cookieStorage' , //localStorage, sessionStorage
//internal variable
filterControls : [ ] ,
filterControlValuesLoaded : false
} ) ;
$ . fn . bootstrapTable . methods . push ( 'getCookies' ) ;
$ . fn . bootstrapTable . methods . push ( 'deleteCookie' ) ;
$ . extend ( $ . fn . bootstrapTable . utils , {
setCookie : setCookie ,
getCookie : getCookie
} ) ;
var BootstrapTable = $ . fn . bootstrapTable . Constructor ,
_init = BootstrapTable . prototype . init ,
_initTable = BootstrapTable . prototype . initTable ,
_initServer = BootstrapTable . prototype . initServer ,
_onSort = BootstrapTable . prototype . onSort ,
_onPageNumber = BootstrapTable . prototype . onPageNumber ,
_onPageListChange = BootstrapTable . prototype . onPageListChange ,
_onPagePre = BootstrapTable . prototype . onPagePre ,
_onPageNext = BootstrapTable . prototype . onPageNext ,
_toggleColumn = BootstrapTable . prototype . toggleColumn ,
_selectPage = BootstrapTable . prototype . selectPage ,
_onSearch = BootstrapTable . prototype . onSearch ;
BootstrapTable . prototype . init = function ( ) {
this . options . filterControls = [ ] ;
this . options . filterControlValuesLoaded = false ;
this . options . cookiesEnabled = typeof this . options . cookiesEnabled === 'string' ?
this . options . cookiesEnabled . replace ( '[' , '' ) . replace ( ']' , '' )
. replace ( / /g , '' ) . toLowerCase ( ) . split ( ',' ) :
this . options . cookiesEnabled ;
if ( this . options . filterControl ) {
var that = this ;
this . $el . on ( 'column-search.bs.table' , function ( e , field , text ) {
var isNewField = true ;
for ( var i = 0 ; i < that . options . filterControls . length ; i ++ ) {
if ( that . options . filterControls [ i ] . field === field ) {
that . options . filterControls [ i ] . text = text ;
isNewField = false ;
break ;
}
}
if ( isNewField ) {
that . options . filterControls . push ( {
field : field ,
text : text
} ) ;
}
setCookie ( that , cookieIds . filterControl , JSON . stringify ( that . options . filterControls ) ) ;
} ) . on ( 'post-body.bs.table' , initCookieFilters ( that ) ) ;
}
_init . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
} ;
BootstrapTable . prototype . initServer = function ( ) {
var bootstrapTable = this ;
if ( bootstrapTable . options . cookie && bootstrapTable . options . filterControl && ! bootstrapTable . options . filterControlValuesLoaded ) {
var cookie = JSON . parse ( getCookie ( bootstrapTable , bootstrapTable . options . cookieIdTable , cookieIds . filterControl ) ) ;
if ( cookie )
return ;
}
_initServer . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
} ;
BootstrapTable . prototype . initTable = function ( ) {
_initTable . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
this . initCookie ( ) ;
} ;
BootstrapTable . prototype . initCookie = function ( ) {
if ( ! this . options . cookie ) {
return ;
}
if ( ( this . options . cookieIdTable === '' ) || ( this . options . cookieExpire === '' ) || ( ! cookieEnabled ( ) ) ) {
console . error ( "Configuration error. Please review the cookieIdTable, cookieExpire properties, if those properties are ok, then this browser does not support the cookies" ) ;
this . options . cookie = false ; //Make sure that the cookie extension is disabled
return ;
}
var sortOrderCookie = getCookie ( this , this . options . cookieIdTable , cookieIds . sortOrder ) ,
sortOrderNameCookie = getCookie ( this , this . options . cookieIdTable , cookieIds . sortName ) ,
pageNumberCookie = getCookie ( this , this . options . cookieIdTable , cookieIds . pageNumber ) ,
pageListCookie = getCookie ( this , this . options . cookieIdTable , cookieIds . pageList ) ,
columnsCookie = JSON . parse ( getCookie ( this , this . options . cookieIdTable , cookieIds . columns ) ) ,
searchTextCookie = getCookie ( this , this . options . cookieIdTable , cookieIds . searchText ) ;
//sortOrder
this . options . sortOrder = sortOrderCookie ? sortOrderCookie : this . options . sortOrder ;
//sortName
this . options . sortName = sortOrderNameCookie ? sortOrderNameCookie : this . options . sortName ;
//pageNumber
this . options . pageNumber = pageNumberCookie ? + pageNumberCookie : this . options . pageNumber ;
//pageSize
this . options . pageSize = pageListCookie ? pageListCookie === this . options . formatAllRows ( ) ? pageListCookie : + pageListCookie : this . options . pageSize ;
//searchText
this . options . searchText = searchTextCookie ? searchTextCookie : '' ;
if ( columnsCookie ) {
$ . each ( this . columns , function ( i , column ) {
column . visible = $ . inArray ( column . field , columnsCookie ) !== - 1 ;
} ) ;
}
} ;
BootstrapTable . prototype . onSort = function ( ) {
_onSort . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
setCookie ( this , cookieIds . sortOrder , this . options . sortOrder ) ;
setCookie ( this , cookieIds . sortName , this . options . sortName ) ;
} ;
BootstrapTable . prototype . onPageNumber = function ( ) {
_onPageNumber . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
setCookie ( this , cookieIds . pageNumber , this . options . pageNumber ) ;
return false ;
} ;
BootstrapTable . prototype . onPageListChange = function ( ) {
_onPageListChange . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
setCookie ( this , cookieIds . pageList , this . options . pageSize ) ;
setCookie ( this , cookieIds . pageNumber , this . options . pageNumber ) ;
return false ;
} ;
BootstrapTable . prototype . onPagePre = function ( ) {
_onPagePre . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
setCookie ( this , cookieIds . pageNumber , this . options . pageNumber ) ;
return false ;
} ;
BootstrapTable . prototype . onPageNext = function ( ) {
_onPageNext . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
setCookie ( this , cookieIds . pageNumber , this . options . pageNumber ) ;
return false ;
} ;
BootstrapTable . prototype . toggleColumn = function ( ) {
_toggleColumn . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
var visibleColumns = [ ] ;
$ . each ( this . columns , function ( i , column ) {
if ( column . visible ) {
visibleColumns . push ( column . field ) ;
}
} ) ;
setCookie ( this , cookieIds . columns , JSON . stringify ( visibleColumns ) ) ;
} ;
BootstrapTable . prototype . selectPage = function ( page ) {
_selectPage . apply ( this , Array . prototype . slice . apply ( arguments ) ) ;
setCookie ( this , cookieIds . pageNumber , page ) ;
} ;
BootstrapTable . prototype . onSearch = function ( ) {
var target = Array . prototype . slice . apply ( arguments ) ;
_onSearch . apply ( this , target ) ;
if ( $ ( target [ 0 ] . currentTarget ) . parent ( ) . hasClass ( 'search' ) ) {
setCookie ( this , cookieIds . searchText , this . searchText ) ;
}
setCookie ( this , cookieIds . pageNumber , this . options . pageNumber ) ;
} ;
BootstrapTable . prototype . getCookies = function ( ) {
var bootstrapTable = this ;
var cookies = { } ;
$ . each ( cookieIds , function ( key , value ) {
cookies [ key ] = getCookie ( bootstrapTable , bootstrapTable . options . cookieIdTable , value ) ;
if ( key === 'columns' ) {
cookies [ key ] = JSON . parse ( cookies [ key ] ) ;
}
} ) ;
return cookies ;
} ;
BootstrapTable . prototype . deleteCookie = function ( cookieName ) {
if ( ( cookieName === '' ) || ( ! cookieEnabled ( ) ) ) {
return ;
}
deleteCookie ( this , this . options . cookieIdTable , cookieIds [ cookieName ] ) ;
} ;
} ) ( jQuery ) ;
jQuery . base64 = ( function ( $ ) {
// private property
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ;
// private method for UTF-8 encoding
function utf8Encode ( string ) {
string = string . replace ( /\r\n/g , "\n" ) ;
var utftext = "" ;
for ( var n = 0 ; n < string . length ; n ++ ) {
var c = string . charCodeAt ( n ) ;
if ( c < 128 ) {
utftext += String . fromCharCode ( c ) ;
}
else if ( ( c > 127 ) && ( c < 2048 ) ) {
utftext += String . fromCharCode ( ( c >> 6 ) | 192 ) ;
utftext += String . fromCharCode ( ( c & 63 ) | 128 ) ;
}
else {
utftext += String . fromCharCode ( ( c >> 12 ) | 224 ) ;
utftext += String . fromCharCode ( ( ( c >> 6 ) & 63 ) | 128 ) ;
utftext += String . fromCharCode ( ( c & 63 ) | 128 ) ;
}
}
return utftext ;
}
function encode ( input ) {
var output = "" ;
var chr1 , chr2 , chr3 , enc1 , enc2 , enc3 , enc4 ;
var i = 0 ;
input = utf8Encode ( input ) ;
while ( i < input . length ) {
chr1 = input . charCodeAt ( i ++ ) ;
chr2 = input . charCodeAt ( i ++ ) ;
chr3 = input . charCodeAt ( i ++ ) ;
enc1 = chr1 >> 2 ;
enc2 = ( ( chr1 & 3 ) << 4 ) | ( chr2 >> 4 ) ;
enc3 = ( ( chr2 & 15 ) << 2 ) | ( chr3 >> 6 ) ;
enc4 = chr3 & 63 ;
if ( isNaN ( chr2 ) ) {
enc3 = enc4 = 64 ;
} else if ( isNaN ( chr3 ) ) {
enc4 = 64 ;
}
output = output +
keyStr . charAt ( enc1 ) + keyStr . charAt ( enc2 ) +
keyStr . charAt ( enc3 ) + keyStr . charAt ( enc4 ) ;
}
return output ;
}
return {
encode : function ( str ) {
return encode ( str ) ;
}
} ;
} ( jQuery ) ) ;
/ * *
* @ preserve tableExport . jquery . plugin
*
* Version 1.10 . 1
*
* Copyright ( c ) 2015 - 2018 hhurz , https : //github.com/hhurz
*
* Original Work Copyright ( c ) 2014 Giri Raj
*
* Licensed under the MIT License
* * /
'use strict' ;
( function ( $ ) {
$ . fn . tableExport = function ( options ) {
var defaults = {
csvEnclosure : '"' ,
csvSeparator : ',' ,
csvUseBOM : true ,
displayTableName : false ,
escape : false ,
exportHiddenCells : false , // true = speed up export of large tables with hidden cells (hidden cells will be exported !)
fileName : 'tableExport' ,
htmlContent : false ,
ignoreColumn : [ ] ,
ignoreRow : [ ] ,
jsonScope : 'all' , // head, data, all
jspdf : { // jsPDF / jsPDF-AutoTable related options
orientation : 'p' ,
unit : 'pt' ,
format : 'a4' , // One of jsPDF page formats or 'bestfit' for autmatic paper format selection
margins : { left : 20 , right : 10 , top : 10 , bottom : 10 } ,
onDocCreated : null ,
autotable : {
styles : {
cellPadding : 2 ,
rowHeight : 12 ,
fontSize : 8 ,
fillColor : 255 , // Color value or 'inherit' to use css background-color from html table
textColor : 50 , // Color value or 'inherit' to use css color from html table
fontStyle : 'normal' , // normal, bold, italic, bolditalic or 'inherit' to use css font-weight and fonst-style from html table
overflow : 'ellipsize' , // visible, hidden, ellipsize or linebreak
halign : 'inherit' , // left, center, right or 'inherit' to use css horizontal cell alignment from html table
valign : 'middle' // top, middle, bottom
} ,
headerStyles : {
fillColor : [ 52 , 73 , 94 ] ,
textColor : 255 ,
fontStyle : 'bold' ,
halign : 'inherit' , // left, center, right or 'inherit' to use css horizontal header cell alignment from html table
valign : 'middle' // top, middle, bottom
} ,
alternateRowStyles : {
fillColor : 245
} ,
tableExport : {
doc : null , // jsPDF doc object. If set, an already created doc will be used to export to
onAfterAutotable : null ,
onBeforeAutotable : null ,
onAutotableText : null ,
onTable : null ,
outputImages : true
}
}
} ,
mso : { // MS Excel and MS Word related options
fileFormat : 'xlshtml' , // xlshtml = Excel 2000 html format
// xmlss = XML Spreadsheet 2003 file format (XMLSS)
// xlsx = Excel 2007 Office Open XML format
onMsoNumberFormat : null , // Excel 2000 html format only. See readme.md for more information about msonumberformat
pageFormat : 'a4' , // Page format used for page orientation
pageOrientation : 'portrait' , // portrait, landscape (xlshtml format only)
rtl : false , // true = Set worksheet option 'DisplayRightToLeft'
styles : [ ] , // E.g. ['border-bottom', 'border-top', 'border-left', 'border-right']
worksheetName : ''
} ,
numbers : {
html : {
decimalMark : '.' ,
thousandsSeparator : ','
} ,
output : { // Use 'output: false' to keep number format in exported output
decimalMark : '.' ,
thousandsSeparator : ','
}
} ,
onCellData : null ,
onCellHtmlData : null ,
onIgnoreRow : null , // onIgnoreRow($tr, rowIndex): function should return true to not export a row
outputMode : 'file' , // 'file', 'string', 'base64' or 'window' (experimental)
pdfmake : {
enabled : false , // true: use pdfmake instead of jspdf and jspdf-autotable (experimental)
docDefinition : {
pageOrientation : 'portrait' , // 'portrait' or 'landscape'
defaultStyle : {
font : 'Roboto' // Default is 'Roboto', for arabic font set this option to 'Mirza' and include mirza_fonts.js
}
} ,
fonts : { }
} ,
preserve : {
leadingWS : false , // preserve leading white spaces
trailingWS : false // preserve trailing white spaces
} ,
preventInjection : true ,
tbodySelector : 'tr' ,
tfootSelector : 'tr' , // Set empty ('') to prevent export of tfoot rows
theadSelector : 'tr' ,
tableName : 'Table' ,
type : 'csv' // 'csv', 'tsv', 'txt', 'sql', 'json', 'xml', 'excel', 'doc', 'png' or 'pdf'
} ;
var pageFormats = { // Size in pt of various paper formats. Adopted from jsPDF.
'a0' : [ 2383.94 , 3370.39 ] , 'a1' : [ 1683.78 , 2383.94 ] , 'a2' : [ 1190.55 , 1683.78 ] ,
'a3' : [ 841.89 , 1190.55 ] , 'a4' : [ 595.28 , 841.89 ] , 'a5' : [ 419.53 , 595.28 ] ,
'a6' : [ 297.64 , 419.53 ] , 'a7' : [ 209.76 , 297.64 ] , 'a8' : [ 147.40 , 209.76 ] ,
'a9' : [ 104.88 , 147.40 ] , 'a10' : [ 73.70 , 104.88 ] ,
'b0' : [ 2834.65 , 4008.19 ] , 'b1' : [ 2004.09 , 2834.65 ] , 'b2' : [ 1417.32 , 2004.09 ] ,
'b3' : [ 1000.63 , 1417.32 ] , 'b4' : [ 708.66 , 1000.63 ] , 'b5' : [ 498.90 , 708.66 ] ,
'b6' : [ 354.33 , 498.90 ] , 'b7' : [ 249.45 , 354.33 ] , 'b8' : [ 175.75 , 249.45 ] ,
'b9' : [ 124.72 , 175.75 ] , 'b10' : [ 87.87 , 124.72 ] ,
'c0' : [ 2599.37 , 3676.54 ] ,
'c1' : [ 1836.85 , 2599.37 ] , 'c2' : [ 1298.27 , 1836.85 ] , 'c3' : [ 918.43 , 1298.27 ] ,
'c4' : [ 649.13 , 918.43 ] , 'c5' : [ 459.21 , 649.13 ] , 'c6' : [ 323.15 , 459.21 ] ,
'c7' : [ 229.61 , 323.15 ] , 'c8' : [ 161.57 , 229.61 ] , 'c9' : [ 113.39 , 161.57 ] ,
'c10' : [ 79.37 , 113.39 ] ,
'dl' : [ 311.81 , 623.62 ] ,
'letter' : [ 612 , 792 ] , 'government-letter' : [ 576 , 756 ] , 'legal' : [ 612 , 1008 ] ,
'junior-legal' : [ 576 , 360 ] , 'ledger' : [ 1224 , 792 ] , 'tabloid' : [ 792 , 1224 ] ,
'credit-card' : [ 153 , 243 ]
} ;
var FONT _ROW _RATIO = 1.15 ;
var el = this ;
var DownloadEvt = null ;
var $hrows = [ ] ;
var $rows = [ ] ;
var rowIndex = 0 ;
var trData = '' ;
var colNames = [ ] ;
var ranges = [ ] ;
var blob ;
var $hiddenTableElements = [ ] ;
var checkCellVisibilty = false ;
$ . extend ( true , defaults , options ) ;
// Adopt deprecated options
if ( defaults . type === 'xlsx' ) {
defaults . mso . fileFormat = defaults . type ;
defaults . type = 'excel' ;
}
if ( typeof defaults . excelFileFormat !== 'undefined' && defaults . mso . fileFormat === 'undefined' )
defaults . mso . fileFormat = defaults . excelFileFormat ;
if ( typeof defaults . excelPageFormat !== 'undefined' && defaults . mso . pageFormat === 'undefined' )
defaults . mso . pageFormat = defaults . excelPageFormat ;
if ( typeof defaults . excelPageOrientation !== 'undefined' && defaults . mso . pageOrientation === 'undefined' )
defaults . mso . pageOrientation = defaults . excelPageOrientation ;
if ( typeof defaults . excelRTL !== 'undefined' && defaults . mso . rtl === 'undefined' )
defaults . mso . rtl = defaults . excelRTL ;
if ( typeof defaults . excelstyles !== 'undefined' && defaults . mso . styles === 'undefined' )
defaults . mso . styles = defaults . excelstyles ;
if ( typeof defaults . onMsoNumberFormat !== 'undefined' && defaults . mso . onMsoNumberFormat === 'undefined' )
defaults . mso . onMsoNumberFormat = defaults . onMsoNumberFormat ;
if ( typeof defaults . worksheetName !== 'undefined' && defaults . mso . worksheetName === 'undefined' )
defaults . mso . worksheetName = defaults . worksheetName ;
// Check values of some options
defaults . mso . pageOrientation = ( defaults . mso . pageOrientation . substr ( 0 , 1 ) === 'l' ) ? 'landscape' : 'portrait' ;
colNames = GetColumnNames ( el ) ;
if ( defaults . type === 'csv' || defaults . type === 'tsv' || defaults . type === 'txt' ) {
var csvData = "" ;
var rowlength = 0 ;
ranges = [ ] ;
rowIndex = 0 ;
var csvString = function ( cell , rowIndex , colIndex ) {
var result = '' ;
if ( cell !== null ) {
var dataString = parseString ( cell , rowIndex , colIndex ) ;
var csvValue = ( dataString === null || dataString === '' ) ? '' : dataString . toString ( ) ;
if ( defaults . type === 'tsv' ) {
if ( dataString instanceof Date )
dataString . toLocaleString ( ) ;
// According to http://www.iana.org/assignments/media-types/text/tab-separated-values
// are fields that contain tabs not allowable in tsv encoding
result = replaceAll ( csvValue , '\t' , ' ' ) ;
}
else {
// Takes a string and encapsulates it (by default in double-quotes) if it
// contains the csv field separator, spaces, or linebreaks.
if ( dataString instanceof Date )
result = defaults . csvEnclosure + dataString . toLocaleString ( ) + defaults . csvEnclosure ;
else {
result = preventInjection ( csvValue ) ;
result = replaceAll ( result , defaults . csvEnclosure , defaults . csvEnclosure + defaults . csvEnclosure ) ;
if ( result . indexOf ( defaults . csvSeparator ) >= 0 || /[\r\n ]/g . test ( result ) )
result = defaults . csvEnclosure + result + defaults . csvEnclosure ;
}
}
}
return result ;
} ;
var CollectCsvData = function ( $rows , rowselector , length ) {
$rows . each ( function ( ) {
trData = "" ;
ForEachVisibleCell ( this , rowselector , rowIndex , length + $rows . length ,
function ( cell , row , col ) {
trData += csvString ( cell , row , col ) + ( defaults . type === 'tsv' ? '\t' : defaults . csvSeparator ) ;
} ) ;
trData = $ . trim ( trData ) . substring ( 0 , trData . length - 1 ) ;
if ( trData . length > 0 ) {
if ( csvData . length > 0 )
csvData += "\n" ;
csvData += trData ;
}
rowIndex ++ ;
} ) ;
return $rows . length ;
} ;
rowlength += CollectCsvData ( $ ( el ) . find ( 'thead' ) . first ( ) . find ( defaults . theadSelector ) , 'th,td' , rowlength ) ;
findTableElements ( $ ( el ) , 'tbody' ) . each ( function ( ) {
rowlength += CollectCsvData ( findTableElements ( $ ( this ) , defaults . tbodySelector ) , 'td,th' , rowlength ) ;
} ) ;
if ( defaults . tfootSelector . length )
CollectCsvData ( $ ( el ) . find ( 'tfoot' ) . first ( ) . find ( defaults . tfootSelector ) , 'td,th' , rowlength ) ;
csvData += "\n" ;
//output
if ( defaults . outputMode === 'string' )
return csvData ;
if ( defaults . outputMode === 'base64' )
return base64encode ( csvData ) ;
if ( defaults . outputMode === 'window' ) {
downloadFile ( false , 'data:text/' + ( defaults . type === 'csv' ? 'csv' : 'plain' ) + ';charset=utf-8,' , csvData ) ;
return ;
}
try {
blob = new Blob ( [ csvData ] , { type : "text/" + ( defaults . type === 'csv' ? 'csv' : 'plain' ) + ";charset=utf-8" } ) ;
saveAs ( blob , defaults . fileName + '.' + defaults . type , ( defaults . type !== 'csv' || defaults . csvUseBOM === false ) ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.' + defaults . type ,
'data:text/' + ( defaults . type === 'csv' ? 'csv' : 'plain' ) + ';charset=utf-8,' + ( ( defaults . type === 'csv' && defaults . csvUseBOM ) ? '\ufeff' : '' ) ,
csvData ) ;
}
} else if ( defaults . type === 'sql' ) {
// Header
rowIndex = 0 ;
ranges = [ ] ;
var tdData = "INSERT INTO `" + defaults . tableName + "` (" ;
$hrows = collectHeadRows ( $ ( el ) ) ;
$ ( $hrows ) . each ( function ( ) {
ForEachVisibleCell ( this , 'th,td' , rowIndex , $hrows . length ,
function ( cell , row , col ) {
tdData += "'" + parseString ( cell , row , col ) + "'," ;
} ) ;
rowIndex ++ ;
tdData = $ . trim ( tdData ) . substring ( 0 , tdData . length - 1 ) ;
} ) ;
tdData += ") VALUES " ;
// Data
$rows = collectRows ( $ ( el ) ) ;
$ ( $rows ) . each ( function ( ) {
trData = "" ;
ForEachVisibleCell ( this , 'td,th' , rowIndex , $hrows . length + $rows . length ,
function ( cell , row , col ) {
trData += "'" + parseString ( cell , row , col ) + "'," ;
} ) ;
if ( trData . length > 3 ) {
tdData += "(" + trData ;
tdData = $ . trim ( tdData ) . substring ( 0 , tdData . length - 1 ) ;
tdData += ")," ;
}
rowIndex ++ ;
} ) ;
tdData = $ . trim ( tdData ) . substring ( 0 , tdData . length - 1 ) ;
tdData += ";" ;
// Output
if ( defaults . outputMode === 'string' )
return tdData ;
if ( defaults . outputMode === 'base64' )
return base64encode ( tdData ) ;
try {
blob = new Blob ( [ tdData ] , { type : "text/plain;charset=utf-8" } ) ;
saveAs ( blob , defaults . fileName + '.sql' ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.sql' ,
'data:application/sql;charset=utf-8,' ,
tdData ) ;
}
} else if ( defaults . type === 'json' ) {
var jsonHeaderArray = [ ] ;
ranges = [ ] ;
$hrows = collectHeadRows ( $ ( el ) ) ;
$ ( $hrows ) . each ( function ( ) {
var jsonArrayTd = [ ] ;
ForEachVisibleCell ( this , 'th,td' , rowIndex , $hrows . length ,
function ( cell , row , col ) {
jsonArrayTd . push ( parseString ( cell , row , col ) ) ;
} ) ;
jsonHeaderArray . push ( jsonArrayTd ) ;
} ) ;
// Data
var jsonArray = [ ] ;
$rows = collectRows ( $ ( el ) ) ;
$ ( $rows ) . each ( function ( ) {
var jsonObjectTd = { } ;
var colIndex = 0 ;
ForEachVisibleCell ( this , 'td,th' , rowIndex , $hrows . length + $rows . length ,
function ( cell , row , col ) {
if ( jsonHeaderArray . length ) {
jsonObjectTd [ jsonHeaderArray [ jsonHeaderArray . length - 1 ] [ colIndex ] ] = parseString ( cell , row , col ) ;
} else {
jsonObjectTd [ colIndex ] = parseString ( cell , row , col ) ;
}
colIndex ++ ;
} ) ;
if ( $ . isEmptyObject ( jsonObjectTd ) === false )
jsonArray . push ( jsonObjectTd ) ;
rowIndex ++ ;
} ) ;
var sdata = "" ;
if ( defaults . jsonScope === 'head' )
sdata = JSON . stringify ( jsonHeaderArray ) ;
else if ( defaults . jsonScope === 'data' )
sdata = JSON . stringify ( jsonArray ) ;
else // all
sdata = JSON . stringify ( { header : jsonHeaderArray , data : jsonArray } ) ;
if ( defaults . outputMode === 'string' )
return sdata ;
if ( defaults . outputMode === 'base64' )
return base64encode ( sdata ) ;
try {
blob = new Blob ( [ sdata ] , { type : "application/json;charset=utf-8" } ) ;
saveAs ( blob , defaults . fileName + '.json' ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.json' ,
'data:application/json;charset=utf-8;base64,' ,
sdata ) ;
}
} else if ( defaults . type === 'xml' ) {
rowIndex = 0 ;
ranges = [ ] ;
var xml = '<?xml version="1.0" encoding="utf-8"?>' ;
xml += '<tabledata><fields>' ;
// Header
$hrows = collectHeadRows ( $ ( el ) ) ;
$ ( $hrows ) . each ( function ( ) {
ForEachVisibleCell ( this , 'th,td' , rowIndex , $hrows . length ,
function ( cell , row , col ) {
xml += "<field>" + parseString ( cell , row , col ) + "</field>" ;
} ) ;
rowIndex ++ ;
} ) ;
xml += '</fields><data>' ;
// Data
var rowCount = 1 ;
$rows = collectRows ( $ ( el ) ) ;
$ ( $rows ) . each ( function ( ) {
var colCount = 1 ;
trData = "" ;
ForEachVisibleCell ( this , 'td,th' , rowIndex , $hrows . length + $rows . length ,
function ( cell , row , col ) {
trData += "<column-" + colCount + ">" + parseString ( cell , row , col ) + "</column-" + colCount + ">" ;
colCount ++ ;
} ) ;
if ( trData . length > 0 && trData !== "<column-1></column-1>" ) {
xml += '<row id="' + rowCount + '">' + trData + '</row>' ;
rowCount ++ ;
}
rowIndex ++ ;
} ) ;
xml += '</data></tabledata>' ;
// Output
if ( defaults . outputMode === 'string' )
return xml ;
if ( defaults . outputMode === 'base64' )
return base64encode ( xml ) ;
try {
blob = new Blob ( [ xml ] , { type : "application/xml;charset=utf-8" } ) ;
saveAs ( blob , defaults . fileName + '.xml' ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.xml' ,
'data:application/xml;charset=utf-8;base64,' ,
xml ) ;
}
}
else if ( defaults . type === 'excel' && defaults . mso . fileFormat === 'xmlss' ) {
var docDatas = [ ] ;
var docNames = [ ] ;
$ ( el ) . filter ( function ( ) {
return isVisible ( $ ( this ) ) ;
} ) . each ( function ( ) {
var $table = $ ( this ) ;
var ssName = '' ;
if ( typeof defaults . mso . worksheetName === 'string' && defaults . mso . worksheetName . length )
ssName = defaults . mso . worksheetName + ' ' + ( docNames . length + 1 ) ;
else if ( typeof defaults . mso . worksheetName [ docNames . length ] !== 'undefined' )
ssName = defaults . mso . worksheetName [ docNames . length ] ;
if ( ! ssName . length )
ssName = $table . find ( 'caption' ) . text ( ) || '' ;
if ( ! ssName . length )
ssName = 'Table ' + ( docNames . length + 1 ) ;
ssName = $ . trim ( ssName . replace ( /[\\\/[\]*:?'"]/g , '' ) . substring ( 0 , 31 ) ) ;
docNames . push ( $ ( '<div />' ) . text ( ssName ) . html ( ) ) ;
if ( defaults . exportHiddenCells === false ) {
$hiddenTableElements = $table . find ( "tr, th, td" ) . filter ( ":hidden" ) ;
checkCellVisibilty = $hiddenTableElements . length > 0 ;
}
rowIndex = 0 ;
colNames = GetColumnNames ( this ) ;
docData = '<Table>\r' ;
function CollectXmlssData ( $rows , rowselector , length ) {
var spans = [ ] ;
$ ( $rows ) . each ( function ( ) {
var ssIndex = 0 ;
var nCols = 0 ;
trData = "" ;
ForEachVisibleCell ( this , 'td,th' , rowIndex , length + $rows . length ,
function ( cell , row , col ) {
if ( cell !== null ) {
var style = "" ;
var data = parseString ( cell , row , col ) ;
var type = "String" ;
if ( jQuery . isNumeric ( data ) !== false ) {
type = "Number" ;
}
else {
var number = parsePercent ( data ) ;
if ( number !== false ) {
data = number ;
type = "Number" ;
style += ' ss:StyleID="pct1"' ;
}
}
if ( type !== "Number" )
data = data . replace ( /\n/g , '<br>' ) ;
var colspan = getColspan ( cell ) ;
var rowspan = getRowspan ( cell ) ;
// Skip spans
$ . each ( spans , function ( ) {
var range = this ;
if ( rowIndex >= range . s . r && rowIndex <= range . e . r && nCols >= range . s . c && nCols <= range . e . c ) {
for ( var i = 0 ; i <= range . e . c - range . s . c ; ++ i ) {
nCols ++ ;
ssIndex ++ ;
}
}
} ) ;
// Handle Row Span
if ( rowspan || colspan ) {
rowspan = rowspan || 1 ;
colspan = colspan || 1 ;
spans . push ( {
s : { r : rowIndex , c : nCols } ,
e : { r : rowIndex + rowspan - 1 , c : nCols + colspan - 1 }
} ) ;
}
// Handle Colspan
if ( colspan > 1 ) {
style += ' ss:MergeAcross="' + ( colspan - 1 ) + '"' ;
nCols += ( colspan - 1 ) ;
}
if ( rowspan > 1 ) {
style += ' ss:MergeDown="' + ( rowspan - 1 ) + '" ss:StyleID="rsp1"' ;
}
if ( ssIndex > 0 ) {
style += ' ss:Index="' + ( nCols + 1 ) + '"' ;
ssIndex = 0 ;
}
trData += '<Cell' + style + '><Data ss:Type="' + type + '">' +
$ ( '<div />' ) . text ( data ) . html ( ) +
'</Data></Cell>\r' ;
nCols ++ ;
}
} ) ;
if ( trData . length > 0 )
docData += '<Row ss:AutoFitHeight="0">\r' + trData + '</Row>\r' ;
rowIndex ++ ;
} ) ;
return $rows . length ;
}
var rowLength = CollectXmlssData ( collectHeadRows ( $table ) , 'th,td' , rowLength ) ;
CollectXmlssData ( collectRows ( $table ) , 'td,th' , rowLength ) ;
docData += '</Table>\r' ;
docDatas . push ( docData ) ;
} ) ;
var count = { } ;
var firstOccurences = { } ;
var item , itemCount ;
for ( var n = 0 , c = docNames . length ; n < c ; n ++ )
{
item = docNames [ n ] ;
itemCount = count [ item ] ;
itemCount = count [ item ] = ( itemCount == null ? 1 : itemCount + 1 ) ;
if ( itemCount === 2 )
docNames [ firstOccurences [ item ] ] = docNames [ firstOccurences [ item ] ] . substring ( 0 , 29 ) + "-1" ;
if ( count [ item ] > 1 )
docNames [ n ] = docNames [ n ] . substring ( 0 , 29 ) + "-" + count [ item ] ;
else
firstOccurences [ item ] = n ;
}
var CreationDate = new Date ( ) . toISOString ( ) ;
var xmlssDocFile = '<?xml version="1.0" encoding="UTF-8"?>\r' +
'<?mso-application progid="Excel.Sheet"?>\r' +
'<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"\r' +
' xmlns:o="urn:schemas-microsoft-com:office:office"\r' +
' xmlns:x="urn:schemas-microsoft-com:office:excel"\r' +
' xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"\r' +
' xmlns:html="http://www.w3.org/TR/REC-html40">\r' +
'<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">\r' +
' <Created>' + CreationDate + '</Created>\r' +
'</DocumentProperties>\r' +
'<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">\r' +
' <AllowPNG/>\r' +
'</OfficeDocumentSettings>\r' +
'<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">\r' +
' <WindowHeight>9000</WindowHeight>\r' +
' <WindowWidth>13860</WindowWidth>\r' +
' <WindowTopX>0</WindowTopX>\r' +
' <WindowTopY>0</WindowTopY>\r' +
' <ProtectStructure>False</ProtectStructure>\r' +
' <ProtectWindows>False</ProtectWindows>\r' +
'</ExcelWorkbook>\r' +
'<Styles>\r' +
' <Style ss:ID="Default" ss:Name="Normal">\r' +
' <Alignment ss:Vertical="Bottom"/>\r' +
' <Borders/>\r' +
' <Font/>\r' +
' <Interior/>\r' +
' <NumberFormat/>\r' +
' <Protection/>\r' +
' </Style>\r' +
' <Style ss:ID="rsp1">\r' +
' <Alignment ss:Vertical="Center"/>\r' +
' </Style>\r' +
' <Style ss:ID="pct1">\r' +
' <NumberFormat ss:Format="Percent"/>\r' +
' </Style>\r' +
'</Styles>\r' ;
for ( var j = 0 ; j < docDatas . length ; j ++ ) {
xmlssDocFile += '<Worksheet ss:Name="' + docNames [ j ] + '" ss:RightToLeft="' + ( defaults . mso . rtl ? '1' : '0' ) + '">\r' +
docDatas [ j ] ;
if ( defaults . mso . rtl ) {
xmlssDocFile += '<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">\r' +
'<DisplayRightToLeft/>\r' +
'</WorksheetOptions>\r' ;
}
else
xmlssDocFile += '<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"/>\r' ;
xmlssDocFile += '</Worksheet>\r' ;
}
xmlssDocFile += '</Workbook>\r' ;
if ( defaults . outputMode === 'string' )
return xmlssDocFile ;
if ( defaults . outputMode === 'base64' )
return base64encode ( xmlssDocFile ) ;
try {
blob = new Blob ( [ xmlssDocFile ] , { type : "application/xml;charset=utf-8" } ) ;
saveAs ( blob , defaults . fileName + '.xml' ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.xml' ,
'data:application/xml;charset=utf-8;base64,' ,
xmlssDocFile ) ;
}
}
else if ( defaults . type === 'excel' && defaults . mso . fileFormat === 'xlsx' ) {
var data = [ ] ;
var spans = [ ] ;
rowIndex = 0 ;
$rows = collectHeadRows ( $ ( el ) ) ;
$rows . push . apply ( $rows , collectRows ( $ ( el ) ) ) ;
$ ( $rows ) . each ( function ( ) {
var cols = [ ] ;
ForEachVisibleCell ( this , 'th,td' , rowIndex , $rows . length ,
function ( cell , row , col ) {
if ( typeof cell !== 'undefined' && cell !== null ) {
var cellValue = parseString ( cell , row , col ) ;
var colspan = getColspan ( cell ) ;
var rowspan = getRowspan ( cell ) ;
// Skip span ranges
$ . each ( spans , function ( ) {
var range = this ;
if ( rowIndex >= range . s . r && rowIndex <= range . e . r && cols . length >= range . s . c && cols . length <= range . e . c ) {
for ( var i = 0 ; i <= range . e . c - range . s . c ; ++ i )
cols . push ( null ) ;
}
} ) ;
// Handle Row Span
if ( rowspan || colspan ) {
rowspan = rowspan || 1 ;
colspan = colspan || 1 ;
spans . push ( {
s : { r : rowIndex , c : cols . length } ,
e : { r : rowIndex + rowspan - 1 , c : cols . length + colspan - 1 }
} ) ;
}
// Handle Value
if ( typeof defaults . onCellData !== 'function' ) {
// Type conversion
if ( cellValue !== "" && cellValue === + cellValue )
cellValue = + cellValue ;
}
cols . push ( cellValue !== "" ? cellValue : null ) ;
// Handle Colspan
if ( colspan )
for ( var k = 0 ; k < colspan - 1 ; ++ k )
cols . push ( null ) ;
}
} ) ;
data . push ( cols ) ;
rowIndex ++ ;
} ) ;
//noinspection JSPotentiallyInvalidConstructorUsage
var wb = new jx _Workbook ( ) ,
ws = jx _createSheet ( data ) ;
// add span ranges to worksheet
ws [ '!merges' ] = spans ;
// add worksheet to workbook
//wb.SheetNames.push(defaults.mso.worksheetName);
//wb.Sheets[defaults.mso.worksheetName] = ws;
XLSX . utils . book _append _sheet ( wb , ws , defaults . mso . worksheetName ) ;
var wbout = XLSX . write ( wb , { type : 'binary' , bookType : defaults . mso . fileFormat , bookSST : false } ) ;
try {
blob = new Blob ( [ jx _s2ab ( wbout ) ] , { type : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8' } ) ;
saveAs ( blob , defaults . fileName + '.' + defaults . mso . fileFormat ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.' + defaults . mso . fileFormat ,
'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8,' ,
jx _s2ab ( wbout ) ) ;
}
}
else if ( defaults . type === 'excel' || defaults . type === 'xls' || defaults . type === 'word' || defaults . type === 'doc' ) {
var MSDocType = ( defaults . type === 'excel' || defaults . type === 'xls' ) ? 'excel' : 'word' ;
var MSDocExt = ( MSDocType === 'excel' ) ? 'xls' : 'doc' ;
var MSDocSchema = 'xmlns:x="urn:schemas-microsoft-com:office:' + MSDocType + '"' ;
var docData = '' ;
var docName = '' ;
$ ( el ) . filter ( function ( ) {
return isVisible ( $ ( this ) ) ;
} ) . each ( function ( ) {
var $table = $ ( this ) ;
if ( docName === '' ) {
docName = defaults . mso . worksheetName || $table . find ( 'caption' ) . text ( ) || 'Table' ;
docName = $ . trim ( docName . replace ( /[\\\/[\]*:?'"]/g , '' ) . substring ( 0 , 31 ) ) ;
}
if ( defaults . exportHiddenCells === false ) {
$hiddenTableElements = $table . find ( "tr, th, td" ) . filter ( ":hidden" ) ;
checkCellVisibilty = $hiddenTableElements . length > 0 ;
}
rowIndex = 0 ;
ranges = [ ] ;
colNames = GetColumnNames ( this ) ;
// Header
docData += '<table><thead>' ;
$hrows = collectHeadRows ( $table ) ;
$ ( $hrows ) . each ( function ( ) {
trData = "" ;
ForEachVisibleCell ( this , 'th,td' , rowIndex , $hrows . length ,
function ( cell , row , col ) {
if ( cell !== null ) {
var thstyle = '' ;
trData += '<th' ;
for ( var styles in defaults . mso . styles ) {
if ( defaults . mso . styles . hasOwnProperty ( styles ) ) {
var thcss = $ ( cell ) . css ( defaults . mso . styles [ styles ] ) ;
if ( thcss !== '' && thcss !== '0px none rgb(0, 0, 0)' && thcss !== 'rgba(0, 0, 0, 0)' ) {
thstyle += ( thstyle === '' ) ? 'style="' : ';' ;
thstyle += defaults . mso . styles [ styles ] + ':' + thcss ;
}
}
}
if ( thstyle !== '' )
trData += ' ' + thstyle + '"' ;
var tdcolspan = getColspan ( cell ) ;
if ( tdcolspan > 0 )
trData += ' colspan="' + tdcolspan + '"' ;
var tdrowspan = getRowspan ( cell ) ;
if ( tdrowspan > 0 )
trData += ' rowspan="' + tdrowspan + '"' ;
trData += '>' + parseString ( cell , row , col ) + '</th>' ;
}
} ) ;
if ( trData . length > 0 )
docData += '<tr>' + trData + '</tr>' ;
rowIndex ++ ;
} ) ;
docData += '</thead><tbody>' ;
// Data
$rows = collectRows ( $table ) ;
$ ( $rows ) . each ( function ( ) {
var $row = $ ( this ) ;
trData = "" ;
ForEachVisibleCell ( this , 'td,th' , rowIndex , $hrows . length + $rows . length ,
function ( cell , row , col ) {
if ( cell !== null ) {
var tdvalue = parseString ( cell , row , col ) ;
var tdstyle = '' ;
var tdcss = $ ( cell ) . data ( "tableexport-msonumberformat" ) ;
if ( typeof tdcss === 'undefined' && typeof defaults . mso . onMsoNumberFormat === 'function' )
tdcss = defaults . mso . onMsoNumberFormat ( cell , row , col ) ;
if ( typeof tdcss !== 'undefined' && tdcss !== '' )
tdstyle = 'style="mso-number-format:\'' + tdcss + '\'' ;
for ( var cssStyle in defaults . mso . styles ) {
if ( defaults . mso . styles . hasOwnProperty ( cssStyle ) ) {
tdcss = $ ( cell ) . css ( defaults . mso . styles [ cssStyle ] ) ;
if ( tdcss === '' )
tdcss = $row . css ( defaults . mso . styles [ cssStyle ] ) ;
if ( tdcss !== '' && tdcss !== '0px none rgb(0, 0, 0)' && tdcss !== 'rgba(0, 0, 0, 0)' ) {
tdstyle += ( tdstyle === '' ) ? 'style="' : ';' ;
tdstyle += defaults . mso . styles [ cssStyle ] + ':' + tdcss ;
}
}
}
trData += '<td' ;
if ( tdstyle !== '' )
trData += ' ' + tdstyle + '"' ;
var tdcolspan = getColspan ( cell ) ;
if ( tdcolspan > 0 )
trData += ' colspan="' + tdcolspan + '"' ;
var tdrowspan = getRowspan ( cell ) ;
if ( tdrowspan > 0 )
trData += ' rowspan="' + tdrowspan + '"' ;
if ( typeof tdvalue === 'string' && tdvalue !== '' ) {
tdvalue = preventInjection ( tdvalue ) ;
tdvalue = tdvalue . replace ( /\n/g , '<br>' ) ;
}
trData += '>' + tdvalue + '</td>' ;
}
} ) ;
if ( trData . length > 0 )
docData += '<tr>' + trData + '</tr>' ;
rowIndex ++ ;
} ) ;
if ( defaults . displayTableName )
docData += '<tr><td></td></tr><tr><td></td></tr><tr><td>' + parseString ( $ ( '<p>' + defaults . tableName + '</p>' ) ) + '</td></tr>' ;
docData += '</tbody></table>' ;
} ) ;
//noinspection XmlUnusedNamespaceDeclaration
var docFile = '<html xmlns:o="urn:schemas-microsoft-com:office:office" ' + MSDocSchema + ' xmlns="http://www.w3.org/TR/REC-html40">' ;
docFile += '<meta http-equiv="content-type" content="application/vnd.ms-' + MSDocType + '; charset=UTF-8">' ;
docFile += "<head>" ;
if ( MSDocType === 'excel' ) {
docFile += "<!--[if gte mso 9]>" ;
docFile += "<xml>" ;
docFile += "<x:ExcelWorkbook>" ;
docFile += "<x:ExcelWorksheets>" ;
docFile += "<x:ExcelWorksheet>" ;
docFile += "<x:Name>" ;
docFile += docName ;
docFile += "</x:Name>" ;
docFile += "<x:WorksheetOptions>" ;
docFile += "<x:DisplayGridlines/>" ;
if ( defaults . mso . rtl )
docFile += "<x:DisplayRightToLeft/>" ;
docFile += "</x:WorksheetOptions>" ;
docFile += "</x:ExcelWorksheet>" ;
docFile += "</x:ExcelWorksheets>" ;
docFile += "</x:ExcelWorkbook>" ;
docFile += "</xml>" ;
docFile += "<![endif]-->" ;
}
docFile += "<style>" ;
docFile += "@page { size:" + defaults . mso . pageOrientation + "; mso-page-orientation:" + defaults . mso . pageOrientation + "; }" ;
docFile += "@page Section1 {size:" + pageFormats [ defaults . mso . pageFormat ] [ 0 ] + "pt " + pageFormats [ defaults . mso . pageFormat ] [ 1 ] + "pt" ;
docFile += "; margin:1.0in 1.25in 1.0in 1.25in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}" ;
docFile += "div.Section1 {page:Section1;}" ;
docFile += "@page Section2 {size:" + pageFormats [ defaults . mso . pageFormat ] [ 1 ] + "pt " + pageFormats [ defaults . mso . pageFormat ] [ 0 ] + "pt" ;
docFile += ";mso-page-orientation:" + defaults . mso . pageOrientation + ";margin:1.25in 1.0in 1.25in 1.0in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}" ;
docFile += "div.Section2 {page:Section2;}" ;
docFile += "br {mso-data-placement:same-cell;}" ;
docFile += "</style>" ;
docFile += "</head>" ;
docFile += "<body>" ;
docFile += "<div class=\"Section" + ( ( defaults . mso . pageOrientation === 'landscape' ) ? "2" : "1" ) + "\">" ;
docFile += docData ;
docFile += "</div>" ;
docFile += "</body>" ;
docFile += "</html>" ;
if ( defaults . outputMode === 'string' )
return docFile ;
if ( defaults . outputMode === 'base64' )
return base64encode ( docFile ) ;
try {
blob = new Blob ( [ docFile ] , { type : 'application/vnd.ms-' + defaults . type } ) ;
saveAs ( blob , defaults . fileName + '.' + MSDocExt ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.' + MSDocExt ,
'data:application/vnd.ms-' + MSDocType + ';base64,' ,
docFile ) ;
}
}
else if ( defaults . type === 'png' ) {
//html2canvas($(el)[0], {
// onrendered: function (canvas) {
html2canvas ( $ ( el ) [ 0 ] ) . then (
function ( canvas ) {
var image = canvas . toDataURL ( ) ;
var byteString = atob ( image . substring ( 22 ) ) ; // remove data stuff
var buffer = new ArrayBuffer ( byteString . length ) ;
var intArray = new Uint8Array ( buffer ) ;
for ( var i = 0 ; i < byteString . length ; i ++ )
intArray [ i ] = byteString . charCodeAt ( i ) ;
if ( defaults . outputMode === 'string' )
return byteString ;
if ( defaults . outputMode === 'base64' )
return base64encode ( image ) ;
if ( defaults . outputMode === 'window' ) {
window . open ( image ) ;
return ;
}
try {
blob = new Blob ( [ buffer ] , { type : "image/png" } ) ;
saveAs ( blob , defaults . fileName + '.png' ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.png' , 'data:image/png,' , blob ) ;
}
//}
} ) ;
} else if ( defaults . type === 'pdf' ) {
if ( defaults . pdfmake . enabled === true ) {
// pdf output using pdfmake
// https://github.com/bpampuch/pdfmake
var widths = [ ] ;
var body = [ ] ;
rowIndex = 0 ;
ranges = [ ] ;
/ * *
* @ return { number }
* /
var CollectPdfmakeData = function ( $rows , colselector , length ) {
var rlength = 0 ;
$ ( $rows ) . each ( function ( ) {
var r = [ ] ;
ForEachVisibleCell ( this , colselector , rowIndex , length ,
function ( cell , row , col ) {
if ( typeof cell !== 'undefined' && cell !== null ) {
var colspan = getColspan ( cell ) ;
var rowspan = getRowspan ( cell ) ;
var cellValue = parseString ( cell , row , col ) || " " ;
if ( colspan > 1 || rowspan > 1 ) {
colspan = colspan || 1 ;
rowspan = rowspan || 1 ;
r . push ( { colSpan : colspan , rowSpan : rowspan , text : cellValue } ) ;
}
else
r . push ( cellValue ) ;
}
else
r . push ( " " ) ;
} ) ;
if ( r . length )
body . push ( r ) ;
if ( rlength < r . length )
rlength = r . length ;
rowIndex ++ ;
} ) ;
return rlength ;
} ;
$hrows = collectHeadRows ( $ ( this ) ) ;
var colcount = CollectPdfmakeData ( $hrows , 'th,td' , $hrows . length ) ;
for ( var i = widths . length ; i < colcount ; i ++ )
widths . push ( "*" ) ;
// Data
$rows = collectRows ( $ ( this ) ) ;
CollectPdfmakeData ( $rows , 'th,td' , $hrows . length + $rows . length ) ;
var docDefinition = {
content : [ {
table : {
headerRows : $hrows . length ,
widths : widths ,
body : body
}
} ]
} ;
$ . extend ( true , docDefinition , defaults . pdfmake . docDefinition ) ;
pdfMake . fonts = {
Roboto : {
normal : 'Roboto-Regular.ttf' ,
bold : 'Roboto-Medium.ttf' ,
italics : 'Roboto-Italic.ttf' ,
bolditalics : 'Roboto-MediumItalic.ttf'
}
} ;
$ . extend ( true , pdfMake . fonts , defaults . pdfmake . fonts ) ;
pdfMake . createPdf ( docDefinition ) . getBuffer ( function ( buffer ) {
try {
var blob = new Blob ( [ buffer ] , { type : "application/pdf" } ) ;
saveAs ( blob , defaults . fileName + '.pdf' ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.pdf' , 'application/pdf' , buffer ) ;
}
} ) ;
}
else if ( defaults . jspdf . autotable === false ) {
// pdf output using jsPDF's core html support
var addHtmlOptions = {
dim : {
w : getPropertyUnitValue ( $ ( el ) . first ( ) . get ( 0 ) , 'width' , 'mm' ) ,
h : getPropertyUnitValue ( $ ( el ) . first ( ) . get ( 0 ) , 'height' , 'mm' )
} ,
pagesplit : false
} ;
var doc = new jsPDF ( defaults . jspdf . orientation , defaults . jspdf . unit , defaults . jspdf . format ) ;
doc . addHTML ( $ ( el ) . first ( ) ,
defaults . jspdf . margins . left ,
defaults . jspdf . margins . top ,
addHtmlOptions ,
function ( ) {
jsPdfOutput ( doc , false ) ;
} ) ;
//delete doc;
}
else {
// pdf output using jsPDF AutoTable plugin
// https://github.com/simonbengtsson/jsPDF-AutoTable
var teOptions = defaults . jspdf . autotable . tableExport ;
// When setting jspdf.format to 'bestfit' tableExport tries to choose
// the minimum required paper format and orientation in which the table
// (or tables in multitable mode) completely fits without column adjustment
if ( typeof defaults . jspdf . format === 'string' && defaults . jspdf . format . toLowerCase ( ) === 'bestfit' ) {
var rk = '' , ro = '' ;
var mw = 0 ;
$ ( el ) . each ( function ( ) {
if ( isVisible ( $ ( this ) ) ) {
var w = getPropertyUnitValue ( $ ( this ) . get ( 0 ) , 'width' , 'pt' ) ;
if ( w > mw ) {
if ( w > pageFormats . a0 [ 0 ] ) {
rk = 'a0' ;
ro = 'l' ;
}
for ( var key in pageFormats ) {
if ( pageFormats . hasOwnProperty ( key ) ) {
if ( pageFormats [ key ] [ 1 ] > w ) {
rk = key ;
ro = 'l' ;
if ( pageFormats [ key ] [ 0 ] > w )
ro = 'p' ;
}
}
}
mw = w ;
}
}
} ) ;
defaults . jspdf . format = ( rk === '' ? 'a4' : rk ) ;
defaults . jspdf . orientation = ( ro === '' ? 'w' : ro ) ;
}
// The jsPDF doc object is stored in defaults.jspdf.autotable.tableExport,
// thus it can be accessed from any callback function
if ( teOptions . doc == null ) {
teOptions . doc = new jsPDF ( defaults . jspdf . orientation ,
defaults . jspdf . unit ,
defaults . jspdf . format ) ;
if ( typeof defaults . jspdf . onDocCreated === 'function' )
defaults . jspdf . onDocCreated ( teOptions . doc ) ;
}
if ( teOptions . outputImages === true )
teOptions . images = { } ;
if ( typeof teOptions . images !== 'undefined' ) {
$ ( el ) . filter ( function ( ) {
return isVisible ( $ ( this ) ) ;
} ) . each ( function ( ) {
var rowCount = 0 ;
ranges = [ ] ;
if ( defaults . exportHiddenCells === false ) {
$hiddenTableElements = $ ( this ) . find ( "tr, th, td" ) . filter ( ":hidden" ) ;
checkCellVisibilty = $hiddenTableElements . length > 0 ;
}
$hrows = collectHeadRows ( $ ( this ) ) ;
$rows = collectRows ( $ ( this ) ) ;
$ ( $rows ) . each ( function ( ) {
ForEachVisibleCell ( this , 'td,th' , $hrows . length + rowCount , $hrows . length + $rows . length ,
function ( cell ) {
collectImages ( cell , $ ( cell ) . children ( ) , teOptions ) ;
} ) ;
rowCount ++ ;
} ) ;
} ) ;
$hrows = [ ] ;
$rows = [ ] ;
}
loadImages ( teOptions , function ( ) {
$ ( el ) . filter ( function ( ) {
return isVisible ( $ ( this ) ) ;
} ) . each ( function ( ) {
var colKey ;
rowIndex = 0 ;
ranges = [ ] ;
if ( defaults . exportHiddenCells === false ) {
$hiddenTableElements = $ ( this ) . find ( "tr, th, td" ) . filter ( ":hidden" ) ;
checkCellVisibilty = $hiddenTableElements . length > 0 ;
}
colNames = GetColumnNames ( this ) ;
teOptions . columns = [ ] ;
teOptions . rows = [ ] ;
teOptions . teCells = { } ;
// onTable: optional callback function for every matching table that can be used
// to modify the tableExport options or to skip the output of a particular table
// if the table selector targets multiple tables
if ( typeof teOptions . onTable === 'function' )
if ( teOptions . onTable ( $ ( this ) , defaults ) === false )
return true ; // continue to next iteration step (table)
// each table works with an own copy of AutoTable options
defaults . jspdf . autotable . tableExport = null ; // avoid deep recursion error
var atOptions = $ . extend ( true , { } , defaults . jspdf . autotable ) ;
defaults . jspdf . autotable . tableExport = teOptions ;
atOptions . margin = { } ;
$ . extend ( true , atOptions . margin , defaults . jspdf . margins ) ;
atOptions . tableExport = teOptions ;
// Fix jsPDF Autotable's row height calculation
if ( typeof atOptions . beforePageContent !== 'function' ) {
atOptions . beforePageContent = function ( data ) {
if ( data . pageCount === 1 ) {
var all = data . table . rows . concat ( data . table . headerRow ) ;
$ . each ( all , function ( ) {
var row = this ;
if ( row . height > 0 ) {
row . height += ( 2 - FONT _ROW _RATIO ) / 2 * row . styles . fontSize ;
data . table . height += ( 2 - FONT _ROW _RATIO ) / 2 * row . styles . fontSize ;
}
} ) ;
}
} ;
}
if ( typeof atOptions . createdHeaderCell !== 'function' ) {
// apply some original css styles to pdf header cells
atOptions . createdHeaderCell = function ( cell , data ) {
// jsPDF AutoTable plugin v2.0.14 fix: each cell needs its own styles object
cell . styles = $ . extend ( { } , data . row . styles ) ;
if ( typeof teOptions . columns [ data . column . dataKey ] !== 'undefined' ) {
var col = teOptions . columns [ data . column . dataKey ] ;
if ( typeof col . rect !== 'undefined' ) {
var rh ;
cell . contentWidth = col . rect . width ;
if ( typeof teOptions . heightRatio === 'undefined' || teOptions . heightRatio === 0 ) {
if ( data . row . raw [ data . column . dataKey ] . rowspan )
rh = data . row . raw [ data . column . dataKey ] . rect . height / data . row . raw [ data . column . dataKey ] . rowspan ;
else
rh = data . row . raw [ data . column . dataKey ] . rect . height ;
teOptions . heightRatio = cell . styles . rowHeight / rh ;
}
rh = data . row . raw [ data . column . dataKey ] . rect . height * teOptions . heightRatio ;
if ( rh > cell . styles . rowHeight )
cell . styles . rowHeight = rh ;
}
cell . styles . halign = ( atOptions . headerStyles . halign === 'inherit' ) ? 'center' : atOptions . headerStyles . halign ;
cell . styles . valign = atOptions . headerStyles . valign ;
if ( typeof col . style !== 'undefined' && col . style . hidden !== true ) {
if ( atOptions . headerStyles . halign === 'inherit' )
cell . styles . halign = col . style . align ;
if ( atOptions . styles . fillColor === 'inherit' )
cell . styles . fillColor = col . style . bcolor ;
if ( atOptions . styles . textColor === 'inherit' )
cell . styles . textColor = col . style . color ;
if ( atOptions . styles . fontStyle === 'inherit' )
cell . styles . fontStyle = col . style . fstyle ;
}
}
} ;
}
if ( typeof atOptions . createdCell !== 'function' ) {
// apply some original css styles to pdf table cells
atOptions . createdCell = function ( cell , data ) {
var tecell = teOptions . teCells [ data . row . index + ":" + data . column . dataKey ] ;
cell . styles . halign = ( atOptions . styles . halign === 'inherit' ) ? 'center' : atOptions . styles . halign ;
cell . styles . valign = atOptions . styles . valign ;
if ( typeof tecell !== 'undefined' && typeof tecell . style !== 'undefined' && tecell . style . hidden !== true ) {
if ( atOptions . styles . halign === 'inherit' )
cell . styles . halign = tecell . style . align ;
if ( atOptions . styles . fillColor === 'inherit' )
cell . styles . fillColor = tecell . style . bcolor ;
if ( atOptions . styles . textColor === 'inherit' )
cell . styles . textColor = tecell . style . color ;
if ( atOptions . styles . fontStyle === 'inherit' )
cell . styles . fontStyle = tecell . style . fstyle ;
}
} ;
}
if ( typeof atOptions . drawHeaderCell !== 'function' ) {
atOptions . drawHeaderCell = function ( cell , data ) {
var colopt = teOptions . columns [ data . column . dataKey ] ;
if ( ( colopt . style . hasOwnProperty ( "hidden" ) !== true || colopt . style . hidden !== true ) &&
colopt . rowIndex >= 0 )
return prepareAutoTableText ( cell , data , colopt ) ;
else
return false ; // cell is hidden
} ;
}
if ( typeof atOptions . drawCell !== 'function' ) {
atOptions . drawCell = function ( cell , data ) {
var tecell = teOptions . teCells [ data . row . index + ":" + data . column . dataKey ] ;
var draw2canvas = ( typeof tecell !== 'undefined' &&
typeof tecell . elements !== 'undefined' && tecell . elements . length &&
tecell . elements [ 0 ] . hasAttribute ( "data-tableexport-canvas" ) ) ;
if ( draw2canvas !== true ) {
if ( prepareAutoTableText ( cell , data , tecell ) ) {
teOptions . doc . rect ( cell . x , cell . y , cell . width , cell . height , cell . styles . fillStyle ) ;
if ( typeof tecell !== 'undefined' &&
typeof tecell . elements !== 'undefined' && tecell . elements . length ) {
var dh = cell . height / tecell . rect . height ;
if ( dh > teOptions . dh || typeof teOptions . dh === 'undefined' )
teOptions . dh = dh ;
teOptions . dw = cell . width / tecell . rect . width ;
var y = cell . textPos . y ;
drawAutotableElements ( cell , tecell . elements , teOptions ) ;
cell . textPos . y = y ;
drawAutotableText ( cell , tecell . elements , teOptions ) ;
}
else
drawAutotableText ( cell , { } , teOptions ) ;
}
}
else {
var container = tecell . elements [ 0 ] ;
var imgId = $ ( container ) . attr ( "data-tableexport-canvas" ) ;
jsPdfDrawImage ( cell , container , imgId , teOptions ) ;
}
return false ;
} ;
}
// collect header and data rows
teOptions . headerrows = [ ] ;
$hrows = collectHeadRows ( $ ( this ) ) ;
$ ( $hrows ) . each ( function ( ) {
colKey = 0 ;
teOptions . headerrows [ rowIndex ] = [ ] ;
ForEachVisibleCell ( this , 'th,td' , rowIndex , $hrows . length ,
function ( cell , row , col ) {
var obj = getCellStyles ( cell ) ;
obj . title = parseString ( cell , row , col ) ;
obj . key = colKey ++ ;
obj . rowIndex = rowIndex ;
teOptions . headerrows [ rowIndex ] . push ( obj ) ;
} ) ;
rowIndex ++ ;
} ) ;
if ( rowIndex > 0 ) {
// iterate through last row
var lastrow = rowIndex - 1 ;
while ( lastrow >= 0 ) {
$ . each ( teOptions . headerrows [ lastrow ] , function ( ) {
var obj = this ;
if ( lastrow > 0 && this . rect === null )
obj = teOptions . headerrows [ lastrow - 1 ] [ this . key ] ;
if ( obj !== null && obj . rowIndex >= 0 &&
( obj . style . hasOwnProperty ( "hidden" ) !== true || obj . style . hidden !== true ) )
teOptions . columns . push ( obj ) ;
} ) ;
lastrow = ( teOptions . columns . length > 0 ) ? - 1 : lastrow - 1 ;
}
}
var rowCount = 0 ;
$rows = [ ] ;
$rows = collectRows ( $ ( this ) ) ;
$ ( $rows ) . each ( function ( ) {
var rowData = [ ] ;
colKey = 0 ;
ForEachVisibleCell ( this , 'td,th' , rowIndex , $hrows . length + $rows . length ,
function ( cell , row , col ) {
var obj ;
if ( typeof teOptions . columns [ colKey ] === 'undefined' ) {
// jsPDF-Autotable needs columns. Thus define hidden ones for tables without thead
obj = {
title : '' ,
key : colKey ,
style : {
hidden : true
}
} ;
teOptions . columns . push ( obj ) ;
}
if ( typeof cell !== 'undefined' && cell !== null ) {
obj = getCellStyles ( cell ) ;
obj . elements = cell . hasAttribute ( "data-tableexport-canvas" ) ? $ ( cell ) : $ ( cell ) . children ( ) ;
teOptions . teCells [ rowCount + ":" + colKey ++ ] = obj ;
}
else {
obj = $ . extend ( true , { } , teOptions . teCells [ rowCount + ":" + ( colKey - 1 ) ] ) ;
obj . colspan = - 1 ;
teOptions . teCells [ rowCount + ":" + colKey ++ ] = obj ;
}
rowData . push ( parseString ( cell , row , col ) ) ;
} ) ;
if ( rowData . length ) {
teOptions . rows . push ( rowData ) ;
rowCount ++ ;
}
rowIndex ++ ;
} ) ;
// onBeforeAutotable: optional callback function before calling
// jsPDF AutoTable that can be used to modify the AutoTable options
if ( typeof teOptions . onBeforeAutotable === 'function' )
teOptions . onBeforeAutotable ( $ ( this ) , teOptions . columns , teOptions . rows , atOptions ) ;
teOptions . doc . autoTable ( teOptions . columns , teOptions . rows , atOptions ) ;
// onAfterAutotable: optional callback function after returning
// from jsPDF AutoTable that can be used to modify the AutoTable options
if ( typeof teOptions . onAfterAutotable === 'function' )
teOptions . onAfterAutotable ( $ ( this ) , atOptions ) ;
// set the start position for the next table (in case there is one)
defaults . jspdf . autotable . startY = teOptions . doc . autoTableEndPosY ( ) + atOptions . margin . top ;
} ) ;
jsPdfOutput ( teOptions . doc , ( typeof teOptions . images !== 'undefined' && jQuery . isEmptyObject ( teOptions . images ) === false ) ) ;
if ( typeof teOptions . headerrows !== 'undefined' )
teOptions . headerrows . length = 0 ;
if ( typeof teOptions . columns !== 'undefined' )
teOptions . columns . length = 0 ;
if ( typeof teOptions . rows !== 'undefined' )
teOptions . rows . length = 0 ;
delete teOptions . doc ;
teOptions . doc = null ;
} ) ;
}
}
function collectHeadRows ( $table ) {
var result = [ ] ;
findTableElements ( $table , 'thead' ) . each ( function ( ) {
result . push . apply ( result , findTableElements ( $ ( this ) , defaults . theadSelector ) . toArray ( ) ) ;
} ) ;
return result ;
}
function collectRows ( $table ) {
var result = [ ] ;
findTableElements ( $table , 'tbody' ) . each ( function ( ) {
result . push . apply ( result , findTableElements ( $ ( this ) , defaults . tbodySelector ) . toArray ( ) ) ;
} ) ;
if ( defaults . tfootSelector . length ) {
findTableElements ( $table , 'tfoot' ) . each ( function ( ) {
result . push . apply ( result , findTableElements ( $ ( this ) , defaults . tfootSelector ) . toArray ( ) ) ;
} ) ;
}
return result ;
}
function findTableElements ( $parent , selector ) {
var parentSelector = $parent [ 0 ] . tagName ;
var parentLevel = $parent . parents ( parentSelector ) . length ;
return $parent . find ( selector ) . filter ( function ( ) {
return parentLevel === $ ( this ) . closest ( parentSelector ) . parents ( parentSelector ) . length ;
} ) ;
}
function GetColumnNames ( table ) {
var result = [ ] ;
$ ( table ) . find ( 'thead' ) . first ( ) . find ( 'th' ) . each ( function ( index , el ) {
if ( $ ( el ) . attr ( "data-field" ) !== undefined )
result [ index ] = $ ( el ) . attr ( "data-field" ) ;
else
result [ index ] = index . toString ( ) ;
} ) ;
return result ;
}
function isVisible ( $element ) {
var isCell = typeof $element [ 0 ] . cellIndex !== 'undefined' ;
var isRow = typeof $element [ 0 ] . rowIndex !== 'undefined' ;
var isElementVisible = ( isCell || isRow ) ? isTableElementVisible ( $element ) : $element . is ( ':visible' ) ;
var tableexportDisplay = $element . data ( "tableexport-display" ) ;
if ( isCell && tableexportDisplay !== 'none' && tableexportDisplay !== 'always' ) {
$element = $ ( $element [ 0 ] . parentNode ) ;
isRow = typeof $element [ 0 ] . rowIndex !== 'undefined' ;
tableexportDisplay = $element . data ( "tableexport-display" ) ;
}
if ( isRow && tableexportDisplay !== 'none' && tableexportDisplay !== 'always' ) {
tableexportDisplay = $element . closest ( 'table' ) . data ( "tableexport-display" ) ;
}
return tableexportDisplay !== 'none' && ( isElementVisible === true || tableexportDisplay === 'always' ) ;
}
function isTableElementVisible ( $element ) {
var hiddenEls = [ ] ;
if ( checkCellVisibilty ) {
hiddenEls = $hiddenTableElements . filter ( function ( ) {
var found = false ;
if ( this . nodeType === $element [ 0 ] . nodeType ) {
if ( typeof this . rowIndex !== 'undefined' && this . rowIndex === $element [ 0 ] . rowIndex )
found = true ;
else if ( typeof this . cellIndex !== 'undefined' && this . cellIndex === $element [ 0 ] . cellIndex &&
typeof this . parentNode . rowIndex !== 'undefined' &&
typeof $element [ 0 ] . parentNode . rowIndex !== 'undefined' &&
this . parentNode . rowIndex === $element [ 0 ] . parentNode . rowIndex )
found = true ;
}
return found ;
} ) ;
}
return ( checkCellVisibilty === false || hiddenEls . length === 0 ) ;
}
function isColumnIgnored ( $cell , rowLength , colIndex ) {
var result = false ;
if ( isVisible ( $cell ) ) {
if ( defaults . ignoreColumn . length > 0 ) {
if ( $ . inArray ( colIndex , defaults . ignoreColumn ) !== - 1 ||
$ . inArray ( colIndex - rowLength , defaults . ignoreColumn ) !== - 1 ||
( colNames . length > colIndex && typeof colNames [ colIndex ] !== 'undefined' &&
$ . inArray ( colNames [ colIndex ] , defaults . ignoreColumn ) !== - 1 ) )
result = true ;
}
}
else
result = true ;
return result ;
}
function ForEachVisibleCell ( tableRow , selector , rowIndex , rowCount , cellcallback ) {
if ( typeof ( cellcallback ) === 'function' ) {
var ignoreRow = false ;
if ( typeof defaults . onIgnoreRow === 'function' )
ignoreRow = defaults . onIgnoreRow ( $ ( tableRow ) , rowIndex ) ;
if ( ignoreRow === false &&
$ . inArray ( rowIndex , defaults . ignoreRow ) === - 1 &&
$ . inArray ( rowIndex - rowCount , defaults . ignoreRow ) === - 1 &&
isVisible ( $ ( tableRow ) ) ) {
var $cells = findTableElements ( $ ( tableRow ) , selector ) ;
var cellCount = 0 ;
$cells . each ( function ( colIndex ) {
var $cell = $ ( this ) ;
var c ;
var colspan = getColspan ( this ) ;
var rowspan = getRowspan ( this ) ;
// Skip ranges
$ . each ( ranges , function ( ) {
var range = this ;
if ( rowIndex >= range . s . r && rowIndex <= range . e . r && cellCount >= range . s . c && cellCount <= range . e . c ) {
for ( c = 0 ; c <= range . e . c - range . s . c ; ++ c )
cellcallback ( null , rowIndex , cellCount ++ ) ;
}
} ) ;
if ( isColumnIgnored ( $cell , $cells . length , colIndex ) === false ) {
// Handle Row Span
if ( rowspan || colspan ) {
rowspan = rowspan || 1 ;
colspan = colspan || 1 ;
ranges . push ( {
s : { r : rowIndex , c : cellCount } ,
e : { r : rowIndex + rowspan - 1 , c : cellCount + colspan - 1 }
} ) ;
}
// Handle Value
cellcallback ( this , rowIndex , cellCount ++ ) ;
}
// Handle Colspan
if ( colspan )
for ( c = 0 ; c < colspan - 1 ; ++ c )
cellcallback ( null , rowIndex , cellCount ++ ) ;
} ) ;
// Skip ranges
$ . each ( ranges , function ( ) {
var range = this ;
if ( rowIndex >= range . s . r && rowIndex <= range . e . r && cellCount >= range . s . c && cellCount <= range . e . c ) {
for ( c = 0 ; c <= range . e . c - range . s . c ; ++ c )
cellcallback ( null , rowIndex , cellCount ++ ) ;
}
} ) ;
}
}
}
function jsPdfDrawImage ( cell , container , imgId , teOptions ) {
if ( typeof teOptions . images !== 'undefined' ) {
var image = teOptions . images [ imgId ] ;
if ( typeof image !== 'undefined' ) {
var arCell = cell . width / cell . height ;
var arImg = container . width / container . height ;
var imgWidth = cell . width ;
var imgHeight = cell . height ;
var px2pt = 0.264583 * 72 / 25.4 ;
var uy = 0 ;
if ( arImg <= arCell ) {
imgHeight = Math . min ( cell . height , container . height ) ;
imgWidth = container . width * imgHeight / container . height ;
}
else if ( arImg > arCell ) {
imgWidth = Math . min ( cell . width , container . width ) ;
imgHeight = container . height * imgWidth / container . width ;
}
imgWidth *= px2pt ;
imgHeight *= px2pt ;
if ( imgHeight < cell . height )
uy = ( cell . height - imgHeight ) / 2 ;
try {
teOptions . doc . addImage ( image . src , cell . textPos . x , cell . y + uy , imgWidth , imgHeight ) ;
}
catch ( e ) {
// TODO: IE -> convert png to jpeg
}
cell . textPos . x += imgWidth ;
}
}
}
function jsPdfOutput ( doc , hasimages ) {
if ( defaults . outputMode === 'string' )
return doc . output ( ) ;
if ( defaults . outputMode === 'base64' )
return base64encode ( doc . output ( ) ) ;
if ( defaults . outputMode === 'window' ) {
window . URL = window . URL || window . webkitURL ;
window . open ( window . URL . createObjectURL ( doc . output ( "blob" ) ) ) ;
return ;
}
try {
var blob = doc . output ( 'blob' ) ;
saveAs ( blob , defaults . fileName + '.pdf' ) ;
}
catch ( e ) {
downloadFile ( defaults . fileName + '.pdf' ,
'data:application/pdf' + ( hasimages ? '' : ';base64' ) + ',' ,
hasimages ? doc . output ( 'blob' ) : doc . output ( ) ) ;
}
}
function prepareAutoTableText ( cell , data , cellopt ) {
var cs = 0 ;
if ( typeof cellopt !== 'undefined' )
cs = cellopt . colspan ;
if ( cs >= 0 ) {
// colspan handling
var cellWidth = cell . width ;
var textPosX = cell . textPos . x ;
var i = data . table . columns . indexOf ( data . column ) ;
for ( var c = 1 ; c < cs ; c ++ ) {
var column = data . table . columns [ i + c ] ;
cellWidth += column . width ;
}
if ( cs > 1 ) {
if ( cell . styles . halign === 'right' )
textPosX = cell . textPos . x + cellWidth - cell . width ;
else if ( cell . styles . halign === 'center' )
textPosX = cell . textPos . x + ( cellWidth - cell . width ) / 2 ;
}
cell . width = cellWidth ;
cell . textPos . x = textPosX ;
if ( typeof cellopt !== 'undefined' && cellopt . rowspan > 1 )
cell . height = cell . height * cellopt . rowspan ;
// fix jsPDF's calculation of text position
if ( cell . styles . valign === 'middle' || cell . styles . valign === 'bottom' ) {
var splittedText = typeof cell . text === 'string' ? cell . text . split ( /\r\n|\r|\n/g ) : cell . text ;
var lineCount = splittedText . length || 1 ;
if ( lineCount > 2 )
cell . textPos . y -= ( ( 2 - FONT _ROW _RATIO ) / 2 * data . row . styles . fontSize ) * ( lineCount - 2 ) / 3 ;
}
return true ;
}
else
return false ; // cell is hidden (colspan = -1), don't draw it
}
function collectImages ( cell , elements , teOptions ) {
if ( typeof cell !== 'undefined' && cell !== null ) {
if ( cell . hasAttribute ( "data-tableexport-canvas" ) ) {
var imgId = new Date ( ) . getTime ( ) ;
$ ( cell ) . attr ( "data-tableexport-canvas" , imgId ) ;
teOptions . images [ imgId ] = {
url : '[data-tableexport-canvas="' + imgId + '"]' ,
src : null
} ;
}
else if ( elements !== 'undefined' && elements != null ) {
elements . each ( function ( ) {
if ( $ ( this ) . is ( "img" ) ) {
var imgId = strHashCode ( this . src ) ;
teOptions . images [ imgId ] = {
url : this . src ,
src : this . src
} ;
}
collectImages ( cell , $ ( this ) . children ( ) , teOptions ) ;
} ) ;
}
}
}
function loadImages ( teOptions , callback ) {
var imageCount = 0 ;
var pendingCount = 0 ;
function done ( ) {
callback ( imageCount ) ;
}
function loadImage ( image ) {
if ( image . url ) {
if ( ! image . src ) {
var $imgContainer = $ ( image . url ) ;
if ( $imgContainer . length ) {
imageCount = ++ pendingCount ;
html2canvas ( $imgContainer [ 0 ] ) . then ( function ( canvas ) {
image . src = canvas . toDataURL ( "image/png" ) ;
if ( ! -- pendingCount )
done ( ) ;
} ) ;
}
}
else {
var img = new Image ( ) ;
imageCount = ++ pendingCount ;
img . crossOrigin = 'Anonymous' ;
img . onerror = img . onload = function ( ) {
if ( img . complete ) {
if ( img . src . indexOf ( 'data:image/' ) === 0 ) {
img . width = image . width || img . width || 0 ;
img . height = image . height || img . height || 0 ;
}
if ( img . width + img . height ) {
var canvas = document . createElement ( "canvas" ) ;
var ctx = canvas . getContext ( "2d" ) ;
canvas . width = img . width ;
canvas . height = img . height ;
ctx . drawImage ( img , 0 , 0 ) ;
image . src = canvas . toDataURL ( "image/png" ) ;
}
}
if ( ! -- pendingCount )
done ( ) ;
} ;
img . src = image . url ;
}
}
}
if ( typeof teOptions . images !== 'undefined' ) {
for ( var i in teOptions . images )
if ( teOptions . images . hasOwnProperty ( i ) )
loadImage ( teOptions . images [ i ] ) ;
}
return pendingCount || done ( ) ;
}
function drawAutotableElements ( cell , elements , teOptions ) {
elements . each ( function ( ) {
if ( $ ( this ) . is ( "div" ) ) {
var bcolor = rgb2array ( getStyle ( this , 'background-color' ) , [ 255 , 255 , 255 ] ) ;
var lcolor = rgb2array ( getStyle ( this , 'border-top-color' ) , [ 0 , 0 , 0 ] ) ;
var lwidth = getPropertyUnitValue ( this , 'border-top-width' , defaults . jspdf . unit ) ;
var r = this . getBoundingClientRect ( ) ;
var ux = this . offsetLeft * teOptions . dw ;
var uy = this . offsetTop * teOptions . dh ;
var uw = r . width * teOptions . dw ;
var uh = r . height * teOptions . dh ;
teOptions . doc . setDrawColor . apply ( undefined , lcolor ) ;
teOptions . doc . setFillColor . apply ( undefined , bcolor ) ;
teOptions . doc . setLineWidth ( lwidth ) ;
teOptions . doc . rect ( cell . x + ux , cell . y + uy , uw , uh , lwidth ? "FD" : "F" ) ;
}
else if ( $ ( this ) . is ( "img" ) ) {
var imgId = strHashCode ( this . src ) ;
jsPdfDrawImage ( cell , this , imgId , teOptions ) ;
}
drawAutotableElements ( cell , $ ( this ) . children ( ) , teOptions ) ;
} ) ;
}
function drawAutotableText ( cell , texttags , teOptions ) {
if ( typeof teOptions . onAutotableText === 'function' ) {
teOptions . onAutotableText ( teOptions . doc , cell , texttags ) ;
}
else {
var x = cell . textPos . x ;
var y = cell . textPos . y ;
var style = { halign : cell . styles . halign , valign : cell . styles . valign } ;
if ( texttags . length ) {
var tag = texttags [ 0 ] ;
while ( tag . previousSibling )
tag = tag . previousSibling ;
var b = false , i = false ;
while ( tag ) {
var txt = tag . innerText || tag . textContent || "" ;
var leadingspace = ( txt . length && txt [ 0 ] === " " ) ? " " : "" ;
var trailingspace = ( txt . length > 1 && txt [ txt . length - 1 ] === " " ) ? " " : "" ;
if ( defaults . preserve . leadingWS !== true )
txt = leadingspace + trimLeft ( txt ) ;
if ( defaults . preserve . trailingWS !== true )
txt = trimRight ( txt ) + trailingspace ;
if ( $ ( tag ) . is ( "br" ) ) {
x = cell . textPos . x ;
y += teOptions . doc . internal . getFontSize ( ) ;
}
if ( $ ( tag ) . is ( "b" ) )
b = true ;
else if ( $ ( tag ) . is ( "i" ) )
i = true ;
if ( b || i )
teOptions . doc . setFontType ( ( b && i ) ? "bolditalic" : b ? "bold" : "italic" ) ;
var w = teOptions . doc . getStringUnitWidth ( txt ) * teOptions . doc . internal . getFontSize ( ) ;
if ( w ) {
if ( cell . styles . overflow === 'linebreak' &&
x > cell . textPos . x && ( x + w ) > ( cell . textPos . x + cell . width ) ) {
var chars = ".,!%*;:=-" ;
if ( chars . indexOf ( txt . charAt ( 0 ) ) >= 0 ) {
var s = txt . charAt ( 0 ) ;
w = teOptions . doc . getStringUnitWidth ( s ) * teOptions . doc . internal . getFontSize ( ) ;
if ( ( x + w ) <= ( cell . textPos . x + cell . width ) ) {
teOptions . doc . autoTableText ( s , x , y , style ) ;
txt = txt . substring ( 1 , txt . length ) ;
}
w = teOptions . doc . getStringUnitWidth ( txt ) * teOptions . doc . internal . getFontSize ( ) ;
}
x = cell . textPos . x ;
y += teOptions . doc . internal . getFontSize ( ) ;
}
if ( cell . styles . overflow !== 'visible' ) {
while ( txt . length && ( x + w ) > ( cell . textPos . x + cell . width ) ) {
txt = txt . substring ( 0 , txt . length - 1 ) ;
w = teOptions . doc . getStringUnitWidth ( txt ) * teOptions . doc . internal . getFontSize ( ) ;
}
}
teOptions . doc . autoTableText ( txt , x , y , style ) ;
x += w ;
}
if ( b || i ) {
if ( $ ( tag ) . is ( "b" ) )
b = false ;
else if ( $ ( tag ) . is ( "i" ) )
i = false ;
teOptions . doc . setFontType ( ( ! b && ! i ) ? "normal" : b ? "bold" : "italic" ) ;
}
tag = tag . nextSibling ;
}
cell . textPos . x = x ;
cell . textPos . y = y ;
}
else {
teOptions . doc . autoTableText ( cell . text , cell . textPos . x , cell . textPos . y , style ) ;
}
}
}
function escapeRegExp ( string ) {
return string == null ? "" : string . toString ( ) . replace ( /([.*+?^=!:${}()|\[\]\/\\])/g , "\\$1" ) ;
}
function replaceAll ( string , find , replace ) {
return string == null ? "" : string . toString ( ) . replace ( new RegExp ( escapeRegExp ( find ) , 'g' ) , replace ) ;
}
function trimLeft ( string ) {
return string == null ? "" : string . toString ( ) . replace ( /^\s+/ , "" ) ;
}
function trimRight ( string ) {
return string == null ? "" : string . toString ( ) . replace ( /\s+$/ , "" ) ;
}
function parseNumber ( value ) {
value = value || "0" ;
value = replaceAll ( value , defaults . numbers . html . thousandsSeparator , '' ) ;
value = replaceAll ( value , defaults . numbers . html . decimalMark , '.' ) ;
return typeof value === "number" || jQuery . isNumeric ( value ) !== false ? value : false ;
}
function parsePercent ( value ) {
if ( value . indexOf ( "%" ) > - 1 ) {
value = parseNumber ( value . replace ( /%/g , "" ) ) ;
if ( value !== false )
value = value / 100 ;
}
else
value = false ;
return value ;
}
function parseString ( cell , rowIndex , colIndex ) {
var result = '' ;
if ( cell !== null ) {
var $cell = $ ( cell ) ;
var htmlData ;
if ( $cell [ 0 ] . hasAttribute ( "data-tableexport-canvas" ) ) {
htmlData = '' ;
}
else if ( $cell [ 0 ] . hasAttribute ( "data-tableexport-value" ) ) {
htmlData = $cell . data ( "tableexport-value" ) ;
htmlData = htmlData ? htmlData + '' : '' ;
}
else {
htmlData = $cell . html ( ) ;
if ( typeof defaults . onCellHtmlData === 'function' )
htmlData = defaults . onCellHtmlData ( $cell , rowIndex , colIndex , htmlData ) ;
else if ( htmlData !== '' ) {
var html = $ . parseHTML ( htmlData ) ;
var inputidx = 0 ;
var selectidx = 0 ;
htmlData = '' ;
$ . each ( html , function ( ) {
if ( $ ( this ) . is ( "input" ) )
htmlData += $cell . find ( 'input' ) . eq ( inputidx ++ ) . val ( ) ;
else if ( $ ( this ) . is ( "select" ) )
htmlData += $cell . find ( 'select option:selected' ) . eq ( selectidx ++ ) . text ( ) ;
else if ( $ ( this ) . is ( "br" ) )
htmlData += "<br>" ;
else {
if ( typeof $ ( this ) . html ( ) === 'undefined' )
htmlData += $ ( this ) . text ( ) ;
else if ( jQuery ( ) . bootstrapTable === undefined ||
( $ ( this ) . hasClass ( 'filterControl' ) !== true &&
$ ( cell ) . parents ( '.detail-view' ) . length === 0 ) )
htmlData += $ ( this ) . html ( ) ;
}
} ) ;
}
}
if ( defaults . htmlContent === true ) {
result = $ . trim ( htmlData ) ;
}
else if ( htmlData && htmlData !== '' ) {
var cellFormat = $ ( cell ) . data ( "tableexport-cellformat" ) ;
if ( cellFormat !== '' ) {
var text = htmlData . replace ( /\n/g , '\u2028' ) . replace ( /(<\s*br([^>]*)>)/gi , '\u2060' ) ;
var obj = $ ( '<div/>' ) . html ( text ) . contents ( ) ;
var number = false ;
text = '' ;
$ . each ( obj . text ( ) . split ( "\u2028" ) , function ( i , v ) {
if ( i > 0 )
text += " " ;
if ( defaults . preserve . leadingWS !== true )
v = trimLeft ( v ) ;
text += ( defaults . preserve . trailingWS !== true ) ? trimRight ( v ) : v ;
} ) ;
$ . each ( text . split ( "\u2060" ) , function ( i , v ) {
if ( i > 0 )
result += "\n" ;
if ( defaults . preserve . leadingWS !== true )
v = trimLeft ( v ) ;
if ( defaults . preserve . trailingWS !== true )
v = trimRight ( v ) ;
result += v . replace ( /\u00AD/g , "" ) ; // remove soft hyphens
} ) ;
result = result . replace ( /\u00A0/g , " " ) ; // replace nbsp's with spaces
if ( defaults . type === 'json' ||
( defaults . type === 'excel' && defaults . mso . fileFormat === 'xmlss' ) ||
defaults . numbers . output === false ) {
number = parseNumber ( result ) ;
if ( number !== false )
result = Number ( number ) ;
}
else if ( defaults . numbers . html . decimalMark !== defaults . numbers . output . decimalMark ||
defaults . numbers . html . thousandsSeparator !== defaults . numbers . output . thousandsSeparator ) {
number = parseNumber ( result ) ;
if ( number !== false ) {
var frac = ( "" + number . substr ( number < 0 ? 1 : 0 ) ) . split ( '.' ) ;
if ( frac . length === 1 )
frac [ 1 ] = "" ;
var mod = frac [ 0 ] . length > 3 ? frac [ 0 ] . length % 3 : 0 ;
result = ( number < 0 ? "-" : "" ) +
( defaults . numbers . output . thousandsSeparator ? ( ( mod ? frac [ 0 ] . substr ( 0 , mod ) + defaults . numbers . output . thousandsSeparator : "" ) + frac [ 0 ] . substr ( mod ) . replace ( /(\d{3})(?=\d)/g , "$1" + defaults . numbers . output . thousandsSeparator ) ) : frac [ 0 ] ) +
( frac [ 1 ] . length ? defaults . numbers . output . decimalMark + frac [ 1 ] : "" ) ;
}
}
}
else
result = htmlData ;
}
if ( defaults . escape === true ) {
//noinspection JSDeprecatedSymbols
result = escape ( result ) ;
}
if ( typeof defaults . onCellData === 'function' ) {
result = defaults . onCellData ( $cell , rowIndex , colIndex , result ) ;
}
}
return result ;
}
function preventInjection ( string ) {
if ( string . length > 0 && defaults . preventInjection === true ) {
var chars = "=+-@" ;
if ( chars . indexOf ( string . charAt ( 0 ) ) >= 0 )
return ( "'" + string ) ;
}
return string ;
}
//noinspection JSUnusedLocalSymbols
function hyphenate ( a , b , c ) {
return b + "-" + c . toLowerCase ( ) ;
}
function rgb2array ( rgb _string , default _result ) {
var re = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/ ;
var bits = re . exec ( rgb _string ) ;
var result = default _result ;
if ( bits )
result = [ parseInt ( bits [ 1 ] ) , parseInt ( bits [ 2 ] ) , parseInt ( bits [ 3 ] ) ] ;
return result ;
}
function getCellStyles ( cell ) {
var a = getStyle ( cell , 'text-align' ) ;
var fw = getStyle ( cell , 'font-weight' ) ;
var fs = getStyle ( cell , 'font-style' ) ;
var f = '' ;
if ( a === 'start' )
a = getStyle ( cell , 'direction' ) === 'rtl' ? 'right' : 'left' ;
if ( fw >= 700 )
f = 'bold' ;
if ( fs === 'italic' )
f += fs ;
if ( f === '' )
f = 'normal' ;
var result = {
style : {
align : a ,
bcolor : rgb2array ( getStyle ( cell , 'background-color' ) , [ 255 , 255 , 255 ] ) ,
color : rgb2array ( getStyle ( cell , 'color' ) , [ 0 , 0 , 0 ] ) ,
fstyle : f
} ,
colspan : getColspan ( cell ) ,
rowspan : getRowspan ( cell )
} ;
if ( cell !== null ) {
var r = cell . getBoundingClientRect ( ) ;
result . rect = {
width : r . width ,
height : r . height
} ;
}
return result ;
}
function getColspan ( cell ) {
var result = $ ( cell ) . data ( "tableexport-colspan" ) ;
if ( typeof result === 'undefined' && $ ( cell ) . is ( "[colspan]" ) )
result = $ ( cell ) . attr ( 'colspan' ) ;
return ( parseInt ( result ) || 0 ) ;
}
function getRowspan ( cell ) {
var result = $ ( cell ) . data ( "tableexport-rowspan" ) ;
if ( typeof result === 'undefined' && $ ( cell ) . is ( "[rowspan]" ) )
result = $ ( cell ) . attr ( 'rowspan' ) ;
return ( parseInt ( result ) || 0 ) ;
}
// get computed style property
function getStyle ( target , prop ) {
try {
if ( window . getComputedStyle ) { // gecko and webkit
prop = prop . replace ( /([a-z])([A-Z])/ , hyphenate ) ; // requires hyphenated, not camel
return window . getComputedStyle ( target , null ) . getPropertyValue ( prop ) ;
}
if ( target . currentStyle ) { // ie
return target . currentStyle [ prop ] ;
}
return target . style [ prop ] ;
}
catch ( e ) {
}
return "" ;
}
function getUnitValue ( parent , value , unit ) {
var baseline = 100 ; // any number serves
var temp = document . createElement ( "div" ) ; // create temporary element
temp . style . overflow = "hidden" ; // in case baseline is set too low
temp . style . visibility = "hidden" ; // no need to show it
parent . appendChild ( temp ) ; // insert it into the parent for em, ex and %
temp . style . width = baseline + unit ;
var factor = baseline / temp . offsetWidth ;
parent . removeChild ( temp ) ; // clean up
return ( value * factor ) ;
}
function getPropertyUnitValue ( target , prop , unit ) {
var value = getStyle ( target , prop ) ; // get the computed style value
var numeric = value . match ( /\d+/ ) ; // get the numeric component
if ( numeric !== null ) {
numeric = numeric [ 0 ] ; // get the string
return getUnitValue ( target . parentElement , numeric , unit ) ;
}
return 0 ;
}
function jx _Workbook ( ) {
if ( ! ( this instanceof jx _Workbook ) ) {
//noinspection JSPotentiallyInvalidConstructorUsage
return new jx _Workbook ( ) ;
}
this . SheetNames = [ ] ;
this . Sheets = { } ;
}
function jx _s2ab ( s ) {
var buf = new ArrayBuffer ( s . length ) ;
var view = new Uint8Array ( buf ) ;
for ( var i = 0 ; i !== s . length ; ++ i ) view [ i ] = s . charCodeAt ( i ) & 0xFF ;
return buf ;
}
function jx _datenum ( v , date1904 ) {
if ( date1904 ) v += 1462 ;
var epoch = Date . parse ( v ) ;
return ( epoch - new Date ( Date . UTC ( 1899 , 11 , 30 ) ) ) / ( 24 * 60 * 60 * 1000 ) ;
}
function jx _createSheet ( data ) {
var ws = { } ;
var range = { s : { c : 10000000 , r : 10000000 } , e : { c : 0 , r : 0 } } ;
for ( var R = 0 ; R !== data . length ; ++ R ) {
for ( var C = 0 ; C !== data [ R ] . length ; ++ C ) {
if ( range . s . r > R ) range . s . r = R ;
if ( range . s . c > C ) range . s . c = C ;
if ( range . e . r < R ) range . e . r = R ;
if ( range . e . c < C ) range . e . c = C ;
var cell = { v : data [ R ] [ C ] } ;
if ( cell . v === null ) continue ;
var cell _ref = XLSX . utils . encode _cell ( { c : C , r : R } ) ;
if ( typeof cell . v === 'number' ) cell . t = 'n' ;
else if ( typeof cell . v === 'boolean' ) cell . t = 'b' ;
else if ( cell . v instanceof Date ) {
cell . t = 'n' ;
cell . z = XLSX . SSF . _table [ 14 ] ;
cell . v = jx _datenum ( cell . v ) ;
}
else cell . t = 's' ;
ws [ cell _ref ] = cell ;
}
}
if ( range . s . c < 10000000 ) ws [ '!ref' ] = XLSX . utils . encode _range ( range ) ;
return ws ;
}
function strHashCode ( str ) {
var hash = 0 , i , chr , len ;
if ( str . length === 0 ) return hash ;
for ( i = 0 , len = str . length ; i < len ; i ++ ) {
chr = str . charCodeAt ( i ) ;
hash = ( ( hash << 5 ) - hash ) + chr ;
hash |= 0 ; // Convert to 32bit integer
}
return hash ;
}
function downloadFile ( filename , header , data ) {
var ua = window . navigator . userAgent ;
if ( filename !== false && window . navigator . msSaveOrOpenBlob ) {
//noinspection JSUnresolvedFunction
window . navigator . msSaveOrOpenBlob ( new Blob ( [ data ] ) , filename ) ;
}
else if ( filename !== false && ( ua . indexOf ( "MSIE " ) > 0 || ! ! ua . match ( /Trident.*rv\:11\./ ) ) ) {
// Internet Explorer (<= 9) workaround by Darryl (https://github.com/dawiong/tableExport.jquery.plugin)
// based on sampopes answer on http://stackoverflow.com/questions/22317951
// ! Not working for json and pdf format !
var frame = document . createElement ( "iframe" ) ;
if ( frame ) {
document . body . appendChild ( frame ) ;
frame . setAttribute ( "style" , "display:none" ) ;
frame . contentDocument . open ( "txt/plain" , "replace" ) ;
frame . contentDocument . write ( data ) ;
frame . contentDocument . close ( ) ;
frame . contentDocument . focus ( ) ;
var extension = filename . substr ( ( filename . lastIndexOf ( '.' ) + 1 ) ) ;
switch ( extension ) {
case 'doc' : case 'json' : case 'png' : case 'pdf' : case 'xls' : case 'xlsx' :
filename += ".txt" ;
break ;
}
frame . contentDocument . execCommand ( "SaveAs" , true , filename ) ;
document . body . removeChild ( frame ) ;
}
}
else {
var DownloadLink = document . createElement ( 'a' ) ;
if ( DownloadLink ) {
var blobUrl = null ;
DownloadLink . style . display = 'none' ;
if ( filename !== false )
DownloadLink . download = filename ;
else
DownloadLink . target = '_blank' ;
if ( typeof data === 'object' ) {
window . URL = window . URL || window . webkitURL ;
var binaryData = [ ] ;
binaryData . push ( data ) ;
blobUrl = window . URL . createObjectURL ( new Blob ( binaryData , { type : header } ) ) ;
DownloadLink . href = blobUrl ;
}
else if ( header . toLowerCase ( ) . indexOf ( "base64," ) >= 0 )
DownloadLink . href = header + base64encode ( data ) ;
else
DownloadLink . href = header + encodeURIComponent ( data ) ;
document . body . appendChild ( DownloadLink ) ;
if ( document . createEvent ) {
if ( DownloadEvt === null )
DownloadEvt = document . createEvent ( 'MouseEvents' ) ;
DownloadEvt . initEvent ( 'click' , true , false ) ;
DownloadLink . dispatchEvent ( DownloadEvt ) ;
}
else if ( document . createEventObject )
DownloadLink . fireEvent ( 'onclick' ) ;
else if ( typeof DownloadLink . onclick === 'function' )
DownloadLink . onclick ( ) ;
setTimeout ( function ( ) {
if ( blobUrl )
window . URL . revokeObjectURL ( blobUrl ) ;
document . body . removeChild ( DownloadLink ) ;
} , 100 ) ;
}
}
}
function utf8Encode ( text ) {
if ( typeof text === 'string' ) {
text = text . replace ( /\x0d\x0a/g , "\x0a" ) ;
var utftext = "" ;
for ( var n = 0 ; n < text . length ; n ++ ) {
var c = text . charCodeAt ( n ) ;
if ( c < 128 ) {
utftext += String . fromCharCode ( c ) ;
}
else if ( ( c > 127 ) && ( c < 2048 ) ) {
utftext += String . fromCharCode ( ( c >> 6 ) | 192 ) ;
utftext += String . fromCharCode ( ( c & 63 ) | 128 ) ;
}
else {
utftext += String . fromCharCode ( ( c >> 12 ) | 224 ) ;
utftext += String . fromCharCode ( ( ( c >> 6 ) & 63 ) | 128 ) ;
utftext += String . fromCharCode ( ( c & 63 ) | 128 ) ;
}
}
return utftext ;
}
return text ;
}
function base64encode ( input ) {
var chr1 , chr2 , chr3 , enc1 , enc2 , enc3 , enc4 ;
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ;
var output = "" ;
var i = 0 ;
input = utf8Encode ( input ) ;
while ( i < input . length ) {
chr1 = input . charCodeAt ( i ++ ) ;
chr2 = input . charCodeAt ( i ++ ) ;
chr3 = input . charCodeAt ( i ++ ) ;
enc1 = chr1 >> 2 ;
enc2 = ( ( chr1 & 3 ) << 4 ) | ( chr2 >> 4 ) ;
enc3 = ( ( chr2 & 15 ) << 2 ) | ( chr3 >> 6 ) ;
enc4 = chr3 & 63 ;
if ( isNaN ( chr2 ) ) {
enc3 = enc4 = 64 ;
} else if ( isNaN ( chr3 ) ) {
enc4 = 64 ;
}
output = output +
keyStr . charAt ( enc1 ) + keyStr . charAt ( enc2 ) +
keyStr . charAt ( enc3 ) + keyStr . charAt ( enc4 ) ;
}
return output ;
}
return this ;
}
} ) ( jQuery ) ;
! function ( t , e ) { "object" == typeof exports && "undefined" != typeof module ? module . exports = e ( ) : "function" == typeof define && define . amd ? define ( e ) : t . jspdf = e ( ) } ( this , function ( ) { "use strict" ; var t = "function" == typeof Symbol && "symbol" == typeof Symbol . iterator ? function ( t ) { return typeof t } : function ( t ) { return t && "function" == typeof Symbol && t . constructor === Symbol && t !== Symbol . prototype ? "symbol" : typeof t } , e = ( function ( ) { function t ( t ) { this . value = t } function e ( e ) { function n ( t , e ) { return new Promise ( function ( n , i ) { var s = { key : t , arg : e , resolve : n , reject : i , next : null } ; a ? a = a . next = s : ( o = a = s , r ( t , e ) ) } ) } function r ( n , o ) { try { var a = e [ n ] ( o ) , s = a . value ; s instanceof t ? Promise . resolve ( s . value ) . then ( function ( t ) { r ( "next" , t ) } , function ( t ) { r ( "throw" , t ) } ) : i ( a . done ? "return" : "normal" , a . value ) } catch ( t ) { i ( "throw" , t ) } } function i ( t , e ) { switch ( t ) { case "return" : o . resolve ( { value : e , done : ! 0 } ) ; break ; case "throw" : o . reject ( e ) ; break ; default : o . resolve ( { value : e , done : ! 1 } ) } o = o . next , o ? r ( o . key , o . arg ) : a = null } var o , a ; this . _invoke = n , "function" != typeof e . return && ( this . return = void 0 ) } return "function" == typeof Symbol && Symbol . asyncIterator && ( e . prototype [ Symbol . asyncIterator ] = function ( ) { return this } ) , e . prototype . next = function ( t ) { return this . _invoke ( "next" , t ) } , e . prototype . throw = function ( t ) { return this . _invoke ( "throw" , t ) } , e . prototype . return = function ( t ) { return this . _invoke ( "return" , t ) } , { wrap : function ( t ) { return function ( ) { return new e ( t . apply ( this , arguments ) ) } } , await : function ( e ) { return new t ( e ) } } } ( ) , function ( e ) { function n ( t ) { var n = { } ; this . subscribe = function ( t , e , r ) { if ( "function" != typeof e ) return ! 1 ; n . hasOwnProperty ( t ) || ( n [ t ] = { } ) ; var i = Math . random ( ) . toString ( 35 ) ; return n [ t ] [ i ] = [ e , ! ! r ] , i } , this . unsubscribe = function ( t ) { for ( var e in n ) if ( n [ e ] [ t ] ) return delete n [ e ] [ t ] , ! 0 ; return ! 1 } , this . publish = function ( r ) { if ( n . hasOwnProperty ( r ) ) { var i = Array . prototype . slice . call ( arguments , 1 ) , o = [ ] ; for ( var a in n [ r ] ) { var s = n [ r ] [ a ] ; try { s [ 0 ] . apply ( t , i ) } catch ( t ) { e . console && console . error ( "jsPDF PubSub Error" , t . message , t ) } s [ 1 ] && o . push ( a ) } o . length && o . forEach ( this . unsubscribe ) } } } function r ( c , l , u , h ) { var f = { } ; "object" === ( "undefined" == typeof c ? "undefined" : t ( c ) ) && ( f = c , c = f . orientation , l = f . unit || l , u = f . format || u , h = f . compress || f . compressPdf || h ) , l = l || "mm" , u = u || "a4" , c = ( "" + ( c || "P" ) ) . toLowerCase ( ) ; var d , p , g , m , w , y , v , b , x , k = ( ( "" + u ) . toLowerCase ( ) , ! ! h && "function" == typeof Uint8Array ) , _ = f . textColor || "0 g" , C = f . drawColor || "0 G" , A = f . fontSize || 16 , S = f . lineHeight || 1.15 , q = f . lineWidth || . 200025 , T = 2 , P = ! 1 , I = [ ] , E = { } , O = { } , F = 0 , R = [ ] , B = [ ] , D = [ ] , j = [ ] , z = [ ] , N = 0 , L = 0 , M = 0 , U = { title : "" , subject : "" , author : "" , keywords : "" , creator : "" } , H = { } , W = new n ( H ) , X = function ( t ) { return t . toFixed ( 2 ) } , V = function ( t ) { return t . toFixed ( 3 ) } , Y = function ( t ) { return ( "0" + parseInt ( t ) ) . slice ( - 2 ) } , G = function ( t ) { P ? R [ m ] . push ( t ) : ( M += t . length + 1 , j . push ( t ) ) } , J = function ( ) { return T ++ , I [ T ] = M , G ( T + " 0 obj" ) , T } , Q = function ( ) { var t = 2 * R . length + 1 ; t += z . length ; var e = { objId : t , content : "" } ; return z . push ( e ) , e } , K = function ( ) { return T ++ , I [ T ] = function ( ) { return M } , T } , $ = function ( t ) { I [ t ] = M } , Z = function ( t ) { G ( "stream" ) , G ( t ) , G ( "endstream" ) } , tt = function ( ) { var t , n , i , o , s , c , l , u , h , f = [ ] ; for ( l = e . adler32cs || r . adler32cs , k && "undefined" == typeof l && ( k = ! 1 ) , t = 1 ; t <= F ; t ++ ) { if ( f . push ( J ( ) ) , u = ( w = D [ t ] . width ) * p , h = ( y = D [ t ] . height ) * p , G ( "<</Type /Page" ) , G ( "/Parent 1 0 R" ) , G ( "/Resources 2 0 R" ) , G ( "/MediaBox [0 0 " + X ( u ) + " " + X ( h ) + "]" ) , W . publish ( "putPage" , { pageNumber : t , page : R [ t ] } ) , G ( "/Contents " + ( T + 1 ) + " 0 R" ) , G ( ">>" ) , G ( "endobj" ) , n = R [ t ] . join ( "\n" ) , J ( ) , k ) { for ( i = [ ] , o = n . length ; o -- ; ) i [ o ] = n . charCodeAt ( o ) ; c = l . from ( n ) , s = new a ( 6 ) , s . append ( new Uint8Array ( i ) ) , n = s . flush ( ) , i = new Uint8Array ( n . length + 6 ) , i . set ( new Uint8Array ( [ 120 , 156 ] ) ) , i . set ( n , 2 ) , i . set ( new Uint8Array ( [ 255 & c , c >> 8 & 255 , c >> 16 & 255 , c >> 24 & 255 ] ) , n . length + 2 ) , n = String . fromCharCode . apply ( null , i ) , G ( "<</Length " + n . length + " /Filter [/FlateDecode]>>" ) } else G ( "<</Length " + n . length + ">>" ) ; Z ( n ) , G ( "endobj" ) } I [ 1 ] = M , G ( "1 0 obj" ) , G ( "<</Type /Pages" ) ; var d = "/Kids [" ; for ( o = 0 ; o < F ; o ++ ) d += f [ o ] + " 0 R " ; G ( d + "]" ) , G ( "/Count " + F ) , G ( ">>" ) , G ( "endobj" ) , W . publish ( "postPutPages" ) } , et = function ( t ) { t . objectNumber = J ( ) , G ( "<</BaseFont/" + t . PostScriptName + "/Type/Font" ) , "string" == typeof t . encoding && G ( "/Encoding/" + t . encoding ) , G ( "/Subtype/Type1>>" ) , G ( "endobj" ) } , nt = function ( ) { for ( va
* jsPDF AcroForm Plugin
* Copyright ( c ) 2016 Alexander Weidt , https : //github.com/BiggA94
*
* Licensed under the MIT License .
* http : //opensource.org/licenses/mit-license
* /
( window . AcroForm = function ( t ) { var n = window . AcroForm ; n . scale = function ( t ) { return t * ( r . internal . scaleFactor / 1 ) } , n . antiScale = function ( t ) { return 1 / r . internal . scaleFactor * t } ; var r = { fields : [ ] , xForms : [ ] , acroFormDictionaryRoot : null , printedOut : ! 1 , internal : null } ; e . API . acroformPlugin = r ; var i = function ( ) { for ( var t in this . acroformPlugin . acroFormDictionaryRoot . Fields ) { var e = this . acroformPlugin . acroFormDictionaryRoot . Fields [ t ] ; e . hasAnnotation && a . call ( this , e ) } } , o = function ( ) { if ( this . acroformPlugin . acroFormDictionaryRoot ) throw new Error ( "Exception while creating AcroformDictionary" ) ; this . acroformPlugin . acroFormDictionaryRoot = new n . AcroFormDictionary , this . acroformPlugin . internal = this . internal , this . acroformPlugin . acroFormDictionaryRoot . _eventID = this . internal . events . subscribe ( "postPutResources" , l ) , this . internal . events . subscribe ( "buildDocument" , i ) , this . internal . events . subscribe ( "putCatalog" , c ) , this . internal . events . subscribe ( "postPutPages" , u ) } , a = function ( t ) { var n = { type : "reference" , object : t } ; e . API . annotationPlugin . annotations [ this . internal . getPageInfo ( t . page ) . pageNumber ] . push ( n ) } , s = function ( t ) { this . acroformPlugin . printedOut && ( this . acroformPlugin . printedOut = ! 1 , this . acroformPlugin . acroFormDictionaryRoot = null ) , this . acroformPlugin . acroFormDictionaryRoot || o . call ( this ) , this . acroformPlugin . acroFormDictionaryRoot . Fields . push ( t ) } , c = function ( ) { "undefined" != typeof this . acroformPlugin . acroFormDictionaryRoot ? this . internal . write ( "/AcroForm " + this . acroformPlugin . acroFormDictionaryRoot . objId + " 0 R" ) : console . log ( "Root missing..." ) } , l = function ( ) { this . internal . events . unsubscribe ( this . acroformPlugin . acroFormDictionaryRoot . _eventID ) , delete this . acroformPlugin . acroFormDictionaryRoot . _eventID , this . acroformPlugin . printedOut = ! 0 } , u = function ( t ) { var e = ! t ; t || ( this . internal . newObjectDeferredBegin ( this . acroformPlugin . acroFormDictionaryRoot . objId ) , this . internal . out ( this . acroformPlugin . acroFormDictionaryRoot . getString ( ) ) ) ; var t = t || this . acroformPlugin . acroFormDictionaryRoot . Kids ; for ( var r in t ) { var i = t [ r ] , o = i . Rect ; i . Rect && ( i . Rect = n . internal . calculateCoordinates . call ( this , i . Rect ) ) , this . internal . newObjectDeferredBegin ( i . objId ) ; var a = "" ; if ( a += i . objId + " 0 obj\n" , a += "<<\n" + i . getContent ( ) , i . Rect = o , i . hasAppearanceStream && ! i . appearanceStreamContent ) { var s = n . internal . calculateAppearanceStream . call ( this , i ) ; a += "/AP << /N " + s + " >>\n" , this . acroformPlugin . xForms . push ( s ) } if ( i . appearanceStreamContent ) { a += "/AP << " ; for ( var c in i . appearanceStreamContent ) { var l = i . appearanceStreamContent [ c ] ; if ( a += "/" + c + " " , a += "<< " , Object . keys ( l ) . length >= 1 || Array . isArray ( l ) ) for ( var r in l ) { var u = l [ r ] ; "function" == typeof u && ( u = u . call ( this , i ) ) , a += "/" + r + " " + u + " " , this . acroformPlugin . xForms . indexOf ( u ) >= 0 || this . acroformPlugin . xForms . push ( u ) } else { var u = l ; "function" == typeof u && ( u = u . call ( this , i ) ) , a += "/" + r + " " + u + " \n" , this . acroformPlugin . xForms . indexOf ( u ) >= 0 || this . acroformPlugin . xForms . push ( u ) } a += " >>\n" } a += ">>\n" } a += ">>\nendobj\n" , this . internal . out ( a ) } e && h . call ( this , this . acroformPlugin . xForms ) } , h = function ( t ) { for ( var e in t ) { var n = e , r = t [ e ] ; this . internal . newObjectDeferredBegin ( r && r . objId ) ; var i = "" ; i += r ? r . getString ( ) : "" , this . internal . out ( i ) , delete t [ n ] } } ; t . addField = function ( t ) { return t instanceof n . TextField ? d . call ( this , t ) : t instanceof n . ChoiceField ? p . call ( this , t ) : t instanceof n . Button ? f . call ( this , t ) : t instanceof n . ChildClass ? s . call ( this , t ) : t && s . call ( this , t ) , t . page = this . acroformPlugin . internal . getCurrentPageInfo ( ) . pageNumber , this } ; var f = function ( t ) { var t = t || new n . Field ; t . FT = "/Btn" ; var e = t . Ff || 0 ; t . pushbutton && ( e = n . internal . setBitPosition ( e , 17 ) , delete t . pushbutton ) , t . radio && ( e = n . internal . setBitPosition ( e , 16 ) , delete t . radio ) , t . noToggleToOff && ( e = n . internal . setBitPosition ( e , 15 ) ) , t . Ff = e , s . call ( this , t ) } , d = function ( t ) { var t = t || new n . Field ; t . FT = "/Tx" ; var e = t . Ff || 0 ; t . multiline && ( e = 4096 | e ) , t . password && ( e = 8192 | e ) , t . fileSelect && ( e |= 1 << 20 ) , t . doNotSpellCheck && ( e |= 1 << 22 ) , t . doNotScroll && ( e |= 1 << 23 ) , t . Ff = t . Ff || e , s . call ( this , t ) } , p = function ( t ) { var e = t || new n . Field ; e . FT = "/Ch" ; var r = e . Ff || 0 ; e . combo && ( r = n . internal . setBitPosition ( r , 18 ) , delete e . combo ) , e . edit && ( r = n . internal . setBitPosition ( r , 19 ) , delete e . edit ) , e . sort && ( r = n . internal . setBitPosition ( r , 20 )
* jsPDF addHTML PlugIn
* Copyright ( c ) 2014 Diego Casorran
*
* Licensed under the MIT License .
* http : //opensource.org/licenses/mit-license
* /
function ( t ) { t . addHTML = function ( t , e , n , r , i ) { if ( "undefined" == typeof html2canvas && "undefined" == typeof rasterizeHTML ) throw new Error ( "You need either https://github.com/niklasvh/html2canvas or https://github.com/cburgmer/rasterizeHTML.js" ) ; "number" != typeof e && ( r = e , i = n ) , "function" == typeof r && ( i = r , r = null ) ; var o = this . internal , a = o . scaleFactor , s = o . pageSize . width , c = o . pageSize . height ; if ( r = r || { } , r . onrendered = function ( t ) { e = parseInt ( e ) || 0 , n = parseInt ( n ) || 0 ; var o = r . dim || { } , l = o . h || 0 , u = o . w || Math . min ( s , t . width / a ) - e , h = "JPEG" ; if ( r . format && ( h = r . format ) , t . height > c && r . pagesplit ) { var f = function ( ) { for ( var r = 0 ; ; ) { var o = document . createElement ( "canvas" ) ; o . width = Math . min ( s * a , t . width ) , o . height = Math . min ( c * a , t . height - r ) ; var l = o . getContext ( "2d" ) ; l . drawImage ( t , 0 , r , t . width , o . height , 0 , 0 , o . width , o . height ) ; var f = [ o , e , r ? 0 : n , o . width / a , o . height / a , h , null , "SLOW" ] ; if ( this . addImage . apply ( this , f ) , r += o . height , r >= t . height ) break ; this . addPage ( ) } i ( u , r , null , f ) } . bind ( this ) ; if ( "CANVAS" === t . nodeName ) { var d = new Image ; d . onload = f , d . src = t . toDataURL ( "image/png" ) , t = d } else f ( ) } else { var p = Math . random ( ) . toString ( 35 ) , g = [ t , e , n , u , l , h , p , "SLOW" ] ; this . addImage . apply ( this , g ) , i ( u , l , p , g ) } } . bind ( this ) , "undefined" != typeof html2canvas && ! r . rstz ) return html2canvas ( t , r ) ; if ( "undefined" != typeof rasterizeHTML ) { var l = "drawDocument" ; return "string" == typeof t && ( l = /^http/ . test ( t ) ? "drawURL" : "drawHTML" ) , r . width = r . width || s * a , rasterizeHTML [ l ] ( t , void 0 , r ) . then ( function ( t ) { r . onrendered ( t . image ) } , function ( t ) { i ( null , t ) } ) } return null } } ( e . API ) , / * * @ p r e s e r v e
* jsPDF addImage plugin
* Copyright ( c ) 2012 Jason Siefken , https : //github.com/siefkenj/
* 2013 Chris Dowling , https : //github.com/gingerchris
* 2013 Trinh Ho , https : //github.com/ineedfat
* 2013 Edwin Alejandro Perez , https : //github.com/eaparango
* 2013 Norah Smith , https : //github.com/burnburnrocket
* 2014 Diego Casorran , https : //github.com/diegocr
* 2014 James Robb , https : //github.com/jamesbrobb
*
*
* /
function ( e ) { var n = "addImage_" , r = [ "jpeg" , "jpg" , "png" ] , i = function t ( e ) { var n = this . internal . newObject ( ) , r = this . internal . write , i = this . internal . putStream ; if ( e . n = n , r ( "<</Type /XObject" ) , r ( "/Subtype /Image" ) , r ( "/Width " + e . w ) , r ( "/Height " + e . h ) , e . cs === this . color _spaces . INDEXED ? r ( "/ColorSpace [/Indexed /DeviceRGB " + ( e . pal . length / 3 - 1 ) + " " + ( "smask" in e ? n + 2 : n + 1 ) + " 0 R]" ) : ( r ( "/ColorSpace /" + e . cs ) , e . cs === this . color _spaces . DEVICE _CMYK && r ( "/Decode [1 0 1 0 1 0 1 0]" ) ) , r ( "/BitsPerComponent " + e . bpc ) , "f" in e && r ( "/Filter /" + e . f ) , "dp" in e && r ( "/DecodeParms <<" + e . dp + ">>" ) , "trns" in e && e . trns . constructor == Array ) { for ( var o = "" , a = 0 , s = e . trns . length ; a < s ; a ++ ) o += e . trns [ a ] + " " + e . trns [ a ] + " " ; r ( "/Mask [" + o + "]" ) } if ( "smask" in e && r ( "/SMask " + ( n + 1 ) + " 0 R" ) , r ( "/Length " + e . data . length + ">>" ) , i ( e . data ) , r ( "endobj" ) , "smask" in e ) { var c = "/Predictor " + e . p + " /Colors 1 /BitsPerComponent " + e . bpc + " /Columns " + e . w , l = { w : e . w , h : e . h , cs : "DeviceGray" , bpc : e . bpc , dp : c , data : e . smask } ; "f" in e && ( l . f = e . f ) , t . call ( this , l ) } e . cs === this . color _spaces . INDEXED && ( this . internal . newObject ( ) , r ( "<< /Length " + e . pal . length + ">>" ) , i ( this . arrayBufferToBinaryString ( new Uint8Array ( e . pal ) ) ) , r ( "endobj" ) ) } , o = function ( ) { var t = this . internal . collections [ n + "images" ] ; for ( var e in t ) i . call ( this , t [ e ] ) } , a = function ( ) { var t , e = this . internal . collections [ n + "images" ] , r = this . internal . write ; for ( var i in e ) t = e [ i ] , r ( "/I" + t . i , t . n , "0" , "R" ) } , s = function ( t ) { return t && "string" == typeof t && ( t = t . toUpperCase ( ) ) , t in e . image _compression ? t : e . image _compression . NONE } , c = function ( ) { var t = this . internal . collections [ n + "images" ] ; return t || ( this . internal . collections [ n + "images" ] = t = { } , this . internal . events . subscribe ( "putResources" , o ) , this . internal . events . subscribe ( "putXobjectDict" , a ) ) , t } , l = function ( t ) { var e = 0 ; return t && ( e = Object . keys ? Object . keys ( t ) . length : function ( t ) { var e = 0 ; for ( var n in t ) t . hasOwnProperty ( n ) && e ++ ; return e } ( t ) ) , e } , u = function ( t ) { return "undefined" == typeof t || null === t } , h = function ( t ) { return "string" == typeof t && e . sHashCode ( t ) } , f = function ( t ) { return r . indexOf ( t ) === - 1 } , d = function ( t ) { return "function" != typeof e [ "process" + t . toUpperCase ( ) ] } , p = function ( e ) { return "object" === ( "undefined" == typeof e ? "undefined" : t ( e ) ) && 1 === e . nodeType } , g = function ( e , n , r ) { if ( "IMG" === e . nodeName && e . hasAttribute ( "src" ) ) { var i = "" + e . getAttribute ( "src" ) ; if ( ! r && 0 === i . indexOf ( "data:image/" ) ) return i ; ! n && /\.png(?:[?#].*)?$/i . test ( i ) && ( n = "png" ) } if ( "CANVAS" === e . nodeName ) var o = e ; else { var o = document . createElement ( "canvas" ) ; o . width = e . clientWidth || e . width , o . height = e . clientHeight || e . height ; var a = o . getContext ( "2d" ) ; if ( ! a ) throw "addImage requires canvas to be supported by browser." ; if ( r ) { var s , c , l , u , h , f , d , p , g = Math . PI / 180 ; "object" === ( "undefined" == typeof r ? "undefined" : t ( r ) ) && ( s = r . x , c = r . y , l = r . bg , r = r . angle ) , p = r * g , u = Math . abs ( Math . cos ( p ) ) , h = Math . abs ( Math . sin ( p ) ) , f = o . width , d = o . height , o . width = d * h + f * u , o . height = d * u + f * h , isNaN ( s ) && ( s = o . width / 2 ) , isNaN ( c ) && ( c = o . height / 2 ) , a . clearRect ( 0 , 0 , o . width , o . height ) , a . fillStyle = l || "white" , a . fillRect ( 0 , 0 , o . width , o . height ) , a . save ( ) , a . translate ( s , c ) , a . rotate ( p ) , a . drawImage ( e , - ( f / 2 ) , - ( d / 2 ) ) , a . rotate ( - p ) , a . translate ( - s , - c ) , a . restore ( ) } else a . drawImage ( e , 0 , 0 , o . width , o . height ) } return o . toDataURL ( "png" == ( "" + n ) . toLowerCase ( ) ? "image/png" : "image/jpeg" ) } , m = function ( t , e ) { var n ; if ( e ) for ( var r in e ) if ( t === e [ r ] . alias ) { n = e [ r ] ; break } return n } , w = function ( t , e , n ) { return t || e || ( t = - 96 , e = - 96 ) , t < 0 && ( t = - 1 * n . w * 72 / t / this . internal . scaleFactor ) , e < 0 && ( e = - 1 * n . h * 72 / e / this . internal . scaleFactor ) , 0 === t && ( t = e * n . w / n . h ) , 0 === e && ( e = t * n . h / n . w ) , [ t , e ] } , y = function ( t , e , n , r , i , o , a ) { var s = w . call ( this , n , r , i ) , c = this . internal . getCoordinateString , l = this . internal . getVerticalCoordinateString ; n = s [ 0 ] , r = s [ 1 ] , a [ o ] = i , this . internal . write ( "q" , c ( n ) , "0 0" , c ( r ) , c ( t ) , l ( e + r ) , "cm /I" + i . i , "Do Q" ) } ; e . color _spaces = { DEVICE _RGB : "DeviceRGB" , DEVICE _GRAY : "DeviceGray" , DEVICE _CMYK : "DeviceCMYK" , CAL _GREY : "CalGray" , CAL _RGB : "CalRGB" , LAB : "Lab" , ICC _BASED : "ICCBased" , INDEXED : "Indexed" , PATTERN : "Pattern" , SEPARATION : "Separation" , DEVICE _N : "DeviceN" } , e . decode = { DCT _DECODE : "DCTDecode" , FLATE _DECODE : "FlateDecode" , LZW _DECODE : "LZWDecode" , JPX _DECODE : "JPXDecode" , JBIG2 _DECODE : "JBIG2Decode" , ASCII85 _DECODE : "ASCII85Decode" , ASCII _HEX _DECODE : "ASCIIHexDecode" , RUN _LENGTH _
* jsPDF Annotations PlugIn
* Copyright ( c ) 2014 Steven Spungin ( TwelveTone LLC ) steven @ twelvetone . tv
*
* Licensed under the MIT License .
* http : //opensource.org/licenses/mit-license
* /
function ( t ) { var n = { annotations : [ ] , f2 : function ( t ) { return t . toFixed ( 2 ) } , notEmpty : function ( t ) { if ( "undefined" != typeof t && "" != t ) return ! 0 } } ; return e . API . annotationPlugin = n , e . API . events . push ( [ "addPage" , function ( t ) { this . annotationPlugin . annotations [ t . pageNumber ] = [ ] } ] ) , t . events . push ( [ "putPage" , function ( t ) { for ( var e = this . annotationPlugin . annotations [ t . pageNumber ] , r = ! 1 , i = 0 ; i < e . length && ! r ; i ++ ) { var o = e [ i ] ; switch ( o . type ) { case "link" : if ( n . notEmpty ( o . options . url ) || n . notEmpty ( o . options . pageNumber ) ) { r = ! 0 ; break } case "reference" : case "text" : case "freetext" : r = ! 0 } } if ( 0 != r ) { this . internal . write ( "/Annots [" ) ; for ( var a = this . annotationPlugin . f2 , s = this . internal . scaleFactor , c = this . internal . pageSize . height , l = this . internal . getPageInfo ( t . pageNumber ) , i = 0 ; i < e . length ; i ++ ) { var o = e [ i ] ; switch ( o . type ) { case "reference" : this . internal . write ( " " + o . object . objId + " 0 R " ) ; break ; case "text" : var u = this . internal . newAdditionalObject ( ) , h = this . internal . newAdditionalObject ( ) , f = o . title || "Note" , d = "/Rect [" + a ( o . bounds . x * s ) + " " + a ( c - ( o . bounds . y + o . bounds . h ) * s ) + " " + a ( ( o . bounds . x + o . bounds . w ) * s ) + " " + a ( ( c - o . bounds . y ) * s ) + "] " ; y = "<</Type /Annot /Subtype /Text " + d + "/Contents (" + o . contents + ")" , y += " /Popup " + h . objId + " 0 R" , y += " /P " + l . objId + " 0 R" , y += " /T (" + f + ") >>" , u . content = y ; var p = u . objId + " 0 R" , g = 30 , d = "/Rect [" + a ( ( o . bounds . x + g ) * s ) + " " + a ( c - ( o . bounds . y + o . bounds . h ) * s ) + " " + a ( ( o . bounds . x + o . bounds . w + g ) * s ) + " " + a ( ( c - o . bounds . y ) * s ) + "] " ; y = "<</Type /Annot /Subtype /Popup " + d + " /Parent " + p , o . open && ( y += " /Open true" ) , y += " >>" , h . content = y , this . internal . write ( u . objId , "0 R" , h . objId , "0 R" ) ; break ; case "freetext" : var d = "/Rect [" + a ( o . bounds . x * s ) + " " + a ( ( c - o . bounds . y ) * s ) + " " + a ( o . bounds . x + o . bounds . w * s ) + " " + a ( c - ( o . bounds . y + o . bounds . h ) * s ) + "] " , m = o . color || "#000000" ; y = "<</Type /Annot /Subtype /FreeText " + d + "/Contents (" + o . contents + ")" , y += " /DS(font: Helvetica,sans-serif 12.0pt; text-align:left; color:#" + m + ")" , y += " /Border [0 0 0]" , y += " >>" , this . internal . write ( y ) ; break ; case "link" : if ( o . options . name ) { var w = this . annotations . _nameMap [ o . options . name ] ; o . options . pageNumber = w . page , o . options . top = w . y } else o . options . top || ( o . options . top = 0 ) ; var d = "/Rect [" + a ( o . x * s ) + " " + a ( ( c - o . y ) * s ) + " " + a ( o . x + o . w * s ) + " " + a ( c - ( o . y + o . h ) * s ) + "] " , y = "" ; if ( o . options . url ) y = "<</Type /Annot /Subtype /Link " + d + "/Border [0 0 0] /A <</S /URI /URI (" + o . options . url + ") >>" ; else if ( o . options . pageNumber ) { var t = this . internal . getPageInfo ( o . options . pageNumber ) ; switch ( y = "<</Type /Annot /Subtype /Link " + d + "/Border [0 0 0] /Dest [" + t . objId + " 0 R" , o . options . magFactor = o . options . magFactor || "XYZ" , o . options . magFactor ) { case "Fit" : y += " /Fit]" ; break ; case "FitH" : y += " /FitH " + o . options . top + "]" ; break ; case "FitV" : o . options . left = o . options . left || 0 , y += " /FitV " + o . options . left + "]" ; break ; case "XYZ" : default : var v = a ( ( c - o . options . top ) * s ) ; o . options . left = o . options . left || 0 , "undefined" == typeof o . options . zoom && ( o . options . zoom = 0 ) , y += " /XYZ " + o . options . left + " " + v + " " + o . options . zoom + "]" } } "" != y && ( y += " >>" , this . internal . write ( y ) ) } } this . internal . write ( "]" ) } } ] ) , t . createAnnotation = function ( t ) { switch ( t . type ) { case "link" : this . link ( t . bounds . x , t . bounds . y , t . bounds . w , t . bounds . h , t ) ; break ; case "text" : case "freetext" : this . annotationPlugin . annotations [ this . internal . getCurrentPageInfo ( ) . pageNumber ] . push ( t ) } } , t . link = function ( t , e , n , r , i ) { this . annotationPlugin . annotations [ this . internal . getCurrentPageInfo ( ) . pageNumber ] . push ( { x : t , y : e , w : n , h : r , options : i , type : "link" } ) } , t . link = function ( t , e , n , r , i ) { this . annotationPlugin . annotations [ this . internal . getCurrentPageInfo ( ) . pageNumber ] . push ( { x : t , y : e , w : n , h : r , options : i , type : "link" } ) } , t . textWithLink = function ( t , e , n , r ) { var i = this . getTextWidth ( t ) , o = this . internal . getLineHeight ( ) ; return this . text ( t , e , n ) , n += . 2 * o , this . link ( e , n - o , i , o , r ) , i } , t . getTextWidth = function ( t ) { var e = this . internal . getFontSize ( ) , n = this . getStringUnitWidth ( t ) * e / this . internal . scaleFactor ; return n } , t . getLineHeight = function ( ) { return this . internal . getLineHeight ( ) } , this } ( e . API ) , function ( t ) { t . autoPrint = function ( ) { var t ; return this . internal . events . subscribe ( "postPutResources" , function ( ) { t = this . internal . newObject ( ) , this . internal . write ( "<< /S/Named /Type/Action /N/Print >>" , "endobj" ) } ) , this . internal . events . subscribe ( "putCatalog" , function ( )
* jsPDF Canvas PlugIn
* Copyright ( c ) 2014 Steven Spungin ( TwelveTone LLC ) steven @ twelvetone . tv
*
* Licensed under the MIT License .
* http : //opensource.org/licenses/mit-license
* /
function ( t ) { return t . events . push ( [ "initialized" , function ( ) { this . canvas . pdf = this } ] ) , t . canvas = { getContext : function ( t ) { return this . pdf . context2d . _canvas = this , this . pdf . context2d } , style : { } } , Object . defineProperty ( t . canvas , "width" , { get : function ( ) { return this . _width } , set : function ( t ) { this . _width = t , this . getContext ( "2d" ) . pageWrapX = t + 1 } } ) , Object . defineProperty ( t . canvas , "height" , { get : function ( ) { return this . _height } , set : function ( t ) { this . _height = t , this . getContext ( "2d" ) . pageWrapY = t + 1 } } ) , this } ( e . API ) , / * * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* jsPDF Cell plugin
* Copyright ( c ) 2013 Youssef Beddad , youssef . beddad @ gmail . com
* 2013 Eduardo Menezes de Morais , eduardo . morais @ usp . br
* 2013 Lee Driscoll , https : //github.com/lsdriscoll
* 2014 Juan Pablo Gaviria , https : //github.com/juanpgaviria
* 2014 James Hall , james @ parall . ax
* 2014 Diego Casorran , https : //github.com/diegocr
*
*
* === === === === === === === === === === === === === === === === === === === === === === ==
* /
function ( t ) { var e , n , r , i , o = 3 , a = 13 , s = { x : void 0 , y : void 0 , w : void 0 , h : void 0 , ln : void 0 } , c = 1 , l = function ( t , e , n , r , i ) { s = { x : t , y : e , w : n , h : r , ln : i } } , u = function ( ) { return s } , h = { left : 0 , top : 0 , bottom : 0 } ; t . setHeaderFunction = function ( t ) { i = t } , t . getTextDimensions = function ( t ) { e = this . internal . getFont ( ) . fontName , n = this . table _font _size || this . internal . getFontSize ( ) , r = this . internal . getFont ( ) . fontStyle ; var i , o , a = 19.049976 / 25.4 ; o = document . createElement ( "font" ) , o . id = "jsPDFCell" ; try { o . style . fontStyle = r } catch ( t ) { o . style . fontWeight = r } o . style . fontName = e , o . style . fontSize = n + "pt" ; try { o . textContent = t } catch ( e ) { o . innerText = t } return document . body . appendChild ( o ) , i = { w : ( o . offsetWidth + 1 ) * a , h : ( o . offsetHeight + 1 ) * a } , document . body . removeChild ( o ) , i } , t . cellAddPage = function ( ) { var t = this . margins || h ; this . addPage ( ) , l ( t . left , t . top , void 0 , void 0 ) , c += 1 } , t . cellInitialize = function ( ) { s = { x : void 0 , y : void 0 , w : void 0 , h : void 0 , ln : void 0 } , c = 1 } , t . cell = function ( t , e , n , r , i , s , c ) { var f = u ( ) , d = ! 1 ; if ( void 0 !== f . ln ) if ( f . ln === s ) t = f . x + f . w , e = f . y ; else { var p = this . margins || h ; f . y + f . h + r + a >= this . internal . pageSize . height - p . bottom && ( this . cellAddPage ( ) , d = ! 0 , this . printHeaders && this . tableHeaderRow && this . printHeaderRow ( s , ! 0 ) ) , e = u ( ) . y + u ( ) . h , d && ( e = a + 10 ) } if ( void 0 !== i [ 0 ] ) if ( this . printingHeaderRow ? this . rect ( t , e , n , r , "FD" ) : this . rect ( t , e , n , r ) , "right" === c ) { i instanceof Array || ( i = [ i ] ) ; for ( var g = 0 ; g < i . length ; g ++ ) { var m = i [ g ] , w = this . getStringUnitWidth ( m ) * this . internal . getFontSize ( ) ; this . text ( m , t + n - w - o , e + this . internal . getLineHeight ( ) * ( g + 1 ) ) } } else this . text ( i , t + o , e + this . internal . getLineHeight ( ) ) ; return l ( t , e , n , r , s ) , this } , t . arrayMax = function ( t , e ) { var n , r , i , o = t [ 0 ] ; for ( n = 0 , r = t . length ; n < r ; n += 1 ) i = t [ n ] , e ? e ( o , i ) === - 1 && ( o = i ) : i > o && ( o = i ) ; return o } , t . table = function ( e , n , r , i , o ) { if ( ! r ) throw "No data for PDF table" ; var a , l , u , f , d , p , g , m , w , y , v = [ ] , b = [ ] , x = { } , k = { } , _ = [ ] , C = [ ] , A = ! 1 , S = ! 0 , q = 12 , T = h ; if ( T . width = this . internal . pageSize . width , o && ( o . autoSize === ! 0 && ( A = ! 0 ) , o . printHeaders === ! 1 && ( S = ! 1 ) , o . fontSize && ( q = o . fontSize ) , o . css && "undefined" != typeof o . css [ "font-size" ] && ( q = 16 * o . css [ "font-size" ] ) , o . margins && ( T = o . margins ) ) , this . lnMod = 0 , s = { x : void 0 , y : void 0 , w : void 0 , h : void 0 , ln : void 0 } , c = 1 , this . printHeaders = S , this . margins = T , this . setFontSize ( q ) , this . table _font _size = q , void 0 === i || null === i ) v = Object . keys ( r [ 0 ] ) ; else if ( i [ 0 ] && "string" != typeof i [ 0 ] ) { var P = 19.049976 / 25.4 ; for ( l = 0 , u = i . length ; l < u ; l += 1 ) a = i [ l ] , v . push ( a . name ) , b . push ( a . prompt ) , k [ a . name ] = a . width * P } else v = i ; if ( A ) for ( y = function ( t ) { return t [ a ] } , l = 0 , u = v . length ; l < u ; l += 1 ) { for ( a = v [ l ] , x [ a ] = r . map ( y ) , _ . push ( this . getTextDimensions ( b [ l ] || a ) . w ) , p = x [ a ] , g = 0 , f = p . length ; g < f ; g += 1 ) d = p [ g ] , _ . push ( this . getTextDimensions ( d ) . w ) ; k [ a ] = t . arrayMax ( _ ) , _ = [ ] } if ( S ) { var I = this . calculateLineHeight ( v , k , b . length ? b : v ) ; for ( l = 0 , u = v . length ; l < u ; l += 1 ) a = v [ l ] , C . push ( [ e , n , k [ a ] , I , String ( b . length ? b [ l ] : a ) ] ) ; this . setTableHeaderRow ( C ) , this . printHeaderRow ( 1 , ! 1 ) } for ( l = 0 , u = r . length ; l < u ; l += 1 ) { var I ; for ( m = r [ l ] , I = this . calculateLineHeight ( v , k , m ) , g = 0 , w = v . length ; g < w ; g += 1 ) a = v [ g ] , this . cell ( e , n , k [ a ] , I , m [ a ] , l + 2 , a . align ) } return this . lastCellPos = s , this . table _x = e , this . table _y = n , this } , t . calculateLineHeight = function ( t , e , n ) { for ( var r , i = 0 , a = 0 ; a < t . length ; a ++ ) { r = t [ a ] , n [ r ] = this . splitTextToSize ( String ( n [ r ] ) , e [ r ] - o ) ; var s = this . internal . getLineHeight ( ) * n [ r ] . length + o ; s > i && ( i = s ) } return i } , t . setTableHeaderRow = function ( t ) { this . tableHeaderRow = t } , t . printHeaderRow = function ( t , e ) { if ( ! this . tableHeaderRow ) throw "Property tableHeaderRow does not exist." ; var n , r , o , s ; if ( this . printingHeaderRow = ! 0 , void 0 !== i ) { var u = i ( this , c ) ; l ( u [ 0 ] , u [ 1 ] , u [ 2 ] , u [ 3 ] , - 1 ) } this . setFontStyle ( "bold" ) ; var h = [ ] ; for ( o = 0 , s = this . tableHeaderRow . length ; o < s ; o += 1 ) this . setFillColor ( 200 , 200 , 200 ) , n = this . tableHeaderRow [ o ] , e && ( this . margins . top = a , n [ 1 ] = this . margins && this . margins . top || 0 , h . push ( n ) ) , r = [ ] . concat ( n ) , this . cell . apply ( this , r . concat ( t ) ) ; h . length > 0 && this . setTableHeaderRow ( h ) , this . setFontStyle ( "normal" ) , this . printingHeaderRow = ! 1 } } ( e . API ) , / * *
* jsPDF Context2D PlugIn Copyright ( c ) 2014 Steven Spungin ( TwelveTone LLC ) steven @ twelvetone . tv
*
* Licensed under the MIT License . http : //opensource.org/licenses/mit-license
* /
function ( t ) { function e ( ) { this . _isStrokeTransparent = ! 1 , this . _strokeOpacity = 1 , this . strokeStyle = "#000000" , this . fillStyle = "#000000" , this . _isFillTransparent = ! 1 , this . _fillOpacity = 1 , this . font = "12pt times" , this . textBaseline = "alphabetic" , this . textAlign = "start" , this . lineWidth = 1 , this . lineJoin = "miter" , this . lineCap = "butt" , this . _transform = [ 1 , 0 , 0 , 1 , 0 , 0 ] , this . globalCompositeOperation = "normal" , this . globalAlpha = 1 , this . _clip _path = [ ] , this . ignoreClearRect = ! 1 , this . copy = function ( t ) { this . _isStrokeTransparent = t . _isStrokeTransparent , this . _strokeOpacity = t . _strokeOpacity , this . strokeStyle = t . strokeStyle , this . _isFillTransparent = t . _isFillTransparent , this . _fillOpacity = t . _fillOpacity , this . fillStyle = t . fillStyle , this . font = t . font , this . lineWidth = t . lineWidth , this . lineJoin = t . lineJoin , this . lineCap = t . lineCap , this . textBaseline = t . textBaseline , this . textAlign = t . textAlign , this . _fontSize = t . _fontSize , this . _transform = t . _transform . slice ( 0 ) , this . globalCompositeOperation = t . globalCompositeOperation , this . globalAlpha = t . globalAlpha , this . _clip _path = t . _clip _path . slice ( 0 ) , this . ignoreClearRect = t . ignoreClearRect } } t . events . push ( [ "initialized" , function ( ) { this . context2d . pdf = this , this . context2d . internal . pdf = this , this . context2d . ctx = new e , this . context2d . ctxStack = [ ] , this . context2d . path = [ ] } ] ) , t . context2d = { pageWrapXEnabled : ! 1 , pageWrapYEnabled : ! 1 , pageWrapX : 9999999 , pageWrapY : 9999999 , ctx : new e , f2 : function ( t ) { return t . toFixed ( 2 ) } , fillRect : function ( t , e , n , r ) { if ( ! this . _isFillTransparent ( ) ) { t = this . _wrapX ( t ) , e = this . _wrapY ( e ) ; var i = this . _matrix _map _rect ( this . ctx . _transform , { x : t , y : e , w : n , h : r } ) ; this . pdf . rect ( i . x , i . y , i . w , i . h , "f" ) } } , strokeRect : function ( t , e , n , r ) { if ( ! this . _isStrokeTransparent ( ) ) { t = this . _wrapX ( t ) , e = this . _wrapY ( e ) ; var i = this . _matrix _map _rect ( this . ctx . _transform , { x : t , y : e , w : n , h : r } ) ; this . pdf . rect ( i . x , i . y , i . w , i . h , "s" ) } } , clearRect : function ( t , e , n , r ) { if ( ! this . ctx . ignoreClearRect ) { t = this . _wrapX ( t ) , e = this . _wrapY ( e ) ; var i = this . _matrix _map _rect ( this . ctx . _transform , { x : t , y : e , w : n , h : r } ) ; this . save ( ) , this . setFillStyle ( "#ffffff" ) , this . pdf . rect ( i . x , i . y , i . w , i . h , "f" ) , this . restore ( ) } } , save : function ( ) { this . ctx . _fontSize = this . pdf . internal . getFontSize ( ) ; var t = new e ; t . copy ( this . ctx ) , this . ctxStack . push ( this . ctx ) , this . ctx = t } , restore : function ( ) { this . ctx = this . ctxStack . pop ( ) , this . setFillStyle ( this . ctx . fillStyle ) , this . setStrokeStyle ( this . ctx . strokeStyle ) , this . setFont ( this . ctx . font ) , this . pdf . setFontSize ( this . ctx . _fontSize ) , this . setLineCap ( this . ctx . lineCap ) , this . setLineWidth ( this . ctx . lineWidth ) , this . setLineJoin ( this . ctx . lineJoin ) } , rect : function ( t , e , n , r ) { this . moveTo ( t , e ) , this . lineTo ( t + n , e ) , this . lineTo ( t + n , e + r ) , this . lineTo ( t , e + r ) , this . lineTo ( t , e ) , this . closePath ( ) } , beginPath : function ( ) { this . path = [ ] } , closePath : function ( ) { this . path . push ( { type : "close" } ) } , _getRgba : function ( t ) { var e = { } ; if ( this . internal . rxTransparent . test ( t ) ) e . r = 0 , e . g = 0 , e . b = 0 , e . a = 0 ; else { var n = this . internal . rxRgb . exec ( t ) ; null != n ? ( e . r = parseInt ( n [ 1 ] ) , e . g = parseInt ( n [ 2 ] ) , e . b = parseInt ( n [ 3 ] ) , e . a = 1 ) : ( n = this . internal . rxRgba . exec ( t ) , null != n ? ( e . r = parseInt ( n [ 1 ] ) , e . g = parseInt ( n [ 2 ] ) , e . b = parseInt ( n [ 3 ] ) , e . a = parseFloat ( n [ 4 ] ) ) : ( e . a = 1 , "#" != t . charAt ( 0 ) && ( t = o . colorNameToHex ( t ) , t || ( t = "#000000" ) ) , 4 === t . length ? ( e . r = t . substring ( 1 , 2 ) , e . r += r , e . g = t . substring ( 2 , 3 ) , e . g += g , e . b = t . substring ( 3 , 4 ) , e . b += b ) : ( e . r = t . substring ( 1 , 3 ) , e . g = t . substring ( 3 , 5 ) , e . b = t . substring ( 5 , 7 ) ) , e . r = parseInt ( e . r , 16 ) , e . g = parseInt ( e . g , 16 ) , e . b = parseInt ( e . b , 16 ) ) ) } return e . style = t , e } , setFillStyle : function ( t ) { var e , n , r , i ; if ( this . internal . rxTransparent . test ( t ) ) e = 0 , n = 0 , r = 0 , i = 0 ; else { var a = this . internal . rxRgb . exec ( t ) ; null != a ? ( e = parseInt ( a [ 1 ] ) , n = parseInt ( a [ 2 ] ) , r = parseInt ( a [ 3 ] ) , i = 1 ) : ( a = this . internal . rxRgba . exec ( t ) , null != a ? ( e = parseInt ( a [ 1 ] ) , n = parseInt ( a [ 2 ] ) , r = parseInt ( a [ 3 ] ) , i = parseFloat ( a [ 4 ] ) ) : ( i = 1 , "#" != t . charAt ( 0 ) && ( t = o . colorNameToHex ( t ) , t || ( t = "#000000" ) ) , 4 === t . length ? ( e = t . substring ( 1 , 2 ) , e += e , n = t . substring ( 2 , 3 ) , n += n , r = t . substring ( 3 , 4 ) , r += r ) : ( e = t . substring ( 1 , 3 ) , n = t . substring ( 3 , 5 ) , r = t . substring ( 5 , 7 ) ) , e = parseInt ( e , 16 ) , n = parseInt ( n , 16 ) , r = parseInt ( r , 16 ) ) ) } this . ctx . fillStyle = t , this . ctx . _isFillTransparent = 0 == i , this . ctx . _fillOpacity = i , this . pdf . setFillColor ( e , n , r , { a : i } ) , this . pdf . setTextColor ( e , n , r , { a : i } ) } , setStrokeStyle : function ( t ) { var e = this . _getR
* jsPDF fromHTML plugin . BETA stage . API subject to change . Needs browser
* Copyright ( c ) 2012 Willow Systems Corporation , willow - systems . com
* 2014 Juan Pablo Gaviria , https : //github.com/juanpgaviria
* 2014 Diego Casorran , https : //github.com/diegocr
* 2014 Daniel Husar , https : //github.com/danielhusar
* 2014 Wolfgang Gassler , https : //github.com/woolfg
* 2014 Steven Spungin , https : //github.com/flamenco
*
*
* === === === === === === === === === === === === === === === === === === === === === === ==
* /
function ( e ) { var n , r , i , a , s , c , l , u , h , f , d , p , g , m , w , y , v , b , x , k ; n = function ( ) { function t ( ) { } return function ( e ) { return t . prototype = e , new t } } ( ) , f = function ( t ) { var e , n , r , i , o , a , s ; for ( n = 0 , r = t . length , e = void 0 , i = ! 1 , a = ! 1 ; ! i && n !== r ; ) e = t [ n ] = t [ n ] . trimLeft ( ) , e && ( i = ! 0 ) , n ++ ; for ( n = r - 1 ; r && ! a && n !== - 1 ; ) e = t [ n ] = t [ n ] . trimRight ( ) , e && ( a = ! 0 ) , n -- ; for ( o = /\s+$/g , s = ! 0 , n = 0 ; n !== r ; ) "\u2028" != t [ n ] && ( e = t [ n ] . replace ( /\s+/g , " " ) , s && ( e = e . trimLeft ( ) ) , e && ( s = o . test ( e ) ) , t [ n ] = e ) , n ++ ; return t } , d = function ( t , e , n , r ) { return this . pdf = t , this . x = e , this . y = n , this . settings = r , this . watchFunctions = [ ] , this . init ( ) , this } , p = function ( t ) { var e , n , r ; for ( e = void 0 , r = t . split ( "," ) , n = r . shift ( ) ; ! e && n ; ) e = i [ n . trim ( ) . toLowerCase ( ) ] , n = r . shift ( ) ; return e } , g = function ( t ) { t = "auto" === t ? "0px" : t , t . indexOf ( "em" ) > - 1 && ! isNaN ( Number ( t . replace ( "em" , "" ) ) ) && ( t = 18.719 * Number ( t . replace ( "em" , "" ) ) + "px" ) , t . indexOf ( "pt" ) > - 1 && ! isNaN ( Number ( t . replace ( "pt" , "" ) ) ) && ( t = 1.333 * Number ( t . replace ( "pt" , "" ) ) + "px" ) ; var e , n , r ; return n = void 0 , e = 16 , ( r = m [ t ] ) ? r : ( r = { "xx-small" : 9 , "x-small" : 11 , small : 13 , medium : 16 , large : 19 , "x-large" : 23 , "xx-large" : 28 , auto : 0 } [ { css _line _height _string : t } ] , r !== n ? m [ t ] = r / e : ( r = parseFloat ( t ) ) ? m [ t ] = r / e : ( r = t . match ( /([\d\.]+)(px)/ ) , 3 === r . length ? m [ t ] = parseFloat ( r [ 1 ] ) / e : m [ t ] = 1 ) ) } , h = function ( t ) { var e , n , r ; return r = function ( t ) { var e ; return e = function ( t ) { return document . defaultView && document . defaultView . getComputedStyle ? document . defaultView . getComputedStyle ( t , null ) : t . currentStyle ? t . currentStyle : t . style } ( t ) , function ( t ) { return t = t . replace ( /-\D/g , function ( t ) { return t . charAt ( 1 ) . toUpperCase ( ) } ) , e [ t ] } } ( t ) , e = { } , n = void 0 , e [ "font-family" ] = p ( r ( "font-family" ) ) || "times" , e [ "font-style" ] = a [ r ( "font-style" ) ] || "normal" , e [ "text-align" ] = s [ r ( "text-align" ) ] || "left" , n = c [ r ( "font-weight" ) ] || "normal" , "bold" === n && ( "normal" === e [ "font-style" ] ? e [ "font-style" ] = n : e [ "font-style" ] = n + e [ "font-style" ] ) , e [ "font-size" ] = g ( r ( "font-size" ) ) || 1 , e [ "line-height" ] = g ( r ( "line-height" ) ) || 1 , e . display = "inline" === r ( "display" ) ? "inline" : "block" , n = "block" === e . display , e [ "margin-top" ] = n && g ( r ( "margin-top" ) ) || 0 , e [ "margin-bottom" ] = n && g ( r ( "margin-bottom" ) ) || 0 , e [ "padding-top" ] = n && g ( r ( "padding-top" ) ) || 0 , e [ "padding-bottom" ] = n && g ( r ( "padding-bottom" ) ) || 0 , e [ "margin-left" ] = n && g ( r ( "margin-left" ) ) || 0 , e [ "margin-right" ] = n && g ( r ( "margin-right" ) ) || 0 , e [ "padding-left" ] = n && g ( r ( "padding-left" ) ) || 0 , e [ "padding-right" ] = n && g ( r ( "padding-right" ) ) || 0 , e [ "page-break-before" ] = r ( "page-break-before" ) || "auto" , e . float = l [ r ( "cssFloat" ) ] || "none" , e . clear = u [ r ( "clear" ) ] || "none" , e . color = r ( "color" ) , e } , w = function ( t , e , n ) { var r , i , o , a , s ; if ( o = ! 1 , i = void 0 , a = void 0 , s = void 0 , r = n [ "#" + t . id ] ) if ( "function" == typeof r ) o = r ( t , e ) ; else for ( i = 0 , a = r . length ; ! o && i !== a ; ) o = r [ i ] ( t , e ) , i ++ ; if ( r = n [ t . nodeName ] , ! o && r ) if ( "function" == typeof r ) o = r ( t , e ) ; else for ( i = 0 , a = r . length ; ! o && i !== a ; ) o = r [ i ] ( t , e ) , i ++ ; return o } , k = function ( t , e ) { var n , r , i , o , a , s , c , l , u , h ; for ( n = [ ] , r = [ ] , i = 0 , h = t . rows [ 0 ] . cells . length , l = t . clientWidth ; i < h ; ) u = t . rows [ 0 ] . cells [ i ] , r [ i ] = { name : u . textContent . toLowerCase ( ) . replace ( /\s+/g , "" ) , prompt : u . textContent . replace ( /\r?\n/g , "" ) , width : u . clientWidth / l * e . pdf . internal . pageSize . width } , i ++ ; for ( i = 1 ; i < t . rows . length ; ) { for ( s = t . rows [ i ] , a = { } , o = 0 ; o < s . cells . length ; ) a [ r [ o ] . name ] = s . cells [ o ] . textContent . replace ( /\r?\n/g , "" ) , o ++ ; n . push ( a ) , i ++ } return c = { rows : n , headers : r } } ; var _ = { SCRIPT : 1 , STYLE : 1 , NOSCRIPT : 1 , OBJECT : 1 , EMBED : 1 , SELECT : 1 } , C = 1 ; r = function ( e , i , o ) { var a , s , c , l , u , f , d , p , g ; for ( s = e . childNodes , a = void 0 , c = h ( e ) , u = "block" === c . display , u && ( i . setBlockBoundary ( ) , i . setBlockStyle ( c ) ) , d = 19.049976 / 25.4 , l = 0 , f = s . length ; l < f ; ) { if ( a = s [ l ] , "object" === ( "undefined" == typeof a ? "undefined" : t ( a ) ) ) { if ( i . executeWatchFunctions ( a ) , 1 === a . nodeType && "HEADER" === a . nodeName ) { var m = a , v = i . pdf . margins _doc . top ; i . pdf . internal . events . subscribe ( "addPage" , function ( t ) { i . y = v , r ( m , i , o ) , i . pdf . margins _doc . top = i . y + 10 , i . y += 10 } , ! 1 ) } if ( 8 === a . nodeType && "#comment" === a . nodeName ) ~ a . textContent . indexOf ( "ADD_PAGE" ) && ( i . pdf . addPage ( ) , i . y = i . pdf . margins _doc . top ) ; else if ( 1 !== a . nodeType || _ [ a . nodeName ] ) if ( 3 === a . nodeType ) { var b = a . nodeValue ; if ( a . nodeValue && "LI" === a . parentNode . nodeName ) if ( "OL" === a . parentNode . parentNode . nodeName ) b = C ++ + ". " + b ; else { var x = c [ "font-size" ] , A = ( 3 - . 75 * x ) * i . pdf . internal . scaleFactor , S = . 75 * x * i . pdf . internal . scaleFactor
* jsPDF JavaScript plugin
* Copyright ( c ) 2013 Youssef Beddad , youssef . beddad @ gmail . com
*
*
* === === === === === === === === === === === === === === === === === === === === === === ==
* /
function ( t ) { var e , n , r ; t . addJS = function ( t ) { return r = t , this . internal . events . subscribe ( "postPutResources" , function ( t ) { e = this . internal . newObject ( ) , this . internal . write ( "<< /Names [(EmbeddedJS) " + ( e + 1 ) + " 0 R] >>" , "endobj" ) , n = this . internal . newObject ( ) , this . internal . write ( "<< /S /JavaScript /JS (" , r , ") >>" , "endobj" ) } ) , this . internal . events . subscribe ( "putCatalog" , function ( ) { void 0 !== e && void 0 !== n && this . internal . write ( "/Names <</JavaScript " + e + " 0 R>>" ) } ) , this } } ( e . API ) , / * *
* jsPDF Outline PlugIn
* Copyright ( c ) 2014 Steven Spungin ( TwelveTone LLC ) steven @ twelvetone . tv
*
* Licensed under the MIT License .
* http : //opensource.org/licenses/mit-license
* /
function ( t ) { return t . events . push ( [ "postPutResources" , function ( ) { var t = this , e = /^(\d+) 0 obj$/ ; if ( this . outline . root . children . length > 0 ) for ( var n = t . outline . render ( ) . split ( /\r\n/ ) , r = 0 ; r < n . length ; r ++ ) { var i = n [ r ] , o = e . exec ( i ) ; if ( null != o ) { var a = o [ 1 ] ; t . internal . newObjectDeferredBegin ( a ) } t . internal . write ( i ) } if ( this . outline . createNamedDestinations ) { for ( var s = this . internal . pages . length , c = [ ] , r = 0 ; r < s ; r ++ ) { var l = t . internal . newObject ( ) ; c . push ( l ) ; var u = t . internal . getPageInfo ( r + 1 ) ; t . internal . write ( "<< /D[" + u . objId + " 0 R /XYZ null null null]>> endobj" ) } var h = t . internal . newObject ( ) ; t . internal . write ( "<< /Names [ " ) ; for ( var r = 0 ; r < c . length ; r ++ ) t . internal . write ( "(page_" + ( r + 1 ) + ")" + c [ r ] + " 0 R" ) ; t . internal . write ( " ] >>" , "endobj" ) ; t . internal . newObject ( ) ; t . internal . write ( "<< /Dests " + h + " 0 R" ) , t . internal . write ( ">>" , "endobj" ) } } ] ) , t . events . push ( [ "putCatalog" , function ( ) { var t = this ; t . outline . root . children . length > 0 && ( t . internal . write ( "/Outlines" , this . outline . makeRef ( this . outline . root ) ) , this . outline . createNamedDestinations && t . internal . write ( "/Names " + namesOid + " 0 R" ) ) } ] ) , t . events . push ( [ "initialized" , function ( ) { var t = this ; t . outline = { createNamedDestinations : ! 1 , root : { children : [ ] } } ; t . outline . add = function ( t , e , n ) { var r = { title : e , options : n , children : [ ] } ; return null == t && ( t = this . root ) , t . children . push ( r ) , r } , t . outline . render = function ( ) { return this . ctx = { } , this . ctx . val = "" , this . ctx . pdf = t , this . genIds _r ( this . root ) , this . renderRoot ( this . root ) , this . renderItems ( this . root ) , this . ctx . val } , t . outline . genIds _r = function ( e ) { e . id = t . internal . newObjectDeferred ( ) ; for ( var n = 0 ; n < e . children . length ; n ++ ) this . genIds _r ( e . children [ n ] ) } , t . outline . renderRoot = function ( t ) { this . objStart ( t ) , this . line ( "/Type /Outlines" ) , t . children . length > 0 && ( this . line ( "/First " + this . makeRef ( t . children [ 0 ] ) ) , this . line ( "/Last " + this . makeRef ( t . children [ t . children . length - 1 ] ) ) ) , this . line ( "/Count " + this . count _r ( { count : 0 } , t ) ) , this . objEnd ( ) } , t . outline . renderItems = function ( e ) { for ( var n = 0 ; n < e . children . length ; n ++ ) { var r = e . children [ n ] ; this . objStart ( r ) , this . line ( "/Title " + this . makeString ( r . title ) ) , this . line ( "/Parent " + this . makeRef ( e ) ) , n > 0 && this . line ( "/Prev " + this . makeRef ( e . children [ n - 1 ] ) ) , n < e . children . length - 1 && this . line ( "/Next " + this . makeRef ( e . children [ n + 1 ] ) ) , r . children . length > 0 && ( this . line ( "/First " + this . makeRef ( r . children [ 0 ] ) ) , this . line ( "/Last " + this . makeRef ( r . children [ r . children . length - 1 ] ) ) ) ; var i = this . count = this . count _r ( { count : 0 } , r ) ; if ( i > 0 && this . line ( "/Count " + i ) , r . options && r . options . pageNumber ) { var o = t . internal . getPageInfo ( r . options . pageNumber ) ; this . line ( "/Dest [" + o . objId + " 0 R /XYZ 0 " + this . ctx . pdf . internal . pageSize . height + " 0]" ) } this . objEnd ( ) } for ( var n = 0 ; n < e . children . length ; n ++ ) { var r = e . children [ n ] ; this . renderItems ( r ) } } , t . outline . line = function ( t ) { this . ctx . val += t + "\r\n" } , t . outline . makeRef = function ( t ) { return t . id + " 0 R" } , t . outline . makeString = function ( e ) { return "(" + t . internal . pdfEscape ( e ) + ")" } , t . outline . objStart = function ( t ) { this . ctx . val += "\r\n" + t . id + " 0 obj\r\n<<\r\n" } , t . outline . objEnd = function ( t ) { this . ctx . val += ">> \r\nendobj\r\n" } , t . outline . count _r = function ( t , e ) { for ( var n = 0 ; n < e . children . length ; n ++ ) t . count ++ , this . count _r ( t , e . children [ n ] ) ; return t . count } } ] ) , this } ( e . API ) , / * * @ p r e s e r v e
* === === === === === === === === === === === === === === === === === === === === === === ==
* jsPDF PNG PlugIn
* Copyright ( c ) 2014 James Robb , https : //github.com/jamesbrobb
*
*
* === === === === === === === === === === === === === === === === === === === === === === ==
* /
function ( t ) { var e = function ( ) { return "function" != typeof PNG || "function" != typeof c } , n = function ( e ) { return e !== t . image _compression . NONE && r ( ) } , r = function ( ) { var t = "function" == typeof a ; if ( ! t ) throw new Error ( "requires deflate.js for compression" ) ; return t } , i = function ( e , n , r , i ) { var c = 5 , u = f ; switch ( i ) { case t . image _compression . FAST : c = 3 , u = h ; break ; case t . image _compression . MEDIUM : c = 6 , u = d ; break ; case t . image _compression . SLOW : c = 9 , u = p } e = l ( e , n , r , u ) ; var g = new Uint8Array ( o ( c ) ) , m = s ( e ) , w = new a ( c ) , y = w . append ( e ) , v = w . flush ( ) , b = g . length + y . length + v . length , x = new Uint8Array ( b + 4 ) ; return x . set ( g ) , x . set ( y , g . length ) , x . set ( v , g . length + y . length ) , x [ b ++ ] = m >>> 24 & 255 , x [ b ++ ] = m >>> 16 & 255 , x [ b ++ ] = m >>> 8 & 255 , x [ b ++ ] = 255 & m , t . arrayBufferToBinaryString ( x ) } , o = function ( t , e ) { var n = 8 , r = Math . LOG2E * Math . log ( 32768 ) - 8 , i = r << 4 | n , o = i << 8 , a = Math . min ( 3 , ( e - 1 & 255 ) >> 1 ) ; return o |= a << 6 , o |= 0 , o += 31 - o % 31 , [ i , 255 & o & 255 ] } , s = function ( t , e ) { for ( var n , r = 1 , i = 65535 & r , o = r >>> 16 & 65535 , a = t . length , s = 0 ; a > 0 ; ) { n = a > e ? e : a , a -= n ; do i += t [ s ++ ] , o += i ; while ( -- n ) ; i %= 65521 , o %= 65521 } return ( o << 16 | i ) >>> 0 } , l = function ( t , e , n , r ) { for ( var i , o , a , s = t . length / e , c = new Uint8Array ( t . length + s ) , l = m ( ) , u = 0 ; u < s ; u ++ ) { if ( a = u * e , i = t . subarray ( a , a + e ) , r ) c . set ( r ( i , n , o ) , a + u ) ; else { for ( var h = 0 , f = l . length , d = [ ] ; h < f ; h ++ ) d [ h ] = l [ h ] ( i , n , o ) ; var p = w ( d . concat ( ) ) ; c . set ( d [ p ] , a + u ) } o = i } return c } , u = function ( t , e , n ) { var r = Array . apply ( [ ] , t ) ; return r . unshift ( 0 ) , r } , h = function ( t , e , n ) { var r , i = [ ] , o = 0 , a = t . length ; for ( i [ 0 ] = 1 ; o < a ; o ++ ) r = t [ o - e ] || 0 , i [ o + 1 ] = t [ o ] - r + 256 & 255 ; return i } , f = function ( t , e , n ) { var r , i = [ ] , o = 0 , a = t . length ; for ( i [ 0 ] = 2 ; o < a ; o ++ ) r = n && n [ o ] || 0 , i [ o + 1 ] = t [ o ] - r + 256 & 255 ; return i } , d = function ( t , e , n ) { var r , i , o = [ ] , a = 0 , s = t . length ; for ( o [ 0 ] = 3 ; a < s ; a ++ ) r = t [ a - e ] || 0 , i = n && n [ a ] || 0 , o [ a + 1 ] = t [ a ] + 256 - ( r + i >>> 1 ) & 255 ; return o } , p = function ( t , e , n ) { var r , i , o , a , s = [ ] , c = 0 , l = t . length ; for ( s [ 0 ] = 4 ; c < l ; c ++ ) r = t [ c - e ] || 0 , i = n && n [ c ] || 0 , o = n && n [ c - e ] || 0 , a = g ( r , i , o ) , s [ c + 1 ] = t [ c ] - a + 256 & 255 ; return s } , g = function ( t , e , n ) { var r = t + e - n , i = Math . abs ( r - t ) , o = Math . abs ( r - e ) , a = Math . abs ( r - n ) ; return i <= o && i <= a ? t : o <= a ? e : n } , m = function ( ) { return [ u , h , f , d , p ] } , w = function ( t ) { for ( var e , n , r , i = 0 , o = t . length ; i < o ; ) e = y ( t [ i ] . slice ( 1 ) ) , ( e < n || ! n ) && ( n = e , r = i ) , i ++ ; return r } , y = function ( t ) { for ( var e = 0 , n = t . length , r = 0 ; e < n ; ) r += Math . abs ( t [ e ++ ] ) ; return r } , v = function ( e ) { var n ; switch ( e ) { case t . image _compression . FAST : n = 11 ; break ; case t . image _compression . MEDIUM : n = 13 ; break ; case t . image _compression . SLOW : n = 14 ; break ; default : n = 12 } return n } ; t . processPNG = function ( t , r , o , a , s ) { var c , l , u , h , f , d , p = this . color _spaces . DEVICE _RGB , g = this . decode . FLATE _DECODE , m = 8 ; if ( this . isArrayBuffer ( t ) && ( t = new Uint8Array ( t ) ) , this . isArrayBufferView ( t ) ) { if ( e ( ) ) throw new Error ( "PNG support requires png.js and zlib.js" ) ; if ( c = new PNG ( t ) , t = c . imgData , m = c . bits , p = c . colorSpace , h = c . colors , [ 4 , 6 ] . indexOf ( c . colorType ) !== - 1 ) { if ( 8 === c . bits ) for ( var w , y , b = 32 == c . pixelBitlength ? new Uint32Array ( c . decodePixels ( ) . buffer ) : 16 == c . pixelBitlength ? new Uint16Array ( c . decodePixels ( ) . buffer ) : new Uint8Array ( c . decodePixels ( ) . buffer ) , x = b . length , k = new Uint8Array ( x * c . colors ) , _ = new Uint8Array ( x ) , C = c . pixelBitlength - c . bits , A = 0 , S = 0 ; A < x ; A ++ ) { for ( w = b [ A ] , y = 0 ; y < C ; ) k [ S ++ ] = w >>> y & 255 , y += c . bits ; _ [ A ] = w >>> y & 255 } if ( 16 === c . bits ) { for ( var w , b = new Uint32Array ( c . decodePixels ( ) . buffer ) , x = b . length , k = new Uint8Array ( x * ( 32 / c . pixelBitlength ) * c . colors ) , _ = new Uint8Array ( x * ( 32 / c . pixelBitlength ) ) , q = c . colors > 1 , A = 0 , S = 0 , T = 0 ; A < x ; ) w = b [ A ++ ] , k [ S ++ ] = w >>> 0 & 255 , q && ( k [ S ++ ] = w >>> 16 & 255 , w = b [ A ++ ] , k [ S ++ ] = w >>> 0 & 255 ) , _ [ T ++ ] = w >>> 16 & 255 ; m = 8 } n ( a ) ? ( t = i ( k , c . width * c . colors , c . colors , a ) , d = i ( _ , c . width , 1 , a ) ) : ( t = k , d = _ , g = null ) } if ( 3 === c . colorType && ( p = this . color _spaces . INDEXED , f = c . palette , c . transparency . indexed ) ) { for ( var P = c . transparency . indexed , I = 0 , A = 0 , x = P . length ; A < x ; ++ A ) I += P [ A ] ; if ( I /= 255 , I === x - 1 && P . indexOf ( 0 ) !== - 1 ) u = [ P . indexOf ( 0 ) ] ; else if ( I !== x ) { for ( var b = c . decodePixels ( ) , _ = new Uint8Array ( b . length ) , A = 0 , x = b . length ; A < x ; A ++ ) _ [ A ] = P [ b [ A ] ] ; d = i ( _ , c . width , 1 ) } } var E = v ( a ) ; return l = g === this . decode . FLATE _DECODE ? "/Predictor " + E + " /Colors " + h + " /BitsPerComponent " + m + " /Columns " + c . width : "/Colors " + h + " /BitsPerComponent " + m + " /Columns " + c . width , ( this . isArrayBuffer ( t ) || this . isArrayBufferView ( t ) ) && ( t = this . arrayBufferToBinaryString ( t ) ) , ( d && this . isArrayBuffer ( d ) || this . isArrayBufferView ( d ) ) && ( d = this . arrayBufferToBinary
* jsPDF split _text _to _size plugin - MIT license .
* Copyright ( c ) 2012 Willow Systems Corporation , willow - systems . com
* 2014 Diego Casorran , https : //github.com/diegocr
* /
function ( t ) { var e = t . getCharWidthsArray = function ( t , e ) { e || ( e = { } ) ; var n , r , i , o = e . widths ? e . widths : this . internal . getFont ( ) . metadata . Unicode . widths , a = o . fof ? o . fof : 1 , s = e . kerning ? e . kerning : this . internal . getFont ( ) . metadata . Unicode . kerning , c = s . fof ? s . fof : 1 , l = 0 , u = o [ 0 ] || a , h = [ ] ; for ( n = 0 , r = t . length ; n < r ; n ++ ) i = t . charCodeAt ( n ) , h . push ( ( o [ i ] || u ) / a + ( s [ i ] && s [ i ] [ l ] || 0 ) / c ) , l = i ; return h } , n = function ( t ) { for ( var e = t . length , n = 0 ; e ; ) e -- , n += t [ e ] ; return n } , r = t . getStringUnitWidth = function ( t , r ) { return n ( e . call ( this , t , r ) ) } , i = function ( t , e , n , r ) { for ( var i = [ ] , o = 0 , a = t . length , s = 0 ; o !== a && s + e [ o ] < n ; ) s += e [ o ] , o ++ ; i . push ( t . slice ( 0 , o ) ) ; var c = o ; for ( s = 0 ; o !== a ; ) s + e [ o ] > r && ( i . push ( t . slice ( c , o ) ) , s = 0 , c = o ) , s += e [ o ] , o ++ ; return c !== o && i . push ( t . slice ( c , o ) ) , i } , o = function ( t , o , a ) { a || ( a = { } ) ; var s , c , l , u , h , f , d = [ ] , p = [ d ] , g = a . textIndent || 0 , m = 0 , w = 0 , y = t . split ( " " ) , v = e ( " " , a ) [ 0 ] ; if ( f = a . lineIndent === - 1 ? y [ 0 ] . length + 2 : a . lineIndent || 0 ) { var b = Array ( f ) . join ( " " ) , x = [ ] ; y . map ( function ( t ) { t = t . split ( /\s*\n/ ) , t . length > 1 ? x = x . concat ( t . map ( function ( t , e ) { return ( e && t . length ? "\n" : "" ) + t } ) ) : x . push ( t [ 0 ] ) } ) , y = x , f = r ( b , a ) } for ( l = 0 , u = y . length ; l < u ; l ++ ) { var k = 0 ; if ( s = y [ l ] , f && "\n" == s [ 0 ] && ( s = s . substr ( 1 ) , k = 1 ) , c = e ( s , a ) , w = n ( c ) , g + m + w > o || k ) { if ( w > o ) { for ( h = i ( s , c , o - ( g + m ) , o ) , d . push ( h . shift ( ) ) , d = [ h . pop ( ) ] ; h . length ; ) p . push ( [ h . shift ( ) ] ) ; w = n ( c . slice ( s . length - d [ 0 ] . length ) ) } else d = [ s ] ; p . push ( d ) , g = w + f , m = v } else d . push ( s ) , g += m + w , m = v } if ( f ) var _ = function ( t , e ) { return ( e ? b : "" ) + t . join ( " " ) } ; else var _ = function ( t ) { return t . join ( " " ) } ; return p . map ( _ ) } ; t . splitTextToSize = function ( t , e , n ) { n || ( n = { } ) ; var r , i = n . fontSize || this . internal . getFontSize ( ) , a = function ( t ) { var e = { 0 : 1 } , n = { } ; if ( t . widths && t . kerning ) return { widths : t . widths , kerning : t . kerning } ; var r = this . internal . getFont ( t . fontName , t . fontStyle ) , i = "Unicode" ; return r . metadata [ i ] ? { widths : r . metadata [ i ] . widths || e , kerning : r . metadata [ i ] . kerning || n } : { widths : e , kerning : n } } . call ( this , n ) ; r = Array . isArray ( t ) ? t : t . split ( /\r?\n/ ) ; var s = 1 * this . internal . scaleFactor * e / i ; a . textIndent = n . textIndent ? 1 * n . textIndent * this . internal . scaleFactor / i : 0 , a . lineIndent = n . lineIndent ; var c , l , u = [ ] ; for ( c = 0 , l = r . length ; c < l ; c ++ ) u = u . concat ( o ( r [ c ] , s , a ) ) ; return u } } ( e . API ) , / * * @ p r e s e r v e
jsPDF standard _fonts _metrics plugin
Copyright ( c ) 2012 Willow Systems Corporation , willow - systems . com
MIT license .
* /
function ( t ) { var e = function ( t ) { for ( var e = "0123456789abcdef" , n = "klmnopqrstuvwxyz" , r = { } , i = 0 ; i < n . length ; i ++ ) r [ n [ i ] ] = e [ i ] ; var o , a , s , c , l , u = { } , h = 1 , f = u , d = [ ] , p = "" , g = "" , m = t . length - 1 ; for ( i = 1 ; i != m ; ) l = t [ i ] , i += 1 , "'" == l ? a ? ( c = a . join ( "" ) , a = o ) : a = [ ] : a ? a . push ( l ) : "{" == l ? ( d . push ( [ f , c ] ) , f = { } , c = o ) : "}" == l ? ( s = d . pop ( ) , s [ 0 ] [ s [ 1 ] ] = f , c = o , f = s [ 0 ] ) : "-" == l ? h = - 1 : c === o ? r . hasOwnProperty ( l ) ? ( p += r [ l ] , c = parseInt ( p , 16 ) * h , h = 1 , p = "" ) : p += l : r . hasOwnProperty ( l ) ? ( g += r [ l ] , f [ c ] = parseInt ( g , 16 ) * h , h = 1 , c = o , g = "" ) : g += l ; return u } , n = { codePages : [ "WinAnsiEncoding" ] , WinAnsiEncoding : e ( "{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}" ) } , r = { Unicode : { Courier : n , "Courier-Bold" : n , "Courier-BoldOblique" : n , "Courier-Oblique" : n , Helvetica : n , "Helvetica-Bold" : n , "Helvetica-BoldOblique" : n , "Helvetica-Oblique" : n , "Times-Roman" : n , "Times-Bold" : n , "Times-BoldItalic" : n , "Times-Italic" : n } } , i = { Unicode : { "Courier-Oblique" : e ( "{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}" ) , "Times-BoldItalic" : e ( "{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}" ) , "Helvetica-Bold" : e ( " { 'widths' { k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u 'fof' 6 obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r } 'kerning' { cl { 4 qs5ku5ot5qs17sv5tv } 201 t { 2 ww4wy2yw } 201 w { 2 ks } 201 x { 2 ww4wy2yw } 2 k { 201 ts201xs } 2 w { 7 qs4qu5kw5os5qw5rs17su5tu7tsfzs } 2 x { 5 ow5qs } 2 y { 7 qs4qu5kw5os5qw5rs17su5tu7tsfzs } 'fof' - 6 o7p { 17 su5tu5ot } ck { 4 qs5ku5ot5qs17sv5tv } 4 l { 4 qs5ku5ot5qs17sv5tv } cm { 4 qs5ku5ot5qs17sv5tv } cn { 4 qs5ku5ot5qs17sv5tv } co { 4 qs5ku5ot5qs17sv5tv } cp { 4 qs5ku5ot5qs17sv5tv } 6 l { 17 st5tt5os } 17 s { 2 kwclvcmvcnvcovcpv4lv4wwckv } 5 o { 2 kucltcmtcntcotcpt4lt4wtckt } 5 q { 2 k
jsPDF SVG plugin
Copyright ( c ) 2012 Willow Systems Corporation , willow - systems . com
* /
function ( t ) { t . addSVG = function ( t , e , n , r , i ) { function o ( t , e ) { var n = e . createElement ( "style" ) ; n . type = "text/css" , n . styleSheet ? n . styleSheet . cssText = t : n . appendChild ( e . createTextNode ( t ) ) , e . getElementsByTagName ( "head" ) [ 0 ] . appendChild ( n ) } function a ( t ) { var e = "childframe" , n = t . createElement ( "iframe" ) ; return o ( ".jsPDF_sillysvg_iframe {display:none;position:absolute;}" , t ) , n . name = e , n . setAttribute ( "width" , 0 ) , n . setAttribute ( "height" , 0 ) , n . setAttribute ( "frameborder" , "0" ) , n . setAttribute ( "scrolling" , "no" ) , n . setAttribute ( "seamless" , "seamless" ) , n . setAttribute ( "class" , "jsPDF_sillysvg_iframe" ) , t . body . appendChild ( n ) , n } function s ( t , e ) { var n = ( e . contentWindow || e . contentDocument ) . document ; return n . write ( t ) , n . close ( ) , n . getElementsByTagName ( "svg" ) [ 0 ] } function c ( t ) { for ( var e = parseFloat ( t [ 1 ] ) , n = parseFloat ( t [ 2 ] ) , r = [ ] , i = 3 , o = t . length ; i < o ; ) "c" === t [ i ] ? ( r . push ( [ parseFloat ( t [ i + 1 ] ) , parseFloat ( t [ i + 2 ] ) , parseFloat ( t [ i + 3 ] ) , parseFloat ( t [ i + 4 ] ) , parseFloat ( t [ i + 5 ] ) , parseFloat ( t [ i + 6 ] ) ] ) , i += 7 ) : "l" === t [ i ] ? ( r . push ( [ parseFloat ( t [ i + 1 ] ) , parseFloat ( t [ i + 2 ] ) ] ) , i += 3 ) : i += 1 ; return [ e , n , r ] } var l ; if ( e === l || n === l ) throw new Error ( "addSVG needs values for 'x' and 'y'" ) ; var u = a ( document ) , h = s ( t , u ) , f = [ 1 , 1 ] , d = parseFloat ( h . getAttribute ( "width" ) ) , p = parseFloat ( h . getAttribute ( "height" ) ) ; d && p && ( r && i ? f = [ r / d , i / p ] : r ? f = [ r / d , r / d ] : i && ( f = [ i / p , i / p ] ) ) ; var g , m , w , y , v = h . childNodes ; for ( g = 0 , m = v . length ; g < m ; g ++ ) w = v [ g ] , w . tagName && "PATH" === w . tagName . toUpperCase ( ) && ( y = c ( w . getAttribute ( "d" ) . split ( " " ) ) , y [ 0 ] = y [ 0 ] * f [ 0 ] + e , y [ 1 ] = y [ 1 ] * f [ 1 ] + n , this . lines . call ( this , y [ 2 ] , y [ 0 ] , y [ 1 ] , f ) ) ; return this } } ( e . API ) , / * * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* jsPDF total _pages plugin
* Copyright ( c ) 2013 Eduardo Menezes de Morais , eduardo . morais @ usp . br
*
*
* === === === === === === === === === === === === === === === === === === === === === === ==
* /
function ( t ) { t . putTotalPages = function ( t ) { for ( var e = new RegExp ( t , "g" ) , n = 1 ; n <= this . internal . getNumberOfPages ( ) ; n ++ ) for ( var r = 0 ; r < this . internal . pages [ n ] . length ; r ++ ) this . internal . pages [ n ] [ r ] = this . internal . pages [ n ] [ r ] . replace ( e , this . internal . getNumberOfPages ( ) ) ; return this } } ( e . API ) , / * * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* jsPDF XMP metadata plugin
* Copyright ( c ) 2016 Jussi Utunen , u - jussi @ suomi24 . fi
*
*
* === === === === === === === === === === === === === === === === === === === === === === ==
* /
function ( t ) { var e = "" , n = "" , r = "" ; t . addMetadata = function ( t , i ) { return n = i || "http://jspdf.default.namespaceuri/" , e = t , this . internal . events . subscribe ( "postPutResources" , function ( ) { if ( e ) { var t = '<x:xmpmeta xmlns:x="adobe:ns:meta/">' , i = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:jspdf="' + n + '"><jspdf:metadata>' , o = "</jspdf:metadata></rdf:Description></rdf:RDF>" , a = "</x:xmpmeta>" , s = unescape ( encodeURIComponent ( t ) ) , c = unescape ( encodeURIComponent ( i ) ) , l = unescape ( encodeURIComponent ( e ) ) , u = unescape ( encodeURIComponent ( o ) ) , h = unescape ( encodeURIComponent ( a ) ) , f = c . length + l . length + u . length + s . length + h . length ; r = this . internal . newObject ( ) , this . internal . write ( "<< /Type /Metadata /Subtype /XML /Length " + f + " >>" ) , this . internal . write ( "stream" ) , this . internal . write ( s + c + l + u + h ) , this . internal . write ( "endstream" ) , this . internal . write ( "endobj" ) } else r = "" } ) , this . internal . events . subscribe ( "putCatalog" , function ( ) { r && this . internal . write ( "/Metadata " + r + " 0 R" ) } ) , this } } ( e . API ) , function ( t ) { if ( t . URL = t . URL || t . webkitURL , t . Blob && t . URL ) try { return void new Blob } catch ( t ) { } var e = t . BlobBuilder || t . WebKitBlobBuilder || t . MozBlobBuilder || function ( t ) { var e = function ( t ) { return Object . prototype . toString . call ( t ) . match ( /^\[object\s(.*)\]$/ ) [ 1 ] } , n = function ( ) { this . data = [ ] } , r = function ( t , e , n ) { this . data = t , this . size = t . length , this . type = e , this . encoding = n } , i = n . prototype , o = r . prototype , a = t . FileReaderSync , s = function ( t ) { this . code = this [ this . name = t ] } , c = "NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR" . split ( " " ) , l = c . length , u = t . URL || t . webkitURL || t , h = u . createObjectURL , f = u . revokeObjectURL , d = u , p = t . btoa , g = t . atob , m = t . ArrayBuffer , w = t . Uint8Array , y = /^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/ ; for ( r . fake = o . fake = ! 0 ; l -- ; ) s . prototype [ c [ l ] ] = l + 1 ; return u . createObjectURL || ( d = t . URL = function ( t ) { var e , n = document . createElementNS ( "http://www.w3.org/1999/xhtml" , "a" ) ; return n . href = t , "origin" in n || ( "data:" === n . protocol . toLowerCase ( ) ? n . origin = null : ( e = t . match ( y ) , n . origin = e && e [ 1 ] ) ) , n } ) , d . createObjectURL = function ( t ) { var e , n = t . type ; return null === n && ( n = "application/octet-stream" ) , t instanceof r ? ( e = "data:" + n , "base64" === t . encoding ? e + ";base64," + t . data : "URI" === t . encoding ? e + "," + decodeURIComponent ( t . data ) : p ? e + ";base64," + p ( t . data ) : e + "," + encodeURIComponent ( t . data ) ) : h ? h . call ( u , t ) : void 0 } , d . revokeObjectURL = function ( t ) { "data:" !== t . substring ( 0 , 5 ) && f && f . call ( u , t ) } , i . append = function ( t ) { var n = this . data ; if ( w && ( t instanceof m || t instanceof w ) ) { for ( var i = "" , o = new w ( t ) , c = 0 , l = o . length ; c < l ; c ++ ) i += String . fromCharCode ( o [ c ] ) ; n . push ( i ) } else if ( "Blob" === e ( t ) || "File" === e ( t ) ) { if ( ! a ) throw new s ( "NOT_READABLE_ERR" ) ; var u = new a ; n . push ( u . readAsBinaryString ( t ) ) } else t instanceof r ? "base64" === t . encoding && g ? n . push ( g ( t . data ) ) : "URI" === t . encoding ? n . push ( decodeURIComponent ( t . data ) ) : "raw" === t . encoding && n . push ( t . data ) : ( "string" != typeof t && ( t += "" ) , n . push ( unescape ( encodeURIComponent ( t ) ) ) ) } , i . getBlob = function ( t ) { return arguments . length || ( t = null ) , new r ( this . data . join ( "" ) , t , "raw" ) } , i . toString = function ( ) { return "[object BlobBuilder]" } , o . slice = function ( t , e , n ) { var i = arguments . length ; return i < 3 && ( n = null ) , new r ( this . data . slice ( t , i > 1 ? e : this . data . length ) , n , this . encoding ) } , o . toString = function ( ) { return "[object Blob]" } , o . close = function ( ) { this . size = 0 , delete this . data } , n } ( t ) ; t . Blob = function ( t , n ) { var r = n ? n . type || "" : "" , i = new e ; if ( t ) for ( var o = 0 , a = t . length ; o < a ; o ++ ) Uint8Array && t [ o ] instanceof Uint8Array ? i . append ( t [ o ] . buffer ) : i . append ( t [ o ] ) ; var s = i . getBlob ( r ) ; return ! s . slice && s . webkitSlice && ( s . slice = s . webkitSlice ) , s } ; var n = Object . getPrototypeOf || function ( t ) { return t . _ _proto _ _ } ; t . Blob . prototype = n ( new t . Blob ) } ( "undefined" != typeof self && self || "undefined" != typeof window && window || ( void 0 ) . content || void 0 ) ; var i = i || function ( t ) { if ( "undefined" == typeof navigator || ! /MSIE [1-9]\./ . test ( navigator . userAgent ) ) { var e = t . document , n = function ( ) { return t . URL || t . webkitURL || t } , r = e . createElementNS ( "http://www.w3.org/1999/xhtml" , "a" ) , i = "download" in r , o = function ( t ) { var e = new MouseEvent ( "click" ) ; t . dispatchEvent ( e ) } , a = /Version\/[\d\.]+.*Safari/ . test ( navigator . userAgent ) , s = t . webkitRequestFileSystem , c =
* Copyright ( c ) 2012 chick307 < chick307 @ gmail . com >
*
* Licensed under the MIT License .
* http : //opensource.org/licenses/mit-license
* /
void function ( t , e ) { "object" == typeof module ? module . exports = e ( ) : "function" == typeof define ? define ( e ) : t . adler32cs = e ( ) } ( e , function ( ) { var t = "function" == typeof ArrayBuffer && "function" == typeof Uint8Array , e = null , n = function ( ) { if ( ! t ) return function ( ) { return ! 1 } ; try { var n = { } ; "function" == typeof n . Buffer && ( e = n . Buffer ) } catch ( t ) { } return function ( t ) { return t instanceof ArrayBuffer || null !== e && t instanceof e } } ( ) , r = function ( ) { return null !== e ? function ( t ) { return new e ( t , "utf8" ) . toString ( "binary" ) } : function ( t ) { return unescape ( encodeURIComponent ( t ) ) } } ( ) , i = 65521 , o = function ( t , e ) { for ( var n = 65535 & t , r = t >>> 16 , o = 0 , a = e . length ; o < a ; o ++ ) n = ( n + ( 255 & e . charCodeAt ( o ) ) ) % i , r = ( r + n ) % i ; return ( r << 16 | n ) >>> 0 } , a = function ( t , e ) { for ( var n = 65535 & t , r = t >>> 16 , o = 0 , a = e . length ; o < a ; o ++ ) n = ( n + e [ o ] ) % i , r = ( r + n ) % i ; return ( r << 16 | n ) >>> 0 } , s = { } , c = s . Adler32 = function ( ) { var e = function ( t ) { if ( ! ( this instanceof e ) ) throw new TypeError ( "Constructor cannot called be as a function." ) ; if ( ! isFinite ( t = null == t ? 1 : + t ) ) throw new Error ( "First arguments needs to be a finite number." ) ; this . checksum = t >>> 0 } , i = e . prototype = { } ; return i . constructor = e , e . from = function ( t ) { return t . prototype = i , t } ( function ( t ) { if ( ! ( this instanceof e ) ) throw new TypeError ( "Constructor cannot called be as a function." ) ; if ( null == t ) throw new Error ( "First argument needs to be a string." ) ; this . checksum = o ( 1 , t . toString ( ) ) } ) , e . fromUtf8 = function ( t ) { return t . prototype = i , t } ( function ( t ) { if ( ! ( this instanceof e ) ) throw new TypeError ( "Constructor cannot called be as a function." ) ; if ( null == t ) throw new Error ( "First argument needs to be a string." ) ; var n = r ( t . toString ( ) ) ; this . checksum = o ( 1 , n ) } ) , t && ( e . fromBuffer = function ( t ) { return t . prototype = i , t } ( function ( t ) { if ( ! ( this instanceof e ) ) throw new TypeError ( "Constructor cannot called be as a function." ) ; if ( ! n ( t ) ) throw new Error ( "First argument needs to be ArrayBuffer." ) ; var r = new Uint8Array ( t ) ; return this . checksum = a ( 1 , r ) } ) ) , i . update = function ( t ) { if ( null == t ) throw new Error ( "First argument needs to be a string." ) ; return t = t . toString ( ) , this . checksum = o ( this . checksum , t ) } , i . updateUtf8 = function ( t ) { if ( null == t ) throw new Error ( "First argument needs to be a string." ) ; var e = r ( t . toString ( ) ) ; return this . checksum = o ( this . checksum , e ) } , t && ( i . updateBuffer = function ( t ) { if ( ! n ( t ) ) throw new Error ( "First argument needs to be ArrayBuffer." ) ; var e = new Uint8Array ( t ) ; return this . checksum = a ( this . checksum , e ) } ) , i . clone = function ( ) { return new c ( this . checksum ) } , e } ( ) ; return s . from = function ( t ) { if ( null == t ) throw new Error ( "First argument needs to be a string." ) ; return o ( 1 , t . toString ( ) ) } , s . fromUtf8 = function ( t ) { if ( null == t ) throw new Error ( "First argument needs to be a string." ) ; var e = r ( t . toString ( ) ) ; return o ( 1 , e ) } , t && ( s . fromBuffer = function ( t ) { if ( ! n ( t ) ) throw new Error ( "First argument need to be ArrayBuffer." ) ; var e = new Uint8Array ( t ) ; return a ( 1 , e ) } ) , s } ) ; / * *
* CssColors
* Copyright ( c ) 2014 Steven Spungin ( TwelveTone LLC ) steven @ twelvetone . tv
*
* Licensed under the MIT License .
* http : //opensource.org/licenses/mit-license
* /
var o = { } ; o . _colorsTable = { aliceblue : "#f0f8ff" , antiquewhite : "#faebd7" , aqua : "#00ffff" , aquamarine : "#7fffd4" , azure : "#f0ffff" , beige : "#f5f5dc" , bisque : "#ffe4c4" , black : "#000000" , blanchedalmond : "#ffebcd" , blue : "#0000ff" , blueviolet : "#8a2be2" , brown : "#a52a2a" , burlywood : "#deb887" , cadetblue : "#5f9ea0" , chartreuse : "#7fff00" , chocolate : "#d2691e" , coral : "#ff7f50" , cornflowerblue : "#6495ed" , cornsilk : "#fff8dc" , crimson : "#dc143c" , cyan : "#00ffff" , darkblue : "#00008b" , darkcyan : "#008b8b" , darkgoldenrod : "#b8860b" , darkgray : "#a9a9a9" , darkgreen : "#006400" , darkkhaki : "#bdb76b" , darkmagenta : "#8b008b" , darkolivegreen : "#556b2f" , darkorange : "#ff8c00" , darkorchid : "#9932cc" , darkred : "#8b0000" , darksalmon : "#e9967a" , darkseagreen : "#8fbc8f" , darkslateblue : "#483d8b" , darkslategray : "#2f4f4f" , darkturquoise : "#00ced1" , darkviolet : "#9400d3" , deeppink : "#ff1493" , deepskyblue : "#00bfff" , dimgray : "#696969" , dodgerblue : "#1e90ff" , firebrick : "#b22222" , floralwhite : "#fffaf0" , forestgreen : "#228b22" , fuchsia : "#ff00ff" , gainsboro : "#dcdcdc" , ghostwhite : "#f8f8ff" , gold : "#ffd700" , goldenrod : "#daa520" , gray : "#808080" , green : "#008000" , greenyellow : "#adff2f" , honeydew : "#f0fff0" , hotpink : "#ff69b4" , "indianred " : "#cd5c5c" , indigo : "#4b0082" , ivory : "#fffff0" , khaki : "#f0e68c" , lavender : "#e6e6fa" , lavenderblush : "#fff0f5" , lawngreen : "#7cfc00" , lemonchiffon : "#fffacd" , lightblue : "#add8e6" , lightcoral : "#f08080" , lightcyan : "#e0ffff" , lightgoldenrodyellow : "#fafad2" , lightgrey : "#d3d3d3" , lightgreen : "#90ee90" , lightpink : "#ffb6c1" , lightsalmon : "#ffa07a" , lightseagreen : "#20b2aa" , lightskyblue : "#87cefa" , lightslategray : "#778899" , lightsteelblue : "#b0c4de" , lightyellow : "#ffffe0" , lime : "#00ff00" , limegreen : "#32cd32" , linen : "#faf0e6" , magenta : "#ff00ff" , maroon : "#800000" , mediumaquamarine : "#66cdaa" , mediumblue : "#0000cd" , mediumorchid : "#ba55d3" , mediumpurple : "#9370d8" , mediumseagreen : "#3cb371" , mediumslateblue : "#7b68ee" , mediumspringgreen : "#00fa9a" , mediumturquoise : "#48d1cc" , mediumvioletred : "#c71585" , midnightblue : "#191970" , mintcream : "#f5fffa" , mistyrose : "#ffe4e1" , moccasin : "#ffe4b5" , navajowhite : "#ffdead" , navy : "#000080" , oldlace : "#fdf5e6" , olive : "#808000" , olivedrab : "#6b8e23" , orange : "#ffa500" , orangered : "#ff4500" , orchid : "#da70d6" , palegoldenrod : "#eee8aa" , palegreen : "#98fb98" , paleturquoise : "#afeeee" , palevioletred : "#d87093" , papayawhip : "#ffefd5" , peachpuff : "#ffdab9" , peru : "#cd853f" , pink : "#ffc0cb" , plum : "#dda0dd" , powderblue : "#b0e0e6" , purple : "#800080" , red : "#ff0000" , rosybrown : "#bc8f8f" , royalblue : "#4169e1" , saddlebrown : "#8b4513" , salmon : "#fa8072" , sandybrown : "#f4a460" , seagreen : "#2e8b57" , seashell : "#fff5ee" , sienna : "#a0522d" , silver : "#c0c0c0" , skyblue : "#87ceeb" , slateblue : "#6a5acd" , slategray : "#708090" , snow : "#fffafa" , springgreen : "#00ff7f" , steelblue : "#4682b4" , tan : "#d2b48c" , teal : "#008080" , thistle : "#d8bfd8" , tomato : "#ff6347" , turquoise : "#40e0d0" , violet : "#ee82ee" , wheat : "#f5deb3" , white : "#ffffff" , whitesmoke : "#f5f5f5" , yellow : "#ffff00" , yellowgreen : "#9acd32" } , o . colorNameToHex = function ( t ) { return t = t . toLowerCase ( ) , "undefined" != typeof this . _colorsTable [ t ] && this . _colorsTable [ t ] } ; / *
Deflate . js - https : //github.com/gildas-lormeau/zip.js
Copyright ( c ) 2013 Gildas Lormeau . All rights reserved .
Redistribution and use in source and binary forms , with or without
modification , are permitted provided that the following conditions are met :
1. Redistributions of source code must retain the above copyright notice ,
this list of conditions and the following disclaimer .
2. Redistributions in binary form must reproduce the above copyright
notice , this list of conditions and the following disclaimer in
the documentation and / or other materials provided with the distribution .
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission .
THIS SOFTWARE IS PROVIDED ` ` AS IS '' AND ANY EXPRESSED OR IMPLIED WARRANTIES ,
INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL JCRAFT ,
INC . OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT , INDIRECT ,
INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT
LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA ,
OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING
NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE ,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* /
var a = function ( t ) { function e ( ) { function t ( t ) { var e , n , i , o , a , c , l = r . dyn _tree , u = r . stat _desc . static _tree , h = r . stat _desc . extra _bits , f = r . stat _desc . extra _base , p = r . stat _desc . max _length , g = 0 ; for ( o = 0 ; o <= s ; o ++ ) t . bl _count [ o ] = 0 ; for ( l [ 2 * t . heap [ t . heap _max ] + 1 ] = 0 , e = t . heap _max + 1 ; e < d ; e ++ ) n = t . heap [ e ] , o = l [ 2 * l [ 2 * n + 1 ] + 1 ] + 1 , o > p && ( o = p , g ++ ) , l [ 2 * n + 1 ] = o , n > r . max _code || ( t . bl _count [ o ] ++ , a = 0 , n >= f && ( a = h [ n - f ] ) , c = l [ 2 * n ] , t . opt _len += c * ( o + a ) , u && ( t . static _len += c * ( u [ 2 * n + 1 ] + a ) ) ) ; if ( 0 !== g ) { do { for ( o = p - 1 ; 0 === t . bl _count [ o ] ; ) o -- ; t . bl _count [ o ] -- , t . bl _count [ o + 1 ] += 2 , t . bl _count [ p ] -- , g -= 2 } while ( g > 0 ) ; for ( o = p ; 0 !== o ; o -- ) for ( n = t . bl _count [ o ] ; 0 !== n ; ) i = t . heap [ -- e ] , i > r . max _code || ( l [ 2 * i + 1 ] != o && ( t . opt _len += ( o - l [ 2 * i + 1 ] ) * l [ 2 * i ] , l [ 2 * i + 1 ] = o ) , n -- ) } } function e ( t , e ) { var n = 0 ; do n |= 1 & t , t >>>= 1 , n <<= 1 ; while ( -- e > 0 ) ; return n >>> 1 } function n ( t , n , r ) { var i , o , a , c = [ ] , l = 0 ; for ( i = 1 ; i <= s ; i ++ ) c [ i ] = l = l + r [ i - 1 ] << 1 ; for ( o = 0 ; o <= n ; o ++ ) a = t [ 2 * o + 1 ] , 0 !== a && ( t [ 2 * o ] = e ( c [ a ] ++ , a ) ) } var r = this ; r . build _tree = function ( e ) { var i , o , a , s = r . dyn _tree , c = r . stat _desc . static _tree , l = r . stat _desc . elems , u = - 1 ; for ( e . heap _len = 0 , e . heap _max = d , i = 0 ; i < l ; i ++ ) 0 !== s [ 2 * i ] ? ( e . heap [ ++ e . heap _len ] = u = i , e . depth [ i ] = 0 ) : s [ 2 * i + 1 ] = 0 ; for ( ; e . heap _len < 2 ; ) a = e . heap [ ++ e . heap _len ] = u < 2 ? ++ u : 0 , s [ 2 * a ] = 1 , e . depth [ a ] = 0 , e . opt _len -- , c && ( e . static _len -= c [ 2 * a + 1 ] ) ; for ( r . max _code = u , i = Math . floor ( e . heap _len / 2 ) ; i >= 1 ; i -- ) e . pqdownheap ( s , i ) ; a = l ; do i = e . heap [ 1 ] , e . heap [ 1 ] = e . heap [ e . heap _len -- ] , e . pqdownheap ( s , 1 ) , o = e . heap [ 1 ] , e . heap [ -- e . heap _max ] = i , e . heap [ -- e . heap _max ] = o , s [ 2 * a ] = s [ 2 * i ] + s [ 2 * o ] , e . depth [ a ] = Math . max ( e . depth [ i ] , e . depth [ o ] ) + 1 , s [ 2 * i + 1 ] = s [ 2 * o + 1 ] = a , e . heap [ 1 ] = a ++ , e . pqdownheap ( s , 1 ) ; while ( e . heap _len >= 2 ) ; e . heap [ -- e . heap _max ] = e . heap [ 1 ] , t ( e ) , n ( s , r . max _code , e . bl _count ) } } function n ( t , e , n , r , i ) { var o = this ; o . static _tree = t , o . extra _bits = e , o . extra _base = n , o . elems = r , o . max _length = i } function r ( t , e , n , r , i ) { var o = this ; o . good _length = t , o . max _lazy = e , o . nice _length = n , o . max _chain = r , o . func = i } function i ( t , e , n , r ) { var i = t [ 2 * e ] , o = t [ 2 * n ] ; return i < o || i == o && r [ e ] <= r [ n ] } function o ( ) { function t ( ) { var t ; for ( It = 2 * St , Ot [ Rt - 1 ] = 0 , t = 0 ; t < Rt - 1 ; t ++ ) Ot [ t ] = 0 ; Yt = L [ Gt ] . max _lazy , Qt = L [ Gt ] . good _length , Kt = L [ Gt ] . nice _length , Vt = L [ Gt ] . max _chain , Ut = 0 , zt = 0 , Wt = 0 , Nt = Xt = tt - 1 , Mt = 0 , Ft = 0 } function r ( ) { var t ; for ( t = 0 ; t < f ; t ++ ) $t [ 2 * t ] = 0 ; for ( t = 0 ; t < c ; t ++ ) Zt [ 2 * t ] = 0 ; for ( t = 0 ; t < l ; t ++ ) te [ 2 * t ] = 0 ; $t [ 2 * p ] = 1 , ee . opt _len = ee . static _len = 0 , se = le = 0 } function o ( ) { ne . dyn _tree = $t , ne . stat _desc = n . static _l _desc , re . dyn _tree = Zt , re . stat _desc = n . static _d _desc , ie . dyn _tree = te , ie . stat _desc = n . static _bl _desc , he = 0 , fe = 0 , ue = 8 , r ( ) } function a ( t , e ) { var n , r , i = - 1 , o = t [ 1 ] , a = 0 , s = 7 , c = 4 ; for ( 0 === o && ( s = 138 , c = 3 ) , t [ 2 * ( e + 1 ) + 1 ] = 65535 , n = 0 ; n <= e ; n ++ ) r = o , o = t [ 2 * ( n + 1 ) + 1 ] , ++ a < s && r == o || ( a < c ? te [ 2 * r ] += a : 0 !== r ? ( r != i && te [ 2 * r ] ++ , te [ 2 * m ] ++ ) : a <= 10 ? te [ 2 * w ] ++ : te [ 2 * y ] ++ , a = 0 , i = r , 0 === o ? ( s = 138 , c = 3 ) : r == o ? ( s = 6 , c = 3 ) : ( s = 7 , c = 4 ) ) } function s ( ) { var t ; for ( a ( $t , ne . max _code ) , a ( Zt , re . max _code ) , ie . build _tree ( ee ) , t = l - 1 ; t >= 3 && 0 === te [ 2 * e . bl _order [ t ] + 1 ] ; t -- ) ; return ee . opt _len += 3 * ( t + 1 ) + 5 + 5 + 4 , t } function u ( t ) { ee . pending _buf [ ee . pending ++ ] = t } function d ( t ) { u ( 255 & t ) , u ( t >>> 8 & 255 ) } function g ( t ) { u ( t >> 8 & 255 ) , u ( 255 & t & 255 ) } function R ( t , e ) { var n , r = e ; fe > v - r ? ( n = t , he |= n << fe & 65535 , d ( he ) , he = n >>> v - fe , fe += r - v ) : ( he |= t << fe & 65535 , fe += r ) } function rt ( t , e ) { var n = 2 * t ; R ( 65535 & e [ n ] , 65535 & e [ n + 1 ] ) } function it ( t , e ) { var n , r , i = - 1 , o = t [ 1 ] , a = 0 , s = 7 , c = 4 ; for ( 0 === o && ( s = 138 , c = 3 ) , n = 0 ; n <= e ; n ++ ) if ( r = o , o = t [ 2 * ( n + 1 ) + 1 ] , ! ( ++ a < s && r == o ) ) { if ( a < c ) { do rt ( r , te ) ; while ( 0 !== -- a ) } else 0 !== r ? ( r != i && ( rt ( r , te ) , a -- ) , rt ( m , te ) , R ( a - 3 , 2 ) ) : a <= 10 ? ( rt ( w , te ) , R ( a - 3 , 3 ) ) : ( rt ( y , te ) , R ( a - 11 , 7 ) ) ; a = 0 , i = r , 0 === o ? ( s = 138 , c = 3 ) : r == o ? ( s = 6 , c = 3 ) : ( s = 7 , c = 4 ) } } function ot ( t , n , r ) { var i ; for ( R ( t - 257 , 5 ) , R ( n - 1 , 5 ) , R ( r - 4 , 4 ) , i = 0 ; i < r ; i ++ ) R ( te [ 2 * e . bl _order [ i ] + 1 ] , 3 ) ; it ( $t , t - 1 ) , it ( Zt , n - 1 ) } function at ( ) { 16 == fe ? ( d ( he ) , he = 0 , fe = 0 ) : fe >= 8 && ( u ( 255 & he ) , he >>>= 8 , fe -= 8 ) } function st ( ) { R ( $ << 1 , 3 ) , rt ( p , n . static _ltree ) , at ( ) , 1 + ue + 10 - fe < 9 && ( R ( $ << 1 , 3 ) , rt ( p , n . static _ltree ) , at ( ) ) , ue = 7 } function ct ( t , n ) { var r , i , o ; if ( ee . pending _buf [ ce + 2 * se ] = t >>> 8 & 255 , ee . pending _buf [ ce + 2 * se + 1 ] = 255 & t , ee . pending _buf [ oe + se ] = 255 & n , se ++ , 0 === t ? $t [ 2 * n ] ++ : ( le ++ , t -- , $t [ 2 * ( e . _length _code [ n ] + h + 1 ) ] ++ , Zt [ 2 * e . d _code ( t ) ] ++ ) , 0 === ( 8191 & se ) && Gt > 2 ) { for ( r = 8 * se , i = Ut - zt , o = 0 ; o < c ; o ++ ) r += Zt [ 2 * o ] * ( 5 + e . extra _dbits [ o ] ) ; if ( r >>>= 3 , le < Math . floor ( se / 2 ) && r < Math . floor ( i / 2 ) ) return ! 0 } return se == ae - 1 } function lt ( t , n ) { var r , i , o , a ,
html2canvas 0.5 . 0 - beta3 < http : //html2canvas.hertzen.com>
Copyright ( c ) 2016 Niklas von Hertzen
Released under License
* /
! function ( t ) { if ( "object" == typeof exports && "undefined" != typeof module ) module . exports = t ( ) ; else if ( "function" == typeof define && define . amd ) define ( [ ] , t ) ; else { var e ; "undefined" != typeof window ? e = window : "undefined" != typeof global ? e = global : "undefined" != typeof self && ( e = self ) , e . html2canvas = t ( ) } } ( function ( ) { var t ; return function t ( e , n , r ) { function i ( a , s ) { if ( ! n [ a ] ) { if ( ! e [ a ] ) { var c = "function" == typeof require && require ; if ( ! s && c ) return c ( a , ! 0 ) ; if ( o ) return o ( a , ! 0 ) ; var l = new Error ( "Cannot find module '" + a + "'" ) ; throw l . code = "MODULE_NOT_FOUND" , l } var u = n [ a ] = { exports : { } } ; e [ a ] [ 0 ] . call ( u . exports , function ( t ) { var n = e [ a ] [ 1 ] [ t ] ; return i ( n ? n : t ) } , u , u . exports , t , e , n , r ) } return n [ a ] . exports } for ( var o = "function" == typeof require && require , a = 0 ; a < r . length ; a ++ ) i ( r [ a ] ) ; return i } ( { 1 : [ function ( e , n , r ) { ( function ( e ) { ! function ( i ) { function o ( t ) { throw RangeError ( R [ t ] ) } function a ( t , e ) { for ( var n = t . length ; n -- ; ) t [ n ] = e ( t [ n ] ) ; return t } function s ( t , e ) { return a ( t . split ( F ) , e ) . join ( "." ) } function c ( t ) { for ( var e , n , r = [ ] , i = 0 , o = t . length ; i < o ; ) e = t . charCodeAt ( i ++ ) , e >= 55296 && e <= 56319 && i < o ? ( n = t . charCodeAt ( i ++ ) , 56320 == ( 64512 & n ) ? r . push ( ( ( 1023 & e ) << 10 ) + ( 1023 & n ) + 65536 ) : ( r . push ( e ) , i -- ) ) : r . push ( e ) ; return r } function l ( t ) { return a ( t , function ( t ) { var e = "" ; return t > 65535 && ( t -= 65536 , e += j ( t >>> 10 & 1023 | 55296 ) , t = 56320 | 1023 & t ) , e += j ( t ) } ) . join ( "" ) } function u ( t ) { return t - 48 < 10 ? t - 22 : t - 65 < 26 ? t - 65 : t - 97 < 26 ? t - 97 : _ } function h ( t , e ) { return t + 22 + 75 * ( t < 26 ) - ( ( 0 != e ) << 5 ) } function f ( t , e , n ) { var r = 0 ; for ( t = n ? D ( t / q ) : t >> 1 , t += D ( t / e ) ; t > B * A >> 1 ; r += _ ) t = D ( t / B ) ; return D ( r + ( B + 1 ) * t / ( t + S ) ) } function d ( t ) { var e , n , r , i , a , s , c , h , d , p , g = [ ] , m = t . length , w = 0 , y = P , v = T ; for ( n = t . lastIndexOf ( I ) , n < 0 && ( n = 0 ) , r = 0 ; r < n ; ++ r ) t . charCodeAt ( r ) >= 128 && o ( "not-basic" ) , g . push ( t . charCodeAt ( r ) ) ; for ( i = n > 0 ? n + 1 : 0 ; i < m ; ) { for ( a = w , s = 1 , c = _ ; i >= m && o ( "invalid-input" ) , h = u ( t . charCodeAt ( i ++ ) ) , ( h >= _ || h > D ( ( k - w ) / s ) ) && o ( "overflow" ) , w += h * s , d = c <= v ? C : c >= v + A ? A : c - v , ! ( h < d ) ; c += _ ) p = _ - d , s > D ( k / p ) && o ( "overflow" ) , s *= p ; e = g . length + 1 , v = f ( w - a , e , 0 == a ) , D ( w / e ) > k - y && o ( "overflow" ) , y += D ( w / e ) , w %= e , g . splice ( w ++ , 0 , y ) } return l ( g ) } function p ( t ) { var e , n , r , i , a , s , l , u , d , p , g , m , w , y , v , b = [ ] ; for ( t = c ( t ) , m = t . length , e = P , n = 0 , a = T , s = 0 ; s < m ; ++ s ) g = t [ s ] , g < 128 && b . push ( j ( g ) ) ; for ( r = i = b . length , i && b . push ( I ) ; r < m ; ) { for ( l = k , s = 0 ; s < m ; ++ s ) g = t [ s ] , g >= e && g < l && ( l = g ) ; for ( w = r + 1 , l - e > D ( ( k - n ) / w ) && o ( "overflow" ) , n += ( l - e ) * w , e = l , s = 0 ; s < m ; ++ s ) if ( g = t [ s ] , g < e && ++ n > k && o ( "overflow" ) , g == e ) { for ( u = n , d = _ ; p = d <= a ? C : d >= a + A ? A : d - a , ! ( u < p ) ; d += _ ) v = u - p , y = _ - p , b . push ( j ( h ( p + v % y , 0 ) ) ) , u = D ( v / y ) ; b . push ( j ( h ( u , 0 ) ) ) , a = f ( n , w , r == i ) , n = 0 , ++ r } ++ n , ++ e } return b . join ( "" ) } function g ( t ) { return s ( t , function ( t ) { return E . test ( t ) ? d ( t . slice ( 4 ) . toLowerCase ( ) ) : t } ) } function m ( t ) { return s ( t , function ( t ) { return O . test ( t ) ? "xn--" + p ( t ) : t } ) } var w = "object" == typeof r && r , y = "object" == typeof n && n && n . exports == w && n , v = "object" == typeof e && e ; v . global !== v && v . window !== v || ( i = v ) ; var b , x , k = 2147483647 , _ = 36 , C = 1 , A = 26 , S = 38 , q = 700 , T = 72 , P = 128 , I = "-" , E = /^xn--/ , O = /[^ -~]/ , F = /\x2E|\u3002|\uFF0E|\uFF61/g , R = { overflow : "Overflow: input needs wider integers to process" , "not-basic" : "Illegal input >= 0x80 (not a basic code point)" , "invalid-input" : "Invalid input" } , B = _ - C , D = Math . floor , j = String . fromCharCode ; if ( b = { version : "1.2.4" , ucs2 : { decode : c , encode : l } , decode : d , encode : p , toASCII : m , toUnicode : g } , "function" == typeof t && "object" == typeof t . amd && t . amd ) t ( "punycode" , function ( ) { return b } ) ; else if ( w && ! w . nodeType ) if ( y ) y . exports = b ; else for ( x in b ) b . hasOwnProperty ( x ) && ( w [ x ] = b [ x ] ) ; else i . punycode = b } ( this ) } ) . call ( this , "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : { } ) } , { } ] , 2 : [ function ( t , e , n ) { function r ( t , e , n ) { ! t . defaultView || e === t . defaultView . pageXOffset && n === t . defaultView . pageYOffset || t . defaultView . scrollTo ( e , n ) } function i ( t , e ) { try { e && ( e . width = t . width , e . height = t . height , e . getContext ( "2d" ) . putImageData ( t . getContext ( "2d" ) . getImageData ( 0 , 0 , t . width , t . height ) , 0 , 0 ) ) } catch ( e ) { s ( "Unable to copy canvas content from" , t , e ) } } function o ( t , e ) { for ( var n = 3 === t . nodeType ? document . createTextNode ( t . nodeValue ) : t . cloneNode ( ! 1 ) , r = t . firstChild ; r ; ) e !== ! 0 && 1 === r . nodeType && "SCRIPT" === r . nodeName || n . appendChild ( o ( r , e ) ) , r = r . nextSibling ; return 1 === t . nodeType && ( n . _scrollTop = t . scrollTop , n . _scrollLeft = t . scrollLeft , "CANVAS" === t . nodeName ? i ( t , n ) : " TEXTAR
bottomLeftInner : c ( r + n [ 3 ] . width , i + v , Math . max ( 0 , p - n [ 3 ] . width ) , g - n [ 2 ] . width ) . bottomLeft . subdivide ( . 5 ) } } function u ( t , e , n , r ) { var i = function ( t , e , n ) { return { x : t . x + ( e . x - t . x ) * n , y : t . y + ( e . y - t . y ) * n } } ; return { start : t , startControl : e , endControl : n , end : r , subdivide : function ( o ) { var a = i ( t , e , o ) , s = i ( e , n , o ) , c = i ( n , r , o ) , l = i ( a , s , o ) , h = i ( s , c , o ) , f = i ( l , h , o ) ; return [ u ( t , a , l , f ) , u ( f , h , c , r ) ] } , curveTo : function ( t ) { t . push ( [ "bezierCurve" , e . x , e . y , n . x , n . y , r . x , r . y ] ) } , curveToReversed : function ( r ) { r . push ( [ "bezierCurve" , n . x , n . y , e . x , e . y , t . x , t . y ] ) } } } function h ( t , e , n , r , i , o , a ) { var s = [ ] ; return e [ 0 ] > 0 || e [ 1 ] > 0 ? ( s . push ( [ "line" , r [ 1 ] . start . x , r [ 1 ] . start . y ] ) , r [ 1 ] . curveTo ( s ) ) : s . push ( [ "line" , t . c1 [ 0 ] , t . c1 [ 1 ] ] ) , n [ 0 ] > 0 || n [ 1 ] > 0 ? ( s . push ( [ "line" , o [ 0 ] . start . x , o [ 0 ] . start . y ] ) , o [ 0 ] . curveTo ( s ) , s . push ( [ "line" , a [ 0 ] . end . x , a [ 0 ] . end . y ] ) , a [ 0 ] . curveToReversed ( s ) ) : ( s . push ( [ "line" , t . c2 [ 0 ] , t . c2 [ 1 ] ] ) , s . push ( [ "line" , t . c3 [ 0 ] , t . c3 [ 1 ] ] ) ) , e [ 0 ] > 0 || e [ 1 ] > 0 ? ( s . push ( [ "line" , i [ 1 ] . end . x , i [ 1 ] . end . y ] ) , i [ 1 ] . curveToReversed ( s ) ) : s . push ( [ "line" , t . c4 [ 0 ] , t . c4 [ 1 ] ] ) , s } function f ( t , e , n , r , i , o , a ) { e [ 0 ] > 0 || e [ 1 ] > 0 ? ( t . push ( [ "line" , r [ 0 ] . start . x , r [ 0 ] . start . y ] ) , r [ 0 ] . curveTo ( t ) , r [ 1 ] . curveTo ( t ) ) : t . push ( [ "line" , o , a ] ) , ( n [ 0 ] > 0 || n [ 1 ] > 0 ) && t . push ( [ "line" , i [ 0 ] . start . x , i [ 0 ] . start . y ] ) } function d ( t ) { return t . cssInt ( "zIndex" ) < 0 } function p ( t ) { return t . cssInt ( "zIndex" ) > 0 } function g ( t ) { return 0 === t . cssInt ( "zIndex" ) } function m ( t ) { return [ "inline" , "inline-block" , "inline-table" ] . indexOf ( t . css ( "display" ) ) !== - 1 } function w ( t ) { return t instanceof Y } function y ( t ) { return t . node . data . trim ( ) . length > 0 } function v ( t ) { return /^(normal|none|0px)$/ . test ( t . parent . css ( "letterSpacing" ) ) } function b ( t ) { return [ "TopLeft" , "TopRight" , "BottomRight" , "BottomLeft" ] . map ( function ( e ) { var n = t . css ( "border" + e + "Radius" ) , r = n . split ( " " ) ; return r . length <= 1 && ( r [ 1 ] = r [ 0 ] ) , r . map ( O ) } ) } function x ( t ) { return t . nodeType === Node . TEXT _NODE || t . nodeType === Node . ELEMENT _NODE } function k ( t ) { var e = t . css ( "position" ) , n = [ "absolute" , "relative" , "fixed" ] . indexOf ( e ) !== - 1 ? t . css ( "zIndex" ) : "auto" ; return "auto" !== n } function _ ( t ) { return "static" !== t . css ( "position" ) } function C ( t ) { return "none" !== t . css ( "float" ) } function A ( t ) { return [ "inline-block" , "inline-table" ] . indexOf ( t . css ( "display" ) ) !== - 1 } function S ( t ) { var e = this ; return function ( ) { return ! t . apply ( e , arguments ) } } function q ( t ) { return t . node . nodeType === Node . ELEMENT _NODE } function T ( t ) { return t . isPseudoElement === ! 0 } function P ( t ) { return t . node . nodeType === Node . TEXT _NODE } function I ( t ) { return function ( e , n ) { return e . cssInt ( "zIndex" ) + t . indexOf ( e ) / t . length - ( n . cssInt ( "zIndex" ) + t . indexOf ( n ) / t . length ) } } function E ( t ) { return t . getOpacity ( ) < 1 } function O ( t ) { return parseInt ( t , 10 ) } function F ( t ) { return t . width } function R ( t ) { return t . node . nodeType !== Node . ELEMENT _NODE || [ "SCRIPT" , "HEAD" , "TITLE" , "OBJECT" , "BR" , "OPTION" ] . indexOf ( t . node . nodeName ) === - 1 } function B ( t ) { return [ ] . concat . apply ( [ ] , t ) } function D ( t ) { var e = t . substr ( 0 , 1 ) ; return e === t . substr ( t . length - 1 ) && e . match ( /'|"/ ) ? t . substr ( 1 , t . length - 2 ) : t } function j ( t ) { for ( var e , n = [ ] , r = 0 , i = ! 1 ; t . length ; ) z ( t [ r ] ) === i ? ( e = t . splice ( 0 , r ) , e . length && n . push ( M . ucs2 . encode ( e ) ) , i = ! i , r = 0 ) : r ++ , r >= t . length && ( e = t . splice ( 0 , r ) , e . length && n . push ( M . ucs2 . encode ( e ) ) ) ; return n } function z ( t ) { return [ 32 , 13 , 10 , 9 , 45 ] . indexOf ( t ) !== - 1 } function N ( t ) { return /[^\u0000-\u00ff]/ . test ( t ) } var L = t ( "./log" ) , M = t ( "punycode" ) , U = t ( "./nodecontainer" ) , H = t ( "./textcontainer" ) , W = t ( "./pseudoelementcontainer" ) , X = t ( "./fontmetrics" ) , V = t ( "./color" ) , Y = t ( "./stackingcontext" ) , G = t ( "./utils" ) , J = G . bind , Q = G . getBounds , K = G . parseBackgrounds , $ = G . offsetBounds ; r . prototype . calculateOverflowClips = function ( ) { this . nodes . forEach ( function ( t ) { if ( q ( t ) ) { T ( t ) && t . appendToDOM ( ) , t . borders = this . parseBorders ( t ) ; var e = "hidden" === t . css ( "overflow" ) ? [ t . borders . clip ] : [ ] , n = t . parseClip ( ) ; n && [ "absolute" , "fixed" ] . indexOf ( t . css ( "position" ) ) !== - 1 && e . push ( [ [ "rect" , t . bounds . left + n . left , t . bounds . top + n . top , n . right - n . left , n . bottom - n . top ] ] ) , t . clip = i ( t ) ? t . parent . clip . concat ( e ) : e , t . backgroundClip = "hidden" !== t . css ( "overflow" ) ? t . clip . concat ( [ t . borders . clip ] ) : t . clip , T ( t ) && t . cleanDOM ( ) } else P ( t ) && ( t . clip = i ( t ) ? t . parent . clip : [ ] ) ; T ( t ) || ( t . bounds = null ) } , this ) } , r . prototype . asyncRenderer = function ( t , e , n ) { n = n || Date . now ( ) , this . paint ( t [ this . renderIndex ++ ] ) , t . length === this . re
* base64 - arraybuffer
* https : //github.com/niklasvh/base64-arraybuffer
*
* Copyright ( c ) 2012 Niklas von Hertzen
* Licensed under the MIT license .
* /
n . decode64 = function ( t ) { var e , n , r , i , o , a , s , c , l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" , u = t . length , h = "" ; for ( e = 0 ; e < u ; e += 4 ) n = l . indexOf ( t [ e ] ) , r = l . indexOf ( t [ e + 1 ] ) , i = l . indexOf ( t [ e + 2 ] ) , o = l . indexOf ( t [ e + 3 ] ) , a = n << 2 | r >> 4 , s = ( 15 & r ) << 4 | i >> 2 , c = ( 3 & i ) << 6 | o , h += 64 === i ? String . fromCharCode ( a ) : 64 === o || o === - 1 ? String . fromCharCode ( a , s ) : String . fromCharCode ( a , s , c ) ; return h } , n . getBounds = function ( t ) { if ( t . getBoundingClientRect ) { var e = t . getBoundingClientRect ( ) , n = null == t . offsetWidth ? e . width : t . offsetWidth ; return { top : e . top , bottom : e . bottom || e . top + e . height , right : e . left + n , left : e . left , width : n , height : null == t . offsetHeight ? e . height : t . offsetHeight } } return { } } , n . offsetBounds = function ( t ) { var e = t . offsetParent ? n . offsetBounds ( t . offsetParent ) : { top : 0 , left : 0 } ; return { top : t . offsetTop + e . top , bottom : t . offsetTop + t . offsetHeight + e . top , right : t . offsetLeft + e . left + t . offsetWidth , left : t . offsetLeft + e . left , width : t . offsetWidth , height : t . offsetHeight } } , n . parseBackgrounds = function ( t ) { var e , n , r , i , o , a , s , c = " \r\n\t" , l = [ ] , u = 0 , h = 0 , f = function ( ) { e && ( '"' === n . substr ( 0 , 1 ) && ( n = n . substr ( 1 , n . length - 2 ) ) , n && s . push ( n ) , "-" === e . substr ( 0 , 1 ) && ( i = e . indexOf ( "-" , 1 ) + 1 ) > 0 && ( r = e . substr ( 0 , i ) , e = e . substr ( i ) ) , l . push ( { prefix : r , method : e . toLowerCase ( ) , value : o , args : s , image : null } ) ) , s = [ ] , e = r = n = o = "" } ; return s = [ ] , e = r = n = o = "" , t . split ( "" ) . forEach ( function ( t ) { if ( ! ( 0 === u && c . indexOf ( t ) > - 1 ) ) { switch ( t ) { case '"' : a ? a === t && ( a = null ) : a = t ; break ; case "(" : if ( a ) break ; if ( 0 === u ) return u = 1 , void ( o += t ) ; h ++ ; break ; case ")" : if ( a ) break ; if ( 1 === u ) { if ( 0 === h ) return u = 0 , o += t , void f ( ) ; h -- } break ; case "," : if ( a ) break ; if ( 0 === u ) return void f ( ) ; if ( 1 === u && 0 === h && ! e . match ( /^url$/i ) ) return s . push ( n ) , n = "" , void ( o += t ) } o += t , 0 === u ? e += t : n += t } } ) , f ( ) , l } } , { } ] , 27 : [ function ( t , e , n ) { function r ( t ) { i . apply ( this , arguments ) , this . type = "linear" === t . args [ 0 ] ? i . TYPES . LINEAR : i . TYPES . RADIAL } var i = t ( "./gradientcontainer" ) ; r . prototype = Object . create ( i . prototype ) , e . exports = r } , { "./gradientcontainer" : 9 } ] , 28 : [ function ( t , e , n ) { function r ( t ) { return new Promise ( function ( e , n ) { var r = new XMLHttpRequest ; r . open ( "GET" , t ) , r . onload = function ( ) { 200 === r . status ? e ( r . responseText ) : n ( new Error ( r . statusText ) ) } , r . onerror = function ( ) { n ( new Error ( "Network Error" ) ) } , r . send ( ) } ) } e . exports = r } , { } ] } , { } , [ 4 ] ) ( 4 ) } ) , / *
# PNG . js
# Copyright ( c ) 2011 Devon Govett
# MIT LICENSE
#
#
* /
function ( t ) { var e ; e = function ( ) { function e ( t ) { var e , n , r , i , o , a , s , c , l , u , h , f , d , p , g ; for ( this . data = t , this . pos = 8 , this . palette = [ ] , this . imgData = [ ] , this . transparency = { } , this . animation = null , this . text = { } , a = null ; ; ) { switch ( e = this . readUInt32 ( ) , u = function ( ) { var t , e ; for ( e = [ ] , s = t = 0 ; t < 4 ; s = ++ t ) e . push ( String . fromCharCode ( this . data [ this . pos ++ ] ) ) ; return e } . call ( this ) . join ( "" ) ) { case "IHDR" : this . width = this . readUInt32 ( ) , this . height = this . readUInt32 ( ) , this . bits = this . data [ this . pos ++ ] , this . colorType = this . data [ this . pos ++ ] , this . compressionMethod = this . data [ this . pos ++ ] , this . filterMethod = this . data [ this . pos ++ ] , this . interlaceMethod = this . data [ this . pos ++ ] ; break ; case "acTL" : this . animation = { numFrames : this . readUInt32 ( ) , numPlays : this . readUInt32 ( ) || 1 / 0 , frames : [ ] } ; break ; case "PLTE" : this . palette = this . read ( e ) ; break ; case "fcTL" : a && this . animation . frames . push ( a ) , this . pos += 4 , a = { width : this . readUInt32 ( ) , height : this . readUInt32 ( ) , xOffset : this . readUInt32 ( ) , yOffset : this . readUInt32 ( ) } , o = this . readUInt16 ( ) , i = this . readUInt16 ( ) || 100 , a . delay = 1e3 * o / i , a . disposeOp = this . data [ this . pos ++ ] , a . blendOp = this . data [ this . pos ++ ] , a . data = [ ] ; break ; case "IDAT" : case "fdAT" : for ( "fdAT" === u && ( this . pos += 4 , e -= 4 ) , t = ( null != a ? a . data : void 0 ) || this . imgData , s = d = 0 ; 0 <= e ? d < e : d > e ; s = 0 <= e ? ++ d : -- d ) t . push ( this . data [ this . pos ++ ] ) ; break ; case "tRNS" : switch ( this . transparency = { } , this . colorType ) { case 3 : if ( r = this . palette . length / 3 , this . transparency . indexed = this . read ( e ) , this . transparency . indexed . length > r ) throw new Error ( "More transparent colors than palette size" ) ; if ( h = r - this . transparency . indexed . length , h > 0 ) for ( s = p = 0 ; 0 <= h ? p < h : p > h ; s = 0 <= h ? ++ p : -- p ) this . transparency . indexed . push ( 255 ) ; break ; case 0 : this . transparency . grayscale = this . read ( e ) [ 0 ] ; break ; case 2 : this . transparency . rgb = this . read ( e ) } break ; case "tEXt" : f = this . read ( e ) , c = f . indexOf ( 0 ) , l = String . fromCharCode . apply ( String , f . slice ( 0 , c ) ) , this . text [ l ] = String . fromCharCode . apply ( String , f . slice ( c + 1 ) ) ; break ; case "IEND" : return a && this . animation . frames . push ( a ) , this . colors = function ( ) { switch ( this . colorType ) { case 0 : case 3 : case 4 : return 1 ; case 2 : case 6 : return 3 } } . call ( this ) , this . hasAlphaChannel = 4 === ( g = this . colorType ) || 6 === g , n = this . colors + ( this . hasAlphaChannel ? 1 : 0 ) , this . pixelBitlength = this . bits * n , this . colorSpace = function ( ) { switch ( this . colors ) { case 1 : return "DeviceGray" ; case 3 : return "DeviceRGB" } } . call ( this ) , void ( this . imgData = new Uint8Array ( this . imgData ) ) ; default : this . pos += e } if ( this . pos += 4 , this . pos > this . data . length ) throw new Error ( "Incomplete or corrupt PNG file" ) } } var n , r , i , o , a , s , l , u ; e . load = function ( t , n , r ) { var i ; return "function" == typeof n && ( r = n ) , i = new XMLHttpRequest , i . open ( "GET" , t , ! 0 ) , i . responseType = "arraybuffer" , i . onload = function ( ) { var t , o ; return t = new Uint8Array ( i . response || i . mozResponseArrayBuffer ) , o = new e ( t ) , "function" == typeof ( null != n ? n . getContext : void 0 ) && o . render ( n ) , "function" == typeof r ? r ( o ) : void 0 } , i . send ( null ) } , o = 0 , i = 1 , a = 2 , r = 0 , n = 1 , e . prototype . read = function ( t ) { var e , n , r ; for ( r = [ ] , e = n = 0 ; 0 <= t ? n < t : n > t ; e = 0 <= t ? ++ n : -- n ) r . push ( this . data [ this . pos ++ ] ) ; return r } , e . prototype . readUInt32 = function ( ) { var t , e , n , r ; return t = this . data [ this . pos ++ ] << 24 , e = this . data [ this . pos ++ ] << 16 , n = this . data [ this . pos ++ ] << 8 , r = this . data [ this . pos ++ ] , t | e | n | r } , e . prototype . readUInt16 = function ( ) { var t , e ; return t = this . data [ this . pos ++ ] << 8 , e = this . data [ this . pos ++ ] , t | e } , e . prototype . decodePixels = function ( t ) { var e , n , r , i , o , a , s , l , u , h , f , d , p , g , m , w , y , v , b , x , k , _ , C ; if ( null == t && ( t = this . imgData ) , 0 === t . length ) return new Uint8Array ( 0 ) ; for ( t = new c ( t ) , t = t . getBytes ( ) , d = this . pixelBitlength / 8 , w = d * this . width , p = new Uint8Array ( w * this . height ) , a = t . length , m = 0 , g = 0 , n = 0 ; g < a ; ) { switch ( t [ g ++ ] ) { case 0 : for ( i = b = 0 ; b < w ; i = b += 1 ) p [ n ++ ] = t [ g ++ ] ; break ; case 1 : for ( i = x = 0 ; x < w ; i = x += 1 ) e = t [ g ++ ] , o = i < d ? 0 : p [ n - d ] , p [ n ++ ] = ( e + o ) % 256 ; break ; case 2 : for ( i = k = 0 ; k < w ; i = k += 1 ) e = t [ g ++ ] , r = ( i - i % d ) / d , y = m && p [ ( m - 1 ) * w + r * d + i % d ] , p [ n ++ ] = ( y + e ) % 256 ; break ; case 3 : for ( i = _ = 0 ; _ < w ; i = _ += 1 ) e = t [ g ++ ] , r = ( i - i % d ) / d , o = i < d ? 0 : p [ n - d ] , y = m && p [ ( m - 1 ) * w + r * d + i % d ] , p [ n ++ ] = ( e + Math . floor ( ( o + y ) / 2 ) ) % 256 ; break ; case 4 : for ( i = C = 0 ; C < w ; i = C += 1 ) e = t [ g ++ ] , r = ( i - i % d ) / d , o = i < d ? 0 : p [ n - d ] , 0 === m ? y = v = 0 : ( y = p [ ( m - 1 ) * w + r * d + i % d ] , v = r && p [ ( m - 1 ) * w + ( r - 1 ) * d + i % d ] ) , s = o + y - v , l = Math . abs ( s - o ) , h = Math . abs ( s - y ) , f = Math . abs ( s - v ) , u = l <= h && l <= f ? o : h <= f ? y : v , p [ n ++ ] = ( e + u ) % 256 ; break ; default : throw new Error ( "
* Extracted from pdf . js
* https : //github.com/andreasgal/pdf.js
*
* Copyright ( c ) 2011 Mozilla Foundation
*
* Contributors : Andreas Gal < gal @ mozilla . com >
* Chris G Jones < cjones @ mozilla . com >
* Shaon Barman < shaon . barman @ gmail . com >
* Vivien Nicolas < 21 @ vingtetun . org >
* Justin D ' Arcangelo < justindarc @ gmail . com >
* Yury Delendik
*
*
* /
var s = function ( ) { function t ( ) { this . pos = 0 , this . bufferLength = 0 , this . eof = ! 1 , this . buffer = null } return t . prototype = { ensureBuffer : function ( t ) { var e = this . buffer , n = e ? e . byteLength : 0 ; if ( t < n ) return e ; for ( var r = 512 ; r < t ; ) r <<= 1 ; for ( var i = new Uint8Array ( r ) , o = 0 ; o < n ; ++ o ) i [ o ] = e [ o ] ; return this . buffer = i } , getByte : function ( ) { for ( var t = this . pos ; this . bufferLength <= t ; ) { if ( this . eof ) return null ; this . readBlock ( ) } return this . buffer [ this . pos ++ ] } , getBytes : function ( t ) { var e = this . pos ; if ( t ) { this . ensureBuffer ( e + t ) ; for ( var n = e + t ; ! this . eof && this . bufferLength < n ; ) this . readBlock ( ) ; var r = this . bufferLength ; n > r && ( n = r ) } else { for ( ; ! this . eof ; ) this . readBlock ( ) ; var n = this . bufferLength } return this . pos = n , this . buffer . subarray ( e , n ) } , lookChar : function ( ) { for ( var t = this . pos ; this . bufferLength <= t ; ) { if ( this . eof ) return null ; this . readBlock ( ) } return String . fromCharCode ( this . buffer [ this . pos ] ) } , getChar : function ( ) { for ( var t = this . pos ; this . bufferLength <= t ; ) { if ( this . eof ) return null ; this . readBlock ( ) } return String . fromCharCode ( this . buffer [ this . pos ++ ] ) } , makeSubStream : function ( t , e , n ) { for ( var r = t + e ; this . bufferLength <= r && ! this . eof ; ) this . readBlock ( ) ; return new Stream ( this . buffer , t , e , n ) } , skip : function ( t ) { t || ( t = 1 ) , this . pos += t } , reset : function ( ) { this . pos = 0 } } , t } ( ) , c = function ( ) { function t ( t ) { throw new Error ( t ) } function e ( e ) { var n = 0 , r = e [ n ++ ] , i = e [ n ++ ] ; r != - 1 && i != - 1 || t ( "Invalid header in flate stream" ) , 8 != ( 15 & r ) && t ( "Unknown compression method in flate stream" ) , ( ( r << 8 ) + i ) % 31 != 0 && t ( "Bad FCHECK in flate stream" ) , 32 & i && t ( "FDICT bit set in flate stream" ) , this . bytes = e , this . bytesPos = n , this . codeSize = 0 , this . codeBuf = 0 , s . call ( this ) } if ( "undefined" != typeof Uint32Array ) { var n = new Uint32Array ( [ 16 , 17 , 18 , 0 , 8 , 7 , 9 , 6 , 10 , 5 , 11 , 4 , 12 , 3 , 13 , 2 , 14 , 1 , 15 ] ) , r = new Uint32Array ( [ 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 65547 , 65549 , 65551 , 65553 , 131091 , 131095 , 131099 , 131103 , 196643 , 196651 , 196659 , 196667 , 262211 , 262227 , 262243 , 262259 , 327811 , 327843 , 327875 , 327907 , 258 , 258 , 258 ] ) , i = new Uint32Array ( [ 1 , 2 , 3 , 4 , 65541 , 65543 , 131081 , 131085 , 196625 , 196633 , 262177 , 262193 , 327745 , 327777 , 393345 , 393409 , 459009 , 459137 , 524801 , 525057 , 590849 , 591361 , 657409 , 658433 , 724993 , 727041 , 794625 , 798721 , 868353 , 876545 ] ) , o = [ new Uint32Array ( [ 459008 , 524368 , 524304 , 524568 , 459024 , 524400 , 524336 , 590016 , 459016 , 524384 , 524320 , 589984 , 524288 , 524416 , 524352 , 590048 , 459012 , 524376 , 524312 , 589968 , 459028 , 524408 , 524344 , 590032 , 459020 , 524392 , 524328 , 59e4 , 524296 , 524424 , 524360 , 590064 , 459010 , 524372 , 524308 , 524572 , 459026 , 524404 , 524340 , 590024 , 459018 , 524388 , 524324 , 589992 , 524292 , 524420 , 524356 , 590056 , 459014 , 524380 , 524316 , 589976 , 459030 , 524412 , 524348 , 590040 , 459022 , 524396 , 524332 , 590008 , 524300 , 524428 , 524364 , 590072 , 459009 , 524370 , 524306 , 524570 , 459025 , 524402 , 524338 , 590020 , 459017 , 524386 , 524322 , 589988 , 524290 , 524418 , 524354 , 590052 , 459013 , 524378 , 524314 , 589972 , 459029 , 524410 , 524346 , 590036 , 459021 , 524394 , 524330 , 590004 , 524298 , 524426 , 524362 , 590068 , 459011 , 524374 , 524310 , 524574 , 459027 , 524406 , 524342 , 590028 , 459019 , 524390 , 524326 , 589996 , 524294 , 524422 , 524358 , 590060 , 459015 , 524382 , 524318 , 589980 , 459031 , 524414 , 524350 , 590044 , 459023 , 524398 , 524334 , 590012 , 524302 , 524430 , 524366 , 590076 , 459008 , 524369 , 524305 , 524569 , 459024 , 524401 , 524337 , 590018 , 459016 , 524385 , 524321 , 589986 , 524289 , 524417 , 524353 , 590050 , 459012 , 524377 , 524313 , 589970 , 459028 , 524409 , 524345 , 590034 , 459020 , 524393 , 524329 , 590002 , 524297 , 524425 , 524361 , 590066 , 459010 , 524373 , 524309 , 524573 , 459026 , 524405 , 524341 , 590026 , 459018 , 524389 , 524325 , 589994 , 524293 , 524421 , 524357 , 590058 , 459014 , 524381 , 524317 , 589978 , 459030 , 524413 , 524349 , 590042 , 459022 , 524397 , 524333 , 590010 , 524301 , 524429 , 524365 , 590074 , 459009 , 524371 , 524307 , 524571 , 459025 , 524403 , 524339 , 590022 , 459017 , 524387 , 524323 , 589990 , 524291 , 524419 , 524355 , 590054 , 459013 , 524379 , 524315 , 589974 , 459029 , 524411 , 524347 , 590038 , 459021 , 524395 , 524331 , 590006 , 524299 , 524427 , 524363 , 590070 , 459011 , 524375 , 524311 , 524575 , 459027 , 524407 , 524343 , 590030 , 459019 , 524391 , 524327 , 589998 , 524295 , 524423 , 524359 , 590062 , 459015 , 524383 , 524319 , 589982 , 459031 , 524415 , 524351 , 590046 , 459023 , 524399 , 524335 , 590014 , 524303 , 524431 , 524367 , 590078 , 459008 , 524368 , 524304 , 524568 , 459024 , 524400 , 524336 , 590017 , 459016 , 524384 , 524320 , 589985 , 524288 , 524416 , 524352 , 590049 , 459012 , 524376 , 524312 , 589969 , 459028 , 524408 , 524344 , 590033 , 459020 , 524392 , 524328 , 590001 , 524296 , 524424 , 524360 , 59
/ * *
* jsPDF AutoTable plugin v2 . 0.14
* Copyright ( c ) 2014 Simon Bengtsson , https : //github.com/simonbengtsson/jsPDF-AutoTable
*
* Licensed under the MIT License .
* http : //opensource.org/licenses/mit-license
*
* @ preserve
* /
"use strict" ; function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) } } ( function ( API ) { "use strict" ; var FONT _ROW _RATIO = 1.15 ; var doc , cursor , settings , pageCount , table ; var defaultStyles = { cellPadding : 5 , fontSize : 10 , font : "helvetica" , lineColor : 200 , lineWidth : . 1 , fontStyle : "normal" , overflow : "ellipsize" , fillColor : 255 , textColor : 20 , halign : "left" , valign : "top" , fillStyle : "F" , rowHeight : 20 , columnWidth : "auto" } ; var themes = { striped : { table : { fillColor : 255 , textColor : 80 , fontStyle : "normal" , fillStyle : "F" } , header : { textColor : 255 , fillColor : [ 41 , 128 , 185 ] , rowHeight : 23 , fontStyle : "bold" } , body : { } , alternateRow : { fillColor : 245 } } , grid : { table : { fillColor : 255 , textColor : 80 , fontStyle : "normal" , lineWidth : . 1 , fillStyle : "DF" } , header : { textColor : 255 , fillColor : [ 26 , 188 , 156 ] , rowHeight : 23 , fillStyle : "F" , fontStyle : "bold" } , body : { } , alternateRow : { } } , plain : { header : { fontStyle : "bold" } } } ; var defaultOptions = function defaultOptions ( ) { return { theme : "striped" , styles : { } , headerStyles : { } , bodyStyles : { } , alternateRowStyles : { } , columnStyles : { } , startY : false , margin : 40 , pageBreak : "auto" , tableWidth : "auto" , createdHeaderCell : function createdHeaderCell ( cell , data ) { } , createdCell : function createdCell ( cell , data ) { } , drawHeaderRow : function drawHeaderRow ( row , data ) { } , drawRow : function drawRow ( row , data ) { } , drawHeaderCell : function drawHeaderCell ( cell , data ) { } , drawCell : function drawCell ( cell , data ) { } , beforePageContent : function beforePageContent ( data ) { } , afterPageContent : function afterPageContent ( data ) { } } } ; API . autoTable = function ( headers , data , options ) { doc = this ; settings = initOptions ( options || { } ) ; pageCount = 1 ; cursor = { y : settings . startY === false ? settings . margin . top : settings . startY } ; var userStyles = { textColor : 30 , fontSize : doc . internal . getFontSize ( ) , fontStyle : doc . internal . getFont ( ) . fontStyle } ; createModels ( headers , data ) ; calculateWidths ( ) ; var firstRowHeight = table . rows [ 0 ] && settings . pageBreak === "auto" ? table . rows [ 0 ] . height : 0 ; var minTableBottomPos = settings . startY + settings . margin . bottom + table . headerRow . height + firstRowHeight ; if ( settings . pageBreak === "avoid" ) { minTableBottomPos += table . height } if ( settings . pageBreak === "always" && settings . startY !== false || settings . startY !== false && minTableBottomPos > doc . internal . pageSize . height ) { doc . addPage ( ) ; cursor . y = settings . margin . top } applyStyles ( userStyles ) ; settings . beforePageContent ( hooksData ( ) ) ; if ( settings . drawHeaderRow ( table . headerRow , hooksData ( { row : table . headerRow } ) ) !== false ) { printRow ( table . headerRow , settings . drawHeaderCell ) } applyStyles ( userStyles ) ; printRows ( ) ; settings . afterPageContent ( hooksData ( ) ) ; applyStyles ( userStyles ) ; return this } ; API . autoTableEndPosY = function ( ) { if ( typeof cursor === "undefined" || typeof cursor . y === "undefined" ) { return 0 } return cursor . y } ; API . autoTableHtmlToJson = function ( table ) { var data = [ ] , headers = [ ] , header = table . rows [ 0 ] , tableRow , rowData , i , j ; for ( i = 0 ; i < header . cells . length ; i ++ ) { headers . push ( typeof header . cells [ i ] !== "undefined" ? header . cells [ i ] . textContent : "" ) } for ( i = 1 ; i < table . rows . length ; i ++ ) { tableRow = table . rows [ i ] ; rowData = [ ] ; for ( j = 0 ; j < header . cells . length ; j ++ ) { rowData . push ( typeof tableRow . cells [ j ] !== "undefined" ? tableRow . cells [ j ] . textContent : "" ) } data . push ( rowData ) } return { columns : headers , data : data , rows : data } } ; API . autoTableText = function ( text , x , y , styles ) { if ( typeof x !== "number" || typeof y !== "number" ) { console . error ( "The x and y parameters are required. Missing for the text: " , text ) } var fontSize = doc . internal . getFontSize ( ) / doc . internal . scaleFactor ; var lineHeightProportion = FONT _ROW _RATIO ; var splitRegex = /\r\n|\r|\n/g ; var splittedText = null ; var lineCount = 1 ; if ( styles . valign === "middle" || styles . valign === "bottom" || styles . halign === "center" || styles . halign === "right" ) { splittedText = typeof text === "string" ? text . split ( splitRegex ) : text ; lineCount = splittedText . length || 1 } y += fontSize * ( 2 - lineHeightProportion ) ; if ( styles . valign === "middle" ) y -= lineCount / 2 * fontSize ; else if ( styles . valign === "bottom" ) y -= lineCount * fontSize ; if ( styles . halign === "center" || styles . halign === "right" ) { var alignSize = fontSize ; if ( styles . halign === "center" ) alignSize *= . 5 ; if ( lineCount >= 1 ) { for ( var iLine = 0 ; iLine < splittedText . length ; iLine ++ ) { doc . text ( splittedText [ iLine ] , x - doc . getStringUnitWid