includes/clientside/static/theme-manager.js
author Dan
Sat, 08 Nov 2008 22:35:05 -0500
changeset 724 af6a618e5c94
parent 699 c7d737202d59
child 823 4596c40aaa94
permissions -rw-r--r--
Fixed plugin manager not checking for plugin file existence before marking to load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
     1
function ajaxToggleSystemThemes()
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
     2
{
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
     3
  var theme_list = document.getElementById('theme_list_edit');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
     4
  var mode = ( theme_list.sys_shown ) ? 'hide' : 'show';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
     5
  for ( var i = 0; i < theme_list.childNodes.length; i++ )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
     6
  {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
     7
    var child = theme_list.childNodes[i];
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
     8
    if ( child.tagName == 'DIV' )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
     9
    {
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 658
diff changeset
    10
      if ( $dynano(child).hasClass('themebutton_theme_system') )
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    11
      {
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 658
diff changeset
    12
        if ( $dynano(child).hasClass('themebutton_theme_disabled') )
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    13
        {
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 658
diff changeset
    14
          $dynano(child).rmClass('themebutton_theme_disabled')
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    15
        }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    16
        if ( mode == 'show' )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    17
        {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    18
          domObjChangeOpac(0, child);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    19
          child.style.display = 'block';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    20
          domOpacity(child, 0, 100, 1000);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    21
        }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    22
        else
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    23
        {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    24
          domOpacity(child, 100, 0, 1000);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    25
          setTimeout("document.getElementById('" + child.id + "').style.display = 'none';", 1050);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    26
        }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    27
      }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    28
    }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    29
  }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    30
  theme_list.sys_shown = ( mode == 'show' );
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    31
  document.getElementById('systheme_toggler').innerHTML = ( mode == 'hide' ) ? $lang.get('acptm_btn_system_themes_show') : $lang.get('acptm_btn_system_themes_hide');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    32
}
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    33
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    34
function ajaxInstallTheme(theme_id)
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    35
{
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    36
  var thediv = document.getElementById('themebtn_install_' + theme_id);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    37
  if ( !thediv )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    38
    return false;
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    39
  thediv.removeChild(thediv.getElementsByTagName('a')[0]);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    40
  var status = document.createElement('div');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    41
  status.className = 'status';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    42
  thediv.appendChild(status);
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    43
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    44
  var req = toJSONString({
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    45
      mode: 'install',
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    46
      theme_id: theme_id
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    47
    });
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    48
  // we've finished nukeing the existing interface, request editor data
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    49
  ajaxPost(makeUrlNS('Admin', 'ThemeManager/action.json'), 'r=' + ajaxEscape(req), function()
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    50
    {
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    51
      if ( ajax.readyState == 4 && ajax.status == 200 )
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    52
      {
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    53
        var response = String(ajax.responseText + '');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    54
        if ( response.substr(0, 1) == '{' )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    55
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    56
          response = parseJSON(response);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    57
          if ( response.mode == 'error' )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    58
          {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    59
            alert(response.error);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    60
            return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    61
          }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    62
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    63
        
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    64
        var theme_list = document.getElementById('theme_list_edit');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    65
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    66
        var btn = document.createElement('div');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    67
        btn.className = 'themebutton';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    68
        btn.style.backgroundImage = thediv.style.backgroundImage;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    69
        btn.id = 'themebtn_edit_' + theme_id;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    70
        
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    71
        var a = document.createElement('a');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    72
        a.className = 'tb-inner';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    73
        a.appendChild(document.createTextNode($lang.get('acptm_btn_theme_edit')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    74
        a.appendChild(document.createTextNode("\n"));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    75
        a.theme_id = theme_id;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    76
        a.onclick = function()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    77
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    78
          ajaxEditTheme(this.theme_id);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    79
          return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    80
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    81
        a.href = '#';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    82
        var span = document.createElement('span');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    83
        span.className = 'themename';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    84
        span.appendChild(document.createTextNode(thediv.getAttribute('enano:themename')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    85
        a.appendChild(span);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    86
        btn.appendChild(a);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    87
        btn.setAttribute('enano:themename', thediv.getAttribute('enano:themename'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    88
        theme_list.appendChild(btn);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    89
        
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    90
        thediv.parentNode.removeChild(thediv);
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    91
      }
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
    92
    });
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    93
}
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    94
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    95
function ajaxEditTheme(theme_id)
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    96
{
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    97
  // Fade out and subsequently destroy the entire list, then make an
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    98
  // ajax request to the theme manager for the theme info via JSON
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
    99
  var theme_list = document.getElementById('theme_list_edit').parentNode;
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   100
  var backgroundImage = document.getElementById('themebtn_edit_' + theme_id).style.backgroundImage;
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   101
  /*
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   102
  for ( var i = 0; i < theme_list.childNodes.length; i++ )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   103
  {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   104
    var el = theme_list.childNodes[i];
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   105
    if ( el.tagName )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   106
      domOpacity(el, 100, 0, 1000);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   107
  }
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   108
  */
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   109
  var thediv = document.getElementById('themebtn_edit_' + theme_id);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   110
  if ( !thediv )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   111
    return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   112
  thediv.removeChild(thediv.getElementsByTagName('a')[0]);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   113
  var status = document.createElement('div');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   114
  status.className = 'status';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   115
  thediv.appendChild(status);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   116
  
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   117
  setTimeout(function()
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   118
    {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   119
      var req = toJSONString({
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   120
          mode: 'fetch_theme',
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   121
          theme_id: theme_id
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   122
        });
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   123
      // we've finished nukeing the existing interface, request editor data
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   124
      ajaxPost(makeUrlNS('Admin', 'ThemeManager/action.json'), 'r=' + ajaxEscape(req), function()
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   125
        {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   126
          if ( ajax.readyState == 4 && ajax.status == 200 )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   127
          {
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   128
            theme_list.innerHTML = '';
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   129
            var response = String(ajax.responseText + '');
651
ce9d78d7251d Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents: 465
diff changeset
   130
            if ( !check_json_response(response) )
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   131
            {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   132
              alert(response);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   133
              return false;
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   134
            }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   135
            response = parseJSON(response);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   136
            if ( response.mode == 'error' )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   137
            {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   138
              alert(response.error);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   139
              return false;
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   140
            }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   141
            response.background_image = backgroundImage;
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   142
            ajaxBuildThemeEditor(response, theme_list);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   143
          }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   144
        });
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   145
    }, 200);
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   146
}
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   147
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   148
function ajaxBuildThemeEditor(data, target)
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   149
{
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   150
  // Build the theme editor interface
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   151
  // Init opacity
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   152
  domObjChangeOpac(0, target);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   153
  
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   154
  // Theme preview
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   155
  var preview = document.createElement('div');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   156
  preview.style.border = '1px solid #F0F0F0';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   157
  preview.style.padding = '5px';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   158
  preview.style.width = '216px';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   159
  preview.style.height = '150px';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   160
  preview.style.backgroundImage = data.background_image;
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   161
  preview.style.backgroundRepeat = 'no-repeat';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   162
  preview.style.backgroundPosition = 'center center';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   163
  preview.style.cssFloat = 'right';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   164
  preview.style.styleFloat = 'right';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   165
  
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   166
  target.appendChild(preview);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   167
  
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   168
  // Heading
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   169
  var h3 = document.createElement('h3');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   170
  h3.appendChild(document.createTextNode($lang.get('acptm_heading_theme_edit', { theme_name: data.theme_name })));
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   171
  target.appendChild(h3);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   172
  
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   173
  // Field: Theme name
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   174
  var l_name = document.createElement('label');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   175
  l_name.appendChild(document.createTextNode($lang.get('acptm_field_theme_name') + ' '));
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   176
  var f_name = document.createElement('input');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   177
  f_name.type = 'text';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   178
  f_name.id = 'themeed_field_name';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   179
  f_name.value = data.theme_name;
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   180
  f_name.size = '40';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   181
  l_name.appendChild(f_name);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   182
  target.appendChild(l_name);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   183
  
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   184
  target.appendChild(document.createElement('br'));
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   185
  target.appendChild(document.createElement('br'));
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   186
  
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   187
  // Field: default style
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   188
  var l_style = document.createElement('label');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   189
  l_style.appendChild(document.createTextNode($lang.get('acptm_field_default_style') + ' '));
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   190
  var f_style = document.createElement('select');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   191
  f_style.id = 'themeed_field_style';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   192
  var opts = [];
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   193
  for ( var i = 0; i < data.css.length; i++ )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   194
  {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   195
    if ( data.css[i] == '_printable' )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   196
      continue;
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   197
    
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   198
    opts[i] = document.createElement('option');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   199
    opts[i].value = data.css[i];
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   200
    opts[i].appendChild(document.createTextNode(data.css[i]));
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   201
    if ( data.default_style == data.css[i] )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   202
    {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   203
      opts[i].selected = true;
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   204
    }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   205
    f_style.appendChild(opts[i]);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   206
  }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   207
  l_style.appendChild(f_style);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   208
  target.appendChild(l_style);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   209
  
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   210
  target.appendChild(document.createElement('br'));
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   211
  target.appendChild(document.createElement('br'));
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   212
  
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   213
  // Default theme
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   214
  target.appendChild(document.createTextNode($lang.get('acptm_field_default_theme') + ' '));
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   215
  if ( data.is_default )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   216
  {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   217
    var l_default = document.createElement('b');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   218
    l_default.appendChild(document.createTextNode($lang.get('acptm_field_default_msg_current')));
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   219
  }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   220
  else
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   221
  {
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   222
    var l_default = document.createElement('label');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   223
    var f_default = document.createElement('input');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   224
    f_default.type = 'checkbox';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   225
    f_default.id = 'themeed_field_default';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   226
    l_default.appendChild(f_default);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   227
    l_default.appendChild(document.createTextNode($lang.get('acptm_field_default_btn_make_default')));
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   228
  }
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   229
  target.appendChild(l_default);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   230
  
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   231
  target.appendChild(document.createElement('br'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   232
  target.appendChild(document.createElement('br'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   233
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   234
  // Disable theme
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   235
  var disable_span = document.createElement('span');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   236
  disable_span.appendChild(document.createTextNode($lang.get('acptm_field_disable_title') + ' '));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   237
  target.appendChild(disable_span);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   238
  var l_disable = document.createElement('label');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   239
  var f_disable = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   240
  f_disable.type = 'checkbox';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   241
  f_disable.id = 'themeed_field_disable';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   242
  if ( !data.enabled )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   243
    f_disable.setAttribute('checked', 'checked');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   244
  l_disable.style.fontWeight = 'bold';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   245
  l_disable.appendChild(f_disable);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   246
  l_disable.appendChild(document.createTextNode($lang.get('acptm_field_disable')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   247
  target.appendChild(l_disable);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   248
  
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   249
  // Availability policy
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   250
  var h3 = document.createElement('h3');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   251
  h3.appendChild(document.createTextNode($lang.get('acptm_heading_theme_groups')));
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   252
  target.appendChild(h3);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   253
  
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   254
  // Label for the whole field
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   255
  var p_d_policy = document.createElement('p');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   256
  p_d_policy.style.fontWeight = 'bold';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   257
  p_d_policy.appendChild(document.createTextNode($lang.get('acptm_field_policy')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   258
  target.appendChild(p_d_policy);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   259
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   260
  // Wrapper for options
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   261
  var p_f_policy = document.createElement('p');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   262
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   263
  // Option: allow all
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   264
  var l_policy_allow_all = document.createElement('label');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   265
  var f_policy_allow_all = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   266
  f_policy_allow_all.type = 'radio';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   267
  f_policy_allow_all.id = 'themeed_field_policy_allow_all';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   268
  f_policy_allow_all.name = 'themeed_field_policy';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   269
  f_policy_allow_all.value = 'allow_all';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   270
  l_policy_allow_all.appendChild(f_policy_allow_all);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   271
  l_policy_allow_all.appendChild(document.createTextNode(' ' + $lang.get('acptm_field_policy_allow_all')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   272
  if ( data.group_policy == 'allow_all' )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   273
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   274
    f_policy_allow_all.setAttribute('checked', 'checked');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   275
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   276
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   277
  // Option: whitelist
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   278
  var l_policy_whitelist = document.createElement('label');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   279
  var f_policy_whitelist = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   280
  f_policy_whitelist.type = 'radio';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   281
  f_policy_whitelist.id = 'themeed_field_policy_whitelist';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   282
  f_policy_whitelist.name = 'themeed_field_policy';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   283
  f_policy_whitelist.value = 'whitelist';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   284
  l_policy_whitelist.appendChild(f_policy_whitelist);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   285
  l_policy_whitelist.appendChild(document.createTextNode(' ' + $lang.get('acptm_field_policy_whitelist')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   286
  if ( data.group_policy == 'whitelist' )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   287
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   288
    f_policy_whitelist.setAttribute('checked', 'checked');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   289
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   290
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   291
  // Option: blacklist
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   292
  var l_policy_blacklist = document.createElement('label');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   293
  var f_policy_blacklist = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   294
  f_policy_blacklist.type = 'radio';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   295
  f_policy_blacklist.id = 'themeed_field_policy_blacklist';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   296
  f_policy_blacklist.name = 'themeed_field_policy';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   297
  f_policy_blacklist.value = 'blacklist';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   298
  l_policy_blacklist.appendChild(f_policy_blacklist);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   299
  l_policy_blacklist.appendChild(document.createTextNode(' ' + $lang.get('acptm_field_policy_blacklist')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   300
  if ( data.group_policy == 'blacklist' )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   301
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   302
    f_policy_blacklist.setAttribute('checked', 'checked');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   303
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   304
  f_policy_allow_all.onclick = ajaxThemeManagerHandlePolicyClick;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   305
  f_policy_whitelist.onclick = ajaxThemeManagerHandlePolicyClick;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   306
  f_policy_blacklist.onclick = ajaxThemeManagerHandlePolicyClick;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   307
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   308
  p_f_policy.appendChild(l_policy_allow_all);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   309
  p_f_policy.appendChild(document.createElement('br'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   310
  p_f_policy.appendChild(l_policy_whitelist);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   311
  p_f_policy.appendChild(document.createElement('br'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   312
  p_f_policy.appendChild(l_policy_blacklist);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   313
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   314
  target.appendChild(p_d_policy);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   315
  target.appendChild(p_f_policy);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   316
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   317
  var div_acl = document.createElement('div');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   318
  div_acl.id = 'themeed_acl_box';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   319
  div_acl.style.margin = '0 0 10px 30px';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   320
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   321
  var h3_g = document.createElement('h3');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   322
  h3_g.appendChild(document.createTextNode($lang.get('acptm_field_acl_heading_groups')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   323
  div_acl.appendChild(h3_g);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   324
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   325
  var div_groups = document.createElement('div');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   326
  div_groups.style.border = '1px solid #E8E8E8';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   327
  div_groups.id = 'themeed_group_list';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   328
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   329
  // Group list
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   330
  for ( var i in data.group_names )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   331
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   332
    var g_name = data.group_names[i];
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   333
    var check = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   334
    check.type = 'checkbox';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   335
    if ( in_array("g:" + i, data.group_list) )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   336
    {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   337
      check.setAttribute('checked', 'checked');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   338
    }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   339
    check.group_id = parseInt(i);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   340
    var lbl_g_acl = document.createElement('label');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   341
    lbl_g_acl.appendChild(check);
658
49dee7f374bf Fixed non-localized group names in theme-manager
Dan
parents: 651
diff changeset
   342
    var str = 'groupcp_grp_' + g_name.toLowerCase();
49dee7f374bf Fixed non-localized group names in theme-manager
Dan
parents: 651
diff changeset
   343
    var g_name_l10n = ( $lang.get(str) != str ) ? $lang.get(str) : g_name;
49dee7f374bf Fixed non-localized group names in theme-manager
Dan
parents: 651
diff changeset
   344
    lbl_g_acl.appendChild(document.createTextNode(g_name_l10n));
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   345
    div_groups.appendChild(lbl_g_acl);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   346
    div_groups.appendChild(document.createElement('br'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   347
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   348
  div_acl.appendChild(div_groups);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   349
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   350
  var h3_u = document.createElement('h3');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   351
  h3_u.appendChild(document.createTextNode($lang.get('acptm_field_acl_heading_users')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   352
  div_acl.appendChild(h3_u);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   353
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   354
  // User addition field
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   355
  var frm = document.createElement('form');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   356
  frm.action = 'javascript:ajaxThemeManagerHandleUserAdd();';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   357
  frm.appendChild(document.createTextNode($lang.get('acptm_field_acl_add_user')));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   358
  var f_useradd = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   359
  f_useradd.type = 'text';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   360
  f_useradd.id = 'themeed_field_adduser';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   361
  f_useradd.onkeyup = function(e)
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   362
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   363
    new AutofillUsername(this, e, false);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   364
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   365
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   366
  frm.appendChild(f_useradd);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   367
  div_acl.appendChild(frm);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   368
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   369
  div_acl.appendChild(document.createElement('br'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   370
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   371
  // User list
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   372
  var div_users = document.createElement('div');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   373
  div_users.style.border = '1px solid #E8E8E8';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   374
  div_users.style.padding = '4px';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   375
  div_users.id = 'themeed_user_list';
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   376
  for ( var i = 0; i < data.group_list.length; i++ )
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   377
  {
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   378
    var id = data.group_list[i];
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   379
    if ( id.substr(0, 2) != 'u:' )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   380
      continue;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   381
    var uid = id.substr(2);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   382
    var username = data.usernames[uid];
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   383
    
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   384
    var useritem = document.createElement('span');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   385
    useritem.appendChild(document.createTextNode(username + ' '));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   386
    useritem.userid = parseInt(uid);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   387
    var deleter = document.createElement('a');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   388
    deleter.href = '#';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   389
    deleter.onclick = function()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   390
    {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   391
      ajaxThemeManagerHandleUserRemoval(this);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   392
      return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   393
    }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   394
    deleter.appendChild(document.createTextNode('[X]'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   395
    useritem.appendChild(deleter);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   396
    div_users.appendChild(useritem);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   397
    div_users.appendChild(document.createElement('br'));
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   398
  }
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   399
  div_acl.appendChild(div_users);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   400
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   401
  target.appendChild(div_acl);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   402
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   403
  ajaxThemeManagerHandlePolicyClick();
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   404
  
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   405
  var clearer = document.createElement('span');
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   406
  clearer.className = 'menuclear';
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   407
  target.appendChild(clearer);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   408
  
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   409
  // Theme ID
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   410
  var tid = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   411
  tid.type = 'hidden';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   412
  tid.id = 'themeed_theme_id';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   413
  tid.value = data.theme_id;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   414
  target.appendChild(tid);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   415
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   416
  // Save button
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   417
  var raquo = unescape('%BB');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   418
  var savebtn = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   419
  savebtn.type = 'button';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   420
  savebtn.style.fontWeight = 'bold';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   421
  savebtn.value = $lang.get('etc_save_changes') + ' ' + raquo;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   422
  savebtn.onclick = function()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   423
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   424
    ajaxThemeManagerHandleSaveRequest();
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   425
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   426
  target.appendChild(savebtn);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   427
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   428
  target.appendChild(document.createTextNode(' '));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   429
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   430
  // Cancel button
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   431
  var savebtn = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   432
  savebtn.type = 'button';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   433
  savebtn.value = $lang.get('etc_cancel');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   434
  savebtn.onclick = function()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   435
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   436
    ajaxPage(namespace_list['Admin'] + 'ThemeManager');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   437
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   438
  target.appendChild(savebtn);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   439
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   440
  target.appendChild(document.createTextNode(' '));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   441
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   442
  // Uninstall button
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   443
  var savebtn = document.createElement('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   444
  savebtn.type = 'button';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   445
  savebtn.value = $lang.get('acptm_btn_uninstall_theme');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   446
  savebtn.style.color = '#D84308';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   447
  savebtn.onclick = function()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   448
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   449
    if ( !confirm($lang.get('acptm_msg_uninstall_confirm')) )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   450
      return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   451
    ajaxThemeManagerHandleUninstallClick();
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   452
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   453
  target.appendChild(savebtn);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   454
  
435
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   455
  // Fade it all in
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   456
  domOpacity(target, 0, 100, 500);
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   457
  f_name.focus();
a434d60e525d And might as well add theme-manager.js while I'm at it.
Dan
parents:
diff changeset
   458
}
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   459
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   460
function ajaxThemeManagerHandlePolicyClick()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   461
{
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   462
  if ( document.getElementById('themeed_field_policy_allow_all').checked )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   463
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   464
    document.getElementById('themeed_acl_box').style.display = 'none';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   465
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   466
  else if ( document.getElementById('themeed_field_policy_whitelist').checked || document.getElementById('themeed_field_policy_blacklist').checked )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   467
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   468
    document.getElementById('themeed_acl_box').style.display = 'block';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   469
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   470
}
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   471
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   472
function ajaxThemeManagerHandleUserAdd()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   473
{
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   474
  var f_useradd = document.getElementById('themeed_field_adduser');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   475
  f_useradd.setAttribute('disabled', 'disabled');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   476
  var parent = f_useradd.parentNode;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   477
  var img = document.createElement('img');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   478
  img.src = ajax_load_icon;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   479
  img.id = 'themeed_useradd_status';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   480
  img.style.marginLeft = '10px';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   481
  insertAfter(parent, img, f_useradd);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   482
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   483
  var req = toJSONString({
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   484
      mode: 'uid_lookup',
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   485
      username: f_useradd.value
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   486
    });
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   487
  ajaxPost(makeUrlNS('Admin', 'ThemeManager/action.json'), 'r=' + ajaxEscape(req), function()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   488
    {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   489
      if ( ajax.readyState == 4 && ajax.status == 200 )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   490
      {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   491
        var img = document.getElementById('themeed_useradd_status');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   492
        var f_useradd = document.getElementById('themeed_field_adduser');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   493
        
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   494
        f_useradd.disabled = null;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   495
        img.parentNode.removeChild(img);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   496
        
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   497
        // process response
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   498
        var response = String(ajax.responseText + '');
651
ce9d78d7251d Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents: 465
diff changeset
   499
        if ( !check_json_response(response) )
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   500
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   501
          alert(response);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   502
          return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   503
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   504
        response = parseJSON(response);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   505
        if ( response.mode == 'error' )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   506
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   507
          alert(response.error);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   508
          return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   509
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   510
            
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   511
        var uid = parseInt(response.uid);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   512
        var username = response.username;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   513
        
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   514
        // Loop through the list of users and remove any existing ones with the same uid
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   515
        var div_users = document.getElementById('themeed_user_list');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   516
        var children = div_users.getElementsByTagName('span');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   517
        for ( var i = 0; i < children.length; i++ )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   518
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   519
          var child = children[i];
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   520
          if ( child.userid == uid )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   521
          {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   522
            // the sister is the br element next to the span with the checkbox/text
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   523
            var sister = child.nextSibling;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   524
            div_users.removeChild(child);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   525
            div_users.removeChild(sister);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   526
            break;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   527
          }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   528
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   529
        
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   530
        var useritem = document.createElement('span');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   531
        useritem.appendChild(document.createTextNode(username + ' '));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   532
        useritem.userid = parseInt(uid);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   533
        var deleter = document.createElement('a');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   534
        deleter.href = '#';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   535
        deleter.onclick = function()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   536
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   537
          ajaxThemeManagerHandleUserRemoval(this);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   538
          return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   539
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   540
        deleter.appendChild(document.createTextNode('[X]'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   541
        useritem.appendChild(deleter);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   542
        div_users.appendChild(useritem);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   543
        div_users.appendChild(document.createElement('br'));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   544
      }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   545
    });
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   546
}
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   547
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   548
function ajaxThemeManagerHandleUserRemoval(el)
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   549
{
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   550
  var parent = el.parentNode;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   551
  var uid = parent.userid;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   552
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   553
  var grandparent = parent.parentNode;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   554
  var sister = parent.nextSibling;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   555
  grandparent.removeChild(parent);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   556
  grandparent.removeChild(sister);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   557
}
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   558
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   559
function ajaxThemeManagerHandleSaveRequest()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   560
{
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   561
  // Build a JSON condensed request
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   562
  var md = false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   563
  if ( document.getElementById('themeed_field_default') )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   564
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   565
    if ( document.getElementById('themeed_field_default').checked )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   566
    {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   567
      md = true;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   568
    }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   569
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   570
  var policy = 'allow_all';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   571
  if ( document.getElementById('themeed_field_policy_whitelist').checked )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   572
    policy = 'whitelist';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   573
  else if ( document.getElementById('themeed_field_policy_blacklist').checked )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   574
    policy = 'blacklist';
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   575
  var json_packet = {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   576
    theme_id: document.getElementById('themeed_theme_id').value,
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   577
    theme_name: document.getElementById('themeed_field_name').value,
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   578
    default_style: document.getElementById('themeed_field_style').value,
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   579
    make_default: md,
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   580
    group_policy: policy,
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   581
    enabled: ( document.getElementById('themeed_field_disable').checked ? false : true )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   582
  };
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   583
  var acl_list = [];
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   584
  var checks = document.getElementById('themeed_group_list').getElementsByTagName('input');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   585
  for ( var i = 0; i < checks.length; i++ )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   586
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   587
    if ( checks[i].checked )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   588
      acl_list.push('g:' + checks[i].group_id);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   589
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   590
  var spans = document.getElementById('themeed_user_list').getElementsByTagName('span');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   591
  for ( var i = 0; i < spans.length; i++ )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   592
  {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   593
    if ( spans[i].userid )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   594
      acl_list.push('u:' + spans[i].userid);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   595
  }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   596
  json_packet.group_list = acl_list;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   597
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   598
  var json_send = {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   599
    mode: 'save_theme',
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   600
    theme_data: json_packet
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   601
  };
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   602
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   603
  json_send = ajaxEscape(toJSONString(json_send));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   604
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   605
  // Request the save
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   606
  var parent = document.getElementById('ajaxPageContainer');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   607
  ajaxPost(makeUrlNS('Admin', 'ThemeManager/action.json'), 'r=' + json_send, function()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   608
    {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   609
      if ( ajax.readyState == 4 && ajax.status == 200 )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   610
      {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   611
        // process response
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   612
        var response = String(ajax.responseText + '');
651
ce9d78d7251d Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents: 465
diff changeset
   613
        if ( !check_json_response(response) )
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   614
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   615
          // For this we actually *expect* an HTML response.
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   616
          parent.innerHTML = response;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   617
          return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   618
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   619
        response = parseJSON(response);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   620
        if ( response.mode == 'error' )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   621
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   622
          alert(response.error);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   623
          return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   624
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   625
      }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   626
    });
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   627
}
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   628
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   629
function ajaxThemeManagerHandleUninstallClick()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   630
{
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   631
  var theme_id = document.getElementById('themeed_theme_id').value;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   632
  var json_send = {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   633
    mode: 'uninstall',
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   634
    theme_id: theme_id
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   635
  };
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   636
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   637
  json_send = ajaxEscape(toJSONString(json_send));
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   638
  
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   639
  // Request the action
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   640
  var parent = document.getElementById('ajaxPageContainer');
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   641
  ajaxPost(makeUrlNS('Admin', 'ThemeManager/action.json'), 'r=' + json_send, function()
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   642
    {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   643
      if ( ajax.readyState == 4 && ajax.status == 200 )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   644
      {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   645
        // process response
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   646
        var response = String(ajax.responseText + '');
651
ce9d78d7251d Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents: 465
diff changeset
   647
        if ( !check_json_response(response) )
465
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   648
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   649
          // For this we actually *expect* an HTML response.
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   650
          parent.innerHTML = response;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   651
          return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   652
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   653
        response = parseJSON(response);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   654
        if ( response.mode == 'error' )
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   655
        {
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   656
          alert(response.error);
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   657
          return false;
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   658
        }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   659
      }
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   660
    });
fe8b8c9b54e8 Finished theme manager to the point where it's in a working state in Firefox and hopefully IE.
Dan
parents: 435
diff changeset
   661
}