[FIX] website_slides : Fixing typos and cleaning methods for fullscreen footer and social sharing; code simplification

This commit is contained in:
odoo-tac
2015-09-07 13:37:50 +02:00
parent 36815037b8
commit 6a4b8881b0
9 changed files with 59 additions and 79 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ Share and Publish Videos, Presentations and Documents'
* Filters and Tagging
* Statistics of Presentation
* Channel Subscription
* Supported document types supported: PDF, images, YouTube videos and Google Drive documents)
* Supported document types : PDF, images, YouTube videos and Google Drive documents)
""",
'depends': ['website', 'website_mail','marketing'],
'data': [
+3 -3
View File
@@ -213,7 +213,7 @@ class Slide(models.Model):
_description = 'Slides'
_PROMOTIONAL_FIELDS = [
'__last_update', 'name', 'image_thumb', 'slide_type', 'total_views', 'category_id',
'__last_update', 'name', 'image_thumb', 'image_medium', 'slide_type', 'total_views', 'category_id',
'channel_id', 'description', 'tag_ids', 'write_date', 'create_date',
'website_published', 'website_url', 'website_meta_title', 'website_meta_description', 'website_meta_keywords']
@@ -359,13 +359,13 @@ class Slide(models.Model):
def check_field_access_rights(self, operation, fields):
""" As per channel access configuration (visibility)
- public ==> no restriction on slides access
- private ==> restrict all slides of channel base on access group defined on channel group_ids field
- private ==> restrict all slides of channel based on access group defined on channel group_ids field
- partial ==> show channel, but presentations based on groups means any user can see channel but not slide's content.
For private: implement using record rule
For partial: user can see channel, but channel gridview have slide detail so we have to implement
partial field access mechanism for public user so he can have access of promotional field (name, view_count) of slides,
but not all fields like data (actual pdf content)
all fields should be accessible only for user group define on channel group_ids
all fields should be accessible only for user group defined on channel group_ids
"""
if self.env.uid == SUPERUSER_ID:
return fields or list(self._fields)
@@ -13,7 +13,7 @@
<div class="oe_span6">
<p class="oe_mt32">
Odoo presentations lets you upload files privately or publicly in the following file formats: PowerPoint, PDF, Keynote, Video or OpenDocument presentations.</p>
<p>This module originally meant to be used for businesses to share slides among employees more easily. It also provides users the ability to rate, comment, share the uploaded content and see detailed statistics like total views, web-views, embedded-views, likes and dislikes, total comments, total social-shares and shares on individual social site.
<p>This module is originally meant to be used by businesses to share slides among employees more easily. It also provides the users with the ability to rate, comment, share the uploaded content and see detailed statistics like total views, web-views, embedded-views, likes and dislikes, total comments, total social-shares and shares on individual social site.
</p>
<div class="oe_centeralign oe_websiteonly">
<a class="oe_button oe_big oe_tacky" href="mailto:sales@openerp.com">Contact Us</a>
@@ -145,26 +145,15 @@ var PDFSlidesViewer = (function(){
return this.queueRenderPage(this.pdf_page_total);
}
PDFSlidesViewer.prototype.toggleFullScreenFooter = function(){
if(document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement) {
$('div#PDFViewer > div.navbar-fixed-bottom').toggleClass('oe_show_footer');
}
}
PDFSlidesViewer.prototype.toggleFullScreen = function(){
var el = this.canvas;
var $PDFViewer = $("div#PDFSlideViewer");
var $navigation_footer = $('div#PDFViewer > div.navbar-fixed-bottom');
$(document).unbind('webkitfullscreenchange mozfullscreenchange fullscreenchange')
.bind('webkitfullscreenchange mozfullscreenchange fullscreenchange', function() {
var state = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullScreen;
if (!state) {
$navigation_footer.removeAttr('style');
$PDFViewer.unbind('click');
} else {
$navigation_footer.css('z-index', 2147483647);
$PDFViewer.on('click', function() {
$navigation_footer.fadeToggle();
});
}
});
var isFullscreenAvailable = document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled || document.msFullscreenEnabled || false;
if(isFullscreenAvailable){ // Full screen supported
// get the actual element in FullScreen mode (Null if no element)
+21 -41
View File
@@ -152,35 +152,11 @@ $(document).ready(function () {
var social_urls = {
'linkedin': 'https://www.linkedin.com/countserv/count/share?url=',
'twitter': 'https://cdn.api.twitter.com/1/urls/count.json?url=',
'fb': 'https://graph.facebook.com/?id=',
'facebook': 'https://graph.facebook.com/?id=',
'gplus': 'https://clients6.google.com/rpc'
}
var socialgatter = function (app_url, url, callback) {
$.ajax({
url: app_url + url,
dataType: 'jsonp',
success: callback
});
};
var update_statistics = function(social_site, slide_url) {
if (social_site == 'linkedin') {
socialgatter(social_urls['linkedin'], slide_url, function(data) {
$('#linkedin-badge').text(data.count || 0);
$('#total-share').text(parseInt($('#total-share').text()) + parseInt($('#linkedin-badge').text()));
});
}
if (social_site == 'twitter') {
socialgatter(social_urls['twitter'], slide_url, function(data) {
$('#twitter-badge').text(data.count || 0);
$('#total-share').text(parseInt($('#total-share').text()) + parseInt($('#twitter-badge').text()));
});
}
if (social_site == 'fb') {
socialgatter(social_urls['fb'], slide_url, function(data) {
$('#facebook-badge').text(data.shares || 0);
$('#total-share').text(parseInt($('#total-share').text()) + parseInt($('#facebook-badge').text()));
});
}
if (social_site == 'gplus') {
$.ajax({
url: social_urls['gplus'],
@@ -206,33 +182,37 @@ $(document).ready(function () {
$('#total-share').text(parseInt($('#total-share').text()) + parseInt($('#google-badge').text()));
},
});
} else {
$.ajax({
url: social_urls[social_site] + slide_url,
dataType: 'jsonp',
success: function(data) {
var shareCount = (social_site === 'facebook' ? data.shares : data.count) || 0;
$('#' + social_site + '-badge').text(shareCount);
$('#total-share').text(parseInt($('#total-share').text()) + parseInt($('#' + social_site+ '-badge').text()));
},
});
}
};
$.each(social_urls, function(key, value) {
update_statistics(key, slide_url)
update_statistics(key, slide_url);
});
$("a.o_slides_social_share").on('click', function(ev) {
ev.preventDefault();
var key = $(ev.currentTarget).attr('social-key');
var win_url = $(ev.currentTarget).attr('href');
var win = window.open(
win_url,
var popUpURL = $(ev.currentTarget).attr('href');
var popUp = window.open(
popUpURL,
'Share Dialog',
'width=626,height=436');
var interval = window.setInterval(function() {
try {
if (win.closed) {
window.clearInterval(interval);
setTimeout(function() {
update_statistics(key, slide_url);
}, 3000);
}
} catch (e) {
window.clearInterval(interval);
$(window).on('focus', function() {
if (popUp.closed) {
update_statistics(key, slide_url);
$(window).off('focus');
}
}, 1000);
});
});
}
});
@@ -73,7 +73,7 @@ $(document).ready(function () {
}
});
},
previous: function (ev) {
previous: function () {
var self = this;
this.pdf_viewer.previousPage().then(function(page_num){
if(page_num){
@@ -82,14 +82,14 @@ $(document).ready(function () {
self.$("#slide_suggest").hide();
});
},
first: function (ev) {
first: function () {
var self = this;
this.pdf_viewer.firstPage().then(function(page_num){
self.on_rendered_page(page_num);
self.$("#slide_suggest").hide();
});
},
last: function (ev) {
last: function () {
var self = this;
this.pdf_viewer.lastPage().then(function(page_num){
self.on_rendered_page(page_num);
@@ -97,9 +97,14 @@ $(document).ready(function () {
});
},
// full screen mode
fullscreen: function (ev) {
fullscreen: function () {
this.pdf_viewer.toggleFullScreen();
},
fullScreenFooter: function (ev) {
if (ev.target.id === "PDFViewerCanvas") {
this.pdf_viewer.toggleFullScreenFooter();
}
},
// display suggestion displayed after last slide
display_suggested_slides: function () {
this.$("#slide_suggest").show();
@@ -128,6 +133,9 @@ $(document).ready(function () {
$('#fullscreen').on('click',function(){
embedded_viewer.fullscreen();
});
$('#PDFViewer').on('click',function (ev){
embedded_viewer.fullScreenFooter(ev);
});
// switching slide with keyboard
$(document).keydown(function (ev) {
@@ -160,7 +168,7 @@ $(document).ready(function () {
);
// embed widget page selector
$('.oe_slide_js_embed_code_widget input').on('change', function (e) {
$('.oe_slide_js_embed_code_widget input').on('change', function () {
var page = parseInt($(this).val());
if (!(page > 0 && page <= embedded_viewer.pdf_viewer.pdf_page_total)) {
page = 1;
@@ -208,22 +208,19 @@ var SlideDialog = Widget.extend({
}
return data.text;
},
check_unique_tag: function(term, tags) {
return _.filter(tags, function(tag) {
return tag.text.toLowerCase() === term.toLowerCase()
}).length === 0;
},
createSearchChoice: function(term, data) {
var added_tags = $(this.opts.element).select2('data');
if (this.opts.check_unique_tag(term, _.union(added_tags, data))) {
if (_.filter(_.union(added_tags, data), function(tag) {
return tag.text.toLowerCase().localeCompare(term.toLowerCase()) === 0;
}).length === 0) {
return {
id: _.uniqueId('tag_'),
create: true,
tag: term,
text: _.str.sprintf(_t("Create New %s '%s'"), tag, term)
text: _.str.sprintf(_t("Create new tag '%s'"), term),
};
}
},
},
fill_data: function (query, data) {
var that = this,
tags = {results: []};
@@ -302,7 +299,8 @@ var SlideDialog = Widget.extend({
svg_to_png: function() {
var img = this.$el.find("img#slide-image")[0];
var canvas = document.createElement("canvas");
canvas.width = img.width, canvas.height = img.height;
canvas.width = img.width;
canvas.height = img.height;
canvas.getContext("2d").drawImage(img, 0, 0);
return canvas.toDataURL("image/png").split(',')[1];
},
@@ -9,6 +9,7 @@
@navbar-default-link-color: #777;
@navbar-default-link-hover-color: #333;
@navbar-default-bg: #f8f8f8;
@MAX-Z-INDEX : 2147483647;
} .define-color-if-not-defined();
.oe_slides_panel_footer {
@@ -167,6 +168,10 @@ textarea.o_slides_comment {
.oe_slides_panel_footer #page_number {
width: 45px;
}
.oe_show_footer {
z-index: @MAX-Z-INDEX; // Looks terrible but seems necessary due to fullscreen & canvas in PDFSlidesViewer
}
// Display Slide Navigation Footer bit clear on mobile preview
@media screen and (max-width: 300px) {
.o_slide_navigation_buttons {
@@ -24,7 +24,7 @@
<!-- Tools template: share on social networkds -->
<template id='slides_share' name="Slides Media Share">
<div class="form-group">
<a t-attf-href="https://www.facebook.com/sharer/sharer.php?u=#{slide.website_url}" class="o_slides_social_share" social-key="fb"><i class="fa fa-facebook-square fa-2x"/></a>
<a t-attf-href="https://www.facebook.com/sharer/sharer.php?u=#{slide.website_url}" class="o_slides_social_share" social-key="facebook"><i class="fa fa-facebook-square fa-2x"/></a>
<a t-attf-href="https://twitter.com/intent/tweet?text=#{slide.name}&amp;url=#{slide.website_url}" class="o_slides_social_share" social-key="twitter"><i class="fa fa-twitter fa-2x"/></a>
<a t-attf-href="http://www.linkedin.com/shareArticle?mini=true&amp;url=#{slide.website_url}&amp;title=#{slide.name}&amp;" social-key="linkedin" class="o_slides_social_share"><i class="fa fa-linkedin fa-2x"/></a>
<a t-attf-href="https://plus.google.com/share?url=#{slide.website_url}" class="o_slides_social_share" social-key="gplus"><i class="fa fa-google-plus-square fa-2x"/></a>
@@ -246,7 +246,7 @@
</section>
<section>
<div class="container mt16">
<div class="row o_promote_box">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding-left: 15px;padding-right: 15px;" t-if="channel.total == 0">
<div class="jumbotron">
<h1>No presentation published yet.</h1>