Results 1 to 4 of 4

Thread: DHTML window: any way to prevent positioning outside window?

  1. #1
    Join Date
    Aug 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DHTML window: any way to prevent positioning outside window?

    DHTML Window widget
    http://www.dynamicdrive.com/dynamici...ndow/index.htm

    Issue:
    I'm currently implementing the script on a multifunctionctional backoffice system with a large menu structure.
    Since i want to keep the main page as a desktop with an overview, i'm opening all menu items/programs inside a DHTML Window, which is a great functionality... especially because it allows multiple floating panels, users feel familiar since it is like working in a "windows-like" environment.

    However i have one problem rising here... opening a new Window inside a smaller browser window will place the controlbar outside the browser, also users dragging the windows outside the browserwindow will cause similar effect, causing the window to be unreachable. With the controlbar outside the window, users will never be able to reach it in order to move it back inside the window.

    However i'm aware of the positioning function onclick="inlinewin.moveTo(400, 200); i would rather prefer to prevent moving outside in the first place, which actually might even be a nice additional setting to the script!?
    Anyway, is there any way to prevent dragging a window to positions outside the browserwindow? Any help or ideas will be appreciated!

    Many thanks
    Marco

  2. #2
    Join Date
    Aug 2004
    Posts
    9,894
    Thanks
    3
    Thanked 966 Times in 954 Posts
    Blog Entries
    15

    Default

    Hey Marco:
    You can try setting up some constraints inside the move() function to bound each DHTML window's draggable area to within the current viewpoint. Try replacing the following code inside the .js file:

    Code:
    move:function(t, e){
    	t.style.left=dhtmlwindow.distancex+dhtmlwindow.initx+"px"
    	t.style.top=dhtmlwindow.distancey+dhtmlwindow.inity+"px"
    },
    to:

    Code:
    move:function(t, e){
    	var d=dhtmlwindow //reference dhtml window object
    	var winleft = dhtmlwindow.distancex+dhtmlwindow.initx
    	var wintop = dhtmlwindow.distancey+dhtmlwindow.inity
    	var scroll_top=(document.all)? this.standardbody.scrollTop : window.pageYOffset
    	var scroll_left=(document.all)? this.standardbody.scrollLeft : window.pageXOffset
    	if ( winleft > scroll_left-10 && (winleft + d.width - 10) < scroll_left + this.docwidth){
    		t.style.left=winleft+"px"
    	}
    	if (  wintop > scroll_top && (wintop + t.offsetHeight) < scroll_top + this.docheight){
    		t.style.top=wintop+"px"
    	}
    },
    DD Admin

  3. #3
    Join Date
    Aug 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Super duper... this seems to work perfectly! Many many thanks man! cheers

  4. #4
    Join Date
    Aug 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have one other issue:
    To give the window a more "windows like" behaviour i think it would be nice to activate (set focus) the window by clicking inside it. Currently you can open multiple windows, the first opened will loose focus while the second goes on top. In order to switch between both windows you can now only click the top bar, clicking elsewhere inside it's window area doesn't do the same thing. Is there a way, maybe simply by adding an onclick behaviour?

    Thanks, Marco.

Similar Threads

  1. Replies: 1
    Last Post: 03-02-2011, 05:53 AM
  2. DHTML Window Widget Window Positioning
    By dbr00d in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 03-13-2010, 10:38 PM
  3. Positioning DHTML modal window
    By mystic7 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 11-02-2009, 09:07 PM
  4. DHTML Window Widget positioning problem
    By Clippo_Puppet in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 10-02-2007, 01:14 PM
  5. Replies: 2
    Last Post: 04-14-2007, 12:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •