Changing options on a per link basis.

classic Classic list List threaded Threaded
35 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Changing options on a per link basis.

kairun
I see "However, options may also be used on a per-link basis as described on the usage page." on the options page but I don't see anything about it and I can't figure it out.

I checked the history of the forums and saw a few people mention rel="shadowbox;options={xxxx:xxxxx;}" but that doesn't seem to work for me either.

Can anyone help me out?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

kairun
I see people posting the same code as in here: http://shadowbox-js.com/forum.html#nabble-td2643171%7Ca2643171

I've tried many variations, shadowbox still works, but the options aren't taking effect.

Is this something I need to buy the licensed version for?
Oz
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Oz

I've run into the same issue today, and have been searching around trying to figure out if my syntax is wrong or something, but everything I've seen seems to indicate that it's alright:

<a href='MyImage.gif' rel='shadowbox;options={ handleOversize:drag }'>link to my image</a>

Like Kairun, I find that Shadowbox works just fine; it's just that any options I specify on a per-link basis are ignored.

Just to be sure I wasn't completely crazy, I tried various options in my Shadowbox.init that I'd tried at the link level, and all of them worked just fine.

Help, please, anyone!

Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Richard Hart
In reply to this post by kairun
I think I read in some release notes for V3.0.3 that the ability to include options in the html has been removed. I think you must use javascript for any desired options now. I can't find those release notes now, but I think I read them, written by M. Jackson, on the github.com site.
Oz
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Oz
Thanks for the info, Richard.

Did M. Jackson offer any recommendations as to the best way one might specify per-link options using JavaScript, if indeed the per-link method is no longer available? Do you have any suggestions yourself?

I'm actually trying to specify the execution of a particular function with the 'onOpen' option for just a few specific links (not every one which uses Shadowbox), and it would have been super-easy to do so right in the link. Now it seems that I might be faced with dreaming up some (perhaps not-so-easy) JavaScript code to get the job done.

Any help you could provide would be greatly appreciated.

Austin.
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Richard Hart
I think you can use onclick with and a tag like this

"<aa href="xyz.html" onClick="shadowFn('mypage.html';">link text"

You will need to replace xyz.html with the current page, because otherwise your click will take to the page in the href option and also the page in the onClick  function, with shadowbox.

Then in the head section define the function:

<script type="text/javascript"> shadowFn(file) { // Open a web page in a shadowbox. Shadowbox.open({ content: } + file + {, player: "iframe", title: "Web Pages", height: 350, width: 350 }); </script>
This is probably not quite right. I haven't tried it. I expect that my handling of the file argument in the function is probably wrong, and there may be some other errors, as I seldom can write javascript from memory and must use cut paste methods to get the syntax correct.
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

BenHC4
I too have encountered this problem, identical to how others have described. Any ideas on a workaround? I have just one image that I need to apply handleOversize:'drag' to and cannot for the life of me get it to work. Help!
m
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

m
...exactly the same problem here. sb v3.0.3 completely ignores the per-link options.
it would be really great if someone knows a workaround/solution for that prob.
can't find anything on the website.
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Peter
In reply to this post by BenHC4
I am also highly interested in a solution for that. I tried to figure out how the examples (drag - tiger) work on the shadowbox-js.com site - but somehow I can't descry it...
Any suggestions/tutorials for that problem would be great.
-P
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

otheroom
Yes, this is very strange that this functionality has been removed. I'm posting so that I can keep tabs on a solution as well.
Oz
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Oz

After hours of trying different ways of invoking the per-link options (thinking that somehow my syntax might have been bad), I finally resigned myself to the idea that this functionality must have been removed from Shadowbox.

So, I rolled up my sleeves and came up with the following method, which works well, although requires a little more "manual labor" when setting up my links.

I simply created a JavaScript function which accepts a few parameter values via the link's onclick event, then passes the values to Shadowbox.open. Unfortunately, as regards options, I had some trouble trying to pass a bunch of them to the function as one string (I kept getting JavaScript errors which I wasn't sure how to resolve). Therefore, the method I'm using only allows you to specify the value for certain, pre-defined options, and pass them in separately. Of course, if the option(s) you need to change on a per-link basis are always the same, this method will work out just fine.

In the sample code below, I'm getting values for the 'overlayOpacity', 'animate' and 'animateFade' options, in addition to the specified content, gallery, player type, height and width:

function openSB(myContent, myGallery, myPlayer, myH, myW, myOpac, myAnim, myFade) {

    Shadowbox.open({ content: myContent, gallery: myGallery, player: myPlayer, height: myH, width: myW, options: { overlayOpacity: myOpac, animate: myAnim, animateFade: myFade } });
    return false;

}

The links in my pages look like this:

<a href="mypath/mypage.htm" onclick="openSB(this.href, 'coolpages', 'iframe', 300, 400, '0.2', false, false);">my link text</a>

So, the link above opens 'mypage.htm' as part of the 'coolpages' gallery in a Shadowbox iframe that's 300px high and 400px wide. The Shadowbox overlay opacity is 20% and the iframe does not open with animation, nor does the overlay fade in or out.

For any "standard" Shadowbox links, I stick with the usual method of setting the rel attribute to "shadowbox" and just let Shadowbox do its thing.


Now, what I *really* wanted to do was pass all those option values to the function as one string, like 'overlayOpacity: 0.2, animate: false, animateFade: false'. That way, you could specify any options you want for any given link. The function would then look like the following:

NOTE: DOES NOT WORK

function openSB(myContent, myGallery, myPlayer, myH, myW, myOptions) {

    Shadowbox.open({ content: myContent, gallery: myGallery, player: myPlayer, height: myH, width: myW, options: { myOptions } });
    return false;

}

... and the links would look like this:

NOTE: DOES NOT WORK

<a href="mypath/mypage.htm" onclick="openSB(this.href, 'coolpages', 'iframe', 300, 400, 'overlayOpacity: 0.2, animate: false, animateFade: false');">my link text</a>

Any suggestions as to how to make this latter method actually work?

Oz

Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Sally
...ok i'll go with shadowbox 2 again. can't get it work with 3.0.3 :( :(
Dan
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Dan
anybody a clue? mike?
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

kairun
Bump, this feature would be really nice.
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Kate
mike - could you please post a tutorial about how to change options (e.g. drag, ....) on a per link basis? there is no such description on your homepage.
thanks a lot in advance!
-k
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

kairun
In reply to this post by kairun
Still nothing so far.  Hopefully somebody finds a simple workaround.
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

TheCosmonaut
Does anyone have a link to Shadowbox 3.0.2? Hate using older versions but I need iframes to work...
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

kairun
In reply to this post by kairun
I need help with this too.
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

Eric
In reply to this post by kairun
It's no solution for all, but in some cases the following will do the trick:

// skip auto setup in the init function
Shadowbox.init({
    skipSetup: true
});

// use pseudo-css class selectors in 'manual' setup
window.onload = function() {

    Shadowbox.setup("a.drag", {
        handleOversize: "drag"
    });

    Shadowbox.setup("a.res", {
        handleOversize: "resize"
    });

};

// make sure that all your Shadowbox links have a corresponding class name:

<a class="drag" href="your/image" rel="shadowbox">
// will be draggable

<a class="res" href="your/image" rel="shadowbox">
// will resize

       
Reply | Threaded
Open this post in threaded view
|

Re: Changing options on a per link basis.

D.M.
In reply to this post by kairun
bump:

In 2.x we had to manually apply options:

   http://shadowbox-js.1309102.n2.nabble.com/Change-slideshowDelay-during-a-slideshow-tp1311157.html

That also doesn't stopped working in 3.0 :(

Any ideas? I really need to have each link define itself due to mixed media gallery
12