Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2010-02-16 12:36:28

Kaminari
New member
Registered: 2010-02-16
Posts: 5

Wrap windowses (like insert_image.html) in Colorbox

Hello.

I want to wrap popup windowses in jquery plugin named Colorbox http://colorpowered.com/colorbox/

I found out that in dialog.js function (in my browser) [Dialog._geckoOpenModal = function(_7, _8, _9) ... ] is responsible for window.open but it's kinda wierd. I don't fully understand how it works.
Colorbox can show iframed content so i think it's possible and should be easy to implement however it's not easy. Script first opens a blank window and then rest of variables.

Could someone point me wich parts of code should i change to painlessly wrap windowses in colorbox?

Offline

#2 2010-02-16 23:48:28

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Wrap windowses (like insert_image.html) in Colorbox

You are looking at compressed files.  Do not look at compressed files.  Use latest trunk.


James Sleeman

Offline

#3 2010-02-16 23:55:32

Kaminari
New member
Registered: 2010-02-16
Posts: 5

Re: Wrap windowses (like insert_image.html) in Colorbox

Of course I have uncompressed files but this one is not important though. I managed to open these windowses in Colorbox by placing statement:

parent.$.fn.colorbox({href: url, iframe:true,width:'960px',height:'500px', onLoad: function() { }});

inside a:
function Dialog(url, action, init){...}

But then there are 2 problems.
1. I dont know how to close colorbox from inside of iframe.
2. I dont know how to pass parameters to Xinha in function:

http://wklej.org/hash/f118f118a58/
in insert_image.html

More specific:
in function
function __dlg_close(val){
    opener.Dialog._return(val);   <-this line does not work.
    window.close();
}

in popup.js.

Offline

#4 2010-02-19 08:12:28

Kaminari
New member
Registered: 2010-02-16
Posts: 5

Re: Wrap windowses (like insert_image.html) in Colorbox

So, anyone has ever tryed? Lightbox? Thightbox? Shadowbox? Anything?

Offline

#5 2010-02-20 06:38:35

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Wrap windowses (like insert_image.html) in Colorbox

Probably you will need to write your own Xinha.Dialog really, I think you roughly need these methods,
* the constructor
* show
* hide
* onresize
* toggle
* setValues
* getValues
* getElementById
* getElementsByName

look at modules/Dialogs/XinhaDialog.js and also modules/Dialogs/div-dialog.js

You will need your dialog to be called Xinha.Dialog so that it is the default, I think you would be able to, AFTER extending (see div dialog) and BEFORE loading the rest of Xinha.

Xinha.Dialog = MyDialog;

I think it should work, but you may need to tweak Xinha a bit perhaps.


James Sleeman

Offline

#6 2010-02-20 06:42:05

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Wrap windowses (like insert_image.html) in Colorbox

Oh wait, you're asking about the popup windows.

If you are using an iframe, they do not have openers I think.  They have parents from memory.  You'll want to use your javascript debugger and inspect exactly what is available to you, but probably changing opener to parent will get you somewhere.


James Sleeman

Offline

#7 2010-02-20 09:56:46

Kaminari
New member
Registered: 2010-02-16
Posts: 5

Re: Wrap windowses (like insert_image.html) in Colorbox

Yes, iframes dont have openers but parents don't work either. I mean, they SHOULD work but they don't in specific place:

function __dlg_close(val){
    opener.Dialog._return(val);   <-this line does not work.
    window.close();
}

I tried debugging but there's no such thing as parent.Dialog, nor parent._return

I think this would be good thing for xinha but i don't know how to get to returning methods from iframe. Maybe someone would want to help me?
This is really easy. First, jquery, second colorbox, and then xinha.
And only one method:

parent.$.fn.colorbox({href: url, iframe:true,width:'960px',height:'500px', onLoad: function() { }}); OR
$.fn.colorbox({href: url, iframe:true,width:'960px',height:'500px', onLoad: function() { }});
//they should both work

inside a:
function Dialog(url, action, init){...}

Offline

#8 2010-02-20 20:37:27

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Wrap windowses (like insert_image.html) in Colorbox

You will need to examine the scope in __dlg_close at that point and see what is available.  It will be there somewhere.  window.parent, window.opener, something.


James Sleeman

Offline

#9 2010-02-21 09:04:42

Kaminari
New member
Registered: 2010-02-16
Posts: 5

Re: Wrap windowses (like insert_image.html) in Colorbox

I already did this, Google Chrome tells me that there are only 2 vars available:
'val' and 'this'.

'THIS' is a global scope of iframe i guess wich means I have access to everything yet I cant find such metods within 'this' scope nor 'this.parent' - another global scope from parent of iframe. I'll try again and maybe give a screenshot

Offline

#10 2010-02-21 21:22:07

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Wrap windowses (like insert_image.html) in Colorbox

You are obviously only seeing local scope variables, you need to look at the wider picture, there are probably hundreds of other properties than val and this available to you there!  window for a start is always available.

Try with firebug.


James Sleeman

Offline

Board footer

Powered by FluxBB