diff options
| author | Barad Mahendra <mba@tinyerp.com> | 2014-04-10 19:46:22 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2014-04-10 19:46:22 +0200 |
| commit | 0152bea512d868cbb0d9adf33cdbf98bc2030a0f (patch) | |
| tree | 6553ccef3cc7a9a0814ad8441c24e4f98df6a7f4 /addons/website_twitter/static/src/js/website.twitter.editor.js | |
| parent | 7c75b5e004ef2e1c836ad2cc788a701a687a6440 (diff) | |
[MERGE] [ADD] website_twitter: add twitter scroller snippet
bzr revid: odo@openerp.com-20140410174622-j2waid38nk3fqitt
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.js | 51 |
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(); + }, + }); + +})(); |
