Here is the code. I'm a newbie at js so it may not be pretty. Not sure how to
delete and/or reuse them. Any suggestions would be appreciated.

Bob

/*
   doc: qooxdoo clientDocument
   title: title of the window
   text: confirmation text
   yesFunction (optional): function that gets called if the user clicks Yes
   noFunction (optional): function that gets called if the user clicks No
   yesLabel (optional): alternate label for the Yes button
   noLabel (optional): alternate label for the No button
   width (optional): window width, defaults to 200
   height (optional): window height, defaults to 120
   icon (optional): name of image file to use for the icon, must be within
qooxdoos image/32/ directory
*/
function ComfirmDialog(doc, title, text, yesFunction, noFunction, yesLabel,
noLabel, width, height, icon)
{
    var w1 = new QxWindow(title);
    w1.setModal(true);
    w1.setShowClose(false);
    w1.setShowMaximize(false);
    w1.setShowMinimize(false);
    w1.getPane().setPadding(10);
    if ((width == null) || (width == 0))
        w1.setWidth(200);
    else
        w1.setWidth(width);
    if ((height == null) || (height == 0))
        w1.setHeight(120);
    else
        w1.setHeight(height);

    var a1;
    if (icon)
        a1 = new QxAtom(text, "icons/32/" + icon + ".png");
    else
        a1 = new QxAtom(text, "icons/32/help.png");
    a1.set({ top: 0, left: 10 });
    w1.add(a1);

    if (yesLabel == null)
        yesLabel = "Yes";
    var btn1 = new QxButton(yesLabel, "icons/16/buttonok.png");
    btn1.set({ bottom: 0, right : 0 });
    btn1.addEventListener("click", function(e)
    {
        if (yesFunction != null)
            yesFunction();
        w1.close();
    });

    if (noLabel == null)
        noLabel = "No";
    var btn2 = new QxButton(noLabel, "icons/16/buttoncancel.png");
    btn2.set({ bottom: 0, right : 60 });
    btn2.addEventListener("click", function(e)
    {
        if (noFunction != null)
            noFunction();
        w1.close();
    });

    w1.add(btn1, btn2);

    doc.add(w1);
    w1.centerToBrowser();
    w1.open();
}

/*
   doc: qooxdoo clientDocument
   title: title of the window
   text: confirmation text
   okFunction (optional): function that gets called if the user clicks OK
   okLabel (optional): alternate label for the OK button
   width (optional): window width, defaults to 200
   height (optional): window height, defaults to 120
   icon (optional): name of image file to use for the icon, must be within
qooxdoos image/32/ directory
*/
function AlertDialog(doc, title, text, okFunction, okLabel, width, height, icon)
{
    var w1 = new QxWindow(title);
    w1.setModal(true);
    w1.setShowClose(false);
    w1.setShowMaximize(false);
    w1.setShowMinimize(false);
    w1.getPane().setPadding(10);
    if ((width == null) || (width == 0))
        w1.setWidth(200);
    else
        w1.setWidth(width);
    if ((height == null) || (height == 0))
        w1.setHeight(120);
    else
        w1.setHeight(height);

    var a1;
    if (icon)
        a1 = new QxAtom(text, "icons/32/" + icon + ".png");
    else
        a1 = new QxAtom(text, "icons/32/info.png");
    a1.set({ top: 0, left: 10 });
    w1.add(a1);

    if (okLabel == null)
        okLabel = "OK";
    var btn1 = new QxButton(okLabel, "icons/16/buttonok.png");
    btn1.set({ bottom: 0, right : 0 });
    btn1.addEventListener("click", function(e)
    {
        if (okFunction != null)
            okFunction();
        w1.close();
    });

    w1.add(btn1);

    doc.add(w1);
    w1.centerToBrowser();
    w1.open();
}

/*
   doc: qooxdoo clientDocument
   title: title of the window
   text: confirmation text
   defaultValue (optional): default field value
   okFunction (optional): function that gets called if the user clicks OK
   cancelFunction (optional): function that gets called if the user clicks 
Cancel
   okLabel (optional): alternate label for the OK button
   cancelLabel (optional): alternate label for the Cancel button
   width (optional): window width, defaults to 200
   height (optional): window height, defaults to 120
   icon (optional): name of image file to use for the icon, must be within
qooxdoos image/32/ directory
*/
function PromptDialog(doc, title, text, defaultValue, okFunction,
cancelFunction, okLabel, cancelLabel, width, height, icon)
{
    var w1 = new QxWindow(title);
    w1.setModal(true);
    w1.setShowClose(false);
    w1.setShowMaximize(false);
    w1.setShowMinimize(false);
    w1.getPane().setPadding(10);
    if ((width == null) || (width == 0))
        w1.setWidth(300);
    else
        w1.setWidth(width);
    if ((height == null) || (height == 0))
        w1.setHeight(140);
    else
        w1.setHeight(height);

    var gl = new QxGridLayout;
    gl.setLocation(0, 0);
    gl.setDimension("auto", "auto");
    gl.setPadding(0);
    gl.setColumnCount(2);
    gl.setRowCount(2);
    gl.setVerticalSpacing(4);
    gl.setHorizontalSpacing(6);
    gl.setColumnWidth(0, 40);
    gl.setColumnWidth(1, 180);
    gl.setColumnHorizontalAlignment(0, "right");
    gl.setColumnVerticalAlignment(0, "middle");
    gl.setRowVerticalAlignment(0, "middle");
    gl.setRowHeight(0, 30);
    gl.setRowHeight(1, 20);

    var a1;
    if (icon)
        a1 = new QxImage("icons/32/" + icon + ".png");
    else
        a1 = new QxImage("icons/32/important.png");
    gl.add(a1, 0, 0);

    var label1 = new QxLabel(text);
    gl.add(label1, 1, 0);

    var t1 = new QxTextArea;
    t1.setValue(defaultValue);
    gl.add(t1, 1, 1);

    if (okLabel == null)
        okLabel = "OK";
    var btn1 = new QxButton(okLabel, "icons/16/buttonok.png");
    btn1.set({ bottom: 0, right : 0 });
    btn1.addEventListener("click", function(e)
    {
        if (okFunction != null)
            okFunction(t1.getValue());
        w1.close();
    });
    w1.add(btn1);

    if (cancelLabel == null)
        cancelLabel = "Cancel";
    var btn2 = new QxButton(cancelLabel, "icons/16/buttoncancel.png");
    btn2.set({ bottom: 0, right : 60 });
    btn2.addEventListener("click", function(e)
    {
        if (cancelFunction != null)
            cancelFunction();
        w1.close();
    });
    w1.add(btn2);

    w1.add(gl);
    doc.add(w1);
    w1.centerToBrowser();
    t1.setFocused(true);
    w1.open();

}



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to