]> jfr.im git - z_archive/KronOS.git/commitdiff
Two-level menus (for Apps menu)
authorJohn Runyon <redacted>
Tue, 23 Oct 2012 05:11:58 +0000 (08:11 +0300)
committerJohn Runyon <redacted>
Tue, 23 Oct 2012 05:11:58 +0000 (08:11 +0300)
application/libraries/Core.php
public/js/application.js

index 0d3cc119fa201c2094dbfda4f4ef62b7df13c3ce..98083b38c527ca8687ddfa84be398861d8622ba1 100644 (file)
@@ -15,7 +15,10 @@ class Core {
                        'Logout'        => 'javascript:wos.logout();void(0);',
                        'GitHub'        => 'https://github.com/mustis/KronOS'
                );*/
-               $menu = array();
+               $menu = array(
+                       'Apps'          => array(),
+                       'System'        => array(),
+               );
 
                $ulev = $this->CI->user->level();
                if ($ulev == 'operator') $chklevel = "a.access = 'user' OR a.access = 'operator'";
@@ -25,11 +28,11 @@ class Core {
                $sql = 'SELECT c.catname AS category, a.appname AS appname, a.aid AS appid FROM categories AS c, apps AS a WHERE c.cid = a.parent AND ('.$chklevel.')';
                $q = $this->CI->db->query($sql);
                foreach ($q->result() as $row) {
-                       $menu[$row->category][$row->appname] = 'javascript:wos.openApp('.$row->appid.');void(0);';
+                       $menu['Apps'][$row->category][$row->appname] = 'javascript:wos.openApp('.$row->appid.');void(0);';
                }
 
-               ksort($menu);
-               foreach ($menu as $key => &$cat) {
+               ksort($menu['Apps']);
+               foreach ($menu['Apps'] as $key => &$cat) {
                        if (is_array($cat)) {
                                ksort($cat);
                        }
index 5195983917d63a69485dee9c884c6bc960db7bd8..adc829786f7dfc189188d4ff35d52e597a189368 100644 (file)
@@ -56,7 +56,15 @@ var wos
                                                innerStr = '';
                                                closeStr = '</ul></li>';
                                                $.each(val, function(ikey, ival) {
-                                                       innerStr += '<li><a tabindex="-1" href=\''+ival+'\'>'+ikey+'</a></li>';
+                                                       if (typeof ival == "object") {
+                                                               innerStr += '<li class="dropdown-submenu"><a tabindex="-1" href="#">'+ikey+'</a><ul class="dropdown-menu">';
+                                                               $.each(ival, function(iikey, iival) {
+                                                                       innerStr += '<li><a tabindex="-1" href=\''+iival+'\'>'+iikey+'</a></li>';
+                                                               });
+                                                               innerStr += '</ul></li>';
+                                                       } else {
+                                                               innerStr += '<li><a tabindex="-1" href=\''+ival+'\'>'+ikey+'</a></li>';
+                                                       }
                                                });
                                                navStr += openStr+innerStr+closeStr;
                                        });