Commit 6b1e1d55 authored by Zack Lee's avatar Zack Lee
Browse files

update files in pd/nw

parent 34a26b91
......@@ -307,8 +307,13 @@
<script>
"use strict";
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
if (typeof(pdbundle) !== "undefined"){
var pdgui = pdbundle.pdgui
}else{
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
}
// For translations
var l = pdgui.get_local_string;
......@@ -607,6 +612,10 @@ function apply() {
function cancel() {
var i, attrs, gfxstub;
//window.close(true);
if(pdgui.is_webapp()){
remove_dialog(pd_object_callback)
}
pdgui.pdsend(pd_object_callback, "cancel");
for (i = 0; i < pd_garray_attrs.length; i++) {
attrs = pd_garray_attrs[i];
......@@ -703,6 +712,7 @@ function register_window_id(gfxstub, attr_objects) {
document.getElementsByClassName("container")[0].style.setProperty("display", "inline");
pdgui.resize_window(pd_object_callback);
}
window.register_dialog = register_window_id;
function tr_text(id) {
var elem = document.getElementById("iem.prop." + id);
......@@ -786,10 +796,12 @@ function populate_form(attr_object) {
function add_events(name) {
// closing the Window
gui.Window.get().on("close", function() {
if(!pdgui.is_webapp()){
gui.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
cancel();
});
});
}
pdgui.dialog_bindings(name);
}
......
......@@ -24,8 +24,13 @@
<script>
"use strict";
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
if (typeof(pdbundle) !== "undefined"){
var pdgui = pdbundle.pdgui
}else{
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
}
// For translations
var l = pdgui.get_local_string;
......@@ -80,6 +85,10 @@ function apply() {
function cancel() {
//window.close(true);
pdgui.pdsend(pd_object_callback, "cancel");
if(pdgui.is_webapp()){
remove_dialog(pd_object_callback)
}
}
function ok() {
......@@ -327,6 +336,7 @@ function register_window_id(gfxstub, data_string) {
document.getElementsByClassName("container")[0]
.style.setProperty("display", "inline");
}
window.register_dialog = register_window_id;
// Stop-gap translator
function translate_form() {
......@@ -353,10 +363,12 @@ function get_elem(name) {
function add_events(name) {
// closing the Window
gui.Window.get().on("close", function () {
if(!pdgui.is_webapp()){
gui.Window.get().on("close", function () {
// this needs to do whatever the "cancel" button does
cancel();
});
});
}
pdgui.dialog_bindings(name);
}
</script>
......
......@@ -32,8 +32,13 @@
</div>
<script>
"use strict";
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
if (typeof(pdbundle) !== "undefined"){
var pdgui = pdbundle.pdgui
}else{
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
}
// For translations
var l = pdgui.get_local_string;
......@@ -68,6 +73,10 @@ function apply() {
function cancel() {
send_props_to_pd(old_properties);
pdgui.pdsend(pd_object_callback, "cancel");
if(pdgui.is_webapp()){
remove_dialog(pd_object_callback)
}
}
function ok() {
......@@ -76,6 +85,10 @@ function ok() {
focus_button("ok_button");
send_props_to_pd(new_properties);
pdgui.pdsend(pd_object_callback, "cancel");
if(pdgui.is_webapp()){
remove_dialog(pd_object_callback)
}
}
// turn a ["name", value, etc.] array
......@@ -142,6 +155,7 @@ function register_window_id(gfxstub, args) {
document.getElementsByClassName("container")[0]
.style.setProperty("display", "inline");
}
window.register_dialog = register_window_id;
// Stop-gap translator
function translate_form() {
......@@ -193,10 +207,12 @@ function build_form(external_name, array_of_objects) {
function add_events(name) {
// closing the Window
gui.Window.get().on("close", function () {
// this needs to do whatever the "cancel" button does
cancel();
});
if(!pdgui.is_webapp()){
gui.Window.get().on("close", function () {
// this needs to do whatever the "cancel" button does
cancel();
});
}
pdgui.dialog_bindings(name);
}
</script>
......
......@@ -88,8 +88,14 @@
<script>
"use strict";
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
if (typeof(pdbundle) !== "undefined"){
var pdgui = pdbundle.pdgui
}else{
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
}
// For translations
var l = pdgui.get_local_string;
......@@ -111,6 +117,10 @@ function apply() {
function cancel() {
//window.close(true);
if(pdgui.is_webapp()){
remove_dialog(pd_object_callback)
}
pdgui.pdsend(pd_object_callback, "cancel");
}
......@@ -141,6 +151,7 @@ function register_window_id(gfxstub, attrs) {
document.getElementsByClassName("container")[0]
.style.setProperty("display", "inline");
}
window.register_dialog = register_window_id;
// Stop-gap translator
function translate_form() {
......@@ -172,11 +183,13 @@ function populate_form(attrs) {
}
function add_events(name) {
// closing the Window
gui.Window.get().on("close", function () {
// this needs to do whatever the "cancel" button does
cancel();
});
if(!pdgui.is_webapp()){
// closing the Window
gui.Window.get().on("close", function () {
// this needs to do whatever the "cancel" button does
cancel();
});
}
pdgui.dialog_bindings(name);
}
</script>
......
......@@ -109,7 +109,7 @@
<input class="label-pos"
type="radio"
id="labelpos_left"
id="labelpos_top"
value="2"
name="labelpos"
onchange="update_attr(this)">
......@@ -166,8 +166,13 @@
<script>
"use strict";
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
if (typeof(pdbundle) !== "undefined"){
var pdgui = pdbundle.pdgui
}else{
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
}
// For translations
var l = pdgui.get_local_string;
......@@ -253,6 +258,10 @@ function send_params(attrs, create_undo_point) {
function cancel(revert_changes) {
var dirty = false, attr;
//window.close(true);
if(pdgui.is_webapp()){
remove_dialog(pd_object_callback)
}
if (revert_changes) {
for (attr in old_attrs) {
if (old_attrs[attr] !== new_attrs[attr]) {
......@@ -322,6 +331,7 @@ function register_window_id(gfxstub, attributes) {
.style.setProperty("display", "inline");
pdgui.resize_window(pd_object_callback);
}
window.register_dialog = register_window_id;
function tr_text(id) {
var elem = document.getElementById("iem.prop." + id);
......@@ -377,10 +387,12 @@ function populate_form(attributes) {
function add_events(name) {
// closing the Window
gui.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
cancel(false);
});
if(!pdgui.is_webapp()){
gui.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
cancel(false);
});
}
pdgui.dialog_bindings(name);
}
......
......@@ -327,8 +327,13 @@
<script>
"use strict";
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
if (typeof(pdbundle) !== "undefined"){
var pdgui = pdbundle.pdgui
}else{
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
}
// For translations
var l = pdgui.get_local_string;
......@@ -525,6 +530,9 @@ function send_params(attrs, create_undo_point) {
function cancel(revert_changes) {
var dirty = false, attr;
//window.close(true);
if(pdgui.is_webapp()){
remove_dialog(pd_object_callback)
}
if (revert_changes) {
for (attr in old_attrs) {
if (old_attrs[attr] !== new_attrs[attr]) {
......@@ -596,6 +604,7 @@ function register_window_id(gfxstub, attr_object) {
.style.setProperty("display", "inline");
pdgui.resize_window(pd_object_callback);
}
window.register_dialog = register_window_id;
function tr_text(id) {
var elem = document.getElementById("iem.prop." + id);
......@@ -657,10 +666,12 @@ function populate_form(attr_object) {
function add_events(name) {
// closing the Window
gui.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
cancel(false);
});
if(!pdgui.is_webapp()){
gui.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
cancel(false);
});
}
pdgui.dialog_bindings(name);
}
......
......@@ -480,8 +480,13 @@
</div>
<script>
"use strict";
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
if (typeof(pdbundle) !== "undefined"){
var pdgui = pdbundle.pdgui
}else{
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
}
// For translations
var l = pdgui.get_local_string;
......@@ -767,7 +772,11 @@ function cancel() {
// that. To see if the bug is gone, try removing the next line and see
// if you can open the Prefs dialog after clicking "Ok".
pdgui.remove_dialogwin(pd_object_callback);
window.close(true);
if(pdgui.is_webapp()){
remove_dialog(pd_object_callback)
}else{
window.close(true);
}
//pdgui.pdsend(pd_object_callback, "cancel");
}
......@@ -916,7 +925,8 @@ function audio_prefs_callback(attrs) {
disable_unused_devs("out", get_attr("canmulti", attrs));
pdgui.resize_window(pd_object_callback);
}
}
window.audio_prefs_callback = audio_prefs_callback;
function set_devs(type, devs) {
var i;
......@@ -985,6 +995,7 @@ function midi_prefs_callback(attrs) {
}
pdgui.resize_window(pd_object_callback);
}
window.midi_prefs_callback = midi_prefs_callback;
function autopatch_yoffset_toggle(checked) {
document.getElementById("autopatch_yoffset_value").disabled = !checked;
......@@ -1256,6 +1267,7 @@ function register_window_id(gfxstub, attr_arrays) {
pdgui.pdsend("pd start-startup-dialog"); // request default loaded libs
document.getElementsByClassName("container")[0].style.setProperty("display", "inline");
}
window.register_dialog = register_window_id;
function tr_text(id) {
var elem = document.getElementById("iem.prop." + id);
......@@ -1307,11 +1319,13 @@ function add_events(name) {
// let's handle some events for this window...
// closing the Window
gui.Window.get().on("close", function() {
pdgui.remove_dialogwin(pd_object_callback);
gui.Window.get().close(true);
//cancel();
});
if(!pdgui.is_webapp()){
gui.Window.get().on("close", function() {
pdgui.remove_dialogwin(pd_object_callback);
gui.Window.get().close(true);
//cancel();
});
}
pdgui.dialog_bindings(name);
}
......
......@@ -7,9 +7,15 @@
<script type="text/javascript" src="./console_search.js"></script>
<script>
"use strict";
var pdgui = require("./pdgui.js");
var fs = require("fs");
var path = require("path");
if (typeof(pdbundle) !== "undefined"){
var pdgui = pdbundle.pdgui
}else{
var pdgui = require("./pdgui.js");
var fs = require("fs");
var path = require("path");
}
var l = pdgui.get_local_string;
var index;
......@@ -169,7 +175,9 @@ function display_toc() {
div = document.createElement("div");
if (doc.id) {
try {
fs.accessSync(path.join(pdgui.get_lib_dir(), doc.id), fs.F_OK);
if(!pdgui.is_webapp()){
fs.accessSync(path.join(pdgui.get_lib_dir(), doc.id), fs.F_OK);
}
a = document.createElement("a");
a.href = "javascript: click_toc('" + doc.id + "');";
a.textContent = doc.title;
......@@ -231,7 +239,9 @@ function display_directory_callback(err, files) {
function display_directory(dir) {
current_dir = dir;
clear_results();
fs.readdir(dir, display_directory_callback);
if(!pdgui.is_webapp()){
fs.readdir(dir, display_directory_callback);
}
}
function file_browser_click() {
......@@ -406,10 +416,12 @@ function toggle_find_bar() {
function add_events() {
// closing the Window
nw.Window.get().on("close", function() {
pdgui.remove_dialogwin("search");
nw.Window.get().close(true);
});
if(!pdgui.is_webapp()){
nw.Window.get().on("close", function() {
pdgui.remove_dialogwin("search");
nw.Window.get().close(true);
});
}
// Find bar
var find_bar = document.getElementById("console_find_text");
......@@ -460,7 +472,11 @@ function add_events() {
}
function register_window_id(id, attrs) {
var doc_path = path.join(pdgui.get_lib_dir(), "doc");
if(!pdgui.is_webapp()){
var doc_path = path.join(pdgui.get_lib_dir(), "doc");
document.getElementById("file_browser").setAttribute("nwworkingdir",
doc_path); // Probably need a doc getter in pdgui
}
translate_form();
// Translate the placeholder for the search input:
document.getElementById("search_text").placeholder =
......@@ -470,10 +486,10 @@ function register_window_id(id, attrs) {
document.getElementById("file_browser").accept = filetypes.join(",");
document.getElementById("results").textContent = l("search.building_index");
document.getElementById("search_text").disabled = true;
document.getElementById("file_browser").setAttribute("nwworkingdir",
doc_path); // Probably need a doc getter in pdgui
pdgui.build_index(finish_build);
}
window.register_dialog = register_window_id
function display_no_results() {
document.getElementById("results").textContent = l("search.no_results");
......
......@@ -42,8 +42,13 @@
</dialog>
<script>
"use strict";
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
if (typeof(pdbundle) !== "undefined"){
var pdgui = pdbundle.pdgui
}else{
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
}
// For translations
var l = pdgui.get_local_string;
......@@ -68,6 +73,9 @@ function apply() {
function cancel() {
//window.close(true);
if(pdgui.is_webapp()){
remove_dialog(pd_object_callback)
}
close_window();
}
......@@ -83,13 +91,17 @@ function close_modal_dialog() {
}
function textarea_clear() {
if(document.getElementById("text") !== null){
document.getElementById("text").value = "";
dirty = true;
}
}
function textarea_append(line) {
if(document.getElementById("text")){
document.getElementById("text").value += line;
dirty = true;
}
}
function set_dirty(state) {
......@@ -120,6 +132,7 @@ function register_window_id(gfxstub, text_string) {
document.getElementsByClassName("container")[0]
.style.setProperty("display", "inline");
}
window.register_dialog = register_window_id;
// Stop-gap translator
function translate_form() {
......@@ -147,23 +160,27 @@ function close_from_pd(signoff) {
pdgui.pdsend(pd_object_callback, "signoff");
}
pdgui.remove_dialogwin(pd_object_callback);
gui.Window.get().close(true);
if(!pdgui.is_webapp()){
gui.Window.get().close(true);
}
}
function add_events(name) {
// closing the Window
gui.Window.get().on("close", function () {
// this needs to do whatever the "cancel" button does
//pdgui.pdsend(name, "menuclose 0");
//cancel();
// blur the textarea to trigger an onchange if it was modified
document.getElementById("text").blur();
if (dirty) {
document.getElementById("save_before_quit").showModal();
} else {
close_window();
}
});
if(!pdgui.is_webapp()){
gui.Window.get().on("close", function () {
// this needs to do whatever the "cancel" button does
//pdgui.pdsend(name, "menuclose 0");
//cancel();
// blur the textarea to trigger an onchange if it was modified
document.getElementById("text").blur();
if (dirty) {
document.getElementById("save_before_quit").showModal();
} else {
close_window();
}
});
}
document.getElementById("text").onchange = function() {
dirty = true;
}
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment