summaryrefslogtreecommitdiff
path: root/addons/pad/static/src/js
diff options
context:
space:
mode:
authorFabien Pinckaers <fp@openerp.com>2012-07-18 00:14:08 +0200
committerFabien Pinckaers <fp@openerp.com>2012-07-18 00:14:08 +0200
commit36cde3d9fca0f786a8fa8dabf94bac71e1ae637a (patch)
treee05d1c8ede03d63cafacaf7150456570c0961a0f /addons/pad/static/src/js
parent2a89c6079c9f7f5d9135bcda777fda3f3ed8d859 (diff)
parent45c50d3a31cc9627e61384bd0c1c80f22c5e740e (diff)
[IMP] some cleaning in etherpad
bzr revid: fp@openerp.com-20120717221408-zk30i103f0erk4a3
Diffstat (limited to 'addons/pad/static/src/js')
-rw-r--r--addons/pad/static/src/js/pad.js55
1 files changed, 39 insertions, 16 deletions
diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js
index 2e5f8820ac4..3f13df45d48 100644
--- a/addons/pad/static/src/js/pad.js
+++ b/addons/pad/static/src/js/pad.js
@@ -1,18 +1,41 @@
openerp.pad = function(instance) {
-instance.web.Sidebar = instance.web.Sidebar.extend({
- init: function(parent) {
- this._super(parent);
- this.add_items('other',[{ label: "Pad", callback: this.on_add_pad }]);
- },
- on_add_pad: function() {
- var self = this;
- var view = this.getParent();
- var model = new instance.web.Model('ir.attachment');
- model.call('pad_get', [view.model ,view.datarecord.id],{}).then(function(r) {
- self.do_action({ type: "ir.actions.act_url", url: r });
- });
- }
-});
-
-};
+instance.web.form.FieldEtherpad = instance.web.form.AbstractField.extend(_.extend({}, instance.web.form.ReinitializeFieldMixin, {
+ template: 'FieldEtherpad',
+ initialize_content: function() {
+ this.$textarea = undefined;
+ this.$element.find('span').text(this.field.string);
+ this.$element.find('span').click(_.bind(function(ev){
+ this.$element.find('span').toggleClass('etherpad_zoom_head');
+ var iszoom = this.$element.find('span').hasClass('etherpad_zoom_head');
+ this.$element.find('span').text((iszoom?'Back to Task':this.field.string));
+ this.$element.find('div').toggleClass('etherpad_zoom');
+ $("body").toggleClass('etherpad_body');
+ },this));
+ },
+ set_value: function(value_) {
+ this._super(value_);
+ this.render_value();
+ },
+ render_value: function() {
+ var show_value = instance.web.format_value(this.get('value'), this, '');
+ if (!this.get("effective_readonly")) {
+ var pad_username = this.session.username;
+ this.$element.find('div').html('<iframe width="100%" height="100%" frameborder="0" src="'+show_value.split('\n')[0]+'?showChat=false&showLineNumbers=false&userName='+pad_username+'"></iframe>');
+ } else {
+ if(this.get('value') != false)
+ {
+ var self = this;
+ if(show_value.split('\n')[0] != '')
+ $.get(show_value.split('\n')[0]+'/export/html')
+ .success(function(data) { self.$element.html('<div class="etherpad_readonly">'+data+'</div>'); })
+ .error(function() { self.$element.text('Unable to load pad'); });
+ }
+ }
+ },
+ }));
+
+ instance.web.form.widgets = instance.web.form.widgets.extend({
+ 'etherpad': 'instance.web.form.FieldEtherpad',
+ });
+};