]> jfr.im git - z_archive/KronOS.git/commitdiff
Added layout for login
authorConny Sjöblom <redacted>
Thu, 11 Oct 2012 11:26:17 +0000 (14:26 +0300)
committerConny Sjöblom <redacted>
Thu, 11 Oct 2012 11:26:17 +0000 (14:26 +0300)
video/application/controllers/backend.php
video/application/models/core.php
video/application/models/user.php
video/application/views/main_view.php
video/public/js/application.js

index 7d89ce204c996fd9defdc8582cd3effb11a3b92f..4e5e0c8ecff09737c9145f91fcbec4938ea869bd 100755 (executable)
@@ -5,14 +5,23 @@ class Backend extends CI_Controller {
                parent::__construct();
 
                $this->load->model('core');
+               $this->load->model('user');
        }
 
        public function index() {
                print "";
        }
 
+       public function logged_in() {
+               print json_encode($this->user->logged_in);
+       }
+
+       public function login_modal() {
+               print $this->core->get_login();
+       }
+
        public function get_menu() {
-               return $this->core->get_menu();
+               print json_encode($this->core->get_menu());
        }
 }
 ?>
index 07a874b20a577f22b35e019da084f3eebdff7706..fcf4cc1bee4ebae399b6a67417f7f8979d182b68 100644 (file)
@@ -7,7 +7,42 @@ class Core extends CI_Model {
                        'Test'          => '#',
                        'GitHub'        => 'https://github.com/mustis/WebOsProject'
                );
-               print json_encode($menu);
+               return $menu;
+       }
+       public function get_login() {
+               $login_modal = '
+               <div id="loginModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+                       <div class="modal-header">
+                               <h3 id="myModalLabel">Login</h3>
+                       </div>
+                       <div class="modal-body">
+                               <form class="form-horizontal">
+                                       <div class="control-group">
+                                               <label class="control-label" for="inputEmail">Email</label>
+                                               <div class="controls">
+                                                       <input type="text" id="inputEmail" placeholder="Email">
+                                               </div>
+                                       </div>
+                                       <div class="control-group">
+                                               <label class="control-label" for="inputPassword">Password</label>
+                                               <div class="controls">
+                                                       <input type="password" id="inputPassword" placeholder="Password">
+                                               </div>
+                                       </div>
+                                       <div class="control-group">
+                                               <div class="controls">
+                                                       <label class="checkbox">
+                                                               <input type="checkbox"> Remember me
+                                                       </label>
+                                               </div>
+                                       </div>
+                               </form>
+                       </div>
+                       <div class="modal-footer">
+                               <button type="submit" class="btn btn-primary">Login</button>
+                       </div>
+               </div>';
+               return $login_modal;
        }
 }
 ?>
index 8be6b6cc4f9586c66e603fd5f7b60a0ded3f6c9d..0fe9c37218484419f151503482a737e3e1149038 100644 (file)
@@ -8,9 +8,9 @@ class User extends CI_Model {
                # Required
         parent::__construct();
        }
-       
+
        public function check_login() {
                if (!$this->logged_in)
                        redirect('account/login/');
        }
-}
\ No newline at end of file
+}
index f837d04f2609352192e426fd43abd2095762680f..b5ccaf89908c52be1093b98107e5d8faab742704 100644 (file)
                                </div>\r
                        </div>\r
                </div>\r
-\r
                <div class="container-fluid">\r
                        <div class="row">\r
-                               <div id="drag_demo_1" style="width:100px; height:100px; background:#7baaed; border:1px solid #333;"></div>\r
-                                       <script type="text/javascript">\r
-                                               new Draggable('drag_demo_1');\r
-                                       </script>\r
-                               </div>\r
                        </div>\r
                </div>\r
 <!--           <script src="/public/js/prototype.js" type="text/javascript"></script>\r
index 501c7ac84923f1adca54ab45461b1698dc106cb4..e952c77d8725cb8f77c5369a0ab39d6362e97689 100644 (file)
@@ -1,13 +1,30 @@
 jQuery.noConflict();
+
 jQuery(document).ready(function () {
-       jQuery.getJSON("/backend/get_menu", function(data) {
-               var menuitems = []
-               jQuery.each(data, function(key, val) {
-                       menuitems.push('<li><a href="' + val + '">' + key + '</li>');
-               });
-               jQuery('<ul/>', {
-                       'class': 'nav',
-                       html: menuitems.join('')
-               }).appendTo('.menudiv');
+       jQuery.getJSON("/backend/logged_in", function(data) {
+               if (!data) {
+                       jQuery.ajax({
+                               url: "/backend/login_modal",
+                               success: function (data) { jQuery('body').append(data); },
+                               dataType: 'html'
+                       }).done(function() {
+                               jQuery('#loginModal').modal({
+                                       backdrop: 'static',
+                                       keyboard: false
+                               });
+                               jQuery('#loginModal').modal('show');
+                       });
+               } else {
+                       jQuery.getJSON("/backend/get_menu", function(data) {
+                               var menuitems = []
+                               jQuery.each(data, function(key, val) {
+                                       menuitems.push('<li><a href="' + val + '">' + key + '</li>');
+                               });
+                               jQuery('<ul/>', {
+                                       'class': 'nav',
+                                       html: menuitems.join('')
+                               }).appendTo('.menudiv');
+                       });
+               }
        });
 });