basic support (still needs some js to expose it) for sharing an item on a remote site by sending it through oexchange on your home hub. Untested.
This commit is contained in:
parent
7b7ef56b54
commit
c88fd01205
@ -58,6 +58,25 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get offset adding all offsets, slow fall-back method
|
||||||
|
var getOffsetSlow = function(el){
|
||||||
|
var top = 0, left = 0;
|
||||||
|
do {
|
||||||
|
top += el.offsetTop || 0;
|
||||||
|
left += el.offsetLeft || 0;
|
||||||
|
el = el.offsetParent;
|
||||||
|
} while (el);
|
||||||
|
|
||||||
|
return {
|
||||||
|
left: left,
|
||||||
|
top: top
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Needs more testing, will be rewriten for next version
|
// Needs more testing, will be rewriten for next version
|
||||||
// getOffset function copied from jQuery lib (http://jquery.com/)
|
// getOffset function copied from jQuery lib (http://jquery.com/)
|
||||||
if (document.documentElement.getBoundingClientRect){
|
if (document.documentElement.getBoundingClientRect){
|
||||||
@ -78,7 +97,12 @@
|
|||||||
var bound = body.getBoundingClientRect();
|
var bound = body.getBoundingClientRect();
|
||||||
zoom = (bound.right - bound.left) / body.clientWidth;
|
zoom = (bound.right - bound.left) / body.clientWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// some CSS layouts gives 0 width and/or bounding boxes
|
||||||
|
// in this case we fall back to the slow method
|
||||||
|
if (zoom == 0 || body.clientWidth == 0)
|
||||||
|
return getOffsetSlow(el);
|
||||||
|
|
||||||
if (zoom > 1) {
|
if (zoom > 1) {
|
||||||
clientTop = 0;
|
clientTop = 0;
|
||||||
clientLeft = 0;
|
clientLeft = 0;
|
||||||
@ -92,20 +116,21 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Get offset adding all offsets
|
// // Get offset adding all offsets
|
||||||
var getOffset = function(el){
|
// var getOffset = function(el){
|
||||||
var top = 0, left = 0;
|
// var top = 0, left = 0;
|
||||||
do {
|
// do {
|
||||||
top += el.offsetTop || 0;
|
// top += el.offsetTop || 0;
|
||||||
left += el.offsetLeft || 0;
|
// left += el.offsetLeft || 0;
|
||||||
el = el.offsetParent;
|
// el = el.offsetParent;
|
||||||
} while (el);
|
// } while (el);
|
||||||
|
|
||||||
return {
|
// return {
|
||||||
left: left,
|
// left: left,
|
||||||
top: top
|
// top: top
|
||||||
};
|
// };
|
||||||
};
|
// };
|
||||||
|
var getOffset = getOffsetSlowl
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +15,21 @@ function oexchange_init(&$a) {
|
|||||||
function oexchange_content(&$a) {
|
function oexchange_content(&$a) {
|
||||||
|
|
||||||
if(! local_user()) {
|
if(! local_user()) {
|
||||||
|
if(remote_user()) {
|
||||||
|
$observer = $a->get_observer();
|
||||||
|
if($observer && $observer['xchan_url']) {
|
||||||
|
$parsed = @parse_url($observer['xchan_url']);
|
||||||
|
if(! $parsed) {
|
||||||
|
notice( t('Unable to find your hub.') . EOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$url = $parsed['scheme'] . '://' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '');
|
||||||
|
$url .= '/oexchange';
|
||||||
|
$result = z_post_url($url,$_REQUEST);
|
||||||
|
json_return_and_die($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return login(false);
|
return login(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user