diff --git a/src/index.html b/src/index.html index 84f07c3..43c4a8a 100644 --- a/src/index.html +++ b/src/index.html @@ -829,6 +829,7 @@ + diff --git a/src/js/Canvas.js b/src/js/Canvas.js index 031f05b..c6286a9 100644 --- a/src/js/Canvas.js +++ b/src/js/Canvas.js @@ -151,6 +151,8 @@ MD.Canvas = function(){ } } + rename(state.get("canvasTitle")); + this.resize = resize; this.update = update; this.rename = rename; diff --git a/src/js/modals.js b/src/js/modals.js new file mode 100644 index 0000000..a066d3a --- /dev/null +++ b/src/js/modals.js @@ -0,0 +1,85 @@ +// globals +const svgCanvas = new $.SvgCanvas(document.getElementById("svgcanvas")); +const editor = new MD.Editor(); +const state = new State(); + +editor.modal = { + about: new MD.Modal({ + html: ` +

About this application

+

Method Draw is a simple open source vector drawing application. Method Draw was forked from SVG-Edit several years ago with the goal of improving and modernizing the interface.

+

At this time (2021), the author (Mark MacKay) is working on improving stability and improving the codebase, which contains a lot of legacy practices. The goal is to create a vector editor suitable for simple graphic design tasks.

+ ` + }), + source: new MD.Modal({ + html: ` +
+
+
+
+ +
+
+ + +
+
+
`, + js: function(el){ + el.children[0].classList.add("modal-item-source"); + el.querySelector("#tool_source_save").addEventListener("click", function(){ + var saveChanges = function() { + svgCanvas.clearSelection(); + $('#svg_source_textarea').blur(); + editor.zoom.multiply(1); + editor.rulers.update(); + editor.paintBox.fill.prep(); + editor.paintBox.stroke.prep(); + editor.modal.source.close(); + } + + if (!svgCanvas.setSvgString($('#svg_source_textarea').val())) { + $.confirm("There were parsing errors in your SVG source.\nRevert back to original SVG source?", function(ok) { + if(!ok) return false; + saveChanges(); + }); + } else { + saveChanges(); + } + }) + el.querySelector("#tool_source_cancel").addEventListener("click", function(){ + editor.modal.source.close(); + }); + } + }), + configure: new MD.Modal({ + html: ` +

Configuration

+
+ +
+ `, + js: function(el){ + const input = el.querySelector("#configuration button.warning"); + input.addEventListener("click", function(){ + state.clean(); + }) + } + }), + donate: new MD.Modal({ + html: ` +

Donate

+

+ Method Draw relies on your generous donations for continued development. + Donate now if you find this application useful. +

` + }), + shortcuts: new MD.Modal({ + html: ` +

Shortcuts

+
`, + js: function(el){ + el.children[0].classList.add("modal-item-wide"); + } + }) +}; \ No newline at end of file diff --git a/src/js/start.js b/src/js/start.js index 7e8867e..aa83d30 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -1,89 +1,3 @@ -// globals -const svgCanvas = new $.SvgCanvas(document.getElementById("svgcanvas")); -const editor = new MD.Editor(); -const state = new State(); - -editor.modal = { - about: new MD.Modal({ - html: ` -

About this application

-

Method Draw is a simple open source vector drawing application. Method Draw was forked from SVG-Edit several years ago with the goal of improving and modernizing the interface.

-

At this time (2021), the author (Mark MacKay) is working on improving stability and improving the codebase, which contains a lot of legacy practices. The goal is to create a vector editor suitable for simple graphic design tasks.

- ` - }), - source: new MD.Modal({ - html: ` -
-
-
-
- -
-
- - -
-
-
`, - js: function(el){ - el.children[0].classList.add("modal-item-source"); - el.querySelector("#tool_source_save").addEventListener("click", function(){ - var saveChanges = function() { - svgCanvas.clearSelection(); - $('#svg_source_textarea').blur(); - editor.zoom.multiply(1); - editor.rulers.update(); - editor.paintBox.fill.prep(); - editor.paintBox.stroke.prep(); - editor.modal.source.close(); - } - - if (!svgCanvas.setSvgString($('#svg_source_textarea').val())) { - $.confirm("There were parsing errors in your SVG source.\nRevert back to original SVG source?", function(ok) { - if(!ok) return false; - saveChanges(); - }); - } else { - saveChanges(); - } - }) - el.querySelector("#tool_source_cancel").addEventListener("click", function(){ - editor.modal.source.close(); - }); - } - }), - configure: new MD.Modal({ - html: ` -

Configuration

-
- -
- `, - js: function(el){ - const input = el.querySelector("#configuration button.warning"); - input.addEventListener("click", function(){ - state.clean(); - }) - } - }), - donate: new MD.Modal({ - html: ` -

Donate

-

- Method Draw relies on your generous donations for continued development. - Donate now if you find this application useful. -

` - }), - shortcuts: new MD.Modal({ - html: ` -

Shortcuts

-
`, - js: function(el){ - el.children[0].classList.add("modal-item-wide"); - } - }) -}; - editor.keyboard = new MD.Keyboard(); editor.menu = new MD.Menu(); editor.toolbar = new MD.Toolbar();