Issachar Brooks wrote:
> Thanks for the suggestion. I am very new to Ajax, as I don't know 
> javascript very well, but I am trying to learn it to implement on my 
> site, which would make things much more flexible for me. Do you have 
> any practical examples of the prototype Ajax functions for me to look 
> at? I have looked at the scattered documentation, but being unfamiliar 
> with javascript (I work with php and am just mastering that recently) 
> the examples are a bit "abstract" to me. I understand the concepts, 
> but putting it into practice is a little different.... currently I am 
> rethinking my site because it is really slow (a combination of the 
> javascript libraries, the php parsing time and the actual size of the 
> images etc.), and wanting to make it more "ajax driven". I have been 
> able to implement the Ajax.Updater for loading content into divs etc. 
> but I am still researching how to load styles and javascript on the 
> fly.... Any help is appreciated, although I don't expect any of you to 
> take that time in helping me... (some links would be very helpful) :). 
> I am just explaining all of this so you can understand at what level I 
> am thinking.
>  
> Thanks once again,
>  
> Issachar Brooks

Mostly you just have to try a bunch of stuff until you begin to 
understand. I can show you the code I came up with, (which I will do 
below) but I can't make you understand it. You have to do that part. So 
just write a lot of code until you understand how it works.

Here is the code I use for one of my windows. I lump it together into a 
"class" to keep it organized. This class is used to manage one window. 
The content for the window is defined in designer.php and is loaded when 
Designer.ccOpen is called. Note that the onComplete for the ajax call 
checks to see if all went well. If the ajax call was successful, then 
Designer.ccShow is called to show the window and load its content. The 
content itself is passed.

HTH,
-- Will

----------------------------------- code 
---------------------------------------
  var Designer = {
    _designerChanged: false,
      _ccWin: null, 
     
      _setResizeHandler: function(win) {
        // Resize logic goes here  
      },
     
    ccOpen: function() {
      new Ajax.Request( "designer.php", {
        method:'post',
        parameters: 
"function=displayDesignCenter&teamid="+this_teamid+"&pageid="+this_pageid,
        onComplete: function(t) {
          console.debug("X-JSON Header: 
"+t.getResponseHeader('X-JSON')+".");
          var json = t.getResponseHeader('X-JSON').parseJSON();
          if(json) {
            if(json.Result == "Ok") {
              Designer.ccShow(t.responseText);
            } else {
              errorDialog(json.Message);
              return;
            }
          } else {
            errorDialog("Contact with the server failed. Please Refresh 
the page.");
            return;
          }
        },
        onException: function(o,e){ throw(e); }
      });
    },     
      
    ccShow: function(content) {
        Designer._ccWin = new Window( 'designcenter', {
          className: "dialog",
          width:  300,
          height: 300,
          top: 0,
          left: 0,
          zIndex: 50,
          resizable: true,
          title: "Page Design Center",
          draggable: true
        });
   
        Designer._ccWin.getContent().update(content);
        Designer._ccWin.setStatusBar("Status bar info");
                                                           
        Designer._ccWin.setDelegate({ canClose: function(win) { return 
Designer.ccCanClose(win); } });
        Designer._ccWin.setDestroyOnClose();
        Designer._ccWin.show();
                   
        // Add Observers for Button Bar                         
        $("designcenter_add_module_btn").observe("click", function () { 
alert("Adding..."); });
        $("designcenter_del_module_btn").observe("click", function () { 
alert("Deleteing..."); });
              
            // Set up a windows observer,
          Windows.addObserver({onResizing: function(eventName, win) {if 
(win == Designer._ccWin) {Designer._setResizeHandler(win);}}});
        },
       
    ccCanClose: function(win) {
        if(Designer._designerChanged) {
          Dialog.query("<span class=\"confirmDialogMessage\"><img 
src=\"graphics/help.gif\" />The Design Center has unsaved data. Do you 
want to save?</span>",  { windowParameters: { className:"alphacube" },
            ok: function() { Designer.ccSave(win); return true; }, 
            no: function() { Designer.ccCompleteClose(win); return 
true;  }, 
            cancel: function() { return false; }
          });
        } else { Designer.ccCompleteClose(win); } 
        return false;
      },
   
    ccSave: function(win) {
        console.debug("Saving Designer");
        // Save logic goes here
        Designer._designerChanged = false;
        Designer.ccCompleteClose(win); 
      },
   
    ccCompleteClose: function(win) {
        console.debug("Closing Designer");
        win.hide();
      }
       
    }  



_______________________________________________
Javawin mailing list
[email protected]
http://mail.xilinus.com/mailman/listinfo/javawin_xilinus.com

Reply via email to