Hi,

Im trying to use some customs settings like returnFocus or overlayClose, but they arent applied when Im doing it like that :

print "<a href='?width=686&returnFocus=false&overlayClose=false&inline=true#overlay_windows_".$node->nid."' class='colorbox-inline'>".$element['#title']."</a><div id='hidden_overlay_windows' style='display: none'><div id='overlay_windows_".$node->nid."'>".$output2."</div></div>";

Do Im doing something wrong or thats a bug ?

Thanks,
Regards,
Xiaodoudou

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xiaodoudou’s picture

Category: bug » feature
Status: Active » Needs work

That's normal in fact, because this settings aren't coded to be passed by URL.

on the colorbox_inline.js :

(function ($) {

Drupal.behaviors.initColorboxInline = {
  attach: function (context, settings) {
    if (!$.isFunction($.colorbox)) {
      return;
    }
    $.urlParam = function(name, url){
      if (name == 'fragment') {
        var results = new RegExp('(#[^&#]*)').exec(url);
      }
      else {
        var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
      }
      if (!results) { return ''; }
      return results[1] || '';
    };
    $('a, area, input', context).filter('.colorbox-inline').once('init-colorbox-inline-processed').colorbox({
      transition:settings.colorbox.transition,
      speed:settings.colorbox.speed,
      opacity:settings.colorbox.opacity,
      slideshow:settings.colorbox.slideshow,
      slideshowAuto:settings.colorbox.slideshowAuto,
      slideshowSpeed:settings.colorbox.slideshowSpeed,
      slideshowStart:settings.colorbox.slideshowStart,
      slideshowStop:settings.colorbox.slideshowStop,
      current:settings.colorbox.current,
      previous:settings.colorbox.previous,
      next:settings.colorbox.next,
      close:settings.colorbox.close,
      overlayClose:settings.colorbox.overlayClose,
      maxWidth:settings.colorbox.maxWidth,
      maxHeight:settings.colorbox.maxHeight,
      innerWidth:function(){
        return $.urlParam('width', $(this).attr('href'));
      },
      innerHeight:function(){
        return $.urlParam('height', $(this).attr('href'));
      },
      title:function(){
        return decodeURIComponent($.urlParam('title', $(this).attr('href')));
      },
      iframe:function(){
        return $.urlParam('iframe', $(this).attr('href'));
      },
      inline:function(){
        return $.urlParam('inline', $(this).attr('href'));
      },
      href:function(){
        return $.urlParam('fragment', $(this).attr('href'));
      }
    });
  }
};

})(jQuery);

As we can see online this parameters are read from the url query : href iframe inline title innerWidth innerHeight

Is that possible we add that as a feature ?

frjo’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Needs work » Active

Submit a patch and I will take a look at it.

kaidjohnson’s picture

Status: Active » Needs review
FileSize
648 bytes

On a slightly different, but related idea, we're finding that the use of colorbox inline for the views trigger field disregards a few of the global colorbox settings, thus making it harder to hook into the colorbox settings to alter the output or result of the colorbox style. The specific case we're working on is for the title field (caption). We are overriding the colorbox title function with our own function to provide additional html markup for more custom styling, but our views colorbox trigger fields don't get this markup applied.

I propose taking a look at the colorbox inline handling to make it less explicit in each defined call, parsing the url parameters, setting the appropriate attribute, then invoking the colorbox settings to allow users to hook into the functions as normal. This concept normalizes the colorbox settings across instances throughout a site, which I think is a big plus, but still allows inline instances to override or set instance-specific settings.

This patch provides a sample of what I'm thinking, which could, be applied to each colorbox setting, thus solving xiaodoudou's issue and mine, although they're opposite sides of the same coin. I'd be happy to flesh out the concept in a more complete patch, if you'd like.

kaidjohnson’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
FileSize
729 bytes

After some more playing around with this concept, I realize the the patch in #3 will throw an error when settings.colorbox.title is undefined, which it is by default, which in turn breaks colorbox altogether. That's obviously no good...

Here's a revised version that checks if there is a custom settings.colorbox.title, and if so, it uses it, otherwise simply returns the title parsed from the url.

Neslee Canil Pinto’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)