").addClass("fr-thumbnails"))));
this.loading = new Loading(this);
if (u.IE && u.IE < 7) {
var s = this.element[0].style;
s.position = "absolute";
s.setExpression("top", "((!!window.jQuery ? jQuery(window).scrollTop() : 0) + 'px')");
s.setExpression("left", "((!!window.jQuery ? jQuery(window).scrollLeft() : 0) + 'px')")
}
if (u.IE) {
if (u.IE < 9) {
this.element.addClass("fr-oldIE")
}
for (var i = 6; i <= 9; i++) {
if (u.IE < i) {
this.element.addClass("fr-ltIE" + i)
}
}
}
if (E.touch) {
this.element.addClass("fr-touch-enabled")
}
if (E.mobileTouch) {
this.element.addClass("fr-mobile-touch-enabled")
}
this.element.data("class-skinless", this.element[0].className);
K.initialize(this.element);
J.initialize(this.element);
I.initialize();
this.element.hide()
},
setSkin: function(a, b) {
b = b || {};
if (a) {
b.skin = a
}
this.overlay.setSkin(a);
var c = this.element.data("class-skinless");
this.element[0].className = c + " fr-window-" + a;
return this
},
setDefaultSkin: function(a) {
if (t.skins[a]) {
this.defaultSkin = a
}
},
startObserving: function() {
$(document.documentElement).delegate(".fresco[href]", "click", function(a, b) {
if (L._disabled) {
return
}
a.stopPropagation();
a.preventDefault();
var b = a.currentTarget;
J.setXY({
x: a.pageX,
y: a.pageY
});
L.show(b)
});
$(document.documentElement).bind("click", function(a) {
J.setXY({
x: a.pageX,
y: a.pageY
})
});
this.element.delegate(".fr-ui-spacer, .fr-box-spacer", "click", $.proxy(function(a) {
a.stopPropagation()
}, this));
$(document.documentElement).delegate(".fr-overlay, .fr-ui, .fr-frame, .fr-bubble", "click", $.proxy(function(a) {
var b = H.view;
if ($(a.target).closest(".fr-info")[0]) {
return
}
if (b) {
var c = b.options;
if (c.overlay && !c.overlay.close) {
return
}
}
a.preventDefault();
a.stopPropagation();
H.hide()
}, this));
this.element.bind("fresco:mousewheel", function(a) {
a.preventDefault()
})
},
load: function(b, c) {
var d = $.extend({}, arguments[2] || {});
this._reset();
this._loading = true;
var e = b.length < 2;
$.each(b, function(i, a) {
if (!a.options.thumbnail) {
e = true;
return false
}
});
if (e) {
$.each(b, function(i, a) {
a.options.thumbnail = false;
a.options.thumbnails = false
})
}
if (b.length < 2) {
var f = b[0].options.onClick;
if (f && f != "close") {
b[0].options.onClick = "close"
}
}
this.views = b;
K.load(b);
J.load(b);
I.enabled = {
esc: true
};
if (c) {
this.setPosition(c, $.proxy(function() {
if (!this._loading) {
return
}
this._loading = false;
if (d.callback) {
d.callback()
}
}, this))
}
},
hideOverlapping: function() {
if (this.states.get("overlapping")) {
return
}
var c = $("embed, object, select");
var d = [];
c.each(function(i, a) {
var b;
if ($(a).is("object, embed") && ((b = $(a).find('param[name="wmode"]')[0]) && b.value && b.value.toLowerCase() == "transparent") || $(a).is("[wmode='transparent']")) {
return
}
d.push({
element: a,
visibility: $(a).css("visibility")
})
});
$.each(d, function(i, a) {
$(a.element).css({
visibility: "hidden"
})
});
this.states.set("overlapping", d)
},
restoreOverlapping: function() {
var b = this.states.get("overlapping");
if (b && b.length > 0) {
$.each(b, function(i, a) {
$(a.element).css({
visibility: a.visibility
})
})
}
this.states.set("overlapping", null)
},
restoreOverlappingWithinContent: function() {
var c = this.states.get("overlapping");
if (!c) {
return
}
$.each(c, $.proxy(function(i, a) {
var b;
if ((b = $(a.element).closest(".fs-content")[0]) && b == this.content[0]) {
$(a.element).css({
visibility: a.visibility
})
}
}, this))
},
show: (function() {
var e = function() {};
return function(b) {
var c = J._frames && J._frames[J._position - 1],
shq = this.queues.showhide,
duration = (c && c.view.options.effects.window.hide) || 0;
if (this.states.get("visible")) {
if ($.type(b) == "function") {
b()
}
return
}
this.states.set("visible", true);
shq.queue([]);
this.hideOverlapping();
if (c && $.type(c.view.options.onShow) == "function") {
c.view.options.onShow.call(t)
}
var d = 2;
shq.queue($.proxy(function(a) {
if (c.view.options.overlay) {
this.overlay.show($.proxy(function() {
if (--d < 1) {
a()
}
}, this))
}
this.timeouts.set("show-window", $.proxy(function() {
this._show(function() {
if (--d < 1) {
a()
}
})
}, this), duration > 1 ? Math.min(duration * 0.5, 50) : 1)
}, this));
e();
shq.queue($.proxy(function(a) {
I.enable();
a()
}, this));
shq.queue($.proxy(function(a) {
K.unblock();
a()
}, this));
if ($.type(b) == "function") {
shq.queue($.proxy(function(a) {
b();
a()
}), this)
}
}
})(),
_show: function(a) {
J.resize();
if (E.mobileTouch) {
this._restoreScroll = {
top: this.element.css("top")
};
H.element.css({
top: $(window).scrollTop()
})
}
this.element.show();
this.bubble.stop(true);
var b = J._frames && J._frames[J._position - 1];
this.setOpacity(1, b.view.options.effects.window.show, $.proxy(function() {
if (a) {
a()
}
}, this));
return this
},
hide: function() {
var c = J._frames && J._frames[J._position - 1],
shq = this.queues.showhide;
shq.queue([]);
this.stopQueues();
this.loading.stop(null, true);
var d = 1;
shq.queue($.proxy(function(a) {
var b = c.view.options.effects.window.hide || 0;
this.bubble.stop(true, true).fadeOut(b, "easeInSine", $.proxy(function() {
this.element.hide();
J.hideAll();
if (--d < 1) {
this._hide();
a()
}
}, this));
if (c.view.options.overlay) {
d++;
this.timeouts.set("hide-overlay", $.proxy(function() {
this.overlay.hide($.proxy(function() {
if (--d < 1) {
this._hide();
a()
}
}, this))
}, this), b > 1 ? Math.min(b * 0.5, 150) : 1)
}
}, this))
},
_hide: function() {
this.states.set("visible", false);
this.restoreOverlapping();
I.disable();
K.block();
var a = J._frames && J._frames[J._position - 1];
if (a && $.type(a.view.options.afterHide) == "function") {
a.view.options.afterHide.call(t)
}
this.timeouts.clear();
this._reset()
},
_reset: function() {
var a = $.extend({
after: false,
before: false
}, arguments[0] || {});
if ($.type(a.before) == "function") {
a.before.call(t)
}
this.stopQueues();
this.timeouts.clear();
this.position = -1;
this.views = null;
K.clear();
if (E.mobileTouch && this._restoreScroll) {
this.element.css(this._restoreScroll)
}
this._loading = false;
H.states.set("_m", false);
if (this._m) {
$(this._m).stop().remove();
this._m = null
}
if (this._s) {
$(this._s).stop().remove();
this._s = null
}
if ($.type(a.after) == "function") {
a.after.call(t)
}
},
setOpacity: function(a, b, c) {
this.bubble.stop(true, true).fadeTo(b || 0, a || 1, "easeOutSine", c)
},
stopQueues: function() {
this.queues.update.queue([]);
this.bubble.stop(true)
},
setPosition: function(a, b) {
if (!a || this.position == a) {
return
}
this.timeouts.clear("_m");
var c = this._position;
this.position = a;
this.view = this.views[a - 1];
this.setSkin(this.view.options && this.view.options.skin, this.view.options);
J.setPosition(a, b)
}
};
if ($.type(u.Android) == "number" && u.Android < 3) {
$.each(H, function(a, b) {
if ($.type(b) == "function") {
H[a] = function() {
return this
}
}
})
}
var I = {
enabled: false,
keyCode: {
left: 37,
right: 39,
esc: 27
},
enable: function() {
this.fetchOptions()
},
disable: function() {
this.enabled = false
},
initialize: function() {
this.fetchOptions();
$(document).keydown($.proxy(this.onkeydown, this)).keyup($.proxy(this.onkeyup, this));
I.disable()
},
fetchOptions: function() {
var a = J._frames && J._frames[J._position - 1];
this.enabled = a && a.view.options.keyboard
},
onkeydown: function(a) {
if (!this.enabled || !H.element.is(":visible")) {
return
}
var b = this.getKeyByKeyCode(a.keyCode);
if (!b || (b && this.enabled && !this.enabled[b])) {
return
}
a.preventDefault();
a.stopPropagation();
switch (b) {
case "left":
J.previous();
break;
case "right":
J.next();
break
}
},
onkeyup: function(a) {
if (!this.enabled || !H.views) {
return
}
var b = this.getKeyByKeyCode(a.keyCode);
if (!b || (b && this.enabled && !this.enabled[b])) {
return
}
switch (b) {
case "esc":
H.hide();
break
}
},
getKeyByKeyCode: function(a) {
for (var b in this.keyCode) {
if (this.keyCode[b] == a) {
return b
}
}
return null
}
};
var J = {
initialize: function(a) {
if (!a) {
return
}
this.element = a;
this._position = -1;
this._visible = [];
this._sideWidth = 0;
this._tracking = [];
this._preloaded = [];
this.queues = [];
this.queues.sides = $({});
this.frames = this.element.find(".fr-frames:first");
this.move = this.element.find(".fr-frames-move:first");
this.uis = this.element.find(".fr-uis:first");
this.setOrientation(getOrientation());
this.updateDimensions();
this.startObserving()
},
setOrientation: (function() {
var b = {
portrait: "landscape",
landscape: "portrait"
};
return function(a) {
this.frames.addClass("fr-frames-" + a).removeClass("fr-frames-" + b[a])
}
})(),
startObserving: function() {
$(window).bind("resize", $.proxy(function() {
if (H.states.get("visible")) {
this.resize()
}
}, this));
$(window).bind("orientationchange", $.proxy(function() {
this.setOrientation(getOrientation());
if (H.states.get("visible")) {
this.resize()
}
}, this));
this.frames.delegate(".fr-side", "click", $.proxy(function(a) {
a.stopPropagation();
this.setXY({
x: a.pageX,
y: a.pageY
});
var b = $(a.target).closest(".fr-side").data("side");
this[b]()
}, this))
},
load: function(b) {
if (this._frames) {
$.each(this._frames, function(i, a) {
a.remove()
});
this._frames = null;
this._touched = false;
this._tracking = [];
this._preloaded = []
}
this._sideWidth = 0;
this.move.removeAttr("style");
this._frames = [];
var c = false;
$.each(b, $.proxy(function(i, a) {
this._frames.push(new Frame(a, i + 1));
if (!c && a.caption) {
c = true
}
}, this));
this._noCaptions = !c;
this.updateDimensions()
},
handleTracking: function(a) {
if (u.IE && u.IE < 9) {
this.setXY({
x: a.pageX,
y: a.pageY
});
this.position()
} else {
this._tracking_timer = setTimeout($.proxy(function() {
this.setXY({
x: a.pageX,
y: a.pageY
});
this.position()
}, this), 30)
}
},
clearTrackingTimer: function() {
if (this._tracking_timer) {
clearTimeout(this._tracking_timer);
this._tracking_timer = null
}
},
startTracking: function() {
if (E.mobileTouch || this._handleTracking) {
return
}
this.element.bind("mousemove", this._handleTracking = $.proxy(this.handleTracking, this))
},
stopTracking: function() {
if (E.mobileTouch || !this._handleTracking) {
return
}
this.element.unbind("mousemove", this._handleTracking);
this._handleTracking = null;
this.clearTrackingTimer()
},
setPosition: function(a, b) {
this.clearLoads();
this._position = a;
var c = this._frames[a - 1],
ui = c.view.options.ui;
var d = 1;
this.move.append(c.frame);
this.frames.find(".fr-frame").removeClass("fr-frame-active");
c.frame.addClass("fr-frame-active");
K.setPosition(a);
c.load($.proxy(function() {
if (!c || (c && !c.view)) {
return
}
this.show(a, function() {
if (!c || !c.view) {
return
}
if (b) {
b()
}
if ($.type(c.view.options.afterPosition) == "function" && --d < 1) {
c.view.options.afterPosition.call(t, a)
}
})
}, this));
this.preloadSurroundingImages()
},
preloadSurroundingImages: function() {
if (!(this._frames && this._frames.length > 1)) {
return
}
var d = this.getSurroundingIndexes(),
previous = d.previous,
next = d.next,
images = {
previous: previous != this._position && this._frames[previous - 1],
next: next != this._position && this._frames[next - 1]
};
if (this._position == 1) {
images.previous = null
}
if (this._position == this._frames.length) {
images.next = null
}
var e;
$.each(images, $.proxy(function(a, b) {
var c = b && b.view;
if (c) {
if (c.type == "image" && c.options.preload) {
F.preload(c.url, {
once: true
})
}
}
}, this))
},
getSurroundingIndexes: function() {
if (!this._frames) {
return {}
}
var a = this._position,
length = this._frames.length;
var b = (a <= 1) ? length : a - 1,
next = (a >= length) ? 1 : a + 1;
return {
previous: b,
next: next
}
},
mayPrevious: function() {
var a = J._frames && J._frames[J._position - 1];
return (a && a.view.options.loop && this._frames && this._frames.length > 1) || this._position != 1
},
previous: function(a) {
var b = this.mayPrevious();
if (a || b) {
H.setPosition(this.getSurroundingIndexes().previous)
}
},
mayNext: function() {
var a = J._frames && J._frames[J._position - 1];
return (a && a.view.options.loop && this._frames && this._frames.length > 1) || (this._frames && this._frames.length > 1 && this.getSurroundingIndexes().next != 1)
},
next: function(a) {
var b = this.mayNext();
if (a || b) {
H.setPosition(this.getSurroundingIndexes().next)
}
},
setVisible: function(a) {
if (!this.isVisible(a)) {
this._visible.push(a)
}
},
setHidden: function(b) {
this._visible = $.grep(this._visible, function(a) {
return a != b
})
},
isVisible: function(a) {
return $.inArray(a, this._visible) > -1
},
setXY: function(a) {
a.y -= $(window).scrollTop();
a.x -= $(window).scrollLeft();
if (K.visible() && K._vars.orientation == "vertical") {
a.x -= K._vars.thumbnails.width
}
var b = {
y: Math.min(Math.max(a.y / this._dimensions.height, 0), 1),
x: Math.min(Math.max(a.x / this._dimensions.width, 0), 1)
};
var c = 20;
var d = {
x: "width",
y: "height"
};
var e = {};
$.each("x y".split(" "), $.proxy(function(i, z) {
e[z] = Math.min(Math.max(c / this._dimensions[d[z]], 0), 1);
b[z] *= 1 + 2 * e[z];
b[z] -= e[z];
b[z] = Math.min(Math.max(b[z], 0), 1)
}, this));
this.setXYP(b)
},
setXYP: function(a) {
this._xyp = a
},
position: function() {
if (this._tracking.length < 1) {
return
}
$.each(this._tracking, function(i, a) {
a.position()
})
},
resize: function() {
if (!(u.IE && u.IE < 7)) {
K.resize()
}
this.updateDimensions();
this.frames.css(px(this._dimensions));
$.each(this._frames, function(i, a) {
a.resize()
});
if (E.mobileTouch) {
this.frames.css({
width: "100%"
});
H.overlay.max()
}
},
updateDimensions: function(e) {
var f = B.viewport(),
ui = this._frames && this._frames[0].view.options.ui;
if (K.visible()) {
K.updateVars();
var g = K._vars.orientation == "horizontal",
subtract = g ? "height" : "width",
subtractPx = K._vars.thumbnails[subtract],
offset = {
left: g ? 0 : subtractPx
};
f[subtract] -= subtractPx;
this.frames.css(px(offset))
} else {
this.frames.removeAttr("style")
}
var h = $.extend({}, f);
this._sideWidth = 0;
switch (ui) {
case "outside":
$.each(this._frames, $.proxy(function(i, b) {
H.element.show();
var c = false;
b._whileVisible(function() {
c = b.close.is(":visible")
});
elements = b.close;
if (this._frames.length > 1) {
if (b._pos) {
elements = elements.add(b._pos)
}
if (b._next_button) {
elements = elements.add(b._next_button)
}
}
var d = 0;
b._whileVisible(function() {
$.each(elements, function(i, a) {
d = Math.max(d, $(a).outerWidth(true))
})
});
this._sideWidth = Math.max(this._sideWidth, d) || 0
}, this));
h.width -= 2 * (this._sideWidth || 0);
break
}
this._dimensions = f;
this._boxDimensions = h;
this._top = top
},
pn: function() {
return {
previous: this._position - 1 > 0,
next: this._position + 1 <= this._frames.length
}
},
show: function(b, c) {
var d = [];
$.each(this._frames, function(i, a) {
if (a._position != b) {
d.push(a)
}
});
var e = d.length + 1;
var f = this._frames[this._position - 1];
K[f.view.options.thumbnails ? "show" : "hide"]();
this.resize();
var g = f.view.options.effects.content.sync;
$.each(d, $.proxy(function(i, a) {
a.hide($.proxy(function() {
if (!g) {
if (e-- <= 2) {
this._frames[b - 1].show(c)
}
} else {
if (c && e-- <= 1) {
c()
}
}
}, this))
}, this));
if (g) {
this._frames[b - 1].show(function() {
if (c && e-- <= 1) {
c()
}
})
}
},
hideAll: function() {
$.each(this._visible, $.proxy(function(j, i) {
var a = this._frames[i - 1];
a._removeVideo();
a.hide()
}, this));
K.hide();
this.setXY({
x: 0,
y: 0
})
},
hideAllBut: function(b) {
$.each(this._frames, $.proxy(function(i, a) {
if (a.position != b) {
a.hide()
}
}, this))
},
setTracking: function(a) {
if (!this.isTracking(a)) {
this._tracking.push(this._frames[a - 1]);
if (this._tracking.length == 1) {
this.startTracking()
}
}
},
clearTracking: function() {
this._tracking = []
},
removeTracking: function(b) {
this._tracking = $.grep(this._tracking, function(a) {
return a._position != b
});
if (this._tracking.length < 1) {
this.stopTracking()
}
},
isTracking: function(b) {
var c = false;
$.each(this._tracking, function(i, a) {
if (a._position == b) {
c = true;
return false
}
});
return c
},
bounds: function() {
var a = this._dimensions;
if (H._scrollbarWidth) {
a.width -= scrollbarWidth
}
return a
},
clearLoads: function() {
$.each(this._frames, $.proxy(function(i, a) {
a.clearLoad()
}, this))
}
};
function Frame() {
this.initialize.apply(this, v.call(arguments))
}
$.extend(Frame.prototype, {
initialize: function(a, b) {
this.view = a;
this._position = b;
this._dimensions = {};
this.build()
},
remove: function() {
this.clearUITimer();
if (this._track) {
J.removeTracking(this._position);
this._track = false
}
this._removeVideo();
this._reset();
this.frame.remove();
this.frame = null;
if (this.ui) {
this.ui.remove();
this.ui = null
}
this.view = null;
this._dimensions = {};
this.clearLoad()
},
build: function() {
var b = this.view.options.ui,
positions = H.views.length;
J.move.append(this.frame = $("
").addClass("fr-frame").append(this.box = $("
").addClass("fr-box").addClass("fr-box-has-ui-" + b).addClass("fr-box-has-type-" + this.view.type)));
this.box.append(this.box_spacer = $("
").addClass("fr-box-spacer").append(this.box_padder = $("
").addClass("fr-box-padder").append(this.box_outer_border = $("
").addClass("fr-box-outer-border").append(this.box_wrapper = $("
").addClass("fr-box-wrapper")))));
if (this.view.type == "image" && b != "touch") {
this.download_image = $("
").addClass("fr-download-image")
}
this.frame.show();
var c = this.view.options.onClick;
if (this.view.type == "image" && ((c == "next" && (this.view.options.loop || (!this.view.options.loop && this._position != H.views.length))) || c == "close")) {
this.frame.addClass("fr-frame-onclick-" + c.toLowerCase())
}
if (b == "outside") {
this.frame.prepend(this.ui = $("
").addClass("fr-ui fr-ui-outside"))
} else {
this.frame.append(this.ui = $("
").addClass("fr-ui fr-ui-inside"))
}
this.box_spacer.bind("click", $.proxy(function(a) {
if (a.target == this.box_spacer[0] && this.view.options.overlay && this.view.options.overlay.close) {
H.hide()
}
}, this));
if (this.view.options.ui == "outside") {
this.ui.append(this.ui_wrapper = $("
").addClass("fr-ui-wrapper-outside"))
} else {
this.ui.append(this.ui_spacer = $("
").addClass("fr-ui-spacer").append(this.ui_padder = $("
").addClass("fr-ui-padder").append(this.ui_outer_border = $("
").addClass("fr-ui-outer-border").append(this.ui_toggle = $("
").addClass("fr-ui-toggle").append(this.ui_wrapper = $("
").addClass("fr-ui-wrapper"))))));
if (this.download_image) {
this.ui_wrapper.append(this.download_image.clone())
}
}
if (positions > 1) {
this.ui_wrapper.append(this._next = $("
").addClass("fr-side fr-side-next").append(this._next_button = $("
").addClass("fr-side-button").append($("
").addClass("fr-side-button-icon"))).data("side", "next"));
if (this._position == positions && !this.view.options.loop) {
this._next.addClass("fr-side-disabled");
this._next_button.addClass("fr-side-button-disabled")
}
this.ui_wrapper.append(this._previous = $("
").addClass("fr-side fr-side-previous").append(this._previous_button = $("
").addClass("fr-side-button").append($("
").addClass("fr-side-button-icon"))).data("side", "previous"));
if (this._position == 1 && !this.view.options.loop) {
this._previous.addClass("fr-side-disabled");
this._previous_button.addClass("fr-side-button-disabled")
}
}
if (this.download_image && this.view.options.ui == "inside") {
this.ui_wrapper.find(".fr-side").prepend(this.download_image.clone())
}
this.frame.addClass("fr-no-caption");
if (this.view.caption || (this.view.options.ui == "inside" && !this.view.caption)) {
this[this.view.options.ui == "inside" ? "ui_wrapper" : "frame"].append(this.info = $("
").addClass("fr-info fr-info-" + this.view.options.ui).append(this.info_background = $("
").addClass("fr-info-background")).append(this.info_padder = $("
").addClass("fr-info-padder")))
}
if (this.view.caption) {
this.frame.removeClass("fr-no-caption").addClass("fr-has-caption");
this.info_padder.append(this.caption = $("
").addClass("fr-caption").html(this.view.caption))
}
if (positions > 1 && this.view.options.position) {
var d = this._position + " / " + positions;
this.frame.addClass("fr-has-position");
var b = this.view.options.ui;
this[b == "inside" ? "info_padder" : "ui_wrapper"][b == "inside" ? "prepend" : "append"](this._pos = $("
").addClass("fr-position").append($("
").addClass("fr-position-background")).append($("
").addClass("fr-position-text").html(d)))
}
this.ui_wrapper.append(this.close = $("").addClass("fr-close").bind("click", function() {
H.hide()
}).append($("
").addClass("fr-close-background")).append($("").addClass("fr-close-icon")));
if (this.view.type == "image" && this.view.options.onClick == "close") {
this[this.view.options.ui == "outside" ? "box_wrapper" : "ui_padder"].bind("click", function(a) {
if ($(a.target).closest(".fr-info")[0]) {
return
}
a.preventDefault();
a.stopPropagation();
H.hide()
})
}
this.frame.hide()
},
_getInfoHeight: function(a) {
if (!this.view.caption) {
return 0
}
if (this.view.options.ui == "outside") {
a = Math.min(a, J._boxDimensions.width)
}
var b, info_pw = this.info.css("width");
this.info.css({
width: a + "px"
});
b = parseFloat(this.info.css("height"));
this.info.css({
width: info_pw
});
return b
},
_whileVisible: function(b, c) {
var d = [];
var e = H.element.add(H.bubble).add(this.frame).add(this.ui);
if (c) {
e = e.add(c)
}
$.each(e, function(i, a) {
d.push({
visible: $(a).is(":visible"),
element: $(a).show()
})
});
b();
$.each(d, function(i, a) {
if (!a.visible) {
a.element.hide()
}
})
},
getLayout: function() {
this.updateVars();
var d = this._dimensions.max,
ui = this.view.options.ui,
fit = this._fit,
i = this._spacing,
border = this._border;
var e = C.within(d, {
fit: fit,
ui: ui,
border: border
});
var f = $.extend({}, e),
contentPosition = {
top: 0,
left: 0
};
if (border) {
f = C.within(f, {
bounds: e,
ui: ui
});
e.width += 2 * border;
e.height += 2 * border
}
if (i.horizontal || i.vertical) {
var g = $.extend({}, J._boxDimensions);
if (border) {
g.width -= 2 * border;
g.height -= 2 * border
}
g = {
width: Math.max(g.width - 2 * i.horizontal, 0),
height: Math.max(g.height - 2 * i.vertical, 0)
};
f = C.within(f, {
fit: fit,
bounds: g,
ui: ui
})
}
var h = {
caption: true
},
cfitted = false;
if (ui == "outside") {
var i = {
height: e.height - f.height,
width: e.width - f.width
};
var j = $.extend({}, f),
noCaptionClass = this.caption && this.frame.hasClass("fr-no-caption");
var k;
if (this.caption) {
k = this.caption;
this.info.removeClass("fr-no-caption");
var l = this.frame.hasClass("fr-no-caption");
this.frame.removeClass("fr-no-caption");
var m = this.frame.hasClass("fr-has-caption");
this.frame.addClass("fr-has-caption")
}
H.element.css({
visibility: "visible"
});
this._whileVisible($.proxy(function() {
var a = 0,
attempts = 2;
while ((a < attempts)) {
h.height = this._getInfoHeight(f.width);
var b = 0.5 * (J._boxDimensions.height - 2 * border - (i.vertical ? i.vertical * 2 : 0) - f.height);
if (b < h.height) {
f = C.within(f, {
bounds: $.extend({}, {
width: f.width,
height: Math.max(f.height - h.height, 0)
}),
fit: fit,
ui: ui
})
}
a++
}
h.height = this._getInfoHeight(f.width);
var c = B.viewport();
if (((c.height <= 320 && c.width <= 568) || (c.width <= 320 && c.height <= 568)) || (h.height >= 0.5 * f.height) || (h.height >= 0.6 * f.width)) {
h.caption = false;
h.height = 0;
f = j
}
}, this), k);
H.element.css({
visibility: "visible"
});
if (l) {
this.frame.addClass("fr-no-caption")
}
if (m) {
this.frame.addClass("fr-has-caption")
}
var n = {
height: e.height - f.height,
width: e.width - f.width
};
e.height += (i.height - n.height);
e.width += (i.width - n.width);
if (f.height != j.height) {
cfitted = true
}
} else {
h.height = 0
}
var o = {
width: f.width + 2 * border,
height: f.height + 2 * border
};
if (h.height) {
e.height += h.height
}
if (ui == "inside") {
h.height = 0
}
var p = {
spacer: {
dimensions: e
},
padder: {
dimensions: o
},
wrapper: {
dimensions: f,
bounds: o,
margin: {
top: 0.5 * (e.height - o.height) - (0.5 * h.height),
left: 0.5 * (e.width - o.width)
}
},
content: {
dimensions: f
},
info: h
};
if (ui == "outside") {
p.info.top = p.wrapper.margin.top;
h.width = Math.min(f.width, J._boxDimensions.width)
}
var g = $.extend({}, J._boxDimensions);
if (ui == "outside") {
p.box = {
dimensions: {
width: J._boxDimensions.width
},
position: {
left: 0.5 * (J._dimensions.width - J._boxDimensions.width)
}
}
}
p.ui = {
spacer: {
dimensions: {
width: Math.min(e.width, g.width),
height: Math.min(e.height, g.height)
}
},
padder: {
dimensions: o
},
wrapper: {
dimensions: {
width: Math.min(p.wrapper.dimensions.width, g.width - 2 * border),
height: Math.min(p.wrapper.dimensions.height, g.height - 2 * border)
},
margin: {
top: p.wrapper.margin.top + border,
left: p.wrapper.margin.left + border
}
}
};
return p
},
updateVars: function() {
var a = $.extend({}, this._dimensions.max);
var b = parseInt(this.box_outer_border.css("border-top-width"));
this._border = b;
if (b) {
a.width -= 2 * b;
a.height -= 2 * b
}
var c = this.view.options.fit;
if (c == "smart") {
if (a.width > a.height) {
c = "height"
} else {
if (a.height > a.width) {
c = "width"
} else {
c = "none"
}
}
} else {
if (!c) {
c = "none"
}
}
this._fit = c;
var d = {
none: "both",
width: "y",
height: "x",
both: "none"
};
var e = this.view.options.spacing[d[this._fit]];
this._spacing = e
},
clearLoadTimer: function() {
if (this._loadTimer) {
clearTimeout(this._loadTimer);
this._loadTimer = null
}
},
clearLoad: function() {
if (this._loadTimer && this._loading && !this._loaded) {
this.clearLoadTimer();
this._loading = false
}
},
load: function(p, q) {
if (this._loaded || this._loading) {
if (this._loaded) {
this.afterLoad(p)
}
return
}
if (!q && !(F.cache.get(this.view.url) || F.preloaded.getDimensions(this.view.url))) {
H.loading.start()
}
this._loading = true;
this._loadTimer = setTimeout($.proxy(function() {
this.clearLoadTimer();
switch (this.view.type) {
case "image":
var n = this.view.options.ui;
F.get(this.view.url, {
dragImage: n != "touch"
}, $.proxy(function(g, h) {
if (!this.view) {
return
}
this._dimensions._max = g;
this._dimensions.max = g;
this._loaded = true;
this._loading = false;
this.updateVars();
var j = this.getLayout();
this._dimensions.spacer = j.spacer.dimensions;
this._dimensions.content = j.content.dimensions;
this.content = $("").attr({
src: this.view.url
}).addClass("fr-content fr-content-image");
this.box_wrapper.append(this.content);
if (n == "touch") {
this.content.bind("dragstart", function(a) {
a.preventDefault()
})
}
var k;
this.box_wrapper.append(k = $("").addClass("fr-content-image-overlay"));
if (this.download_image) {
k.append(this.download_image.clone())
}
var l;
if (this.view.options.ui == "outside" && ((l = this.view.options.onClick) && l == "next" || l == "previous-next")) {
var m = this.view.options.loop;
if ((this._position != J._frames.length) || m) {
this.box_wrapper.append($("
").addClass("fr-onclick-side fr-onclick-next").data("side", "next"))
}
if (l == "previous-next" && (this._position != 1 || m)) {
this.box_wrapper.append($("
").addClass("fr-onclick-side fr-onclick-previous").data("side", "previous"))
}
if (this.download_image) {
this.box_wrapper.find(".fr-onclick-side").each($.proxy(function(i, a) {
var b = $(a).data("side");
$(a).prepend(this.download_image.clone().data("side", b))
}, this))
}
this.frame.delegate(".fr-onclick-side", "click", function(a) {
var b = $(a.target).closest(".fr-onclick-side").data("side");
J[b]()
});
this.frame.delegate(".fr-onclick-side", "mouseenter", $.proxy(function(a) {
var b = $(a.target).closest(".fr-onclick-side").data("side"),
button = b && this["_" + b + "_button"];
if (!button) {
return
}
this["_" + b + "_button"].addClass("fr-side-button-active")
}, this)).delegate(".fr-onclick-side", "mouseleave", $.proxy(function(a) {
var b = $(a.target).data("side"),
button = b && this["_" + b + "_button"];
if (!button) {
return
}
this["_" + b + "_button"].removeClass("fr-side-button-active")
}, this))
}
this.frame.find(".fr-download-image").each($.proxy(function(i, d) {
var e = $("
").addClass("fr-download-image").attr({
src: this.view.url
}).css({
opacity: 0
}),
side = $(d).data("side");
if (u.IE && u.IE < 9) {
var f = parseInt(H.element.css("z-index")) || 0;
e.css({
"z-index": f
});
$(d).parents().css({
"z-index": f
});
if (/^(x|both)$/.test(this.view.options.overflow || "")) {
e.hide()
}
}
if (h.dragImage && !E.mobileTouch) {
e.add(this.content).bind("dragstart", $.proxy(function(a) {
if (this.view.options.ui == "touch") {
a.preventDefault();
return
}
var b = a.originalEvent,
dt = b.dataTransfer || {};
if (h.dragImage && dt.setDragImage) {
var x = b.pageX || 0,
y = b.pageY || 0;
var c = this.content.offset();
x = Math.round(x - c.left);
y = Math.round(y - c.top);
if (h.dragScale < 1) {
x *= h.dragScale;
y *= h.dragScale
}
dt.setDragImage(h.dragImage, x, y)
} else {
if (dt.addElement) {
dt.addElement(this.content[0])
} else {
a.preventDefault()
}
}
}, this))
}
if (side) {
e.data("side", side)
}
$(d).replaceWith(e)
}, this));
this.afterLoad(p, q)
}, this));
break;
case "youtube":
var o = {
width: this.view.options.width,
height: this.view.options.height
};
if (this.view.options.youtube && this.view.options.youtube.hd) {
this.view._data.quality = (o.width > 720) ? "hd1080" : "hd720"
}
this._movieLoaded(o, p);
break;
case "vimeo":
var o = {
width: this.view.options.width,
height: this.view.options.height
};
F.get(this.view.url, $.proxy(function(a, b) {
if (!this.view) {
return
}
var c = o.width,
dh = o.height,
bw = a.width,
bh = a.height,
oneDimension = false;
if ((oneDimension = (c && !dh) || (dh && !c)) || c && dh) {
if (oneDimension) {
if (c && !dh) {
o.height = c * bh / bw
} else {
o.width = dh * bw / bh
}
}
o = C.within(a, {
bounds: o
})
} else {
o = a
}
this._movieLoaded(o, p)
}, this));
break
}
}, this), 10)
},
_movieLoaded: function(a, b) {
this._dimensions._max = a;
this._dimensions.max = a;
this._loaded = true;
this._loading = false;
this.updateVars();
var c = this.getLayout();
this._dimensions.spacer = c.spacer.dimensions;
this._dimensions.content = c.content.dimensions;
this.box_wrapper.append(this.content = $("
").addClass("fr-content fr-content-" + this.view.type));
if (this.view.options.ui == "touch" && (this.view.type == "youtube" || this.view.type == "vimeo")) {
this.resize();
if ((this.view.type == "youtube" && !! window.YT) || (this.view.type == "vimeo" && E.postMessage)) {
this.show()
}
}
this.afterLoad(b)
},
afterLoad: function(a) {
var b = this.view.options.ui;
this.resize();
if (b == "inside") {
this.ui_outer_border.bind("mouseenter", $.proxy(this.showUI, this)).bind("mouseleave", $.proxy(this.hideUI, this))
}
if (this.ui) {
if (!E.mobileTouch) {
this.ui.delegate(".fr-ui-padder", "mousemove", $.proxy(function() {
if (!this.ui_wrapper.is(":visible")) {
this.showUI()
}
this.startUITimer()
}, this))
} else {
this.box.bind("click", $.proxy(function() {
if (!this.ui_wrapper.is(":visible")) {
this.showUI()
}
this.startUITimer()
}, this))
}
}
var c;
if (J._frames && (c = J._frames[J._position - 1]) && (c.view.url == this.view.url || c.view.options.ui == "touch")) {
H.loading.stop()
}
if (a) {
a()
}
},
resize: function() {
if (this.content) {
var a = this.getLayout();
var b = this.view.options.ui;
this._dimensions.spacer = a.spacer.dimensions;
this._dimensions.content = a.content.dimensions;
this.box_spacer.css(px(a.spacer.dimensions));
if (b == "inside") {
this.ui_spacer.css(px(a.ui.spacer.dimensions))
}
this.box_wrapper.add(this.box_outer_border).css(px(a.wrapper.dimensions));
var c = 0;
if (this.view.options.ui == "outside" && a.info.caption) {
c = a.info.height
}
this.box_outer_border.css({
"padding-bottom": c + "px"
});
this.box_padder.css(px({
width: a.padder.dimensions.width,
height: a.padder.dimensions.height + c
}));
if (a.spacer.dimensions.width > (this.view.options.ui == "outside" ? a.box.dimensions.width : B.viewport().width)) {
this.box.addClass("fr-prevent-swipe")
} else {
this.box.removeClass("fr-prevent-swipe")
}
switch (b) {
case "outside":
if (this.caption) {
this.info.css(px({
width: a.info.width
}))
}
break;
case "inside":
this.ui_wrapper.add(this.ui_outer_border).add(this.ui_toggle).css(px(a.ui.wrapper.dimensions));
this.ui_padder.css(px(a.ui.padder.dimensions));
var d = 0;
if (this.caption) {
var e = this.frame.hasClass("fr-no-caption"),
has_hascap = this.frame.hasClass("fr-has-caption");
this.frame.removeClass("fr-no-caption");
this.frame.addClass("fr-has-caption");
var d = 0;
this._whileVisible($.proxy(function() {
d = this.info.outerHeight()
}, this), this.ui_wrapper.add(this.caption));
var f = B.viewport();
if (d >= 0.45 * a.wrapper.dimensions.height || ((f.height <= 320 && f.width <= 568) || (f.width <= 320 && f.height <= 568))) {
a.info.caption = false
}
if (e) {
this.frame.addClass("fr-no-caption")
}
if (!has_hascap) {
this.frame.removeClass("fr-has-caption")
}
}
break
}
if (this.caption) {
var g = a.info.caption;
this.caption[g ? "show" : "hide"]();
this.frame[(!g ? "add" : "remove") + "Class"]("fr-no-caption");
this.frame[(!g ? "remove" : "add") + "Class"]("fr-has-caption")
}
this.box_padder.add(this.ui_padder).css(px(a.wrapper.margin));
var h = J._boxDimensions,
spacer_dimensions = this._dimensions.spacer;
this.overlap = {
y: spacer_dimensions.height - h.height,
x: spacer_dimensions.width - h.width
};
this._track = this.view.options.overflow != "none" && (this.overlap.x > 0 || this.overlap.y > 0);
J[(this._track ? "set" : "remove") + "Tracking"](this._position);
if (u.IE && u.IE < 8 && this.view.type == "image") {
this.content.css(px(a.wrapper.dimensions))
}
if (/^(vimeo|youtube)$/.test(this.view.type)) {
var i = a.wrapper.dimensions;
if (this.player) {
this.player.setSize(i.width, i.height)
} else {
if (this.player_iframe) {
this.player_iframe.attr(i)
}
}
}
}
this.position()
},
position: function() {
if (!this.content) {
return
}
var a = J._xyp;
var b = J._boxDimensions,
spacer_dimensions = this._dimensions.spacer;
var c = {
top: 0,
left: 0
};
var d = this.overlap;
if (d.y > 0) {
c.top = 0 - a.y * d.y
} else {
c.top = b.height * 0.5 - spacer_dimensions.height * 0.5
}
if (d.x > 0) {
c.left = 0 - a.x * d.x
} else {
c.left = b.width * 0.5 - spacer_dimensions.width * 0.5
}
if (E.mobileTouch) {
if (d.y > 0) {
c.top = 0
}
if (d.x > 0) {
c.left = 0
}
this.box_spacer.css({
position: "relative"
})
}
this._style = c;
this.box_spacer.css({
top: c.top + "px",
left: c.left + "px"
});
var e = $.extend({}, c);
if (e.top < 0) {
e.top = 0
}
if (e.left < 0) {
e.left = 0
}
var f = this.view.options.ui;
switch (f) {
case "outside":
var g = this.getLayout();
this.box.css(px(g.box.dimensions)).css(px(g.box.position));
if (this.view.caption) {
var h = c.top + g.wrapper.margin.top + g.wrapper.dimensions.height + this._border;
if (h > J._boxDimensions.height - g.info.height) {
h = J._boxDimensions.height - g.info.height
}
var i = J._sideWidth + c.left + g.wrapper.margin.left + this._border;
if (i < J._sideWidth) {
i = J._sideWidth
}
if (i + g.info.width > J._sideWidth + g.box.dimensions.width) {
i = J._sideWidth
}
this.info.css({
top: h + "px",
left: i + "px"
})
}
break;
case "inside":
this.ui_spacer.css({
left: e.left + "px",
top: e.top + "px"
});
break
}
},
setDimensions: function(a) {
this.dimensions = a
},
insertYoutubeVideo: function() {
var a = u.IE && u.IE < 8,
layout = this.getLayout(),
lwd = layout.wrapper.dimensions;
var b = $.extend({}, this.view.options.youtube || {});
var c = "http" + (window.location && window.location.protocol == "https:" ? "s" : "") + ":";
var d = $.param(b);
this.content.append(this.player_iframe = $("