diff options
| author | chm@openerp.com <> | 2014-03-10 14:54:34 +0100 |
|---|---|---|
| committer | chm@openerp.com <> | 2014-03-10 14:54:34 +0100 |
| commit | 7e8b25dbeeec3a8bef5f092fd74cc71da75943ad (patch) | |
| tree | 7eb7d62affc51ac46f3fa1e22adecb5e4f1679e5 /addons | |
| parent | 74bb1d6e9554afd2bd49db3ce4d9a98526c4f0a7 (diff) | |
[IMP] website: create share snippet. TODO: controller to send mail or mailto href
bzr revid: chm@openerp.com-20140310135434-7xt2sy89if9116l3
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/website/controllers/main.py | 8 | ||||
| -rw-r--r-- | addons/website/static/src/js/website.snippets.animation.js | 37 | ||||
| -rw-r--r-- | addons/website/views/snippets.xml | 73 |
3 files changed, 115 insertions, 3 deletions
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 95c7ad82e2b..b155317d826 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -378,6 +378,14 @@ class Website(openerp.addons.web.controllers.main.Home): del response.headers['Content-Length'] return response + + @http.route(['/website/current_user/'], type='json', auth="public", website=True) + def get_current_user(self, fields): + cr, uid, context = request.cr, request.uid, request.context + if request.registry["website"].get_public_user(cr, uid, context=context) != uid: + return request.registry["res.users"].read(cr, openerp.SUPERUSER_ID, [uid], fields, context=context)[0] + else: + return None #------------------------------------------------------ # Server actions diff --git a/addons/website/static/src/js/website.snippets.animation.js b/addons/website/static/src/js/website.snippets.animation.js index 933f4b8e6ed..173cdf39a58 100644 --- a/addons/website/static/src/js/website.snippets.animation.js +++ b/addons/website/static/src/js/website.snippets.animation.js @@ -127,4 +127,41 @@ } }); + website.snippet.animationRegistry.share = website.snippet.Animation.extend({ + selector: ".oe_share", + start: function () { + var self = this; + var url = encodeURIComponent(window.location.href); + var title = encodeURIComponent($("title").text()); + this.$target.find(".oe_share_facebook").attr("href", + "https://www.facebook.com/sharer/sharer.php?u="+url); + this.$target.find(".oe_share_twitter").attr("href", + "https://twitter.com/intent/tweet?text="+title+"&related=&url="+url); + this.$target.find(".oe_share_linkedin").attr("href", + "http://www.linkedin.com/shareArticle?mini=true&url="+url+"&title="+title+"&summary=&source="); + this.$target.find(".oe_share_google").attr("href", + "https://plus.google.com/share?url="+url); + this.$target.find("a").click(function () { + window.open(this.href,'','menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=550,width=600'); + }); + + var $modal = this.$target.find(".oe_share_mail_modal"); + var $from = $modal.find("input[name='from']").parent().parent(); + this.$target.find(".oe_share_mail").off("click").click(function () { + // open popover + $modal.modal("show"); + }); + $modal.find("input[name='url']").attr("value", window.location.href); + openerp.jsonRpc('/website/current_user/', 'call', { + fields: ["email"] + }).then(function (result) { + if (result) $from.addClass("hidden"); + else $from.removeClass("hidden"); + }); + $modal.find(".btn-primary").click(function () { + $modal.modal("hide"); + console.log("valid"); + }); + }, + }); })(); diff --git a/addons/website/views/snippets.xml b/addons/website/views/snippets.xml index 53e2d87186d..f592286c8f7 100644 --- a/addons/website/views/snippets.xml +++ b/addons/website/views/snippets.xml @@ -336,6 +336,73 @@ <hr class="oe_snippet_body"/> </div> + + <div> + <div class="oe_snippet_thumbnail"> + <img class="oe_snippet_thumbnail_img" src="/website/static/src/img/blocks/block_button.png"/> + <span class="oe_snippet_thumbnail_title">Share</span> + </div> + <div class="oe_snippet_body oe_share"> + <h3> + Share + <a target="_Blank" class="oe_share_facebook" href="https://www.facebook.com/OpenERP"><i class="fa fa-facebook-square"></i></a> + <a target="_Blank" class="oe_share_twitter" href="https://twitter.com/openerp"><i class="fa fa-twitter"></i></a> + <a target="_Blank" class="oe_share_linkedin" href="http://www.linkedin.com/company/openerp"><i class="fa fa-linkedin"></i></a> + <a target="_Blank" class="oe_share_google" href="https://plus.google.com/+openerp"><i class="fa fa-google-plus-square"></i></a> + <a class="oe_share_mail" href="#"><i class="fa fa-envelope-o"></i></a> + </h3> + + <!-- Modal for Mail --> + <div class="oe_share_mail_modal modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> + <div class="modal-dialog"> + <div class="modal-content"> + <form class="form-horizontal" role="form"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> + <h4 class="modal-title" id="myModalLabel">Share by Email</h4> + </div> + <div class="modal-body"> + <div class="form-group"> + <label class="col-sm-2 control-label">To</label> + <div class="col-sm-10"> + <input type="email" class="form-control" name="to"/> + </div> + </div> + <div class="form-group"> + <label class="col-sm-2 control-label">From</label> + <div class="col-sm-10"> + <input type="email" class="form-control" name="from"/> + </div> + </div> + <div class="form-group"> + <label class="col-sm-2 control-label">Subject</label> + <div class="col-sm-10"> + <input type="text" class="form-control" name="subject"/> + </div> + </div> + <div class="form-group"> + <label class="col-sm-2 control-label">Summary</label> + <div class="col-sm-10"> + <textarea class="form-control" rows="4" name="Summary"></textarea> + </div> + </div> + <div class="form-group"> + <label class="col-sm-2 control-label">URL</label> + <div class="col-sm-10"> + <input readonly="readonly" value="" class="form-control" name="url"/> + </div> + </div> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary pull-right">Send Email</button> + </div> + </form> + </div> + </div> + </div> + </div> + </div> + </div> <div id="snippet_feature" class="tab-pane fade"> @@ -947,8 +1014,8 @@ </div> <div data-snippet-option-id='content' - data-selector="blockquote, .well, .panel" - data-selector-siblings="blockquote, .well, .panel" + data-selector="blockquote, .well, .panel, .oe_share" + data-selector-siblings="p, h1, h2, h3, blockquote, .well, .panel, .oe_share" data-selector-children=".content"> </div> @@ -971,4 +1038,4 @@ </data> -</openerp> +</openerp>
\ No newline at end of file |
