]> _ Git - fluidbook-html5.git/commitdiff
wip #1998 @4
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Jun 2018 10:51:19 +0000 (12:51 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Jun 2018 10:51:19 +0000 (12:51 +0200)
js/libs/fluidbook/forms/fluidbook.form.bourbon.js
style/fluidbook.less

index a2089f066433b7d7e0e08d749a35e9fd870520d5..852d9702afbe083ad3da65e6d14c3a2106f3df3b 100644 (file)
@@ -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 = '<div class="caption">' + this.closeButton() + '<h2>Suggest a mondification</h2></div>';
+        view += '<div class="content">';
+        view += '<form class="cart-bourbon-suggest" action="" method="post">';
+        view += '<div>';
+        view += '<label>Page number';
+        view += '<input type="text" id="bourbon-suggestion-page" data-parsley-type="integer" name="page" value="' + this.fluidbook.currentPage + '" min="0" max="' + this.fluidbook.datas.pages + '" tabindex="100" required>';
+        view += '</label>';
+        view += '<label>Suggestion type';
+        view += '<select id="bourbon-suggestion-type"><option>TYPO / WORDING</option><option>CLARIFICATION REQUEST</option><option>OTHERS (Improvement, etc)</option></select>';
+        view += '</label>';
+        view += '<label>Suggestion';
+        view += '<textarea cols="100" rows="20" tabindex="101" id="bourbon-suggestion-body" name="suggestion" required></textarea>';
+        view += '</label>';
+        view += '</div>';
+        view += '<div class="fonctions"><a href="#" class="submit">Send the suggestion</a></div>';
+        view += '</form>';
+        view += '</div>';
+
+        $("#view").append('<div class="mview" data-menu="suggest">' + view + '</div>');
 
         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('<div class="message">Your suggestion has been added in your Outlook outbox. It will be effectively sent as you as Outlook will get an internet connection.</div>');
+                    resize();
+                });
+            }
+        });
+    },
 };
\ No newline at end of file
index 1c6c1f46a931312f1088ee9d3543319b2c9ab015..bc6601371d4031401c04424379de0d7c9239b2d1 100644 (file)
@@ -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 {