[IMP] website: create share snippet. TODO: controller to send mail or mailto href
bzr revid: chm@openerp.com-20140310135434-7xt2sy89if9116l3
This commit is contained in:
parent
74bb1d6e95
commit
7e8b25dbee
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue