From: Vincent Vanwaelscappel Date: Wed, 6 Jun 2018 10:51:19 +0000 (+0200) Subject: wip #1998 @4 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=49cf4600cd68adca0f80191d2391c33313213390;p=fluidbook-html5.git wip #1998 @4 --- diff --git a/js/libs/fluidbook/forms/fluidbook.form.bourbon.js b/js/libs/fluidbook/forms/fluidbook.form.bourbon.js index a2089f06..852d9702 100644 --- a/js/libs/fluidbook/forms/fluidbook.form.bourbon.js +++ b/js/libs/fluidbook/forms/fluidbook.form.bourbon.js @@ -1,5 +1,6 @@ function FluidbookBourbonForm(fluidbook) { this.fluidbook = fluidbook; + this.formInstance; this.init(); } @@ -9,10 +10,73 @@ FluidbookBourbonForm.prototype = { this.fluidbook.menu.openSuggest = this.openSuggest; + $(document).on('click', '.cart-bourbon-suggest .submit', function () { + $this.formInstance = $(".cart-bourbon-suggest").parsley(); + if ($this.formInstance.validate()) { + $this.sendSuggestion(); + } + return false; + }); + }, openSuggest: function (p1, p2, callback) { + var view = '
' + this.closeButton() + '

Suggest a mondification

'; + view += '
'; + view += '
'; + view += '
'; + view += ''; + view += ''; + view += ''; + view += '
'; + view += ''; + view += '
'; + view += '
'; + + $("#view").append('
' + view + '
'); callback(); - } + }, + sendSuggestion: function () { + var $this = this; + console.log('sendSuggestion'); + var fs = require('fs'); + var path = require('path'); + + var file = 'suggestion.txt'; + var filePath = path.join(nw.App.dataPath, file); + var data = $("#bourbon-suggestion-page").val() + "/|!/" + Date.now() +"/|!/" + $("#bourbon-suggestion-type").val()+ "/|!/" +$("#bourbon-suggestion-body").val(); + console.log('Data to send: ' + data); + this.fluidbook.displayLoader(); + fs.writeFile(filePath, data, function (err) { + if (err) { + console.info("There was an error attempting to save your data."); + console.warn(err.message); + return; + } else { + console.log('File written'); + var exec = require('child_process').exec; + var path = require('path'); + var cmd = '"' + path.join(process.cwd(), 'exe/sendemail.exe') + '" "bourbon+2018@fluidbook.com" "Bourbon SMS Suggestion" "Please see attached suggestion" "' + filePath + '" "' + file + '"'; + console.log('exec ' + cmd); + exec(cmd, function (error, stdout, stderr) { + $this.fluidbook.hideLoader(); + if (error) { + console.error("exec error: ${error}"); + return; + } + console.log('output: ' + stdout.toString()); + console.log('Email sent'); + $(".cart-bourbon-suggest").html('
Your suggestion has been added in your Outlook outbox. It will be effectively sent as you as Outlook will get an internet connection.
'); + resize(); + }); + } + }); + }, }; \ No newline at end of file diff --git a/style/fluidbook.less b/style/fluidbook.less index 1c6c1f46..bc660137 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -2346,7 +2346,6 @@ ul.chapters { #tooltip { @tooltip-arrows-size: 10px; - position: absolute; background-color: @tooltip-background; color: @tooltip-color; @@ -2654,6 +2653,41 @@ body > input { } } +.cart-bourbon-suggest { + + padding: 30px; + width: 100%; + + label { + margin-bottom: 15px; + display: block; + text-align: left; + } + + input, textarea, select { + border: 2px solid #fff; + width: 100%; + padding: 8px; + display: block; + margin-top: 5px; + font-family: @font; + font-size: 14px; + &.parsley-error { + border-color: #cc0000; + } + + } + + .parsley-errors-list { + display: none; + } + + .fonctions { + padding: 20px 0 0 0; + } + +} + /* Webfonts*/ @font-face {