includes/clientside/static/rank-manager.js
author Dan
Mon, 16 Jun 2008 19:07:15 -0400
changeset 577 5118610ce160
parent 563 0103428e2179
child 628 ab6f55abb17e
permissions -rw-r--r--
Made template parser remember last initted page_id and namespace to avoid double init; made additional_headers reassign only do so if $template->additional_headers is empty (it's being blanked somehow, need to come up with a backtrace sometime)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
563
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
     1
/**
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
     2
 * Creates a control that can be used to edit a rank.
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
     3
 */
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
     4
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
     5
var RankEditorControl = function(rankdata)
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
     6
{
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
     7
  this.rankdata = rankdata;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
     8
  
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
     9
  // have the browser parse CSS for us and use an anchor to be as close
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    10
  // as possible in calculating CSS
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    11
  
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    12
  // this is kind of a hack as it relies on setAttribute/getAttribute in
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    13
  // order to obtain stringified versions of CSS data
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    14
  var cssobj = document.createElement('a');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    15
  cssobj.setAttribute('style', this.rankdata.rank_style);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    16
  
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    17
  this.style_sim_obj = cssobj;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    18
  
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    19
  // figure out if we're editing or creating
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    20
  this.editing = ( typeof(this.rankdata.rank_id) == 'number' );
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    21
  
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    22
  this.render = function()
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    23
  {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    24
    var editor = document.createElement('div');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    25
    editor.className = 'tblholder';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    26
    // stash this editor instance in the parent div for later function calls
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    27
    editor.editor = this;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    28
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    29
    // tables suck.
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    30
    var table = document.createElement('table');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    31
    table.setAttribute('cellspacing', '1');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    32
    table.setAttribute('cellpadding', '4');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    33
    table.setAttribute('width', '100%');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    34
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    35
    // heading: "Edit rank: foo" or "Create a new rank"
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    36
    var tr_head = document.createElement('tr');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    37
    var th_head = document.createElement('th');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    38
    th_head.setAttribute('colspan', '2');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    39
    if ( this.editing )
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    40
    {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    41
      var th_head_string = 'acpur_th_edit_rank';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    42
      var th_head_data = { rank_title: $lang.get(this.rankdata.rank_title) };
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    43
    }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    44
    else
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    45
    {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    46
      var th_head_string = 'acpur_th_create_rank';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    47
      var th_head_data = { };
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    48
    }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    49
    th_head.appendChild(document.createTextNode($lang.get(th_head_string, th_head_data)));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    50
    tr_head.appendChild(th_head);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    51
    table.appendChild(tr_head);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    52
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    53
    // row: rank title
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    54
    var tr_title = document.createElement('tr');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    55
    var td_title_l = document.createElement('td');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    56
    var td_title_f = document.createElement('td');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    57
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    58
    td_title_l.className = td_title_f.className = 'row1';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    59
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    60
    td_title_l.appendChild(document.createTextNode($lang.get('acpur_field_rank_title')));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    61
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    62
    // field: rank title
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    63
    var f_rank_title = document.createElement('input');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    64
    f_rank_title.type = 'text';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    65
    f_rank_title.size = '30';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    66
    f_rank_title.value = ( this.editing ) ? this.rankdata.rank_title : '';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    67
    this.f_rank_title = f_rank_title;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    68
    td_title_f.appendChild(f_rank_title);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    69
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    70
    tr_title.appendChild(td_title_l);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    71
    tr_title.appendChild(td_title_f);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    72
    table.appendChild(tr_title);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    73
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    74
    // row: basic style options
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    75
    var tr_basic = document.createElement('tr');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    76
    var td_basic_l = document.createElement('td');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    77
    var td_basic_f = document.createElement('td');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    78
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    79
    td_basic_l.className = td_basic_f.className = 'row2';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    80
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    81
    td_basic_l.appendChild(document.createTextNode($lang.get('acpur_field_style_basic')));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    82
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    83
    // fieldset: basic style options
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    84
    // field: bold
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    85
    var l_basic_bold = document.createElement('label');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    86
    var f_basic_bold = document.createElement('input');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    87
    f_basic_bold.type = 'checkbox';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    88
    f_basic_bold.checked = ( this.style_sim_obj.style.fontWeight == 'bold' ) ? true : false;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    89
    f_basic_bold.editor = this;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    90
    f_basic_bold.onclick = function()
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    91
    {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    92
      this.editor.style_sim_obj.style.fontWeight = ( this.checked ) ? 'bold' : null;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    93
    }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    94
    l_basic_bold.style.fontWeight = 'bold';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    95
    l_basic_bold.appendChild(f_basic_bold);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    96
    l_basic_bold.appendChild(document.createTextNode(' '));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    97
    l_basic_bold.appendChild(document.createTextNode($lang.get('acpur_field_style_basic_bold')));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    98
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
    99
    // field: italic
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   100
    var l_basic_italic = document.createElement('label');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   101
    var f_basic_italic = document.createElement('input');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   102
    f_basic_italic.type = 'checkbox';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   103
    f_basic_italic.checked = ( this.style_sim_obj.style.fontStyle == 'italic' ) ? true : false;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   104
    f_basic_italic.editor = this;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   105
    f_basic_italic.onclick = function()
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   106
    {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   107
      this.editor.style_sim_obj.style.fontStyle = ( this.checked ) ? 'italic' : null;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   108
    }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   109
    l_basic_italic.style.fontStyle = 'italic';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   110
    l_basic_italic.appendChild(f_basic_italic);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   111
    l_basic_italic.appendChild(document.createTextNode(' '));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   112
    l_basic_italic.appendChild(document.createTextNode($lang.get('acpur_field_style_basic_italic')));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   113
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   114
    // field: underline
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   115
    var l_basic_underline = document.createElement('label');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   116
    var f_basic_underline = document.createElement('input');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   117
    f_basic_underline.type = 'checkbox';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   118
    f_basic_underline.checked = ( this.style_sim_obj.style.textDecoration == 'underline' ) ? true : false;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   119
    f_basic_underline.editor = this;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   120
    f_basic_underline.onclick = function()
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   121
    {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   122
      this.editor.style_sim_obj.style.textDecoration = ( this.checked ) ? 'underline' : null;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   123
    }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   124
    l_basic_underline.style.textDecoration = 'underline';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   125
    l_basic_underline.appendChild(f_basic_underline);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   126
    l_basic_underline.appendChild(document.createTextNode(' '));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   127
    l_basic_underline.appendChild(document.createTextNode($lang.get('acpur_field_style_basic_underline')));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   128
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   129
    // finish up formatting row#1
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   130
    td_basic_f.appendChild(l_basic_bold);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   131
    td_basic_f.appendChild(document.createTextNode(' '));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   132
    td_basic_f.appendChild(l_basic_italic);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   133
    td_basic_f.appendChild(document.createTextNode(' '));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   134
    td_basic_f.appendChild(l_basic_underline);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   135
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   136
    tr_basic.appendChild(td_basic_l);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   137
    tr_basic.appendChild(td_basic_f);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   138
    table.appendChild(tr_basic);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   139
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   140
    // row: rank color
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   141
    var tr_color = document.createElement('tr');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   142
    var td_color_l = document.createElement('td');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   143
    var td_color_f = document.createElement('td');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   144
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   145
    td_color_l.className = td_color_f.className = 'row1';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   146
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   147
    td_color_l.appendChild(document.createTextNode($lang.get('acpur_field_style_color')));
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   148
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   149
    // field: rank color
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   150
    var f_rank_color = document.createElement('input');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   151
    f_rank_color.type = 'text';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   152
    f_rank_color.size = '7';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   153
    f_rank_color.value = ( this.editing ) ? this.rgb2hex(this.style_sim_obj.style.color) : '';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   154
    f_rank_color.style.backgroundColor = this.style_sim_obj.style.color;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   155
    this.f_rank_color = f_rank_color;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   156
    f_rank_color.onkeyup = function(e)
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   157
    {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   158
      if ( !e.keyCode )
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   159
        e = window.event;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   160
      if ( !e )
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   161
        return false;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   162
      var chr = (String.fromCharCode(e.keyCode)).toLowerCase();
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   163
      this.value = this.value.replace(/[^a-fA-F0-9]/g, '');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   164
      if ( this.value.length > 6 )
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   165
      {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   166
        this.value = this.value.substr(0, 6);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   167
      }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   168
      if ( this.value.length == 6 || this.value.length == 3 )
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   169
      {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   170
        this.style.backgroundColor = '#' + this.value;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   171
      }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   172
    }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   173
    td_color_f.appendChild(f_rank_color);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   174
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   175
    tr_color.appendChild(td_color_l);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   176
    tr_color.appendChild(td_color_f);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   177
    table.appendChild(tr_color);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   178
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   179
    // finalize the editor table
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   180
    editor.appendChild(table);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   181
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   182
    // stash rendered editor
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   183
    this.editordiv = editor;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   184
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   185
    // send output
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   186
    return editor;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   187
  }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   188
  
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   189
  this.getJSONDataset = function()
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   190
  {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   191
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   192
  }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   193
  
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   194
  this.getCSS = function()
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   195
  {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   196
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   197
  }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   198
  
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   199
  /**
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   200
   * Converts a parenthetical color specification (rgb(x, y, z)) to hex form (xxyyzz)
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   201
   * @param string
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   202
   * @return string
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   203
   */
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   204
  
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   205
  this.rgb2hex = function(rgb)
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   206
  {
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   207
    var p = rgb.match(/^rgb\(([0-9]+), ([0-9]+), ([0-9]+)\)$/);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   208
    if ( !p )
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   209
      return rgb.replace(/^#/, '');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   210
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   211
    var r = parseInt(p[1]).toString(16), g = parseInt(p[2]).toString(16), b = parseInt(p[3]).toString(16);
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   212
    if ( r.length < 2 )
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   213
      r = '0' + r;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   214
    if ( g.length < 2 )
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   215
      g = '0' + g;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   216
    if ( b.length < 2 )
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   217
      b = '0' + b;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   218
    
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   219
    return r + g + b;
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   220
  }
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   221
}
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   222
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   223
/**
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   224
 * Perform request for editable rank data and draw editor
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   225
 */
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   226
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   227
function ajaxInitRankEdit(rank_id)
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   228
{
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   229
  var editor = new RankEditorControl({ rank_title: 'Foo', rank_id: rank_id, rank_style: 'color: #ff0000; font-weight: bold;' });
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   230
  var ren
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   231
  var container = document.getElementById('admin_ranks_container_right');
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   232
  container.innerHTML = '';
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   233
  container.appendChild(editor.render());
0103428e2179 First test of rank manager interface, not currently capable of doing anything interesting (fills form with placeholder data); strings are in an earlier commit
Dan
parents:
diff changeset
   234
}