~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/browser/editor.js

  • Committer: mattgiuca
  • Date: 2008-06-16 09:13:20 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:778
editor.js: The Save button now enables when the text is changed, and disables
    upon saving.
    (Note: There is some problem getting the callback, so for now it remains
    active, but all the code is there).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
saved_status = null;
2
 
 
3
1
function save_file()
4
2
{
5
 
    filename = document.getElementById("save_filename").value;
 
3
    var savebutton = document.getElementById("save_button");
 
4
    var filename = document.getElementById("save_filename").value;
6
5
    data = editAreaLoader.getValue("editbox");
7
6
    /* Do NOT refresh the page contents (causes problems for editarea and is
8
7
     * unnecessary). */
9
8
    do_action("putfile", filename, {"path":".", "data":data}, null, true);
10
 
    saved_status.data = "Saved.";
 
9
    savebutton.setAttribute("value", "Saved");
 
10
    // XXX Do not disable for now; there is a problem getting the callback
 
11
    // to edit_text.
 
12
    //savebutton.setAttribute("disabled", "disabled");
11
13
}
12
14
 
13
15
function edit_text()
14
16
{
15
 
    saved_status.data = "Not saved.";
 
17
    var savebutton = document.getElementById("save_button");
 
18
    savebutton.setAttribute("value", "Save");
 
19
    savebutton.removeAttribute("disabled");
16
20
}
17
21
 
18
22
/** Presents the "editor heading" (the part with the save box)
31
35
    pathname.setAttribute("value", path);
32
36
    p.appendChild(pathname);
33
37
    var savebutton = document.createElement("input");
 
38
    savebutton.setAttribute("id", "save_button");
34
39
    savebutton.setAttribute("type", "button");
35
 
    savebutton.setAttribute("value", "Save");
 
40
    savebutton.setAttribute("value", "Saved");
 
41
    savebutton.setAttribute("disabled", "disabled");
36
42
    savebutton.setAttribute("onclick", "save_file()");
37
43
    p.appendChild(savebutton);
38
44
    var t = document.createTextNode(" ");
39
45
    p.appendChild(t);
40
 
    saved_status = document.createTextNode("Saved.");
41
 
    //p.appendChild(saved_status);
42
46
    div.appendChild(p);
43
47
 
44
48
    /* Print a warning message if this is not actually a text file.
82
86
        start_highlight: true,
83
87
        allow_toggle: false,
84
88
        allow_resize: false,
85
 
        replace_tab_by_spaces: 4
 
89
        replace_tab_by_spaces: 4,
 
90
        change_callback: "edit_text"
86
91
    });
87
92
}
88
93