diff --git a/NOTICE.txt b/NOTICE.txt index 885d7d2..4688bd0 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,6 +1,7 @@ Doodle3D uses the following external projects: Garden font - Copyright (c) 2012 So-ghislaine - "Garden is a free font for commercial and personal use." +Copse font - Copyright (c) 2010 Dan Rhatigan - SIL Open Font License v1.10 jQuery - Copyright (c) 2005, 2012 jQuery Foundation, Inc. and other contributors - MIT License jQuery-cookie - Copyright (c) 2011, Klaus Hartl - MIT or GPLv2 jQuery-coolfieldset - Copyright (c) 2010 Lucky - GPL diff --git a/js/AddShapeDialog.js b/js/AddShapeDialog.js index 286e904..5a1ebce 100644 --- a/js/AddShapeDialog.js +++ b/js/AddShapeDialog.js @@ -2,15 +2,15 @@ var shapeResolution=3; var shapePopup; function initShapeDialog() { - $("#btnShapeOk").on("onButtonClick",onShapeOk); - $("#btnShapeCancel").on("onButtonClick",onShapeCancel); + shapePopup = new Popup($("#popupShape"), $("#popupMask")); + $("#btnShapeOk").on("onButtonClick", shapePopup.commit); + $("#btnShapeCancel").on("onButtonClick", shapePopup.cancel); + $("#popupShape").bind("onPopupCancel", onShapeCancel); + $("#popupShape").bind("onPopupCommit", onShapeOk); + $("#btnShapePlus").on("onButtonHold",onShapePlus); $("#btnShapeMin").on("onButtonHold",onShapeMin); updateShapePreview(); - - shapePopup = new Popup($("#popupShape"), $("#popupMask")); - shapePopup.setEscapeKeyHandler(onShapeCancel); - shapePopup.setEnterKeyHandler(onShapeOk); } function showShapeDialog() { @@ -18,12 +18,9 @@ function showShapeDialog() { } function onShapeCancel() { - shapePopup.close(); } function onShapeOk() { - shapePopup.close(); - var res = shapeResolution; if (res!=undefined) { diff --git a/js/Popup.js b/js/Popup.js index bbf1635..053c3b0 100644 --- a/js/Popup.js +++ b/js/Popup.js @@ -1,7 +1,5 @@ function Popup(element, mask) { var self = this; - var escapeKeyHandler = null; - var enterKeyHandler = null; this.open = function(complete, disableMaskClick) { mask.fadeIn(POPUP_SHOW_DURATION); @@ -11,9 +9,9 @@ function Popup(element, mask) { keyboardEscapeEnterEnabled = true; document.body.removeEventListener('touchmove', prevent, false); - mask.bind("onButtonClick", function() { self.close() }); - if (escapeKeyHandler) $(document).bind("onEscapeKey", escapeKeyHandler); - if (enterKeyHandler) $(document).bind("onEnterKey", enterKeyHandler); + mask.bind("onButtonClick", self.cancel); + $(document).bind("onEscapeKey", self.cancel); + $(document).bind("onEnterKey", self.commit); } this.close = function(complete) { @@ -24,11 +22,18 @@ function Popup(element, mask) { keyboardEscapeEnterEnabled = false; document.body.addEventListener('touchmove', prevent, false); - mask.unbind("onButtonClick"); - if (escapeKeyHandler) $(document).unbind("onEscapeKey", escapeKeyHandler); - if (enterKeyHandler) $(document).unbind("onEnterKey", enterKeyHandler); + mask.unbind("onButtonClick", self.cancel); + $(document).unbind("onEscapeKey", self.cancel); + $(document).unbind("onEnterKey", self.commit); } - this.setEscapeKeyHandler = function(hnd) { escapeKeyHandler = hnd; } - this.setEnterKeyHandler = function(hnd) { enterKeyHandler = hnd; } + this.cancel = function() { + self.close(); + $(element).trigger('onPopupCancel'); + } + + this.commit = function() { + self.close(); + $(element).trigger('onPopupCommit'); + } } \ No newline at end of file diff --git a/js/WordArt.js b/js/WordArt.js index 105b4cd..8cb49ef 100644 --- a/js/WordArt.js +++ b/js/WordArt.js @@ -3,12 +3,12 @@ var wordArtPopup; function initWordArt() { $("body").append(''); $("#svgfont").load("img/font.svg?"); - $("#btnWordArtOk").on("onButtonClick",onWordArtOk); - $("#btnWordArtCancel").on("onButtonClick",onWordArtCancel); wordArtPopup = new Popup($("#popupWordArt"),$("#popupMask")); - wordArtPopup.setEscapeKeyHandler(onWordArtCancel); - wordArtPopup.setEnterKeyHandler(onWordArtOk); + $("#btnWordArtOk").on("onButtonClick",wordArtPopup.commit); + $("#btnWordArtCancel").on("onButtonClick",wordArtPopup.cancel); + $("#popupWordArt").bind("onPopupCancel", onWordArtCancel); + $("#popupWordArt").bind("onPopupCommit", onWordArtOk); } function showWordArtDialog() { @@ -19,13 +19,13 @@ function showWordArtDialog() { } function onWordArtCancel() { - wordArtPopup.close(); + $("#txtWordArt").blur(); } function onWordArtOk() { - wordArtPopup.close(); - var s = $("#txtWordArt").val(); - drawTextOnCanvas(s); + $("#txtWordArt").blur(); + var s = $("#txtWordArt").val(); + drawTextOnCanvas(s); } function drawTextOnCanvas(text) {