diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index e3742b7..e4a3251 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -3017,6 +3017,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic } $rootScope.iniiaTextAreaValues = []; $rootScope.initTextAreaValues = []; + $rootScope.textWidth = []; + $rootScope.duplicatetextWidth = []; + $rootScope.resieTextArray = []; + $rootScope.duplicateResizeTextArray = []; + $rootScope.aaaa = 0; + $rootScope.aaaa1 = 0; ///----- var isDoubleTouchSaveText = null; @@ -3026,9 +3032,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic 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) { @@ -3042,8 +3045,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"); @@ -3054,7 +3055,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)) { @@ -3070,9 +3071,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 { @@ -3082,6 +3095,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())); } @@ -3090,9 +3107,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); } @@ -3131,6 +3151,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) { @@ -3147,7 +3173,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic }, click: function (layer) { - if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; @@ -3544,12 +3569,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) { @@ -3566,6 +3594,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, + }); + } + } + } } } @@ -3607,17 +3669,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" }); @@ -3691,6 +3747,16 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#duptextspan").append(text[i]); $("#textspan").append(text[i]); contentWidthArray = []; + if ($rootScope.duplicatetextWidth.length > 0) { + $rootScope.aaaa1 = $("#textspan").width(); + $rootScope.aaaa1 = $rootScope.aaaa1 - $rootScope.aaaa; + $rootScope.aaaa = $rootScope.aaaa + $rootScope.aaaa1; + $rootScope.duplicatetextWidth.push({ "id": "", "width": $rootScope.aaaa1, "character": text[i] }); + } + else + { + $rootScope.duplicatetextWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); + } contentWidthArray.push(Math.ceil($("#textspan").width())); } else { @@ -3700,6 +3766,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.duplicatetextWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); contentWidthArray.push(Math.ceil($("#textspan").width())); } @@ -3708,9 +3778,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#duptextspan").text(text[i]); $("#textspan").text(text[i]); contentWidthArray = []; + $rootScope.duplicatetextWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); + $rootScope.aaaa = $("#textspan").width(); contentWidthArray.push(Math.ceil($("#textspan").width())); } } + console.log($rootScope.duplicatetextWidth); _modifiedText = $("#duptextspan").text(); console.log(_modifiedText); } @@ -3719,12 +3792,11 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#canvas").removeLayer($rootScope.layerNameArr).drawLayers(); $("#canvas").removeLayer($rootScope.rectTextArr).drawLayers(); - $rootScope.resetTextRectSave = $rootScope.ObjectIndexSave++; $rootScope.resetTextSave = $rootScope.ObjectIndexSave++; - + // generating new text area - // $('#canvas') + // Draw rect as wide as the text $('#canvas').drawRect({ name: 'TextAreaAfterEditRect_' + $rootScope.resetTextSave, @@ -3746,9 +3818,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.duplicatetextWidth.length - 1; i++) { + if ($rootScope.duplicatetextWidth[i].id == "") { + $rootScope.duplicatetextWidth[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) { @@ -3826,7 +3908,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); @@ -4072,13 +4153,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) { @@ -4094,6 +4175,39 @@ 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.duplicateResizeTextArray.length - 1; i++) { + if ($rootScope.duplicateResizeTextArray[i].layerName == CangedTextAreaName) { + if (/(\r\n)/gm.test($rootScope.duplicateResizeTextArray[i].Rect_Text) || /\s/.test($rootScope.duplicateResizeTextArray[i].Rect_Text)) { + textAftrResize = ($rootScope.duplicateResizeTextArray[i].Rect_Text).replace(/(\r\n)/gm, ""); + for (var i = 0; i <= $rootScope.duplicatetextWidth.length - 1; i++) { + if ($rootScope.duplicatetextWidth[i].id == layer.name) { + textWidthCounter = textWidthCounter + $rootScope.duplicatetextWidth[i].width; + if (textWidthCounter < layer.width) { + $("#duptextspan").append($rootScope.duplicatetextWidth[i].character); + $("#textspan").append($rootScope.duplicatetextWidth[i].character); + } + else { + $("#duptextspan").append("\r\n"); + $("#textspan").append("\r\n"); + $("#duptextspan").append($rootScope.duplicatetextWidth[i].character); + $("#textspan").text(''); + $("#textspan").append($rootScope.duplicatetextWidth[i].character); + textWidthCounter = 0; + } + } + } + textAftrResize = $("#duptextspan").text(); + $('#canvas').setLayer(CangedTextAreaName, { + text: textAftrResize, + }); + } + } + } + } } @@ -4142,6 +4256,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic // console.log(layer.x + " " + layer.y); $rootScope.editTextXAxisAftrResize = layer.x; $rootScope.editTextYAxisAftrResize = layer.y; + $rootScope.duplicateResizeTextArray.push({ layerName: layer.name, Rect_Text: layer.text }); } });