|
<?php |
|
|
|
class Lazyload_LogicHooks_LazyloadLauncher |
|
{ |
|
|
|
/** |
|
* Add JS to launch Subpanel with lazyload |
|
* |
|
* @param string $event -- What kind of logic_hook is it (after_ui_frame, after_ui_footer...) |
|
* @param string $arguments -- unused |
|
* @return unknown -- No return |
|
*/ |
|
public function run($event, $arguments) |
|
{ |
|
if ($GLOBALS['app']->controller->action == 'DetailView') { |
|
echo '<script type="text/javascript""> |
|
if ( typeof(Lazyload) == \'undefined\' ) Lazyload = {}; |
|
if ( typeof(Lazyload.util) == \'undefined\' ) Lazyload.util = {}; |
|
Lazyload.util.loadVisibleSubpanel = function () { |
|
var subPanelLayouts = SUGAR.subpanelUtils.getLayout(); |
|
for( i=0; i < subPanelLayouts.length; i++) { |
|
var subPanelName = subPanelLayouts[i]; |
|
var position = $("#subpanel_title_"+subPanelName).offset().top; |
|
var scllwidth = $(window).scrollTop() + $(window).height(); |
|
if ( scllwidth > position && $.inArray(subPanelName, subPanelDisplayed) == -1) { |
|
subPanelDisplayed.push(subPanelName); |
|
current_child_field = subPanelName; |
|
showSubPanel(subPanelName,null,null, \'' .$GLOBALS['app']->controller->module . '\'); |
|
$(\'#show_link_\'+subPanelName).css(\'display\', \'none\'); |
|
$(\'#hide_link_\'+subPanelName).css(\'display\', \'\'); |
|
} |
|
} |
|
} |
|
|
|
var subPanelDisplayed = new Array(); |
|
SUGAR.util.doWhen("typeof(SUGAR.subpanelUtils) == \'object\' && typeof(SUGAR.subpanelUtils.onDrag) == \'function\' && document.getElementById(\'subpanel_list\') && typeof($) != \'undefined\'", function() { |
|
Lazyload.util.loadVisibleSubpanel(); |
|
$(window).scroll(Lazyload.util.loadVisibleSubpanel); |
|
}); |
|
</script>'; |
|
} |
|
} |
|
} |