955
|
1 |
// Sidebar collapse
|
958
|
2 |
function enanium_toggle_sidebar(side)
|
955
|
3 |
{
|
958
|
4 |
if ( document.getElementById('enanium_sidebar_' + side).style.display == 'none' )
|
955
|
5 |
{
|
|
6 |
// show
|
958
|
7 |
document.getElementById('enanium_sidebar_' + side).style.display = 'block';
|
|
8 |
document.getElementById('enanium_sidebar_' + side + '_hidden').style.display = 'none';
|
|
9 |
createCookie(side + '_sidebar', 'open', 365);
|
955
|
10 |
}
|
|
11 |
else
|
|
12 |
{
|
|
13 |
// hide
|
958
|
14 |
document.getElementById('enanium_sidebar_' + side).style.display = 'none';
|
|
15 |
document.getElementById('enanium_sidebar_' + side + '_hidden').style.display = 'block';
|
|
16 |
createCookie(side + '_sidebar', 'collapsed', 365);
|
955
|
17 |
}
|
|
18 |
}
|
|
19 |
|
958
|
20 |
function enanium_toggle_sidebar_right()
|
|
21 |
{
|
|
22 |
enanium_toggle_sidebar('right');
|
|
23 |
}
|
|
24 |
|
|
25 |
function enanium_toggle_sidebar_left()
|
|
26 |
{
|
|
27 |
enanium_toggle_sidebar('left');
|
|
28 |
}
|
|
29 |
|
955
|
30 |
addOnloadHook(function()
|
|
31 |
{
|
958
|
32 |
if ( readCookie('left_sidebar') == 'collapsed' )
|
|
33 |
{
|
|
34 |
document.getElementById('enanium_sidebar_left').style.display = 'none';
|
|
35 |
document.getElementById('enanium_sidebar_left_hidden').style.display = 'block';
|
|
36 |
}
|
|
37 |
|
955
|
38 |
if ( readCookie('right_sidebar') == 'collapsed' )
|
|
39 |
{
|
|
40 |
document.getElementById('enanium_sidebar_right').style.display = 'none';
|
|
41 |
document.getElementById('enanium_sidebar_right_hidden').style.display = 'block';
|
|
42 |
}
|
|
43 |
});
|
|
44 |
|
|
45 |
// Inline rename
|
|
46 |
|
921
|
47 |
function ajaxRenameInline()
|
|
48 |
{
|
|
49 |
if ( KILL_SWITCH || IE )
|
|
50 |
return false;
|
|
51 |
// This trick is _so_ vBulletin...
|
|
52 |
elem = document.getElementById('h2PageName');
|
|
53 |
if(!elem) return;
|
|
54 |
elem.style.display = 'none';
|
|
55 |
name = elem.firstChild.nodeValue;
|
|
56 |
textbox = document.createElement('input');
|
|
57 |
textbox.type = 'text';
|
|
58 |
textbox.value = name;
|
|
59 |
textbox.id = 'pageheading';
|
|
60 |
textbox.size = name.length + 7;
|
|
61 |
textbox.onkeyup = function(e) { if(!e) return; if(e.keyCode == 13) ajaxRenameInlineSave(); if(e.keyCode == 27) ajaxRenameInlineCancel(); };
|
|
62 |
textbox.oldname = name;
|
|
63 |
elem.parentNode.insertBefore(textbox, elem);
|
|
64 |
document.onclick = ajaxRenameInlineCancel;
|
|
65 |
|
|
66 |
load_component(['l10n', 'fadefilter', 'messagebox']);
|
|
67 |
textbox.focus();
|
|
68 |
textbox.select();
|
|
69 |
}
|
|
70 |
|
|
71 |
function ajaxRenameInlineSave()
|
|
72 |
{
|
|
73 |
elem1 = document.getElementById('h2PageName');
|
|
74 |
elem2 = document.getElementById('pageheading');
|
|
75 |
if(!elem1 || !elem2) return;
|
|
76 |
value = elem2.value;
|
|
77 |
elem2.parentNode.removeChild(elem2); // just destroy the thing
|
|
78 |
elem1.removeChild(elem1.firstChild);
|
|
79 |
elem1.appendChild(document.createTextNode(value));
|
|
80 |
elem1.style.display = 'block';
|
|
81 |
if(!value || value=='' || value==elem2.oldname) return;
|
|
82 |
setAjaxLoading();
|
|
83 |
ajaxPost(stdAjaxPrefix+'&_mode=rename', 'newtitle='+ajaxEscape(value), function() {
|
|
84 |
if ( ajax.readyState == 4 )
|
|
85 |
{
|
|
86 |
unsetAjaxLoading();
|
|
87 |
var response = String(ajax.responseText);
|
|
88 |
if ( !check_json_response(response) )
|
|
89 |
{
|
|
90 |
handle_invalid_json(response);
|
|
91 |
return false;
|
|
92 |
}
|
|
93 |
response = parseJSON(response);
|
|
94 |
if ( response.success )
|
|
95 |
{
|
|
96 |
new MessageBox( MB_OK|MB_ICONINFORMATION, $lang.get('ajax_rename_success_title'), $lang.get('ajax_rename_success_body', { page_name_new: value }) );
|
|
97 |
}
|
|
98 |
else
|
|
99 |
{
|
|
100 |
alert(response.error);
|
|
101 |
}
|
|
102 |
}
|
|
103 |
});
|
|
104 |
}
|
|
105 |
|
|
106 |
function ajaxRenameInlineCancel(e)
|
|
107 |
{
|
|
108 |
if ( typeof(e) != 'object' && IE )
|
|
109 |
e = window.event;
|
|
110 |
elem1 = document.getElementById('h2PageName');
|
|
111 |
elem2 = document.getElementById('pageheading');
|
|
112 |
if(!elem1 || !elem2) return;
|
|
113 |
if ( typeof(e) == 'object' && e.target )
|
|
114 |
{
|
|
115 |
if(e.target == elem2)
|
|
116 |
return;
|
|
117 |
}
|
|
118 |
//value = elem2.value;
|
|
119 |
elem2.parentNode.removeChild(elem2); // just destroy the thing
|
|
120 |
//elem1.innerHTML = value;
|
|
121 |
elem1.style.display = 'block';
|
|
122 |
document.onclick = null;
|
|
123 |
}
|
|
124 |
|
955
|
125 |
if ( window.auth_rename )
|
|
126 |
{
|
|
127 |
addOnloadHook(function()
|
921
|
128 |
{
|
955
|
129 |
var h2 = document.getElementById('h2PageName');
|
|
130 |
if ( h2 )
|
921
|
131 |
{
|
955
|
132 |
h2.ondblclick = function()
|
|
133 |
{
|
|
134 |
ajaxRenameInline();
|
|
135 |
}
|
921
|
136 |
}
|
955
|
137 |
});
|
|
138 |
}
|