summaryrefslogtreecommitdiff
path: root/addons/website_twitter/static/src/js/website.twitter.editor.js
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2014-04-11 15:38:13 +0200
committerThibault Delavallée <tde@openerp.com>2014-04-11 15:38:13 +0200
commitd04ee666ccb0c35bd1c13d9814fdb52f1159e7e9 (patch)
treefbb09260a719fc158b6f4087ac16fed36e332ae4 /addons/website_twitter/static/src/js/website.twitter.editor.js
parente53f66dcea9ff012682dcece8e29d179ebe7d339 (diff)
parent6b84615627dca50a3c07cf80d8da0ea9b2d28934 (diff)
[MERGE] Sync with trunk
bzr revid: tde@openerp.com-20140411133813-4rj4de6dlzna5g5s
Diffstat (limited to 'addons/website_twitter/static/src/js/website.twitter.editor.js')
-rw-r--r--addons/website_twitter/static/src/js/website.twitter.editor.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/addons/website_twitter/static/src/js/website.twitter.editor.js b/addons/website_twitter/static/src/js/website.twitter.editor.js
new file mode 100644
index 00000000000..69a1896695a
--- /dev/null
+++ b/addons/website_twitter/static/src/js/website.twitter.editor.js
@@ -0,0 +1,51 @@
+(function () {
+ 'use strict';
+ var website = openerp.website,
+ qweb = openerp.qweb;
+
+ website.snippet.options["twitter"] = website.snippet.options.marginAndResize.extend({
+ start: function(){
+ this._super();
+ this.make_hover_config();
+ this.$target.find('.lnk_configure').click(function(e){
+ window.location = e.target.href;
+ });
+ if (this.$target.data("snippet-view")) {
+ this.$target.data("snippet-view").stop();
+ }
+ },
+ twitter_reload: function(){
+ openerp.jsonRpc('/twitter_reload','call', {});
+ },
+ make_hover_config: function(){
+ var self = this;
+ var $configuration = $(qweb.render("website.Twitter.Reload")).hide().appendTo(document.body).click(function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ self.twitter_reload();
+ });
+ this.$target.on('mouseover', '', function () {
+ var $selected = $(this);
+ var position = $selected.offset();
+ $configuration.show().offset({
+ top: $selected.outerHeight() / 2
+ + position.top
+ - $configuration.outerHeight() / 2,
+ left: $selected.outerWidth() / 2
+ + position.left
+ - $configuration.outerWidth() / 2,
+ })
+ }).on('mouseleave', '', function (e) {
+ var current = document.elementFromPoint(e.clientX, e.clientY);
+ if (current === $configuration[0]) {
+ return;
+ }
+ $configuration.hide();
+ });
+ },
+ clean_for_save: function () {
+ this.$target.find(".twitter_timeline").empty();
+ },
+ });
+
+})();