Skip to content

Instantly share code, notes, and snippets.

@hans2103
Created August 4, 2016 08:08
Show Gist options
  • Save hans2103/dc1994f205f778b3ebf34ed0fb73e445 to your computer and use it in GitHub Desktop.
Save hans2103/dc1994f205f778b3ebf34ed0fb73e445 to your computer and use it in GitHub Desktop.
Removal of SqueezeBox in Joomla! frontend head
// what is added
<script type="text/javascript">
jQuery(function($) {
SqueezeBox.initialize({});
SqueezeBox.assign($('a.modal').get(), {
parse: 'rel'
});
});
window.jModalClose = function () {
SqueezeBox.close();
};
// Add extra modal close functionality for tinyMCE-based editors
document.onreadystatechange = function () {
if (document.readyState == 'interactive' && typeof tinyMCE != 'undefined' && tinyMCE)
{
if (typeof window.jModalClose_no_tinyMCE === 'undefined')
{
window.jModalClose_no_tinyMCE = typeof(jModalClose) == 'function' ? jModalClose : false;
jModalClose = function () {
if (window.jModalClose_no_tinyMCE) window.jModalClose_no_tinyMCE.apply(this, arguments);
tinyMCE.activeEditor.windowManager.close();
};
}
if (typeof window.SqueezeBoxClose_no_tinyMCE === 'undefined')
{
if (typeof(SqueezeBox) == 'undefined') SqueezeBox = {};
window.SqueezeBoxClose_no_tinyMCE = typeof(SqueezeBox.close) == 'function' ? SqueezeBox.close : false;
SqueezeBox.close = function () {
if (window.SqueezeBoxClose_no_tinyMCE) window.SqueezeBoxClose_no_tinyMCE.apply(this, arguments);
tinyMCE.activeEditor.windowManager.close();
};
}
}
};
</script>
// how it can be removed
public function unsetExtraSqueezeBox()
{
if (isset($this->doc->_script['text/javascript']))
{
$this->doc->_script['text/javascript'] = preg_replace('%jQuery\(function\(\$\) \{\s*SqueezeBox.initialize\(\{\}\);\s*SqueezeBox.assign\(\$\(\'a.modal\'\).get\(\), \{\s*parse: \'rel\'\s*\}\);\s*\}\);\s*\s*window.jModalClose = function \(\) \{\s*SqueezeBox.close\(\);\s*\};\s*\s*// Add extra modal close functionality for tinyMCE-based editors\s*document.onreadystatechange = function \(\) \{\s*if \(document.readyState == \'interactive\' && typeof tinyMCE != \'undefined\' && tinyMCE\)\s*\{\s*if \(typeof window.jModalClose_no_tinyMCE === \'undefined\'\)\s*\{\s*window.jModalClose_no_tinyMCE = typeof\(jModalClose\) == \'function\' \? jModalClose : false;\s*\s*jModalClose = function \(\) \{\s*if \(window.jModalClose_no_tinyMCE\) window.jModalClose_no_tinyMCE.apply\(this, arguments\);\s*tinyMCE.activeEditor.windowManager.close\(\);\s*\};\s*\}\s*\s*if \(typeof window.SqueezeBoxClose_no_tinyMCE === \'undefined\'\)\s*\{\s*if \(typeof\(SqueezeBox\) == \'undefined\'\) SqueezeBox = \{\};\s*window.SqueezeBoxClose_no_tinyMCE = typeof\(SqueezeBox.close\) == \'function\' \? SqueezeBox.close : false;\s*\s*SqueezeBox.close = function \(\) \{\s*if \(window.SqueezeBoxClose_no_tinyMCE\) window.SqueezeBoxClose_no_tinyMCE.apply\(this, arguments\);\s*tinyMCE.activeEditor.windowManager.close\(\);\s*\};\s*\}\s*\}\s*\};%', '', $this->doc->_script['text/javascript']);
// Unset completly if empty
if (empty($this->doc->_script['text/javascript']))
{
unset($this->doc->_script['text/javascript']);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment