From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- .../static/src/img/badge_bronze.svg | 1 + .../website_profile/static/src/img/badge_gold.svg | 1 + .../static/src/img/badge_silver.svg | 1 + addons/website_profile/static/src/img/rank_1.svg | 1 + addons/website_profile/static/src/img/rank_2.svg | 1 + addons/website_profile/static/src/img/rank_3.svg | 1 + .../static/src/js/website_profile.js | 143 ++++++++++++ .../static/src/scss/website_profile.scss | 256 +++++++++++++++++++++ 8 files changed, 405 insertions(+) create mode 100644 addons/website_profile/static/src/img/badge_bronze.svg create mode 100644 addons/website_profile/static/src/img/badge_gold.svg create mode 100644 addons/website_profile/static/src/img/badge_silver.svg create mode 100644 addons/website_profile/static/src/img/rank_1.svg create mode 100644 addons/website_profile/static/src/img/rank_2.svg create mode 100644 addons/website_profile/static/src/img/rank_3.svg create mode 100644 addons/website_profile/static/src/js/website_profile.js create mode 100644 addons/website_profile/static/src/scss/website_profile.scss (limited to 'addons/website_profile/static/src') diff --git a/addons/website_profile/static/src/img/badge_bronze.svg b/addons/website_profile/static/src/img/badge_bronze.svg new file mode 100644 index 00000000..a94491e8 --- /dev/null +++ b/addons/website_profile/static/src/img/badge_bronze.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/addons/website_profile/static/src/img/badge_gold.svg b/addons/website_profile/static/src/img/badge_gold.svg new file mode 100644 index 00000000..423f63e6 --- /dev/null +++ b/addons/website_profile/static/src/img/badge_gold.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/addons/website_profile/static/src/img/badge_silver.svg b/addons/website_profile/static/src/img/badge_silver.svg new file mode 100644 index 00000000..dd16d4f2 --- /dev/null +++ b/addons/website_profile/static/src/img/badge_silver.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/addons/website_profile/static/src/img/rank_1.svg b/addons/website_profile/static/src/img/rank_1.svg new file mode 100644 index 00000000..6477a906 --- /dev/null +++ b/addons/website_profile/static/src/img/rank_1.svg @@ -0,0 +1 @@ +1st \ No newline at end of file diff --git a/addons/website_profile/static/src/img/rank_2.svg b/addons/website_profile/static/src/img/rank_2.svg new file mode 100644 index 00000000..e9ae886a --- /dev/null +++ b/addons/website_profile/static/src/img/rank_2.svg @@ -0,0 +1 @@ +2nd \ No newline at end of file diff --git a/addons/website_profile/static/src/img/rank_3.svg b/addons/website_profile/static/src/img/rank_3.svg new file mode 100644 index 00000000..8c22af97 --- /dev/null +++ b/addons/website_profile/static/src/img/rank_3.svg @@ -0,0 +1 @@ +3rd \ No newline at end of file diff --git a/addons/website_profile/static/src/js/website_profile.js b/addons/website_profile/static/src/js/website_profile.js new file mode 100644 index 00000000..105bdb03 --- /dev/null +++ b/addons/website_profile/static/src/js/website_profile.js @@ -0,0 +1,143 @@ +odoo.define('website_profile.website_profile', function (require) { +'use strict'; + +var publicWidget = require('web.public.widget'); +var wysiwygLoader = require('web_editor.loader'); + +publicWidget.registry.websiteProfile = publicWidget.Widget.extend({ + selector: '.o_wprofile_email_validation_container', + read_events: { + 'click .send_validation_email': '_onSendValidationEmailClick', + 'click .validated_email_close': '_onCloseValidatedEmailClick', + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + /** + * @private + * @param {Event} ev + */ + _onSendValidationEmailClick: function (ev) { + ev.preventDefault(); + var self = this; + var $element = $(ev.currentTarget); + this._rpc({ + route: '/profile/send_validation_email', + params: {'redirect_url': $element.data('redirect_url')}, + }).then(function (data) { + if (data) { + self.$('button.validation_email_close').click(); + } + }); + }, + + /** + * @private + */ + _onCloseValidatedEmailClick: function () { + this._rpc({ + route: '/profile/validate_email/close', + }); + }, +}); + +publicWidget.registry.websiteProfileEditor = publicWidget.Widget.extend({ + selector: '.o_wprofile_editor_form', + read_events: { + 'click .o_forum_profile_pic_edit': '_onEditProfilePicClick', + 'change .o_forum_file_upload': '_onFileUploadChange', + 'click .o_forum_profile_pic_clear': '_onProfilePicClearClick', + 'click .o_wprofile_submit_btn': '_onSubmitClick', + }, + + /** + * @override + */ + start: function () { + var def = this._super.apply(this, arguments); + if (this.editableMode) { + return def; + } + + // Warning: Do not activate any option that adds inline style. + // Because the style is deleted after save. + var toolbar = [ + ['style', ['style']], + ['font', ['bold', 'italic', 'underline', 'clear']], + ['para', ['ul', 'ol', 'paragraph']], + ['table', ['table']], + ['insert', ['link', 'picture']], + ['history', ['undo', 'redo']], + ]; + + var $textarea = this.$('textarea.o_wysiwyg_loader'); + var loadProm = wysiwygLoader.load(this, $textarea[0], { + toolbar: toolbar, + recordInfo: { + context: this._getContext(), + res_model: 'res.users', + res_id: parseInt(this.$('input[name=user_id]').val()), + }, + disableResizeImage: true, + }).then(wysiwyg => { + this._wysiwyg = wysiwyg; + }); + + return Promise.all([def, loadProm]); + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * @private + * @param {Event} ev + */ + _onEditProfilePicClick: function (ev) { + ev.preventDefault(); + $(ev.currentTarget).closest('form').find('.o_forum_file_upload').trigger('click'); + }, + /** + * @private + * @param {Event} ev + */ + _onFileUploadChange: function (ev) { + if (!ev.currentTarget.files.length) { + return; + } + var $form = $(ev.currentTarget).closest('form'); + var reader = new window.FileReader(); + reader.readAsDataURL(ev.currentTarget.files[0]); + reader.onload = function (ev) { + $form.find('.o_forum_avatar_img').attr('src', ev.target.result); + }; + $form.find('#forum_clear_image').remove(); + }, + /** + * @private + * @param {Event} ev + */ + _onProfilePicClearClick: function (ev) { + var $form = $(ev.currentTarget).closest('form'); + $form.find('.o_forum_avatar_img').attr('src', '/web/static/src/img/placeholder.png'); + $form.append($('', { + name: 'clear_image', + id: 'forum_clear_image', + type: 'hidden', + })); + }, + /** + * @private + */ + _onSubmitClick: function () { + if (this._wysiwyg) { + this._wysiwyg.save(); + } + }, +}); + +return publicWidget.registry.websiteProfile; + +}); diff --git a/addons/website_profile/static/src/scss/website_profile.scss b/addons/website_profile/static/src/scss/website_profile.scss new file mode 100644 index 00000000..98e7da85 --- /dev/null +++ b/addons/website_profile/static/src/scss/website_profile.scss @@ -0,0 +1,256 @@ +// Retrive the tab's height by summ its properties +$owprofile-tabs-height: ($nav-link-padding-y*2) + ($font-size-base * $line-height-base); + +// Overal page bg-color: Blend it 'over' the color chosen by the user +// ($body-bg), rather than force it replacing the variable's value. +$owprofile-color-bg: mix($body-bg, #efeff4); + +.o_wprofile_body { + background-color: $owprofile-color-bg; +} + +.o_wprofile_gradient { + background-image: linear-gradient(120deg, #875A7B, darken(#875A7B, 10%)); +} + +.o_wprofile_pict { + @include size(100%); + padding-top: 30%; + background-size: cover; + background-position: center; + + @include media-breakpoint-up(md) { + padding-top: 70%; + border: 1px solid darken(#875A7B, 10%); + border-bottom-width: 0; + } +} + +.o_wprofile_header { + @include media-breakpoint-up(md) { + &:before { + content: ""; + @include o-position-absolute(auto, 0, 0, 0); + height: $owprofile-tabs-height; + background: rgba(black, 0.2); + } + } +} + +.o_wprofile_sidebar { + border: 1px solid $border-color; + + @include media-breakpoint-up(md) { + border-top-width: 0; + } +} + +.o_wprofile_nav_tabs { + @include media-breakpoint-up(md) { + margin-top: $owprofile-tabs-height * -1; + border-bottom: 0; + + .nav-link { + border-radius: 0; + border-width: 0 1px; + line-height: $line-height-base; + @include o-hover-text-color(rgba(white, 0.8), white); + + & { + border-color: transparent; + } + + &:hover { + border-color: transparent; + background: #3d2938; + } + + &.active { + color: color-yiq($owprofile-color-bg); + background: $owprofile-color-bg; + border-color: $owprofile-color-bg; + } + } + } + + @include media-breakpoint-only(xs) { + overflow-x: auto; + overflow-y: hidden; + + li { + white-space: nowrap; + } + } +} + +.o_wprofile_tabs_content { + @include media-breakpoint-down(sm) { + background-color: $nav-tabs-link-active-bg; + padding:0 ($grid-gutter-width * 0.5); + } + + @include media-breakpoint-only(xs) { + margin: 0 ($grid-gutter-width * -0.5); + } +} + +/// Progress Circle +.o_wprofile_progress_circle { + position: relative; + + svg.o_pc_circular_chart { + display: block; + max-width: 100%; + + .o_pc_circle_bg, .o_pc_circle { + fill: none; + stroke-width: 1.5px; + stroke-linecap: round; + } + + .o_pc_circle_bg { + stroke: rgba(black, 0.1); + } + + .o_pc_circle { + animation: progress 1s ease-out forwards; + } + + #gradient { + --o-pc-color-stop-1: lighten(theme-color('primary'), 10%); + --o-pc-color-stop-2: theme-color('primary'); + } + } + + .o_pc_overlay { + @include o-position-absolute(0,0,0,0); + } + + @keyframes progress { + 0% { + stroke-dasharray: 0 100; + } + } +} + +// All Users Page +.o_wprofile_all_users_nav { + border-width: 1px 0; + + &, .o_wprofile_course_nav_search, .o_wprofile_all_users_nav_btn { + background-color: rgba(white, 0.05); + border-color: rgba(white, 0.1); + border-style: solid; + } + + .o_wprofile_course_nav_search, .o_wprofile_all_users_nav_btn { + border-width: 0 1px; + } + + .o_wprofile_all_users_nav_btn { + @include media-breakpoint-up(md) { + @include o-hover-text-color(white, $gray-800); + margin-top: -1px; + border-radius: 0; + min-height: 35px; + + &:hover { + background-color: white; + } + } + } + + .o_wprofile_all_users_nav_btn_container { + @include media-breakpoint-down(sm) { + ~ .o_wprofile_user_profile_sub_nav_mobile_col { + padding-left: 0; + } + + .o_wprofile_all_users_nav_btn { + @include o-hover-text-color(white, white); + border-radius: $btn-border-radius; + background-color: rgba(black, 0.25); + } + } + } + + .breadcrumb-item.active a, .breadcrumb-item a:hover { + color: white; + } + + .breadcrumb-item a, .breadcrumb-item + .breadcrumb-item::before, .o_wprofile_course_nav_search input::placeholder { + color: rgba(white, 0.8); + } +} + +.o_wprofile_top3_card_footer div { + border-color: $border-color; + border-style: solid; + border-width: 1px 0; + margin-top: -1px; + + + div { + border-left-width: 1px; + margin-left: -1px; + } +} + +.o_wprofile_pager { + li.page-item { + a.page-link { + background-color: transparent; + border: 0; + color: $gray-600; + transition-duration: .3s; + + &:hover { + color: $primary; + } + } + + &.active { + a.page-link { + color: $white; + } + } + + &.o_wprofile_pager_arrow a { + color: $primary; + + &:hover { + transform: scaleX(1.50) scaleY(1.50); + } + } + + &.o_wprofile_pager_arrow.disabled a { + color: $gray-600; + } + + .page-link:focus { + box-shadow: 0 0 0 0; + } + } +} + +.wprofile_badge_img { + height: 2.5em; +} + + +// Other stuffs +.country_flag { + display: inline-block; + margin-left: 2px; + max-height: 13px; + width: auto !important; +} + +// Tools +.o_wprofile_pointer { + cursor: pointer; +} + +// Own profile border +.o_wprofile_border_focus { + border-left: 4px solid theme-color('secondary'); +} -- cgit v1.2.3