diff options
| author | Parth Gajjar <pga@openerp.com> | 2015-01-29 16:59:25 +0100 |
|---|---|---|
| committer | Jérome Maes <jem@openerp.com> | 2015-03-12 15:41:10 +0100 |
| commit | f76ca21b15cfa67c04d5931efb4ac53a34a33e71 (patch) | |
| tree | a9c80e8da7682d960d898775c2edf5d0cad7648f /addons/website_forum/static/src | |
| parent | 9804ee91c5fa503b7a3397337777c2ecb5689a6e (diff) | |
[IMP] website_forum : improve tag ordering, add 'in menu' checkox when create a forum, customize welcome_message on a forum, better fetch link title when insert it, display answers of a question on form view, ans some changes in faq
Diffstat (limited to 'addons/website_forum/static/src')
4 files changed, 60 insertions, 16 deletions
diff --git a/addons/website_forum/static/src/css/website_forum.css b/addons/website_forum/static/src/css/website_forum.css index 79fd7dd330c..395167cf615 100644 --- a/addons/website_forum/static/src/css/website_forum.css +++ b/addons/website_forum/static/src/css/website_forum.css @@ -50,9 +50,17 @@ img.img-avatar { .oe_answer_true { color: #3c763d; } +.forum_answer .oe_answer_true:hover { + color: #4D964E; +} + .oe_answer_false { color: #bbbbbb; } +.oe_answer_false:hover { + color: #9E9C9C; +} + .favourite_question { color: #bbbbbb !important; } @@ -100,4 +108,6 @@ a.no-decoration { z-index: 5; } button.btn-link.text-muted { - color: #999999; } + color: #999999; +} + diff --git a/addons/website_forum/static/src/css/website_forum.sass b/addons/website_forum/static/src/css/website_forum.sass index 8ade74975ea..1313516a084 100644 --- a/addons/website_forum/static/src/css/website_forum.sass +++ b/addons/website_forum/static/src/css/website_forum.sass @@ -51,9 +51,15 @@ img.img-avatar .oe_answer_true color: #3c763d + &:hover { + color: #4D964E; + } .oe_answer_false color: #bbbbbb + &:hover { + color: #9E9C9C; + } .favourite_question color: #bbbbbb !important 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 6687ed5e3f2..b14191b3557 100644 --- a/addons/website_forum/static/src/js/website_forum.editor.js +++ b/addons/website_forum/static/src/js/website_forum.editor.js @@ -9,10 +9,24 @@ website.prompt({ id: "editor_new_forum", window_title: _t("New Forum"), - input: "Forum Name", - }).then(function (forum_name) { + input: "Forum Name",init: function () { + var $group = this.$dialog.find("div.form-group"); + $group.removeClass("mb0"); + + var $add = $( + '<div class="form-group mb0">'+ + '<label class="col-sm-offset-3 col-sm-9 text-left">'+ + ' <input type="checkbox" required="required"/> '+ + '</label>'+ + '</div>'); + $add.find('label').append(_t("Add page in menu")); + $group.after($add); + } + }).then(function (forum_name, field, $dialog) { + var add_menu = ($dialog.find('input[type="checkbox"]').is(':checked')); website.form('/forum/new', 'POST', { - forum_name: forum_name + forum_name: forum_name, + add_menu: add_menu || "" }); }); }, diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js index 3d7ec8c8559..6abe4b97ffc 100644 --- a/addons/website_forum/static/src/js/website_forum.js +++ b/addons/website_forum/static/src/js/website_forum.js @@ -1,4 +1,6 @@ + openerp.website.if_dom_contains('.website_forum', function () { + var _t = openerp._t; $("[data-toggle='popover']").popover(); $('.karma_required').on('click', function (ev) { var karma = $(ev.currentTarget).data('karma'); @@ -6,8 +8,8 @@ ev.preventDefault(); var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="karma_alert">'+ '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+ - karma + ' karma is required to perform this action. You can earn karma by having '+ - 'your answers upvoted by the community.</div>'); + karma + _t(' karma is required to perform this action. You can earn karma by having your answers upvoted by the community.')+ + '</div>'); var vote_alert = $(ev.currentTarget).parent().find("#vote_alert"); if (vote_alert.length == 0) { $(ev.currentTarget).parent().append($warning); @@ -24,12 +26,12 @@ if (data['error'] == 'own_post'){ var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+ '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+ - 'Sorry, you cannot vote for your own posts'+ + _t('Sorry, you cannot vote for your own posts')+ '</div>'); } else if (data['error'] == 'anonymous_user'){ var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+ '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+ - 'Sorry you must be logged to vote'+ + _t('Sorry you must be logged to vote')+ '</div>'); } vote_alert = $link.parent().find("#vote_alert"); @@ -37,7 +39,7 @@ $link.parent().append($warning); } } else { - $link.parent().find("#vote_count").html(data['vote_count']); + $link.parent().find(".vote_count").html(data['vote_count']); if (data['user_vote'] == 0) { $link.parent().find(".text-success").removeClass("text-success"); $link.parent().find(".text-warning").removeClass("text-warning"); @@ -60,7 +62,7 @@ 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">×</button>'+ - 'Sorry, anonymous users cannot choose correct answer.'+ + _t('Sorry, anonymous users cannot choose correct answer.')+ '</div>'); } correct_answer_alert = $link.parent().find("#correct_answer_alert"); @@ -69,6 +71,7 @@ } } else { if (data) { + $(".oe_answer_true").addClass('oe_answer_false').removeClass("oe_answer_true"); $link.addClass("oe_answer_true").removeClass('oe_answer_false'); } else { $link.removeClass("oe_answer_true").addClass('oe_answer_false'); @@ -120,15 +123,22 @@ openerp.jsonRpc("/forum/validate_email/close", 'call', {}); }); + // welcome message action button + var forum_login = _.string.sprintf('%s/web?redirect=%s', + window.location.origin, escape(window.location.href)); + $('.forum_register_url').attr('href',forum_login); $('.js_close_intro').on('click', function (ev) { ev.preventDefault(); - document.cookie = "no_introduction_message = false"; + document.cookie = "forum_welcome_message = false"; + $('.forum_intro').slideUp(); return true; }); + $('.link_url').on('change', function (ev) { ev.preventDefault(); + var $link = $(ev.currentTarget); var display_error = function(){ var $warning = $('<div class="alert alert-danger alert-dismissable" style="position:absolute; margin-top: -180px; margin-left: 90px;">'+ '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+ @@ -137,11 +147,13 @@ $link.parent().append($warning); $("button#btn_post_your_article")[0].disabled = true; }; - var $link = $(ev.currentTarget); - if ($link.val().search("^http(s?)://.*")) { - display_error(); - } else { - openerp.jsonRpc("/forum/get_url_title", 'call', {'url': $link.val()}).then(function (data) { + var url = $link.val(); + if (url.search("^http(s?)://.*")) { + url = 'http://'+url; + } + var regex = new RegExp("(http(s)?://.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)"); + if(regex.test(url)){ + openerp.jsonRpc("/forum/get_url_title", 'call', {'url': url}).then(function (data) { if(data){ $("input[name='post_name']")[0].value = data; $('button#btn_post_your_article').prop('disabled', false); @@ -149,6 +161,8 @@ display_error(); } }); + }else{ + display_error(); } }); |
