Advertisement
Guest User

Screen JS

a guest
Dec 20th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.61 KB | None | 0 0
  1. jQuery.noConflict();
  2.  
  3. $apex_highlightcolor = "#51227E";
  4.  
  5.  
  6. /* #On Document Ready
  7. ================================================== */
  8.  
  9. function getWeather() {
  10. jQuery.simpleWeather({
  11. location: 'Morristown, NJ',
  12. woeid: '',
  13. unit: 'f',
  14. success: function(weather) {
  15. html = '<h2><i class="icon-'+weather.code+'"></i> '+weather.temp+'&deg;'+weather.units.temp+'</h2>';
  16. //html += '<ul><li>'+weather.city+', '+weather.region+'</li>';
  17. //html += '<li class="currently">'+weather.currently+'</li>';
  18. //html += '<li>'+weather.alt.temp+'&deg;C</li></ul>';
  19.  
  20. jQuery("#weather").html(html);
  21. },
  22. error: function(error) {
  23. $("#weather").html('<p>'+error+'</p>');
  24. }
  25. });
  26. }
  27.  
  28.  
  29.  
  30. jQuery(document).ready(function() {
  31.  
  32. getWeather(); //Get the initial weather.
  33. setInterval(getWeather, 600000);
  34.  
  35. /* Menu */
  36. ddsmoothmenu.init({
  37. mainmenuid: "mainmenu", //menu DIV id
  38. orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
  39. classname: 'ddsmoothmenu', //class added to menu's outer DIV
  40. contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
  41. });
  42.  
  43. /* Hover Effects */
  44. hoverEffects();
  45.  
  46. /* Tabs */
  47. tabsInit();
  48.  
  49. /* Fit Videos */
  50. jQuery(".scalevid").fitVids();
  51.  
  52. /* Portfolio 4 Column */
  53. jQuery('.portfolio4column').tpportfolio({
  54. speed:500,
  55. row:4,
  56. nonSelectedAlpha:15,
  57. portfolioContainer:'.portfolio'
  58. });
  59.  
  60. /* Portfolio 2 Column */
  61. jQuery('.portfolio2column').tpportfolio({
  62. speed:500,
  63. row:2,
  64. nonSelectedAlpha:0,
  65. portfolioContainer:'.portfolio'
  66. });
  67.  
  68. /* Responsive Select Menu */
  69. jQuery("#responsive-menu select").change(function() {
  70. window.location = jQuery(this).find("option:selected").val();
  71. });
  72.  
  73. /* Contact Form */
  74. if(jQuery('#contactform').length != 0){
  75. addForm('#contactform');
  76. }
  77.  
  78. /* Quick Contact */
  79. if(jQuery('#quickcontact').length != 0){
  80. addForm('#quickcontact');
  81. }
  82.  
  83. /* Blog Comments */
  84. if(jQuery('#replyform').length != 0){
  85. addForm('#replyform');
  86. }
  87.  
  88. /* Footer Position Calculator */
  89. footerHandler();
  90.  
  91. /* Responsive Menu Generation */
  92. menuHandler();
  93.  
  94. /* Twitter Customization */
  95. twitterTimelineCustomize();
  96.  
  97. /* PrettyPhoto */
  98. addPrettyPhoto();
  99.  
  100. });
  101.  
  102.  
  103.  
  104. /* #On Window Load
  105. ================================================== */
  106.  
  107.  
  108.  
  109. jQuery(window).load(function() {
  110.  
  111. jQuery("#background").fullBg();
  112.  
  113. /* Init FlexSlider */
  114. jQuery('.flexslider').flexslider({
  115. touchSwipe: true,
  116. controlNav: false,
  117. directionNav: true,
  118. slideshow: true,
  119. slideshowSpeed: 7000,
  120. animationDuration: 600,
  121. randomize: false,
  122. pauseOnAction: true,
  123. pauseOnHover: false
  124. });
  125.  
  126. /* FlexSlider Button Hover */
  127. jQuery(".flex-direction-nav li a.next, .flex-direction-nav li a.prev").hover(function() {
  128. jQuery(this).animate({ backgroundColor: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  129. },function() {
  130. jQuery(this).animate({ backgroundColor: "#222" },{duration:300,queue:false}, 'easeOutSine');
  131. });
  132.  
  133. /* CSS fixes */
  134. jQuery('.tiledbackground').height(jQuery(document).height());
  135. jQuery('.whitebackground').height(jQuery(document).height());
  136.  
  137. /* Google Maps */
  138. loadGoogleMaps();
  139.  
  140. });
  141.  
  142.  
  143.  
  144. /* #Menu Handler
  145. ================================================== */
  146.  
  147.  
  148.  
  149. function menuHandler() {
  150.  
  151.  
  152. jQuery('#mainmenu li >a').each(function() {
  153. var a=jQuery(this);
  154. if(a.attr('class') != "parent"){
  155. jQuery('#responsive-menu select').append(new Option("\u0020\u0020\u0020- " + a.text(),a.attr('href')) );
  156. } else {
  157. jQuery('#responsive-menu select').append(new Option(a.text(),a.attr('href')) );
  158. }
  159. });
  160. }
  161.  
  162.  
  163.  
  164. /* #Footer Handler
  165. ================================================== */
  166.  
  167.  
  168.  
  169. /********************/
  170. function footerHandler() {
  171. setInterval(function() {
  172.  
  173. var mainh = jQuery('body').find('.main:first').outerHeight();
  174. var footerh = jQuery('body').find('.footerwrap').outerHeight() + jQuery('body').find('.subfooterwrap').outerHeight();
  175. var windowh = jQuery(window).height();
  176.  
  177. var dif = windowh - (mainh+footerh);
  178. if (dif>0) {
  179. jQuery('body').find('.footerwrap').stop();
  180. jQuery('body').find('.footerwrap').animate({'marginTop':dif+"px"},{duration:300,queue:false});
  181. }
  182.  
  183. if (dif<0) {
  184. jQuery('body').find('.footerwrap').stop();
  185. jQuery('body').find('.footerwrap').animate({'marginTop':"0px"},{duration:300,queue:false});
  186.  
  187. }
  188. // DEBUG jQuery('body').find('.khinfo').html('main:'+mainh+" footer:"+footerh+" Window:"+windowh+" dif:"+dif);
  189. },100);
  190.  
  191. setInterval(function() {
  192. jQuery('.tiledbackground').height(jQuery(document).height());
  193. jQuery('.whitebackground').height(jQuery(document).height());
  194. },500);
  195. }
  196.  
  197.  
  198.  
  199. /* #Pretty Photo
  200. ================================================== */
  201.  
  202.  
  203.  
  204. function addPrettyPhoto() {
  205. /* PrettyPhoto init */
  206. jQuery("a[data-rel^='prettyPhoto']").prettyPhoto({
  207. theme: 'pp_default',
  208. overlay_gallery: false,
  209. show_title: false,
  210. social_tools: false,
  211. hideflash: true
  212. });
  213. }
  214.  
  215.  
  216.  
  217. /* #Twitter Customizer
  218. ================================================== */
  219.  
  220.  
  221. function twitterTimelineCustomize() {
  222.  
  223.  
  224. // Customize twitter feed
  225. var changeTwitterAttempts = 0;
  226. function changeTwitterBoxElements() {
  227. setTimeout( function() {
  228. if ( jQuery('[id*=twitter]').length ) {
  229. jQuery('[id*=twitter]').each( function(){
  230. var ibody = jQuery(this).contents().find( 'body' );
  231. if ( ibody.find( '.timeline .stream .h-feed li.tweet' ).length ) {
  232. ibody.find( '.timeline .stream .h-feed li.tweet' ).slice(2, ibody.find( '.timeline .stream .h-feed li.tweet' ).length).remove();
  233.  
  234. ibody.find( '.timeline .stream').css('height',(ibody.find( '.timeline .stream ol').outerHeight()+10)+"px");
  235. jQuery( '.twitter-timeline').css('height',(ibody.find( '.timeline .stream ol').outerHeight()+10)+"px");
  236.  
  237. ibody.find( '.timeline' ).css( 'border', '0px solid #000' );
  238. ibody.find( '.timeline' ).css( 'background-color', 'transparent' );
  239. ibody.find( '.tweet' ).css( 'border', "0px solid #000" );
  240. ibody.find( '.timeline .stream' ).css( 'overflow-x', 'hidden' );
  241. ibody.find( '.timeline .stream' ).css( 'overflow-y', 'hidden' );
  242. ibody.find( '.timeline-header').hide();
  243. ibody.find( '.timeline-footer').hide();
  244. ibody.find( '.timeline .load-more').hide();
  245. jQuery( '.twitter-timeline').show();
  246. ibody.find( '.timeline .stream').click(function(){
  247. clickEvent();
  248. });
  249. }
  250. else {
  251. jQuery(this).hide();
  252. }
  253. });
  254. }
  255. changeTwitterAttempts++;
  256. if ( changeTwitterAttempts < 3 ) {
  257. changeTwitterBoxElements();
  258. }
  259. }, 1500);
  260. }
  261.  
  262. changeTwitterBoxElements();
  263.  
  264. var timeouts;
  265. jQuery(window).resize(function() {
  266. clearTimeout(timeouts);
  267. timeouts= setTimeout(function() {
  268. changeTwitterBoxElements();
  269. },150);
  270. });
  271.  
  272. function clickEvent(){
  273. changeTwitterBoxElements();
  274. }
  275.  
  276. }
  277.  
  278.  
  279.  
  280.  
  281. /* #Site Tabs
  282. ================================================== */
  283.  
  284.  
  285.  
  286. function tabsInit() {
  287.  
  288. /*
  289. * Skeleton V1.1
  290. * Copyright 2011, Dave Gamache
  291. * www.getskeleton.com
  292. * Free to use under the MIT license.
  293. * http://www.opensource.org/licenses/mit-license.php
  294. * 8/17/2011
  295. */
  296.  
  297. /* Tabs Activiation
  298. ================================================== */
  299.  
  300. var tabs = jQuery('ul.tabs');
  301.  
  302. tabs.each(function(i) {
  303.  
  304. //Get all tabs
  305. var tab = jQuery(this).find('> li > a');
  306. tab.click(function(e) {
  307.  
  308. //Get Location of tab's content
  309. var contentLocation = jQuery(this).attr('href');
  310.  
  311. //Let go if not a hashed one
  312. if(contentLocation.charAt(0)=="#") {
  313.  
  314. e.preventDefault();
  315.  
  316. //Make Tab Active
  317. tab.removeClass('active');
  318. jQuery(this).addClass('active');
  319.  
  320. //Show Tab Content & add active class
  321. jQuery(contentLocation).show().addClass('active').siblings().hide().removeClass('active');
  322.  
  323. }
  324. });
  325. });
  326. }
  327.  
  328.  
  329.  
  330. /* #Site Hover Effects
  331. ================================================== */
  332.  
  333.  
  334.  
  335. function hoverEffects() {
  336.  
  337. /* Logo Hover */
  338. jQuery(".logo a").hover(function() {
  339. jQuery(this).animate({'opacity':'0.6'},{duration:200,queue:false}, 'easeOutSine');
  340. },function() {
  341. jQuery(this).animate({'opacity':'1'},{duration:300,queue:false}, 'easeOutSine');
  342. });
  343.  
  344. /* Button Hover */
  345. jQuery("a.button, button").hover(function() {
  346. jQuery(this).animate({ backgroundColor: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  347. },function() {
  348. jQuery(this).animate({ backgroundColor: "#D49E0E" },{duration:300,queue:false}, 'easeOutSine');
  349. });
  350. jQuery("a.bigplus, a.bigdoc, a.bigcomment").hover(function() {
  351. jQuery(this).animate({ backgroundColor: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  352. },function() {
  353. jQuery(this).animate({ backgroundColor: "#d5d5d5" },{duration:300,queue:false}, 'easeOutSine');
  354. });
  355.  
  356. /* Border Hover */
  357. jQuery(".footer a.borderhover img").hover(function() {
  358. jQuery(this).animate({ borderColor: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  359. },function() {
  360. jQuery(this).animate({ borderColor: "#222" },{duration:300,queue:false}, 'easeOutSine');
  361. });
  362. jQuery("a.borderhover img").not(".footer a.borderhover img").hover(function() {
  363. jQuery(this).animate({ borderColor: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  364. },function() {
  365. jQuery(this).animate({ borderColor: "#ddd" },{duration:300,queue:false}, 'easeOutSine');
  366. });
  367.  
  368. /* Social Hover */
  369. jQuery("a.social_facebook").hover(function() {
  370. jQuery(this).animate({ backgroundColor: "#222" },{duration:200,queue:false}, 'easeInSine');
  371. },function() {
  372. jQuery(this).animate({ backgroundColor: "#3b5998" },{duration:300,queue:false}, 'easeOutSine');
  373. });
  374. jQuery("a.social_twitter").hover(function() {
  375. jQuery(this).animate({ backgroundColor: "#222" },{duration:200,queue:false}, 'easeInSine');
  376. },function() {
  377. jQuery(this).animate({ backgroundColor: "#1dcaff" },{duration:300,queue:false}, 'easeOutSine');
  378. });
  379. jQuery("a.social_flickr").hover(function() {
  380. jQuery(this).animate({ backgroundColor: "#222" },{duration:200,queue:false}, 'easeInSine');
  381. },function() {
  382. jQuery(this).animate({ backgroundColor: "#FF0084" },{duration:300,queue:false}, 'easeOutSine');
  383. });
  384. jQuery("a.social_pinterest").hover(function() {
  385. jQuery(this).animate({ backgroundColor: "#222" },{duration:200,queue:false}, 'easeInSine');
  386. },function() {
  387. jQuery(this).animate({ backgroundColor: "#D20000" },{duration:300,queue:false}, 'easeOutSine');
  388. });
  389. jQuery("a.social_youtube").hover(function() {
  390. jQuery(this).animate({ backgroundColor: "#222" },{duration:200,queue:false}, 'easeInSine');
  391. },function() {
  392. jQuery(this).animate({ backgroundColor: "#cd201f" },{duration:300,queue:false}, 'easeOutSine');
  393. });
  394. jQuery("a.social_instagram").hover(function() {
  395. jQuery(this).animate({ backgroundColor: "#222" },{duration:200,queue:false}, 'easeInSine');
  396. },function() {
  397. jQuery(this).animate({ backgroundColor: "#3f729b" },{duration:300,queue:false}, 'easeOutSine');
  398. });
  399.  
  400. jQuery("a.social_tripadvisor").hover(function() {
  401. jQuery(this).animate({ backgroundColor: "#222" },{duration:200,queue:false}, 'easeInSine');
  402. },function() {
  403. jQuery(this).animate({ backgroundColor: "#49863E" },{duration:300,queue:false}, 'easeOutSine');
  404. });
  405.  
  406. /* Link Hover */
  407. jQuery("a").not("a.button, a.bigplus, .footer a, .flex-caption a, .mainmenu a, a.titlelink, a.link, a.linkbg, .subline a, h6 a, h5 a, h4 a, h3 a, h2 a, h1 a, .blogpages li a").hover(function() {
  408. jQuery(this).animate({ color: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  409. },function() {
  410. jQuery(this).animate({ color: "#333" },{duration:300,queue:false}, 'easeOutSine');
  411. });
  412.  
  413.  
  414.  
  415. jQuery(".blogpages li a").not(".blogpages li a.selected").hover(function() {
  416. jQuery(this).animate({ backgroundColor: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  417. },function() {
  418. jQuery(this).animate({ backgroundColor: "#222" },{duration:300,queue:false}, 'easeOutSine');
  419. });
  420. jQuery("h6 a, h5 a, h4 a, h3 a, h2 a, h1 a").not("h4 a.button").hover(function() {
  421. jQuery(this).animate({ color: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  422. },function() {
  423. jQuery(this).animate({ color: "#000" },{duration:300,queue:false}, 'easeOutSine');
  424. });
  425. jQuery(".footer a").hover(function() {
  426. jQuery(this).animate({ color: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  427. },function() {
  428. jQuery(this).animate({ color: "#ccc" },{duration:300,queue:false}, 'easeOutSine');
  429. });
  430. jQuery(".flex-caption a").hover(function() {
  431. jQuery(this).animate({ color: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  432. },function() {
  433. jQuery(this).animate({ color: "#fff" },{duration:300,queue:false}, 'easeOutSine');
  434. });
  435. jQuery("a.link, .replylink a").hover(function() {
  436. jQuery(this).animate({ color: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  437. jQuery(this).css("border-bottom-color", $apex_highlightcolor);
  438. },function() {
  439. jQuery(this).animate({ color: "#333" },{duration:300,queue:false}, 'easeOutSine');
  440. jQuery(this).css("border-bottom-color", "#999");
  441. });
  442. jQuery("a.linkbg").hover(function() {
  443. jQuery(this).animate({ color: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  444. jQuery(this).css("backgroundColor", "#fff");
  445. },function() {
  446. jQuery(this).animate({ color: "#fff" },{duration:300,queue:false}, 'easeOutSine');
  447. jQuery(this).css("backgroundColor", $apex_highlightcolor);
  448. });
  449. jQuery(".subline a, .postinfo a").hover(function() {
  450. jQuery(this).animate({ color: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  451. },function() {
  452. jQuery(this).animate({ color: "#777" },{duration:300,queue:false}, 'easeOutSine');
  453. });
  454. jQuery("a.titlelink").hover(function() {
  455. jQuery(this).animate({ color: $apex_highlightcolor },{duration:200,queue:false}, 'easeOutSine');
  456. },function() {
  457. jQuery(this).animate({ color: "#b3b3b3" },{duration:300,queue:false}, 'easeOutSine');
  458. });
  459.  
  460. /* Top Level Menu Hover
  461. jQuery(".ddsmoothmenu ul li a").hover(function() {
  462. jQuery(this).animate({ color: "#000" },{duration:200,queue:false}, 'easeOutSine');
  463. },function() {
  464. jQuery(this).animate({ color: "#999" },{duration:200,queue:false}, 'easeOutSine');
  465. });*/
  466.  
  467. /* Sub Menu Hover */
  468. jQuery(".ddsmoothmenu ul li ul li a").hover(function() {
  469. jQuery(this).animate({ color: "#000", backgroundColor: "#f7f7f7" },{duration:200,queue:false}, 'easeOutSine');
  470. },function() {
  471. jQuery(this).animate({ color: "#777", backgroundColor: "#fff" },{duration:200,queue:false}, 'easeOutSine');
  472. });
  473.  
  474. /* Image Hover */
  475. jQuery('.hovering').hover(
  476. function() {
  477. var $this=jQuery(this);
  478.  
  479. if (jQuery.browser.msie && jQuery.browser.version==8) {
  480. jQuery('body').data('somethinghovered',1);
  481. }
  482.  
  483. if (!$this.find('img:first').hasClass("underanimation")) {
  484. if (jQuery.browser.msie && jQuery.browser.version<9 && $this.find('.overlay').length>0) {
  485. // IS ALREADY IN ACTION
  486.  
  487. } else {
  488.  
  489. var img = $this.find('img:first');
  490. var w=img.width();
  491. var h=img.height();
  492. var btw = parseInt(img.css('border-top-width'),0);
  493. var blw = parseInt(img.css('border-left-width'),0);
  494. if (btw>0 && btw<1000) {
  495. } else {
  496. btw=0;
  497. }
  498. if (blw>0 && blw<1000) {
  499. } else {
  500. blw=0;
  501. }
  502.  
  503.  
  504. var t=img.position().top + btw;
  505. var l=img.position().left + blw;
  506.  
  507.  
  508. // ADD THE OVERLAY ON THE A TAG BY HOVER
  509.  
  510. $this.append('<div class="overlay" style="overflow:hidden;position:absolute;cursor:pointer;"></div>');
  511. $this.find('.overlay').css({'top':t+'px',
  512. 'left':l+'px',
  513. 'width':w+'px',
  514. 'height':h+'px'});
  515.  
  516. $this.find('.overlay').css({'opacity':0});
  517. $this.find('.overlay').animate({'opacity':0.25},{duration:350,queue:false}, 'easeOutSine');
  518.  
  519. // ADD THE TEXT CAPTION ON THE HOVERED A TAG IMAGE
  520. if ($this.data('text')!=undefined) {
  521. $this.append('<div class="overlaytext" style="position:absolute;top:'+t+'px;left:'+(l+40)+'px;opacity:0.0">'+$this.data("text")+'</div>');
  522. var txt=$this.find('.overlaytext');
  523.  
  524. txt.css({'top':(t+h/2-parseInt(txt.outerHeight(),0)/2)+"px"});
  525. txt.animate({'opacity':'1.0','left':l+"px"},{duration:350,queue:false}, 'easeOutExpo');
  526. }
  527.  
  528. }
  529. }
  530. },
  531. function() {
  532.  
  533.  
  534.  
  535. var $this=jQuery(this);
  536. $this.find('.overlay').stop();
  537. $this.find('.overlay').animate({'opacity':0},{duration:350,queue:false}, 'easeOutSine');
  538. $this.find('.overlaytext').animate({'opacity':0},{duration:350,queue:false}, 'easeOutSine');
  539. $this.data('removetimer',setTimeout(function() {
  540. $this.find('.overlay').remove();
  541. $this.find('.overlaytext').remove();
  542.  
  543. },350));
  544.  
  545. });
  546.  
  547. }
  548.  
  549.  
  550.  
  551.  
  552. /* #Background Image
  553. ================================================== */
  554.  
  555.  
  556.  
  557. /**
  558. * jQuery.fullBg
  559. * Version 1.0
  560. * Copyright (c) 2010 c.bavota - http://bavotasan.com
  561. * Dual licensed under MIT and GPL.
  562. * Date: 02/23/2010
  563. **/
  564. (function($) {
  565. $.fn.fullBg = function(){
  566. var bgImg = $(this);
  567.  
  568. function resizeImg() {
  569. var imgwidth = bgImg.width();
  570. var imgheight = bgImg.height();
  571.  
  572. var winwidth = $(window).width();
  573. var winheight = $(window).height();
  574.  
  575. var widthratio = winwidth / imgwidth;
  576. var heightratio = winheight / imgheight;
  577.  
  578. var widthdiff = heightratio * imgwidth;
  579. var heightdiff = widthratio * imgheight;
  580.  
  581. if(heightdiff>winheight) {
  582. bgImg.css({
  583. width: winwidth+'px',
  584. height: heightdiff+'px'
  585. });
  586. } else {
  587. bgImg.css({
  588. width: widthdiff+'px',
  589. height: winheight+'px'
  590. });
  591. }
  592. }
  593. resizeImg();
  594. bgImg.fadeIn('200');
  595. $(window).resize(function() {
  596. resizeImg();
  597. });
  598. };
  599. })(jQuery)
  600.  
  601.  
  602.  
  603. /* #Contact Page Google Maps
  604. ================================================== */
  605.  
  606.  
  607.  
  608. function initGoogleMaps() {
  609. /* Google Maps Init */
  610. var myLatlng = new google.maps.LatLng(50.935816, 6.961212);
  611. var myOptions = {
  612. zoom: 14,
  613. center: myLatlng,
  614. popup: true,
  615. mapTypeId: google.maps.MapTypeId.ROADMAP
  616. }
  617. var map = new google.maps.Map(document.getElementById("googlemap"), myOptions);
  618.  
  619. var marker = new google.maps.Marker({
  620. position: myLatlng,
  621. map: map,
  622. title: "Our Office Location"
  623. });
  624. google.maps.event.addListener(marker, 'click', function() {
  625. map.setZoom(17);
  626. });
  627. }
  628.  
  629. function loadGoogleMaps() {
  630. /* Google Maps Load */
  631. if(jQuery('#googlemap').length != 0){
  632. var script = document.createElement("script");
  633. script.type = "text/javascript";
  634. script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initGoogleMaps";
  635. document.body.appendChild(script);
  636. }
  637. }
  638.  
  639.  
  640.  
  641. /* #Forms
  642. ================================================== */
  643.  
  644.  
  645.  
  646. function addForm(formtype) {
  647.  
  648. var formid = jQuery(formtype);
  649. var emailsend = false;
  650.  
  651. formid.find("button[name=send]").click(sendemail);
  652.  
  653. function validator() {
  654.  
  655. var emailcheck = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  656. var othercheck = /.{4}/;
  657. var noerror = true;
  658.  
  659. formid.find(".requiredfield").each(function () {
  660.  
  661. var fieldname = jQuery(this).attr('name');
  662. var value = jQuery(this).val();
  663. if(value == "Name *" || value == "Email *" || value == "Message *"){
  664. value = "";
  665. }
  666.  
  667. if(fieldname == "email"){
  668. if (!emailcheck.test(value)) {
  669. jQuery(this).addClass("formerror");
  670. noerror = false;
  671. } else {
  672. jQuery(this).removeClass("formerror");
  673. }
  674. }else{
  675. if (!othercheck.test(value)) {
  676. jQuery(this).addClass("formerror");
  677. noerror = false;
  678. } else {
  679. jQuery(this).removeClass("formerror");
  680. }
  681. }
  682. })
  683.  
  684. if(!noerror){
  685. formid.find(".errormessage").fadeIn();
  686. }
  687.  
  688. return noerror;
  689. }
  690.  
  691. function resetform() {
  692. formid.find("input").each(function () {
  693. jQuery(this).val("");
  694. })
  695. formid.find("textarea").val("");
  696. emailsend = false;
  697. }
  698.  
  699. function sendemail() {
  700. formid.find(".successmessage").hide();
  701. var phpfile = "";
  702. if(formtype=="#contactform"){
  703. phpfile = "php/contact.php";
  704. }else if(formtype=="#quickcontact"){
  705. phpfile = "php/quickcontact.php";
  706. }else{
  707. phpfile = "";
  708. }
  709. if (validator()) {
  710. if(!emailsend){
  711. emailsend = true;
  712. formid.find(".errormessage").hide();
  713. formid.find(".sendingmessage").show();
  714. jQuery.post(phpfile, formid.serialize(), function() {
  715. formid.find(".sendingmessage").hide();
  716. formid.find(".successmessage").fadeIn();
  717. resetform();
  718. });
  719. }
  720. }
  721. return false
  722. }
  723. }
  724.  
  725.  
  726.  
  727. /* #Portfolio
  728. ================================================== */
  729.  
  730.  
  731.  
  732. (function($,undefined){
  733.  
  734.  
  735.  
  736. ////////////////////////////
  737. // THE PLUGIN STARTS HERE //
  738. ////////////////////////////
  739.  
  740. $.fn.extend({
  741.  
  742.  
  743. // OUR PLUGIN HERE :)
  744. tpportfolio: function(options) {
  745.  
  746.  
  747.  
  748. ////////////////////////////////
  749. // SET DEFAULT VALUES OF ITEM //
  750. ////////////////////////////////
  751. var defaults = {
  752. speed:500,
  753. row:2,
  754. nonSelectedAlpha:0,
  755. portfolioContainer:".portfolio"
  756. };
  757.  
  758. options = $.extend({}, $.fn.tpportfolio.defaults, options);
  759.  
  760.  
  761. return this.each(function() {
  762.  
  763. var opt=options;
  764. var bod= $(this);
  765.  
  766. var start=0;
  767. var many =bod.find('.all-group').length;
  768. var lasts = many - (Math.floor(many / opt.row) * opt.row);
  769.  
  770. if (opt.nonSelectedAlpha===0) {
  771. bod.find(opt.portfolioContainer).wrap('<div class="portfoliooutterholder" style="position:relative;clear:both;overflow:hidden;"></div>');
  772. }
  773.  
  774. if (lasts==0) lasts=opt.row;
  775.  
  776.  
  777.  
  778. // ADD ALPHA AND OMEGA CLASS FOR FIRST AND LAST ITEM !
  779. bod.find('.all-group').each(function(i) {
  780. start++;
  781. var item=$(this);
  782.  
  783. //alert(item.find('img:first').width());
  784. if (start==1)
  785. item.addClass('alpha');
  786.  
  787.  
  788. if (start===opt.row) {
  789. item.addClass('omega');
  790. start=0;
  791. }
  792.  
  793. if (i>=many-lasts) item.addClass('nopadding');
  794.  
  795. });
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802. // SET UP THE CLICKS AND THE ANIMATIONS
  803. bod.find('.portfolio_selector').each(function(){
  804.  
  805. // PREPARE THE FIRST START HERE
  806. var selector=$(this);
  807. if (selector.data('group') === "all-group") {
  808. selector.addClass('selected_selector');
  809. } else {
  810. selector.animate({'opacity':0.35},{duration:opt.speed,queue:false});
  811. }
  812.  
  813.  
  814. // HOVER EFFECT
  815. selector.hover(
  816. function() {
  817. var sels=$(this);
  818. sels.stop();
  819. sels.animate({'opacity':1},{duration:opt.speed,queue:false});
  820. },
  821. function() {
  822. var sels=$(this);
  823. if (!(sels.hasClass('selected_selector'))) {
  824. sels.stop();
  825. sels.animate({'opacity':0.35},{duration:opt.speed,queue:false});
  826. }
  827. });
  828.  
  829.  
  830.  
  831. // CLICK EFFECT
  832. selector.click(function() {
  833.  
  834. // FOR HIDING PORTFOLIO SET THE OUTER CONTAINER HEIGHT
  835. if (opt.nonSelectedAlpha===0) {
  836. // SET THE OUTTER AND INNER HEIGHT OF THE CONTAINER DIV
  837. var oholder = bod.find('.portfoliooutterholder');
  838. var iholder = bod.find(opt.portfolioContainer);
  839. oholder.css({'width':'100%','height':iholder.height()+"px"});
  840.  
  841. if (!oholder.hasClass("row")) oholder.addClass("row");
  842. }
  843.  
  844.  
  845. // ADD AND REMOVE THE FADES FROM THE SELECTORS !!
  846. // FIRST REMOVE THE SELECTED SELECTORS
  847. bod.find('.portfolio_selector').each(function(){
  848. var sels=$(this);
  849. sels.removeClass('selected_selector');
  850. });
  851.  
  852. // THAN ADD THE SELECTED SELECTOR TO THE NEW ONE
  853. selector.addClass("selected_selector");
  854.  
  855. // THAN FADE OUT ALL NOT NEEDED SELECTOR
  856. bod.find('.portfolio_selector').each(function(){
  857. var sels=$(this);
  858. sels.stop();
  859. if (sels.hasClass('selected_selector')) {
  860. sels.animate({'opacity':1},{duration:opt.speed,queue:false});
  861. } else {
  862. sels.animate({'opacity':0.35},{duration:opt.speed,queue:false});
  863. }
  864. });
  865.  
  866.  
  867.  
  868.  
  869. // DEPENDING ON HOW FAR WE SHOUD HIDE THE REsT OF THE ITEMS, WE NEED TO REORGANISE THE FULL PORTFOLIO
  870. if (opt.nonSelectedAlpha===0) {
  871.  
  872. var aoh = 0; // Amount Of Items to Hide
  873. var aos = 0; // Amount Of Items to Show
  874.  
  875. $('body').find('.all-group').each(function(i) {
  876.  
  877. var item=$(this);
  878. item.stop();
  879.  
  880. var img=item.find('img:first');
  881.  
  882. // CALCULATE THE CURRENT IMAGE SIZES
  883. var l=img.position().left;
  884. var t=img.position().top;
  885. var iw=img.width();
  886. var ih=img.height();
  887.  
  888. item.css({'position':'relative'});
  889.  
  890. if (item.find('.deletemesoon').length==0)
  891. img.wrap('<div class="deletemesoon" style="position:relative;overflow:hidden;width:100%;height:'+ih+'px"></div>');
  892. img.css({'position':'absolute'});
  893.  
  894. //if (item.css('display') != "none") aoh++;
  895. setTimeout(function() {
  896. img.animate({'top':ih+'px'},{duration:opt.speed,queue:false});
  897. item.animate({'opacity':0},{duration:opt.speed,queue:false});
  898. },aoh*125);
  899.  
  900. });
  901.  
  902.  
  903. // REMOVE THE ITEMS WE DONT NEED, AND REMOVE THE CLASSES
  904. setTimeout(function() {
  905. $('body').find('.all-group').each(function(i) {
  906. var item=$(this);
  907.  
  908.  
  909.  
  910. if (!item.hasClass(selector.data('group')))
  911. {
  912. item.css({'display':'none'})
  913. } else {
  914. item.css({'display':'block','opacity':0})
  915. }
  916. item.removeClass('alpha')
  917. item.removeClass('omega')
  918. item.remove('nopadding');
  919.  
  920.  
  921. });
  922. },opt.speed+aoh*125);
  923.  
  924.  
  925. setTimeout(function() {
  926.  
  927. var start=0;
  928. var many = $('body').find('.'+selector.data('group')).length;
  929. var lasts = many - (Math.floor(many / opt.row) * opt.row);
  930. if (lasts==0) lasts=opt.row;
  931.  
  932. $('body').find('.'+selector.data('group')).each(function(i) {
  933. start++;
  934. var item=$(this);
  935. item.css({'display':'block','opacity':0});
  936.  
  937. // STOP IMG ANIMATION
  938. var img=item.find('img:first');
  939. var dele=item.find('.deletemesoon');
  940. dele.css({'width':'100%'});
  941. img.css({'top':'0px'});
  942. dele.css({'height':img.height()+"px"});
  943.  
  944. img.stop();
  945. img.css({'position':'absolute','top':img.height()+"px"});
  946. img.animate({'top':'0px'},{duration:opt.speed,queue:false});
  947.  
  948. var oholder = bod.find('.portfoliooutterholder');
  949.  
  950.  
  951. setTimeout(function() {
  952. img.prependTo(item.find('a:first'));
  953. img.css({'position':'relative','top':'0px'});
  954. item.find('.deletemesoon').remove();
  955.  
  956.  
  957. },opt.speed+10+aoh*125);
  958.  
  959.  
  960.  
  961. item.stop();
  962. item.animate({'opacity':1},{duration:opt.speed,queue:false});
  963.  
  964. if (start==1)
  965. item.addClass('alpha');
  966.  
  967. if (start===opt.row) {
  968. item.addClass('omega');
  969. start=0;
  970. }
  971. if (i>=many-lasts) {
  972. item.addClass('nopadding');
  973. } else {
  974. item.removeClass('nopadding');
  975. }
  976. });
  977.  
  978.  
  979. buildRows(opt);
  980.  
  981. // SET HEIGHT OF PORTFOLIO HOLDER
  982.  
  983.  
  984. var iholder = bod.find(opt.portfolioContainer);
  985. oholder.stop();
  986.  
  987. oholder.animate({'height':iholder.outerHeight()+"px"},{duration:400,queue:false});
  988.  
  989. },(opt.speed+20)+(aoh*125));
  990.  
  991. } else {
  992.  
  993.  
  994. $('body').find('.nonclickbar').remove();
  995. // IF UNSLECTED ARE STILL VISIBLE, WE DONT NEED TO REMOVE THEM...
  996.  
  997.  
  998. $('body').find('.all-group').each(function() {
  999.  
  1000. var item=$(this);
  1001. item.stop();
  1002. if (item.hasClass(selector.data('group'))) {
  1003. item.animate({'opacity':1},{duration:opt.speed,queue:false});
  1004. } else {
  1005.  
  1006. var w=item.outerWidth();
  1007. var h=item.outerHeight();
  1008.  
  1009.  
  1010.  
  1011. var t=item.position().top;
  1012. var l=item.position().left;
  1013.  
  1014.  
  1015. // ADD THE OVERLAY ON THE A TAG BY HOVER
  1016. item.parent().append('<div class="nonclickbar" style="position:absolute;top:'+t+'px;left:'+l+'px;width:'+w+'px;height:'+h+'px;background:#000"></div>');
  1017.  
  1018. item.parent().find('.nonclickbar').css({'opacity':0.0}).addClass(item.data('row'));
  1019.  
  1020.  
  1021. item.animate({'opacity':opt.nonSelectedAlpha/100},{duration:opt.speed,queue:false});
  1022.  
  1023.  
  1024. }
  1025.  
  1026. });
  1027. setTimeout(function() {buildRows(opt);},100);
  1028. }
  1029. return false;
  1030. });
  1031. });
  1032.  
  1033.  
  1034. var lodedimg=0;
  1035. bod.find('.all-group').waitForImages(
  1036. function() {
  1037. buildRows(opt);
  1038. if (opt.nonSelectedAlpha===0) {
  1039. // SET THE OUTTER AND INNER HEIGHT OF THE CONTAINER DIV
  1040. var oholder = bod.find('.portfoliooutterholder');
  1041. var iholder = bod.find(opt.portfolioContainer);
  1042. oholder.css({'width':'100%','height':iholder.height()+"px"});
  1043. if (!oholder.hasClass("row")) oholder.addClass("row");
  1044. }
  1045.  
  1046. },
  1047.  
  1048. function() {
  1049. lodedimg = lodedimg+1;
  1050. buildRows(opt);
  1051.  
  1052. }
  1053.  
  1054. );
  1055.  
  1056. buildRows(opt,true);
  1057. $(window).resize(function() {
  1058.  
  1059. clearTimeout(opt.resized);
  1060. opt.resized=setTimeout(function() {
  1061. buildRows(opt,true);
  1062. },100);
  1063.  
  1064. });
  1065.  
  1066. })
  1067. }
  1068. })
  1069.  
  1070. //////////////////////////////////////////////
  1071. // BUILD THE ROWS ON RESCALING OR AT START //
  1072. ////////////////////////////////////////////
  1073. function buildRows(opt,no) {
  1074.  
  1075.  
  1076. var bod=$('body');
  1077.  
  1078. // REMOVE ACTUAL ROWS (IF THERE IS ANY)
  1079. bod.find('.rowwrap').each(function(i) {
  1080. var item=$(this).find('.rowed:first');
  1081. item.unwrap();
  1082.  
  1083. });
  1084.  
  1085. // REMOVE THE ROWED AND ROWx CLASSES
  1086. bod.find('.rowed').each(function(i) {
  1087. var item=$(this);
  1088. item.removeClass(item.data('row'));
  1089. item.removeClass('rowed');
  1090. });
  1091.  
  1092. var row=0;
  1093.  
  1094. // GO THROUGH, AND CHECK ALPHAS AND OMEGAS
  1095. bod.find('.all-group').each(function(i) {
  1096. var item=$(this);
  1097. item.addClass('row'+row);
  1098. item.addClass('rowed');
  1099. item.data('row','row'+row);
  1100. if (item.hasClass('omega')) {
  1101. row++;
  1102. }
  1103. });
  1104.  
  1105.  
  1106. // CREATE ROWS AROUND THE ITEMS
  1107. for (i=0;i<row;i++) {
  1108. bod.find('.row'+i).wrapAll('<div class="rowwrap" style="position:relative;height:0px;width:100%;"></div>');
  1109. }
  1110.  
  1111. // SET HEIGHT OF EACH ROW HERE
  1112.  
  1113. bod.find('.killerclear').remove();
  1114. var maxrowa = bod.find('.rowwrap').length;
  1115.  
  1116. bod.find('.rowwrap').each(function(j) {
  1117. var $this=$(this);
  1118. var max=0;
  1119. $this.find('.rowed').each(function(i) {
  1120. if ($(this).css('display')!="none") {
  1121. //console.log(j+". Row Element "+i+". height:"+$(this).outerHeight());
  1122. if (max<$(this).height()) max=$(this).outerHeight();
  1123. }
  1124. });
  1125. //console.log(j+'. Row Berechnete:'+max);
  1126. $this.css({'height':(max)+"px"}); //max+"px"});
  1127. //if (j<maxrowa-1) {
  1128. //console.log('Added Clear');
  1129. $this.after('<div style="clear:both" class="killerclear"></div>');
  1130. //} else {
  1131. // console.log('Last Row has no Clear !!');
  1132. //}
  1133.  
  1134. });
  1135.  
  1136.  
  1137. var oholder = bod.find('.portfoliooutterholder');
  1138. var iholder = bod.find(opt.portfolioContainer);
  1139. oholder.stop();
  1140. oholder.animate({'height':iholder.outerHeight()+"px"},{duration:400,queue:false});
  1141.  
  1142. };
  1143.  
  1144.  
  1145. })(jQuery);
  1146.  
  1147.  
  1148.  
  1149. /*
  1150. * waitForImages 1.3.3
  1151. * -----------------
  1152. * Provides a callback when all images have loaded in your given selector.
  1153. * http://www.alexanderdickson.com/
  1154. *
  1155. *
  1156. * Copyright (c) 2011 Alex Dickson
  1157. * Licensed under the MIT licenses.
  1158. * See website for more info.
  1159. *
  1160. */
  1161.  
  1162. ;(function($) {
  1163.  
  1164. // CSS properties which contain references to images.
  1165. $.waitForImages = {
  1166. hasImageProperties: [
  1167. 'backgroundImage',
  1168. 'listStyleImage',
  1169. 'borderImage',
  1170. 'borderCornerImage'
  1171. ]
  1172. };
  1173.  
  1174. // Custom selector to find `img` elements that have a valid `src` attribute and have not already loaded.
  1175. $.expr[':'].uncached = function(obj) {
  1176. // Firefox will always return `true` even if the image has not been downloaded.
  1177. // Doing it this way works in Firefox.
  1178. var img = document.createElement('img');
  1179. img.src = obj.src;
  1180. return $(obj).is('img[src!=""]') && ! img.complete;
  1181. };
  1182.  
  1183. $.fn.waitForImages = function(finishedCallback, eachCallback, waitForAll) {
  1184.  
  1185. // Handle options object.
  1186. if ($.isPlainObject(arguments[0])) {
  1187. eachCallback = finishedCallback.each;
  1188. waitForAll = finishedCallback.waitForAll;
  1189. finishedCallback = finishedCallback.finished;
  1190. }
  1191.  
  1192. // Handle missing callbacks.
  1193. finishedCallback = finishedCallback || $.noop;
  1194. eachCallback = eachCallback || $.noop;
  1195.  
  1196. // Convert waitForAll to Boolean
  1197. waitForAll = !! waitForAll;
  1198.  
  1199. // Ensure callbacks are functions.
  1200. if (!$.isFunction(finishedCallback) || !$.isFunction(eachCallback)) {
  1201. throw new TypeError('An invalid callback was supplied.');
  1202. };
  1203.  
  1204. return this.each(function() {
  1205. // Build a list of all imgs, dependent on what images will be considered.
  1206. var obj = $(this),
  1207. allImgs = [];
  1208.  
  1209. if (waitForAll) {
  1210. // CSS properties which may contain an image.
  1211. var hasImgProperties = $.waitForImages.hasImageProperties || [],
  1212. matchUrl = /url\((['"]?)(.*?)\1\)/g;
  1213.  
  1214. // Get all elements, as any one of them could have a background image.
  1215. obj.find('*').each(function() {
  1216. var element = $(this);
  1217.  
  1218. // If an `img` element, add it. But keep iterating in case it has a background image too.
  1219. if (element.is('img:uncached')) {
  1220. allImgs.push({
  1221. src: element.attr('src'),
  1222. element: element[0]
  1223. });
  1224. }
  1225.  
  1226. $.each(hasImgProperties, function(i, property) {
  1227. var propertyValue = element.css(property);
  1228. // If it doesn't contain this property, skip.
  1229. if ( ! propertyValue) {
  1230. return true;
  1231. }
  1232.  
  1233. // Get all url() of this element.
  1234. var match;
  1235. while (match = matchUrl.exec(propertyValue)) {
  1236. allImgs.push({
  1237. src: match[2],
  1238. element: element[0]
  1239. });
  1240. };
  1241. });
  1242. });
  1243. } else {
  1244. // For images only, the task is simpler.
  1245. obj
  1246. .find('img:uncached')
  1247. .each(function() {
  1248. allImgs.push({
  1249. src: this.src,
  1250. element: this
  1251. });
  1252. });
  1253. };
  1254.  
  1255. var allImgsLength = allImgs.length,
  1256. allImgsLoaded = 0;
  1257.  
  1258. // If no images found, don't bother.
  1259. if (allImgsLength == 0) {
  1260. finishedCallback.call(obj[0]);
  1261. };
  1262.  
  1263. $.each(allImgs, function(i, img) {
  1264.  
  1265. var image = new Image;
  1266.  
  1267. // Handle the image loading and error with the same callback.
  1268. $(image).bind('load error', function(event) {
  1269. allImgsLoaded++;
  1270.  
  1271. // If an error occurred with loading the image, set the third argument accordingly.
  1272. eachCallback.call(img.element, allImgsLoaded, allImgsLength, event.type == 'load');
  1273.  
  1274. if (allImgsLoaded == allImgsLength) {
  1275. finishedCallback.call(obj[0]);
  1276. return false;
  1277. };
  1278.  
  1279. });
  1280.  
  1281. image.src = img.src;
  1282. });
  1283. });
  1284. };
  1285. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement