Skip to content

Commit

Permalink
Rename printPage function to printCurrentBrew()
Browse files Browse the repository at this point in the history
Avoid confusion with other "page" components.
  • Loading branch information
calculuschild committed May 28, 2024
1 parent 01d60c4 commit 8a55658
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions client/homebrew/brewRenderer/brewRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx');
const NotificationPopup = require('./notificationPopup/notificationPopup.jsx');
const Frame = require('react-frame-component').default;
const dedent = require('dedent-tabs').default;
const { printPage } = require('../../../shared/helpers.js');
const { printCurrentBrew } = require('../../../shared/helpers.js');

const DOMPurify = require('dompurify');
const purifyConfig = { FORCE_BODY: true, SANITIZE_DOM: false };
Expand Down Expand Up @@ -163,7 +163,7 @@ const BrewRenderer = (props)=>{
const handleControlKeys = (e)=>{
if(!(e.ctrlKey || e.metaKey)) return;
const P_KEY = 80;
if(e.keyCode == P_KEY && props.allowPrint) printPage();
if(e.keyCode == P_KEY && props.allowPrint) printCurrentBrew();
if(e.keyCode == P_KEY) {
e.stopPropagation();
e.preventDefault();
Expand Down
4 changes: 2 additions & 2 deletions client/homebrew/navbar/print.navitem.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const React = require('react');
const Nav = require('naturalcrit/nav/nav.jsx');
const { printPage } = require('../../../shared/helpers.js');
const { printCurrentBrew } = require('../../../shared/helpers.js');

module.exports = function(){
return <Nav.item onClick={printPage} color='purple' icon='far fa-file-pdf'>
return <Nav.item onClick={printCurrentBrew} color='purple' icon='far fa-file-pdf'>
get PDF
</Nav.item>;
};
4 changes: 2 additions & 2 deletions client/homebrew/pages/editPage/editPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
const Markdown = require('naturalcrit/markdown.js');

const { DEFAULT_BREW_LOAD } = require('../../../../server/brewDefaults.js');
const { printPage } = require('../../../../shared/helpers.js');
const { printCurrentBrew } = require('../../../../shared/helpers.js');

const googleDriveIcon = require('../../googleDrive.svg');

Expand Down Expand Up @@ -96,7 +96,7 @@ const EditPage = createClass({
const S_KEY = 83;
const P_KEY = 80;
if(e.keyCode == S_KEY) this.trySave(true);
if(e.keyCode == P_KEY) printPage();
if(e.keyCode == P_KEY) printCurrentBrew();
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
e.stopPropagation();
e.preventDefault();
Expand Down
4 changes: 2 additions & 2 deletions client/homebrew/pages/newPage/newPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Editor = require('../../editor/editor.jsx');
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');

const { DEFAULT_BREW } = require('../../../../server/brewDefaults.js');
const { printPage } = require('../../../../shared/helpers.js');
const { printCurrentBrew } = require('../../../../shared/helpers.js');

const BREWKEY = 'homebrewery-new';
const STYLEKEY = 'homebrewery-new-style';
Expand Down Expand Up @@ -91,7 +91,7 @@ const NewPage = createClass({
const S_KEY = 83;
const P_KEY = 80;
if(e.keyCode == S_KEY) this.save();
if(e.keyCode == P_KEY) printPage();
if(e.keyCode == P_KEY) printCurrentBrew();
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
e.stopPropagation();
e.preventDefault();
Expand Down
4 changes: 2 additions & 2 deletions client/homebrew/pages/sharePage/sharePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Account = require('../../navbar/account.navitem.jsx');
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');

const { DEFAULT_BREW_LOAD } = require('../../../../server/brewDefaults.js');
const { printPage } = require('../../../../shared/helpers.js');
const { printCurrentBrew } = require('../../../../shared/helpers.js');

const SharePage = createClass({
displayName : 'SharePage',
Expand All @@ -34,7 +34,7 @@ const SharePage = createClass({
if(!(e.ctrlKey || e.metaKey)) return;
const P_KEY = 80;
if(e.keyCode == P_KEY){
if(e.keyCode == P_KEY) printPage();
if(e.keyCode == P_KEY) printCurrentBrew();
e.stopPropagation();
e.preventDefault();
}
Expand Down
4 changes: 2 additions & 2 deletions shared/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const splitTextStyleAndMetadata = (brew)=>{
}
};

const printPage = ()=>{
const printCurrentBrew = ()=>{
if(window.typeof !== 'undefined') {
window.frames['BrewRenderer'].contentWindow.print();
//Force DOM reflow; Print dialog causes a repaint, and @media print CSS somehow makes out-of-view pages disappear
Expand All @@ -30,5 +30,5 @@ const printPage = ()=>{

module.exports = {
splitTextStyleAndMetadata,
printPage
printCurrentBrew
};

0 comments on commit 8a55658

Please sign in to comment.