commit aafab48773be58d1c6f98290532e6db1120babf1 Author: Dennis Eichhorn Date: Sun Nov 29 21:57:18 2015 +0100 Init diff --git a/Admin/Installer.php b/Admin/Installer.php new file mode 100644 index 0000000..ad44bcf --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,131 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Navigation\Admin; + +use phpOMS\DataStorage\Database\DatabaseType; +use phpOMS\DataStorage\Database\Pool; +use phpOMS\Module\InstallerAbstract; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Navigation + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Installer extends InstallerAbstract +{ + + /** + * {@inheritdoc} + */ + public static function install(Pool $dbPool, array $info) + { + parent::install($dbPool, $info); + + switch ($dbPool->get('core')->getType()) { + case DatabaseType::MYSQL: + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'nav` ( + `nav_id` int(11) NOT NULL, + `nav_pid` varchar(40) NOT NULL, + `nav_name` varchar(40) NOT NULL, + `nav_type` tinyint(1) NOT NULL, + `nav_subtype` tinyint(1) NOT NULL, + `nav_icon` varchar(40) DEFAULT NULL, + `nav_uri` varchar(255) DEFAULT NULL, + `nav_target` varchar(10) DEFAULT NULL, + `nav_from` varchar(255) DEFAULT NULL, + `nav_order` smallint(3) DEFAULT NULL, + `nav_parent` int(11) DEFAULT NULL, + `nav_permission` int(11) DEFAULT NULL, + PRIMARY KEY (`nav_id`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8;' + )->execute(); + break; + } + } + + /** + * Install data from providing modules. + * + * @param Pool $dbPool Database pool + * @param array $data Module info + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function installExternal($dbPool, $data) + { + try { + $dbPool->get('core')->con->query('select 1 from `' . $dbPool->get('core')->prefix . 'nav`'); + } catch (\Exception $e) { + return; + } + + foreach ($data as $link) { + self::installLink($dbPool, $link, $link['parent']); + } + } + + /** + * Install navigation element. + * + * @param Pool $dbPool Database instance + * @param array $data Link info + * @param \int $parent Parent element (default is 0 for none) + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private static function installLink($dbPool, $data, $parent = 0) + { + $sth = $dbPool->get('core')->con->prepare( + 'INSERT INTO `' . $dbPool->get('core')->prefix . 'nav` (`nav_id`, `nav_pid`, `nav_name`, `nav_type`, `nav_subtype`, `nav_icon`, `nav_uri`, `nav_target`, `nav_from`, `nav_order`, `nav_parent`, `nav_permission`) VALUES + (:id, :pid, :name, :type, :subtype, :icon, :uri, :target, :from, :order, :parent, :perm);' + ); + + $sth->bindValue(':id', $data['id'] ?? 0, \PDO::PARAM_INT); + $sth->bindValue(':pid', $data['pid'] ?? '', \PDO::PARAM_STR); + $sth->bindValue(':name', $data['name'] ?? '', \PDO::PARAM_STR); + $sth->bindValue(':type', $data['type'] ?? 1, \PDO::PARAM_INT); + $sth->bindValue(':subtype', $data['subtype'] ?? 2, \PDO::PARAM_INT); + $sth->bindValue(':icon', $data['icon'] ?? null, \PDO::PARAM_STR); + $sth->bindValue(':uri', $data['uri'] ?? null, \PDO::PARAM_STR); + $sth->bindValue(':target', $data['target'] ?? "self", \PDO::PARAM_STR); + $sth->bindValue(':from', $data['from'] ?? 0, \PDO::PARAM_INT); + $sth->bindValue(':order', $data['order'] ?? 1, \PDO::PARAM_INT); + $sth->bindValue(':parent', $parent, \PDO::PARAM_INT); + $sth->bindValue(':perm', $data['permission'] ?? 0, \PDO::PARAM_INT); + + $sth->execute(); + + $lastInsertID = $dbPool->get('core')->con->lastInsertId(); + + foreach ($data['children'] as $link) { + $parent = ($link['parent'] == null ? $lastInsertID : $link['parent']); + self::installLink($dbPool, $link, $parent); + } + } +} diff --git a/Controller.js b/Controller.js new file mode 100644 index 0000000..728994d --- /dev/null +++ b/Controller.js @@ -0,0 +1,34 @@ +(function (skillet, undefined) { + //Private Property + var isHot = true; + + //Public Property + skillet.ingredient = 'Bacon Strips'; + + //Public Method + skillet.fry = function () { + var oliveOil; + + addItem('tn Butter nt'); + addItem(oliveOil); + console.log('Frying ' + skillet.ingredient); + }; + + //Private Method + function addItem(item) { + if (item !== undefined) { + console.log('Adding ' + item); + } + } + +}(window.skillet = window.skillet || {})); + +//Public Properties +console.log(skillet.ingredient); //Bacon Strips + +//Public Methods +skillet.fry(); //Adding Butter & Fraying Bacon Strips + +//Adding a Public Property +skillet.quantity = "12"; +console.log(skillet.quantity); //12 \ No newline at end of file diff --git a/Controller.php b/Controller.php new file mode 100644 index 0000000..5719a08 --- /dev/null +++ b/Controller.php @@ -0,0 +1,193 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Navigation; + +use Modules\Navigation\Models\NavigationType; +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Navigation + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Controller extends ModuleAbstract implements WebInterface +{ + + /** + * JavaScript files. + * + * @var \string[] + * @since 1.0.0 + */ + public static $js = [ + 'backend', + ]; + + /** + * CSS files. + * + * @var \string[] + * @since 1.0.0 + */ + public static $css = [ + ]; + + /** + * Navigation array. + * + * Array of all navigation elements sorted by type->parent->id + * + * @var array + * @since 1.0.0 + */ + public $nav = []; + + /** + * Navigation array. + * + * Array of all navigation elements by id + * + * @var array + * @since 1.0.0 + */ + public $nid = null; + + /** + * Parent links of the current page. + * + * @var array + * @since 1.0.0 + */ + public $nav_parents = null; + + /** + * Module name. + * + * @var \string + * @since 1.0.0 + */ + protected static $module = 'Navigation'; + + /** + * Localization files. + * + * @var \string + * @since 1.0.0 + */ + protected static $localization = [ + ]; + + /** + * Providing. + * + * @var \string[] + * @since 1.0.0 + */ + protected static $providing = [ + ]; + + /** + * Dependencies. + * + * @var \string[] + * @since 1.0.0 + */ + protected static $dependencies = [ + ]; + + /** + * Constructor. + * + * @param \Web\WebApplication $app Application + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct($app) + { + parent::__construct($app); + } + + /** + * {@inheritdoc} + */ + public function call(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $modules = $this->app->moduleManager->getActiveModules(); + $language = $this->app->accountManager->get($request->getAccount())->getL11n()->getLanguage(); + + foreach ($modules as $id => $module) { + $this->app->accountManager->get($request->getAccount())->getL11n()->loadLanguage($language, 'nav.backend', $module[0]['module_path']); + } + + if (!empty($this->nav)) { + $this->nav = []; + + $uri_hash = $request->getHash(); + $uri_pdo = ''; + $i = 1; + foreach ($uri_hash as $hash) { + $uri_pdo .= ':pid' . $i . ','; + $i++; + } + + $uri_pdo = rtrim($uri_pdo, ','); + + $sth = $this->app->dbPool->get('core')->con->prepare('SELECT * FROM `' . $this->app->dbPool->get('core')->prefix . 'nav` WHERE `nav_pid` IN(' . $uri_pdo . ') ORDER BY `nav_order` ASC'); + + $i = 1; + foreach ($uri_hash as $hash) { + $sth->bindValue(':pid' . $i, $hash, \PDO::PARAM_STR); + $i++; + } + + $sth->execute(); + $temp_nav = $sth->fetchAll(); + + foreach ($temp_nav as $link) { + $this->nav[$link['nav_type']][$link['nav_subtype']][$link['nav_id']] = $link; + } + } + + switch ($data[0]) { + case NavigationType::TOP: + /** @noinspection PhpIncludeInspection */ + require __DIR__ . '/Theme/' . $request->getType() . '/top.tpl.php'; + break; + case NavigationType::SIDE: + /** @noinspection PhpIncludeInspection */ + require __DIR__ . '/Theme/' . $request->getType() . '/side.tpl.php'; + break; + case NavigationType::CONTENT: + /** @noinspection PhpIncludeInspection */ + require __DIR__ . '/Theme/' . $request->getType() . '/mid.tpl.php'; + break; + case NavigationType::CONTENT_SIDE: + /** @noinspection PhpIncludeInspection */ + require __DIR__ . '/Theme/' . $request->getType() . '/mid-side.tpl.php'; + break; + } + } +} diff --git a/Models/LinkType.php b/Models/LinkType.php new file mode 100644 index 0000000..510f145 --- /dev/null +++ b/Models/LinkType.php @@ -0,0 +1,36 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Navigation\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Link type enum. + * + * @category Modules + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class LinkType extends Enum +{ + const CATEGORY = 0; + + const LINK = 1; +} diff --git a/Models/Navigation.js b/Models/Navigation.js new file mode 100644 index 0000000..e69de29 diff --git a/Models/Navigation.php b/Models/Navigation.php new file mode 100644 index 0000000..930944e --- /dev/null +++ b/Models/Navigation.php @@ -0,0 +1,152 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Navigation\Models; + +use phpOMS\DataStorage\Database\Pool; +use phpOMS\Message\RequestAbstract; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Navigation + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Navigation +{ + + /** + * Navigation array. + * + * Array of all navigation elements sorted by type->parent->id + * + * @var array + * @since 1.0.0 + */ + private $nav = []; + + /** + * Singleton instance. + * + * @var \Modules\Navigation\Models\Navigation + * @since 1.0.0 + */ + private static $instance = null; + + /** + * Database pool. + * + * @var Pool + * @since 1.0.0 + */ + private $dbPool = null; + + /** + * Constructor. + * + * @param RequestAbstract $request Request hashes + * @param Pool $dbPool Database pool + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private function __construct(RequestAbstract $request, Pool $dbPool = null) + { + $this->dbPool = $dbPool; + $this->load($request->getHash()); + } + + /** + * Load navigation based on request. + * + * @param \string[] $request Request hashes + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private function load($request) + { + if (empty($this->nav)) { + $this->nav = []; + $uriPdo = ''; + + $i = 1; + foreach ($request as $hash) { + $uriPdo .= ':pid' . $i . ','; + $i++; + } + + $uriPdo = rtrim($uriPdo, ','); + $sth = $this->dbPool->get('core')->con->prepare('SELECT * FROM `' . $this->dbPool->get('core')->prefix . 'nav` WHERE `nav_pid` IN(' . $uriPdo . ') ORDER BY `nav_order` ASC'); + + $i = 1; + foreach ($request as $hash) { + $sth->bindValue(':pid' . $i, $hash, \PDO::PARAM_STR); + $i++; + } + + $sth->execute(); + $tempNav = $sth->fetchAll(); + + foreach ($tempNav as $link) { + $this->nav[$link['nav_type']][$link['nav_subtype']][$link['nav_id']] = $link; + } + } + } + + /** + * Get instance. + * + * @param RequestAbstract $request Request hashes + * @param Pool $dbPool Database pool + * + * @return \Modules\Navigation\Models\Navigation + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getInstance(RequestAbstract $request = null, Pool $dbPool = null) + { + if (!isset(self::$instance)) { + self::$instance = new self($request, $dbPool); + } + + return self::$instance; + } + + /** + * Overwriting clone in order to maintain singleton pattern. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __clone() + { + } + + public function getNav() + { + return $this->nav; + } +} diff --git a/Models/NavigationType.php b/Models/NavigationType.php new file mode 100644 index 0000000..b55bed5 --- /dev/null +++ b/Models/NavigationType.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Navigation\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Navigation type enum. + * + * @category Modules + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class NavigationType extends Enum +{ + const TOP = 1; + + const SIDE = 2; + + const CONTENT = 3; + + const TAB = 4; + + const CONTENT_SIDE = 5; + + const BOTTOM = 6; +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..686a0e5 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Navigation # diff --git a/Theme/backend/mid-side.tpl.php b/Theme/backend/mid-side.tpl.php new file mode 100644 index 0000000..8eff47c --- /dev/null +++ b/Theme/backend/mid-side.tpl.php @@ -0,0 +1,40 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \Modules\Navigation\Views\NavigationView $this + */ + +/* Looping through all links */ +if (isset($this->nav[\Modules\Navigation\Models\NavigationType::CONTENT_SIDE])) { + echo '
' + . '

' . $this->l11n->lang[0]['Navigation'] + . '' + . '

' + . '
' + . '
'; +} diff --git a/Theme/backend/mid.tpl.php b/Theme/backend/mid.tpl.php new file mode 100644 index 0000000..8899d26 --- /dev/null +++ b/Theme/backend/mid.tpl.php @@ -0,0 +1,32 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \Modules\Navigation\Views\NavigationView $this + */ +if (isset($this->nav[\Modules\Navigation\Models\NavigationType::CONTENT])) { + echo ''; +} diff --git a/Theme/backend/side.tpl.php b/Theme/backend/side.tpl.php new file mode 100644 index 0000000..62cde67 --- /dev/null +++ b/Theme/backend/side.tpl.php @@ -0,0 +1,53 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \Modules\Navigation\Views\NavigationView $this + */ +if (isset($this->nav[\Modules\Navigation\Models\NavigationType::SIDE])) : ?> + + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ endif; diff --git a/Theme/backend/top.tpl.php b/Theme/backend/top.tpl.php new file mode 100644 index 0000000..ec2d726 --- /dev/null +++ b/Theme/backend/top.tpl.php @@ -0,0 +1,49 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \Modules\Navigation\Views\NavigationView $this + */ +if (isset($this->nav[\Modules\Navigation\Models\NavigationType::TOP])): ?> + + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ endif; diff --git a/Views/NavigationView.js b/Views/NavigationView.js new file mode 100644 index 0000000..e69de29 diff --git a/Views/NavigationView.php b/Views/NavigationView.php new file mode 100644 index 0000000..2473225 --- /dev/null +++ b/Views/NavigationView.php @@ -0,0 +1,176 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Navigation\Views; + +use phpOMS\Views\View; + +/** + * Navigation view. + * + * @category Modules + * @package Modules\Navigation + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class NavigationView extends View +{ + + /** + * Navigation Id. + * + * This is getting used in order to identify which navigation elements should get rendered. + * This usually is the parent navigation id + * + * @var int + * @since 1.0.0 + */ + protected $navId = null; + + /** + * Navigation. + * + * @var mixed[] + * @since 1.0.0 + */ + protected $nav = []; + + /** + * Language used for the navigation. + * + * @var \string + * @since 1.0.0 + */ + protected $language = 'en'; + + /** + * Parent element used for navigation. + * + * @var \int + * @since 1.0.0 + */ + protected $parent = 0; + + /** + * {@inheritdoc} + */ + public function __construct($app, $request, $response) + { + parent::__construct($app, $request, $response); + } + + /** + * Get navigation Id. + * + * @return \int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getNavId() : \int + { + return $this->navId; + } + + /** + * Set navigation Id. + * + * @param \int $navId Navigation id used for display + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setNavId(\int $navId) + { + $this->navId = $navId; + } + + /** + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getNav() : array + { + return $this->nav; + } + + /** + * @param mixed $nav + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setNav(array $nav) + { + $this->nav = $nav; + } + + /** + * @return \string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getLanguage() : \string + { + return $this->language; + } + + /** + * @param \string $language + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setLanguage(\string $language) + { + $this->language = $language; + } + + /** + * @return \int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getParent() : \int + { + return $this->parent; + } + + /** + * @param \int $parent + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setParent(\int $parent) + { + $this->parent = $parent; + } +} diff --git a/docs/guidelines.dev.md b/docs/guidelines.dev.md new file mode 100644 index 0000000..01d1a5d --- /dev/null +++ b/docs/guidelines.dev.md @@ -0,0 +1,3 @@ +## Installation + +The order of link elements inside the `nav.install.json` file needs to be unique. In case the order is not unique it's possible that the link order can vary from page to page. \ No newline at end of file diff --git a/docs/info.md b/docs/info.md new file mode 100644 index 0000000..db3bfa1 --- /dev/null +++ b/docs/info.md @@ -0,0 +1,11 @@ +# Navigation levels + +0. None +1. Top bar +2. Side bar +3. Content bar +4. Content Side +5. Tabs +6. Dashboard +7. Content Footer +8. Footer \ No newline at end of file diff --git a/img/module_teaser_small.png b/img/module_teaser_small.png new file mode 100644 index 0000000..f56e6ff Binary files /dev/null and b/img/module_teaser_small.png differ diff --git a/info.json b/info.json new file mode 100644 index 0000000..2dbd835 --- /dev/null +++ b/info.json @@ -0,0 +1,37 @@ +{ + "name": { + "id": 1000500000, + "internal": "Navigation", + "external": "OMS Navigation" + }, + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "The navigation module.", + "directory": "Navigation", + "dependencies": {}, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "40a630e157504605e40ba241f6b1f78ab1dd97b9" + ], + "type": 4, + "for": "Content", + "file": "Navigation", + "from": "Admin" + } + ], + "lang": false, + "js": true, + "css": false +} diff --git a/lang/en.lang.php b/lang/en.lang.php new file mode 100644 index 0000000..54adf12 --- /dev/null +++ b/lang/en.lang.php @@ -0,0 +1,21 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * Created by PhpStorm. + * User: spl1nes + * Date: 14.04.14 + * Time: 22:52. + */ diff --git a/module.js b/module.js new file mode 100644 index 0000000..884f02f --- /dev/null +++ b/module.js @@ -0,0 +1,93 @@ +/* global supports_html5_storage, setCookie, getCookie */ +$(document).ready(function () { + "use strict"; + + var sidebar = document.getElementById("s-nav"), + scrollPos = sidebar.scrollTop; + + /* [BEGIN]: Load/Save old navigation status */ + var $localStorage = supports_html5_storage(); + var navigation = null; + + if (!$localStorage) { + navigation = getCookie('1000500001'); + } else { + navigation = localStorage['1000500001']; + } + + var naviOBJ = null; + + if (navigation !== null) { + naviOBJ = JSON.parse(navigation); + + if ('1000500000' in naviOBJ) { + sidebar.hide(); + $('#content').css('margin-left', 0); + } + + var val = null; + for (var key in naviOBJ) { + //noinspection JSUnfilteredForInLoop + if (!isNaN(key)) { + val = naviOBJ[key]; + sidebar.find('.' + val + ' li:not(:first-child)').hide(); + sidebar.find('.' + val + ' .min').hide(); + sidebar.find('.' + val + ' .max').show(); + } + } + } + + sidebar.find('li .min').click(function () { + $(this).parent().parent().children('li:not(:first-child)').slideUp(); + naviOBJ[$(this).parent().parent().attr('class')] = $(this).parent().parent().attr('class'); + + if (!$localStorage) { + setCookie('1000500000', JSON.stringify(naviOBJ), 365, window.location.host, '/'); + } + else { + localStorage['1000500000'] = JSON.stringify(naviOBJ); + } + }); + + sidebar.find('li .max').click(function () { + $(this).parent().parent().children('li:not(:first-child)').slideDown(); + delete naviOBJ[$(this).parent().parent().attr('class')]; + + if (!$localStorage) { + setCookie('1000500000', JSON.stringify(naviOBJ), 365, window.location.host, '/'); + } + else { + localStorage['1000500000'] = JSON.stringify(naviOBJ); + } + }); + + sidebar.find('.hide').click(function () { + $(this).hide(); + $('#content').css('margin-left', 0); + }); + + /* [BEGIN]: Hide and Show sidenav */ + $(document).keydown(function (e) { + if (e.ctrlKey && e.altKey && e.which === 78) { + if (!sidebar.hasClass('.hidden')) { + sidebar.show(); + $('#content').css('margin-left', sidebar.width()); + delete naviOBJ['1000500000']; + } else { + sidebar.hide(); + $('#content').css('margin-left', 0); + naviOBJ['1000500000'] = 0; + } + + if (!$localStorage) { + setCookie('1000500000', JSON.stringify(naviOBJ), 365, window.location.host, '/'); + } + else { + localStorage['1000500000'] = JSON.stringify(naviOBJ); + } + } + }); + /* [END]: Hide and Show sidenav */ + + /* [END]: Load/Save old navigation status */ +}); \ No newline at end of file