1
1
function disable_save_if_safe()
3
/* If this is defined, this engine supports change notification, so is able
4
* to enable the button again. Disable it for them. */
5
if(editbox.editor.addChangeHandler)
3
/* If we are using CodePress, we can only safely disable the save button
4
* (indicating that there are no changes to save) if the engine supports
5
* change notification, so the button can be enabled again.
7
* Our non-CodePress mode just uses normal textarea events, so is always
10
if((!using_codepress) || editbox.editor.addChangeHandler)
7
12
var savebutton = document.getElementById("save_button");
8
13
savebutton.disabled = true;
13
18
function save_file(filename)
15
data = editbox.getCode();
21
data = editbox.getCode();
23
data = document.getElementById("editbox").value;
16
25
/* Do NOT refresh the page contents (causes problems for editarea and is
18
27
if (current_file.svnstatus != "revision" ||
120
129
language = language ? language : "text";
121
130
document.getElementById("highlighting_select").value = language;
123
txt_elem.className = "codepress autocomplete-off " + language;
124
txt_elem.setAttribute("onchange", "edit_text()");
125
/* TODO: Make CSS height: 100% work */
126
txt_elem.setAttribute("rows", "35");
132
$(txt_elem).change(edit_text);
134
/* This isn't ideal, as Opera seems to fire it even for non-textual keys.
135
* But IE and WebKit don't, so this will behave properly in most browsers.
138
$(txt_elem).keypress(edit_text);
140
txt_elem.style.width = "100%";
141
txt_elem.style.height = "100%";
129
142
window.onbeforeunload = confirm_beforeunload;
131
/* And set a callback so we know that the editor iframe is loaded so we
132
* can set a callback so we know when to enable the save button.
133
* We also take this opportunity to disable the save button, if
134
* the browser is likely to reenable it as needed. */
135
editbox.onload = initialise_codepress
144
/* XXX: Lord, please forgive me for browser sniffing.
145
CodePress only works properly in real Gecko at the moment,
146
so we must go to great and evil lengths to sniff it out.
147
It's by no means a complete check, but it has to support
148
more browsers than the previous situation.
149
This should be killed ASAP when we fix/replace CodePress.
151
using_codepress = (navigator.userAgent.match('Gecko') &&
152
!navigator.userAgent.match('WebKit') &&
153
!navigator.userAgent.match('Presto'))
157
/* This is probably real Gecko. Try to fire up CodePress.
158
* If it fails we'll have a horrible mess, so we'll hope.
160
txt_elem.className = "codepress autocomplete-off " + language;
163
/* And set a callback so we know that the editor iframe is loaded so
164
* we can set a callback so we know when to enable the save button.
165
* We also take this opportunity to disable the save button, if
166
* the browser is likely to reenable it as needed. */
167
editbox.onload = initialise_codepress;
171
/* Not using CodePress, so we can already disable the Save button. */
172
disable_save_if_safe();
138
176
function language_from_mime(mime)