/*!
Horizonal Unique Creative OnePage Bootstrap HTML5
Copyright (c) 2013, Subramanian
Author: Subramanian
Profile: themeforest.net/user/FMedia/
Version: 1.0.0
Release Date: September 2013
Built using: jQuery version:1.6.2 http://jquery.com/
jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*/
(function( $ ){
function mainFm(selector, params){
var defaults = $.extend({}, {
// default variables
onePage : true, // Set whether this template will work as one page or separate page
currentPage : "!home", // Set the current page
animationSpeed : 1000, // Default animation speed
slideshowSpeed : 5000, // Flexslider slideshow delaytime on porfolio detail page
homeSliderThumbnail : false, // Home slider thumbnail
portfolioAutoOpen : false
} , params);
// Initialize required variables and objects
var self = this;
self.pageHolderHeight_desktop = self.pgHigDesk = "100%";
self.pageHolderHeight_ipad = self.pgHigIpad = "100%";
self.winWidth = $(window).width();
self.winHeight = $(window).height();
self.selEle = $(selector);
self.IE_old = $.browser.msie;
self.mobile = $(window).width() <= 959;
self.midMobile = $(window).width() <= 767 && $(window).width() > 479;
self.minMobile = $(window).width() <= 480;
self.mobileDevice = screen.width < 1024 && screen.height < 1024;
ipad = ($(window).width() === 768 || $(window).height() === 768) && ($(window).width() === 1024 || $(window).height() === 1024) ;
self.ipadPort = (self.winWidth >= 768 && self.winWidth < 1024);
self.navTop = $(window).width() <= 959;
self.StgHig = iPhoneDevice ? screen.height-60 : self.winHeight;
lowResDesktop = self.winWidth <= 979 || isTouch;
self.onePage = defaults.onePage;
self.aniSpeed = defaults.animationSpeed;
self.flxDelay = flxDelay = defaults.slideshowSpeed;
self.headerFixedHig = $(".navbar").outerHeight();
self.curPgChk = undefined;
self.isoAniFin = false;
self.porAutoOpen = defaults.portfolioAutoOpen;
self.txtAniTim = [];
if(!self.onePage){
//siteStartOpen = true;
}
self.bdy = $("body");
self.htmlBody = $(" body");
self.foot = $(".footer");
self.foter_close = $(".footer_close")
self.navUl = $('.nav');
self.pgNexPre = $(".previousPage, .nextPage")
self.pgUp = $(".pgScrollUp");
self.bdy.data("width", Number($(window).width()));
self.bdy.data("height", Number($(window).height()));
self.pageLoaded = false;
self.homePage = defaults.currentPage;
self.pageLoadfinished = false;
self.projFm = false;
self.apis = [];
self.ff = -1;
self.ContPgTopSpace = 360;
self.singleBg = true;
self.cM = $('.contentWrapper [data-id="'+"#"+self.homePg+'"]').parent();
self.cM_= $('.contentWrapper [data-id="'+"#"+self.homePg+'"]');
self.homDia = $(".homeDiamond");
self.hSlider = $(".homeSlider");
self.hSliderResp = $(".homeSlider .fullHeight.fullResponse");
self.hSliderVid = $(".homeSlider .fullHeight.fullResponse .video_content.backGroundVideo");
// create Menu fadeout layer
self.headerFad = $(".pageFade");
self.contClose = $(".closeBtn");
self.bdy.prepend('
');
self.dumDiv = self.bdy.children(':first-child');
self.navArry = [];
$('.contentWrapper').each(function(){
var n_spt = $(this);
if(n_spt.attr("data-id") !== undefined){
self.navArry.push($(this));
}
});
for(var ik=0; ik < self.navArry.length; ik++){
self.navArry[ik].addClass("enablHardwareAcc");
}
// Scroll bar added for require div
if(!isTouch){
self.addScrollbar();
}else{
$(".m-Scrollbar").each(
function(){
$(this).addClass("enablHardwareAcc");
});
}
// Initialize niceScroll to html
if(!isTouch){ $("html").niceScroll({ zindex : 900000, cursorborder : "0px", cursorcolor : self.scrollColor, cursorwidth:"7px", scrollspeed :70, horizrailenabled:false }); }
// Initialize the site after the required time interval
$("#supersized").css({"opacity":0});
self.bdy.css("display","block");
if(typeof api === "undefined"){
siteStartOpen = true;
}
var intV = setInterval(function() {
//if ((zz.indexOf(ch)>-1) ){
if(siteStartOpen){
clearInterval(intV);
setTimeout( function(){
$(".header").show();
$(".homeSlider .homepage_con").show();
self.headerFixedHig = $(".navbar").outerHeight();
self.initialize();
if($("#supersized").height() !== null){
if(!self.mobile){
$("#supersized").animate({"opacity":1}, 1500, "easeInOutQuart" );
$("#superNav").fadeIn(1000, "easeInOutQuart" );
$(".supersized-nav").fadeIn(500, "easeInOutQuart" );
}else{
$("#supersized").show().css({"opacity":1});
$("#superNav").show();
$(".supersized-nav").show();
}
if(typeof api !== 'undefined' && defaults.homeSliderThumbnail ){
api.min_thumb();
}
}
}, 200);
}
//}
},10);
// Page buttons ==================================================================
// Page scrollUp button
self.pgScrUp = $(".move_up, .goTop");
$(".pgScrollUp, .move_up, .goTop").click(function(){
self.scroll_update(0);
self.htmlScroll.animate({ scrollTop: "0px" }, 500, "easeInOutQuart" );
});
// Cache the Window object
self.pgAll = $(".bodyContainer");
self.$html = $("html");
self.$window = $("body");
$(".contactPage .contactPage_content").css({ "min-height": $(window).height() - self.ContPgTopSpace, "margin-top": self.ContPgTopSpace } );
self.htmlScroll = isNaN($("body").scrollTop()) ? $("html") : $("body");
// Full Screen gallery thumbnail code
$(".fullScreenGallery_thumbnails").each(function(){
var me = $(this);
var mc = $(this).find(".carousel_container");
// Next image Button
$(this).find("a.next_button").click(function(){
me.find(".carousel_thumbails").each(function(){
var cur = $(this).children().length-1 > $(this).data("cur") ? $(this).data("cur")+1 : 0;
$(this).data("fn")($(this).children().eq( cur ), cur,true);
});
});
// Previous image Button
$(this).find("a.previous_button").click(function(){
me.find(".carousel_thumbails").each(function(){
var cur = $(this).data("cur") > 0 ? $(this).data("cur")-1 : $(this).children().length-1;
$(this).data("fn")($(this).children().eq( cur ), cur,true);
});
});
// Thumbnail close Button
if(!isTouch){
$(this).find(".pageClose_btn").click(function(){
if(!self.mobile){
if(mc.height() <= 50){
$(this).text("CLOSE");
try {
mc.animate({"height":mc.data("hig")+"px"}, 500, "easeInOutQuart", function(){
self.curP.mCustomScrollbar("update");
self.curP.mCustomScrollbar("scrollTo","bottom");
});
} catch (e) {
self.htmlScroll.animate({ scrollTop: self.curP.height() }, 500, "easeInOutQuart" );
}
}else{
mc.css({"height":"auto"});
mc.data("hig", mc.height());
$(this).text("OPEN");
try {
mc.animate({"height":"13px"} , 500, "easeInOutQuart",function(){
self.curP.mCustomScrollbar("scrollTo","top");
self.curP.mCustomScrollbar("update");
});
} catch (e) {
self.htmlScroll.animate({ scrollTop: "13px" }, 500, "easeInOutQuart" );
}
}
}else{
mc.css({"height":"auto"});
$(this).text("Thumbnails");
self.curP.mCustomScrollbar("update");
self.curP.mCustomScrollbar("scrollTo","top");
if(self.htmlScroll.scrollTop() >= 30){
self.htmlScroll.animate({ scrollTop: "0px" }, 500, "easeInOutQuart" );
}else{
self.htmlScroll.animate({ scrollTop: self.curP.height() }, 500, "easeInOutQuart" );
}
}
});
}else{
$(this).find(".pageClose_btn").text("Thumbnails").css({"pointer-events":"none"});
}
});
if(isTouch){
$("body").find('.mainContent .addVideo.backGroundVideo').each(function(){
$(this).data("inMain",true);
});
}
// Footer Open - close button
if(isTouch){
$(".nav a, .footer_close, .btn-navbar").click(function(){
$("body").find('.addVideo.backGroundVideo, .video_content.fullscreenVideo').each(function(){
var vid2 = $(this);
vid2.data("added", false);
vid2.data("isPlaying", false);
vid2.find('.vid').each(function(){
$(this).removeClass("enablHardwareAcc")
$(this).remove();
});
vid2.find('img').show();
vid2.find('.video_hover').show();
vid2.find('.video_hover').css({"z-index":"15"});
});
self.videoRest();
});
}
if(!isTouch){
$(".tutorial").click(function(){
$(this).fadeOut(200, function(){
$(this).remove();
})
});
}
}
mainFm.prototype = {
// Initialize the require objects and variables
initialize : function(){
var self = this;
self.prePg = "";
self.curPg = "";
self.menuList = [];
// Loading object added
self.bdy.prepend('
');
self.dumDiv.addClass('email_loading');
self.dumDiv.removeClass('email_loading');
$(".isotope_option").show();
self.masonry();
self.nexButton_detailPg = $("a.next_button");
self.preButton_detailPg = $("a.previous_button");
// Initialize the menu navigation action
var kk = -1;
var qq = -1;
self.rez = false;
if( parseInt($.browser.version, 10) === 7 && $.browser.msie){
$(".header").css({"background":"","filter":"none"});
self.dumDiv.addClass("mobile_menuBg_ie");
$(".header").css({"background-color": self.dumDiv.css("background-color")});
}
if( parseInt($.browser.version, 10) <= 8 && $.browser.msie){
$(".img-shadow").css({"opacity" : 0});
}
try {
document.createEvent('TouchEvent');
$(".lightStyle, .darkStyle, .contentWrapper").bind('click', function() {
});
} catch (e) {
// nothing to do
}
$(".header .nav li").each(function() {
var slf = $(this).children();
qq++;
if(slf.attr("href") === "" || slf.attr("href") === undefined){
return;
}
slf.bind('click', function() {
$(".nav li a").removeClass("active");
$(this).addClass("active");
var gg = String($(this).attr("href")).split("#");
if(gg[1] === self.url){
self.page_position();
}
});
});
$("body").find(".move_down, .move_down_white").each(function(){
$(this).bind('click', function() {
var gg = $(this).attr("href").split("#");
if(gg[1] === self.url){
self.page_position();
}
});
});
self.homePg = self.homePage === "" ? self.menuList[0].substr(1, self.menuList[0].length): self.homePage;
self.cM = $('.contentWrapper [data-id="'+"#"+self.menuList[0]+'"]').parent();
$('.contentWrapper [data-id="'+"#"+self.homePg+'"]').css("visibility","visible");
$('.contentWrapper [data-id="'+"#"+self.homePg+'"]').hide();
// Initialize the mobile button action
self.navUl.data('view',false);
self.navEvent = ('ontouchstart' in document.documentElement) ? 'touchstart' : 'click';
self.bdy.find('img').each(function() {
$(this).data("src",$(this).attr('src'));
});
// Initialize the video
self.intVideoObject(self.bdy);
// Enable/disable the image scale animation
if(isTouch){
$(".fmSliderNode img").removeClass("enableTransition");
$(".circle_large").removeClass("enableTransition");
}else{
$(".fmSliderNode img").addClass("enableTransition");
$(".circle_large").addClass("enableTransition");
}
// Initialize the window resize function
clearInterval(self.intr);
$(window).resize(function() {
clearInterval(self.intr);
self.intr = setInterval(function(){clearInterval(self.intr); self.windowRez();},100);
});
//Initialize the mobile orientationchange function
$(window).bind( 'orientationchange', function(){
self.windowRez();
});
self.site_display();
self.moveItem = $(".mainContent");
if(!isTouch){
self.page_drag();
}
var chkInt = setInterval(function() {
clearInterval(chkInt);
self.history();
self.page_setup();
}, 300);
// display isotope item
$('.isotope_items').show();
if(self.headerFad){
self.headerFad.delay(100).fadeOut(1000, "easeInOutQuart", function(){
self.headerFad.remove();
try{ $api.playToggle(); } catch (e) { }
});
}
$(document.documentElement).keyup(function (event) {
// if("!home" !== self.url){
// Left Arrow or Down Arrow
if ((event.keyCode == 37) || (event.keyCode == 40)) {
nexPreAction($(".previousPage span"));
// Right Arrow or Up Arrow
} else if ((event.keyCode == 39) || (event.keyCode == 38)) {
nexPreAction($(".nextPage span"));
}
// }
});
$(".previousPage span, .nextPage span").bind('click', function() {
nexPreAction($(this));
});
function nexPreAction (mc){
if(mc.data("url")){
if(mc.data("url") !== self.url){
window.location.href = "#"+mc.data("url");
}else{
self.page_position();
}
if($('.nav a[href$="#'+mc.data("url")+'"]').length > 0){
$(".nav li a").removeClass("active");
$('.nav a[href$="#'+mc.data("url")+'"]').addClass("active");
}
}
}
$(".fadeAfterLoad").delay(200).fadeIn(300);
},
// Initialize video cover image
intVideoObject : function(obj){
var self = this;
obj.find('.addVideo').each(function(){
var addCover = false;
$(this).find('.video_hover').each(function(){
addCover = true;
var vv = $(this);
var vid = $(this).parent();
vid.data("added", true);
vv.click(function(){
$("body").find('.addVideo').each(function(){
$(this).data("isPlaying", false);
if($(this).parent().hasClass("tabVideo")){ return; }
if(!$(this).data("added")){
vid.children(':first-child').removeClass("enablHardwareAcc");
}
$(this).find('.vid').remove();
if(!$(this).hasClass("backGroundVideo")){
$(this).find('img').fadeIn();
$(this).find('.video_hover').fadeIn();
$(this).find('.video_hover').css({"z-index":"5"});
}
});
vid.prepend('');
vid.data("added", true);
vid.data("isPlaying", true);
vid.data("url_", self.curP.attr("data-id"));
vid.find('.video_hover').css({"z-index":"-1"});
vid.find('img').fadeOut(100,function(){
var vid_ = $(this).parent();
vid_.children(':first-child').embedPlayer(vid_.attr('data-url'), vid_.width()+"px", vid_.height()+"px", vid_.width(), false);
}
);
});
});
});
},
// Video Reset function
videoRest : function(obj){
var self = this;
$("#fancybox-wrap").find('.addVideo').each(function(){
$(this).find('.vid').each(function(){
$(this).removeClass("enablHardwareAcc")
$(this).remove();
});
$(this).find('img').show();
$(this).find('.video_hover').show();
$(this).find('.video_hover').css({"z-index":"15"});
});
try{
$("body").find('.addVideo').each(function(){
if(!$(this).hasClass("backGroundVideo") && !$(this).data("isPlaying") || ($(this).data("url_") !== self.curP.attr("data-id")) ){
$(this).find('.vid').each(function(){
$(this).removeClass("enablHardwareAcc")
$(this).remove();
});
$(this).find('img').show();
$(this).find('.video_hover').show();
$(this).find('.video_hover').css({"z-index":"15"});
}
if($(this).data("isPlaying") ){
var vid = $(this);
var www = Math.round(vid.width());
var hhh = Math.round(vid.height());
vid.find("iframe").css({"width": www+"px", "height": hhh+"px"});
if(isTouch){ vid.find("iframe").css({"top":self.headerFixedHig }); }
}
});
} catch (e) { }
try{
if(!self.mobile){
self.curP.find('.addVideo.backGroundVideo').each(function(){
var vid = $(this);
var www = Math.round(vid.width());
var hhh = Math.round(vid.height());
var vidW = !isTouch ? www * 1.8 : www;
var vidH = !isTouch ? hhh * 1.8 : hhh-100;
var ww = vidW;
var hh = vidH;
if(!vid.data("added") && vid.data("inMain") === undefined){
vid.data("url_", self.curP.attr("data-id"));
vid.prepend('');
vid.children(':first-child').addClass("enablHardwareAcc");
vid.find('.video_hover').css({"z-index":"5"});
vid.find('img').show();
vid.children(':first-child').embedPlayer(vid.attr('data-url'), vidW+"px", vidH+"px", true);
}
vid.data("added", true);
vid.children(':first-child').css({ "top": -Math.round((hh-hhh)/2)});
vid.find("iframe").css({"width": ww+"px", "height": hh+"px" });
});
}
$("body").find('.addVideo.backGroundVideo').each(function(){
var vid_ = $(this);
if(vid_.data("url_") !== self.curP.attr("data-id")){
vid_.data("added", false);
vid_.find('.vid').each(function(){
$(this).removeClass("enablHardwareAcc")
$(this).remove();
});
vid_.find('img').show();
vid_.find('.video_hover').show();
vid_.find('.video_hover').css({"z-index":"5"});
}
});
} catch (e) { }
},
// Fullscreen gallery video load function
fullScreenGallery : function(obj){
var self = this;
try{
$(obj).find('.addVideo').each(function(){
var vid_ = $(this);
vid_.data("added", false);
vid_.find('.vid').each(function(){
$(this).removeClass("enablHardwareAcc")
$(this).remove();
});
vid_.find('img').show();
vid_.find('.video_hover').show();
vid_.find('.video_hover').css({"z-index":"5"});
});
} catch (e) { }
},
/* Resize Image */
resizeImg : function (obj){
var self = this;
if(obj.width() === 0){ return; }
var hold;
if(obj.parent().parent().parent().parent().hasClass("projImgs") || obj.hasClass("resize_align")){
if(obj.hasClass("resize_align")){
hold =obj.parent();
}else{
hold =obj.parent().parent().parent().parent();
}
}else{
return;
}
obj.css({"width":"auto", "height":"auto"});
if(obj.data("width_") === undefined){
var image = new Image();
image.onload = function() {
appy_resizeImg(obj, this.width, this.height);
obj.data("width_", this.width);
obj.data("height_", this.height);
try { this.remove(); } catch (e) { }
self.scroll_update();
};
image.src = obj.attr("src");
}else{
appy_resizeImg(obj,obj.data("width_"), obj.data("height_"));
self.scroll_update();
}
function appy_resizeImg(obj,wid, hig){
var iw = wid,
ih = hig,
ww = hold.width(),
wh = hold.height(),
rw = wh / ww,
ri = ih / iw,
tp = 0,
lp = 0,
newWidth, newHeight,
newLeft, newTop,
properties;
if(obj.hasClass("resize_align") && !obj.hasClass("fitInside") ){
obj.css({ "margin-left": "0px" });
var rezr = hold.width() < hold.height() ? rw < ri : rw > ri;
newWidth = ww;
newHeight = ww * ri;
if ( rezr ) {
lp = ( ww -newWidth)/2;
}
obj.css({'margin-left': Math.round(lp) + "px"});
}else{
if (ww > wh) {
newWidth = ww;
newHeight = ww * ri;
if(ww < newWidth || wh < newHeight ){
newWidth = wh / ri;
newHeight = wh;
}
} else {
newWidth = ww;
newHeight = ww * ri;
}
lp = ( ww -newWidth)/2;
obj.css({'margin-left': Math.round(lp) + "px"});
}
tp = (wh-newHeight)/2;
properties = {
'width': Math.round(newWidth) + 'px',
'height': Math.round(newHeight) + 'px',
'margin-top': Math.round(tp) + "px",
"left":"auto",
"right":"auto",
'bottom': "auto"
};
obj.css( properties);
}
},
// Site start display function
site_display : function(){
var self = this;
if(!self.IE_old){
$(".isotope_items .item a .img_text").css("visibility","visible");
}
$("body").data("bgType",isMobileChk);
$("body").find('.parallax').each(function(){
var img = !isMobileChk ? $(this).attr("data-src") : ($(this).attr("data-src-small")? $(this).attr("data-src-small") : $(this).attr("data-src"));
var imgAtt = !isTouch ? "fixed" : "scroll";
var vd = false;
$(this).find('.backGroundVideo').each(function(){
vd = true;
});
if(img !== undefined ){
if(!lowResDesktop && !vd){
$(this).css({"background-image":"url("+img+")"});
}else{
if(!((vd && $(this).hasClass("homeSlider")) && ipadDevice) && lowResDesktop){
$(this).css({"background-image":"url("+img+")"});
}
}
}
});
$(".contentWrapper").find('#mapWrapper').each(function(){
if(!self.IE_old){
$(this).parent().prepend($(this).data('map'));
$(this).parent().children(":first-child").addClass('mapStyle');
$(this).remove();
}
});
// Twitter flex slideshow initialize
$('body').find('.flexslider').each(function(){
if(!$(this).hasClass("flexSlideshow_twitter")){
try{
var aniTyp = $(this).hasClass('slideAnimation') ? "slide" : "fade";
var laz = $(this).hasClass('flexslider');
if(!laz){ $(this).addClass("flexslider"); }
var ffx = $(this);
ffx.append('');
$(this).find(" a.lazyload").each(function(){
self.lazyLoadInt($(this));
});
var flexs = $(this);
flexs.flexslider({
slideshow: true,
animation: aniTyp,
slideshowSpeed: 5000,
start: function(slider){
flexs.data("slid",slider);
flexs.find(".slider_loading").remove();
slider.pause();
}
});
} catch (e) { }
}
});
$("body").find('.contentWrapper').each(function(){
if($(this).attr("data-id") === self.url){
isInCont = $(this);
}
});
},
// Page Drag code start here
page_drag : function(){
var self = this;
self.pageCurPos = 0;
// slide Drag Coding
var tm;
var tmArr=[];
var tmMovChk;
var tmRevMov = false;
var bgDrgPos = 0;
var strDrg = false;
self.drgPosDir = 0;
self.finishPlay = true;
var mainCon = self.selEle;
self.moveItem = $(".mainContent");
self.dragIt = false;
self.mouse_drag = true;
self.applyDragAction = true;
$(".disable_mouse_drag").bind('mousedown', function(e) {
self.applyDragAction = false;
});
$(".disable_mouse_drag").bind('mouseup', function(e) {
self.applyDragAction = true;
});
/* Add Mouse cursor */
if(self.mouse_drag){
if(!this.hasTouch) {
self.moveItem.bind('mousedown', function() {
if(self.applyDragAction){
tmRevMov = false;
//self.moveItem.removeClass("fm_drag-cursor");
//self.moveItem.addClass("fm_draging-cursor");
mouseDragInit();
}
});
}
// Start to drag using below functionv
var dragStart = function(){
if(tch !== tch_){
strDrg = true;
self.dragIt = true;
self.moveItem.addClass("fm_draging-cursor");
}
self.moveItem.stop();
var tm__ = Math.round(Math.abs(Number(tch_)-Number(tch)))< 101?
Math.round( Math.abs(Number(tch_)-Number(tch))) : Math.round(100 + Math.abs(100-(Math.abs(Number(tch_)-Number(tch))))*0.2);
if(Math.round(Number(tch_)-Number(tch)) > 0){
tm = tm__ + self.pageCurPos;
}else{
tm = tm__ - self.pageCurPos;
}
if(self.finishPlay){
if((Number(tch_) > Number(tch))){
self.moveItem.css({"left":Number(tm)+"px"});
}else{
self.moveItem.css({"left":-Number(tm)+"px"});
}
}
};
// Stop drag using below function, The next and previous slide will start here
var dragStop = function(){
if(Number(tch) !== Number(tch_) && self.finishPlay){
if(Number(tch) > Number(tch_) ){
if(((Number(tch) - Number(tch_)) > 50 || tmMovChk>5) && !tmRevMov){
self.moveItem.stop();
self.drgPosDir = 1;
dragFinish();
}else{
self.moveItem.stop();
self.moveItem.animate({"left":self.pageCurPos});
}
}else{
if(((Number(tch_)-Number(tch)) > 50 || tmMovChk>5) && !tmRevMov){
self.moveItem.stop();
self.drgPosDir = -1;
dragFinish();
}else{
self.moveItem.stop();
self.moveItem.animate({"left":self.pageCurPos});
}
}
}
tm = 0;
self.moveItem.removeClass("fm_draging-cursor");
};
// Mousedown event for drag
var mouseDragInit = function(){
$(document).bind('mousedown.fmDragEvent', function(e) {
tch = tch_ = Math.abs(e.clientX);
tmArr = [];
tmArr.push(tch);
bgDrgPos = parseInt(self.moveItem.css("left"), 10);
$(document).bind('mousemove.fmDragEvent', function(e) {
tmRevMov = tch_ > Math.abs(e.clientX) ? (Number(tch) > Number(tch_)) ? false:true : (Number(tch) < Number(tch_)) ? false : true;
tch_ = Math.abs(e.clientX);
tmArr.push(tch_);
tmMovChk = Math.abs((tmArr[tmArr.length-1]-tmArr[tmArr.length-2]));
dragStart();
return false;
});
return false;
});
$(document).bind('mouseup.fmDragEvent', function() {
strDrg = tch !== tch_ ? false : true;
$(document).unbind('mousedown.fmDragEvent');
$(document).unbind('mouseleave.fmDragEvent');
$(document).unbind('mousemove.fmDragEvent');
$(document).unbind('mouseup.fmDragEvent');
dragStop();
return false;
});
$(document).bind('mouseleave.fmDragEvent', function() {
strDrg = false;
$(document).unbind('mousedown.fmDragEvent');
$(document).unbind('mouseleave.fmDragEvent');
$(document).unbind('mousemove.fmDragEvent');
$(document).unbind('mouseup.fmDragEvent');
return false;
});
};
// Touch screen Enable
var touEle = self.moveItem;
var tch = 0;
var tch_ = 0;
var tchY = 0;
var tchY_ = 0;
self.touMoving = true;
try {
document.createEvent('TouchEvent');
$(touEle).each(function() {
this.ontouchstart = function(e) {
self.touMoving = true;
touchStart(e);
return true;
};
this.ontouchend = function(e) {
self.touMoving = true;
touchEnd();
return true;
};
this.ontouchmove = function(e) {
if(self.touMoving){
touchMove(e);
}
if(!isMobile){
return true;
}
};
this.find('.nonDraggable').bind("mousedown", function(e) {
e.stopImmediatePropagation();
});
});
} catch (e) {
// Nothing to do
}
var touchStart = function(e) {
tch = tch_ = Math.abs(e.clientX);
tmArr = [];
tmArr.push(tch);
self.moveItem.stop();
bgDrgPos = parseInt(self.moveItem.css("left"), 10);
tch = tch_ = e.targetTouches[0].clientX;
tchY = tchY_ = e.targetTouches[0].clientY;
};
var touchEnd = function() {
dragStop();
if(Math.abs(tchY - tchY_) > 100){
self.moveItem.stop();
}
};
var touchMove = function(e) {
tchY_ = e.targetTouches[0].clientY;
if(Math.abs(tchY - tchY_) < 100){
tmRevMov = tch_ > Math.abs(e.targetTouches[0].clientX) ? (Number(tch) > Number(tch_)) ? false:true : (Number(tch) < Number(tch_)) ? false : true;
tch_ = Math.abs(e.targetTouches[0].clientX);
tmArr.push(tch_);
tmMovChk = Math.abs((tmArr[tmArr.length-1]-tmArr[tmArr.length-2]));
dragStart();
}else{
self.touMoving = false;
return false;
}
};
var dragFinish = function(){
if(Math.abs(tchY - tchY_) < 100){
self.moveItem.stop();
var pre, nex,preP, nexP;
for(var ik=0; ik < self.navArry.length; ik++){
if(self.navArry[ik].attr("data-id") === self.url){
if(self.navArry[ik-1]){
pre = self.navArry[ik-1].attr("data-id");
preP = self.navArry[ik-1];
}
if(self.navArry[ik+1]){
nex = self.navArry[ik+1].attr("data-id");
nexP = self.navArry[ik+1];
}
}
}
self.spd = 0;
if(self.drgPosDir<0){
self.pageCurPos = -self.pageCurPos >= self.winWidth ? self.pageCurPos+self.winWidth: 0;
if(!lowResDesktop){
for(var ik=0; ik < self.navArry.length; ik++){
if(((self.pageCurPos+50)*-1) < (self.navArry[ik].position().left+50) && ((self.pageCurPos-50)*-1) > (self.navArry[ik].position().left-50)){
pre = self.navArry[ik].attr("data-id");
preP = self.navArry[ik];
if(self.navArry[ik+1]){
nex = self.navArry[ik+1].attr("data-id");
nexP = self.navArry[ik+1];
}
}
}
}
try{ if(preP && pre !== "!home"){ preP.mCustomScrollbar("scrollTo","top") }; } catch (e) { }
self.moveItem.animate({"left":self.pageCurPos+"px"},500,"easeInOutQuart", function(){
if(pre && pre !== "!home"){ window.location.href = "#"+pre; }
self.moveItem.css({"left":self.pageCurPos+"px"});
});
}else{
self.pageCurPos = -self.pageCurPos <= ($(".mainContent").width()-(self.winWidth*2)) ? self.pageCurPos-self.winWidth : - ($(".mainContent").width()-(self.winWidth+51-self.numCon));
if(!lowResDesktop){
for(var ik=0; ik < self.navArry.length; ik++){
if( ((self.pageCurPos-50)*-1) > (self.navArry[ik].position().left-50) && ((self.pageCurPos+50)*-1) < (self.navArry[ik].position().left+50)){
nex = self.navArry[ik].attr("data-id");
nexP = self.navArry[ik];
if(self.navArry[ik-1]){
pre = self.navArry[ik-1].attr("data-id");
preP = self.navArry[ik-1];
}
}
}
}
try{ if(nexP){ nexP.mCustomScrollbar("scrollTo","top") }; } catch (e) { }
self.moveItem.animate({"left":self.pageCurPos+"px"},500,"easeInOutQuart", function(){
if(nex){ window.location.href = "#"+nex; }
self.moveItem.css({"left":self.pageCurPos+"px"});
});
}
}
};
// Page Drag code end
}
},
// Site footer code
siteFooter : function(){
var self = this;
if(!self.footActive){
self.footActive = true;
self.foter_close.each(function(){
var fc = $($(this).attr("data-close"));
$(this).click(function(){
if(fc.height() !== 0){
$(this).addClass("footOpen");
fc.animate({"height": "0px"}, 500 , "easeInOutQuart");
}else{
$(this).removeClass("footOpen");
fc.css({"height": "auto"});
var ggg = fc.height()
fc.css({"height": "0px"});
fc.animate({"height": ggg},500 , "easeInOutQuart");
}
})
});
}
self.foter_close.each(function(){
var fc = $($(this).attr("data-close"));
if(self.winWidth > 979 && !isTouch){
$(this).addClass("footOpen");
fc.parent().css({"position":"absolute"});
fc.stop().animate({"height": "0px"}, 500 , "easeInOutQuart");
$(this).css({"visibility":"visible"});
}else{
$(this).removeClass("footOpen");
fc.stop().css({"height": "auto"});
fc.parent().css({"position":"relative"});
$(this).css({"visibility":"hidden"});
}
});
},
// Set page dimension
page_dimension : function(){
var self = this;
var conPos = 0;
self.numCon = 0;
$(".mainContent").children().each(function(){
self.numCon++;
});
if(self.foter_close.data("fir") === undefined ){
var timm = !lowResDesktop ? 2500 : 0;
self.foter_close.data("fir", "s1");
setTimeout(function(){
self.foter_close.data("fir", "s2");
self.siteFooter();
},timm);
}
if(self.foter_close.data("fir") === "s2" ){
self.siteFooter();
}
$("body").find(".contentWrapper").each(function(){
if(!lowResDesktop){
$(this).css({"width": self.winWidth, "height": self.StgHig});
$(".top_space").css({"padding-top": self.headerFixedHig+15});
}else{
if(isTouch){
$(this).css({"width": self.winWidth, "min-height": self.StgHig, "height": "auto" });
}else{
$(this).css({"width": self.winWidth, "height": "auto" });
}
$(".top_space").css({"padding-top": 50});
}
});
$(".mainContent").css({"width":(self.numCon*self.winWidth)+50+"px"});
if(!lowResDesktop){
$(".mainContent").css({"height": self.StgHig,"overflow-y":"hidden"});
}else{
$(".mainContent").css({"height": "auto", "overflow-y":"auto"});
}
},
// Scrollbar update function
scroll_update : function(rPos){
var self = this;
var rePos = typeof rPos !== undefined ? rPos : 0;
try{
if(self.curP.hasClass("m-Scrollbar")){
self.curP.mCustomScrollbar("update");
self.curP.mCustomScrollbar("scrollTo","top");
}
self.curP.find(".m-Scrollbar").each(function(){
$(this).mCustomScrollbar("update");
$(this).mCustomScrollbar("scrollTo","top");
});
} catch (e) { }
try{
if(!isTouch){
if(rePos !== 0 && rePos !== undefined){
self.curP.mCustomScrollbar("update");
self.curP.mCustomScrollbar("scrollTo", rePos);
}
}
} catch (e) { }
if(!isTouch){ $("html").getNiceScroll().resize(); }
},
// Update the page, when the page change is or resize
updatePage : function(ele){
var self = this;
if(self.rez){
return;
}
var menuDefined = false;
if($('.nav a[href$="#'+ ele.attr("data-id")+'"]').length > 0){
menuDefined = true;
$(".nav li a").removeClass("active");
$('.nav a[href$="#'+ele.attr("data-id")+'"]').addClass("active");
if($('.nav a[href$="#'+ele.attr("data-id")+'"]').parent().parent().parent().hasClass("dropdown")){
$('.nav a[href$="#'+ele.attr("data-id")+'"]').parent().parent().parent().find(".dropdown-toggle").addClass("active")
}
}
if(!menuDefined){ $(".nav li a").removeClass("active"); }
if(!menuDefined){
if($('.nav a[href$="#'+ele.attr("data-continue-page")+'"]').length > 0){
$(".nav li a").removeClass("active");
$('.nav a[href$="#'+ele.attr("data-continue-page")+'"]').addClass("active");
}
}
for(var ik=0; ik < self.navArry.length; ik++){
if(self.navArry[ik].attr("data-id") === ele.attr("data-id")){
if(self.navArry[ik-1]){
$(".previousPage span").data( "url" , self.navArry[ik-1].attr("data-id") );
}
if(self.navArry[ik+1]){
$(".nextPage span").data( "url" , self.navArry[ik+1].attr("data-id") );
}
}
}
ele.find('.homeDiamond').each(function(){
if(!self.homDia.data("show")){
self.homDia.data("show", true);
var tim = isNaN(Number(self.homDia.attr("data-time"))) ? 0 : Number(self.homDia.attr("data-time"));
self.homDia.delay(tim*100).fadeIn();
}
});
if(!isTouch){
$("body").find('.graph_container li').each(function() {
$(this).each(function() {
$(this).children(':first-child').css("width","0px");
});
});
ele.find('.graph_container').each(function(){
self.graph_display($(this));
});
}
ele.find('.flexslider').each(function(){
try{
if($(this).data("slid") !== undefined){
$(this).data("slid").windowRez();
}
} catch (e) { }
});
ele.find('.masonry_items').each(function(){
$(this).find(".item").css({"width":self.masonPer});
});
ele.find('.fullScreenGallery_thumbnails').each(function(){
var sc = $(this).find('.pageClose_btn');
var mc = $(this).find(".carousel_container");
if(!isTouch && !self.mobile){
$(this).removeClass("mobileView");
if(mc.height()<15){
sc.text("OPEN");
}else{
sc.text("CLOSE");
}
}else{
$(this).addClass("mobileView");
sc.children(":first-child").text("Thumbnails");
mc.css({"height":"auto"});
ele.mCustomScrollbar("update");
ele.mCustomScrollbar("scrollTo","top");
}
});
if(self.porAutoOpen){
if(ele.hasClass('portfolioPage')){
if( ele.data("c_url") !== self.url){
ele.data("load_when_page_open" , undefined)
}
ele.data("c_url", self.url);
if( ele.data("lod_when_page_open") === undefined){
ele.data("lod_when_page_open" , true);
try {
ele.detailPage("autoOpenProject");
} catch (e) {}
}
};
}
if(lowResDesktop){
ele.find('img.resize_align').each(function(){
self.resizeImg($(this));
});
}
// Text animation
for(var s=0; s 0 ? 0 : self.aniSpeed;
self.curP.find(".carousel_container a.lazyload, .elastislide-carousel a.lazyload").each(function(){
self.lazyLoadInt($(this));
});
self.curP.find(".carousel_container li, .elastislide-carousel li").each(function(){
$(this).find("img").appendTo($(this).find("a"));
});
if(self.curP.data("carouselLoad") === undefined){
self.curP.data("carouselLoad", true);
/* Initialize carousel Elasticslider */
self.curP.find('.carousel').each(function(){
$(this).elastislide();
$(this).find("img").css({"visibility":"visible"}).show();
});
}
if(self.curP.data("carouseGallLoad") === undefined){
self.curP.data("carouseGallLoad", true);
var fullThumbnail = self.curP.find('.fullScreenGallery_thumbnails').css({"visibility":"hidden"});
self.curP.find('.carousel_container').each(function(){
$(this).data("thu",fullThumbnail);
/* Initialize carousel galler Elasticslider */
carousel_gallery_int ($(this));
});
}
if(self.url !== self.curPgChk){
self.htmlBody.scrollTop(0);
try{
self.curP.find(".carousel_container").each(function(){
var mc = $(this);
if(mc.data("firstLoad") === undefined){
mc.data("firstLoad", true);
mc.css({"height":"auto"});
mc.data("hig", mc.height());
}else{
mc.find(".carousel_thumbails").each(function(){
$(this).data("fn")($(this).children().eq( 0 ),0,true);
});
}
});
} catch (e) { }
}
self.pgAll.stop();
self.moveItem.stop();
if(!lowResDesktop){
if(self.Tutor === undefined && !isTouch){
if(posT > 10){
setTimeout(function(){
self.Tutor = true;
$(".tutorial").fadeIn(500);
},100);
}
}
if(posT < 10 && $("#supersized").length > 0){
$("#supersized .prevslide, #supersized .activeslide").css({"visibility":"visible"});
$("#supersized .prevslide, #supersized .activeslide").animate({"opacity":1});
$(".sliderStyle1, .sliderStyle2, .sliderStyle3, .sliderStyle4, .sliderStyle5").addClass(".enablHardwareAcc");
}
if(!self.rez){
self.pgAll.stop().animate({ scrollTop: posT }, sped2, "easeInOutQuart", function(){
if(isInCont !== undefined){
self.pageCurPos = -isInCont.position().left;
if(self.pageCurPos <= 0){
var sped = self.moveItem.position().left >= self.pageCurPos-5 && self.moveItem.position().left <= self.pageCurPos+5 ? 0 : 1000 ;
self.moveItem.stop().animate({"left":self.pageCurPos+"px"},sped,"easeInOutQuart", function(){
if(posT > 10){
$("#supersized .prevslide, #supersized .activeslide").css({"visibility":"hidden", "opacity":0});
$(".sliderStyle1, .sliderStyle2, .sliderStyle3, .sliderStyle4, .sliderStyle5").removeClass(".enablHardwareAcc");
}
self.pageUpdate();
});
}
}
});
}else{
self.pgAll.stop().scrollTop(posT);
if(isInCont !== undefined){
self.pageCurPos = -isInCont.position().left;
if(self.pageCurPos <= 0){
var sped = self.moveItem.position().left >= self.pageCurPos-5 && self.moveItem.position().left <= self.pageCurPos+5 ? 0 : 1000 ;
self.moveItem.stop().css({"left":self.pageCurPos+"px"});
if(posT > 10){
$("#supersized .prevslide, #supersized .activeslide").css({"visibility":"hidden", "opacity":0});
$(".sliderStyle1, .sliderStyle2, .sliderStyle3, .sliderStyle4, .sliderStyle5").removeClass(".enablHardwareAcc");
}
self.pageUpdate();
}
}
}
}else{
self.pgAll.scrollTop(posT);
if(isInCont !== undefined){
self.pageCurPos = -isInCont.position().left;
if(self.pageCurPos <= 0){
if(!self.rez && (ipadDevice || !isTouch) && self.url !== self.curPgChk){
for(ik=0; ik < self.navArry.length; ik++){
if(self.navArry[ik].attr("data-id") === self.url){
self.curP = self.navArry[ik];
self.ir = ik > self.dirFind ? 1 : -1;
self.dirFind = ik;
}
}
self.moveItem.css({"left":self.pageCurPos+ (self.winWidth * self.ir) +"px", "height": self.winHeight, "overflow-y":"hidden"});
self.moveItem.stop().animate({"left":self.pageCurPos+"px"}, 700 ,"easeInOutQuart", function(){
self.moveItem.css({"height": "auto", "overflow-y":"auto"});
self.pageUpdate();
});
}else{
self.moveItem.stop().css({"left":self.pageCurPos+"px"});
self.pageUpdate();
}
}
}
if("!home" !== self.url){
$(".header").removeClass("bg_transparent");
$("#supersized .prevslide, #supersized .activeslide").css({"visibility":"hidden", "opacity":0});
$(".sliderStyle1, .sliderStyle2, .sliderStyle3, .sliderStyle4, .sliderStyle5").removeClass(".enablHardwareAcc");
}else{
$(".header").addClass("bg_transparent");
$("#supersized .prevslide, #supersized .activeslide").css({"visibility":"visible"});
$("#supersized .prevslide, #supersized .activeslide").animate({"opacity":1});
$(".sliderStyle1, .sliderStyle2, .sliderStyle3, .sliderStyle4, .sliderStyle5").addClass(".enablHardwareAcc");
}
}
if("!home" !== self.url){
if($(".nextPage span").data( "url") === self.url || $(".nextPage span").data( "url") === undefined){
self.pgNexPre.addClass("endPage");
}else{
self.pgNexPre.removeClass("endPage");
}
self.pgNexPre.removeClass("autoPosition");
if(lowResDesktop){ self.pgUp.fadeIn(200); }
$(".header").removeClass("bg_transparent");
}else{
self.pgNexPre.removeClass("endPage");
self.pgNexPre.addClass("autoPosition");
self.pgUp.fadeOut(200);
$(".header").addClass("bg_transparent");
}
self.curPgChk = self.url;
setTimeout(function(){ self.videoRest(); }, 1000);
},
pageUpdate : function(){
var self = this;
for(var ik=0; ik < self.navArry.length; ik++){
if(self.navArry[ik].attr("data-id") === self.url){
self.updatePage(self.curP);
}
}
self.scroll_update();
},
// The entire page can be reposition, resize and modified by page_setup function
page_setup : function (){
var self = this;
self.winWidth = $(window).width();
self.winHeight = $(window).height();
self.ipadPort = (self.winWidth >= 768 && self.winWidth < 1024);
self.mobile = self.winWidth <= 959 && !self.ipadPort;
self.midMobile = self.winWidth <= 767 && self.winWidth > 479;
self.minMobile = self.winWidth <= 480;
isMobileChk = self.winWidth < 768;
self.navTop = true;
self.headerFixedHig = $(".navbar").outerHeight();
lowResDesktop = self.winWidth <= 979 || isTouch;
self.StgHig = iPhoneDevice ? screen.height-60 : self.winHeight;
if(!lowResDesktop){
self.pgAll.css({"height":self.StgHig, "overflow":"hidden"});
}else{
self.pgAll.css({"height":"auto", "overflow-y":"auto"});
if("!home" !== self.url){
self.pgAll.css({"visibility":"visible"});
}else{
self.pgAll.css({"visibility":"hidden"});
}
}
self.page_dimension();
// Change the default image in img tag, if mobile version(data-src-small) image is assign on the img tag
self.bdy.find('img').each(function() {
var thsImg = $(this);
var mobVer = thsImg.hasClass("lowResSupport") ? (self.winWidth <= 979 ? true : false) : self.mobile;
if($(this).attr('data-src-small')){
if(!mobVer || !$(this).attr('data-src-small')){
var img_Src = $(this).data('src').split(".");
var iimg = $(this).attr('data-retina') === "yes" && retinaDevice ? img_Src[0]+"@2x."+ img_Src[1] : $(this).data('src');
if(String($(this).attr('src')) !== iimg){
$(this).attr("src", iimg);
$(this).data("i_src",$(this).data('src'));
}
}else{
if($(this).attr('data-src-small')){
img_Src = $(this).attr('data-src-small').split(".");
iimg = $(this).attr('data-retina') === "yes" && retinaDevice ? img_Src[0]+"@2x."+ img_Src[1] : $(this).attr('data-src-small');
if(String($(this).attr('src')) !== String($(this).attr('data-src-small')) && String($(this).attr('src')) !== iimg){
$(this).attr("src",iimg);
$(this).data("i_src",$(this).attr('data-src-small'));
}
}
}
}
});
if(self.rez){
$(self.contClose.attr("data-content")).css({"top":"0px"});
self.contClose.children(":first-child").children(":first-child").css({"right" : "-40px"});
}
if(lowResDesktop || iPhoneDevice){
$("body").find('.addVideo.backGroundVideo').each(function(){
var vid2 = $(this);
var vd = $(this).hasClass('.backGroundVideo.playInIpad');
var img = !self.mobile ? vid2.attr("data-src") : (vid2.attr("data-src-small")? vid2.attr("data-src-small") : vid2.attr("data-src"));
if(img !== undefined && !(ipadDevice && vid2.attr("data-url") !== undefined || !vd) ){
vid2.css({"background-image":"url("+img+")"});
}
});
}
if(isTouch){
$("body").find('.mainContent .addVideo.backGroundVideo').each(function(){
var vid2 = $(this);
var img = !self.mobile ? vid2.attr("data-src") : (vid2.attr("data-src-small")? vid2.attr("data-src-small") : vid2.attr("data-src"));
if(img !== undefined ){
vid2.css({"background-image":"url("+img+")"});
}
});
}
var tppp = 0;
$("body").find(".fullHeight").each(function(){
var se2 = $(this);
se2.css({"min-height": self.StgHig});
if(se2.hasClass("fullResponse")){
if(!isTouch){
se2.find(".video_content.fullscreenVideo").css({"min-height": self.StgHig, "min-width": "100%"});
}else{
se2.find(".video_content.fullscreenVideo").css({"min-height": self.StgHig-120, "min-width": "100%", "top":60});
}
}else{
if(self.mobile){
se2.css({"min-height": "50px"});
se2.css({"min-height": "auto"});
}
}
});
$("body").find(".video_content.backGroundVideo").each(function(){
$(this).css({"min-height": self.StgHig, "min-width": "100%"});
});
$("body").find(".carousel_preview.fullScreenGallery_items, .carousel_preview.fullScreenGallery_items .carousel_item").each(function(){
$(this).css({"height": self.StgHig, "width":"100%"});
});
var dimSiz = self.winWidth > self.winHeight || self.mobile ? self.winHeight : self.winWidth;
dimSiz = !self.mobile ? self.winWidth > 700 ? 700 : 400 : 400;
$(".diamond_container.fullWid").css({"width": dimSiz/2, "height": dimSiz/2 });
$(".diamond_container.fullWid").each(function(){ $(this).css({"top":( self.winHeight - $(this).height())/2 +50+"px" }); });
self.ContPgTopSpace = $(window).height() > 360 ? 360 : 150;
$(".contactPage .contactPage_content").css({ "min-height": $(window).height() - self.ContPgTopSpace, "margin-top": self.ContPgTopSpace } );
self.masonNum = self.winWidth < 1149? (self.mobile ? (self.midMobile ? 2 : 1) : 3) : (self.winWidth > 1360 ? 5 : 4);
self.masonPer = (100/self.masonNum)-0.1+"%";
$("body").find(".masonry_items").each(function(){
$(this).find(".item").css({"width":self.masonPer});
});
self.page_position();
$('body').find('img.resize_align').each(function(){
self.resizeImg($(this));
});
$('body').find('.masonry_items').css({"mini-width":self.winWidth});
if(isTouch){
$(".overlayPattern").hide();
}
if(lowResDesktop){ $(".mobile_Only").show(); }else{ $(".mobile_Only").hide(); }
},
// The page_load function is used to position the page as per current menu
page_load : function (e){
var self = this;
self.url = e ? e : self.homePg;
self.cM = $('a[href$="#'+self.url+'"]').parent();
self.cM_= !self.onePage ? $('a[href="'+self.url+'"]') : $('a[href$="#'+self.url+'"]');
self.pgViewed = false;
for(var ik=0; ik < self.navArry.length; ik++){
if(self.navArry[ik].attr("data-id") === self.url){
if(self.navArry[ik-1]){
$(".previousPage span").data( "url" , self.navArry[ik-1].attr("data-id") );
}
if(self.navArry[ik+1]){
$(".nextPage span").data( "url" , self.navArry[ik+1].attr("data-id") );
}
}
}
for(var s=0; s');
$(this).find(" a.lazyload").each(function(){
self.lazyLoadInt($(this));
});
var flexs = $(this);
flexs.flexslider({
slideshow: true,
animation: aniTyp,
slideshowSpeed: 5000,
start: function(slider){
flexs.data("slid",slider);
flexs.find(".slider_loading").remove();
slider.pause();
}
});
} catch (e) { }
});
}
if(isInCont.hasClass("portfolioPage") && isInCont.data("isImgLoaded") === undefined){
isInCont.data("isImgLoaded", true);
isInCont.find(" a.lazyload_masonry").each(function(){
if($(this).data("loaded") !== true){
$(this).data("loaded", true);
var cc = $(this).attr('class');
var img_ = $(this).attr("href") ? $(this).attr("href") : undefined;
var img = $('');
img.removeClass('lazyload_masonry');
$(this).replaceWith(img);
img.load(function() {
self.scroll_update();
})
.each(function() {
if(this.complete) $(this).trigger('load');
});
}
});
}
isInCont.find('#map_canvas').each(function(){
if($(this).data("addMap") !== "yes"){
$(this).data("addMap", "yes");
try{
map_initialize();
} catch (e) {
$("#map_canvas").html($(this).data("con"));
}
}
mapResizer();
});
}
self.page_setup();
$("body").find('.portfolioPage').each(function(){
try {
$(this).detailPage("closeBackCon");
} catch (e) {}
});
if(isInCont !== undefined ){
if(self.curPg === ""){
self.curPg = self.prePg = self.url;
if(self.pgSub === undefined && self.onePage){
window.location.href = "#"+self.url;
}
self.cM = $('a[href$="#'+self.curPg+'"]').parent();
}
return;
}
self.firstScrol = true;
// Check the previous and current page
if(self.prePg === self.curPg){
try { self.fflod.remove(); } catch (e) { }
// Initialize to load the opening page as per history
if(self.curPg === "" ){
self.curPg = self.prePg = self.url;
if(self.pgSub === undefined && self.onePage){
window.location.href = "#"+self.url;
}
self.cM = $('a[href$="#'+self.curPg+'"]').parent();
self.pgAll.stop().animate({ scrollTop: "0px" }, 0, "easeInOutQuart");
}else{
// Initialize to load current page, background and animate to left side
self.curPg = self.url;
var pagScrl_Speed = window.pageYOffset !== 0 ? self.aniSpeed : 50;
var con_Speed = 0;
if(self.prePg !== self.url){
self.pgAll.stop().animate({ scrollTop: "0px" }, pagScrl_Speed, "easeInOutQuart" ,function(){ });
}else{
if(isInCont !== undefined){
self.page_position();
}
self.pgAll.stop().animate({ scrollTop: "0px" }, 500, "easeInOutQuart" );
}
}
}
},
// Portfolio masonry gallery
masonry : function(){
var self = this;
self.masonNum = self.winWidth < 1149? (self.mobile ? (self.midMobile ? 2 : 1) : 3) : (self.winWidth > 1360 ? 5 : 4);
self.masonPer = (100/self.masonNum)-0.1+"%";
$("body").find('.masonry_items').each(function(){
self.manso = $(this);
$(this).find(".item").css({"width":self.masonPer});
$(this).find(".item").css({"position":"relative"});
$(this).find(".item").addClass("enablHardwareAcc");
});
},
// Lazy load function
lazyLoadInt : function(obj){
var self = this;
var imSrc = !self.mobileDevice ? obj.attr("href") : (obj.attr("data-src-small")? obj.attr("data-src-small") :obj.attr("href"));
var lodr = obj.parent().hasClass('large_image');
lodr = !lodr ? obj.parent().hasClass('medium_image') : lodr;
lodr = !lodr ? obj.parent().hasClass('fixedHeight') : lodr;
lodr = !lodr ? obj.hasClass('lazyload_single') : lodr;
if(obj.parent().hasClass('imgBorder')){
lodr = !lodr ? obj.parent().parent().hasClass('fixedHeight') : lodr;
}
var cc = obj.attr('class');
var st = obj.attr('style');
var $img;
if(st){
$img = $('');
}else{
$img = $('');
}
$img.removeClass('lazyload_single');
$img.removeClass('lazyload');
obj.replaceWith($img);
$img.hide();
if(lodr){
$img.parent().append('');
if($img.parent().height() > 50){
$img.parent().children(":last-child").css({"top":$img.parent().height()/2-15});
}
$img.attr('src', imSrc).load(function() {
$(this).parent().find(".slider_loading").remove();
if($(this).hasClass("resize_align")){
self.resizeImg($(this));
};
$(this).fadeIn(300);
}).error(function () {
$(this).parent().find(".slider_loading").remove();
}).each(function() {
if(this.complete) { $(this).trigger('load'); }
});
}else{
if($img.parent().hasClass('projImgPop')){
$img.parent().append('');
$img.parent().children(":last-child").css({"top":$img.parent().height()/2-15});
$img.parent().children(":last-child").css({"left":$img.parent().width()/2-15});
}
$img.attr('src', imSrc).load(function() {
$(this).parent().find(".slider_loading").remove();
if($(this).hasClass("resize_align")){
self.resizeImg($(this));
};
$(this).fadeIn(300);
var pim = $img.parent().parent().hasClass('projImgs');
pim = pim ? pim : $img.parent().parent().parent().parent().hasClass('projImgs');
if(pim){
self.resizeImg($(this));
}else{
var posY = $(this).hasClass("scale_fill");
posY = !posY ? $(this).hasClass("scale_fit") : posY;
posY = !posY ? $(this).hasClass("scale_cover") : posY;
if(posY){
if($(this).width() > $(this).parent().width()+5 ){
$(this).css({"left":-($(this).width()-$(this).parent().width())/2});
}
$(this).css({"top":-($(this).height()-$(this).parent().height())/2});
}
}
}).error(function () {
$(this).parent().find(".slider_loading").remove();
}).each(function() {
if(this.complete) { $(this).trigger('load'); }
});
}
return $img;
},
// Initialize the History
history : function(){
var self = this;
(function($){
var origContent = "";
function loadContent(hash2) {
window.location.href.substr(0, window.location.href.indexOf('#'));
var splt = hash2.split("?");
var hash = !self.onePage ? self.homePg : splt[0];
self.pgSub = splt[1];
if(hash !== "") {
if(origContent === "" && self.curPg === "") {
origContent = $('.contentWrapper [data-id="'+"#"+self.homePg+'"]');
}
if(self.hisPath !== hash ){
self.hisPath = hash;
self.page_load(hash);
}else{
if(self.pgSub !== undefined && self.projFm){
var p2 = self.pgSub.split("=");
if((Number(p2[1]) !== self.curSlide)){
self.curFmSlider = $(".pageHolder .fmSlides").data("sArry");
self.curSlide = Number(p2[1]);
self.showDetailPage(self.curFmSlider[Number(p2[1])]);
}
}
}
} else {
if(origContent !== "" && self.curPg === "") {
if(self.hisPath !== hash ){
self.hisPath = hash;
self.page_load(self.homePg);
}
}else{
if(!self.onePage){
if(self.pgSub !== undefined && self.projFm){
p2 = self.pgSub.split("=");
if((Number(p2[1]) !== self.curSlide)){
self.curFmSlider = $(".pageHolder .fmSlides").data("sArry");
self.curSlide = Number(p2[1]);
self.showDetailPage(self.curFmSlider[Number(p2[1])]);
}
}
}
}
}
if(hash === "" && self.curPg === ""){
self.page_load(self.homePg);
}
}
$(document).ready(function() {
$.history.init(loadContent);
$('#navigation a').not('.external-link').click(function() {
var url = $(this).attr('href');
url = url.replace(/^.*#/, '');
$.history.load(url);
return false;
});
});
})(jQuery);
},
// Add scrollbar
addScrollbar : function (){
var self = this;
$('body').find(".m-Scrollbar").each(
function(){
$(this).mCustomScrollbar({
theme: "light-thick",
autoHideScrollbar:true,
scrollInertia: 200,
mouseWheelPixels: 320
});
}
);
$('body').find(".scroll-pane").each(
function()
{
self.apis.push($(this).jScrollPane({ autoReinitialise: true, verticalDragMinHeight : 70 }).data().jsp);
}
);
},
// Remove scrollbar
removeScrollbar : function(){
var self = this;
if (self.apis.length) {
$.each(
self.apis,
function(i) {
this.destroy();
}
);
self.apis = [];
}
},
// Graph display function
graph_display : function (e){
e.find('li').each(function() {
$(this).each(function() {
$(this).children(':first-child').css("width","0px");
$(this).children(':first-child').stop();
$(this).children(':first-child').animate( { width: $(this).attr('data-level') }, 1500, "easeInOutQuart");
});
});
},
// Window Resize function
windowRez : function (){
var self = this;
if(Number(self.bdy.data("width")) !== Number($(window).width()) || Number(self.bdy.data("height")) !== Number($(window).height())){
self.bdy.data("width", Number($(window).width()));
self.bdy.data("height", Number($(window).height()));
self.rez = true;
self.page_setup();
self.rez = false;
}
}
};
// Initizlize and create the main plug-in
$.fn.mainFm = function(params) {
var $fm = $(this);
var instance = $fm.data('GBInstance');
if (!instance) {
if (typeof params === 'object' || !params){
return $fm.data('GBInstance', new mainFm($fm, params));
}
} else {
if (instance[params]) {
return instance[params].apply(instance, Array.prototype.slice.call(arguments, 1));
}
}
};
})( jQuery );