Commit bec81dab authored by bbaer's avatar bbaer
Browse files

added outputfield and parentdata.

parent 747e5f56
......@@ -17,10 +17,12 @@ var QfqNS = QfqNS || {};
$(function (n) {
n.Fabric = function() {
this.parentElement = {};
this.controlElement = {};
this.emojiContainer = {};
this.textContainer = {};
this.userTextInput = {};
this.outputField = {};
this.canvas = {};
this.activeColor = {red: 0, green: 68, blue: 255, opacity: 1};
this.brushSize = 2;
......@@ -232,6 +234,9 @@ $(function (n) {
n.Fabric.prototype.initialize = function($fabricElement) {
var jsonButtons = $fabricElement.data('buttons');
var jsonEmojis = $fabricElement.data('emojis');
var inputField = $fabricElement.data('control-name');
this.parentElement = $fabricElement;
this.outputField = $(inputField);
this.modeSettings.initialize(this, jsonButtons);
this.emojiHandler.initialize(this, jsonEmojis);
this.generateCanvas();
......@@ -256,17 +261,17 @@ $(function (n) {
});
var that = this;
canvas.id = "c1";
canvas.width = $('#fabric').innerWidth();
canvas.width = this.parentElement.innerWidth();
canvas.height = canvas.width / 3 * 4;
textContainer.append(textArea);
$('#fabric').append(controlElement);
$('#fabric').append(emojiContainer);
$('#fabric').append(textContainer);
this.parentElement.append(controlElement);
this.parentElement.append(emojiContainer);
this.parentElement.append(textContainer);
this.controlElement = controlElement;
this.emojiContainer = emojiContainer;
this.textContainer = textContainer;
this.userTextInput = textArea;
$('#fabric').append(canvas);
this.parentElement.append(canvas);
this.canvas = this.__canvas = new fabric.Canvas(canvas, {
isDrawingMode: true,
stateful: true,
......@@ -278,8 +283,7 @@ $(function (n) {
this.canvas.on('mouse:out', function (e) { that.defaultMouseOutEvent(e) });
this.canvas.on('after:render', function(){
this.calcOffset();
$('#fabric-output').val(JSON.stringify(that.canvas.toJSON()));
console.log(that.canvas.toJSON());
that.outputField.val(JSON.stringify(that.canvas.toJSON()));
});
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment