Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modify JDocumentRendererMessage to always render <div id="system-mess…

…age-container"></div>. This makes it possible to render messages via JavaScript.

Added Joomla.renderMessages() to core.js. This functions enabled rendering messages via JavaScript.
  • Loading branch information...
commit bade3acf0f5ea588be92cb24d4237228c043a3c7 1 parent c323ebe
Rouven Weßling realityking authored
18 libraries/joomla/document/html/renderer/message.php
View
@@ -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;
}
}
37 media/system/js/core-uncompressed.js
View
@@ -92,6 +92,43 @@ Joomla.isEmail = function(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
*
* Writes a dynamically generated list
14 media/system/js/core.js
View
@@ -1 +1,13 @@
-if(typeof(Joomla)==="undefined"){var Joomla={}}Joomla.editors={};Joomla.editors.instances={};Joomla.submitform=function(a,b){if(typeof(b)==="undefined"){b=document.getElementById("adminForm");if(!b){b=document.adminForm}}if(typeof(a)!=="undefined"){b.task.value=a}if(typeof b.onsubmit=="function"){b.onsubmit()}if(typeof b.fireEvent=="function"){b.fireEvent("submit")}b.submit()};Joomla.submitbutton=function(a){Joomla.submitform(a)};Joomla.JText={strings:{},_:function(a,b){return typeof this.strings[a.toUpperCase()]!=="undefined"?this.strings[a.toUpperCase()]:b},load:function(a){for(var b in a){this.strings[b.toUpperCase()]=a[b]}return this}};Joomla.replaceTokens=function(c){var b=document.getElementsByTagName("input");for(var a=0;a<b.length;a++){if((b[a].type=="hidden")&&(b[a].name.length==32)&&b[a].value=="1"){b[a].name=c}}};Joomla.isEmail=function(b){var a=new RegExp("^[\\w-_.]*[\\w-_.]@[\\w].+[\\w]+[\\w]$");return a.test(b)};function writeDynaList(e,g,d,h,a){var c="\n <select "+e+">";var b=0;for(x in g){if(g[x][0]==d){var f="";if((h==d&&a==g[x][1])||(b==0&&h!=d)){f='selected="selected"'}c+='\n <option value="'+g[x][1]+'" '+f+">"+g[x][2]+"</option>"}b++}c+="\n </select>";document.writeln(c)}function changeDynaList(c,e,b,f,a){var d=document.adminForm[c];for(i in d.options.length){d.options[i]=null}i=0;for(x in e){if(e[x][0]==b){opt=new Option();opt.value=e[x][1];opt.text=e[x][2];if((f==b&&a==opt.value)||i==0){opt.selected=true}d.options[i++]=opt}}d.length=i}function radioGetCheckedValue(b){if(!b){return""}var c=b.length;if(c==undefined){if(b.checked){return b.value}else{return""}}for(var a=0;a<c;a++){if(b[a].checked){return b[a].value}}return""}function getSelectedValue(b,a){var c=document[b];var d=c[a];i=d.selectedIndex;if(i!=null&&i>-1){return d.options[i].value}else{return null}}function checkAll(h,b){if(!b){b="cb"}if(h.form){var m=0;for(var g=0,a=h.form.elements.length;g<a;g++){var l=h.form.elements[g];if(l.type==h.type){if((b&&l.id.indexOf(b)==0)||!b){l.checked=h.checked;m+=(l.checked==true?1:0)}}}if(h.form.boxchecked){h.form.boxchecked.value=m}return true}else{var j=document.adminForm;var m=j.toggle.checked;var a=h;var k=0;for(var g=0;g<a;g++){var d=j[b+""+g];if(d){d.checked=m;k++}}if(m){document.adminForm.boxchecked.value=k}else{document.adminForm.boxchecked.value=0}}}function listItemTask(g,b){var d=document.adminForm;var a=d[g];if(a){for(var c=0;true;c++){var e=d["cb"+c];if(!e){break}e.checked=false}a.checked=true;d.boxchecked.value=1;submitbutton(b)}return false}function isChecked(a){if(a==true){document.adminForm.boxchecked.value++}else{document.adminForm.boxchecked.value--}}function submitbutton(a){submitform(a)}function submitform(a){if(a){document.adminForm.task.value=a}if(typeof document.adminForm.onsubmit=="function"){document.adminForm.onsubmit()}if(typeof document.adminForm.fireEvent=="function"){document.adminForm.fireEvent("submit")}document.adminForm.submit()}function popupWindow(g,e,b,d,a){var c=(screen.width-b)/2;var f=(screen.height-d)/2;winprops="height="+d+",width="+b+",top="+f+",left="+c+",scrollbars="+a+",resizable";win=window.open(g,e,winprops);if(parseInt(navigator.appVersion)>=4){win.window.focus()}}function tableOrdering(a,c,b){var d=document.adminForm;d.filter_order.value=a;d.filter_order_Dir.value=c;submitform(b)}function saveorder(b,a){checkAll_button(b,a)}function checkAll_button(d,a){if(!a){a="saveorder"}for(var b=0;b<=d;b++){var c=document.adminForm["cb"+b];if(c){if(c.checked==false){c.checked=true}}else{alert("You cannot change the order of items, as an item in the list is `Checked Out`");return}}submitform(a)};
+/*
+ GNU General Public License version 2 or later; see LICENSE.txt
+*/
+if(typeof Joomla==="undefined")var Joomla={};Joomla.editors={};Joomla.editors.instances={};Joomla.submitform=function(a,b){if(typeof b==="undefined"&&(b=document.getElementById("adminForm"),!b))b=document.adminForm;if(typeof a!=="undefined")b.task.value=a;if(typeof b.onsubmit=="function")b.onsubmit();typeof b.fireEvent=="function"&&b.fireEvent("submit");b.submit()};Joomla.submitbutton=function(a){Joomla.submitform(a)};
+Joomla.JText={strings:{},_:function(a,b){return typeof this.strings[a.toUpperCase()]!=="undefined"?this.strings[a.toUpperCase()]:b},load:function(a){for(var b in a)this.strings[b.toUpperCase()]=a[b];return this}};Joomla.replaceTokens=function(a){for(var b=document.getElementsByTagName("input"),c=0;c<b.length;c++)if(b[c].type=="hidden"&&b[c].name.length==32&&b[c].value=="1")b[c].name=a};Joomla.isEmail=function(a){return/^[\w-_.]*[\w-_.]@[\w].+[\w]+[\w]$/.test(a)};
+Joomla.renderMessages=function(a){var b=document.id("system-message-container");$$("#system-message-container > *").destroy();var c=new Element("dl",{id:"system-message"});Object.each(a,function(a,b){(new Element("dt",{"class":b,html:b})).inject(c);var e=new Element("dd",{"class":b});e.addClass("message");var g=new Element("ul");Array.each(a,function(a){(new Element("li",{html:a})).inject(g)},this);g.inject(e);e.inject(c)},this);c.inject(b)};
+function writeDynaList(a,b,c,d,f){var a="\n\t<select "+a+">",e=0;for(x in b){if(b[x][0]==c){var g="";if(d==c&&f==b[x][1]||e==0&&d!=c)g='selected="selected"';a+='\n\t\t<option value="'+b[x][1]+'" '+g+">"+b[x][2]+"</option>"}e++}a+="\n\t</select>";document.writeln(a)}
+function changeDynaList(a,b,c,d,f){a=document.adminForm[a];for(i in a.options.length)a.options[i]=null;i=0;for(x in b)if(b[x][0]==c){opt=new Option;opt.value=b[x][1];opt.text=b[x][2];if(d==c&&f==opt.value||i==0)opt.selected=!0;a.options[i++]=opt}a.length=i}function radioGetCheckedValue(a){if(!a)return"";var b=a.length;if(b==void 0)return a.checked?a.value:"";for(var c=0;c<b;c++)if(a[c].checked)return a[c].value;return""}
+function getSelectedValue(a,b){var c=document[a][b];i=c.selectedIndex;return i!=null&&i>-1?c.options[i].value:null}
+function checkAll(a,b){b||(b="cb");if(a.form){for(var c=0,d=0,f=a.form.elements.length;d<f;d++){var e=a.form.elements[d];if(e.type==a.type&&(b&&e.id.indexOf(b)==0||!b))e.checked=a.checked,c+=e.checked==!0?1:0}if(a.form.boxchecked)a.form.boxchecked.value=c;return!0}else{for(var e=document.adminForm,c=e.toggle.checked,f=a,g=0,d=0;d<f;d++){var h=e[b+""+d];if(h)h.checked=c,g++}document.adminForm.boxchecked.value=c?g:0}}
+function listItemTask(a,b){var c=document.adminForm,d=c[a];if(d){for(var f=0;;f++){var e=c["cb"+f];if(!e)break;e.checked=!1}d.checked=!0;c.boxchecked.value=1;submitbutton(b)}return!1}function isChecked(a){a==!0?document.adminForm.boxchecked.value++:document.adminForm.boxchecked.value--}function submitbutton(a){submitform(a)}
+function submitform(a){if(a)document.adminForm.task.value=a;if(typeof document.adminForm.onsubmit=="function")document.adminForm.onsubmit();typeof document.adminForm.fireEvent=="function"&&document.adminForm.fireEvent("submit");document.adminForm.submit()}function popupWindow(a,b,c,d,f){winprops="height="+d+",width="+c+",top="+(screen.height-d)/2+",left="+(screen.width-c)/2+",scrollbars="+f+",resizable";win=window.open(a,b,winprops);parseInt(navigator.appVersion)>=4&&win.window.focus()}
+function tableOrdering(a,b,c){var d=document.adminForm;d.filter_order.value=a;d.filter_order_Dir.value=b;submitform(c)}function saveorder(a,b){checkAll_button(a,b)}function checkAll_button(a,b){b||(b="saveorder");for(var c=0;c<=a;c++){var d=document.adminForm["cb"+c];if(d){if(d.checked==!1)d.checked=!0}else{alert("You cannot change the order of items, as an item in the list is `Checked Out`");return}}submitform(b)};
Please sign in to comment.
Something went wrong with that request. Please try again.