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
{
628
+ − 7
this.rankdata = ( typeof(rankdata) == 'object' ) ? rankdata : {};
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 8
if ( !this.rankdata.rank_style )
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 9
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 10
this.rankdata.rank_style = '';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 11
}
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
+ − 12
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
// 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
+ − 14
// 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
+ − 15
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
// 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
+ − 17
// 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
+ − 18
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
+ − 19
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
+ − 20
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
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
+ − 22
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
// 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
+ − 24
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
+ − 25
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
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
+ − 27
{
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
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
+ − 29
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
+ − 30
// 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
+ − 31
editor.editor = this;
628
+ − 32
this.wrapperdiv = editor;
+ − 33
editor.style.width = '100%';
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
+ − 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
// 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
+ − 36
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
+ − 37
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
+ − 38
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
+ − 39
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
+ − 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
// 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
+ − 42
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
+ − 43
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
+ − 44
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
+ − 45
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
+ − 46
{
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_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
+ − 48
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
+ − 49
}
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
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
+ − 51
{
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
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
+ − 53
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
+ − 54
}
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
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
+ − 56
tr_head.appendChild(th_head);
628
+ − 57
this.th_head = th_head;
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
+ − 58
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
+ − 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
// 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
+ − 61
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
+ − 62
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
+ − 63
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
+ − 64
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
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
+ − 66
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
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
+ − 68
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
// 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
+ − 70
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
+ − 71
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
+ − 72
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
+ − 73
f_rank_title.value = ( this.editing ) ? this.rankdata.rank_title : '';
628
+ − 74
f_rank_title.editor = this;
+ − 75
f_rank_title.onkeyup = function()
+ − 76
{
+ − 77
this.editor.renderPreview();
+ − 78
}
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
+ − 79
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
+ − 80
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
+ − 81
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
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
+ − 83
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
+ − 84
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
+ − 85
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
// 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
+ − 87
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
+ − 88
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
+ − 89
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
+ − 90
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
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
+ − 92
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
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
+ − 94
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
// 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
+ − 96
// 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
+ − 97
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
+ − 98
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
+ − 99
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
+ − 100
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
+ − 101
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
+ − 102
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
+ − 103
{
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
this.editor.style_sim_obj.style.fontWeight = ( this.checked ) ? 'bold' : null;
628
+ − 105
this.editor.renderPreview();
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
+ − 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
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
+ − 108
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
+ − 109
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
+ − 110
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
+ − 111
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
// 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
+ − 113
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
+ − 114
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
+ − 115
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
+ − 116
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
+ − 117
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
+ − 118
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
+ − 119
{
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
this.editor.style_sim_obj.style.fontStyle = ( this.checked ) ? 'italic' : null;
628
+ − 121
this.editor.renderPreview();
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
+ − 122
}
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
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
+ − 124
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
+ − 125
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
+ − 126
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
+ − 127
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
// 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
+ − 129
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
+ − 130
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
+ − 131
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
+ − 132
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
+ − 133
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
+ − 134
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
+ − 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
this.editor.style_sim_obj.style.textDecoration = ( this.checked ) ? 'underline' : null;
628
+ − 137
this.editor.renderPreview();
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
+ − 138
}
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
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
+ − 140
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
+ − 141
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
+ − 142
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
+ − 143
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
// 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
+ − 145
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
+ − 146
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
+ − 147
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
+ − 148
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
+ − 149
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
+ − 150
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
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
+ − 152
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
+ − 153
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
+ − 154
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
// 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
+ − 156
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
+ − 157
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
+ − 158
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
+ − 159
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
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
+ − 161
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
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
+ − 163
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
// 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
+ − 165
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
+ − 166
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
+ − 167
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
+ − 168
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
+ − 169
f_rank_color.style.backgroundColor = this.style_sim_obj.style.color;
628
+ − 170
f_rank_color.editor = this;
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
+ − 171
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
+ − 172
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
+ − 173
{
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
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
+ − 175
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
+ − 176
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
+ − 177
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
+ − 178
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
+ − 179
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
+ − 180
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
+ − 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
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
+ − 183
}
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
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
+ − 185
{
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
this.style.backgroundColor = '#' + this.value;
628
+ − 187
this.editor.style_sim_obj.style.color = '#' + this.value;
+ − 188
this.style.color = '#' + this.editor.determineLightness(this.value);
+ − 189
this.editor.renderPreview();
+ − 190
}
+ − 191
else if ( this.value.length == 0 )
+ − 192
{
+ − 193
this.style.backgroundColor = null;
+ − 194
this.editor.style_sim_obj.style.color = null;
+ − 195
this.editor.renderPreview();
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
+ − 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
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
+ − 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
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
+ − 201
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
+ − 202
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
+ − 203
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 204
// field: additional CSS
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 205
var tr_css = document.createElement('tr');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 206
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 207
var td_css_l = document.createElement('td');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 208
td_css_l.className = 'row2';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 209
td_css_l.appendChild(document.createTextNode($lang.get('acpur_field_style_css')));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 210
tr_css.appendChild(td_css_l);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 211
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 212
var td_css_f = document.createElement('td');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 213
td_css_f.className = 'row2';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 214
var f_css = document.createElement('input');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 215
f_css.type = 'text';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 216
f_css.value = this.stripBasicCSSAttributes(this.rankdata.rank_style);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 217
f_css.style.width = '98%';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 218
f_css.editor = this;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 219
f_css.onkeyup = function()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 220
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 221
if ( !(trim(this.value)).match(/^((([a-z-]+):(.+?);)+)?$/) )
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 222
return;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 223
var newcss = this.editor.stripExtendedCSSAttributes(String(this.editor.style_sim_obj.getAttribute('style'))) + ' ' + this.value;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 224
this.editor.preview_div.setAttribute('style', 'font-size: x-large; ' + newcss);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 225
this.editor.style_sim_obj.setAttribute('style', newcss);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 226
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 227
this.f_css = f_css;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 228
td_css_f.appendChild(f_css);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 229
tr_css.appendChild(td_css_f);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 230
table.appendChild(tr_css);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 231
628
+ − 232
// "field": preview
+ − 233
var tr_preview = document.createElement('tr');
+ − 234
var td_preview_l = document.createElement('td');
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 235
td_preview_l.className = 'row1';
628
+ − 236
td_preview_l.appendChild(document.createTextNode($lang.get('acpur_field_preview')));
+ − 237
tr_preview.appendChild(td_preview_l);
+ − 238
+ − 239
var td_preview_f = document.createElement('td');
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 240
td_preview_f.className = 'row1';
628
+ − 241
var div_preview = document.createElement('a');
+ − 242
this.preview_div = div_preview;
+ − 243
div_preview.style.fontSize = 'x-large';
+ − 244
div_preview.appendChild(document.createTextNode(''));
+ − 245
div_preview.firstChild.nodeValue = ( this.editing ) ? this.rankdata.rank_title : '';
+ − 246
td_preview_f.appendChild(div_preview);
+ − 247
tr_preview.appendChild(td_preview_f);
+ − 248
+ − 249
table.appendChild(tr_preview);
+ − 250
+ − 251
// submit button
+ − 252
var tr_submit = document.createElement('tr');
+ − 253
var th_submit = document.createElement('th');
+ − 254
th_submit.className = 'subhead';
+ − 255
th_submit.setAttribute('colspan', '2');
+ − 256
var btn_submit = document.createElement('input');
+ − 257
btn_submit.type = 'submit';
+ − 258
btn_submit.value = ( this.editing ) ? $lang.get('acpur_btn_save') : $lang.get('acpur_btn_create_submit');
+ − 259
btn_submit.editor = this;
+ − 260
btn_submit.style.fontWeight = 'bold';
+ − 261
btn_submit.onclick = function(e)
+ − 262
{
+ − 263
this.editor.submitEvent(e);
+ − 264
}
+ − 265
this.btn_submit = btn_submit;
+ − 266
th_submit.appendChild(btn_submit);
+ − 267
+ − 268
// delete button
+ − 269
if ( this.editing )
+ − 270
{
+ − 271
var btn_delete = document.createElement('input');
+ − 272
btn_delete.type = 'button';
+ − 273
btn_delete.value = $lang.get('acpur_btn_delete');
+ − 274
btn_delete.editor = this;
+ − 275
btn_delete.onclick = function(e)
+ − 276
{
+ − 277
this.editor.deleteEvent(e);
+ − 278
}
+ − 279
th_submit.appendChild(document.createTextNode(' '));
+ − 280
th_submit.appendChild(btn_delete);
+ − 281
}
+ − 282
+ − 283
tr_submit.appendChild(th_submit);
+ − 284
+ − 285
table.appendChild(tr_submit);
+ − 286
+ − 287
// render preview
+ − 288
this.renderPreview();
+ − 289
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
+ − 290
// 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
+ − 291
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
+ − 292
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
+ − 293
// 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
+ − 294
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
+ − 295
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
+ − 296
// 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
+ − 297
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
+ − 298
}
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
+ − 299
628
+ − 300
/**
+ − 301
* Takes the existing editor div and transforms the necessary elements so that it goes from "create" mode to "edit" mode
+ − 302
* @param object Edit data - same format as the rankdata parameter to the constructor, but we should only need rank_id
+ − 303
*/
+ − 304
+ − 305
this.transformToEditor = function(rankdata)
+ − 306
{
+ − 307
// we need a rank ID
+ − 308
if ( typeof(rankdata.rank_id) != 'number' )
+ − 309
return false;
+ − 310
+ − 311
if ( this.editing )
+ − 312
return false;
+ − 313
+ − 314
this.editing = true;
+ − 315
+ − 316
this.rankdata = rankdata;
+ − 317
this.rankdata.rank_title = this.f_rank_title.value;
+ − 318
this.rankdata.rank_style = this.getCSS();
+ − 319
+ − 320
// transform various controls
+ − 321
this.th_head.firstChild.nodeValue = $lang.get('acpur_th_edit_rank', {
+ − 322
rank_title: $lang.get(this.rankdata.rank_title)
+ − 323
});
+ − 324
this.btn_submit.value = $lang.get('acpur_btn_save');
+ − 325
+ − 326
// add the delete button
+ − 327
var th_submit = this.btn_submit.parentNode;
+ − 328
+ − 329
var btn_delete = document.createElement('input');
+ − 330
btn_delete.type = 'button';
+ − 331
btn_delete.value = $lang.get('acpur_btn_delete');
+ − 332
btn_delete.editor = this;
+ − 333
btn_delete.onclick = function(e)
+ − 334
{
+ − 335
this.editor.deleteEvent(e);
+ − 336
}
+ − 337
th_submit.appendChild(document.createTextNode(' '));
+ − 338
th_submit.appendChild(btn_delete);
+ − 339
+ − 340
return true;
+ − 341
}
+ − 342
+ − 343
/**
+ − 344
* Takes a hex color, averages the three channels, and returns either 'ffffff' or '000000' depending on the luminosity of the color.
+ − 345
* @param string
+ − 346
* @return string
+ − 347
*/
+ − 348
+ − 349
this.determineLightness = function(hexval)
+ − 350
{
+ − 351
var rgb = this.hex2rgb(hexval);
+ − 352
var lumin = ( rgb[0] + rgb[1] + rgb[2] ) / 3;
+ − 353
return ( lumin > 60 ) ? '000000' : 'ffffff';
+ − 354
}
+ − 355
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 356
/**
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 357
* Strips out basic CSS attributes (color, font-weight, font-style, text-decoration) from a snippet of CSS.
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 358
* @param string
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 359
* @return string
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 360
*/
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 361
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 362
this.stripBasicCSSAttributes = function(css)
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
+ − 363
{
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 364
return trim(css.replace(/(color|font-weight|font-style|text-decoration): ?([A-z0-9# ,\(\)]+);/g, ''));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 365
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 366
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 367
/**
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 368
* Strips out all but basic CSS attributes.
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 369
* @param string
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 370
* @return string
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 371
*/
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 372
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 373
this.stripExtendedCSSAttributes = function(css)
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 374
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 375
var match;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 376
var final_css = '';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 377
var basics = ['color', 'font-weight', 'font-style', 'text-decoration'];
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 378
while ( match = css.match(/([a-z-]+):(.+?);/) )
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 379
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 380
if ( in_array(match[1], basics) )
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 381
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 382
final_css += ' ' + match[0] + ' ';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 383
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 384
css = css.replace(match[0], '');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 385
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 386
final_css = trim(final_css);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 387
return final_css;
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
+ − 388
}
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
+ − 389
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
+ − 390
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
+ − 391
{
628
+ − 392
return this.style_sim_obj.getAttribute('style');
+ − 393
}
+ − 394
+ − 395
this.renderPreview = function()
+ − 396
{
+ − 397
if ( !this.preview_div )
+ − 398
return false;
+ − 399
var color = ( this.style_sim_obj.style.color ) ? '#' + this.rgb2hex(this.style_sim_obj.style.color) : null;
+ − 400
this.preview_div.style.color = color;
+ − 401
this.preview_div.style.fontWeight = this.style_sim_obj.style.fontWeight;
+ − 402
this.preview_div.style.fontStyle = this.style_sim_obj.style.fontStyle;
+ − 403
this.preview_div.style.textDecoration = this.style_sim_obj.style.textDecoration;
+ − 404
this.preview_div.firstChild.nodeValue = $lang.get(this.f_rank_title.value);
+ − 405
}
+ − 406
+ − 407
this.submitEvent = function(e)
+ − 408
{
+ − 409
if ( this.onsubmit )
+ − 410
{
+ − 411
this.onsubmit(e);
+ − 412
}
+ − 413
else
+ − 414
{
+ − 415
window.console.error('RankEditorControl: no onsubmit event specified');
+ − 416
}
+ − 417
}
+ − 418
+ − 419
this.deleteEvent = function(e)
+ − 420
{
+ − 421
if ( this.ondelete )
+ − 422
{
+ − 423
this.ondelete(e);
+ − 424
}
+ − 425
else
+ − 426
{
+ − 427
window.console.error('RankEditorControl: no ondelete event specified');
+ − 428
}
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
+ − 429
}
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
+ − 430
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
+ − 431
/**
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
+ − 432
* 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
+ − 433
* @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
+ − 434
* @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
+ − 435
*/
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
+ − 436
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
+ − 437
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
+ − 438
{
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
+ − 439
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
+ − 440
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
+ − 441
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
+ − 442
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
+ − 443
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
+ − 444
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
+ − 445
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
+ − 446
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
+ − 447
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
+ − 448
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
+ − 449
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
+ − 450
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
+ − 451
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
+ − 452
}
628
+ − 453
+ − 454
/**
+ − 455
* Get red, green, and blue values for the given hex color
+ − 456
* @param string
+ − 457
* @return array (numbered, e.g. not an object
+ − 458
*/
+ − 459
+ − 460
this.hex2rgb = function(hex)
+ − 461
{
+ − 462
hex = hex.replace(/^#/, '');
+ − 463
if ( hex.length != 3 && hex.length != 6 )
+ − 464
{
+ − 465
return hex;
+ − 466
}
+ − 467
if ( hex.length == 3 )
+ − 468
{
+ − 469
// is there a better way to do this?
+ − 470
hex = hex.charAt(0) + hex.charAt(0) + hex.charAt(1) + hex.charAt(1) + hex.charAt(2) + hex.charAt(2);
+ − 471
}
+ − 472
hex = [ hex.substr(0, 2), hex.substr(2, 2), hex.substr(4, 2) ];
+ − 473
var red = parseInt(hex[0], 16);
+ − 474
var green = parseInt(hex[1], 16);
+ − 475
var blue = parseInt(hex[2], 16);
+ − 476
return [red, green, blue];
+ − 477
}
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
+ − 478
}
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
+ − 479
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
+ − 480
/**
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
+ − 481
* 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
+ − 482
*/
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
+ − 483
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
+ − 484
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
+ − 485
{
628
+ − 486
load_component('messagebox');
+ − 487
var json_packet = {
+ − 488
mode: 'get_rank',
+ − 489
rank_id: rank_id
+ − 490
};
+ − 491
json_packet = ajaxEscape(toJSONString(json_packet));
+ − 492
ajaxPost(makeUrlNS('Admin', 'UserRanks/action.json'), 'r=' + json_packet, function()
+ − 493
{
+ − 494
if ( ajax.readyState == 4 && ajax.status == 200 )
+ − 495
{
+ − 496
var response = String(ajax.responseText + '');
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 497
if ( !check_json_response(response) )
628
+ − 498
{
+ − 499
handle_invalid_json(ajax.responseText);
+ − 500
return false;
+ − 501
}
+ − 502
try
+ − 503
{
+ − 504
var response = parseJSON(ajax.responseText);
+ − 505
}
+ − 506
catch(e)
+ − 507
{
+ − 508
handle_invalid_json(ajax.responseText);
+ − 509
}
+ − 510
var editor = new RankEditorControl(response);
+ − 511
editor.onsubmit = ajaxRankEditHandleSaveExisting;
+ − 512
editor.ondelete = ajaxRankEditHandleDelete;
+ − 513
var container = document.getElementById('admin_ranks_container_right');
+ − 514
container.innerHTML = '';
+ − 515
container.appendChild(editor.render());
+ − 516
}
+ − 517
}, true);
+ − 518
}
+ − 519
+ − 520
function ajaxInitRankCreate()
+ − 521
{
+ − 522
load_component('messagebox');
+ − 523
var editor = new RankEditorControl();
+ − 524
editor.onsubmit = ajaxRankEditHandleSaveNew;
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
+ − 525
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
+ − 526
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
+ − 527
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
+ − 528
}
628
+ − 529
+ − 530
function ajaxRankEditHandleSave(editor, switch_new)
+ − 531
{
+ − 532
var whitey = whiteOutElement(editor.wrapperdiv);
+ − 533
+ − 534
// pack it up, ...
+ − 535
var json_packet = {
+ − 536
mode: ( switch_new ) ? 'create_rank' : 'save_rank',
+ − 537
rank_title: editor.f_rank_title.value,
+ − 538
rank_style: editor.getCSS()
+ − 539
}
+ − 540
if ( !switch_new )
+ − 541
{
+ − 542
json_packet.rank_id = editor.rankdata.rank_id;
+ − 543
}
+ − 544
/// ... pack it in
+ − 545
var json_packet = ajaxEscape(toJSONString(json_packet));
+ − 546
+ − 547
ajaxPost(makeUrlNS('Admin', 'UserRanks/action.json'), 'r=' + json_packet, function()
+ − 548
{
+ − 549
if ( ajax.readyState == 4 && ajax.status == 200 )
+ − 550
{
+ − 551
var response = String(ajax.responseText + '');
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 552
if ( !check_json_response(response) )
628
+ − 553
{
+ − 554
handle_invalid_json(ajax.responseText);
+ − 555
return false;
+ − 556
}
+ − 557
try
+ − 558
{
+ − 559
var response = parseJSON(ajax.responseText);
+ − 560
}
+ − 561
catch(e)
+ − 562
{
+ − 563
handle_invalid_json(ajax.responseText);
+ − 564
}
+ − 565
if ( response.mode == 'success' )
+ − 566
{
+ − 567
whiteOutReportSuccess(whitey);
+ − 568
if ( switch_new )
+ − 569
{
+ − 570
//
+ − 571
// we have a few more things to do with a newly created rank.
+ − 572
//
+ − 573
+ − 574
// 1. transform editor
+ − 575
editor.transformToEditor(response);
+ − 576
editor.onsubmit = ajaxRankEditHandleSaveExisting;
+ − 577
editor.ondelete = ajaxRankEditHandleDelete;
+ − 578
+ − 579
// 2. append the new rank to the list
+ − 580
var create_link = document.getElementById('rankadmin_createlink');
+ − 581
if ( create_link )
+ − 582
{
+ − 583
var parent = create_link.parentNode;
+ − 584
var edit_link = document.createElement('a');
+ − 585
edit_link.href = '#rank_edit:' + response.rank_id;
+ − 586
edit_link.className = 'rankadmin-editlink';
+ − 587
edit_link.setAttribute('style', editor.getCSS());
+ − 588
edit_link.id = 'rankadmin_editlink_' + response.rank_id;
+ − 589
edit_link.rank_id = response.rank_id;
+ − 590
edit_link.appendChild(document.createTextNode($lang.get(editor.f_rank_title.value)));
+ − 591
parent.insertBefore(edit_link, create_link);
+ − 592
edit_link.onclick = function()
+ − 593
{
+ − 594
ajaxInitRankEdit(this.rank_id);
+ − 595
}
+ − 596
}
+ − 597
}
+ − 598
else
+ − 599
{
+ − 600
// update the rank title on the left
+ − 601
var edit_link = document.getElementById('rankadmin_editlink_' + editor.rankdata.rank_id);
+ − 602
if ( edit_link )
+ − 603
{
+ − 604
edit_link.firstChild.nodeValue = $lang.get(editor.f_rank_title.value);
+ − 605
edit_link.setAttribute('style', editor.getCSS());
+ − 606
}
+ − 607
}
+ − 608
}
+ − 609
else
+ − 610
{
+ − 611
whitey.parentNode.removeChild(whitey);
+ − 612
miniPromptMessage({
+ − 613
title: $lang.get('acpur_err_save_failed_title'),
+ − 614
message: response.error,
+ − 615
buttons: [
+ − 616
{
+ − 617
text: $lang.get('etc_ok'),
+ − 618
color: 'red',
+ − 619
style: {
+ − 620
fontWeight: 'bold'
+ − 621
},
+ − 622
onclick: function()
+ − 623
{
+ − 624
miniPromptDestroy(this);
+ − 625
}
+ − 626
}
+ − 627
]
+ − 628
});
+ − 629
}
+ − 630
}
+ − 631
}, true);
+ − 632
}
+ − 633
+ − 634
var ajaxRankEditHandleSaveExisting = function()
+ − 635
{
+ − 636
ajaxRankEditHandleSave(this, false);
+ − 637
}
+ − 638
+ − 639
var ajaxRankEditHandleSaveNew = function()
+ − 640
{
+ − 641
ajaxRankEditHandleSave(this, true);
+ − 642
}
+ − 643
+ − 644
var ajaxRankEditHandleDelete = function()
+ − 645
{
+ − 646
var mp = miniPromptMessage({
+ − 647
title: $lang.get('acpur_msg_rank_delete_confirm_title'),
+ − 648
message: $lang.get('acpur_msg_rank_delete_confirm_body'),
+ − 649
buttons: [
+ − 650
{
+ − 651
text: $lang.get('acpur_btn_delete'),
+ − 652
color: 'red',
+ − 653
style: {
+ − 654
fontWeight: 'bold'
+ − 655
},
+ − 656
onclick: function()
+ − 657
{
+ − 658
var parent = miniPromptGetParent(this);
+ − 659
var editor = parent.editor;
+ − 660
setTimeout(function()
+ − 661
{
+ − 662
ajaxRankEditDeleteConfirmed(editor);
+ − 663
}, 1000);
+ − 664
miniPromptDestroy(parent);
+ − 665
}
+ − 666
},
+ − 667
{
+ − 668
text: $lang.get('etc_cancel'),
+ − 669
onclick: function()
+ − 670
{
+ − 671
miniPromptDestroy(this);
+ − 672
}
+ − 673
}
+ − 674
]
+ − 675
});
+ − 676
console.debug(mp);
+ − 677
mp.editor = this;
+ − 678
}
+ − 679
+ − 680
function ajaxRankEditDeleteConfirmed(editor)
+ − 681
{
+ − 682
var whitey = whiteOutElement(editor.wrapperdiv);
+ − 683
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 684
load_component('jquery');
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 685
load_component('jquery-ui');
628
+ − 686
+ − 687
var json_packet = {
+ − 688
mode: 'delete_rank',
+ − 689
rank_id: editor.rankdata.rank_id
+ − 690
};
+ − 691
var rank_id = editor.rankdata.rank_id;
+ − 692
+ − 693
json_packet = ajaxEscape(toJSONString(json_packet));
+ − 694
ajaxPost(makeUrlNS('Admin', 'UserRanks/action.json'), 'r=' + json_packet, function()
+ − 695
{
+ − 696
if ( ajax.readyState == 4 && ajax.status == 200 )
+ − 697
{
+ − 698
var response = String(ajax.responseText + '');
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 699
if ( !check_json_response(response) )
628
+ − 700
{
+ − 701
handle_invalid_json(ajax.responseText);
+ − 702
return false;
+ − 703
}
+ − 704
try
+ − 705
{
+ − 706
var response = parseJSON(ajax.responseText);
+ − 707
}
+ − 708
catch(e)
+ − 709
{
+ − 710
handle_invalid_json(ajax.responseText);
+ − 711
}
+ − 712
if ( response.mode == 'success' )
+ − 713
{
+ − 714
// the deletion was successful, report success and kill off the editor
+ − 715
whiteOutReportSuccess(whitey);
+ − 716
setTimeout(function()
+ − 717
{
+ − 718
// nuke the rank title on the left
+ − 719
var edit_link = document.getElementById('rankadmin_editlink_' + editor.rankdata.rank_id);
+ − 720
if ( edit_link )
+ − 721
{
+ − 722
edit_link.parentNode.removeChild(edit_link);
+ − 723
}
+ − 724
// collapse and destroy the editor
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 725
$(editor.wrapperdiv).hide("blind", {}, 500, function()
628
+ − 726
{
+ − 727
// when the animation finishes, nuke the whole thing
+ − 728
var container = document.getElementById('admin_ranks_container_right');
+ − 729
container.innerHTML = $lang.get('acpur_msg_select_rank');
+ − 730
}
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 731
);
628
+ − 732
}, 1500);
+ − 733
}
+ − 734
else
+ − 735
{
+ − 736
whitey.parentNode.removeChild(whitey);
+ − 737
miniPromptMessage({
+ − 738
title: $lang.get('acpur_err_delete_failed_title'),
+ − 739
message: response.error,
+ − 740
buttons: [
+ − 741
{
+ − 742
text: $lang.get('etc_ok'),
+ − 743
color: 'red',
+ − 744
style: {
+ − 745
fontWeight: 'bold'
+ − 746
},
+ − 747
onclick: function()
+ − 748
{
+ − 749
miniPromptDestroy(this);
+ − 750
}
+ − 751
}
+ − 752
]
+ − 753
});
+ − 754
}
+ − 755
}
+ − 756
}, true);
+ − 757
}