includes/clientside/sbedit.js
author Dan
Fri, 15 May 2009 20:06:27 -0400
changeset 991 1ad055d689fc
parent 943 6eab82abc952
child 1039 4226cedb3bc4
permissions -rw-r--r--
Detagged 1.1.6 release - upgrader bug found
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
     1
addOnloadHook(function()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
     2
  {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
     3
    load_component(['jquery', 'jquery-ui']);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
     4
    $('.sbedit-column').sortable({
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
     5
      handle: '.sbedit-handle',
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
     6
      connectWith: '.sbedit-column',
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
     7
      stop: function()
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     8
      {
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
     9
        ajaxUpdateSidebarOrder();
1
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
    });
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    12
  });
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    13
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    14
function serialize_sidebar()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    15
{
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    16
  var columns = {};
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    17
  var i = 0;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    18
  $('.sbedit-column').each(function(i, e)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    19
    {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    20
      var arr = $(e).sortable('toArray');
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    21
      for ( var j = 0; j < arr.length; j++ )
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    22
        arr[j] = parseInt(arr[j].replace(/^block:/, ''));
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    23
      
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    24
      i++;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    25
      columns[i] = arr;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    26
    });
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    27
  return toJSONString(columns);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    28
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    29
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    30
function sbedit_open_editor(a)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    31
{
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    32
  if ( auth_level < USER_LEVEL_ADMIN )
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    33
  {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    34
    load_component('login');
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    35
    ajaxDynamicReauth(function(sid)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    36
      {
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    37
        sbedit_open_editor(a);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    38
      }, USER_LEVEL_ADMIN);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    39
    return false;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    40
  }
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    41
  load_component(['fadefilter', 'l10n']);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    42
  var shade = darken(true, 50, 'sbedit-shade');
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    43
  $(shade).css('z-index', 0);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    44
  var parent = sbedit_get_parent(a);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    45
  var offset = $(parent).offset();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    46
  var top = (( getHeight() ) / 2) - 200 + getScrollOffset();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    47
  var box = $(parent)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    48
    .clone()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    49
    .empty()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    50
    .attr('id', 'sb_blockedit')
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    51
    .addClass('sbedit-float')
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    52
    .css('height', $(parent).height())
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    53
    .css('top', offset.top)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    54
    .css('left', offset.left)
943
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    55
    .appendTo('body');
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    56
  var item_id = parseInt($(parent).attr('id').replace(/^block:/, ''));
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    57
  
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    58
  $(box)
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    59
    .animate({ width: 500, height: 400, top: top, left: (getWidth() / 2) - 250 }, 400, function()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    60
      {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    61
        var whitey = whiteOutElement(this);
943
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    62
        $(this).append('<textarea style="width: 98%; height: 360px; margin: 0 auto; display: block;" rows="20" cols="80"></textarea>');
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    63
        $(this).append('<p style="text-align: center;"><a href="#" onclick="sbedit_edit_save(this); return false;">' + $lang.get('etc_save_changes') + '</a> | <a href="#" onclick="sbedit_edit_cancel(this); return false;">' + $lang.get('etc_cancel') + '</a></p>');
943
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    64
        $.get(makeUrlNS('Special', 'EditSidebar', 'action=getsource&noheaders&id=' + item_id), {}, function(response, statustext)
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    65
          {
943
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    66
            $('textarea', box).val(response);
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    67
            $(whitey).remove();
943
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    68
            
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    69
            $(box).attr('enano:item_id', item_id);
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    70
          }, 'html');
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    71
      })
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    72
    .get(0);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    73
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    74
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    75
function sbedit_edit_save(a)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    76
{
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    77
  var box = a.parentNode.parentNode;
943
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    78
  var parent = document.getElementById('block:' + $(box).attr('enano:item_id'));
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    79
  var whitey = whiteOutElement(box);
943
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    80
  $.post(makeUrlNS('Special', 'EditSidebar', 'noheaders&action=save&id=' + $(box).attr('enano:item_id')), { content: $('textarea', box).attr('value') }, function(response, statustext)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    81
    {
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    82
      whiteOutReportSuccess(whitey);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    83
      setTimeout(function()
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    84
        {
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    85
          sbedit_close_editor(parent, box);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    86
        }, 1250);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    87
    }, 'html');
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    88
}
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    89
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    90
function sbedit_edit_cancel(a)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    91
{
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    92
  var box = a.parentNode.parentNode;
943
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
    93
  var parent = document.getElementById('block:' + $(box).attr('enano:item_id'));
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    94
  
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    95
  sbedit_close_editor(parent, box);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    96
}
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    97
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    98
function sbedit_close_editor(parent, box)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
    99
{
943
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   100
  if ( !parent )
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   101
  {
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   102
    console.warn('Failed to get DOM object for parent, skipping transition effect');
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   103
  }
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   104
  
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   105
  if ( jQuery.fx.off || !parent )
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   106
  {
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   107
    enlighten(true, 'sbedit-shade');
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   108
    $('body').get(0).removeChild(box);
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   109
    return true;
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   110
  }
6eab82abc952 Fixed sidebar editor not closing floating windows properly when FX off
Dan
parents: 886
diff changeset
   111
  
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   112
  var offset = $(parent).offset();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   113
  $(box).empty().animate(
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   114
    {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   115
      width:  $(parent).width(),
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   116
      height: $(parent).height(),
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   117
      top:    offset.top,
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   118
      left:   offset.left,
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   119
    }, 400, function()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   120
    {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   121
      $(this).css('background-color', '#f70').fadeOut(1000, function() { $(this).remove(); });
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   122
      enlighten(true, 'sbedit-shade');
1
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
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   126
function sbedit_delete_block(a)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   127
{
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   128
  var parent = sbedit_get_parent(a);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   129
  load_component(['messagebox', 'fadefilter', 'flyin', 'l10n']);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   130
  var mp = miniPromptMessage({
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   131
      title: $lang.get('sbedit_msg_delete_confirm_title'),
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   132
      message: $lang.get('sbedit_msg_delete_confirm_body'),
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   133
      buttons: [
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   134
        {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   135
          text: $lang.get('sbedit_btn_delete_confirm'),
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   136
          color: 'red',
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   137
          onclick: function()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   138
          {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   139
            var mp = miniPromptGetParent(this);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   140
            sbedit_delete_block_s2(mp.target_block);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   141
            miniPromptDestroy(this);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   142
            return false;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   143
          },
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   144
          style: {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   145
            fontWeight: 'bold'
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   146
          }
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   147
        },
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   148
        {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   149
          text: $lang.get('etc_cancel'),
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   150
          onclick: function()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   151
          {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   152
            miniPromptDestroy(this);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   153
            return false;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   154
          }
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   155
        }
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   156
      ]
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   157
    });
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   158
  mp.target_block = parent;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   159
}
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   160
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   161
function sbedit_delete_block_s2(box)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   162
{
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   163
  var parent = box;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   164
  var id = parseInt($(parent).attr('id').replace(/^block:/, ''));
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   165
  var whitey = whiteOutElement(parent);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   166
  
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   167
  $.get(makeUrlNS('Special', 'EditSidebar', 'action=delete&ajax=true&noheaders&id=' + id), function(response, statustext)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   168
    {
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   169
      if ( response == 'GOOD' )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   170
      {
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   171
        whiteOutReportSuccess(whitey);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   172
        setTimeout(function()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   173
          {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   174
            $(parent)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   175
            .hide('blind', { duration: 500 }, function()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   176
              {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   177
                $(this).remove();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   178
                ajaxUpdateSidebarOrder();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   179
              });
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   180
          }, 1250);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   181
      }
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   182
      else
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   183
      {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   184
        whiteOutReportFailure(whitey);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   185
        alert(response);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   186
      }
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   187
    }, 'html');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   188
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   189
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   190
function sbedit_rename_block(a)
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   191
{
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   192
  var parent = sbedit_get_parent(a);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   193
  $('div.sbedit-handle > span', parent).hide();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   194
  var input = $('div.sbedit-handle > input', parent).show().focus().select().keyup(function(e)
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   195
    {
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   196
      switch(e.keyCode)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   197
      {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   198
        case 13:
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   199
          // enter
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   200
          var whitey = whiteOutElement(this.parentNode);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   201
          var me = this;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   202
          var id = parseInt($(parent).attr('id').replace(/^block:/, ''));
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   203
          $.post(makeUrlNS('Special', 'EditSidebar', 'ajax&noheaders&action=rename&id='+id), { newname: $(this).attr('value') }, function(response, statustext)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   204
            {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   205
              if ( response == 'GOOD' )
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   206
              {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   207
                whiteOutReportSuccess(whitey);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   208
                setTimeout(function()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   209
                  {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   210
                    $(me).hide();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   211
                    $('span', me.parentNode).show().text(me.value);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   212
                  }, 1250);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   213
              }
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   214
              else
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   215
              {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   216
                alert(response);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   217
                whiteOutReportFailure(whitey);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   218
              }
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   219
            }, 'html');
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   220
          break;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   221
        case 27:
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   222
          // escape
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   223
          this.value = this.origvalue;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   224
          $(this).hide();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   225
          $('span', this.parentNode).show();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   226
          break;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   227
      }
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   228
    }).get(0);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   229
  input.origvalue = input.value;
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   230
}
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   231
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   232
function sbedit_disenable_block(a)
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   233
{
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   234
  var parent = sbedit_get_parent(a);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   235
  var whitey = whiteOutElement(parent);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   236
  $.get(makeUrlNS('Special', 'EditSidebar', 'action=disenable&ajax=true&noheaders&id=' + parseInt($(parent).attr('id').replace(/^block:/, ''))), {}, function(response, statustext)
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   237
    {
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   238
      if ( response == 'GOOD' )
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   239
      {
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   240
        whiteOutReportSuccess(whitey);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   241
        $(parent).toggleClass('disabled');
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   242
      }
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   243
      else
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   244
      {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   245
        whiteOutReportFailure(whitey);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   246
        alert(response);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   247
      }
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   248
    }, 'html');
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   249
}
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   250
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   251
function sbedit_get_parent(a)
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   252
{
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   253
  var o = a.parentNode;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   254
  while ( !$(o).hasClass('sbedit-block') )
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   255
    o = o.parentNode;
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   256
  
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   257
  return o;
190
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   258
}
e858bacb5cfa Sidebar blocks can be renamed now (untested except in Fx2)
Dan
parents: 80
diff changeset
   259
885
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   260
function ajaxUpdateSidebarOrder()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   261
{
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   262
  setAjaxLoading();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   263
  var ser = serialize_sidebar();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   264
  $.post(makeUrlNS('Special', 'EditSidebar', 'update_order'), { order: ser }, function(response, statustext)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   265
    {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   266
      var msg = document.createElement('div');
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   267
      $(msg)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   268
        .addClass('info-box-mini')
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   269
        .text('Sidebar order saved.')
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   270
        .css('position', 'fixed')
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   271
        .css('bottom', 1)
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   272
        .appendTo('body')
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   273
        .css('left', ( getWidth() / 2 ) - ( $(msg).width() / 2 ));
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   274
      setTimeout(function()
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   275
        {
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   276
          $(msg).fadeOut(500, function() { $(this).remove(); });
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   277
        }, 1000);
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   278
      unsetAjaxLoading();
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   279
    }, 'json');
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   280
}
a86a69394a95 Major revamp to sidebar editor. Some behavioral changes as well as being based on jQuery UI Sortables. Creation interface remains the same, but better strings merged in from stable.
Dan
parents: 407
diff changeset
   281