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));
823
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 492
ajaxPost(makeUrlNS('Admin', 'UserRanks/action.json'), 'r=' + json_packet, function(ajax)
628
+ − 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
}
794
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 510
if ( response.error )
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 511
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 512
if ( response.error == 'need_auth_to_admin' )
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 513
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 514
load_component('login');
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 515
var rid = rank_id;
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 516
ajaxDynamicReauth(function()
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 517
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 518
ajaxInitRankEdit(rid);
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 519
});
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 520
}
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 521
else
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 522
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 523
alert(response.error);
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 524
}
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 525
return false;
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 526
}
628
+ − 527
var editor = new RankEditorControl(response);
+ − 528
editor.onsubmit = ajaxRankEditHandleSaveExisting;
+ − 529
editor.ondelete = ajaxRankEditHandleDelete;
+ − 530
var container = document.getElementById('admin_ranks_container_right');
+ − 531
container.innerHTML = '';
+ − 532
container.appendChild(editor.render());
+ − 533
}
+ − 534
}, true);
+ − 535
}
+ − 536
+ − 537
function ajaxInitRankCreate()
+ − 538
{
+ − 539
load_component('messagebox');
+ − 540
var editor = new RankEditorControl();
+ − 541
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
+ − 542
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
+ − 543
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
+ − 544
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
+ − 545
}
628
+ − 546
+ − 547
function ajaxRankEditHandleSave(editor, switch_new)
+ − 548
{
+ − 549
var whitey = whiteOutElement(editor.wrapperdiv);
+ − 550
+ − 551
// pack it up, ...
+ − 552
var json_packet = {
+ − 553
mode: ( switch_new ) ? 'create_rank' : 'save_rank',
+ − 554
rank_title: editor.f_rank_title.value,
+ − 555
rank_style: editor.getCSS()
+ − 556
}
+ − 557
if ( !switch_new )
+ − 558
{
+ − 559
json_packet.rank_id = editor.rankdata.rank_id;
+ − 560
}
+ − 561
/// ... pack it in
+ − 562
var json_packet = ajaxEscape(toJSONString(json_packet));
+ − 563
823
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 564
ajaxPost(makeUrlNS('Admin', 'UserRanks/action.json'), 'r=' + json_packet, function(ajax)
628
+ − 565
{
+ − 566
if ( ajax.readyState == 4 && ajax.status == 200 )
+ − 567
{
+ − 568
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
+ − 569
if ( !check_json_response(response) )
628
+ − 570
{
+ − 571
handle_invalid_json(ajax.responseText);
+ − 572
return false;
+ − 573
}
+ − 574
try
+ − 575
{
+ − 576
var response = parseJSON(ajax.responseText);
+ − 577
}
+ − 578
catch(e)
+ − 579
{
+ − 580
handle_invalid_json(ajax.responseText);
+ − 581
}
+ − 582
if ( response.mode == 'success' )
+ − 583
{
+ − 584
whiteOutReportSuccess(whitey);
+ − 585
if ( switch_new )
+ − 586
{
+ − 587
//
+ − 588
// we have a few more things to do with a newly created rank.
+ − 589
//
+ − 590
+ − 591
// 1. transform editor
+ − 592
editor.transformToEditor(response);
+ − 593
editor.onsubmit = ajaxRankEditHandleSaveExisting;
+ − 594
editor.ondelete = ajaxRankEditHandleDelete;
+ − 595
+ − 596
// 2. append the new rank to the list
+ − 597
var create_link = document.getElementById('rankadmin_createlink');
+ − 598
if ( create_link )
+ − 599
{
+ − 600
var parent = create_link.parentNode;
+ − 601
var edit_link = document.createElement('a');
+ − 602
edit_link.href = '#rank_edit:' + response.rank_id;
+ − 603
edit_link.className = 'rankadmin-editlink';
+ − 604
edit_link.setAttribute('style', editor.getCSS());
+ − 605
edit_link.id = 'rankadmin_editlink_' + response.rank_id;
+ − 606
edit_link.rank_id = response.rank_id;
+ − 607
edit_link.appendChild(document.createTextNode($lang.get(editor.f_rank_title.value)));
+ − 608
parent.insertBefore(edit_link, create_link);
+ − 609
edit_link.onclick = function()
+ − 610
{
+ − 611
ajaxInitRankEdit(this.rank_id);
+ − 612
}
+ − 613
}
+ − 614
}
+ − 615
else
+ − 616
{
+ − 617
// update the rank title on the left
+ − 618
var edit_link = document.getElementById('rankadmin_editlink_' + editor.rankdata.rank_id);
+ − 619
if ( edit_link )
+ − 620
{
+ − 621
edit_link.firstChild.nodeValue = $lang.get(editor.f_rank_title.value);
+ − 622
edit_link.setAttribute('style', editor.getCSS());
+ − 623
}
+ − 624
}
+ − 625
}
+ − 626
else
+ − 627
{
+ − 628
whitey.parentNode.removeChild(whitey);
794
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 629
if ( response.error == 'need_auth_to_admin' )
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 630
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 631
load_component('login');
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 632
ajaxDynamicReauth(function()
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 633
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 634
ajaxRankEditHandleSave(editor, switch_new);
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 635
});
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 636
}
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 637
else
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 638
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 639
miniPromptMessage({
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 640
title: $lang.get('acpur_err_save_failed_title'),
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 641
message: response.error,
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 642
buttons: [
628
+ − 643
{
794
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 644
text: $lang.get('etc_ok'),
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 645
color: 'red',
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 646
style: {
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 647
fontWeight: 'bold'
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 648
},
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 649
onclick: function()
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 650
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 651
miniPromptDestroy(this);
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 652
}
628
+ − 653
}
794
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 654
]
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 655
});
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 656
}
628
+ − 657
}
+ − 658
}
+ − 659
}, true);
+ − 660
}
+ − 661
+ − 662
var ajaxRankEditHandleSaveExisting = function()
+ − 663
{
+ − 664
ajaxRankEditHandleSave(this, false);
+ − 665
}
+ − 666
+ − 667
var ajaxRankEditHandleSaveNew = function()
+ − 668
{
+ − 669
ajaxRankEditHandleSave(this, true);
+ − 670
}
+ − 671
+ − 672
var ajaxRankEditHandleDelete = function()
+ − 673
{
+ − 674
var mp = miniPromptMessage({
+ − 675
title: $lang.get('acpur_msg_rank_delete_confirm_title'),
+ − 676
message: $lang.get('acpur_msg_rank_delete_confirm_body'),
+ − 677
buttons: [
+ − 678
{
+ − 679
text: $lang.get('acpur_btn_delete'),
+ − 680
color: 'red',
+ − 681
style: {
+ − 682
fontWeight: 'bold'
+ − 683
},
+ − 684
onclick: function()
+ − 685
{
+ − 686
var parent = miniPromptGetParent(this);
+ − 687
var editor = parent.editor;
+ − 688
setTimeout(function()
+ − 689
{
+ − 690
ajaxRankEditDeleteConfirmed(editor);
+ − 691
}, 1000);
+ − 692
miniPromptDestroy(parent);
+ − 693
}
+ − 694
},
+ − 695
{
+ − 696
text: $lang.get('etc_cancel'),
+ − 697
onclick: function()
+ − 698
{
+ − 699
miniPromptDestroy(this);
+ − 700
}
+ − 701
}
+ − 702
]
+ − 703
});
+ − 704
console.debug(mp);
+ − 705
mp.editor = this;
+ − 706
}
+ − 707
+ − 708
function ajaxRankEditDeleteConfirmed(editor)
+ − 709
{
+ − 710
var whitey = whiteOutElement(editor.wrapperdiv);
+ − 711
779
609e35845ec3
load_component() now accepts an array, and most JS components are loaded all in one request now. Totally modular baby. And failsafe too.
Dan
diff
changeset
+ − 712
load_component(['jquery', 'jquery-ui']);
628
+ − 713
+ − 714
var json_packet = {
+ − 715
mode: 'delete_rank',
+ − 716
rank_id: editor.rankdata.rank_id
+ − 717
};
+ − 718
var rank_id = editor.rankdata.rank_id;
+ − 719
+ − 720
json_packet = ajaxEscape(toJSONString(json_packet));
823
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 721
ajaxPost(makeUrlNS('Admin', 'UserRanks/action.json'), 'r=' + json_packet, function(ajax)
628
+ − 722
{
+ − 723
if ( ajax.readyState == 4 && ajax.status == 200 )
+ − 724
{
+ − 725
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
+ − 726
if ( !check_json_response(response) )
628
+ − 727
{
+ − 728
handle_invalid_json(ajax.responseText);
+ − 729
return false;
+ − 730
}
+ − 731
try
+ − 732
{
+ − 733
var response = parseJSON(ajax.responseText);
+ − 734
}
+ − 735
catch(e)
+ − 736
{
+ − 737
handle_invalid_json(ajax.responseText);
+ − 738
}
+ − 739
if ( response.mode == 'success' )
+ − 740
{
+ − 741
// the deletion was successful, report success and kill off the editor
+ − 742
whiteOutReportSuccess(whitey);
+ − 743
setTimeout(function()
+ − 744
{
+ − 745
// nuke the rank title on the left
+ − 746
var edit_link = document.getElementById('rankadmin_editlink_' + editor.rankdata.rank_id);
+ − 747
if ( edit_link )
+ − 748
{
+ − 749
edit_link.parentNode.removeChild(edit_link);
+ − 750
}
+ − 751
// 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
+ − 752
$(editor.wrapperdiv).hide("blind", {}, 500, function()
628
+ − 753
{
+ − 754
// when the animation finishes, nuke the whole thing
+ − 755
var container = document.getElementById('admin_ranks_container_right');
+ − 756
container.innerHTML = $lang.get('acpur_msg_select_rank');
+ − 757
}
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
+ − 758
);
628
+ − 759
}, 1500);
+ − 760
}
+ − 761
else
+ − 762
{
+ − 763
whitey.parentNode.removeChild(whitey);
794
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 764
if ( response.error == 'need_auth_to_admin' )
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 765
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 766
load_component('login');
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 767
ajaxDynamicReauth(function()
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 768
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 769
ajaxRankEditDeleteConfirmed(editor);
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 770
});
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 771
}
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 772
else
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 773
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 774
miniPromptMessage({
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 775
title: $lang.get('acpur_err_delete_failed_title'),
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 776
message: response.error,
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 777
buttons: [
628
+ − 778
{
794
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 779
text: $lang.get('etc_ok'),
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 780
color: 'red',
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 781
style: {
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 782
fontWeight: 'bold'
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 783
},
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 784
onclick: function()
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 785
{
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 786
miniPromptDestroy(this);
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 787
}
628
+ − 788
}
794
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 789
]
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 790
});
720516162012
Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
diff
changeset
+ − 791
}
628
+ − 792
}
+ − 793
}
+ − 794
}, true);
+ − 795
}