summaryrefslogtreecommitdiff
path: root/addons/website_forum/static/src
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2014-04-11 15:29:39 +0200
committerThibault Delavallée <tde@openerp.com>2014-04-11 15:29:39 +0200
commitcd4afee17e77d5d5de8dc27f7dbe56be6d8fe7a2 (patch)
tree70f6a320d9359206621887dc46e3d2ff5f431fac /addons/website_forum/static/src
parent4b776a90c0c65a1e0cfecfcdbc638462a9ece8e5 (diff)
[CLEAN] website_forum: cleaning before merging
- cleaned models - cleaned controllers: lots of cleaning, rewriting, simplfiication + updated in views - added an override of the contact widget, to be able to display partner-related stuff about karma and badges - some css tweaking - badges cleaning bzr revid: tde@openerp.com-20140411132939-bmvyc9bqpqpkk843
Diffstat (limited to 'addons/website_forum/static/src')
-rw-r--r--addons/website_forum/static/src/css/Makefile7
-rw-r--r--addons/website_forum/static/src/css/website_forum.css15
-rw-r--r--addons/website_forum/static/src/css/website_forum.sass10
-rw-r--r--addons/website_forum/static/src/js/website_forum.js122
4 files changed, 65 insertions, 89 deletions
diff --git a/addons/website_forum/static/src/css/Makefile b/addons/website_forum/static/src/css/Makefile
index 867a1fedb38..ceee4ae3f7a 100644
--- a/addons/website_forum/static/src/css/Makefile
+++ b/addons/website_forum/static/src/css/Makefile
@@ -1,2 +1,5 @@
-sass:
- sass --compass --unix-newlines -t expanded website_forum.sass:website_forum.css
+all: website_forum.css
+%.css: %.sass
+ sass -t expanded --compass --unix-newlines $< $@
+watch:
+ sass -t expanded --compass --unix-newlines --watch .:.
diff --git a/addons/website_forum/static/src/css/website_forum.css b/addons/website_forum/static/src/css/website_forum.css
index 6548e8d01b1..e83242c1484 100644
--- a/addons/website_forum/static/src/css/website_forum.css
+++ b/addons/website_forum/static/src/css/website_forum.css
@@ -1,17 +1,16 @@
.box {
padding-left: 8px;
padding-right: 8px;
+ margin-left: 4px;
+ margin-right: 4px;
border-radius: 4px;
+ min-width: 80px;
}
.box span {
font-size: 200%;
font-weight: bold;
}
-.question div.pull-left {
- margin-right: 14px;
- min-width: 80px;
-}
.question .question-name {
font-size: 150%;
}
@@ -64,13 +63,11 @@ a.no-decoration {
}
.oe_comment_grey {
- -moz-box-shadow: 0px 4px 6px 2px #eeeeee;
- -webkit-box-shadow: 0px 4px 6px 2px #eeeeee;
- box-shadow: 0px 4px 6px 2px #eeeeee;
+ color: whitesmoke;
}
-.forum_user_flag {
- max-width: 25px;
+.country_flag {
+ max-height: 16px;
display: inline-block;
margin-left: 2px;
}
diff --git a/addons/website_forum/static/src/css/website_forum.sass b/addons/website_forum/static/src/css/website_forum.sass
index 555250bd6f3..d3c239b7dc4 100644
--- a/addons/website_forum/static/src/css/website_forum.sass
+++ b/addons/website_forum/static/src/css/website_forum.sass
@@ -1,15 +1,15 @@
.box
padding-left: 8px
padding-right: 8px
+ margin-left: 4px
+ margin-right: 4px
border-radius: 4px
+ min-width: 80px
span
font-size: 200%
font-weight: bold
.question
- div.pull-left
- margin-right: 14px
- min-width: 80px
.question-name
font-size: 150%
@@ -52,8 +52,8 @@ a.no-decoration
.oe_comment_grey
color: #f5f5f5
-.forum_user_flag
- max-width: 25px
+.country_flag
+ max-height: 16px
display: inline-block
margin-left: 2px
diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js
index 907e5d47a01..202b0a7d90d 100644
--- a/addons/website_forum/static/src/js/website_forum.js
+++ b/addons/website_forum/static/src/js/website_forum.js
@@ -3,11 +3,11 @@ $(document).ready(function () {
$('.vote_up ,.vote_down').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
- var value = $link.attr("value")
-
- openerp.jsonRpc("/forum/post_vote", 'call', {
- 'post_id': $link.attr("id"),
- 'vote': value})
+ var url_target = $link.data("value") == '1' ? 'upvote' : 'downvote';
+ var forum_id = $link.data('forum-id');
+ var post_id = $link.data('post-id');
+
+ openerp.jsonRpc("/forum/" + forum_id + "/post/" + post_id + "/" + url_target, 'call', {})
.then(function (data) {
if (data['error']){
if (data['error'] == 'own_post'){
@@ -38,7 +38,7 @@ $(document).ready(function () {
$link.parent().find(".text-success").removeClass("text-success");
$link.parent().find(".text-warning").removeClass("text-warning");
} else {
- if (value == 1) {
+ if (data['vote_count'] == 1) {
$link.addClass("text-success");
} else {
$link.addClass("text-warning");
@@ -49,75 +49,65 @@ $(document).ready(function () {
return true;
});
- $('.delete').on('click', function (ev) {
- ev.preventDefault();
- var $link = $(ev.currentTarget);
- openerp.jsonRpc("/forum/post_delete", 'call', {
- 'post_id': $link.attr("id")})
- .then(function (data) {
- $("div#answer_" + $link.attr('id')).remove();
- });
- return false;
- });
-
$('.accept_answer').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
- openerp.jsonRpc("/forum/correct_answer", 'call', {
- 'post_id': $link.attr("id")})
- .then(function (data) {
- if (data['error']) {
- if (data['error'] == 'anonymous_user'){
- var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
- '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
- 'Sorry, anonymous users cannot choose correct answer.'+
- '</div>');
- } else if (data['error'] == 'user'){
- var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
- '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
- 'Sorry, the user who asked this question can only accept the answer as correct.'+
- '</div>');
- }
- correct_answer_alert = $link.parent().find("#correct_answer_alert");
- if (correct_answer_alert.length == 0) {
- $link.parent().append($warning);
- }
- } else {
- $link.parents().find(".oe_answer_true").removeClass("oe_answer_true alert alert-info").addClass('oe_answer_false');
- $link.parents().find(".answer_correct").removeClass("answer_correct alert alert-info")
- if (data) {
- $link.removeClass("oe_answer_false").addClass('oe_answer_true');
- $("div#answer_" + $link.attr('id')).addClass("answer_correct alert alert-info");
- console.log("aaaaa",$("div#answer_" + $link.attr('id')))
- }
+ var forum_id = $link.data('forum-id');
+ var post_id = $link.data('post-id');
+ openerp.jsonRpc("/forum/" + forum_id + "/post/" + post_id + "/toggle_correct", 'call', {}).then(function (data) {
+ if (data['error']) {
+ if (data['error'] == 'anonymous_user'){
+ var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
+ '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
+ 'Sorry, anonymous users cannot choose correct answer.'+
+ '</div>');
+ } else if (data['error'] == 'user'){
+ var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
+ '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
+ 'Sorry, the user who asked this question can only accept the answer as correct.'+
+ '</div>');
}
- });
+ correct_answer_alert = $link.parent().find("#correct_answer_alert");
+ if (correct_answer_alert.length == 0) {
+ $link.parent().append($warning);
+ }
+ } else {
+ $link.parents().find(".oe_answer_true").removeClass("oe_answer_true alert alert-info").addClass('oe_answer_false');
+ $link.parents().find(".answer_correct").removeClass("answer_correct alert alert-info")
+ if (data) {
+ $link.removeClass("oe_answer_false").addClass('oe_answer_true');
+ $("div#answer_" + $link.attr('id')).addClass("answer_correct alert alert-info");
+ console.log("aaaaa",$("div#answer_" + $link.attr('id')))
+ }
+ }
+ });
return true;
});
$('.favourite_question').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
- openerp.jsonRpc("/forum/favourite_question", 'call', {
- 'post_id': $link.attr("id")})
- .then(function (data) {
- if (data) {
- $link.addClass("forum_favourite_question")
- } else {
- $link.removeClass("forum_favourite_question")
- }
- });
+ var forum_id = $link.data('forum-id');
+ var post_id = $link.data('post-id');
+ openerp.jsonRpc("/forum/" + forum_id + "/question/" + post_id + "/toggle_favourite", 'call', {}).then(function (data) {
+ if (data) {
+ $link.addClass("forum_favourite_question")
+ } else {
+ $link.removeClass("forum_favourite_question")
+ }
+ });
return true;
});
$('.comment_delete').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
- openerp.jsonRpc("/forum/message_delete", 'call', {
- 'message_id': $link.attr("id")})
- .then(function (data) {
- $link.parents('#comment').remove();
- });
+ var forum_id = $link.data('forum-id');
+ var post_id = $link.data('post-id');
+ var message_id = $link.data('message-id');
+ openerp.jsonRpc("/forum/message_delete", 'call', {}).then(function (data) {
+ $link.parents('#comment').remove();
+ });
return true;
});
@@ -155,20 +145,6 @@ $(document).ready(function () {
});
}
- $('.post_history').change(function (ev) {
- var $option = $(ev.currentTarget);
- openerp.jsonRpc("/forum/selecthistory", 'call', {
- 'history_id': $option.attr("value")})
- .then(function (data) {
- var $input = $('<input type="text" name="question_tag" class="form-control col-md-9 load_tags" placeholder="Tags"/>')
- $option.parent().find(".text-core").replaceWith($input);
- set_tags(data['tags']);
- $option.parent().find("#question_name").attr('value', data['name']);
- CKEDITOR.instances['content'].setData(data['content'])
- })
- return true;
- });
-
if ($('textarea.load_editor').length) {
var editor = CKEDITOR.instances['content'];
editor.on('instanceReady', CKEDITORLoadComplete);