includes/clientside/sbedit.js
author Dan
Wed, 13 Aug 2008 08:47:20 -0400
changeset 690 aeac05b5b7ca
parent 407 35d94240a197
child 885 a86a69394a95
permissions -rw-r--r--
Fixed ACL_TYPE_PRESET pseudo-rules being shown in rule list
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
var disenable_currentBlock;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
function ajaxDisenableBlock(id)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
  disenable_currentBlock = document.getElementById('disabled_'+id);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     5
  ajaxGet(makeUrlNS('Special', 'EditSidebar', 'action=disenable&ajax=true&noheaders&id='+id), function()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
    {
407
35d94240a197 Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents: 365
diff changeset
     7
      if ( ajax.readyState == 4 && ajax.status == 200 )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     8
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     9
        if(ajax.responseText == 'GOOD')
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
        {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
          if(disenable_currentBlock.style.display == 'none')
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
          {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    13
            disenable_currentBlock.style.display = 'inline';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    14
          }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    15
          else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    16
          {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    17
            disenable_currentBlock.style.display = 'none';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    18
          }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    19
        } 
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    20
        else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    21
        {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    22
          document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    23
        }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    24
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    25
    });
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    26
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    27
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    28
var delete_currentBlock;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    29
function ajaxDeleteBlock(id, oElm)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    30
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    31
  delete_currentBlock = { 0 : id, 1 : oElm };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    32
  ajaxGet(makeUrlNS('Special', 'EditSidebar', 'action=delete&ajax=true&noheaders&id='+id), function()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    33
    {
407
35d94240a197 Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents: 365
diff changeset
    34
      if ( ajax.readyState == 4 && ajax.status == 200 )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    35
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    36
        if(ajax.responseText == 'GOOD')
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    37
        {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    38
          e = delete_currentBlock[1];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    39
          e = e.parentNode.parentNode;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    40
          e.parentNode.removeChild(e);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    41
        } 
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    42
        else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    43
        {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    44
          document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    45
        }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    46
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    47
    });
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    48
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    49
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    50
var blockEdit_current;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    51
function ajaxEditBlock(id, oElm)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    52
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    53
  blockEdit_current = { 0 : id, 1 : oElm };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    54
  ajaxGet(makeUrlNS('Special', 'EditSidebar', 'action=getsource&noheaders&id='+id), function()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    55
    {
407
35d94240a197 Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents: 365
diff changeset
    56
      if ( ajax.readyState == 4 && ajax.status == 200 )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    57
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    58
        id = blockEdit_current[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    59
        oElm = blockEdit_current[1];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    60
        var thediv = document.createElement('div');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    61
        //if(!oElm.id) oElm.id = 'autoEditButton_'+Math.floor(Math.random() * 100000);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    62
        oElm = oElm.parentNode;
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 1
diff changeset
    63
        var magic = $(oElm).Top() + $(oElm).Height();
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 1
diff changeset
    64
        var top = String(magic);
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 1
diff changeset
    65
        top = top + 'px';
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 1
diff changeset
    66
        left = $(oElm).Left() + 'px';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    67
        thediv.style.top = top;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    68
        thediv.style.left = left;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    69
        thediv.style.position = 'absolute';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    70
        thediv.className = 'mdg-comment';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    71
        thediv.style.margin = '0';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    72
        if(ajax.responseText == 'HOUSTON_WE_HAVE_A_PLUGIN')
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    73
        {
365
cc6bf4d63684 Localized Special:EditSidebar
Dan
parents: 202
diff changeset
    74
          thediv.innerHTML = '<h3>' + $lang.get('sbedit_msg_cant_edit_plugin_title') + '</h3><p>' + $lang.get('sbedit_msg_cant_edit_plugin_body', { close_link: 'a href="#" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); return false;"' }) + '</p>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    75
        }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    76
        else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    77
        {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    78
          ta = document.createElement('textarea');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    79
          ta.rows = '15';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    80
          ta.cols = '50';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    81
          ta.innerHTML = ajax.responseText;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    82
          thediv.appendChild(ta);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    83
          b = document.createElement('br');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    84
          thediv.appendChild(b);
365
cc6bf4d63684 Localized Special:EditSidebar
Dan
parents: 202
diff changeset
    85
          thediv.innerHTML += '<a href="#" onclick="ajaxSaveBlock(this, \''+id+'\'); return false;">' + $lang.get('sbedit_btn_edit_save') + '</a>  |  <a href="#" onclick="if(confirm(\'' + $lang.get('sbedit_msg_discard_confirm') + '\')) this.parentNode.parentNode.removeChild(this.parentNode); return false;">' + $lang.get('sbedit_btn_edit_cancel') + '</a>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    86
        }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    87
        body = document.getElementsByTagName('body');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    88
        body = body[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    89
        body.appendChild(thediv);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    90
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    91
    });
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    92
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    93
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    94
var blockSave_current;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    95
function ajaxSaveBlock(oElm, id)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    96
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    97
  taContent = escape(oElm.previousSibling.previousSibling.value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    98
  taContent = taContent.replace(unescape('%0A'), '%0A');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    99
  taContent = taContent.replace('+', '%2B');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   100
  blockSave_current = { 0 : id, 1 : oElm };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   101
  ajaxPost(makeUrlNS('Special', 'EditSidebar', 'noheaders&action=save&id='+id), 'content='+taContent, function()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   102
    {
407
35d94240a197 Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents: 365
diff changeset
   103
      if ( ajax.readyState == 4 && ajax.status == 200 )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   104
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   105
        id   = blockSave_current[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   106
        oElm = blockSave_current[1];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   107
        eval(ajax.responseText);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   108
        if(status == 'GOOD')
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   109
        {
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 1
diff changeset
   110
          var _id = 'disabled_' + String(id);
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 1
diff changeset
   111
          var parent = document.getElementById(_id).parentNode.parentNode;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   112
          oElm.parentNode.parentNode.removeChild(oElm.parentNode);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   113
          content = content.replace('%a', unescape('%0A'));
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 1
diff changeset
   114
          var obj = ( IE ) ? parent.firstChild.nextSibling.nextSibling : parent.firstChild.nextSibling.nextSibling.nextSibling;
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 1
diff changeset
   115
          if ( obj )
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 1
diff changeset
   116
            obj.innerHTML = content; // $content is set in ajax.responseText
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   117
        }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   118
        else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   119
        {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   120
          alert(status);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   121
        }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   122
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   123
    });
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   124
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   125
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   126
function ajaxRenameSidebarStage1(parent, id)
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   127
{
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   128
  var oldname = parent.firstChild.nodeValue;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   129
  parent.removeChild(parent.firstChild);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   130
  parent.ondblclick = function() {};
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   131
  parent._idcache = id;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   132
  var input = document.createElement('input');
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   133
  input.type = 'text';
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   134
  input.sbedit_id = id;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   135
  input.oldvalue = oldname;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   136
  input.onkeyup = function(e)
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   137
  {
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   138
    if ( typeof(e) != 'object' )
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   139
      return false;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   140
    if ( !e.keyCode )
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   141
      return false;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   142
    if ( e.keyCode == 13 )
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   143
    {
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   144
      ajaxRenameSidebarStage2(this);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   145
    }
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   146
    if ( e.keyCode == 27 )
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   147
    {
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   148
      ajaxRenameSidebarCancel(this);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   149
    }
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   150
  };
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   151
  input.onblur = function()
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   152
  {
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   153
    ajaxRenameSidebarCancel(this);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   154
  };
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   155
  input.value = oldname;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   156
  input.style.fontSize = '7pt';
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   157
  parent.appendChild(input);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   158
  input.focus();
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   159
}
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   160
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   161
function ajaxRenameSidebarStage2(input)
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   162
{
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   163
  var newname = input.value;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   164
  var id = input.sbedit_id;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   165
  var parent = input.parentNode;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   166
  parent.removeChild(input);
202
88d7a7c2743c Nothing special at all. Unnamed sidebar blocks will show the text <Unnamed> instead of just showing nothing, thus making them renamable
Dan
parents: 190
diff changeset
   167
  parent.appendChild(document.createTextNode(( newname == '' ? '<Unnamed>' : newname )));
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   168
  parent.ondblclick = function() { ajaxRenameSidebarStage1(this, this._idcache); return false; };
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   169
  var img = document.createElement('img');
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   170
  img.src = scriptPath + '/images/loading.gif';
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   171
  parent.appendChild(img);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   172
  newname = ajaxEscape(newname);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   173
  ajaxPost(makeUrlNS('Special', 'EditSidebar', 'ajax&noheaders&action=rename&id='+id), 'newname=' +newname, function()
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   174
    {
407
35d94240a197 Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents: 365
diff changeset
   175
      if ( ajax.readyState == 4 && ajax.status == 200 )
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   176
      {
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   177
        parent.removeChild(img);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   178
        if ( ajax.responseText != 'GOOD' )
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   179
          new messagebox(MB_OK|MB_ICONSTOP, 'Error renaming block', ajax.responseText);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   180
      }
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   181
    });
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   182
}
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   183
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   184
function ajaxRenameSidebarCancel(input)
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   185
{
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   186
  var newname = input.oldvalue;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   187
  var id = input.sbedit_id;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   188
  var parent = input.parentNode;
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   189
  parent.removeChild(input);
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   190
  parent.appendChild(document.createTextNode(newname));
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   191
  parent.ondblclick = function() { ajaxRenameSidebarStage1(this, this._idcache); return false; };
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   192
}
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   193