Some more WIP of attachment mime handling

This commit is contained in:
Hadi Nategh 2015-03-24 11:40:06 +00:00
parent 14cd9dfb34
commit 89a9ea4bb1
5 changed files with 63 additions and 18 deletions

View File

@ -15,6 +15,7 @@
/*egw:uses /*egw:uses
jquery.jquery; jquery.jquery;
et2_core_baseWidget; et2_core_baseWidget;
/etemplate/js/expose.js;
*/ */
/** /**
@ -22,7 +23,7 @@
* *
* @augments et2_baseWidget * @augments et2_baseWidget
*/ */
var et2_description = et2_baseWidget.extend([et2_IDetachedDOM], var et2_description = expose(et2_baseWidget.extend([et2_IDetachedDOM],
{ {
attributes: { attributes: {
"label": { "label": {
@ -82,6 +83,18 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM],
"type": "string", "type": "string",
"description": "Link title which is displayed on mouse over.", "description": "Link title which is displayed on mouse over.",
"translate": true "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"
} }
}, },
@ -182,7 +195,26 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM],
// Copy the given value // Copy the given value
this.label = _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) { set_value: function(_value) {
if (!_value) _value = ""; if (!_value) _value = "";
if (!this.options.no_lang) _value = this.egw().lang(_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.span[0],
this.options.href ? this.options.extra_link_target : '_blank' 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 self= this;
var title = this.options.extra_link_title;
var popup = this.options.extra_link_popup;
jQuery('a',this.span) jQuery('a',this.span)
.click(function(e) { .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(); e.preventDefault();
return false; return false;
}); });
@ -280,6 +317,6 @@ var et2_description = et2_baseWidget.extend([et2_IDetachedDOM],
_nodes[0].setAttribute("class", _values["class"]); _nodes[0].setAttribute("class", _values["class"]);
} }
} }
}); }));
et2_register_widget(et2_description, ["description", "label"]); et2_register_widget(et2_description, ["description", "label"]);

View File

@ -373,6 +373,9 @@ function expose (widget)
set_value:function (_value) 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 // Do not run set value of expose if expose_view is not set
// it causes a wired error on nested image widgets which // it causes a wired error on nested image widgets which
// seems the expose is not its child widget // seems the expose is not its child widget
@ -380,7 +383,7 @@ function expose (widget)
{ {
return; return;
} }
this._super.apply(this,arguments);
var self=this; var self=this;
// If the media type is not supported do not bind the click handler // If the media type is not supported do not bind the click handler
@ -488,6 +491,7 @@ function expose (widget)
* @param {DOMNode} slide * @param {DOMNode} slide
*/ */
expose_onslide: function (gallery, index, slide){ expose_onslide: function (gallery, index, slide){
if (typeof this._super == 'undefined') return;
// First let parent try // First let parent try
this._super.apply(this, arguments); this._super.apply(this, arguments);
var nm = find_nextmatch(this); var nm = find_nextmatch(this);

View File

@ -2189,6 +2189,7 @@ class mail_ui
$attachmentHTML[$key]['size']=egw_vfs::hsize($value['size']); $attachmentHTML[$key]['size']=egw_vfs::hsize($value['size']);
$attachmentHTML[$key]['attachment_number']=$key; $attachmentHTML[$key]['attachment_number']=$key;
$attachmentHTML[$key]['partID']=$value['partID']; $attachmentHTML[$key]['partID']=$value['partID'];
$attachmentHTML[$key]['mail_id'] = $rowID;
$attachmentHTML[$key]['winmailFlag']=$value['is_winmail']; $attachmentHTML[$key]['winmailFlag']=$value['is_winmail'];
$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone"; $attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone";
@ -2198,7 +2199,7 @@ class mail_ui
$linkData = array $linkData = array
( (
'menuaction' => 'mail.mail_ui.displayMessage', '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, 'id' => $rowID,
'part' => $value['partID'], 'part' => $value['partID'],
'is_winmail' => $value['is_winmail'] 'is_winmail' => $value['is_winmail']
@ -2265,6 +2266,9 @@ class mail_ui
$linkView = "window.location.href = '".egw::link('/index.php',$linkData)."';"; $linkView = "window.location.href = '".egw::link('/index.php',$linkData)."';";
break; break;
} }
$attachmentHTML[$key]['href_link'] = egw::link('/index.php',$linkData);
$attachmentHTML[$key]['windowName'] = $windowName;
//error_log(__METHOD__.__LINE__.$linkView); //error_log(__METHOD__.__LINE__.$linkView);
$attachmentHTML[$key]['link_view'] = '<a href="#" ." title="'.$attachmentHTML[$key]['filename'].'" onclick="'.$linkView.' return false;"><b>'. $attachmentHTML[$key]['link_view'] = '<a href="#" ." title="'.$attachmentHTML[$key]['filename'].'" onclick="'.$linkView.' return false;"><b>'.
($value['name'] ? ( $filename ? $filename : $value['name'] ) : lang('(no subject)')). ($value['name'] ? ( $filename ? $filename : $value['name'] ) : lang('(no subject)')).

View File

@ -72,7 +72,7 @@
<description id="${row}[partID]" /> <description id="${row}[partID]" />
<description id="${row}[type]" /> <description id="${row}[type]" />
<description id="${row}[winmailFlag]" /> <description id="${row}[winmailFlag]" />
<description class="useEllipsis et2_link" id="${row}[filename]" no_lang="1" onclick="app.mail.displayAttachment"/> <description class="useEllipsis et2_link" id="${row}[filename]" expose_view="true" mime="$row_cont[type]" no_lang="1" href="$row_cont[href_link]" extra_link_title="$row_cont[windowName]" />
<description align="right" id="${row}[size]" /> <description align="right" id="${row}[size]" />
<buttononly id="${row}[save]" value="save" image="fileexport" onclick="app.mail.saveAttachment"/> <buttononly id="${row}[save]" value="save" image="fileexport" onclick="app.mail.saveAttachment"/>
<buttononly id="${row}[saveAsVFS]" value="save" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/> <buttononly id="${row}[saveAsVFS]" value="save" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/>

View File

@ -98,7 +98,7 @@
<description id="${row}[partID]" /> <description id="${row}[partID]" />
<description id="${row}[type]" /> <description id="${row}[type]" />
<description id="${row}[winmailFlag]" /> <description id="${row}[winmailFlag]" />
<description class="et2_link useEllipsis" id="${row}[filename]" no_lang="1" onclick="app.mail.displayAttachment"/> <description class="et2_link useEllipsis" id="${row}[filename]" no_lang="1" expose_view="true" mime="$row_cont[type]" href="$row_cont[href_link]" extra_link_title="$row_cont[windowName]"/>
<description align="right" id="${row}[size]"/> <description align="right" id="${row}[size]"/>
<buttononly id="${row}[save]" image="fileexport" onclick="app.mail.saveAttachment"/> <buttononly id="${row}[save]" image="fileexport" onclick="app.mail.saveAttachment"/>
<buttononly id="${row}[saveAsVFS]" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/> <buttononly id="${row}[saveAsVFS]" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/>