Skip to content

Commit

Permalink
Merge pull request joomla#11 from realityking/ajax
Browse files Browse the repository at this point in the history
AJAX improvements
  • Loading branch information
LouisLandry committed May 26, 2011
2 parents 6999a7f + a47709f commit 666121d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 9 deletions.
18 changes: 10 additions & 8 deletions libraries/joomla/document/html/renderer/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand All @@ -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>";
Expand All @@ -67,6 +67,8 @@ public function render($name, $params = array (), $content = null)
}
$buffer .= "\n</dl>";
}

$buffer .= "\n</div>";
return $buffer;
}
}
37 changes: 37 additions & 0 deletions media/system/js/core-uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
14 changes: 13 additions & 1 deletion media/system/js/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 666121d

Please sign in to comment.