more fixes for vfs widget, click on "links" works again under jdots, still needs work for displaying multiple path-elements

This commit is contained in:
Ralf Becker 2012-03-29 11:52:56 +00:00
parent 4d95a9b495
commit 5ca6860618
2 changed files with 12 additions and 41 deletions

View File

@ -257,21 +257,5 @@ function nm_hide_popup(element, div_id)
*/
function nm_activate_link(_action, _senders)
{
// $j(_senders[0].iface.getDOMNode()).find('a:first').trigger('click'); not sure why this is NOT working
var a_href = $j(_senders[0].iface.getDOMNode()).find('a:first');
if (typeof a_href != undefined)
{
var target = a_href.attr('target');
var href = a_href.attr('href');
if (a_href.attr('onclick'))
a_href.click();
else if (target)
window.open(href,target);
else
window.location = href;
}
$j(_senders[0].iface.getDOMNode()).find('.et2_clickable:first').trigger('click');
}

View File

@ -46,39 +46,21 @@ var et2_vfs = et2_valueWidget.extend([et2_IDetachedDOM], {
},
set_value: function(_value) {
var path = '';
if(_value.path)
{
path = _value.path
}
else if (typeof _value !== 'object')
if (typeof _value !== 'object')
{
this.egw().debug("warn", "%s only has path, needs full array", this.id, _value);
this.span.empty().text(_value);
return;
}
var path_parts = path ? path.split('/') : [];
var path_parts = _value.path ? _value.path.split('/') : [];
this._make_path(path_parts);
// Make it clickable
var type = this.egw().get_mime_info(_value.mime) ? _value.mime : this.DIR_MIME_TYPE;
jQuery("li",this.span).addClass("et2_clickable et2_link")
.wrapInner('<a onclick="egw.open({path:\''+
egw.encodePath(path.replace('"','&quot;').replace("'", "\\\'"))+
'\',type:\''+type+'\'},\'file\');">'
);
},
/**
* Create a list of clickable path components
*/
_make_path: function(path_parts) {
// TODO: This is apparently not used in old etemplate
var text;
var path = '/';
var mime = this.DIR_MIME_TYPE;
for(var i = 0; i < path_parts.length; i++)
{
text = decodeURIComponent(path_parts[i]);
path += (path=='/'?'':'/')+path_parts[i];
text = egw.decodePath(path_parts[i]);
// Nice human-readable stuff for apps
if(path_parts[1] == 'apps')
@ -115,9 +97,14 @@ var et2_vfs = et2_valueWidget.extend([et2_IDetachedDOM], {
.appendTo(this.span);
*/
}
var data = {path: path, type: i==path_parts.length-1 ? _value.mime : this.DIR_MIME_TYPE };
var part = $j(document.createElement("li"))
.addClass("vfsFilename")
.text(text)
.addClass("et2_clickable et2_link")
.click({data:data, egw: this.egw()}, function(e) {
e.data.egw.open(e.data.data, "file");
})
.appendTo(this.span);
},