]> git.mjollnir.org Git - moodle.git/commitdiff
navigation MDL-20557 Made navigation icons part of the link for that item so it is...
authorsamhemelryk <samhemelryk>
Wed, 14 Oct 2009 09:27:07 +0000 (09:27 +0000)
committersamhemelryk <samhemelryk>
Wed, 14 Oct 2009 09:27:07 +0000 (09:27 +0000)
lib/javascript-navigation.js
lib/navigationlib.php

index 59c591d5a68b0874d7f20d2248e0c94ed253031b..451dc61dff73ba4d5f2dc10a2335b42318283c1d 100644 (file)
@@ -771,26 +771,33 @@ navigation_tree_branch.prototype.inject_into_dom = function (element, gntinstanc
     if (this.myid != null) {
         branchp.setAttribute('id',this.myid);
     }
+    var branchicon = false;
     if (this.myicon != null) {
-        var branchicon = document.createElement('img');
+        branchicon = document.createElement('img');
         branchicon.setAttribute('src',this.myicon);
         branchicon.setAttribute('alt','');
-        branchp.appendChild(branchicon);
         this.myname = ' '+this.myname;
     }
     if (this.mylink === null) {
-        branchp.innerHTML = this.myname.replace(/\n/g, '<br />');
+        if (branchicon !== false) {
+            branchp.appendChild(branchicon);
+        }
+        branchp.appendChild(document.createTextNode(this.myname.replace(/\n/g, '<br />')));
     } else {
         var branchlink = document.createElement('a');
         branchlink.setAttribute('title', this.mytitle);
         branchlink.setAttribute('href', this.mylink);
-        branchlink.innerHTML = this.myname.replace(/\n/g, '<br />');
+        if (branchicon !== false) {
+            branchlink.appendChild(branchicon);
+        }
+        branchlink.appendChild(document.createTextNode(this.myname.replace(/\n/g, '<br />')));
         if (this.myhidden) {
             YAHOO.util.Dom.addClass(branchlink, 'dimmed');
         }
         branchp.appendChild(branchlink);
     }
     branchli.appendChild(branchp);
+    alert(branchli.innerHTML);
     element.appendChild(branchli);
     return branchli;
 }
index a128204f43ccaeb6798a44c2462aa3db58e02748..f29e2b0d6626e717b11d9bde1e2aee03030245e2 100644 (file)
@@ -402,6 +402,15 @@ class navigation_node {
              $title = $this->title;
         }
 
+        if ($this->icon!==null) {
+            $icon = new html_image();
+            $icon->src = $this->icon;
+            $icon->alt = '';
+            $content = $OUTPUT->image($icon).' '.$content;
+        } else if ($this->helpbutton!==null) {
+            $content = sprintf('%s<span class="clearhelpbutton">%s</span>',trim($this->helpbutton),$content);
+        }
+
         if ($content != '' && ((is_object($this->action) && ($this->action instanceof moodle_url || $this->action instanceof html_link)) || is_string($this->action))) {
             if (!($this->action instanceof html_link)) {
                 $link = new html_link();
@@ -424,19 +433,15 @@ class navigation_node {
 
             $content = $OUTPUT->link($link);
         } else {
+            $span = new html_span();
+            $span->contents = $content;
             if ($title !== '') {
-                $title = ' title="'.s($title).'"';
+                $span->title = $title;
             }
             if ($this->hidden) {
-                $content = sprintf('<span class="dimmed_text"%s>%s</span>', $title, clean_text($content));
-            } else {
-                $content = sprintf('<span%s>%s</span>', $title, clean_text($content));
+                $span->add_class('dimmed_text');
             }
-        }
-        if ($this->icon!==null) {
-            $content = sprintf('<img src="%s" alt="" /> %s',$this->icon,$content);
-        } else if ($this->helpbutton!==null) {
-            $content = sprintf('%s<span class="clearhelpbutton">%s</span>',trim($this->helpbutton),$content);
+            $content = $OUTPUT->span($span);
         }
         return $content;
     }