Skip to content

Commit

Permalink
add headerStyle optional param
Browse files Browse the repository at this point in the history
  • Loading branch information
crabbly committed Oct 12, 2017
1 parent eb733ff commit 6d18889
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/print.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "print-js",
"homepage": "http://printjs.crabbly.com",
"description": "A tiny javascript library to help printing from the web.",
"version": "1.0.20",
"version": "1.0.21",
"main": "src/index.js",
"repository": "https://github.com/crabbly/Print.js",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function loopNodesCollectStyles (elements, params) {
}
}

export function addHeader (printElement, header) {
export function addHeader (printElement, header, headerStyle) {
// Create header element
let headerElement = document.createElement('h1')

Expand All @@ -110,7 +110,7 @@ export function addHeader (printElement, header) {

// Build and style
headerElement.appendChild(headerNode)
headerElement.setAttribute('style', 'font-weight:300;')
headerElement.setAttribute('style', headerStyle)

printElement.insertBefore(headerElement, printElement.childNodes[0])
}
2 changes: 1 addition & 1 deletion src/js/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default {

// Add header if any
if (params.header) {
addHeader(printableElement, params.header)
addHeader(printableElement, params.header, params.headerStyle)
}

// Remove DOM printableElement
Expand Down
2 changes: 1 addition & 1 deletion src/js/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {

// Check if we are adding a header for the image
if (params.header) {
addHeader(printableElement)
addHeader(printableElement, params.header, params.headerStyle)
}

// Store html data
Expand Down
2 changes: 2 additions & 0 deletions src/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
printable: null,
type: 'pdf',
header: null,
headerStyle: 'font-weight: 300;',
maxWidth: 800,
font: 'TimesNewRoman',
font_size: '12pt',
Expand Down Expand Up @@ -45,6 +46,7 @@ export default {
params.type = typeof args.type !== 'undefined' ? args.type : params.type
params.frameId = typeof args.frameId !== 'undefined' ? args.frameId : params.frameId
params.header = typeof args.header !== 'undefined' ? args.header : params.header
params.headerStyle = typeof args.headerStyle !== 'undefined' ? args.headerStyle : params.headerStyle
params.maxWidth = typeof args.maxWidth !== 'undefined' ? args.maxWidth : params.maxWidth
params.font = typeof args.font !== 'undefined' ? args.font : params.font
params.font_size = typeof args.font_size !== 'undefined' ? args.font_size : params.font_size
Expand Down
2 changes: 1 addition & 1 deletion src/js/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {

// Check print has header
if (params.header) {
htmlData += '<h1 style="font-weight:300;">' + params.header + '</h1>'
htmlData += '<h1 style="' + params.headerStyle + '">' + params.header + '</h1>'
}

// Function to build html templates for json data
Expand Down

0 comments on commit 6d18889

Please sign in to comment.