Created
May 2, 2011 15:17
-
-
Save gergoerdosi/951763 to your computer and use it in GitHub Desktop.
Overlay patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/code/libraries/koowa/template/helper/behavior.php b/code/libraries/koowa/template/helper/behavior.php | |
index bacd6c1..80de659 100644 | |
--- a/code/libraries/koowa/template/helper/behavior.php | |
+++ b/code/libraries/koowa/template/helper/behavior.php | |
@@ -21,24 +21,24 @@ class KTemplateHelperBehavior extends KTemplateHelperAbstract | |
{ | |
/* | |
* Array which holds a list of loaded javascript libraries | |
- * | |
+ * | |
* boolean | |
*/ | |
protected $_loaded = array(); | |
- | |
+ | |
/** | |
* Constructor. | |
* | |
* @param object An optional KConfig object with configuration options | |
*/ | |
- public function __construct( KConfig $config = null) | |
- { | |
+ public function __construct( KConfig $config = null) | |
+ { | |
parent::__construct($config); | |
- | |
+ | |
//Reset the array of loaded scripts | |
$this->_loaded = array(); | |
} | |
- | |
+ | |
/** | |
* Method to load the mootools framework into the document head | |
* | |
@@ -52,11 +52,11 @@ class KTemplateHelperBehavior extends KTemplateHelperAbstract | |
$config->append(array( | |
'debug' => KDEBUG | |
)); | |
- | |
+ | |
$html =''; | |
- | |
+ | |
// Only load once | |
- if (!isset($this->_loaded['mootools'])) | |
+ if (!isset($this->_loaded['mootools'])) | |
{ | |
// If no debugging value is set, use the configuration setting | |
if($config->debug) { | |
@@ -64,13 +64,13 @@ class KTemplateHelperBehavior extends KTemplateHelperAbstract | |
} else { | |
$html .= '<script src="media://lib_koowa/js/mootools.js" />'; | |
} | |
- | |
+ | |
$this->_loaded['mootools'] = true; | |
} | |
return $html; | |
} | |
- | |
+ | |
/** | |
* Render a modal box | |
* | |
@@ -83,26 +83,26 @@ class KTemplateHelperBehavior extends KTemplateHelperAbstract | |
'selector' => 'a.modal', | |
'options' => array('disableFx' => true) | |
)); | |
- | |
+ | |
$html = ''; | |
// Load the necessary files if they haven't yet been loaded | |
- if (!isset($this->_loaded['modal'])) | |
+ if (!isset($this->_loaded['modal'])) | |
{ | |
$html .= '<script src="media://system/js/modal.js" />'; | |
$html .= '<style src="media://system/css/modal.css" />'; | |
- | |
+ | |
$this->_loaded['modal'] = true; | |
} | |
- | |
+ | |
$signature = md5(serialize(array($config->selector,$config->options))); | |
- if (!isset($this->_loaded[$signature])) | |
+ if (!isset($this->_loaded[$signature])) | |
{ | |
- $options = !empty($config->options) ? $config->options->toArray() : array(); | |
+ $options = !empty($config->options) ? $config->options->toArray() : array(); | |
$html .= " | |
<script> | |
window.addEvent('domready', function() { | |
- | |
+ | |
SqueezeBox.initialize(".json_encode($options)."); | |
$$('".$config->selector."').each(function(el) { | |
@@ -116,13 +116,13 @@ class KTemplateHelperBehavior extends KTemplateHelperAbstract | |
$this->_loaded[$signature] = true; | |
} | |
- | |
+ | |
return $html; | |
} | |
/** | |
* Render a tooltip | |
- * | |
+ * | |
* @return string The html output | |
*/ | |
public function tooltip($config = array()) | |
@@ -132,21 +132,21 @@ class KTemplateHelperBehavior extends KTemplateHelperAbstract | |
'selector' => '.hasTip', | |
'options' => array() | |
)); | |
- | |
+ | |
$html = ''; | |
- | |
+ | |
$signature = md5(serialize(array($config->selector,$config->options))); | |
- if (!isset($this->_loaded[$signature])) | |
+ if (!isset($this->_loaded[$signature])) | |
{ | |
- $options = !empty($config->options) ? $config->options->toArray() : array(); | |
+ $options = !empty($config->options) ? $config->options->toArray() : array(); | |
$html .= " | |
<script> | |
window.addEvent('domready', function(){ var JTooltips = new Tips($$('".$config->selector."'), '.json_encode($options).'); }); | |
</script>"; | |
- | |
+ | |
$this->_loaded[$signature] = true; | |
} | |
- | |
+ | |
return $html; | |
} | |
@@ -163,36 +163,36 @@ class KTemplateHelperBehavior extends KTemplateHelperAbstract | |
'options' => array(), | |
'attribs' => array() | |
)); | |
- | |
+ | |
$html = ''; | |
- | |
+ | |
// Load the necessary files if they haven't yet been loaded | |
- if (!isset($this->_loaded['overlay'])) | |
+ if (!isset($this->_loaded['overlay'])) | |
{ | |
$html .= '<script src="media://lib_koowa/js/koowa.js" />'; | |
$html .= '<style src="media://lib_koowa/css/koowa.css" />'; | |
- | |
+ | |
$options = !empty($config->options) ? $config->options->toArray() : array(); | |
$html .= " | |
- <script> | |
- window.addEvent('domready', function(){ $$('.-koowa-overlay').each(function(overlay){ new Koowa.Overlay(overlay, '".json_encode($options)."'); }); }); | |
- </script>"; | |
- | |
+ <script> | |
+ window.addEvent('domready', function(){ $$('.-koowa-overlay').each(function(overlay){ new Koowa.Overlay(overlay,'".json_encode($options)."') }); }); | |
+ </script>"; | |
+ | |
$this->_loaded['overlay'] = true; | |
} | |
$uri = KFactory::tmp('lib.koowa.http.uri', array('uri' => $config->uri)); | |
$uri->query['tmpl'] = ''; | |
- | |
+ | |
$attribs = KHelperArray::toString($config->attribs); | |
$html .= '<div href="'.$uri.'" class="-koowa-overlay" id="'.$uri->fragment.'" '.$attribs.'><div class="-koowa-overlay-status">'.JText::_('Loading...').'</div></div>'; | |
return $html; | |
} | |
- | |
+ | |
/** | |
- * Keep session alive | |
- * | |
+ * Keep session alive | |
+ * | |
* This will send an ascynchronous request to the server via AJAX on an interval | |
* in miliseconds | |
* | |
@@ -205,21 +205,21 @@ class KTemplateHelperBehavior extends KTemplateHelperAbstract | |
'refresh' => 15 * 60000, //15min | |
'url' => KRequest::url() | |
)); | |
- | |
+ | |
$refresh = (int) $config->refresh; | |
- | |
+ | |
// Longest refresh period is one hour to prevent integer overflow. | |
if ($refresh > 3600000 || $refresh <= 0) { | |
$refresh = 3600000; | |
} | |
// Build the keepalive script. | |
- $html = | |
+ $html = | |
"<script> | |
- Koowa.keepalive = function() { | |
+ Koowa.keepalive = function() { | |
var request = new Request({method: 'get', url: '".$config->url."'}).send(); | |
} | |
- | |
+ | |
window.addEvent('domready', function() { Koowa.keepalive.periodical('".$refresh."'); }); | |
</script>"; | |
diff --git a/code/media/lib_koowa/js/koowa.js b/code/media/lib_koowa/js/koowa.js | |
index 141325c..e47ba71 100644 | |
--- a/code/media/lib_koowa/js/koowa.js | |
+++ b/code/media/lib_koowa/js/koowa.js | |
@@ -164,15 +164,14 @@ Koowa.Query = new Class({ | |
} | |
}); | |
- | |
/** | |
* Overlay class | |
* | |
* @package Koowa_Media | |
* @subpackage Javascript | |
*/ | |
-Koowa.Overlay = Request.extend({ | |
- | |
+Koowa.Overlay = new Class({ | |
+ Extends : Request, | |
element : null, | |
options: { | |
@@ -211,15 +210,15 @@ Koowa.Overlay = Request.extend({ | |
} | |
this.element = $(element); | |
- this.parent(element.getAttribute('href'), options); | |
- | |
- this.request(); | |
+ this.parent(options); | |
+ this.options.url = element.getAttribute('href'); | |
if (this.options.initialize) this.options.initialize.call(this); | |
+ | |
+ this.send(); | |
} | |
}); | |
- | |
/** | |
* String class | |
* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment