Index: extensions/AdminTools/include/MultiView.class.php
===================================================================
--- extensions/AdminTools/include/MultiView.class.php	(revision 25776)
+++ extensions/AdminTools/include/MultiView.class.php	(revision 25791)
@@ -113,5 +113,6 @@
       );
 
-    if ($this->is_admin)
+    // inactive on ws.php to allow AJAX admin tasks
+    if ($this->is_admin && script_basename() != 'ws')
     {
       if ($this->data['view_as'] == 0)
@@ -201,9 +202,12 @@
   public function init()
   {
-    if (isset($_GET['ato_purge_template']))
-    {
-      global $template;
-      $template->delete_compiled_templates();
-      FileCombiner::clear_combined_files();
+    if ($this->is_admin)
+    {
+      if (isset($_GET['ato_purge_template']))
+      {
+        global $template;
+        $template->delete_compiled_templates();
+        FileCombiner::clear_combined_files();
+      }
     }
   }
Index: extensions/AdminTools/include/events.inc.php
===================================================================
--- extensions/AdminTools/include/events.inc.php	(revision 25776)
+++ extensions/AdminTools/include/events.inc.php	(revision 25791)
@@ -8,5 +8,5 @@
 function admintools_add_public_controller()
 {
-  global $MultiView, $conf;
+  global $MultiView, $conf, $template, $page, $user;
 
   if (!$MultiView->is_admin())
@@ -14,6 +14,4 @@
     return;
   }
-
-  global $template, $page, $user;
 
   $url_root = get_root_url();
@@ -99,5 +97,5 @@
 
     $tpl_vars['QUICK_EDIT'] = array(
-      'img' =>                $picture['current']['derivatives']['square'],
+      'img' =>                $picture['current']['derivatives']['square']->get_url(),
       'name' =>               $picture['current']['name'],
       'comment' =>            $picture['current']['comment'],
@@ -132,15 +130,20 @@
     }
 
-    $query = '
+    $tpl_vars['QUICK_EDIT'] = array(
+      'img' =>      null,
+      'name' =>     $page['category']['name'],
+      'comment' =>  $page['category']['comment'],
+      );
+
+    if (!empty($page['category']['representative_picture_id']))
+    {
+      $query = '
 SELECT * FROM '.IMAGES_TABLE.'
   WHERE id = '. $page['category']['representative_picture_id'] .'
 ;';
-    $image_infos = pwg_db_fetch_assoc(pwg_query($query));
-
-    $tpl_vars['QUICK_EDIT'] = array(
-      'img' =>      DerivativeImage::get_one(IMG_SQUARE, $image_infos),
-      'name' =>     $page['category']['name'],
-      'comment' =>  $page['category']['comment'],
-      );
+      $image_infos = pwg_db_fetch_assoc(pwg_query($query));
+
+      $tpl_vars['QUICK_EDIT']['img'] = DerivativeImage::get_one(IMG_SQUARE, $image_infos)->get_url();
+    }
   }
 
@@ -201,5 +204,10 @@
 function admintools_save_picture()
 {
-  global $page, $conf;
+  global $page, $conf, $MultiView;
+
+  if (!$MultiView->is_admin())
+  {
+    return;
+  }
 
   if (isset($_GET['delete']) and get_pwg_token()==@$_GET['pwg_token'])
@@ -269,5 +277,10 @@
 function admintools_save_category()
 {
-  global $page, $conf;
+  global $page, $conf, $MultiView;
+
+  if (!$MultiView->is_admin())
+  {
+    return;
+  }
   
   if (@$_POST['action'] == 'quick_edit')
Index: extensions/AdminTools/main.inc.php
===================================================================
--- extensions/AdminTools/main.inc.php	(revision 25776)
+++ extensions/AdminTools/main.inc.php	(revision 25791)
@@ -10,4 +10,5 @@
 
 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
+
 
 // +-----------------------------------------------------------------------+
@@ -31,11 +32,4 @@
 add_event_handler('init', 'admintools_init');
 
-if (!defined('IN_ADMIN'))
-{
-  add_event_handler('loc_after_page_header', 'admintools_add_public_controller');
-  add_event_handler('loc_begin_picture', 'admintools_save_picture');
-  add_event_handler('loc_begin_index', 'admintools_save_category');
-}
-
 add_event_handler('user_init', array(&$MultiView, 'user_init'));
 add_event_handler('init', array(&$MultiView, 'init'));
@@ -47,4 +41,15 @@
 function admintools_init()
 {
+  global $MultiView;
+  
+  if (!defined('IN_ADMIN') && $MultiView->is_admin())
+  {
+    add_event_handler('loc_after_page_header', 'admintools_add_public_controller');
+    add_event_handler('loc_begin_picture', 'admintools_save_picture');
+    add_event_handler('loc_begin_index', 'admintools_save_category');
+  }
+  
+  load_language('plugin.lang', ADMINTOOLS_PATH);
+
   // global $conf;
 
@@ -52,7 +57,5 @@
   // $maintain = new AdminTools_maintain(ADMINTOOLS_ID);
   // $maintain->autoUpdate(ADMINTOOLS_VERSION, 'install');
-
-  load_language('plugin.lang', ADMINTOOLS_PATH);
-
+  
   // $conf['AdminTools'] = unserialize($conf['AdminTools']);
 }
Index: extensions/AdminTools/template/public_controller.tpl
===================================================================
--- extensions/AdminTools/template/public_controller.tpl	(revision 25776)
+++ extensions/AdminTools/template/public_controller.tpl	(revision 25791)
@@ -102,5 +102,5 @@
     <form method="post" action="{$ato.U_SELF}">
       <fieldset class="left">
-        <img src="{$ato.QUICK_EDIT.img->get_url()}" width="100" height="100">
+        <img src="{$ato.QUICK_EDIT.img}" width="100" height="100">
         <input type="submit" value="{'Save'|translate}">
         <a href="#" class="icon-ato-cancel close-edit">{'Cancel'|translate}</a>
@@ -150,6 +150,6 @@
       $('body').animate({ldelim}'margin-top': operator+ato_height});
       
-      if ($('#the_page').css('position')=='absolute') {
-        $('#the_page').animate({ldelim}'top': operator+ato_height});
+      if ($('#the_page, [data-role="page"]').css('position')=='absolute') {
+        $('#the_page, [data-role="page"]').animate({ldelim}'top': operator+ato_height});
       }
     }
@@ -157,6 +157,6 @@
       $('body').css({ldelim}'margin-top': operator+ato_height});
       
-      if ($('#the_page').css('position')=='absolute') {
-        $('#the_page').css({ldelim}'top': operator+ato_height});
+      if ($('#the_page, [data-role="page"]').css('position')=='absolute') {
+        $('#the_page, [data-role="page"]').css({ldelim}'top': operator+ato_height});
       }
     }
@@ -168,5 +168,17 @@
       urlWS = '{$ROOT_URL}ws.php?format=json&method=';
 
-  $('body').prepend($ato);
+  $('body').prepend($ato); // ensure the bar is at the begining
+  
+  {if $themeconf.mobile}
+    var $headerbar = $('div[data-role="header"] .title');
+    if ($headerbar.length == 1) {
+      $ato_closed.addClass('smartpocket');
+      $ato_closed.find('a').attr({
+        'data-iconpos':'notext',
+        'data-role':'button'
+      });
+      $headerbar.prepend($ato_closed);    
+    }
+  {/if}
 
   if (window.localStorage.ato_panel_open == null) {
@@ -289,10 +301,21 @@
 {if isset($ato.QUICK_EDIT)}
   var $ato_edit = $('#ato_quick_edit');
-
-  var bg_color = $('#the_page #content').css('background-color');
-  if (!bg_color || bg_color=='transparent') {
-    bg_color = $('body').css('background-color');
-  }
-  $ato_edit.css('background-color', bg_color);
+  
+  
+  setTimeout(function() {
+    var bg_color = 'white';
+    var selectors = ['#the_page #content', '[data-role="page"]', 'body'];
+    
+    for (var i=0; i<selectors.length; i++) {
+      var color = $(selectors[i]).css('background-color');
+      console.log(selectors[i], color);
+      if (color && color!='transparent') {
+        bg_color = color;
+        break;
+      }
+    }
+
+    $ato_edit.css('background-color', bg_color);
+  }, 1000);
 
   $ato_edit.find('.close-edit').on('click', function(e) {
Index: extensions/AdminTools/template/style.css
===================================================================
--- extensions/AdminTools/template/style.css	(revision 25776)
+++ extensions/AdminTools/template/style.css	(revision 25791)
@@ -7,4 +7,6 @@
 #ato_header, #ato_header_closed {
   display:none;
+}
+#ato_header, #ato_header_closed:not(.smartpocket) {
   position:fixed;
   top:0;
@@ -28,5 +30,5 @@
   white-space:nowrap;
 }
-  #ato_header_root li a, #ato_header_closed a {
+  #ato_header_root li a, #ato_header_closed:not(.smartpocket) a {
     display:inline-block;
     padding:5px 10px;
@@ -54,5 +56,5 @@
     border-right:1px solid #222;
   }
-  #ato_header_root>li a, #ato_header_closed a {
+  #ato_header_root>li a, #ato_header_closed:not(.smartpocket) a {
     color:#ddd;
     text-shadow:1px 1px 0px #222;
@@ -62,5 +64,5 @@
     text-shadow:none;
   }
-  #ato_header_root>li:not(.disabled):hover, #ato_header_closed:hover {
+  #ato_header_root>li:not(.disabled):hover, #ato_header_closed:not(.smartpocket):hover {
     background:#222;
     background-image:linear-gradient(to bottom, #222, #353535);
@@ -113,5 +115,5 @@
     }
 
-#ato_header_closed {
+#ato_header_closed:not(.smartpocket) {
   left:10px;
   font-size:20px;
@@ -121,7 +123,15 @@
   height:35px;
 }
-  #ato_header_closed a {
+  #ato_header_closed:not(.smartpocket) a {
     padding:4px;
   }
+#ato_header_closed.smartpocket {
+  float:left;
+  margin-right:10px;
+}
+  #ato_header_closed.smartpocket .ui-btn-inner {
+    display:none;
+  }
+
 #ato_header_root a.close-panel {
   padding:6px 1px 4px 5px;
