From 89a9ea4bb12ea6390402dc8e681ad4373d7d8b35 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 24 Mar 2015 11:40:06 +0000 Subject: [PATCH] Some more WIP of attachment mime handling --- etemplate/js/et2_widget_description.js | 57 +++++++++++++++++++++----- etemplate/js/expose.js | 6 ++- mail/inc/class.mail_ui.inc.php | 12 ++++-- mail/templates/default/display.xet | 2 +- mail/templates/default/index.xet | 4 +- 5 files changed, 63 insertions(+), 18 deletions(-) diff --git a/etemplate/js/et2_widget_description.js b/etemplate/js/et2_widget_description.js index 028e65b44a..0bf0be3942 100644 --- a/etemplate/js/et2_widget_description.js +++ b/etemplate/js/et2_widget_description.js @@ -15,6 +15,7 @@ /*egw:uses jquery.jquery; et2_core_baseWidget; + /etemplate/js/expose.js; */ /** @@ -22,7 +23,7 @@ * * @augments et2_baseWidget */ -var et2_description = et2_baseWidget.extend([et2_IDetachedDOM], +var et2_description = expose(et2_baseWidget.extend([et2_IDetachedDOM], { attributes: { "label": { @@ -82,6 +83,18 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM], "type": "string", "description": "Link title which is displayed on mouse over.", "translate": true + }, + "expose_view":{ + name: "Expose view", + type: "boolean", + default: false, + description: "Clicking on description with href value would popup an expose view, and will show content referenced by href." + }, + mime:{ + name: "Mime type", + type: "string", + default: '', + description: "Mime type of the registered link" } }, @@ -142,7 +155,7 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM], .addClass("et2_label"); this.getSurroundings().insertDOMNode(this._labelContainer[0]); } - + // Clear the label container. this._labelContainer.empty(); @@ -175,14 +188,33 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM], } this._labelContainer = null; } - + // Update the surroundings in order to reflect the change in the label this.getSurroundings().update(); // Copy the given value this.label = _value; }, - + /** + * Function to get media content to feed the expose + * @param {type} _value + * @returns {Array|Array.getMedia.mediaContent} + */ + getMedia: function (_value) + { + var base_url = egw.webserverUrl.match(/^\//,'ig')?egw(window).window.location.origin :egw.webserverUrl + '/'; + var mediaContent = []; + if (_value) + { + mediaContent = [{ + title: this.options.label, + href: base_url + _value, + type: this.options.type + "/*", + thumbnail: base_url + _value + }]; + } + return mediaContent; + }, set_value: function(_value) { if (!_value) _value = ""; if (!this.options.no_lang) _value = this.egw().lang(_value); @@ -194,14 +226,19 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM], this.span[0], this.options.href ? this.options.extra_link_target : '_blank' ); - if(this.options.extra_link_popup) + if(this.options.extra_link_popup || this.options.mime) { - var href = this.options.href; - var title = this.options.extra_link_title; - var popup = this.options.extra_link_popup; + var self= this; jQuery('a',this.span) .click(function(e) { - egw.open_link(href, title,popup); + if (self.options.expose_view && typeof self.options.mime !='undefined' && self.options.mime.match(/video\/|image\/|audio\//,'ig')) + { + self._init_blueimp_gallery(e,self.options.href); + } + else + { + egw(window).open_link(self.options.href, self.options.extra_link_title,self.options.extra_link_popup,null,null,self.options.mime); + } e.preventDefault(); return false; }); @@ -280,6 +317,6 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM], _nodes[0].setAttribute("class", _values["class"]); } } -}); +})); et2_register_widget(et2_description, ["description", "label"]); diff --git a/etemplate/js/expose.js b/etemplate/js/expose.js index f5823b345d..9585ab995c 100644 --- a/etemplate/js/expose.js +++ b/etemplate/js/expose.js @@ -373,6 +373,9 @@ function expose (widget) set_value:function (_value) { + if (typeof this._super == 'undefined') return; + + this._super.apply(this,arguments); // Do not run set value of expose if expose_view is not set // it causes a wired error on nested image widgets which // seems the expose is not its child widget @@ -380,7 +383,7 @@ function expose (widget) { return; } - this._super.apply(this,arguments); + var self=this; // If the media type is not supported do not bind the click handler @@ -488,6 +491,7 @@ function expose (widget) * @param {DOMNode} slide */ expose_onslide: function (gallery, index, slide){ + if (typeof this._super == 'undefined') return; // First let parent try this._super.apply(this, arguments); var nm = find_nextmatch(this); diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index aad741e057..3ced0369c5 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -2181,24 +2181,25 @@ class mail_ui $attachmentHTML[$key]['filename'] = $x; } } -//error_log(array2string($value)); -//error_log(strtoupper($value['mimeType']) .'<->'. mime_magic::filename2mime($attachmentHTML[$key]['filename'])); + //error_log(array2string($value)); + //error_log(strtoupper($value['mimeType']) .'<->'. mime_magic::filename2mime($attachmentHTML[$key]['filename'])); if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']); $attachmentHTML[$key]['type']=$value['mimeType']; $attachmentHTML[$key]['mimetype']=mime_magic::mime2label($value['mimeType']); $attachmentHTML[$key]['size']=egw_vfs::hsize($value['size']); $attachmentHTML[$key]['attachment_number']=$key; $attachmentHTML[$key]['partID']=$value['partID']; + $attachmentHTML[$key]['mail_id'] = $rowID; $attachmentHTML[$key]['winmailFlag']=$value['is_winmail']; $attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone"; - + switch(strtoupper($value['mimeType'])) { case 'MESSAGE/RFC822': $linkData = array ( 'menuaction' => 'mail.mail_ui.displayMessage', - //'mode' => 'display', //message/rfc822 attachments should be opened in display mode + 'mode' => 'display', //message/rfc822 attachments should be opened in display mode 'id' => $rowID, 'part' => $value['partID'], 'is_winmail' => $value['is_winmail'] @@ -2265,6 +2266,9 @@ class mail_ui $linkView = "window.location.href = '".egw::link('/index.php',$linkData)."';"; break; } + $attachmentHTML[$key]['href_link'] = egw::link('/index.php',$linkData); + $attachmentHTML[$key]['windowName'] = $windowName; + //error_log(__METHOD__.__LINE__.$linkView); $attachmentHTML[$key]['link_view'] = ''. ($value['name'] ? ( $filename ? $filename : $value['name'] ) : lang('(no subject)')). diff --git a/mail/templates/default/display.xet b/mail/templates/default/display.xet index 62608b421a..4c73b01e89 100644 --- a/mail/templates/default/display.xet +++ b/mail/templates/default/display.xet @@ -72,7 +72,7 @@ - + diff --git a/mail/templates/default/index.xet b/mail/templates/default/index.xet index c0281806d8..cbae82d687 100644 --- a/mail/templates/default/index.xet +++ b/mail/templates/default/index.xet @@ -98,8 +98,8 @@ - - + +