diff --git a/addons/website_forum/static/src/css/website_forum.css b/addons/website_forum/static/src/css/website_forum.css index 5263b7beb79..77a021a668f 100644 --- a/addons/website_forum/static/src/css/website_forum.css +++ b/addons/website_forum/static/src/css/website_forum.css @@ -53,6 +53,6 @@ height: 1.2em !important; } -#question_tag{ - width: 825px !important; +.load_tags{ + width: 845px !important; } \ No newline at end of file diff --git a/addons/website_forum/static/src/js/website_forum.editor.js b/addons/website_forum/static/src/js/website_forum.editor.js index d166e3f711b..4c4887f6b38 100644 --- a/addons/website_forum/static/src/js/website_forum.editor.js +++ b/addons/website_forum/static/src/js/website_forum.editor.js @@ -29,98 +29,3 @@ }), }); })(); - -$(document).ready(function () { - - $('.fa-thumbs-up ,.fa-thumbs-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}) - .then(function (data) { - if (data == false){ - vote_alert = $link.parents().find("#vote_alert"); - if (vote_alert.length <= 1) { - var $warning = $('
'+ - ''+ - 'Sorry, you cannot vote for your own posts'+ - '
'); - $link.parents().find("#post_vote").append($warning); - } - } else { - $link.parent().find("#vote_count").html(data['vote_count']); - if (data == 0) { - $link.parent().find(".text-success").removeClass("text-success"); - $link.parent().find(".text-warning").removeClass("text-warning"); - } else { - if (value == 1) { - $link.addClass("text-success"); - } else { - $link.addClass("text-warning"); - } - } - } - }); - 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) { - $link.parents('#answer').remove(); - }); - return false; - }); - - $('.fa-check').on('click', function (ev) { - ev.preventDefault(); - var $link = $(ev.currentTarget); - openerp.jsonRpc("/forum/correct_answer/", 'call', { - 'post_id': $link.attr("id")}) - .then(function (data) { - par = $link.parents().find(".oe_answer_true") - $link.parents().find(".oe_answer_true").removeClass("oe_answer_true").addClass('oe_answer_false') - if (data) { - $link.removeClass("oe_answer_false").addClass('oe_answer_true'); - } - }); - return false; - }); - - $('.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(); - }); - return true; - }); - - $('.notification_close').on('click', function (ev) { - ev.preventDefault(); - var $link = $(ev.currentTarget); - openerp.jsonRpc("/forum/notification_read/", 'call', { - 'notification_id': $link.attr("id")}) - return true; - }); - - openerp.jsonRpc('/forum/get_tags/','call' ,{}).then(function(data){ - var previous_tags = $("#question_tag").val(); - $("#question_tag").val(""); - var array_of_tags = previous_tags.split(","); - $('#question_tag').textext({ - plugins : 'tags suggestions autocomplete', - tagsItems : array_of_tags, - suggestions :data, - }); - return true; - }); - -}); \ No newline at end of file diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js new file mode 100644 index 00000000000..38bfbfc434c --- /dev/null +++ b/addons/website_forum/static/src/js/website_forum.js @@ -0,0 +1,95 @@ +$(document).ready(function () { + + $('.fa-thumbs-up ,.fa-thumbs-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}) + .then(function (data) { + if (data == false){ + vote_alert = $link.parents().find("#vote_alert"); + if (vote_alert.length <= 1) { + var $warning = $('
'+ + ''+ + 'Sorry, you cannot vote for your own posts'+ + '
'); + $link.parents().find("#post_vote").append($warning); + } + } else { + $link.parent().find("#vote_count").html(data['vote_count']); + if (data == 0) { + $link.parent().find(".text-success").removeClass("text-success"); + $link.parent().find(".text-warning").removeClass("text-warning"); + } else { + if (value == 1) { + $link.addClass("text-success"); + } else { + $link.addClass("text-warning"); + } + } + } + }); + 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) { + $link.parents('#answer').remove(); + }); + return false; + }); + + $('.fa-check').on('click', function (ev) { + ev.preventDefault(); + var $link = $(ev.currentTarget); + openerp.jsonRpc("/forum/correct_answer/", 'call', { + 'post_id': $link.attr("id")}) + .then(function (data) { + par = $link.parents().find(".oe_answer_true") + $link.parents().find(".oe_answer_true").removeClass("oe_answer_true").addClass('oe_answer_false') + if (data) { + $link.removeClass("oe_answer_false").addClass('oe_answer_true'); + } + }); + return false; + }); + + $('.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(); + }); + return true; + }); + + $('.notification_close').on('click', function (ev) { + ev.preventDefault(); + var $link = $(ev.currentTarget); + openerp.jsonRpc("/forum/notification_read/", 'call', { + 'notification_id': $link.attr("id")}) + return true; + }); + + if($('input.load_tags').length){ + openerp.jsonRpc('/forum/get_tags/','call' ,{}).then(function(data){ + var previous_tags = $("input.load_tags").val(); + $("input.load_tags").val(""); + $("input.load_tags").textext({ + plugins : 'tags suggestions autocomplete', + tagsItems : previous_tags.split(","), + suggestions :data, + }); + return true; + }) + }; + +}); \ No newline at end of file diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index 287696da024..b487b31ed54 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -6,15 +6,17 @@ name="Event Editor"> - + src="/website_forum/static/src/js/website.tour.forum.js"/> - + + + + + - - - -