author | Dan |
Sat, 06 Oct 2007 20:47:09 -0400 | |
changeset 170 | 250aeb408ed7 |
parent 80 | cb7dde69c301 |
child 190 | e858bacb5cfa |
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 |