diff options
| author | qsm-odoo <qsm@odoo.com> | 2019-02-06 14:29:07 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2019-02-26 17:09:22 +0000 |
| commit | 27fca749af30d7dce448f6632132422df8d8a7c1 (patch) | |
| tree | c644db5efbb12cde722d059d250a83ec0de8aed7 /addons/project/static/src/js | |
| parent | c3da83b40a6431f607cf69b8c2a7a922a6e5b52c (diff) | |
[REF] *: use 'frontend' system in non-website apps
* account, auth_signup, payment, portal, project, sale, sale_management,
web_unsplash, website, website_mail, website_rating, website_sale
This commit does probably not do what is stated for all non-website apps
but it is a first step. It also uses the system in apps which could have
already used it but did not.
Part of https://github.com/odoo/odoo/pull/29442
task-1932066
Diffstat (limited to 'addons/project/static/src/js')
| -rw-r--r-- | addons/project/static/src/js/portal_rating.js | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/addons/project/static/src/js/portal_rating.js b/addons/project/static/src/js/portal_rating.js index 12740b9bbba..e1b51d9edc1 100644 --- a/addons/project/static/src/js/portal_rating.js +++ b/addons/project/static/src/js/portal_rating.js @@ -1,27 +1,32 @@ odoo.define('website_rating_project.rating', function (require) { 'use strict'; - var time = require('web.time'); - require('web.dom_ready'); +var time = require('web.time'); +var publicWidget = require('web.public.widget'); - if(!$('.o_portal_project_rating').length) { - return $.Deferred().reject("DOM doesn't contain '.o_portal_project_rating'"); - } +publicWidget.registry.ProjectRatingImage = publicWidget.Widget.extend({ + selector: '.o_portal_project_rating .o_rating_image', - /** - * Rating popover with some informations - */ - $('.o_portal_project_rating .o_rating_image').popover({ - placement: 'bottom', - trigger: 'hover', - html: 'true', - content: function () { - var id = $(this).data('id'); - var rating_date = $(this).data('rating-date'); - var base_date = time.auto_str_to_date(rating_date); - var duration = moment(base_date).fromNow(); - $("#rating_"+ id).find(".rating_timeduration").text(duration); - return $("#rating_"+ id).html(); - } - }); + /** + * @override + */ + start: function () { + this.$el.popover({ + placement: 'bottom', + trigger: 'hover', + html: 'true', + content: function () { + var $elem = $(this); + var id = $elem.data('id'); + var ratingDate = $elem.data('rating-date'); + var baseDate = time.auto_str_to_date(ratingDate); + var duration = moment(baseDate).fromNow(); + var $rating = $('#rating_' + id); + $rating.find('.rating_timeduration').text(duration); + return $rating.html(); + }, + }); + return this._super.apply(this, arguments); + }, +}); }); |
