Commit 57e58c047d1087df9508b64be576970263abf7bb
1 parent
2b8b72c8
Horizontal Text Issue
Showing
1 changed file
with
150 additions
and
19 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... | ... | @@ -2943,15 +2943,19 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
2943 | 2943 | } |
2944 | 2944 | $rootScope.iniiaTextAreaValues = []; |
2945 | 2945 | $rootScope.initTextAreaValues = []; |
2946 | + $rootScope.textWidth = []; | |
2947 | + $rootScope.textWidth1 = []; | |
2948 | + $rootScope.resieTextArray = []; | |
2949 | + $rootScope.resieTextArray1 = []; | |
2950 | + // $rootScope.textWidth1 = []; | |
2951 | + $rootScope.aaaa = 0; | |
2952 | + $rootScope.aaaa1 = 0; | |
2946 | 2953 | ///----- |
2947 | 2954 | $rootScope.saveText = function () { |
2948 | 2955 | |
2949 | 2956 | document.getElementById('modelbackground').style.display = "none"; |
2950 | 2957 | $rootScope.selectedBGColorForTextArea = $("#drawTextBGColorpicker span.minicolors-swatch-color").css('background-color'); |
2951 | 2958 | |
2952 | - | |
2953 | - | |
2954 | - | |
2955 | 2959 | // this part will work first time when save button will be clicked |
2956 | 2960 | if ($rootScope.IsTextAlreadySave == false) { |
2957 | 2961 | |
... | ... | @@ -2965,8 +2969,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
2965 | 2969 | } |
2966 | 2970 | } |
2967 | 2971 | |
2968 | - | |
2969 | - | |
2970 | 2972 | // getting textarea style properties |
2971 | 2973 | $rootScope.fontSizes = $("#text_area").css("font-size"); |
2972 | 2974 | $rootScope.fontWeight = $("#text_area").css("font-weight"); |
... | ... | @@ -2977,7 +2979,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
2977 | 2979 | $rootScope.underlineText = $("#text_area").css("text-decoration"); |
2978 | 2980 | $rootScope.textArea = $("#text_area").val(); |
2979 | 2981 | |
2980 | - | |
2982 | + | |
2981 | 2983 | // code for horizonatl text going out |
2982 | 2984 | if (/\s/.test($rootScope.textArea)) { |
2983 | 2985 | |
... | ... | @@ -2993,9 +2995,21 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
2993 | 2995 | for (var i = 0; i <= text.length - 1; i++) { |
2994 | 2996 | if (contentWidthArray.length > 0) { |
2995 | 2997 | if (parseInt(contentWidthArray[0]) < $("#atTextDiv").width()) { |
2998 | + | |
2996 | 2999 | $("#duptextspan").append(text[i]); |
2997 | 3000 | $("#textspan").append(text[i]); |
2998 | 3001 | contentWidthArray = []; |
3002 | + if ($rootScope.textWidth.length > 0) { | |
3003 | + $rootScope.aaaa1 = $("#textspan").width(); | |
3004 | + $rootScope.aaaa1 = $rootScope.aaaa1 - $rootScope.aaaa; | |
3005 | + $rootScope.aaaa = $rootScope.aaaa + $rootScope.aaaa1; | |
3006 | + $rootScope.textWidth.push({ "id": "", "width": $rootScope.aaaa1, "character": text[i] }); | |
3007 | + } | |
3008 | + else | |
3009 | + { | |
3010 | + $rootScope.textWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); | |
3011 | + } | |
3012 | + | |
2999 | 3013 | contentWidthArray.push(Math.ceil($("#textspan").width())); |
3000 | 3014 | } |
3001 | 3015 | else { |
... | ... | @@ -3005,6 +3019,10 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3005 | 3019 | $("#duptextspan").append(text[i]); |
3006 | 3020 | $("#textspan").text(''); |
3007 | 3021 | $("#textspan").append(text[i]); |
3022 | + $rootScope.aaaa = 0; | |
3023 | + $rootScope.aaaa1 = 0; | |
3024 | + $rootScope.aaaa = $("#textspan").width(); | |
3025 | + $rootScope.textWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); | |
3008 | 3026 | contentWidthArray.push(Math.ceil($("#textspan").width())); |
3009 | 3027 | |
3010 | 3028 | } |
... | ... | @@ -3013,9 +3031,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3013 | 3031 | $("#duptextspan").text(text[i]); |
3014 | 3032 | $("#textspan").text(text[i]); |
3015 | 3033 | contentWidthArray = []; |
3034 | + $rootScope.textWidth.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); | |
3035 | + $rootScope.aaaa = $("#textspan").width(); | |
3016 | 3036 | contentWidthArray.push(Math.ceil($("#textspan").width())); |
3017 | 3037 | } |
3018 | 3038 | } |
3039 | + console.log($rootScope.textWidth); | |
3019 | 3040 | $rootScope.textArea = $("#duptextspan").text(); |
3020 | 3041 | console.log($rootScope.textArea); |
3021 | 3042 | } |
... | ... | @@ -3054,6 +3075,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3054 | 3075 | $rootScope.initialTextAreaName = layer.name; |
3055 | 3076 | $rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height }); |
3056 | 3077 | } |
3078 | + | |
3079 | + for (var i = 0; i <= $rootScope.textWidth.length - 1; i++) { | |
3080 | + if ($rootScope.textWidth[i].id == "") { | |
3081 | + $rootScope.textWidth[i].id = layer.name; | |
3082 | + } | |
3083 | + } | |
3057 | 3084 | }, |
3058 | 3085 | dragstop: function (layer) { |
3059 | 3086 | |
... | ... | @@ -3070,7 +3097,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3070 | 3097 | }, |
3071 | 3098 | |
3072 | 3099 | click: function (layer) { |
3073 | - | |
3074 | 3100 | if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { |
3075 | 3101 | //jcanvas property |
3076 | 3102 | layer.draggable = true; |
... | ... | @@ -3291,12 +3317,15 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3291 | 3317 | } |
3292 | 3318 | }, |
3293 | 3319 | change: function (layer) { |
3294 | - | |
3320 | + | |
3321 | + | |
3295 | 3322 | if ($rootScope.isTextAReaRectangleClicked == true) { |
3323 | + | |
3296 | 3324 | if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { |
3297 | 3325 | console.log(layer.x + " " + layer.y); |
3298 | 3326 | console.log($rootScope.textXAxisAftrResize + " " + $rootScope.textYAxisAftrResize); |
3299 | 3327 | $rootScope.isTextAReaRectangleClicked = false; |
3328 | + | |
3300 | 3329 | for (var i = 0; i <= $rootScope.iniiaTextAreaValues.length-1; i++) { |
3301 | 3330 | |
3302 | 3331 | if ($rootScope.iniiaTextAreaValues[i].name == layer.name) { |
... | ... | @@ -3313,6 +3342,40 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3313 | 3342 | x: layer.x, |
3314 | 3343 | y: layer.y |
3315 | 3344 | }); |
3345 | + | |
3346 | + $("#textspan").empty(); | |
3347 | + $("#duptextspan").empty(); | |
3348 | + var textWidthCounter = 0; | |
3349 | + var textAftrResize; | |
3350 | + for (var i = 0; i <= $rootScope.resieTextArray.length - 1; i++) { | |
3351 | + if($rootScope.resieTextArray[i].layerName == CangedTextAreaName) | |
3352 | + { | |
3353 | + if (/(\r\n)/gm.test($rootScope.resieTextArray[i].Rect_Text) || /\s/.test($rootScope.resieTextArray[i].Rect_Text)) { | |
3354 | + textAftrResize = ($rootScope.resieTextArray[i].Rect_Text).replace(/(\r\n)/gm, ""); | |
3355 | + for (var i = 0;i <= $rootScope.textWidth.length - 1; i++) { | |
3356 | + if ($rootScope.textWidth[i].id == layer.name) { | |
3357 | + textWidthCounter = textWidthCounter + $rootScope.textWidth[i].width; | |
3358 | + if (textWidthCounter < layer.width) { | |
3359 | + $("#duptextspan").append($rootScope.textWidth[i].character); | |
3360 | + $("#textspan").append($rootScope.textWidth[i].character); | |
3361 | + } | |
3362 | + else { | |
3363 | + $("#duptextspan").append("\r\n"); | |
3364 | + $("#textspan").append("\r\n"); | |
3365 | + $("#duptextspan").append($rootScope.textWidth[i].character); | |
3366 | + $("#textspan").text(''); | |
3367 | + $("#textspan").append($rootScope.textWidth[i].character); | |
3368 | + textWidthCounter = 0; | |
3369 | + } | |
3370 | + } | |
3371 | + } | |
3372 | + textAftrResize = $("#duptextspan").text(); | |
3373 | + $('#canvas').setLayer(CangedTextAreaName, { | |
3374 | + text: textAftrResize, | |
3375 | + }); | |
3376 | + } | |
3377 | + } | |
3378 | + } | |
3316 | 3379 | } |
3317 | 3380 | } |
3318 | 3381 | |
... | ... | @@ -3354,17 +3417,11 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3354 | 3417 | maxWidth: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].width), |
3355 | 3418 | maxHeight: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].height), |
3356 | 3419 | add: function (layer) { |
3357 | - // console.log(layer.x + " " + layer.y); | |
3358 | 3420 | $rootScope.textXAxisAftrResize = layer.x; |
3359 | 3421 | $rootScope.textYAxisAftrResize = layer.y; |
3360 | - | |
3361 | - //$rootScope.TextPropertyArray.push({ Text1: '', Align: '', FontColor: '', FontSize: '', FontStyle: '', FontFamily: '' }); | |
3362 | 3422 | $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 }); |
3363 | - }, | |
3364 | - dblclick: function (layer) { | |
3365 | - | |
3423 | + $rootScope.resieTextArray.push({ layerName: layer.name, Rect_Text: layer.text }); | |
3366 | 3424 | } |
3367 | - | |
3368 | 3425 | }); |
3369 | 3426 | $("#text_area").val(''); |
3370 | 3427 | $("#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 |
3438 | 3495 | $("#duptextspan").append(text[i]); |
3439 | 3496 | $("#textspan").append(text[i]); |
3440 | 3497 | contentWidthArray = []; |
3498 | + if ($rootScope.textWidth1.length > 0) { | |
3499 | + | |
3500 | + $rootScope.aaaa1 = $("#textspan").width(); | |
3501 | + // alert("Second Time" + $rootScope.aaaa1); | |
3502 | + $rootScope.aaaa1 = $rootScope.aaaa1 - $rootScope.aaaa; | |
3503 | + $rootScope.aaaa = $rootScope.aaaa + $rootScope.aaaa1; | |
3504 | + // alert("Second Time" + $rootScope.aaaa); | |
3505 | + | |
3506 | + $rootScope.textWidth1.push({ "id": "", "width": $rootScope.aaaa1, "character": text[i] }); | |
3507 | + } | |
3508 | + else | |
3509 | + { | |
3510 | + $rootScope.textWidth1.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); | |
3511 | + } | |
3441 | 3512 | contentWidthArray.push(Math.ceil($("#textspan").width())); |
3442 | 3513 | } |
3443 | 3514 | else { |
... | ... | @@ -3447,6 +3518,11 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3447 | 3518 | $("#duptextspan").append(text[i]); |
3448 | 3519 | $("#textspan").text(''); |
3449 | 3520 | $("#textspan").append(text[i]); |
3521 | + $rootScope.aaaa = 0; | |
3522 | + $rootScope.aaaa1 = 0; | |
3523 | + $rootScope.aaaa = $("#textspan").width(); | |
3524 | + // alert("New Line" + $rootScope.aaaa); | |
3525 | + $rootScope.textWidth1.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); | |
3450 | 3526 | contentWidthArray.push(Math.ceil($("#textspan").width())); |
3451 | 3527 | |
3452 | 3528 | } |
... | ... | @@ -3455,9 +3531,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3455 | 3531 | $("#duptextspan").text(text[i]); |
3456 | 3532 | $("#textspan").text(text[i]); |
3457 | 3533 | contentWidthArray = []; |
3534 | + $rootScope.textWidth1.push({ "id": "", "width": $("#textspan").width(), "character": text[i] }); | |
3535 | + $rootScope.aaaa = $("#textspan").width(); | |
3458 | 3536 | contentWidthArray.push(Math.ceil($("#textspan").width())); |
3459 | 3537 | } |
3460 | 3538 | } |
3539 | + console.log($rootScope.textWidth1); | |
3461 | 3540 | _modifiedText = $("#duptextspan").text(); |
3462 | 3541 | console.log(_modifiedText); |
3463 | 3542 | } |
... | ... | @@ -3469,7 +3548,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3469 | 3548 | |
3470 | 3549 | $rootScope.resetTextRectSave = $rootScope.ObjectIndexSave++; |
3471 | 3550 | $rootScope.resetTextSave = $rootScope.ObjectIndexSave++; |
3472 | - | |
3551 | + | |
3473 | 3552 | // generating new text area |
3474 | 3553 | // $('#canvas') |
3475 | 3554 | // Draw rect as wide as the text |
... | ... | @@ -3493,9 +3572,19 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3493 | 3572 | var TextAreaLayerNameAftrSplit = TextAreaLayerName.split("_"); |
3494 | 3573 | $rootScope.postFixLayerNumberAftrEdit = TextAreaLayerNameAftrSplit[1]; |
3495 | 3574 | $rootScope.initTextAreaValues.push({ "name": layer.name, "width": layer.width, "height": layer.height }); |
3575 | + | |
3576 | + for (var i = 0; i <= $rootScope.textWidth1.length - 1; i++) { | |
3577 | + if ($rootScope.textWidth1[i].id == "") { | |
3578 | + $rootScope.textWidth1[i].id = layer.name; | |
3579 | + } | |
3580 | + } | |
3581 | + | |
3582 | + | |
3496 | 3583 | if ($location.path() == "/module-item-view") { |
3497 | 3584 | $rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height }); |
3498 | 3585 | } |
3586 | + | |
3587 | + | |
3499 | 3588 | }, |
3500 | 3589 | dragstop: function (layer) { |
3501 | 3590 | |
... | ... | @@ -3573,7 +3662,6 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3573 | 3662 | |
3574 | 3663 | //khushbu |
3575 | 3664 | var CurrentFontFamily = _modifiedFontFamily; |
3576 | - // alert(CurrentFontFamily); | |
3577 | 3665 | // CurrentFontFamily = CurrentFontFamily.replace(/'/g, ""); |
3578 | 3666 | var CurrentFontSize = parseInt(_modifiedFontSize); |
3579 | 3667 | $("#selected-font-family option[value=" + CurrentFontFamily + "]").prop('selected', true); |
... | ... | @@ -3687,13 +3775,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3687 | 3775 | } |
3688 | 3776 | }, |
3689 | 3777 | change: function (layer) { |
3690 | - | |
3778 | + | |
3691 | 3779 | if ($rootScope.isTextAReaRectangleClickedAftrEdit == true) { |
3692 | 3780 | if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { |
3693 | 3781 | console.log(layer.x + " " + layer.y); |
3694 | 3782 | console.log($rootScope.textXAxisAftrResize + " " + $rootScope.textYAxisAftrResize); |
3695 | 3783 | $rootScope.isTextAReaRectangleClickedAftrEdit = false; |
3696 | - | |
3784 | + | |
3697 | 3785 | for (var i = 0; i <= $rootScope.initTextAreaValues.length - 1; i++) { |
3698 | 3786 | |
3699 | 3787 | if ($rootScope.initTextAreaValues[i].name == layer.name) { |
... | ... | @@ -3709,6 +3797,48 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3709 | 3797 | x: layer.x, |
3710 | 3798 | y: layer.y |
3711 | 3799 | }); |
3800 | + | |
3801 | + | |
3802 | + | |
3803 | + | |
3804 | + $("#textspan").empty(); | |
3805 | + $("#duptextspan").empty(); | |
3806 | + var textWidthCounter = 0; | |
3807 | + var textAftrResize; | |
3808 | + for (var i = 0; i <= $rootScope.resieTextArray1.length - 1; i++) { | |
3809 | + if ($rootScope.resieTextArray1[i].layerName == CangedTextAreaName) { | |
3810 | + if (/(\r\n)/gm.test($rootScope.resieTextArray1[i].Rect_Text) || /\s/.test($rootScope.resieTextArray1[i].Rect_Text)) { | |
3811 | + textAftrResize = ($rootScope.resieTextArray1[i].Rect_Text).replace(/(\r\n)/gm, ""); | |
3812 | + for (var i = 0; i <= $rootScope.textWidth1.length - 1; i++) { | |
3813 | + if ($rootScope.textWidth1[i].id == layer.name) { | |
3814 | + textWidthCounter = textWidthCounter + $rootScope.textWidth1[i].width; | |
3815 | + if (textWidthCounter < layer.width) { | |
3816 | + $("#duptextspan").append($rootScope.textWidth1[i].character); | |
3817 | + $("#textspan").append($rootScope.textWidth1[i].character); | |
3818 | + } | |
3819 | + else { | |
3820 | + $("#duptextspan").append("\r\n"); | |
3821 | + $("#textspan").append("\r\n"); | |
3822 | + $("#duptextspan").append($rootScope.textWidth1[i].character); | |
3823 | + $("#textspan").text(''); | |
3824 | + $("#textspan").append($rootScope.textWidth1[i].character); | |
3825 | + textWidthCounter = 0; | |
3826 | + } | |
3827 | + } | |
3828 | + } | |
3829 | + textAftrResize = $("#duptextspan").text(); | |
3830 | + $('#canvas').setLayer(CangedTextAreaName, { | |
3831 | + text: textAftrResize, | |
3832 | + }); | |
3833 | + } | |
3834 | + } | |
3835 | + } | |
3836 | + | |
3837 | + | |
3838 | + | |
3839 | + | |
3840 | + | |
3841 | + | |
3712 | 3842 | } |
3713 | 3843 | } |
3714 | 3844 | |
... | ... | @@ -3757,6 +3887,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3757 | 3887 | // console.log(layer.x + " " + layer.y); |
3758 | 3888 | $rootScope.editTextXAxisAftrResize = layer.x; |
3759 | 3889 | $rootScope.editTextYAxisAftrResize = layer.y; |
3890 | + $rootScope.resieTextArray1.push({ layerName: layer.name, Rect_Text: layer.text }); | |
3760 | 3891 | } |
3761 | 3892 | }); |
3762 | 3893 | ... | ... |