Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 56.76 KB | None | 0 0
  1. /* ====== SHARED VARS ====== */
  2.  
  3. var phone, touch, ltie9, lteie9, wh, ww, dh, ar, fonts, ieMobile;
  4.  
  5. var ua = navigator.userAgent;
  6. var winLoc = window.location.toString();
  7.  
  8. var is_webkit = ua.match(/webkit/i);
  9. var is_firefox = ua.match(/gecko/i);
  10. var is_newer_ie = ua.match(/msie (9|([1-9][0-9]))/i);
  11. var is_older_ie = ua.match(/msie/i) && !is_newer_ie;
  12. var is_ancient_ie = ua.match(/msie 6/i);
  13. var is_mobile = ua.match(/mobile/i);
  14. var is_OSX = (ua.match(/(iPad|iPhone|iPod|Macintosh)/g) ? true : false);
  15.  
  16. var nua = navigator.userAgent;
  17. var is_android = ((nua.indexOf('Mozilla/5.0') > -1 && nua.indexOf('Android ') > -1 && nua.indexOf('AppleWebKit') > -1) && !(nua.indexOf('Chrome') > -1));
  18.  
  19. var useTransform = true;
  20. var use2DTransform = (ua.match(/msie 9/i) || winLoc.match(/transform\=2d/i));
  21. //
  22. // To be used like this
  23. //
  24. // if (!use2DTransform) {
  25. // transformParam = 'translate3d(...)';
  26. // } else {
  27. // transformParam = 'translateY(...)';
  28. // }
  29. var transform;
  30.  
  31. // setting up transform prefixes
  32. var prefixes = {
  33. webkit: 'webkitTransform',
  34. firefox: 'MozTransform',
  35. ie: 'msTransform',
  36. w3c: 'transform'
  37. };
  38.  
  39. if (useTransform) {
  40. if (is_webkit) {
  41. transform = prefixes.webkit;
  42. } else if (is_firefox) {
  43. transform = prefixes.firefox;
  44. } else if (is_newer_ie) {
  45. transform = prefixes.ie;
  46. }
  47. }
  48.  
  49. /* --- To enable verbose debug add to Theme Options > Custom Code footer -> globalDebug=true; --- */
  50. var globalDebug = false,
  51. timestamp;
  52.  
  53. (function($,window,undefined) {
  54.  
  55. /* --- DETECT VIEWPORT SIZE --- */
  56.  
  57. function browserSize(){
  58. wh = $(window).height();
  59. ww = $(window).width();
  60. dh = $(document).height();
  61. ar = ww/wh;
  62. }
  63.  
  64.  
  65. /* --- DETECT PLATFORM --- */
  66.  
  67. function platformDetect(){
  68. $.support.touch = 'ontouchend' in document;
  69. var navUA = navigator.userAgent.toLowerCase(),
  70. navPlat = navigator.platform.toLowerCase();
  71.  
  72.  
  73. var isiPhone = navPlat.indexOf("iphone"),
  74. isiPod = navPlat.indexOf("ipod"),
  75. isAndroidPhone = navPlat.indexOf("android"),
  76. safari = (navUA.indexOf('safari') != -1 && navUA.indexOf('chrome') == -1) ? true : false,
  77. svgSupport = (window.SVGAngle) ? true : false,
  78. svgSupportAlt = (document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")) ? true : false,
  79. ff3x = (/gecko/i.test(navUA) && /rv:1.9/i.test(navUA)) ? true : false;
  80.  
  81. phone = (isiPhone > -1 || isiPod > -1 || isAndroidPhone > -1) ? true : false;
  82. touch = $.support.touch ? true : false;
  83. ltie9 = $.support.leadingWhitespace ? false : true;
  84. lteie9 = typeof window.atob === 'undefined' ? true : false;
  85.  
  86. ieMobile = navigator.userAgent.match(/Windows Phone/i) ? true : false;
  87.  
  88.  
  89.  
  90. var $bod = $('body');
  91.  
  92. if (touch || ieMobile) {
  93. $('html').addClass('touch');
  94. }
  95. if (safari) $bod.addClass('safari');
  96. if (phone) $bod.addClass('phone');
  97.  
  98. }
  99.  
  100. /* --- Magnific Popup Initialization --- */
  101.  
  102. function magnificPopupInit() {
  103. if (globalDebug) {console.log("Magnific Popup - Init");}
  104.  
  105. $('.js-gallery').each(function() { // the containers for all your galleries should have the class gallery
  106. $(this).magnificPopup({
  107. delegate: '.mosaic__item.magnific-link a, .masonry__item--image__container a', // the container for each your gallery items
  108. removalDelay: 500,
  109. mainClass: 'mfp-fade',
  110. image: {
  111. titleSrc: function (item){
  112. var output = '';
  113. if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  114. output = item.el.attr('data-title');
  115. }
  116. if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  117. output += '<small>'+item.el.attr('data-alt')+'</small>';
  118. }
  119. return output;
  120. }
  121. },
  122. iframe: {
  123. markup:
  124. '<div class="mfp-figure mfp-figure--video">'+
  125. '<button class="mfp-close"></button>'+
  126. '<div>'+
  127. '<div class="mfp-iframe-scaler">'+
  128. '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
  129. '</div>'+
  130. '</div>'+
  131. '<div class="mfp-bottom-bar">'+
  132. '<div class="mfp-title mfp-title--video"></div>'+
  133. '<div class="mfp-counter"></div>'+
  134. '</div>'+
  135. '</div>',
  136. patterns: {
  137. youtube: {
  138. index: 'youtube.com/', // String that detects type of video (in this case YouTube). Simply via url.indexOf(index).
  139. id: function(url){
  140. var video_id = url.split('v=')[1];
  141. var ampersandPosition = video_id.indexOf('&');
  142. if(ampersandPosition != -1) {
  143. video_id = video_id.substring(0, ampersandPosition);
  144. }
  145.  
  146. return video_id;
  147. }, // String that splits URL in a two parts, second part should be %id%
  148. // Or null - full URL will be returned
  149. // Or a function that should return %id%, for example:
  150. // id: function(url) { return 'parsed id'; }
  151. src: '//www.youtube.com/embed/%id%' // URL that will be set as a source for iframe.
  152. },
  153. youtu_be: {
  154. index: 'youtu.be/', // String that detects type of video (in this case YouTube). Simply via url.indexOf(index).
  155. id: '.be/', // String that splits URL in a two parts, second part should be %id%
  156. // Or null - full URL will be returned
  157. // Or a function that should return %id%, for example:
  158. // id: function(url) { return 'parsed id'; }
  159. src: '//www.youtube.com/embed/%id%' // URL that will be set as a source for iframe.
  160. },
  161.  
  162. vimeo: {
  163. index: 'vimeo.com/',
  164. id: '/',
  165. src: '//player.vimeo.com/video/%id%'
  166. },
  167. gmaps: {
  168. index: '//maps.google.',
  169. src: '%id%&output=embed'
  170. }
  171. // you may add here more sources
  172. },
  173. srcAction: 'iframe_src' // Templating object key. First part defines CSS selector, second attribute. "iframe_src" means: find "iframe" and set attribute "src".
  174. },
  175. gallery:{
  176. enabled:true,
  177. navigateByImgClick: true,
  178. // arrowMarkup: '<a href="#" class="mfp-arrow mfp-arrow-%dir% control-item arrow-button arrow-button--%dir%"></a>',
  179. tPrev: 'Previous (Left arrow key)', // title for left button
  180. tNext: 'Next (Right arrow key)', // title for right button
  181. // tCounter: '<div class="gallery-control gallery-control--popup"><div class="control-item count js-gallery-current-slide"><span class="js-unit">%curr%</span><sup class="js-gallery-slides-total">%total%</sup></div></div>'
  182. tCounter: '<div class="gallery-control gallery-control--popup"><a href="#" class="control-item arrow-button arrow-button--left js-arrow-popup-prev"></a><div class="control-item count js-gallery-current-slide"><span class="js-unit">%curr%</span><sup class="js-gallery-slides-total">%total%</sup></div><a href="#" class="control-item arrow-button arrow-button--right js-arrow-popup-next"></a></div>'
  183. },
  184. callbacks:{
  185. elementParse: function(item) {
  186. $(item).find('iframe').each(function(){
  187. var url = $(this).attr("src");
  188. $(this).attr("src", setQueryParameter(url, "wmode", "transparent"));
  189. });
  190.  
  191. if(this.currItem != undefined){
  192. item = this.currItem;
  193. }
  194.  
  195. var output = '';
  196. if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  197. output = item.el.attr('data-title');
  198. }
  199. if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  200. output += '<small>'+item.el.attr('data-alt')+'</small>';
  201. }
  202.  
  203. $('.mfp-title--video').html(output);
  204. },
  205. change: function(item) {
  206. $(this.content).find('iframe').each(function(){
  207. var url = $(this).attr("src");
  208. $(this).attr("src", setQueryParameter(url, "wmode", "transparent"));
  209. });
  210.  
  211. var output = '';
  212. if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  213. output = item.el.attr('data-title');
  214. }
  215. if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  216. output += '<small>'+item.el.attr('data-alt')+'</small>';
  217. }
  218.  
  219. $('.mfp-title--video').html(output);
  220. }
  221. }
  222. });
  223. });
  224.  
  225. // hide title on hover over images so we don't have that ugly tooltip
  226. // replace when hover leaves
  227. var tempGalleryTitle = '';
  228. $('.js-gallery a').hover(
  229. function () {
  230. tempGalleryTitle = $(this).attr('title');
  231. $(this).attr({'title':''});
  232. },
  233. function () {
  234. $(this).attr({'title':tempGalleryTitle});
  235. }
  236. );
  237.  
  238. $('.js-project-gallery').each(function() { // the containers for all your galleries should have the class gallery
  239. $(this).magnificPopup({
  240. delegate: 'a[href$=".jpg"], a[href$=".png"], a[href$=".gif"], .mfp-iframe', // the container for each your gallery items
  241. type: 'image',
  242. removalDelay: 500,
  243. mainClass: 'mfp-fade',
  244. image: {
  245. titleSrc: function (item){
  246. var output = '';
  247. if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  248. output = item.el.attr('data-title');
  249. }
  250. if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  251. output += '<small>'+item.el.attr('data-alt')+'</small>';
  252. }
  253. return output;
  254. }
  255. },
  256. iframe: {
  257. markup:
  258. '<div class="mfp-figure mfp-figure--video">'+
  259. '<div>'+
  260. '<div class="mfp-close"></div>'+
  261. '<div class="mfp-iframe-scaler">'+
  262. '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
  263. '</div>'+
  264. '</div>'+
  265. '<div class="mfp-bottom-bar">'+
  266. '<div class="mfp-title mfp-title--video"></div>'+
  267. '<div class="mfp-counter"></div>'+
  268. '</div>'+
  269. '</div>',
  270. patterns: {
  271. youtube: {
  272. index: 'youtube.com/', // String that detects type of video (in this case YouTube). Simply via url.indexOf(index).
  273. id: 'v=', // String that splits URL in a two parts, second part should be %id%
  274. // Or null - full URL will be returned
  275. // Or a function that should return %id%, for example:
  276. // id: function(url) { return 'parsed id'; }
  277. src: '//www.youtube.com/embed/%id%' // URL that will be set as a source for iframe.
  278. },
  279. vimeo: {
  280. index: 'vimeo.com/',
  281. id: '/',
  282. src: '//player.vimeo.com/video/%id%'
  283. },
  284. gmaps: {
  285. index: '//maps.google.',
  286. src: '%id%&output=embed'
  287. }
  288. // you may add here more sources
  289. },
  290. srcAction: 'iframe_src' // Templating object key. First part defines CSS selector, second attribute. "iframe_src" means: find "iframe" and set attribute "src".
  291. },
  292. gallery:{
  293. enabled:true,
  294. navigateByImgClick: true,
  295. tPrev: 'Previous (Left arrow key)', // title for left button
  296. tNext: 'Next (Right arrow key)', // title for right button
  297. tCounter: '<div class="gallery-control gallery-control--popup"><a href="#" class="control-item arrow-button arrow-button--left js-arrow-popup-prev"></a><div class="control-item count js-gallery-current-slide"><span class="js-unit">%curr%</span><sup class="js-gallery-slides-total">%total%</sup></div><a href="#" class="control-item arrow-button arrow-button--right js-arrow-popup-next"></a></div>'
  298. },
  299. callbacks:{
  300. elementParse: function(item) {
  301. $(item).find('iframe').each(function(){
  302. var url = $(this).attr("src");
  303. $(this).attr("src", url+"?wmode=transparent");
  304. });
  305.  
  306. if(this.currItem != undefined){
  307. item = this.currItem;
  308. }
  309.  
  310. var output = '';
  311. if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  312. output = item.el.attr('data-title');
  313. }
  314. if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  315. output += '<small>'+item.el.attr('data-alt')+'</small>';
  316. }
  317.  
  318. $('.mfp-title--video').html(output);
  319. },
  320. change: function(item) {
  321. $(this.content).find('iframe').each(function(){
  322. var url = $(this).attr("src");
  323. $(this).attr("src", url+"?wmode=transparent");
  324. });
  325.  
  326. var output = '';
  327. if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  328. output = item.el.attr('data-title');
  329. }
  330. if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  331. output += '<small>'+item.el.attr('data-alt')+'</small>';
  332. }
  333.  
  334. $('.mfp-title--video').html(output);
  335. }
  336. }
  337. });
  338. });
  339.  
  340. //Magnific Popup for any other <a> tag that links to an image
  341. function blog_posts_popup(e) {
  342. if (jQuery().magnificPopup) {
  343. e.magnificPopup({
  344. type: 'image',
  345. closeOnContentClick: false,
  346. closeBtnInside: false,
  347. removalDelay: 500,
  348. mainClass: 'mfp-fade',
  349. image: {
  350. titleSrc: function (item){
  351. var output = '';
  352. if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  353. output = item.el.attr('data-title');
  354. }
  355. if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  356. output += '<small>'+item.el.attr('data-alt')+'</small>';
  357. }
  358. return output;
  359. }
  360. },
  361. gallery: {
  362. enabled:true,
  363. navigateByImgClick: true,
  364. tPrev: 'Previous (Left arrow key)', // title for left button
  365. tNext: 'Next (Right arrow key)', // title for right button
  366. tCounter: '<div class="gallery-control gallery-control--popup"><a href="#" class="control-item arrow-button arrow-button--left js-arrow-popup-prev"></a><div class="control-item count js-gallery-current-slide"><span class="js-unit">%curr%</span><sup class="js-gallery-slides-total">%total%</sup></div><a href="#" class="control-item arrow-button arrow-button--right js-arrow-popup-next"></a></div>'
  367. },
  368. callbacks:{
  369. elementParse: function(item) {
  370. $(item).find('iframe').each(function(){
  371. var url = $(this).attr("src");
  372. $(this).attr("src", url+"?wmode=transparent");
  373. });
  374.  
  375. if(this.currItem != undefined){
  376. item = this.currItem;
  377. }
  378.  
  379. var output = '';
  380. if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  381. output = item.el.attr('data-title');
  382. }
  383. if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  384. output += '<small>'+item.el.attr('data-alt')+'</small>';
  385. }
  386.  
  387. $('.mfp-title--video').html(output);
  388. },
  389. change: function(item) {
  390. $(this.content).find('iframe').each(function(){
  391. var url = $(this).attr("src");
  392. $(this).attr("src", url+"?wmode=transparent");
  393. });
  394.  
  395. var output = '';
  396. if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  397. output = item.el.attr('data-title');
  398. }
  399. if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  400. output += '<small>'+item.el.attr('data-alt')+'</small>';
  401. }
  402.  
  403. $('.mfp-title--video').html(output);
  404. }
  405. }
  406. });
  407. }
  408. }
  409.  
  410. var blog_posts_images = $('.post a[href$=".jpg"], .post a[href$=".png"], .post a[href$=".gif"], .page a[href$=".jpg"], .page a[href$=".png"], .page a[href$=".gif"]');
  411. if(blog_posts_images.length) { blog_posts_popup(blog_posts_images); }
  412.  
  413. $('.popup-video').magnificPopup({
  414. type: 'iframe',
  415. closeOnContentClick: false,
  416. closeBtnInside: false,
  417. removalDelay: 500,
  418. mainClass: 'mfp-fade',
  419.  
  420. iframe: {
  421. markup:
  422. '<div class="mfp-figure mfp-figure--video">'+
  423. '<div>'+
  424. '<div class="mfp-close"></div>'+
  425. '<div class="mfp-iframe-scaler">'+
  426. '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
  427. '</div>'+
  428. '</div>'+
  429. '<div class="mfp-bottom-bar">'+
  430. '<div class="mfp-title mfp-title--video"></div>'+
  431. '<div class="mfp-counter"></div>'+
  432. '</div>'+
  433. '</div>',
  434. patterns: {
  435. youtube: {
  436. index: 'youtube.com/', // String that detects type of video (in this case YouTube). Simply via url.indexOf(index).
  437. id: 'v=', // String that splits URL in a two parts, second part should be %id%
  438. // Or null - full URL will be returned
  439. // Or a function that should return %id%, for example:
  440. // id: function(url) { return 'parsed id'; }
  441. src: '//www.youtube.com/embed/%id%' // URL that will be set as a source for iframe.
  442. },
  443. vimeo: {
  444. index: 'vimeo.com/',
  445. id: '/',
  446. src: '//player.vimeo.com/video/%id%'
  447. },
  448. gmaps: {
  449. index: '//maps.google.',
  450. src: '%id%&output=embed'
  451. }
  452. // you may add here more sources
  453. },
  454. srcAction: 'iframe_src' // Templating object key. First part defines CSS selector, second attribute. "iframe_src" means: find "iframe" and set attribute "src".
  455. },
  456. callbacks:{
  457. // elementParse: function(item) {
  458. // $(item).find('iframe').each(function(){
  459. // var url = $(this).attr("src");
  460. // $(this).attr("src", url+"?wmode=transparent");
  461. // });
  462. //
  463. // if(this.currItem != undefined){
  464. // item = this.currItem;
  465. // }
  466. //
  467. // var output = '';
  468. // var $image = $(item.el).children("img:first");
  469. // if ($image.length) {
  470. // if ( typeof $image.attr('title') !== "undefined" && $image.attr('title') !== "") {
  471. // output = $image.attr('title');
  472. // }
  473. // if ( typeof $image.attr('alt') !== "undefined" && $image.attr('alt') !== "") {
  474. // output += '<small>'+$image.attr('alt')+'</small>';
  475. // }
  476. // }
  477. //
  478. // $('.mfp-title--video').html(output);
  479. // },
  480. // change: function(item) {
  481. // $(this.content).find('iframe').each(function(){
  482. // var url = $(this).attr("src");
  483. // $(this).attr("src", url+"?wmode=transparent");
  484. // });
  485. //
  486. // var output = '';
  487. // if ( typeof item.el.attr('data-title') !== "undefined" && item.el.attr('data-title') !== "") {
  488. // output = item.el.attr('data-title');
  489. // }
  490. // if ( typeof item.el.attr('data-alt') !== "undefined" && item.el.attr('data-alt') !== "") {
  491. // output += '<small>'+item.el.attr('data-alt')+'</small>';
  492. // }
  493. //
  494. // $('.mfp-title--video').html(output);
  495. // }
  496. }
  497. });
  498.  
  499. // hide title on hover over images so we don't have that ugly tooltip
  500. // replace when hover leaves
  501. var tempProjectTitle = '';
  502. $('.js-project-gallery a').hover(
  503. function () {
  504. tempProjectTitle = $(this).attr('title');
  505. $(this).attr({'title':''});
  506. },
  507. function () {
  508. $(this).attr({'title':tempProjectTitle});
  509. }
  510. );
  511.  
  512. //for the PixProof galleries in case they are used
  513. $('.js-pixproof-lens-gallery').each(function() { // the containers for all your galleries should have the class gallery
  514. $(this).magnificPopup({
  515. delegate: 'a.zoom-action', // the container for each your gallery items
  516. type: 'image',
  517. mainClass: 'mfp-fade',
  518. closeOnBgClick: false,
  519. image: {
  520. markup: '<button class="mfp-close">x</button>'+
  521. '<div class="mfp-figure">'+
  522. '<div class="mfp-img"></div>'+
  523. '</div>'+
  524. '<div class="mfp-bottom-bar">'+
  525. '<div class="mfp-title"></div>'+
  526. '<div class="mfp-counter"></div>'+
  527. '</div>',
  528. titleSrc: function(item) {
  529. var text = $('#' + item.el.data('photoid')).hasClass('selected') == true ? 'Deselect' : 'Select';
  530.  
  531. return '<a class="meta__action meta__action--popup select-action" id="popup-selector" href="#" data-photoid="' + item.el.data('photoid') + '"><span class="button-text">' + text + '</span></a>';
  532. }
  533. },
  534. gallery:{
  535. enabled:true,
  536. navigateByImgClick: true,
  537. tPrev: 'Previous (Left arrow key)', // title for left button
  538. tNext: 'Next (Right arrow key)', // title for right button
  539. tCounter: '<div class="gallery-control gallery-control--popup"><a href="#" class="control-item arrow-button arrow-button--left js-arrow-popup-prev"></a><a href="#" class="control-item arrow-button arrow-button--right js-arrow-popup-next"></a></div>'
  540. }
  541. });
  542. });
  543. }
  544.  
  545.  
  546. /* --- Royal Slider Init --- */
  547.  
  548. function royalSliderInit() {
  549. if (globalDebug) {console.log("Royal Slider - Init");}
  550.  
  551. // Helper function
  552. // examples
  553. // console.log(padLeft(23,5)); //=> '00023'
  554. // console.log(padLeft(23,5,'>>')); //=> '>>>>>>23'
  555. function padLeft(nr, n, str){
  556. return Array(n-String(nr).length+1).join(str||'0')+nr;
  557. }
  558.  
  559. // create the markup for the slider from the gallery shortcode
  560. // take all the images and insert them in the .gallery <div>
  561. $('.wp-gallery').each(function() {
  562. var $old_gallery = $(this),
  563. $images = $old_gallery.find('img'),
  564. $new_gallery = $('<div class="pixslider js-pixslider">');
  565. $images.prependTo($new_gallery).addClass('rsImg');
  566. $old_gallery.replaceWith($new_gallery);
  567.  
  568. var gallery_data = $(this).data();
  569. $new_gallery.data(gallery_data);
  570. });
  571.  
  572. $('.js-pixslider').each(function(){
  573.  
  574. var $slider = $(this),
  575. rs_arrows = typeof $slider.data('arrows') !== "undefined",
  576. rs_bullets = typeof $slider.data('bullets') !== "undefined" ? "bullets" : "none",
  577. rs_autoheight = typeof $slider.data('autoheight') !== "undefined",
  578. rs_customArrows = typeof $slider.data('customarrows') !== "undefined",
  579. rs_slidesSpacing = typeof $slider.data('slidesspacing') !== "undefined" ? parseInt($slider.data('slidesspacing')) : 0,
  580. rs_keyboardNav = typeof $slider.data('fullscreen') !== "undefined",
  581. rs_enableCaption = typeof $slider.data('enablecaption') !== "undefined",
  582. rs_imageScale = typeof $slider.data('imagescale') !== "undefined" && $slider.data('imagescale') != '' ? $slider.data('imagescale') : 'fill',
  583. rs_imageAlignCenter = typeof $slider.data('imagealigncenter') !== "undefined",
  584. rs_transition = typeof $slider.data('slidertransition') !== "undefined" && $slider.data('slidertransition') != '' ? $slider.data('slidertransition') : 'move',
  585. rs_autoPlay = typeof $slider.data('sliderautoplay') !== "undefined" ? true : false,
  586. rs_delay = typeof $slider.data('sliderdelay') !== "undefined" && $slider.data('sliderdelay') != '' ? $slider.data('sliderdelay') : '1000',
  587. rs_pauseOnHover = typeof $slider.data('sliderpauseonhover') !== "undefined" ? true : false,
  588. rs_visibleNearby = typeof $slider.data('visiblenearby') !== "undefined" ? true : false,
  589. rs_drag = true;
  590.  
  591.  
  592. var $children = $(this).children();
  593.  
  594. if($children.length == 1){
  595. rs_arrows = false;
  596. rs_bullets = 'none';
  597. rs_customArrows = false;
  598. rs_keyboardNav = false;
  599. rs_drag = false;
  600. rs_transition = 'fade';
  601. // rs_enable_caption = false;
  602. }
  603.  
  604. // make sure default arrows won't appear if customArrows is set
  605. if (rs_customArrows) arrows = false;
  606.  
  607. //the main params for Royal Slider
  608. var royalSliderParams = {
  609. loop: true,
  610. imageScaleMode: rs_imageScale,
  611. imageAlignCenter: rs_imageAlignCenter,
  612. slidesSpacing: rs_slidesSpacing,
  613. arrowsNav: rs_arrows,
  614. controlNavigation: rs_bullets,
  615. keyboardNavEnabled: rs_keyboardNav,
  616. arrowsNavAutoHide: false,
  617. sliderDrag: rs_drag,
  618. transitionType: rs_transition,
  619. globalCaption: rs_enableCaption,
  620. numImagesToPreload: 2,
  621. autoPlay: {
  622. enabled: rs_autoPlay,
  623. stopAtAction: true,
  624. pauseOnHover: rs_pauseOnHover,
  625. delay: rs_delay
  626. },
  627. video: {
  628. // stop showing related videos at the end
  629. youTubeCode: '<iframe src="http://www.youtube.com/embed/%id%?rel=0&autoplay=1&showinfo=0&wmode=transparent" frameborder="no"></iframe>'
  630. }
  631. };
  632.  
  633. if (rs_autoheight) {
  634. royalSliderParams['autoHeight'] = true;
  635. royalSliderParams['autoScaleSlider'] = false;
  636. royalSliderParams['imageScaleMode'] = 'none';
  637. royalSliderParams['imageAlignCenter'] = false;
  638. } else {
  639. royalSliderParams['autoHeight'] = false;
  640. royalSliderParams['autoScaleSlider'] = true;
  641. }
  642.  
  643. if (rs_visibleNearby) {
  644. royalSliderParams['visibleNearby'] = {
  645. enabled: true,
  646. // centerArea: 0.7,
  647. // center: true,
  648. breakpoint: 650,
  649. breakpointCenterArea: 0.64,
  650. navigateByCenterClick: false
  651. }
  652. }
  653.  
  654. //fire it up!!!!
  655. $slider.royalSlider(royalSliderParams);
  656.  
  657. var royalSlider = $slider.data('royalSlider');
  658. var slidesNumber = royalSlider.numSlides;
  659.  
  660. if(slidesNumber == 1) $slider.addClass('single-slide');
  661.  
  662. // create the markup for the customArrows
  663. if(slidesNumber > 1)
  664. if (royalSlider && rs_customArrows) {
  665. var $gallery_control = $(
  666. '<div class="gallery-control js-gallery-control">' +
  667. '<a href="#" class="control-item arrow-button arrow-button--left js-slider-arrow-prev"></a>' +
  668. '<div class="control-item count js-gallery-current-slide">' +
  669. '<span class="highlighted js-decimal">0</span><span class="js-unit">1</span>' +
  670. '<sup class="js-gallery-slides-total">0</sup>' +
  671. '</div>' +
  672. '<a href="#" class="control-item arrow-button arrow-button--right js-slider-arrow-next"></a>'+
  673. '</div>'
  674. );
  675.  
  676. if ($slider.data('customarrows') == "left") {
  677. $gallery_control.addClass('gallery-control--left');
  678. }
  679.  
  680. $gallery_control.insertAfter($slider);
  681.  
  682. // write the total number of slides inside the markup created above
  683. // make sure it is left padded with 0 in case it is lower than 10
  684. slidesNumber = (slidesNumber < 10) ? padLeft(slidesNumber, 2) : slidesNumber;
  685. $gallery_control.find('.js-gallery-slides-total').html(slidesNumber);
  686.  
  687. // add event listener to change the current slide number on slide change
  688. royalSlider.ev.on('rsBeforeAnimStart', function(event) {
  689. var currentSlide = royalSlider.currSlideId + 1;
  690. if(currentSlide < 10){
  691. $gallery_control.find('.js-gallery-current-slide .js-decimal').html('0');
  692. $gallery_control.find('.js-gallery-current-slide .js-unit').html(currentSlide);
  693. } else {
  694. $gallery_control.find('.js-gallery-current-slide .js-decimal').html(Math.floor(currentSlide / 10));
  695. $gallery_control.find('.js-gallery-current-slide .js-unit').html(currentSlide % 10);
  696. }
  697. });
  698.  
  699. $gallery_control.on('click', '.js-slider-arrow-prev', function(event){
  700. event.preventDefault();
  701. royalSlider.prev();
  702. });
  703.  
  704. $gallery_control.on('click', '.js-slider-arrow-next', function(event){
  705. event.preventDefault();
  706. royalSlider.next();
  707. });
  708. }
  709.  
  710. royalSlider.ev.on('rsVideoPlay', function() {
  711.  
  712. $('.js-gallery-control').hide();
  713.  
  714. if($('.single-gallery-fullscreen').length) {
  715. $('html').addClass('video-active');
  716. }
  717.  
  718. var $frameHolder = $('.rsVideoFrameHolder');
  719. //var top = Math.abs(parseInt($frameHolder.siblings('.rsMainSlideImage').css('margin-top'), 10));
  720.  
  721. if(rs_imageScale == "fill"){
  722. $frameHolder
  723. .height($('.rsContainer').height());
  724. //.css('top', top + 'px');
  725. }
  726.  
  727. if($('html').hasClass('no-touch'))
  728. $frameHolder.appendTo('body');
  729.  
  730. });
  731.  
  732. royalSlider.ev.on('rsVideoStop', function() {
  733. $('.js-gallery-control').show();
  734.  
  735. if($('.single-gallery-fullscreen').length)
  736. $('html').removeClass('video-active');
  737. });
  738.  
  739. });
  740.  
  741. // While watching a video in RoyalSlider on gallery fullscreen,
  742. // if directly navigating without stopping using RoyalSlider,
  743. // to allow the event written above ^ to take place,
  744. // the <html/> has the class .video-active, making the header transparent.
  745. // So it needs to be removed.
  746. if($('html').hasClass('video-active')) $('html').removeClass('video-active');
  747. };
  748.  
  749.  
  750. /* --- MOSAIC INIT --- */
  751.  
  752.  
  753. //global mosaic variables
  754. var $mosaic_container,
  755. max_mosaic_pages,
  756. is_everything_loaded,
  757. mosaic_page_counter;
  758.  
  759. function mosaicInit() {
  760. if (globalDebug) {console.log("Mosaic - Init");}
  761.  
  762. //initialize global variables
  763. $mosaic_container = $('.mosaic');
  764.  
  765. if ( !empty($mosaic_container)) {
  766. max_mosaic_pages = $mosaic_container.data('maxpages');
  767. is_everything_loaded = false;
  768. }
  769.  
  770. mixitUpRun();
  771.  
  772. //force the infinite scroll to wait for the first images to lead before doing it's thing
  773. if ($mosaic_container.hasClass('infinite_scroll')) {
  774. // $mosaic_container.imagesLoaded(function(){
  775. mosaicInfiniteScrollingInit($mosaic_container);
  776. // });
  777. }
  778.  
  779. // Call Direction Aware Hover Effect
  780. if(!touch) {
  781. $('.mosaic__item .image_item-meta--portfolio .image_item-table').each(function() {
  782. $(this).hoverdir();
  783. });
  784. }
  785. }
  786.  
  787. /* --- Mosaic Update --- */
  788.  
  789. function mosaicUpdateLayout() {
  790. if (globalDebug) {console.log("Mosaic Update Layout");}
  791.  
  792. if ( !empty($mosaic_container) && $mosaic_container.length ) {
  793. $mosaic_container.isotope( 'layout');
  794. }
  795. }
  796.  
  797. /* --- Mosaic Destroy --- */
  798.  
  799. function mosaicDestroy() {
  800. if (globalDebug) {console.log("Mosaic Destroy");}
  801.  
  802. if ( !empty($mosaic_container) && $mosaic_container.length ) {
  803. $mosaic_container.isotope( 'destroy');
  804. }
  805. }
  806.  
  807.  
  808. /* --- Layout Refresh --- */
  809.  
  810. function layoutRefresh() {
  811. if (globalDebug) {console.log("Mosaic Layout Refresh");}
  812.  
  813. mosaicUpdateLayout();
  814. }
  815.  
  816. /* --- MixitUp Run --- */
  817.  
  818. function mixitUpRun() {
  819. if (!empty($mosaic_container) && $mosaic_container.length) {
  820. if (globalDebug) {console.log("Mosaic Initialization (mixitUpRun)");}
  821. // MixitUp init
  822. $mosaic_container.mixitup({
  823. targetSelector: '.mosaic__item',
  824. filterSelector: '.mosaic__filter-item',
  825. sortSelector: '.mosaic__sort-item',
  826. effects: ['fade','scale'],
  827. easing: 'snap',
  828. transitionSpeed: 850
  829. });
  830.  
  831. //Mixitup 2 config
  832. // $mosaic_container.mixItUp({
  833. // selectors: {
  834. // target: '.mosaic__item',
  835. // filter: '.mosaic__filter-item'
  836. // },
  837. // animation: {
  838. // enable: true,
  839. // effects: 'fade scale',
  840. // easing: 'snap',
  841. // duration: 850
  842. // }
  843. //
  844. // });
  845.  
  846. }
  847. }
  848.  
  849. /* -- Mosaic Infinite Scrolling Initialization --- */
  850.  
  851. function mosaicInfiniteScrollingInit($container) {
  852. if (globalDebug) {console.log("Mosaic Infinite Scroll Init");}
  853.  
  854. max_mosaic_pages = $container.data('maxpages');
  855. mosaic_page_counter = 1;
  856.  
  857. $container.infinitescroll({
  858. navSelector : '.mosaic__pagination', // selector for the paged navigation
  859. nextSelector : '.mosaic__pagination a.next', // selector for the NEXT link
  860. itemSelector : '.mosaic__item', // selector for all items you'll retrieve
  861. loading: {
  862. finished: undefined,
  863. finishedMsg: '',
  864. img: '',
  865. msg: null,
  866. msgText: '',
  867. selector: null,
  868. speed: 'fast',
  869. start: undefined
  870. },
  871. debug: globalDebug,
  872. //animate : true,
  873. //extraScrollPx: 500,
  874. prefill: true,
  875. maxPage: max_mosaic_pages,
  876. errorCallback: function(){
  877. $('html').removeClass('loading');
  878. },
  879. startCallback: function(){
  880. $('html').addClass('loading');
  881. }
  882. // called when a requested page 404's or when there is no more content
  883. // new in 1.2
  884. },
  885. // a callback when all is fetched
  886. function( newElements ) {
  887.  
  888. var $newElems = $( newElements );
  889.  
  890. //refresh all there is to refresh
  891. infiniteScrollingRefreshComponents($container);
  892.  
  893. if (globalDebug) {console.log("Mosaic Infinite Scroll - Adding new "+$newElems.length+" items to the DOM");}
  894.  
  895. if (globalDebug) {console.log("Mosaic Infinite Scroll Loaded Next Page");}
  896.  
  897. mosaic_page_counter++;
  898.  
  899. if (mosaic_page_counter == max_mosaic_pages) {
  900. $('.load-more__container').fadeOut('slow');
  901. } else {
  902. $('.load-more__container .load-more__button').removeClass('loading');
  903. }
  904.  
  905. $('html').removeClass('loading');
  906. });
  907.  
  908. if ($container.hasClass('infinite_scroll_with_button')) {
  909. infiniteScrollingOnClick($container);
  910. }
  911. }
  912.  
  913. function infiniteScrollingOnClick($container) {
  914. if (globalDebug) {console.log("Infinite Scroll Init - ON CLICK");}
  915.  
  916. // unbind normal behavior. needs to occur after normal infinite scroll setup.
  917. $(window).unbind('.infscr');
  918.  
  919. $('.load-more__container .load-more__button').click(function(){
  920.  
  921. $('html').addClass('loading');
  922.  
  923. $container.infinitescroll('retrieve');
  924.  
  925. return false;
  926. });
  927.  
  928. // remove the paginator when we're done.
  929. $(document).ajaxError(function(e,xhr,opt){
  930. if (xhr.status == 404) {
  931. $('.load-more__container').fadeOut('slow');
  932. }
  933. });
  934. }
  935.  
  936. //in case you need to control infinitescroll
  937. function infiniteScrollingPause() {
  938. if (globalDebug) {console.log("Infinite Scroll Pause");}
  939.  
  940. $mosaic_container.infinitescroll('pause');
  941. }
  942. function infiniteScrollingResume() {
  943. if (globalDebug) {console.log("Infinite Scroll Resume");}
  944.  
  945. $mosaic_container.infinitescroll('resume');
  946. }
  947. function infiniteScrollingDestroy() {
  948. if (globalDebug) {console.log("Infinite Scroll Destroy");}
  949.  
  950. $mosaic_container.infinitescroll('destroy');
  951. }
  952.  
  953. function infiniteScrollingRefreshComponents($container) {
  954. if (globalDebug) {console.log("Infinite Scroll - Refresh Components");}
  955.  
  956. lazyLoad();
  957.  
  958. mixitUpRun();
  959.  
  960. // Call Direction Aware Hover Effect
  961. if(!touch) {
  962. $('.mosaic__item .image_item-meta--portfolio .image_item-table').each(function() {
  963. $(this).hoverdir();
  964. });
  965. }
  966.  
  967. animateGallery('in');
  968. }
  969.  
  970. /* --- GMAP Init --- */
  971.  
  972. function gmapInit() {
  973. if ($('#gmap').length) {
  974.  
  975. var gmap_link, gmap_variables, gmap_zoom, gmap_style;
  976. gmap_link = $('#gmap').data('url');
  977. gmap_style = typeof $('#gmap').data('customstyle') !== "undefined" ? "style1" : google.maps.MapTypeId.ROADMAP;
  978.  
  979. // Overwrite Math.log to accept a second optional parameter as base for logarhitm
  980. Math.log = (function() {
  981. var log = Math.log;
  982. return function(n, base) {
  983. return log(n)/(base ? log(base) : 1);
  984. };
  985. })();
  986.  
  987. function get_url_parameter(needed_param, gmap_url) {
  988. var sURLVariables = (gmap_url.split('?'))[1];
  989. if (typeof sURLVariables === "undefined") {
  990. return sURLVariables;
  991. }
  992. sURLVariables = sURLVariables.split('&');
  993. for (var i = 0; i < sURLVariables.length; i++) {
  994. var sParameterName = sURLVariables[i].split('=');
  995. if (sParameterName[0] == needed_param) {
  996. return sParameterName[1];
  997. }
  998. }
  999. }
  1000.  
  1001. var gmap_coordinates = [],
  1002. gmap_zoom;
  1003.  
  1004. if (gmap_link) {
  1005. //Parse the URL and load variables (ll = latitude/longitude; z = zoom)
  1006. var gmap_variables = get_url_parameter('ll', gmap_link);
  1007. if (typeof gmap_variables === "undefined") {
  1008. gmap_variables = get_url_parameter('sll', gmap_link);
  1009. }
  1010. // if gmap_variables is still undefined that means the url was pasted from the new version of google maps
  1011. if (typeof gmap_variables === "undefined") {
  1012.  
  1013. if(gmap_link.split('!3d') != gmap_link){
  1014. //new google maps old link type
  1015.  
  1016. var split, lt, ln, dist, z;
  1017. split = gmap_link.split('!3d');
  1018. lt = split[1];
  1019. split = split[0].split('!2d');
  1020. ln = split[1];
  1021. split = split[0].split('!1d');
  1022. dist = split[1];
  1023. gmap_zoom = 21 - Math.round(Math.log(Math.round(dist/218), 2));
  1024. gmap_coordinates = [lt, ln];
  1025.  
  1026. } else {
  1027. //new google maps new link type
  1028.  
  1029. var gmap_link_l;
  1030.  
  1031. gmap_link_l = gmap_link.split('@')[1];
  1032. gmap_link_l = gmap_link_l.split('z/')[0];
  1033.  
  1034. gmap_link_l = gmap_link_l.split(',');
  1035.  
  1036. var latitude = gmap_link_l[0];
  1037. var longitude = gmap_link_l[1];
  1038. var zoom = gmap_link_l[2];
  1039.  
  1040. if(zoom.indexOf('z') >= 0)
  1041. zoom = zoom.substring(0, zoom.length-1);
  1042.  
  1043. gmap_coordinates[0] = latitude;
  1044. gmap_coordinates[1] = longitude;
  1045. gmap_zoom = zoom;
  1046. }
  1047.  
  1048.  
  1049.  
  1050. } else {
  1051. gmap_zoom = get_url_parameter('z', gmap_link);
  1052. if (typeof gmap_zoom === "undefined") {
  1053. gmap_zoom = 10;
  1054. }
  1055. gmap_coordinates = gmap_variables.split(',');
  1056. }
  1057. }
  1058.  
  1059. $("#gmap").gmap3({
  1060. map:{
  1061. options:{
  1062. center: new google.maps.LatLng(gmap_coordinates[0], gmap_coordinates[1]),
  1063. zoom: parseInt(gmap_zoom),
  1064. mapTypeId: gmap_style,
  1065. mapTypeControlOptions: {mapTypeIds: []},
  1066. scrollwheel: false
  1067. }
  1068. },
  1069. overlay:{
  1070. latLng: new google.maps.LatLng(gmap_coordinates[0], gmap_coordinates[1]),
  1071. options:{
  1072. content: '<div class="pin_ring pin_ring--outer">' +
  1073. '<div class="pin_ring pin_ring--inner"></div>' +
  1074. '</div>'
  1075. }
  1076. },
  1077. styledmaptype:{
  1078. id: "style1",
  1079. options:{
  1080. name: "Style 1"
  1081. },
  1082. styles: [
  1083. {
  1084. stylers: [
  1085. { saturation: -100 }
  1086. ]
  1087. }
  1088. ]
  1089. }
  1090. });
  1091. }
  1092. }
  1093.  
  1094.  
  1095. /* ====== INITIALIZE ====== */
  1096.  
  1097.  
  1098. function init() {
  1099. if (globalDebug) {console.group("Init");}
  1100.  
  1101. /* GLOBAL VARS */
  1102. touch = false;
  1103.  
  1104. /* GET BROWSER DIMENSIONS */
  1105. browserSize();
  1106.  
  1107. /* DETECT PLATFORM */
  1108. platformDetect();
  1109.  
  1110. /* INSTANTIATE DJAX */
  1111. if ($('body').data('ajaxloading') !== undefined) {
  1112.  
  1113. var djax_transition = function($newEl) {
  1114. if (globalDebug) {console.group("djax Transition");}
  1115.  
  1116. var $oldEl = this;
  1117. $oldEl.replaceWith($newEl);
  1118. // we should make sure initial transition ended
  1119.  
  1120. $('html').removeClass('is--gallery-fullscreen');
  1121. $('html').removeClass('is--gallery-grid');
  1122.  
  1123. if(!empty($newEl.find('.pixslider--gallery-fs'))){
  1124. $('html').addClass('is--gallery-fullscreen');
  1125. }
  1126.  
  1127. if(!empty($newEl.find('.gallery-grid'))){
  1128. $('html').addClass('is--gallery-grid');
  1129. }
  1130.  
  1131. setTimeout(function() {
  1132. $('html').removeClass('loading');
  1133. });
  1134.  
  1135. if (globalDebug) {console.groupEnd();}
  1136. };
  1137.  
  1138. $('body').djax('.djax-updatable', ['.pdf','.doc','.eps','.png','.zip','admin','wp-','wp-admin','feed','#', '?lang=', '&lang=', '&add-to-cart=', '?add-to-cart=', '?remove_item'], djax_transition);
  1139.  
  1140. }
  1141.  
  1142. if (is_android || window.opera) {
  1143. $('html').addClass('android-browser').removeClass('no-android-browser');
  1144. }
  1145.  
  1146. var is_retina = (window.retina || window.devicePixelRatio > 1);
  1147.  
  1148. if (is_retina && $('.site-logo--image-2x').length) {
  1149. var image = $('.site-logo--image-2x').find('img');
  1150.  
  1151. if (image.data('logo2x') !== undefined) {
  1152. image.attr('src', image.data('logo2x'));
  1153. }
  1154. }
  1155.  
  1156. $('html').addClass('loaded');
  1157.  
  1158. var h = $(window).height(),
  1159. sh = $('.site-header__branding').outerHeight(true),
  1160. hh = $('.site-header').outerHeight(true),
  1161. fh = $('.site-footer').outerHeight(true);
  1162.  
  1163. if (h < hh + sh + fh) {
  1164. $('.site-footer').css({
  1165. "position": "static",
  1166. "margin-left": 0,
  1167. // "padding-right": "24px"
  1168. });
  1169. }
  1170.  
  1171. if(!empty($('.pixslider--gallery-fs'))) {
  1172. $('html').addClass('is--gallery-fullscreen');
  1173. }
  1174.  
  1175. if(!empty($('.gallery-grid'))){
  1176. $('html').addClass('is--gallery-grid');
  1177. }
  1178.  
  1179. FastClick.attach(document.body);
  1180.  
  1181. /* ONE TIME EVENT HANDLERS */
  1182. eventHandlersOnce();
  1183.  
  1184. /* INSTANTIATE EVENT HANDLERS */
  1185. eventHandlers();
  1186.  
  1187. if (globalDebug) {console.groupEnd();}
  1188. };
  1189.  
  1190.  
  1191. /* ====== CONDITIONAL LOADING ====== */
  1192.  
  1193. function loadUp(){
  1194. if (globalDebug) {console.group("LoadUp");}
  1195.  
  1196. // always
  1197. niceScrollInit();
  1198. initVideos();
  1199. resizeVideos();
  1200. progressbarInit();
  1201.  
  1202. //Set textarea from contact page to autoresize
  1203. if($("textarea").length) { $("textarea").autosize(); }
  1204.  
  1205. // if blog archive
  1206. if ($('.masonry').length && !lteie9 && !is_android) {
  1207. salvattoreStart();
  1208. }
  1209.  
  1210. // royal slider must initialize after salavottre
  1211. // for the layout to show up properly
  1212. royalSliderInit();
  1213.  
  1214. // if gallery
  1215. magnificPopupInit();
  1216.  
  1217. // if gallery grid or portfolio
  1218. mosaicInit();
  1219.  
  1220. // if contact
  1221. gmapInit();
  1222.  
  1223. $(".pixcode-tabs").tab();
  1224.  
  1225.  
  1226. /* --- ANIMATE STUFF IN --- */
  1227. animateGallery('in');
  1228. animateBlog('in');
  1229.  
  1230. if (globalDebug) {console.groupEnd();}
  1231. }
  1232.  
  1233.  
  1234. /* ====== EVENT HANDLERS ====== */
  1235.  
  1236. function eventHandlersOnce() {
  1237. if (globalDebug) {console.group("Event Handlers Once");}
  1238.  
  1239. // $('.js-nav-trigger').on('click', function(e) {
  1240. // var hh = $('.header').height(),
  1241. // ch = $('.navigation--mobile').height(),
  1242. // max = Math.max(wh,ch,hh);
  1243. // // console.log(max);
  1244. // if ($('html').hasClass('navigation--is-visible')) {
  1245. // $('#page').css({'height': ''});
  1246. // } else {
  1247. // $('#page').css({'height': max});
  1248. // }
  1249.  
  1250. // $('html').toggleClass('navigation--is-visible');
  1251. // });
  1252.  
  1253. var windowHeigth = $(window).height();
  1254.  
  1255. $('.js-nav-trigger').bind('click', function(e) {
  1256. e.preventDefault();
  1257. e.stopPropagation();
  1258.  
  1259. if($('html').hasClass('navigation--is-visible')){
  1260. $('#page').css('height', '');
  1261. $('html').removeClass('navigation--is-visible');
  1262.  
  1263. } else {
  1264. $('#page').height(windowHeigth);
  1265. $('html').addClass('navigation--is-visible');
  1266. }
  1267. });
  1268.  
  1269. $('.wrapper').bind('click', function(e) {
  1270. if ($('html').hasClass('navigation--is-visible')) {
  1271.  
  1272. e.preventDefault();
  1273. e.stopPropagation();
  1274.  
  1275. $('#page').css('height', '');
  1276. $('html').removeClass('navigation--is-visible');
  1277. }
  1278. });
  1279.  
  1280. copyrightOverlayInit();
  1281.  
  1282.  
  1283. // if (typeof once_woocommerce_events_handlers == 'function') {
  1284. // once_woocommerce_events_handlers();
  1285. // }
  1286.  
  1287. if (globalDebug) {console.groupEnd();}
  1288. };
  1289.  
  1290.  
  1291. function likeBoxAnimation(){
  1292. $(document).on('click', '.can_like .like-link', function(e){
  1293. e.preventDefault();
  1294. var $iElem = $(this).find('i');
  1295. $iElem.addClass('animate-like').delay(1000).queue(function(){$(this).addClass('like-complete');});
  1296. // $(this).addClass('animate-like');
  1297. });
  1298. }
  1299.  
  1300.  
  1301. /* --- GLOBAL EVENT HANDLERS --- */
  1302.  
  1303. function magnificPrev(e) {
  1304. if (globalDebug) {console.log("Magnific Popup Prev");}
  1305.  
  1306. e.preventDefault();
  1307. var magnificPopup = $.magnificPopup.instance;
  1308. magnificPopup.prev();
  1309. return false;
  1310. }
  1311.  
  1312. function magnificNext(e) {
  1313. if (globalDebug) {console.log("Magnific Popup Next");}
  1314.  
  1315. e.preventDefault();
  1316. var magnificPopup = $.magnificPopup.instance;
  1317. magnificPopup.next();
  1318. return false;
  1319. }
  1320.  
  1321. $(window).bind('beforeunload', function(event) {
  1322. if (globalDebug) {console.log("ON BEFORE UNLOAD");}
  1323.  
  1324. // event.stopPropagation();
  1325.  
  1326. // animateBlog('out');
  1327. });
  1328.  
  1329. function eventHandlers() {
  1330. if (globalDebug) {console.group("Event Handlers");}
  1331.  
  1332. /*
  1333. * Woocommerce Events support
  1334. * */
  1335.  
  1336. if (typeof woocommerce_events_handlers == 'function') {
  1337. woocommerce_events_handlers();
  1338. // needed for the floating ajax cart
  1339. $('body').trigger('added_to_cart');
  1340. }
  1341.  
  1342. $('body').off('click', '.js-arrow-popup-prev', magnificPrev).on('click', '.js-arrow-popup-prev', magnificPrev);
  1343. $('body').off('click', '.js-arrow-popup-next', magnificNext).on('click', '.js-arrow-popup-next', magnificNext);
  1344.  
  1345. /* @todo: change classes so style and js don't interfere */
  1346. $('.menu-item--parent').hoverIntent({
  1347. over: function() {
  1348. $(this).addClass('js--is-active');
  1349. $(this).children('.site-navigation__sub-menu').slideDown(200, 'easeInOutSine', function(){
  1350. placeFooter();
  1351. });
  1352. },
  1353. out: function() {
  1354. if(!($(this).hasClass('current-menu-item')) &&
  1355. !($(this).hasClass('current-menu-ancestor')) &&
  1356. !($(this).hasClass('current-menu-parent'))){
  1357. $(this).removeClass('js--is-active');
  1358. $(this).children('.site-navigation__sub-menu').slideUp(200, 'easeInOutSine');
  1359. }
  1360. },
  1361. timeout: 1000
  1362. });
  1363.  
  1364.  
  1365. likeBoxAnimation();
  1366.  
  1367. var filterHandler;
  1368.  
  1369. if(touch) {
  1370. filterHandler = 'click';
  1371. } else {
  1372. filterHandler = 'hover';
  1373. }
  1374.  
  1375. if(ieMobile) filterHandler = 'click';
  1376.  
  1377. $('.sticky-button__btn').on(filterHandler, function(){
  1378. $(this).toggleClass('sticky-button--active');
  1379. });
  1380.  
  1381. $('.cart__btn1').on(filterHandler, function(){
  1382. $(this).toggleClass('cart--active');
  1383. });
  1384.  
  1385. if (globalDebug) {console.groupEnd();}
  1386. };
  1387.  
  1388.  
  1389.  
  1390. /* ====== ON DOCU READY ====== */
  1391.  
  1392. $(function(){
  1393. if (globalDebug) {console.group("OnDocumentReady");}
  1394.  
  1395. /* --- INITIALIZE --- */
  1396.  
  1397. init();
  1398.  
  1399. /* --- CONDITIONAL LOADING --- */
  1400.  
  1401. loadUp();
  1402.  
  1403. /* --- VISUAL LOADING --- */
  1404.  
  1405.  
  1406. if (globalDebug) {console.groupEnd();}
  1407. });
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413. /* --- $LAZY LOADING INIT --- */
  1414.  
  1415. /**
  1416. *
  1417. * When an image finished loaded add class to parent for
  1418. * the image to fade in
  1419. *
  1420. **/
  1421. function lazyLoad() {
  1422.  
  1423. var $images = $('.js-lazy-load');
  1424.  
  1425. $images.each(function(){
  1426.  
  1427. var $img = $(this),
  1428. src = $img.attr('data-src');
  1429.  
  1430. $img.on('load', function() {
  1431. $img.closest('.mosaic__item').addClass('js--is-loaded');
  1432. });
  1433.  
  1434. $img.attr('src', src);
  1435. });
  1436. };
  1437.  
  1438.  
  1439.  
  1440. /* ====== ON WINDOW LOAD ====== */
  1441.  
  1442. $(window).load(function(){
  1443. if (globalDebug) {console.group("OnWindowLoad");}
  1444.  
  1445. lazyLoad();
  1446.  
  1447. $('html').removeClass('loading');
  1448.  
  1449. if (globalDebug) {console.groupEnd();}
  1450. });
  1451.  
  1452.  
  1453. /* --- Animation Functions --- */
  1454.  
  1455. function animateGallery(direction) {
  1456. if (globalDebug) {console.log("Animate Gallery " + direction);}
  1457.  
  1458. direction = direction == "in" ? direction : "out";
  1459.  
  1460. $('.mosaic__item').each(function(){
  1461. var $item = $(this);
  1462. setTimeout(function() {
  1463. $item.addClass('slide-' + direction);
  1464. }, 80 * Math.floor((Math.random()*5)+1));
  1465. });
  1466.  
  1467. }
  1468.  
  1469.  
  1470. function animateBlog(direction) {
  1471. if (globalDebug) {console.log("Animate Blog " + direction);}
  1472.  
  1473. if (!is_android) {
  1474.  
  1475. direction = direction == "in" ? direction : "out";
  1476.  
  1477. var sizes = new Array();
  1478. var columns = new Array();
  1479. var items = $('.masonry .span .masonry__item').length;
  1480.  
  1481. $('.masonry .span').each(function(i, e){
  1482. columns[i] = $(this).children('.masonry__item');
  1483. sizes[i] = columns[i].length;
  1484. });
  1485.  
  1486. var max = Math.max.apply(null, sizes);
  1487.  
  1488. for (var item = 0; item < max; item++) {
  1489.  
  1490. $(columns).each(function(column) {
  1491.  
  1492. if (columns[column][item] !== undefined) {
  1493.  
  1494. if (direction == "in") {
  1495.  
  1496. var $item = $(columns[column][item]),
  1497. timeout = item * columns.length + column;
  1498.  
  1499. setTimeout(function() {
  1500. $item.addClass('is-loaded');
  1501. }, 100 * timeout);
  1502.  
  1503. } else {
  1504.  
  1505. var $item = $(columns[column][item]),
  1506. timeout = items - (item * columns.length + column);
  1507.  
  1508. setTimeout(function() {
  1509. $item.removeClass('is-loaded');
  1510. }, 100 * timeout);
  1511. }
  1512. }
  1513. });
  1514. }
  1515. }
  1516. }
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. /* ====== ON DJAX REQUEST ====== */
  1523.  
  1524. $(window).bind('djaxClick', function(e, data) {
  1525. if (globalDebug) {console.group("On-dJaxClick");}
  1526.  
  1527. $('html').removeClass('noanims');
  1528.  
  1529. $('html').addClass('loading');
  1530. $('html, body').animate({scrollTop: 0}, 300);
  1531.  
  1532. if ($('html').hasClass('navigation--is-visible')) {
  1533. $('#page').css({'height': ''});
  1534. $('html').removeClass('navigation--is-visible');
  1535. // $(window).trigger('resize');
  1536. }
  1537.  
  1538. /* --- ANIMATE STUFF OUT --- */
  1539. animateGallery('out');
  1540. animateBlog('out');
  1541.  
  1542. if (globalDebug) {console.groupEnd();}
  1543. });
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549. /* ====== ON DJAX LOAD ====== */
  1550.  
  1551. $(window).bind('djaxLoad', function(e, data) {
  1552. if (globalDebug) {console.group("On-dJaxLoad");}
  1553.  
  1554. // get data and replace the body tag with a nobody tag
  1555. // because jquery strips the body tag when creating objects from data
  1556. data = data.response.replace(/(<\/?)body( .+?)?>/gi,'$1NOTBODY$2>', data);
  1557. // get the nobody tag's classes
  1558. var nobodyClass = $(data).filter('notbody').attr("class");
  1559. // set it to current body tag
  1560. $('body').attr("class", nobodyClass);
  1561. // let the party begin
  1562. $('html').removeClass('loading');
  1563.  
  1564. setTimeout(function(){
  1565. $('html').addClass('noanims');
  1566. }, 700);
  1567.  
  1568. // progressbars ?
  1569.  
  1570. eventHandlers();
  1571.  
  1572. browserSize();
  1573. resizeVideos();
  1574.  
  1575. lazyLoad();
  1576. loadUp();
  1577.  
  1578. //need to get the id and edit string from the data attributes
  1579. var curPostID = $(data).filter('notbody').data("curpostid"),
  1580. curPostTax = $(data).filter('notbody').data("curtaxonomy"),
  1581. curPostEditString = $(data).filter('notbody').data("curpostedit");
  1582.  
  1583. adminBarEditFix(curPostID, curPostEditString, curPostTax);
  1584.  
  1585. //lets do some Google Analytics Tracking
  1586. if (window._gaq) {
  1587. _gaq.push(['_trackPageview']);
  1588. }
  1589.  
  1590. if (globalDebug) {console.groupEnd();}
  1591. });
  1592.  
  1593.  
  1594.  
  1595.  
  1596. // /* ====== ON DJAX LOADING!!! ====== */
  1597.  
  1598. $(window).bind('djaxLoading', function(e, data) {
  1599. if (globalDebug) {console.group("On-dJaxLoading");}
  1600.  
  1601. cleanupBeforeDJax();
  1602.  
  1603. if (globalDebug) {console.groupEnd();}
  1604. });
  1605.  
  1606.  
  1607.  
  1608.  
  1609. /* ====== ON RESIZE ====== */
  1610.  
  1611. $(window).on("debouncedresize", function(e){
  1612. if (globalDebug) {console.group("OnResize");}
  1613.  
  1614. browserSize();
  1615.  
  1616. resizeVideos();
  1617.  
  1618. placeFooter();
  1619.  
  1620. if (ww < 901) {
  1621. $('html').removeClass('nicescroll');
  1622. $('[data-smoothscrolling]').getNiceScroll().hide();
  1623. } else {
  1624. niceScrollInit();
  1625. }
  1626.  
  1627. if (globalDebug) {console.groupEnd();}
  1628. });
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635. /* ====== ON SCROLL ====== */
  1636.  
  1637. $(window).scroll(function(e){
  1638.  
  1639.  
  1640. if ($('.entry__likes').length) {
  1641.  
  1642. var likes = $('.entry__likes'),
  1643. likesOffset = likes.offset(),
  1644. likesh = likes.height(),
  1645. likesTop = likesOffset.top,
  1646. likesBottom = likesTop + likesh,
  1647. post = $('.post .entry__wrap'),
  1648. posth = post.height(),
  1649. postOffset = post.offset(),
  1650. postTop = postOffset.top,
  1651. postBottom = postTop + posth,
  1652. scroll = $('body').scrollTop();
  1653.  
  1654. if (ww > 1599) {
  1655.  
  1656. // hacky way to get scroll consisten in chrome / firefox
  1657. if (scroll == 0) scroll = $('html').scrollTop();
  1658.  
  1659. // if scrolled past the top of the container but not below the bottom of it
  1660. if (scroll > postTop && scroll + likesh < postBottom) {
  1661.  
  1662. // insert after content for fixed position to work properly
  1663. // set left value to the box's initial left offset
  1664. likes.insertAfter('.content').css({
  1665. position: 'fixed',
  1666. top: 0,
  1667. left: likesOffset.left
  1668. });
  1669.  
  1670. // the box should follow scroll anymore
  1671. } else {
  1672.  
  1673. // we are below the container's bottom
  1674. // so we have to move to box back up while scrolling down
  1675. if (scroll + likesh > postBottom) {
  1676.  
  1677. likes.insertAfter('.content').css({
  1678. top: postBottom - scroll - likesh
  1679. });
  1680.  
  1681. // we are back up so we must put the box back in it's place
  1682. } else {
  1683.  
  1684. likes.prependTo('.entry__wrap').css({
  1685. position: '',
  1686. top: 0,
  1687. left: ''
  1688. });
  1689.  
  1690. }
  1691. }
  1692.  
  1693. } else {
  1694.  
  1695. // make sure that the box is in it's lace when resizing the browser
  1696. likes.prependTo('.entry__wrap').css({
  1697. position: '',
  1698. top: 0,
  1699. left: ''
  1700. });
  1701.  
  1702. }
  1703. }
  1704. });
  1705.  
  1706. /* === Functions that require jQuery but have no place on this Earth, yet === */
  1707.  
  1708. /* --- NICESCROLL INIT--- */
  1709.  
  1710. function niceScrollInit() {
  1711. if (globalDebug) {console.log("NiceScroll - Init");}
  1712.  
  1713. var smoothScroll = $('body').data('smoothscrolling') !== undefined;
  1714.  
  1715. if ($('.site-navigation').length) {
  1716. var offset = $('.site-navigation').offset();
  1717. mobile = offset.left > ww;
  1718. }
  1719.  
  1720. if (smoothScroll && ww > 899 && !touch && !is_OSX) {
  1721. $('html').addClass('nicescroll');
  1722. $('[data-smoothscrolling]').niceScroll({
  1723. zindex: 9999,
  1724. cursoropacitymin: 0.3,
  1725. cursorwidth: 7,
  1726. cursorborder: 0,
  1727. mousescrollstep: 40,
  1728. scrollspeed: 100,
  1729. cursorcolor: '#000000'
  1730. });
  1731. }
  1732. }
  1733.  
  1734. /* --- PROGRESSBAR INIT --- */
  1735.  
  1736. function progressbarInit() {
  1737. if (globalDebug) {console.log("ProgressBar - Init");}
  1738.  
  1739. var progressbar_shc = $('.progressbar');
  1740. progressbar_shc.addClass('is-visible');
  1741. if (progressbar_shc.length) {
  1742. progressbar_shc.each(function() {
  1743. var self = $(this).find('.progressbar__progress');
  1744. self.css({'width': self.data('value')});
  1745. });;
  1746. }
  1747. }
  1748.  
  1749. /* --- $VIDEOS --- */
  1750.  
  1751. function initVideos() {
  1752. if (globalDebug) {console.log("Videos - Init");}
  1753.  
  1754. var videos = $('.video-wrap iframe, .entry__wrap iframe, video');
  1755.  
  1756. // Figure out and save aspect ratio for each video
  1757. videos.each(function() {
  1758. $(this).data('aspectRatio', this.width / this.height)
  1759. // and remove the hard coded width/height
  1760. .removeAttr('height')
  1761. .removeAttr('width');
  1762. });
  1763.  
  1764. // Firefox Opacity Video Hack
  1765. $('.video-wrap iframe').each(function(){
  1766. var url = $(this).attr("src");
  1767.  
  1768. $(this).attr("src", setQueryParameter(url, "wmode", "transparent"));
  1769. });
  1770. }
  1771.  
  1772.  
  1773. function resizeVideos() {
  1774.  
  1775. var videos = $('.video-wrap iframe, .entry__wrap iframe, video');
  1776.  
  1777. videos.each(function() {
  1778. var video = $(this),
  1779. ratio = video.data('aspectRatio'),
  1780. w = video.css('width', '100%').width(),
  1781. h = w/ratio;
  1782. video.height(h);
  1783. });
  1784. }
  1785.  
  1786. /* --- FOOTER VOODOO MAGIC --- */
  1787.  
  1788. function placeFooter() {
  1789.  
  1790. var sh = $('.sidebar--header').outerHeight(true),
  1791. hh = $('.site-header').outerHeight(true),
  1792. fh = $('.site-footer').outerHeight(true);
  1793.  
  1794. if (wh < hh + fh + sh) {
  1795. $('.site-footer').css({
  1796. "position": "static",
  1797. "margin-left": 0,
  1798. // "padding-right": "24px"
  1799. });
  1800. } else {
  1801. $('.site-footer').css({
  1802. "position": "",
  1803. "margin-left": "",
  1804. "padding-right": ""
  1805. });
  1806. }
  1807. }
  1808.  
  1809. /* --- DJAX CLEANUP - Do all the cleanup that is needed when going to another page with dJax --- */
  1810.  
  1811. function cleanupBeforeDJax() {
  1812. if (globalDebug) {console.group("CleanUp before dJax");}
  1813.  
  1814. /* --- KILL ROYALSLIDER ---*/
  1815. var sliders = $('.js-pixslider');
  1816. if (!empty(sliders)) {
  1817. sliders.each(function() {
  1818. var slider = $(this).data('royalSlider');
  1819. slider.destroy();
  1820. });
  1821. }
  1822.  
  1823. /* --- KILL MAGNIFIC POPUP ---*/
  1824. //when hitting back or forward we need to make sure that there is no rezidual Magnific Popup
  1825. $.magnificPopup.close(); // Close popup that is currently opened (shorthand)
  1826.  
  1827. infiniteScrollingDestroy();
  1828. }
  1829.  
  1830. // here we change the link of the Edit button in the Admin Bar
  1831. // to make sure it reflects the current page
  1832. function adminBarEditFix(id, editString, taxonomy) {
  1833. //get the admin ajax url and clean it
  1834. var baseEditURL = ajaxurl.replace('admin-ajax.php','post.php'),
  1835. baseExitTaxURL = ajaxurl.replace('admin-ajax.php','edit-tags.php'),
  1836. $editButton = $('#wp-admin-bar-edit a');
  1837.  
  1838. if ( !empty($editButton) ) {
  1839. if ( id !== undefined && editString !== undefined ) { //modify the current Edit button
  1840. if (!empty(taxonomy)) { //it seems we need to edit a taxonomy
  1841. $editButton.attr('href', baseExitTaxURL + '?tag_ID=' + id + '&taxonomy=' + taxonomy + '&action=edit');
  1842. } else {
  1843. $editButton.attr('href', baseEditURL + '?post=' + id + '&action=edit');
  1844. }
  1845. $editButton.html(editString);
  1846. } else { //we have found an edit button but right now we don't need it anymore since we have no id
  1847. $('#wp-admin-bar-edit').remove();
  1848. }
  1849. } else { //upss ... no edit button
  1850. //lets see if we need one
  1851. if ( id !== undefined && editString !== undefined ) { //we do need one after all
  1852. //locate the New button because we need to add stuff after it
  1853. var $newButton = $('#wp-admin-bar-new-content');
  1854.  
  1855. if (!empty($newButton)) {
  1856. if (!empty(taxonomy)) { //it seems we need to generate a taxonomy edit thingy
  1857. $newButton.after('<li id="wp-admin-bar-edit"><a class="ab-item dJAX_internal" href="' + baseExitTaxURL + '?tag_ID=' + id + '&taxonomy=' + taxonomy + '&action=edit">' + editString + '</a></li>');
  1858. } else { //just a regular edit
  1859. $newButton.after('<li id="wp-admin-bar-edit"><a class="ab-item dJAX_internal" href="' + baseEditURL + '?post=' + id + '&action=edit">' + editString + '</a></li>');
  1860. }
  1861. }
  1862. }
  1863. }
  1864. }
  1865.  
  1866. function copyrightOverlayAnimation(direction, x, y){
  1867. switch (direction){
  1868. case 'in':{
  1869. if (globalDebug) {timestamp = ' [' + Date.now() + ']';console.log("Animate Copyright Overlay - IN"+timestamp);}
  1870.  
  1871. $('.copyright-overlay').css({top: y, left: x});
  1872. $('body').addClass('is--active-copyright-overlay');
  1873. $('.copyright-overlay').fadeIn();
  1874.  
  1875. break;
  1876. }
  1877.  
  1878. case 'out':{
  1879. if (globalDebug) {timestamp = ' [' + Date.now() + ']';console.log("Animate Copyright Overlay - OUT"+timestamp);}
  1880.  
  1881. $('.copyright-overlay').fadeOut();
  1882. $('body').removeClass('is--active-copyright-overlay');
  1883.  
  1884. break;
  1885. }
  1886.  
  1887. default: break;
  1888. }
  1889. }
  1890.  
  1891. function copyrightOverlayInit(){
  1892. $(document).on('contextmenu', '.pixslider--gallery.js-pixslider, .mfp-container, .mosaic-wrapper, img, a[href$=".jpg"], a[href$=".jpeg"], a[href$=".png"], a[href$=".gif"]', function(e){
  1893. if( !empty($('.copyright-overlay'))){
  1894. e.preventDefault();
  1895. e.stopPropagation();
  1896.  
  1897. copyrightOverlayAnimation('in', e.clientX, e.clientY);
  1898. }
  1899. });
  1900.  
  1901. $('a[href$=".jpg"], a[href$=".jpeg"], a[href$=".png"], a[href$=".gif"]').bind('click', function(e){
  1902. if (e.ctrlKey || e.metaKey){
  1903. e.preventDefault();
  1904. e.stopPropagation();
  1905.  
  1906. copyrightOverlayAnimation('in', e.clientX, e.clientY);
  1907. }
  1908. });
  1909.  
  1910. $(document).on('mousedown', function(){
  1911. if($('body').hasClass('is--active-copyright-overlay'))
  1912. copyrightOverlayAnimation('out');
  1913. });
  1914. }
  1915.  
  1916.  
  1917. })(jQuery, window);
  1918.  
  1919. // /* ====== HELPER FUNCTIONS ====== */
  1920.  
  1921. //similar to PHP's empty function
  1922. function empty(data)
  1923. {
  1924. if(typeof(data) == 'number' || typeof(data) == 'boolean')
  1925. {
  1926. return false;
  1927. }
  1928. if(typeof(data) == 'undefined' || data === null)
  1929. {
  1930. return true;
  1931. }
  1932. if(typeof(data.length) != 'undefined')
  1933. {
  1934. return data.length === 0;
  1935. }
  1936. var count = 0;
  1937. for(var i in data)
  1938. {
  1939. // if(data.hasOwnProperty(i))
  1940. //
  1941. // This doesn't work in ie8/ie9 due the fact that hasOwnProperty works only on native objects.
  1942. // http://stackoverflow.com/questions/8157700/object-has-no-hasownproperty-method-i-e-its-undefined-ie8
  1943. //
  1944. // for hosts objects we do this
  1945. if(Object.prototype.hasOwnProperty.call(data,i))
  1946. {
  1947. count ++;
  1948. }
  1949. }
  1950. return count === 0;
  1951. }
  1952.  
  1953. /* --- Set Query Parameter--- */
  1954. function setQueryParameter(uri, key, value) {
  1955. var re = new RegExp("([?|&])" + key + "=.*?(&|$)", "i");
  1956. separator = uri.indexOf('?') !== -1 ? "&" : "?";
  1957. if (uri.match(re)) {
  1958. return uri.replace(re, '$1' + key + "=" + value + '$2');
  1959. }
  1960. else {
  1961. return uri + separator + key + "=" + value;
  1962. }
  1963. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement