Commit 406ea9736b59c9d5e850b39512788bf53cc91923

Authored by Nikita Kulshreshtha
2 parents 63560c2e d5881720

manually merged textHorizontalIssue

400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -3017,6 +3017,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3017 3017 }
3018 3018 $rootScope.iniiaTextAreaValues = [];
3019 3019 $rootScope.initTextAreaValues = [];
  3020 + $rootScope.textWidth = [];
  3021 + $rootScope.duplicatetextWidth = [];
  3022 + $rootScope.resieTextArray = [];
  3023 + $rootScope.duplicateResizeTextArray = [];
  3024 + $rootScope.aaaa = 0;
  3025 + $rootScope.aaaa1 = 0;
3020 3026 ///-----
3021 3027  
3022 3028 var isDoubleTouchSaveText = null;
... ... @@ -3026,9 +3032,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3026 3032 document.getElementById('modelbackground').style.display = "none";
3027 3033 $rootScope.selectedBGColorForTextArea = $("#drawTextBGColorpicker span.minicolors-swatch-color").css('background-color');
3028 3034  
3029   -
3030   -
3031   -
3032 3035 // this part will work first time when save button will be clicked
3033 3036 if ($rootScope.IsTextAlreadySave == false) {
3034 3037  
... ... @@ -3042,8 +3045,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3042 3045 }
3043 3046 }
3044 3047  
3045   -
3046   -
3047 3048 // getting textarea style properties
3048 3049 $rootScope.fontSizes = $("#text_area").css("font-size");
3049 3050 $rootScope.fontWeight = $("#text_area").css("font-weight");
... ... @@ -3054,7 +3055,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3054 3055 $rootScope.underlineText = $("#text_area").css("text-decoration");
3055 3056 $rootScope.textArea = $("#text_area").val();
3056 3057  
3057   -
  3058 +
3058 3059 // code for horizonatl text going out
3059 3060 if (/\s/.test($rootScope.textArea)) {
3060 3061  
... ... @@ -3070,9 +3071,21 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3070 3071 for (var i = 0; i <= text.length - 1; i++) {
3071 3072 if (contentWidthArray.length > 0) {
3072 3073 if (parseInt(contentWidthArray[0]) < $("#atTextDiv").width()) {
  3074 +
3073 3075 $("#duptextspan").append(text[i]);
3074 3076 $("#textspan").append(text[i]);
3075 3077 contentWidthArray = [];
  3078 + if ($rootScope.textWidth.length > 0) {
  3079 + $rootScope.aaaa1 = $("#textspan").width();
  3080 + $rootScope.aaaa1 = $rootScope.aaaa1 - $rootScope.aaaa;
  3081 + $rootScope.aaaa = $rootScope.aaaa + $rootScope.aaaa1;
  3082 + $rootScope.textWidth.push({ "id": "", "width": $rootScope.aaaa1, "character": text[i] });
  3083 + }
  3084 + else
  3085 + {
  3086 + $rootScope.textWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] });
  3087 + }
  3088 +
3076 3089 contentWidthArray.push(Math.ceil($("#textspan").width()));
3077 3090 }
3078 3091 else {
... ... @@ -3082,6 +3095,10 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3082 3095 $("#duptextspan").append(text[i]);
3083 3096 $("#textspan").text('');
3084 3097 $("#textspan").append(text[i]);
  3098 + $rootScope.aaaa = 0;
  3099 + $rootScope.aaaa1 = 0;
  3100 + $rootScope.aaaa = $("#textspan").width();
  3101 + $rootScope.textWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] });
3085 3102 contentWidthArray.push(Math.ceil($("#textspan").width()));
3086 3103  
3087 3104 }
... ... @@ -3090,9 +3107,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3090 3107 $("#duptextspan").text(text[i]);
3091 3108 $("#textspan").text(text[i]);
3092 3109 contentWidthArray = [];
  3110 + $rootScope.textWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] });
  3111 + $rootScope.aaaa = $("#textspan").width();
3093 3112 contentWidthArray.push(Math.ceil($("#textspan").width()));
3094 3113 }
3095 3114 }
  3115 + console.log($rootScope.textWidth);
3096 3116 $rootScope.textArea = $("#duptextspan").text();
3097 3117 console.log($rootScope.textArea);
3098 3118 }
... ... @@ -3131,6 +3151,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3131 3151 $rootScope.initialTextAreaName = layer.name;
3132 3152 $rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
3133 3153 }
  3154 +
  3155 + for (var i = 0; i <= $rootScope.textWidth.length - 1; i++) {
  3156 + if ($rootScope.textWidth[i].id == "") {
  3157 + $rootScope.textWidth[i].id = layer.name;
  3158 + }
  3159 + }
3134 3160 },
3135 3161 dragstop: function (layer) {
3136 3162  
... ... @@ -3147,7 +3173,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3147 3173 },
3148 3174  
3149 3175 click: function (layer) {
3150   -
3151 3176 if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
3152 3177 //jcanvas property
3153 3178 layer.draggable = true;
... ... @@ -3544,12 +3569,15 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3544 3569 }
3545 3570 },
3546 3571 change: function (layer) {
3547   -
  3572 +
  3573 +
3548 3574 if ($rootScope.isTextAReaRectangleClicked == true) {
  3575 +
3549 3576 if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
3550 3577 console.log(layer.x + " " + layer.y);
3551 3578 console.log($rootScope.textXAxisAftrResize + " " + $rootScope.textYAxisAftrResize);
3552 3579 $rootScope.isTextAReaRectangleClicked = false;
  3580 +
3553 3581 for (var i = 0; i <= $rootScope.iniiaTextAreaValues.length-1; i++) {
3554 3582  
3555 3583 if ($rootScope.iniiaTextAreaValues[i].name == layer.name) {
... ... @@ -3566,6 +3594,40 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3566 3594 x: layer.x,
3567 3595 y: layer.y
3568 3596 });
  3597 +
  3598 + $("#textspan").empty();
  3599 + $("#duptextspan").empty();
  3600 + var textWidthCounter = 0;
  3601 + var textAftrResize;
  3602 + for (var i = 0; i <= $rootScope.resieTextArray.length - 1; i++) {
  3603 + if($rootScope.resieTextArray[i].layerName == CangedTextAreaName)
  3604 + {
  3605 + if (/(\r\n)/gm.test($rootScope.resieTextArray[i].Rect_Text) || /\s/.test($rootScope.resieTextArray[i].Rect_Text)) {
  3606 + textAftrResize = ($rootScope.resieTextArray[i].Rect_Text).replace(/(\r\n)/gm, "");
  3607 + for (var i = 0;i <= $rootScope.textWidth.length - 1; i++) {
  3608 + if ($rootScope.textWidth[i].id == layer.name) {
  3609 + textWidthCounter = textWidthCounter + $rootScope.textWidth[i].width;
  3610 + if (textWidthCounter < layer.width) {
  3611 + $("#duptextspan").append($rootScope.textWidth[i].character);
  3612 + $("#textspan").append($rootScope.textWidth[i].character);
  3613 + }
  3614 + else {
  3615 + $("#duptextspan").append("\r\n");
  3616 + $("#textspan").append("\r\n");
  3617 + $("#duptextspan").append($rootScope.textWidth[i].character);
  3618 + $("#textspan").text('');
  3619 + $("#textspan").append($rootScope.textWidth[i].character);
  3620 + textWidthCounter = 0;
  3621 + }
  3622 + }
  3623 + }
  3624 + textAftrResize = $("#duptextspan").text();
  3625 + $('#canvas').setLayer(CangedTextAreaName, {
  3626 + text: textAftrResize,
  3627 + });
  3628 + }
  3629 + }
  3630 + }
3569 3631 }
3570 3632 }
3571 3633  
... ... @@ -3607,17 +3669,11 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3607 3669 maxWidth: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].width),
3608 3670 maxHeight: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].height),
3609 3671 add: function (layer) {
3610   - // console.log(layer.x + " " + layer.y);
3611 3672 $rootScope.textXAxisAftrResize = layer.x;
3612 3673 $rootScope.textYAxisAftrResize = layer.y;
3613   -
3614   - //$rootScope.TextPropertyArray.push({ Text1: '', Align: '', FontColor: '', FontSize: '', FontStyle: '', FontFamily: '' });
3615 3674 $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 });
3616   - },
3617   - dblclick: function (layer) {
3618   -
  3675 + $rootScope.resieTextArray.push({ layerName: layer.name, Rect_Text: layer.text });
3619 3676 }
3620   -
3621 3677 });
3622 3678 $("#text_area").val('');
3623 3679 $("#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
3691 3747 $("#duptextspan").append(text[i]);
3692 3748 $("#textspan").append(text[i]);
3693 3749 contentWidthArray = [];
  3750 + if ($rootScope.duplicatetextWidth.length > 0) {
  3751 + $rootScope.aaaa1 = $("#textspan").width();
  3752 + $rootScope.aaaa1 = $rootScope.aaaa1 - $rootScope.aaaa;
  3753 + $rootScope.aaaa = $rootScope.aaaa + $rootScope.aaaa1;
  3754 + $rootScope.duplicatetextWidth.push({ "id": "", "width": $rootScope.aaaa1, "character": text[i] });
  3755 + }
  3756 + else
  3757 + {
  3758 + $rootScope.duplicatetextWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] });
  3759 + }
3694 3760 contentWidthArray.push(Math.ceil($("#textspan").width()));
3695 3761 }
3696 3762 else {
... ... @@ -3700,6 +3766,10 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3700 3766 $("#duptextspan").append(text[i]);
3701 3767 $("#textspan").text('');
3702 3768 $("#textspan").append(text[i]);
  3769 + $rootScope.aaaa = 0;
  3770 + $rootScope.aaaa1 = 0;
  3771 + $rootScope.aaaa = $("#textspan").width();
  3772 + $rootScope.duplicatetextWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] });
3703 3773 contentWidthArray.push(Math.ceil($("#textspan").width()));
3704 3774  
3705 3775 }
... ... @@ -3708,9 +3778,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3708 3778 $("#duptextspan").text(text[i]);
3709 3779 $("#textspan").text(text[i]);
3710 3780 contentWidthArray = [];
  3781 + $rootScope.duplicatetextWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] });
  3782 + $rootScope.aaaa = $("#textspan").width();
3711 3783 contentWidthArray.push(Math.ceil($("#textspan").width()));
3712 3784 }
3713 3785 }
  3786 + console.log($rootScope.duplicatetextWidth);
3714 3787 _modifiedText = $("#duptextspan").text();
3715 3788 console.log(_modifiedText);
3716 3789 }
... ... @@ -3719,12 +3792,11 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3719 3792  
3720 3793 $("#canvas").removeLayer($rootScope.layerNameArr).drawLayers();
3721 3794 $("#canvas").removeLayer($rootScope.rectTextArr).drawLayers();
3722   -
3723 3795 $rootScope.resetTextRectSave = $rootScope.ObjectIndexSave++;
3724 3796 $rootScope.resetTextSave = $rootScope.ObjectIndexSave++;
3725   -
  3797 +
3726 3798 // generating new text area
3727   - // $('#canvas')
  3799 +
3728 3800 // Draw rect as wide as the text
3729 3801 $('#canvas').drawRect({
3730 3802 name: 'TextAreaAfterEditRect_' + $rootScope.resetTextSave,
... ... @@ -3746,9 +3818,19 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3746 3818 var TextAreaLayerNameAftrSplit = TextAreaLayerName.split("_");
3747 3819 $rootScope.postFixLayerNumberAftrEdit = TextAreaLayerNameAftrSplit[1];
3748 3820 $rootScope.initTextAreaValues.push({ "name": layer.name, "width": layer.width, "height": layer.height });
  3821 +
  3822 + for (var i = 0; i <= $rootScope.duplicatetextWidth.length - 1; i++) {
  3823 + if ($rootScope.duplicatetextWidth[i].id == "") {
  3824 + $rootScope.duplicatetextWidth[i].id = layer.name;
  3825 + }
  3826 + }
  3827 +
  3828 +
3749 3829 if ($location.path() == "/module-item-view") {
3750 3830 $rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
3751 3831 }
  3832 +
  3833 +
3752 3834 },
3753 3835 dragstop: function (layer) {
3754 3836  
... ... @@ -3826,7 +3908,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3826 3908  
3827 3909 //khushbu
3828 3910 var CurrentFontFamily = _modifiedFontFamily;
3829   - // alert(CurrentFontFamily);
3830 3911 // CurrentFontFamily = CurrentFontFamily.replace(/'/g, "");
3831 3912 var CurrentFontSize = parseInt(_modifiedFontSize);
3832 3913 $("#selected-font-family option[value=" + CurrentFontFamily + "]").prop('selected', true);
... ... @@ -4072,13 +4153,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
4072 4153 }
4073 4154 },
4074 4155 change: function (layer) {
4075   -
  4156 +
4076 4157 if ($rootScope.isTextAReaRectangleClickedAftrEdit == true) {
4077 4158 if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
4078 4159 console.log(layer.x + " " + layer.y);
4079 4160 console.log($rootScope.textXAxisAftrResize + " " + $rootScope.textYAxisAftrResize);
4080 4161 $rootScope.isTextAReaRectangleClickedAftrEdit = false;
4081   -
  4162 +
4082 4163 for (var i = 0; i <= $rootScope.initTextAreaValues.length - 1; i++) {
4083 4164  
4084 4165 if ($rootScope.initTextAreaValues[i].name == layer.name) {
... ... @@ -4094,6 +4175,39 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
4094 4175 x: layer.x,
4095 4176 y: layer.y
4096 4177 });
  4178 + $("#textspan").empty();
  4179 + $("#duptextspan").empty();
  4180 + var textWidthCounter = 0;
  4181 + var textAftrResize;
  4182 + for (var i = 0; i <= $rootScope.duplicateResizeTextArray.length - 1; i++) {
  4183 + if ($rootScope.duplicateResizeTextArray[i].layerName == CangedTextAreaName) {
  4184 + if (/(\r\n)/gm.test($rootScope.duplicateResizeTextArray[i].Rect_Text) || /\s/.test($rootScope.duplicateResizeTextArray[i].Rect_Text)) {
  4185 + textAftrResize = ($rootScope.duplicateResizeTextArray[i].Rect_Text).replace(/(\r\n)/gm, "");
  4186 + for (var i = 0; i <= $rootScope.duplicatetextWidth.length - 1; i++) {
  4187 + if ($rootScope.duplicatetextWidth[i].id == layer.name) {
  4188 + textWidthCounter = textWidthCounter + $rootScope.duplicatetextWidth[i].width;
  4189 + if (textWidthCounter < layer.width) {
  4190 + $("#duptextspan").append($rootScope.duplicatetextWidth[i].character);
  4191 + $("#textspan").append($rootScope.duplicatetextWidth[i].character);
  4192 + }
  4193 + else {
  4194 + $("#duptextspan").append("\r\n");
  4195 + $("#textspan").append("\r\n");
  4196 + $("#duptextspan").append($rootScope.duplicatetextWidth[i].character);
  4197 + $("#textspan").text('');
  4198 + $("#textspan").append($rootScope.duplicatetextWidth[i].character);
  4199 + textWidthCounter = 0;
  4200 + }
  4201 + }
  4202 + }
  4203 + textAftrResize = $("#duptextspan").text();
  4204 + $('#canvas').setLayer(CangedTextAreaName, {
  4205 + text: textAftrResize,
  4206 + });
  4207 + }
  4208 + }
  4209 + }
  4210 +
4097 4211 }
4098 4212 }
4099 4213  
... ... @@ -4142,6 +4256,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
4142 4256 // console.log(layer.x + " " + layer.y);
4143 4257 $rootScope.editTextXAxisAftrResize = layer.x;
4144 4258 $rootScope.editTextYAxisAftrResize = layer.y;
  4259 + $rootScope.duplicateResizeTextArray.push({ layerName: layer.name, Rect_Text: layer.text });
4145 4260 }
4146 4261 });
4147 4262  
... ...