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