diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 5fdbb39..1c6332d 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -2943,15 +2943,19 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic } $rootScope.iniiaTextAreaValues = []; $rootScope.initTextAreaValues = []; + $rootScope.textWidth = []; + $rootScope.textWidth1 = []; + $rootScope.resieTextArray = []; + $rootScope.resieTextArray1 = []; + // $rootScope.textWidth1 = []; + $rootScope.aaaa = 0; + $rootScope.aaaa1 = 0; ///----- $rootScope.saveText = function () { document.getElementById('modelbackground').style.display = "none"; $rootScope.selectedBGColorForTextArea = $("#drawTextBGColorpicker span.minicolors-swatch-color").css('background-color'); - - - // this part will work first time when save button will be clicked if ($rootScope.IsTextAlreadySave == false) { @@ -2965,8 +2969,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic } } - - // getting textarea style properties $rootScope.fontSizes = $("#text_area").css("font-size"); $rootScope.fontWeight = $("#text_area").css("font-weight"); @@ -2977,7 +2979,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.underlineText = $("#text_area").css("text-decoration"); $rootScope.textArea = $("#text_area").val(); - + // code for horizonatl text going out if (/\s/.test($rootScope.textArea)) { @@ -2993,9 +2995,21 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic for (var i = 0; i <= text.length - 1; i++) { if (contentWidthArray.length > 0) { if (parseInt(contentWidthArray[0]) < $("#atTextDiv").width()) { + $("#duptextspan").append(text[i]); $("#textspan").append(text[i]); contentWidthArray = []; + if ($rootScope.textWidth.length > 0) { + $rootScope.aaaa1 = $("#textspan").width(); + $rootScope.aaaa1 = $rootScope.aaaa1 - $rootScope.aaaa; + $rootScope.aaaa = $rootScope.aaaa + $rootScope.aaaa1; + $rootScope.textWidth.push({ "id": "", "width": $rootScope.aaaa1, "character": text[i] }); + } + else + { + $rootScope.textWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); + } + contentWidthArray.push(Math.ceil($("#textspan").width())); } else { @@ -3005,6 +3019,10 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#duptextspan").append(text[i]); $("#textspan").text(''); $("#textspan").append(text[i]); + $rootScope.aaaa = 0; + $rootScope.aaaa1 = 0; + $rootScope.aaaa = $("#textspan").width(); + $rootScope.textWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); contentWidthArray.push(Math.ceil($("#textspan").width())); } @@ -3013,9 +3031,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#duptextspan").text(text[i]); $("#textspan").text(text[i]); contentWidthArray = []; + $rootScope.textWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); + $rootScope.aaaa = $("#textspan").width(); contentWidthArray.push(Math.ceil($("#textspan").width())); } } + console.log($rootScope.textWidth); $rootScope.textArea = $("#duptextspan").text(); console.log($rootScope.textArea); } @@ -3054,6 +3075,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.initialTextAreaName = layer.name; $rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height }); } + + for (var i = 0; i <= $rootScope.textWidth.length - 1; i++) { + if ($rootScope.textWidth[i].id == "") { + $rootScope.textWidth[i].id = layer.name; + } + } }, dragstop: function (layer) { @@ -3070,7 +3097,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic }, click: function (layer) { - if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; @@ -3291,12 +3317,15 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic } }, change: function (layer) { - + + if ($rootScope.isTextAReaRectangleClicked == true) { + if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { console.log(layer.x + " " + layer.y); console.log($rootScope.textXAxisAftrResize + " " + $rootScope.textYAxisAftrResize); $rootScope.isTextAReaRectangleClicked = false; + for (var i = 0; i <= $rootScope.iniiaTextAreaValues.length-1; i++) { if ($rootScope.iniiaTextAreaValues[i].name == layer.name) { @@ -3313,6 +3342,40 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic x: layer.x, y: layer.y }); + + $("#textspan").empty(); + $("#duptextspan").empty(); + var textWidthCounter = 0; + var textAftrResize; + for (var i = 0; i <= $rootScope.resieTextArray.length - 1; i++) { + if($rootScope.resieTextArray[i].layerName == CangedTextAreaName) + { + if (/(\r\n)/gm.test($rootScope.resieTextArray[i].Rect_Text) || /\s/.test($rootScope.resieTextArray[i].Rect_Text)) { + textAftrResize = ($rootScope.resieTextArray[i].Rect_Text).replace(/(\r\n)/gm, ""); + for (var i = 0;i <= $rootScope.textWidth.length - 1; i++) { + if ($rootScope.textWidth[i].id == layer.name) { + textWidthCounter = textWidthCounter + $rootScope.textWidth[i].width; + if (textWidthCounter < layer.width) { + $("#duptextspan").append($rootScope.textWidth[i].character); + $("#textspan").append($rootScope.textWidth[i].character); + } + else { + $("#duptextspan").append("\r\n"); + $("#textspan").append("\r\n"); + $("#duptextspan").append($rootScope.textWidth[i].character); + $("#textspan").text(''); + $("#textspan").append($rootScope.textWidth[i].character); + textWidthCounter = 0; + } + } + } + textAftrResize = $("#duptextspan").text(); + $('#canvas').setLayer(CangedTextAreaName, { + text: textAftrResize, + }); + } + } + } } } @@ -3354,17 +3417,11 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic maxWidth: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].width), maxHeight: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].height), add: function (layer) { - // console.log(layer.x + " " + layer.y); $rootScope.textXAxisAftrResize = layer.x; $rootScope.textYAxisAftrResize = layer.y; - - //$rootScope.TextPropertyArray.push({ Text1: '', Align: '', FontColor: '', FontSize: '', FontStyle: '', FontFamily: '' }); $rootScope.TextPropertyArray.push({ layerName: layer.name, Rect_Text: layer.text, Align: layer.align, FontColor: layer.fillStyle, FontSize: layer.fontSize, FontStyle: layer.fontStyle, FontFamily: layer.fontFamily, TextDecoration: $rootScope.underlineText }); - }, - dblclick: function (layer) { - + $rootScope.resieTextArray.push({ layerName: layer.name, Rect_Text: layer.text }); } - }); $("#text_area").val(''); $("#text_area").css({ " font-family": "Arial", "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" }); @@ -3438,6 +3495,20 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#duptextspan").append(text[i]); $("#textspan").append(text[i]); contentWidthArray = []; + if ($rootScope.textWidth1.length > 0) { + + $rootScope.aaaa1 = $("#textspan").width(); + // alert("Second Time" + $rootScope.aaaa1); + $rootScope.aaaa1 = $rootScope.aaaa1 - $rootScope.aaaa; + $rootScope.aaaa = $rootScope.aaaa + $rootScope.aaaa1; + // alert("Second Time" + $rootScope.aaaa); + + $rootScope.textWidth1.push({ "id": "", "width": $rootScope.aaaa1, "character": text[i] }); + } + else + { + $rootScope.textWidth1.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); + } contentWidthArray.push(Math.ceil($("#textspan").width())); } else { @@ -3447,6 +3518,11 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#duptextspan").append(text[i]); $("#textspan").text(''); $("#textspan").append(text[i]); + $rootScope.aaaa = 0; + $rootScope.aaaa1 = 0; + $rootScope.aaaa = $("#textspan").width(); + // alert("New Line" + $rootScope.aaaa); + $rootScope.textWidth1.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); contentWidthArray.push(Math.ceil($("#textspan").width())); } @@ -3455,9 +3531,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#duptextspan").text(text[i]); $("#textspan").text(text[i]); contentWidthArray = []; + $rootScope.textWidth1.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); + $rootScope.aaaa = $("#textspan").width(); contentWidthArray.push(Math.ceil($("#textspan").width())); } } + console.log($rootScope.textWidth1); _modifiedText = $("#duptextspan").text(); console.log(_modifiedText); } @@ -3469,7 +3548,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.resetTextRectSave = $rootScope.ObjectIndexSave++; $rootScope.resetTextSave = $rootScope.ObjectIndexSave++; - + // generating new text area // $('#canvas') // Draw rect as wide as the text @@ -3493,9 +3572,19 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic var TextAreaLayerNameAftrSplit = TextAreaLayerName.split("_"); $rootScope.postFixLayerNumberAftrEdit = TextAreaLayerNameAftrSplit[1]; $rootScope.initTextAreaValues.push({ "name": layer.name, "width": layer.width, "height": layer.height }); + + for (var i = 0; i <= $rootScope.textWidth1.length - 1; i++) { + if ($rootScope.textWidth1[i].id == "") { + $rootScope.textWidth1[i].id = layer.name; + } + } + + if ($location.path() == "/module-item-view") { $rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height }); } + + }, dragstop: function (layer) { @@ -3573,7 +3662,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic //khushbu var CurrentFontFamily = _modifiedFontFamily; - // alert(CurrentFontFamily); // CurrentFontFamily = CurrentFontFamily.replace(/'/g, ""); var CurrentFontSize = parseInt(_modifiedFontSize); $("#selected-font-family option[value=" + CurrentFontFamily + "]").prop('selected', true); @@ -3687,13 +3775,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic } }, change: function (layer) { - + if ($rootScope.isTextAReaRectangleClickedAftrEdit == true) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { console.log(layer.x + " " + layer.y); console.log($rootScope.textXAxisAftrResize + " " + $rootScope.textYAxisAftrResize); $rootScope.isTextAReaRectangleClickedAftrEdit = false; - + for (var i = 0; i <= $rootScope.initTextAreaValues.length - 1; i++) { if ($rootScope.initTextAreaValues[i].name == layer.name) { @@ -3709,6 +3797,48 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic x: layer.x, y: layer.y }); + + + + + $("#textspan").empty(); + $("#duptextspan").empty(); + var textWidthCounter = 0; + var textAftrResize; + for (var i = 0; i <= $rootScope.resieTextArray1.length - 1; i++) { + if ($rootScope.resieTextArray1[i].layerName == CangedTextAreaName) { + if (/(\r\n)/gm.test($rootScope.resieTextArray1[i].Rect_Text) || /\s/.test($rootScope.resieTextArray1[i].Rect_Text)) { + textAftrResize = ($rootScope.resieTextArray1[i].Rect_Text).replace(/(\r\n)/gm, ""); + for (var i = 0; i <= $rootScope.textWidth1.length - 1; i++) { + if ($rootScope.textWidth1[i].id == layer.name) { + textWidthCounter = textWidthCounter + $rootScope.textWidth1[i].width; + if (textWidthCounter < layer.width) { + $("#duptextspan").append($rootScope.textWidth1[i].character); + $("#textspan").append($rootScope.textWidth1[i].character); + } + else { + $("#duptextspan").append("\r\n"); + $("#textspan").append("\r\n"); + $("#duptextspan").append($rootScope.textWidth1[i].character); + $("#textspan").text(''); + $("#textspan").append($rootScope.textWidth1[i].character); + textWidthCounter = 0; + } + } + } + textAftrResize = $("#duptextspan").text(); + $('#canvas').setLayer(CangedTextAreaName, { + text: textAftrResize, + }); + } + } + } + + + + + + } } @@ -3757,6 +3887,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic // console.log(layer.x + " " + layer.y); $rootScope.editTextXAxisAftrResize = layer.x; $rootScope.editTextYAxisAftrResize = layer.y; + $rootScope.resieTextArray1.push({ layerName: layer.name, Rect_Text: layer.text }); } });