This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merge pull request #11 from realityking/ajax

AJAX improvements
  • Loading branch information...
2 parents 6999a7f + a47709f commit 666121df37ca6eeb54d0e44d837a6eba3b57cd6f @LouisLandry LouisLandry committed May 26, 2011
@@ -36,8 +36,7 @@ public function render($name, $params = array (), $content = null)
$messages = JFactory::getApplication()->getMessageQueue();
// Build the sorted message list
- if (is_array($messages) && count($messages))
- {
+ if (is_array($messages) && !empty($messages)) {
foreach ($messages as $msg)
{
if (isset($msg['type']) && isset($msg['message'])) {
@@ -46,19 +45,20 @@ public function render($name, $params = array (), $content = null)
}
}
+ // Build the return string
+ $buffer .= "\n<div id=\"system-message-container\">";
+
// If messages exist render them
- if (is_array($lists))
- {
- // Build the return string
+ if (is_array($lists)) {
$buffer .= "\n<dl id=\"system-message\">";
foreach ($lists as $type => $msgs)
{
- if (count($msgs))
- {
+ if (count($msgs)) {
$buffer .= "\n<dt class=\"".strtolower($type)."\">".JText::_($type)."</dt>";
$buffer .= "\n<dd class=\"".strtolower($type)." message\">";
$buffer .= "\n\t<ul>";
- foreach ($msgs as $msg) {
+ foreach ($msgs as $msg)
+ {
$buffer .="\n\t\t<li>".$msg."</li>";
}
$buffer .= "\n\t</ul>";
@@ -67,6 +67,8 @@ public function render($name, $params = array (), $content = null)
}
$buffer .= "\n</dl>";
}
+
+ $buffer .= "\n</div>";
return $buffer;
}
}
@@ -91,6 +91,43 @@ Joomla.isEmail = function(text) {
return regex.test(text);
};
+/**
+ * Render messages send via JSON
+ *
+ * @param object
+ * @return void
+ */
+Joomla.renderMessages = function(messages) {
+ var container = document.id('system-message-container');
+ var children = $$('#system-message-container > *');
+ children.destroy();
+ var dl = new Element('dl', {
+ id: 'system-message'
+ });
+ Object.each(messages, function (item, type) {
+ var dt = new Element('dt', {
+ 'class': type,
+ html: type
+ });
+ dt.inject(dl);
+ var dd = new Element('dd', {
+ 'class': type
+ });
+ dd.addClass('message');
+ var list = new Element('ul');
+
+ Array.each(item, function (item, index, object) {
+ var li = new Element('li', {
+ html: item
+ });
+ li.inject(list);
+ }, this);
+ list.inject(dd);
+ dd.inject(dl);
+ }, this);
+ dl.inject(container);
+};
+
/**
* USED IN: administrator/components/com_modules/views/module/tmpl/default.php
*
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 666121d

Please sign in to comment.