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