Open only 1 highslide pupup window if use highslide in a gallery (automatically close the already open window)
1.       Open Highslide-full.js or highslide-with-html.js
which is used in your project.
Add the below hightailed code in Highslide-full.js or highslide-with-html.js
Add the below hightailed code in Highslide-full.js or highslide-with-html.js
hs.Outline
=  function
(outlineType, onLoad) {
   this.onLoad =
onLoad;
   this.outlineType
= outlineType;
   var v =
hs.uaVersion, tr;
   this.hasAlphaImageLoader
= hs.ie && hs.uaVersion < 7;
   if
(!outlineType) {
          if
(onLoad) onLoad();
          return;
   }
   hs.init();
   this.table = hs.createElement(
          'table',
{ 
                 cellSpacing: 0 
          }, {
                 visibility: 'hidden',
                 position: 'absolute',
                 borderCollapse: 'collapse',
                 width: 0
          },
          hs.container,
          true
              ); 
    /****** add this code to generate the Table
Unique ID****************/
    var key = this.key = hs.expanders.length;
    this.table.id="table"+key;
    /*******************************/
    var tbody =
hs.createElement('tbody', null, null, this.table, 1);
   this.td = [];
   for (var i = 0; i <= 8; i++) {
          if (i
% 3 == 0) tr = hs.createElement('tr', null, { height: 'auto'
}, tbody, true);
          this.td[i]
= hs.createElement('td', null, null, tr, true);
          var
style = i != 4 ? { lineHeight: 0, fontSize: 0} : { position : 'relative' };
          hs.setStyles(this.td[i],
style);
   }
   this.td[4].className
= outlineType +' highslide-outline';
   this.preloadGraphic();
};
hs.Expander = function
(a, params, custom, contentType) {
    if (document.readyState && hs.ie &&
!hs.isReady) {
       
hs.addEventListener(document, 'ready',
function () {
            new hs.Expander(a, params, custom, contentType);
        });
        return;
    }
    this.a = a;
    this.custom = custom;
    this.contentType = contentType || 'image';
    this.isHtml = (contentType == 'html');
    this.isImage = !this.isHtml;
   
hs.continuePreloading = false;
    this.overlays = [];
    this.last = hs.last;
    hs.last =
null;
   
hs.init();
    var key = this.key =
hs.expanders.length;
    // override inline parameters
    for (var i = 0; i
< hs.overrides.length; i++) {
        var name = hs.overrides[i];
        this[name] = params && typeof params[name] != 'undefined'
?
                     params[name]
: hs[name];
    }
    if (!this.src) this.src = a.href;
    // get thumb
    var el = (params && params.thumbnailId) ?
hs.$(params.thumbnailId) : a;
    el = this.thumb = el.getElementsByTagName('img')[0] || el;
    this.thumbsUserSetId = el.id || a.id;
    if (!hs.fireEvent(this,
'onInit')) return
true;
    // check if already open
    for (var i = 0; i
< hs.expanders.length; i++) {
        if (hs.expanders[i] && hs.expanders[i].a == a
                     &&
!(this.last && this.transitions[1]
== 'crossfade')) {
           
hs.expanders[i].focus();
            return false;
        }
    }
    // cancel other
    if (!hs.allowSimultaneousLoading) for (var i = 0; i
< hs.expanders.length; i++) {
        if (hs.expanders[i] && hs.expanders[i].thumb
!= el && !hs.expanders[i].onLoadStarted) {
           
hs.expanders[i].cancelLoading();
        }
    }
   
hs.expanders[key] = this;
    if (!hs.allowMultipleInstances &&
!hs.upcoming) {
        if (hs.expanders[key - 1]) hs.expanders[key -
1].close();
        if (typeof
hs.focusKey != 'undefined' &&
hs.expanders[hs.focusKey])
            hs.expanders[hs.focusKey].close();
    }
    // initiate metrics
    this.el = el;
    this.tpos = this.pageOrigin
|| hs.getPosition(el);
   
hs.getPageSize();
    var x = this.x = new hs.Dimension(this,
'x');
   
x.calcThumb();
    var y = this.y = new hs.Dimension(this,
'y');
   
y.calcThumb();
    if (/area/i.test(el.tagName)) this.getImageMapAreaCorrection(el);
    this.wrapper = hs.createElement(
              'div', {
                  id: 'highslide-wrapper-'
+ this.key,
                  className: 'highslide-wrapper
' + this.wrapperClassName
              },
{
                  visibility: 'hidden',
                  position: 'absolute',
                  zIndex: hs.zIndexCounter += 2
              },
null, true);
    this.wrapper.onmouseover = this.wrapper.onmouseout
= hs.wrapperMouseHandler;
    if (this.contentType
== 'image' && this.outlineWhileAnimating == 2)
        this.outlineWhileAnimating = 0;
    /*************Automatically close the already open window
********************************************/
    if (key > 0) {
        var chkid = "highslide-wrapper-";
        for (var i = 0; i
< key; i++) {
            var ctrldiv = document.getElementById(chkid + i);
            hs.close(ctrldiv);
        }
    }
    /*********************************************************/
    // get the outline
    if (!this.outlineType
              ||
(this.last && this.isImage
&& this.transitions[1] == 'crossfade')) {
        this[this.contentType
+ 'Create']();
    } else if
(hs.pendingOutlines[this.outlineType]) {
        this.connectOutline();
        this[this.contentType
+ 'Create']();
    } else {
        this.showLoading();
        var exp = this;
        new hs.Outline(this.outlineType,
                     function () {
                         exp.connectOutline();
                         exp[exp.contentType + 'Create']();
                     }
              );
    }
    return true;
};
Comments
Post a Comment