From 6ca442f9cc30ce24d61a9636fddc9077a1106814 Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Tue, 24 Jul 2018 11:57:25 +0530 Subject: [PATCH] frontend: dynamically generate width and position --- frontend/js/commento.js | 29 +++++++++-------------------- frontend/sass/commento-buttons.scss | 11 ----------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/frontend/js/commento.js b/frontend/js/commento.js index e2e9752..52908a7 100644 --- a/frontend/js/commento.js +++ b/frontend/js/commento.js @@ -694,37 +694,27 @@ else attrSet(reply, "onclick", "loginBoxShow()"); - if (isAuthenticated) { - if (isModerator) { - if (comment.state == "unapproved") - attrSet(options, "style", "width: 192px;"); - else - attrSet(options, "style", "width: 160px;"); - } - else - attrSet(options, "style", "width: 128px;"); - } - else - attrSet(options, "style", "width: 32px;"); - if (commenter.link != "undefined") attrSet(name, "href", commenter.link); - if (false) // replace when edit is implemented - append(options, edit); + append(options, collapse); - append(options, upvote); + // append(options, edit); // uncomment when implemented append(options, downvote); + append(options, upvote); append(options, reply); - if (isModerator) { + append(options, remove); if (comment.state == "unapproved") append(options, approve); - append(options, remove); } - append(options, collapse); + attrSet(options, "style", "width: " + ((options.childNodes.length+1)*32) + "px;"); + for (var i = 0; i < options.childNodes.length; i++) + attrSet(options.childNodes[i], "style", "right: " + (i*32) + "px;"); + append(subtitle, score); + append(header, options); append(header, avatar); append(header, name); @@ -764,7 +754,6 @@ var tick = $(ID_APPROVE + commentHex); classRemove(card, "dark-card"); - attrSet(options, "style", "width: 160px;"); remove(tick); }); } diff --git a/frontend/sass/commento-buttons.scss b/frontend/sass/commento-buttons.scss index 3edc9de..8831821 100644 --- a/frontend/sass/commento-buttons.scss +++ b/frontend/sass/commento-buttons.scss @@ -21,7 +21,6 @@ width: 20px; @include mask-image('data:image/svg+xml;utf8,'); margin: 9px 3px 9px 3px; - right: 32px; } .commento-option-cancel { @@ -29,7 +28,6 @@ width: 13px; @include mask-image('data:image/svg+xml;utf8,'); margin: 12px 6px 12px 6px; - right: 32px; background: $gray-5; } @@ -38,7 +36,6 @@ width: 14px; @include mask-image('data:image/svg+xml;utf8,'); margin: 12px 6px 12px 6px; - right: 0px; background: $gray-7; } @@ -47,7 +44,6 @@ width: 14px; @include mask-image('data:image/svg+xml;utf8,'); margin: 12px 6px 12px 6px; - right: 0px; background: $gray-7; } @@ -59,13 +55,8 @@ margin: 12px 6px 12px 6px; } -.commento-option-upvote { - right: 96px; -} - .commento-option-downvote { transform: rotate(180deg); - right: 64px; } .commento-upvoted { @@ -81,7 +72,6 @@ width: 14px; @include mask-image('data:image/svg+xml;utf8, '); margin: 12px 6px 12px 6px; - right: 128px; background: $red-8; } @@ -90,7 +80,6 @@ width: 14px; @include mask-image('data:image/svg+xml;utf8,'); margin: 12px 6px 12px 6px; - right: 160px; background: $green-7; }