1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-13 15:15:57 +00:00

Removing save warning from new page

This commit is contained in:
Scott Tolksdorf
2016-11-14 19:45:02 -05:00
parent 582deb7bf7
commit 5f6f7ec691
2 changed files with 16 additions and 27 deletions

View File

@@ -1,26 +1,25 @@
var React = require('react'); const React = require('react');
var _ = require('lodash'); const _ = require('lodash');
var cx = require('classnames'); const cx = require('classnames');
var request = require("superagent"); const request = require("superagent");
var Markdown = require('naturalcrit/markdown.js'); const Markdown = require('naturalcrit/markdown.js');
var Nav = require('naturalcrit/nav/nav.jsx'); const Nav = require('naturalcrit/nav/nav.jsx');
var Navbar = require('../../navbar/navbar.jsx'); const Navbar = require('../../navbar/navbar.jsx');
var EditTitle = require('../../navbar/editTitle.navitem.jsx'); const EditTitle = require('../../navbar/editTitle.navitem.jsx');
var IssueNavItem = require('../../navbar/issue.navitem.jsx'); const IssueNavItem = require('../../navbar/issue.navitem.jsx');
var SplitPane = require('naturalcrit/splitPane/splitPane.jsx'); const SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
var Editor = require('../../editor/editor.jsx'); const Editor = require('../../editor/editor.jsx');
var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx'); const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
const KEY = 'homebrewery-new'; const KEY = 'homebrewery-new';
var NewPage = React.createClass({ const NewPage = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {
ver : '0.0.0',
title : '', title : '',
text: '', text: '',
isSaving : false, isSaving : false,
@@ -30,23 +29,13 @@ var NewPage = React.createClass({
componentDidMount: function() { componentDidMount: function() {
var storage = localStorage.getItem(KEY); const storage = localStorage.getItem(KEY);
if(storage){ if(storage){
this.setState({ this.setState({
text : storage text : storage
}) })
} }
window.onbeforeunload = (e)=>{
if(this.state.text == '') return;
return "Your homebrew isn't saved. Are you sure you want to leave?";
};
}, },
componentWillUnmount: function() {
window.onbeforeunload = function(){};
},
handleSplitMove : function(){ handleSplitMove : function(){
this.refs.editor.update(); this.refs.editor.update();
}, },
@@ -84,7 +73,7 @@ var NewPage = React.createClass({
return; return;
} }
window.onbeforeunload = function(){}; window.onbeforeunload = function(){};
var brew = res.body; const brew = res.body;
localStorage.removeItem(KEY); localStorage.removeItem(KEY);
window.location = '/edit/' + brew.editId; window.location = '/edit/' + brew.editId;
}) })

View File

@@ -1,7 +1,7 @@
{ {
"name": "homebrewery", "name": "homebrewery",
"description": "Create authentic looking D&D homebrews using only markdown", "description": "Create authentic looking D&D homebrews using only markdown",
"version": "2.4.0", "version": "2.4.1",
"scripts": { "scripts": {
"build": "node_modules/.bin/gulp prod", "build": "node_modules/.bin/gulp prod",
"watch": "node_modules/.bin/gulp", "watch": "node_modules/.bin/gulp",