1// Init actions 2function sevenhills_sc_init_actions() { 3 "use strict"; 4 setTimeout(function() { 5 sevenhills_sc_animation(); 6 }, 600); 7 8 // MenuItems - init once 9 jQuery('body') 10 .on('click', '.show_popup_menuitem', function(e) { 11 "use strict"; 12 sevenhills_menuitems_show_popup(jQuery(this)); 13 e.preventDefault(); 14 return false; 15 }) 16 .on('click', '.close_menuitem, .popup_menuitem', function(e) { 17 "use strict"; 18 var target = jQuery(e.target); 19 if (target.hasClass('popup_menuitem') || target.hasClass('close_menuitem') || target.parent().hasClass('close_menuitem')) { 20 sevenhills_menuitems_hide_popup(); 21 e.preventDefault(); 22 return false; 23 } 24 }); 25 26 // Init sc in container 27 sevenhills_sc_init(jQuery('body').eq(0)); 28} 29 30 31// Resize actions 32function sevenhills_sc_resize_actions() { 33 "use strict"; 34 sevenhills_sc_sliders_resize(); 35 sevenhills_sc_equal_height(); 36} 37 38 39// Scroll actions 40function sevenhills_sc_scroll_actions() { 41 "use strict"; 42 sevenhills_sc_animation(); 43} 44 45 46// Animation 47function sevenhills_sc_animation() { 48 jQuery('[data-animation^="animated"]:not(.animated)').each(function() { 49 "use strict"; 50 if (jQuery(this).offset().top < jQuery(window).scrollTop() + jQuery(window).height()) 51 jQuery(this).addClass(jQuery(this).data('animation')); 52 }); 53} 54 55 56// Shortcodes init 57function sevenhills_sc_init(container) { 58 59 // Call theme specific action (if exists) 60 if (window.sevenhills_theme_sc_init) sevenhills_theme_sc_init(container); 61 62 // Accordion 63 if (container.find('.sc_accordion:not(.inited)').length > 0) { 64 container.find(".sc_accordion:not(.inited)").each(function () { 65 "use strict"; 66 var init = jQuery(this).data('active'); 67 if (isNaN(init)) init = 0; 68 else init = Math.max(0, init); 69 jQuery(this) 70 .addClass('inited') 71 .accordion({ 72 active: init, 73 heightStyle: "content", 74 header: "> .sc_accordion_item > .sc_accordion_title", 75 create: function (event, ui) { 76 "use strict"; 77 sevenhills_sc_init(ui.panel); 78 if (window.sevenhills_init_hidden_elements) sevenhills_init_hidden_elements(ui.panel); 79 ui.header.each(function () { 80 "use strict"; 81 jQuery(this).parent().addClass('sc_active'); 82 }); 83 }, 84 activate: function (event, ui) { 85 "use strict"; 86 sevenhills_sc_init(ui.newPanel); 87 if (window.sevenhills_init_hidden_elements) sevenhills_init_hidden_elements(ui.newPanel); 88 ui.newHeader.each(function () { 89 "use strict"; 90 jQuery(this).parent().addClass('sc_active'); 91 }); 92 ui.oldHeader.each(function () { 93 "use strict"; 94 jQuery(this).parent().removeClass('sc_active'); 95 }); 96 } 97 }); 98 }); 99 } 100 101 // Blogger: style Polaroid 102 if (container.find('.sc_blogger.layout_polaroid .photostack:not(.inited)').length > 0) { 103 container.find(".sc_blogger.layout_polaroid .photostack:not(.inited)").each(function () { 104 "use strict"; 105 var obj = jQuery(this); 106 var id = obj.attr('id'); 107 if (id == undefined) { 108 id = 'photostack_'+Math.random(); 109 id = id.replace('.', ''); 110 obj.attr('id', id); 111 } 112 setTimeout(function() { 113 "use strict"; 114 obj.addClass('inited').parent().height("auto"); 115 new Photostack( obj.get(0), { 116 callback: function( item ) { 117 } 118 } ); 119 }, 10); 120 }); 121 } 122 123 // Blogger: Scroll horizontal 124 if (container.find('.sc_blogger .sc_scroll_horizontal .sc_scroll_wrapper:not(.inited)').length > 0) { 125 container.find(".sc_blogger .sc_scroll_horizontal .sc_scroll_wrapper:not(.inited)").each(function () { 126 "use strict"; 127 var obj = jQuery(this); 128 var width = 0; 129 obj.find('.isotope_item').each(function(){ 130 "use strict"; 131 width += jQuery(this).outerWidth(); 132 }); 133 obj.addClass('inited').width(width); 134 }); 135 } 136 137 // Form 138 if (container.find('.sc_form form:not(.inited)').length > 0) { 139 container.find(".sc_form form:not(.inited)").each(function() { 140 "use strict"; 141 jQuery(this).addClass('inited'); 142 jQuery(this).submit(function(e) { 143 "use strict"; 144 sevenhills_sc_form_validate(jQuery(this)); 145 e.preventDefault(); 146 return false; 147 }); 148 if (jQuery(this).find('.js__datepicker').length > 0) { 149 jQuery(this).find('.js__datepicker').pickadate({ 150 // Work-around for some mobile browsers clipping off the picker. 151 onOpen: function() { 152 "use strict"; 153 jQuery('pre').css('overflow', 'hidden'); 154 }, 155 onClose: function() { 156 "use strict"; 157 jQuery('pre').css('overflow', ''); 158 }, 159 monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec' ], 160 showMonthsShort: true, 161 format: 'dd.mm.yyyy', 162 formatSubmit: 'yyyy-mm-dd', 163 min: true 164 }); 165 } 166 if (jQuery(this).find('.js__timepicker').length > 0) { 167 jQuery(this).find('.js__timepicker').pickatime(); 168 } 169 }); 170 } 171 172 //Countdown 173 if (container.find('.sc_countdown:not(.inited)').length > 0) { 174 container.find('.sc_countdown:not(.inited)') 175 .each(function () { 176 "use strict"; 177 jQuery(this).addClass('inited'); 178 var id = jQuery(this).attr('id'); 179 var curDate = new Date(); 180 var curDateTimeStr = curDate.getFullYear()+'-'+(curDate.getMonth()<9 ? '0' : '')+(curDate.getMonth()+1)+'-'+(curDate.getDate()<10 ? '0' : '')+curDate.getDate() 181 +' '+(curDate.getHours()<10 ? '0' : '')+curDate.getHours()+':'+(curDate.getMinutes()<10 ? '0' : '')+curDate.getMinutes()+':'+(curDate.getSeconds()<10 ? '0' : '')+curDate.getSeconds(); 182 var interval = 1; //jQuery(this).data('interval'); 183 var endDateStr = jQuery(this).data('date'); 184 var endDateParts = endDateStr.split('-'); 185 var endTimeStr = jQuery(this).data('time'); 186 var endTimeParts = endTimeStr.split(':'); 187 if (endTimeParts.length < 3) endTimeParts[2] = '00'; 188 var endDateTimeStr = endDateStr+' '+endTimeStr; 189 if (curDateTimeStr < endDateTimeStr) { 190 jQuery(this).find('.sc_countdown_placeholder').countdown({ 191 until: new Date(endDateParts[0], endDateParts[1]-1, endDateParts[2], endTimeParts[0], endTimeParts[1], endTimeParts[2]), 192 tickInterval: interval, 193 onTick: sevenhills_countdown 194 }); 195 } else { 196 jQuery(this).find('.sc_countdown_placeholder').countdown({ 197 since: new Date(endDateParts[0], endDateParts[1]-1, endDateParts[2], endTimeParts[0], endTimeParts[1], endTimeParts[2]), 198 tickInterval: interval, 199 onTick: sevenhills_countdown 200 }); 201 } 202 }); 203 } 204 205 // Googlemap init 206 if (container.find('.sc_googlemap:not(.inited)').length > 0) { 207 container.find('.sc_googlemap:not(.inited)') 208 .each(function () { 209 "use strict"; 210 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 211 var map = jQuery(this).addClass('inited'); 212 var map_id = map.attr('id'); 213 var map_zoom = map.data('zoom'); 214 var map_style = map.data('style'); 215 var map_markers = []; 216 map.find('.sc_googlemap_marker').each(function() { 217 "use strict"; 218 var marker = jQuery(this); 219 map_markers.push({ 220 point: marker.data('point'), 221 address: marker.data('address'), 222 latlng: marker.data('latlng'), 223 description: marker.data('description'), 224 title: marker.data('title') 225 }); 226 }); 227 sevenhills_googlemap_init( jQuery('#'+map_id).get(0), {style: map_style, zoom: map_zoom, markers: map_markers}); 228 }); 229 } 230 231 // Infoboxes 232 if (container.find('.sc_infobox.sc_infobox_closeable:not(.inited)').length > 0) { 233 container.find('.sc_infobox.sc_infobox_closeable:not(.inited)') 234 .addClass('inited') 235 .on('click', function (e) { 236 "use strict"; 237 jQuery(this).slideUp(); 238 e.preventDefault(); 239 return false;
240 }); 241 } 242 243 // Intro 244 if (container.find('.sc_intro[data-href]:not(.inited)').length > 0) { 245 container.find('.sc_intro[data-href]:not(.inited)') 246 .addClass('inited') 247 .on('click', function (e) { 248 "use strict"; 249 var link = jQuery(this).data('href'); 250 window.location.href = link; 251 e.preventDefault(); 252 return false; 253 }); 254 } 255 256 // Matches 257 if (container.find('.sc_matches:not(.inited)').length > 0) { 258 container.find('.sc_matches:not(.inited)') 259 .each(function () { 260 "use strict"; 261 jQuery(this).find('.sc_matches_next .sc_matches_list .sc_match').on('click', function () { 262 "use strict"; 263 jQuery(this).parents('.sc_matches').find('.sc_matches_current .sc_match').hide(); 264 var item = jQuery(this).data('item'); 265 jQuery(item).fadeIn(); 266 }); 267 }); 268 } 269 270 // Matches & Players: Sort players by points 271 if (container.find('.sc_players_table:not(.inited)').length > 0) { 272 container.find('.sc_players_table:not(.inited)') 273 .addClass('inited') 274 .on('click', '.sort', function (e) { 275 "use strict"; 276 var table = jQuery(this).parents('.sc_players_table'); 277 var id = jQuery(table).attr('id')
278 var sort = jQuery(table).data('sort') == 'asc' ? 'desc' : 'asc'; 279 jQuery.post(SEVENHILLS_STORAGE['ajax_url'], { 280 action: 'sort_by_points', 281 nonce: SEVENHILLS_STORAGE['ajax_nonce'], 282 sort: sort, 283 table: SEVENHILLS_STORAGE['ajax_' + id] 284 }).done(function(response) { 285 var rez = {}; 286 try { 287 rez = JSON.parse(response); 288 } catch (e) { 289 rez = { error: SEVENHILLS_STORAGE['ajax_error'] }; 290 console.log(response); 291 } 292 if (rez.error === '') { 293 table 294 .data('sort', sort) 295 .find('.sc_table') 296 .after(rez.data) 297 .remove(); 298 sevenhills_select_players_category(jQuery(table).find('.sc_players_table_category select')); 299 } 300 }); 301 e.preventDefault(); 302 return false; 303 }); 304 } 305 306 // Matches & Players: Select category in the points table 307 if (container.find('.sc_players_table_category:not(.inited)').length > 0) { 308 container.find('.sc_players_table_category:not(.inited)') 309 .addClass('inited') 310 .on('change', function () { 311 "use strict"; 312 sevenhills_select_players_category(jQuery(this)); 313 }); 314 } 315 316 // Popup links 317 if (container.find('.sc_popup_link:not(.inited)').length > 0) { 318 container.find('.sc_popup_link:not(.inited)').each(function() { 319 var popup_id = jQuery(this).attr('href'); 320 jQuery(this) 321 .addClass('inited') 322 .magnificPopup({ 323 type: 'inline', 324 removalDelay: 500, 325 midClick: true, 326 callbacks: { 327 beforeOpen: function () { 328 this.st.mainClass = 'mfp-zoom-in'; 329 }, 330 open: function() { 331 "use strict"; 332 sevenhills_sc_init(jQuery(popup_id)); 333 sevenhills_resize_actions(); 334 if (window.sevenhills_init_hidden_elements) sevenhills_init_hidden_elements(jQuery(popup_id)); 335 }, 336 close: function() {} 337 } 338 }); 339 }); 340 } 341 342 // Recent news widget and sc 343 if (container.find('.sc_recent_news_header_category_item_more:not(.inited)').length > 0) { 344 container.find('.sc_recent_news_header_category_item_more:not(.inited)').each(function() { 345 "use strict"; 346 jQuery(this) 347 .addClass('inited') 348 .on('click', function(e) { 349 "use strict"; 350 jQuery(this).toggleClass('opened').find('.sc_recent_news_header_more_categories').slideToggle(); 351 e.preventDefault(); 352 return false; 353 }); 354 }); 355 } 356 357 // Search form 358 if (container.find('.search_wrap:not(.inited)').length > 0) { 359 container.find('.search_wrap:not(.inited)').each(function() { 360 "use strict"; 361 jQuery(this) 362 .addClass('inited') 363 .on('click', '.search_submit', function(e) { 364 "use strict"; 365 var search_wrap = jQuery(this).parents('.search_wrap'); 366 if (!search_wrap.hasClass('search_state_fixed')) { 367 if (search_wrap.hasClass('search_state_opened')) { 368 if (search_wrap.find('.search_field').val() != '') 369 search_wrap.find('form').get(0).submit(); 370 else 371 search_wrap.removeClass('search_state_opened').addClass('search_state_closed').find('.search_results').fadeOut(); 372 } else 373 search_wrap.removeClass('search_state_closed').addClass('search_state_opened').find('.search_field').get(0).focus(); 374 } else { 375 if (search_wrap.find('.search_field').val() != '') 376 search_wrap.find('form').get(0).submit(); 377 else { 378 search_wrap.find('.search_field').val(''); 379 search_wrap.find('.search_results').fadeOut(); 380 } 381 } 382 e.preventDefault(); 383 return false; 384 }) 385 .on('click', '.search_close', function(e) { 386 "use strict"; 387 jQuery(this).parents('.search_wrap').removeClass('search_state_opened').addClass('search_state_closed').find('.search_results').fadeOut(); 388 e.preventDefault(); 389 return false; 390 }) 391 .on('click', '.search_results_close', function(e) { 392 "use strict"; 393 jQuery(this).parent().fadeOut(); 394 e.preventDefault(); 395 return false; 396 }) 397 .on('click', '.search_more', function(e) { 398 "use strict"; 399 if (jQuery(this).parents('.search_wrap').find('.search_field').val() != '') 400 jQuery(this).parents('.search_wrap').find('form').get(0).submit(); 401 e.preventDefault(); 402 return false;
403 }) 404 .on('blur', '.search_field', function(e) { 405 if (jQuery(this).val() == '' && !jQuery(this).parents('.search_wrap').hasClass('search_state_fixed')) 406 jQuery(this).parents('.search_wrap').removeClass('search_state_opened').addClass('search_state_closed').find('.search_results').fadeOut(); 407 }); 408 409 if (jQuery(this).hasClass('search_ajax')) { 410 var ajax_timer = null; 411 jQuery(this).find('.search_field').keyup(function(e) { 412 "use strict"; 413 var search_field = jQuery(this); 414 var s = search_field.val(); 415 if (ajax_timer) { 416 clearTimeout(ajax_timer); 417 ajax_timer = null; 418 } 419 if (s.length >= SEVENHILLS_STORAGE['ajax_search_min_length']) { 420 ajax_timer = setTimeout(function() { 421 "use strict"; 422 jQuery.post(SEVENHILLS_STORAGE['ajax_url'], { 423 action: 'ajax_search', 424 nonce: SEVENHILLS_STORAGE['ajax_nonce'], 425 text: s 426 }).done(function(response) { 427 "use strict"; 428 clearTimeout(ajax_timer); 429 ajax_timer = null; 430 var rez = {}; 431 try { 432 rez = JSON.parse(response); 433 } catch (e) { 434 rez = { error: SEVENHILLS_STORAGE['ajax_error'] }; 435 console.log(response); 436 } 437 if (rez.error === '') { 438 search_field.parents('.search_ajax').find('.search_results_content').empty().append(rez.data); 439 search_field.parents('.search_ajax').find('.search_results').fadeIn(); 440 } else { 441 sevenhills_message_warning(SEVENHILLS_STORAGE['strings']['search_error']); 442 } 443 }); 444 }, SEVENHILLS_STORAGE['ajax_search_delay']); 445 } 446 }); 447 } 448 }); 449 } 450 451 452 // Section Pan init 453 if (container.find('.sc_pan:not(.inited_pan)').length > 0) { 454 container.find('.sc_pan:not(.inited_pan)') 455 .each(function () { 456 "use strict"; 457 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 458 var pan = jQuery(this).addClass('inited_pan'); 459 var cont = pan.parent(); 460 cont.mousemove(function(e) { 461 "use strict"; 462 var anim = {}; 463 var tm = 0; 464 var pw = pan.width(), ph = pan.height(); 465 var cw = cont.width(), ch = cont.height(); 466 var coff = cont.offset(); 467 if (pan.hasClass('sc_pan_vertical')) 468 pan.css('top', -Math.floor((e.pageY - coff.top) / ch * (ph-ch))); 469 if (pan.hasClass('sc_pan_horizontal')) 470 pan.css('left', -Math.floor((e.pageX - coff.left) / cw * (pw-cw))); 471 }); 472 cont.mouseout(function(e) { 473 "use strict"; 474 pan.css({'left': 0, 'top': 0}); 475 }); 476 }); 477 } 478 479 // Scroll 480 if (container.find('.sc_scroll:not(.inited)').length > 0) { 481 container.find('.sc_scroll:not(.inited)') 482 .each(function () { 483 "use strict"; 484 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 485 SEVENHILLS_STORAGE['scroll_init_counter'] = 0; 486 sevenhills_sc_init_scroll_area(jQuery(this)); 487 }); 488 } 489 490 491 // Swiper Slider 492 if (container.find('.sc_slider_swiper:not(.inited)').length > 0) { 493 container.find('.sc_slider_swiper:not(.inited)') 494 .each(function () { 495 "use strict"; 496 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 497 //if (jQuery(this).parents('.isotope_wrap:not(.inited)').length > 0) return; 498 jQuery(this).addClass('inited'); 499 sevenhills_sc_slider_autoheight(jQuery(this)); 500 if (jQuery(this).parents('.sc_slider_pagination_area').length > 0) { 501 jQuery(this).parents('.sc_slider_pagination_area').find('.sc_slider_pagination .post_item').eq(0).addClass('active'); 502 } 503 var id = jQuery(this).attr('id'); 504 if (id == undefined) { 505 id = 'swiper_'+Math.random(); 506 id = id.replace('.', ''); 507 jQuery(this).attr('id', id); 508 } 509 jQuery(this).addClass(id); 510 jQuery(this).find('.slides .swiper-slide').css('position', 'relative'); 511 var width = jQuery(this).width(); 512 if (width == 0) width = jQuery(this).parent().width(); 513 var spv = jQuery(this).data('slides-per-view'); 514 if (spv == undefined) spv = 1; 515 var min_width = jQuery(this).data('slides-min-width'); 516 if (min_width == undefined) min_width = 50; 517 if (width / spv < min_width) spv = Math.max(1, Math.floor(width / min_width)); 518 var space = jQuery(this).data('slides-space'); 519 if (space == undefined) space = 0; 520 if (SEVENHILLS_STORAGE['swipers'] === undefined) SEVENHILLS_STORAGE['swipers'] = {}; 521 SEVENHILLS_STORAGE['swipers'][id] = new Swiper('.'+id, { 522 calculateHeight: !jQuery(this).hasClass('sc_slider_height_fixed'), 523 resizeReInit: true, 524 autoResize: true, 525 loop: true, 526 grabCursor: true, 527 nextButton: jQuery(this).hasClass('sc_slider_controls') ? '#'+id+' .sc_slider_next' : false, 528 prevButton: jQuery(this).hasClass('sc_slider_controls') ? '#'+id+' .sc_slider_prev' : false, 529 pagination: jQuery(this).hasClass('sc_slider_pagination') ? '#'+id+' .sc_slider_pagination_wrap' : false, 530 paginationClickable: true, 531 autoplay: jQuery(this).hasClass('sc_slider_noautoplay') ? false : (isNaN(jQuery(this).data('interval')) ? 7000 : jQuery(this).data('interval')), 532 autoplayDisableOnInteraction: false, 533 initialSlide: 0, 534 slidesPerView: spv, 535 loopedSlides: spv, 536 spaceBetween: space, 537 speed: 600,
538 // Autoheight on start 539 onFirstInit: function (slider){ 540 "use strict"; 541 var cont = jQuery(slider.container); 542 if (!cont.hasClass('sc_slider_height_auto')) return; 543 var li = cont.find('.swiper-slide').eq(1); 544 var h = li.data('height_auto'); 545 if (h > 0) { 546 var pt = parseInt(li.css('paddingTop')), pb = parseInt(li.css('paddingBottom')); 547 li.height(h); 548 cont.height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb)); 549 cont.find('.swiper-wrapper').height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb)); 550 } 551 }, 552 // Autoheight on slide change 553 onSlideChangeStart: function (slider){ 554 "use strict"; 555 var cont = jQuery(slider.container); 556 if (!cont.hasClass('sc_slider_height_auto')) return; 557 var idx = slider.activeIndex; 558 var li = cont.find('.swiper-slide').eq(idx); 559 var h = li.data('height_auto'); 560 if (h > 0) { 561 var pt = parseInt(li.css('paddingTop')), pb = parseInt(li.css('paddingBottom')); 562 li.height(h); 563 cont.height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb)); 564 cont.find('.swiper-wrapper').height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb)); 565 } 566 }, 567 // Change current item in 'full' or 'over' pagination wrap 568 onSlideChangeEnd: function (slider, dir) { 569 "use strict"; 570 var cont = jQuery(slider.container); 571 if (cont.parents('.sc_slider_pagination_area').length > 0) { 572 var li = cont.parents('.sc_slider_pagination_area').find('.sc_slider_pagination .post_item'); 573 var idx = slider.activeIndex > li.length ? 0 : slider.activeIndex-1; 574 sevenhills_sc_change_active_pagination_in_slider(cont, idx); 575 } 576 } 577 }); 578 579 jQuery(this).data('settings', {mode: 'horizontal'}); // VC hook 580 581 var curSlide = jQuery(this).find('.slides').data('current-slide'); 582 if (curSlide > 0) 583 SEVENHILLS_STORAGE['swipers'][id].slideTo(curSlide-1); 584 585 sevenhills_sc_prepare_slider_navi(jQuery(this)); 586 587 }); 588 589 // Check slides per view 590 sevenhills_sc_sliders_resize(); 591 } 592 593 //Skills init 594 if (container.find('.sc_skills_item:not(.inited)').length > 0) { 595 sevenhills_sc_init_skills(container); 596 jQuery(window).scroll(function () { sevenhills_sc_init_skills(container); }); 597 } 598 //Skills type='arc' init 599 if (container.find('.sc_skills_arc:not(.inited)').length > 0) { 600 sevenhills_sc_init_skills_arc(container); 601 jQuery(window).scroll(function () { sevenhills_sc_init_skills_arc(container); }); 602 } 603 604 // Tabs 605 if (container.find('.sc_tabs:not(.inited):not(.no_jquery_ui),.tabs_area:not(.inited)').length > 0) { 606 container.find('.sc_tabs:not(.inited):not(.no_jquery_ui),.tabs_area:not(.inited)').each(function () { 607 "use strict"; 608 var init = jQuery(this).data('active'); 609 if (isNaN(init)) init = 0; 610 else init = Math.max(0, init); 611 jQuery(this) 612 .addClass('inited') 613 .tabs({ 614 active: init, 615 show: { 616 effect: 'fadeIn', 617 duration: 300 618 }, 619 hide: { 620 effect: 'fadeOut', 621 duration: 300 622 }, 623 create: function (event, ui) { 624 "use strict"; 625 sevenhills_sc_init(ui.panel); 626 if (window.sevenhills_init_hidden_elements) sevenhills_init_hidden_elements(ui.panel); 627 sevenhills_init_isotope(); 628 }, 629 activate: function (event, ui) { 630 "use strict"; 631 sevenhills_sc_init(ui.newPanel); 632 if (window.sevenhills_init_hidden_elements) sevenhills_init_hidden_elements(ui.newPanel); 633 sevenhills_init_isotope(); 634 } 635 }); 636 }); 637 } 638 if (container.find('.sc_tabs.no_jquery_ui:not(.inited)').length > 0) { 639 container.find('.sc_tabs.no_jquery_ui:not(.inited)').each(function () { 640 "use strict"; 641 jQuery(this) 642 .addClass('inited') 643 .on('click', '.sc_tabs_titles li a', function(e) { 644 "use strict"; 645 if (!jQuery(this).parent().hasClass('sc_tabs_active')) { 646 var id_act = jQuery(this).parent().siblings('.sc_tabs_active').find('a').attr('href'); 647 var id = jQuery(this).attr('href'); 648 jQuery(this).parent().addClass('sc_tabs_active').siblings().removeClass('sc_tabs_active'); 649 jQuery(id_act).fadeOut(function() { 650 "use strict"; 651 jQuery(id).fadeIn(function() { 652 "use strict"; 653 sevenhills_sc_init(jQuery(this)); 654 if (window.sevenhills_init_hidden_elements) sevenhills_init_hidden_elements(jQuery(this)); 655 }); 656 }); 657 } 658 e.preventDefault(); 659 return false;
660 }); 661 jQuery(this).find('.sc_tabs_titles li').eq(0).addClass('sc_tabs_active'); 662 jQuery(this).find('.sc_tabs_content').eq(0).fadeIn(function() { 663 "use strict"; 664 sevenhills_sc_init(jQuery(this)); 665 if (window.sevenhills_init_hidden_elements) sevenhills_init_hidden_elements(jQuery(this)); 666 }); 667 }); 668 } 669 670 // Toggles 671 if (container.find('.sc_toggles .sc_toggles_title:not(.inited)').length > 0) { 672 container.find('.sc_toggles .sc_toggles_title:not(.inited)') 673 .addClass('inited') 674 .on('click', function () { 675 "use strict"; 676 jQuery(this).toggleClass('ui-state-active').parent().toggleClass('sc_active'); 677 jQuery(this).parent().find('.sc_toggles_content').slideToggle(300, function () { 678 "use strict"; 679 sevenhills_sc_init(jQuery(this).parent().find('.sc_toggles_content')); 680 if (window.sevenhills_init_hidden_elements) sevenhills_init_hidden_elements(jQuery(this).parent().find('.sc_toggles_content')); 681 }); 682 }); 683 } 684 685 //Zoom 686 if (container.find('.sc_zoom:not(.inited)').length > 0) { 687 container.find('.sc_zoom:not(.inited)') 688 .each(function () { 689 "use strict"; 690 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 691 jQuery(this).addClass('inited'); 692 jQuery(this).find('img').elevateZoom({ 693 zoomType: "lens", 694 lensShape: "round", 695 lensSize: 200, 696 lensBorderSize: 4, 697 lensBorderColour: '#ccc' 698 }); 699 }); 700 } 701 702} 703 704 705 706// Scrolled areas 707function sevenhills_sc_init_scroll_area(obj) { 708 "use strict"; 709 710 // Wait for images loading 711 if (!sevenhills_check_images_complete(obj) && SEVENHILLS_STORAGE['scroll_init_counter']++ < 30) { 712 setTimeout(function() { sevenhills_sc_init_scroll_area(obj); }, 200); 713 return; 714 } 715 716 // Start init scroll area 717 obj.addClass('inited'); 718 719 var id = obj.attr('id'); 720 if (id == undefined) { 721 id = 'scroll_'+Math.random(); 722 id = id.replace('.', ''); 723 obj.attr('id', id); 724 } 725 obj.addClass(id); 726 727 var parent_obj = obj.parent(); 728 var parent_id = parent_obj.attr('id'); 729 if (parent_id == undefined) { 730 parent_id = 'scroll_wrap_'+Math.random(); 731 parent_id = parent_id.replace('.', ''); 732 parent_obj.attr('id', parent_id); 733 } 734 parent_obj.addClass(parent_id); 735 736 var bar = obj.find('#'+id+'_bar'); 737 if (bar.length > 0 && !bar.hasClass(id+'_bar')) { 738 bar.addClass(id+'_bar'); 739 } 740 741 // Correct wrapper width (if scroll dir = horizontal) 742 if (obj.hasClass('sc_scroll_horizontal')) { 743 obj.find('.sc_scroll_wrapper > .sc_scroll_slide').css('width', 'auto'); 744 obj.find('.sc_scroll_wrapper').css('width', obj.find('.sc_scroll_wrapper > .sc_scroll_slide').width()+10); 745 obj.find('.sc_scroll_wrapper > .sc_scroll_slide').css('width', '100%') 746 } 747 748 // Init Swiper with scroll plugin 749 if (SEVENHILLS_STORAGE['swipers'] === undefined) SEVENHILLS_STORAGE['swipers'] = {}; 750 SEVENHILLS_STORAGE['swipers'][id] = new Swiper('.'+id, { 751 calculateHeight: false, 752 resizeReInit: true, 753 autoResize: true, 754 freeMode: true, 755 freeModeFluid: true, 756 grabCursor: true, 757 mode: obj.hasClass('sc_scroll_vertical') ? 'vertical' : 'horizontal', 758 direction: obj.hasClass('sc_scroll_vertical') ? 'vertical' : 'horizontal', 759 slidesPerView: obj.hasClass('sc_scroll') ? 'auto' : 1, 760 nextButton: parent_obj.hasClass('sc_scroll_controls') ? '#'+parent_id+' .sc_scroll_next' : false, 761 prevButton: parent_obj.hasClass('sc_scroll_controls') ? '#'+parent_id+' .sc_scroll_prev' : false, 762 scrollbar: '.'+id+'_bar', 763 scrollbarHide: true, 764 }) 765 766 // VC hook 767 obj.data('settings', {mode: 'horizontal'}); 768} 769 770 771// Slider navigation 772function sevenhills_sc_prepare_slider_navi(slider) { 773 "use strict"; 774 var navi = null; 775 776 // Prev / Next
777 // Remove condition in the line below if you need add click handler to next/prev buttons 778 if (false) { 779 navi = slider.find('> .sc_slider_controls_wrap, > .sc_scroll_controls_wrap'); 780 if (navi.length == 0) navi = slider.siblings('.sc_slider_controls_wrap,.sc_scroll_controls_wrap'); 781 if (navi.length > 0) { 782 navi.on('click', '.sc_slider_prev,.sc_scroll_prev', function(e) { 783 var swiper = jQuery(this).parents('.swiper-slider-container'); 784 if (swiper.length == 0) swiper = jQuery(this).parents('.sc_slider_controls_wrap,.sc_scroll_controls_wrap').siblings('.swiper-slider-container'); 785 var id = swiper.attr('id'); 786 SEVENHILLS_STORAGE['swipers'][id].slidePrev(); 787 e.preventDefault(); 788 return false; 789 }) 790 .on('click', '.sc_slider_next,.sc_scroll_next', function(e){ 791 var swiper = jQuery(this).parents('.swiper-slider-container'); 792 if (swiper.length == 0) swiper = jQuery(this).parents('.sc_slider_controls_wrap,.sc_scroll_controls_wrap').siblings('.swiper-slider-container'); 793 var id = swiper.attr('id'); 794 SEVENHILLS_STORAGE['swipers'][id].slideNext(); 795 e.preventDefault(); 796 return false; 797 }); 798 } 799 } 800 801 // Pagination with slide's title 802 navi = slider.siblings('.sc_slider_pagination'); 803 if (navi.length > 0) { 804 navi.on('click', '.post_item', function(e){ 805 var swiper = jQuery(this).parents('.sc_slider_pagination_area').find('.swiper-slider-container'); 806 var id = swiper.attr('id'); 807 SEVENHILLS_STORAGE['swipers'][id].slideTo(jQuery(this).index()+1); 808 e.preventDefault(); 809 return false; 810 }); 811 } 812} 813 814// Sliders: Pagination 815function sevenhills_sc_change_active_pagination_in_slider(slider, idx) { 816 "use strict"; 817 var pg = slider.parents('.sc_slider_pagination_area').find('.sc_slider_pagination'); 818 if (pg.length==0) return; 819 pg.find('.post_item').removeClass('active').eq(idx).addClass('active'); 820 var h = pg.height(); 821 var off = pg.find('.active').offset().top - pg.offset().top; 822 var off2 = pg.find('.sc_scroll_wrapper').offset().top - pg.offset().top; 823 var h2 = pg.find('.active').height(); 824 if (off < 0) { 825 pg.find('.sc_scroll_wrapper').css({'transform': 'translate3d(0px, 0px, 0px)', 'transition-duration': '0.3s'}); 826 } else if (h <= off+h2) { 827 pg.find('.sc_scroll_wrapper').css({'transform': 'translate3d(0px, -'+(Math.abs(off2)+off-h/4)+'px, 0px)', 'transition-duration': '0.3s'}); 828 } 829} 830 831// Sliders: Autoheight 832function sevenhills_sc_slider_autoheight(slider) { 833 "use strict"; 834 if (slider.hasClass('.sc_slider_height_auto')) { 835 slider.find('.swiper-slide').each(function() { 836 "use strict"; 837 if (jQuery(this).data('height_auto') == undefined) { 838 jQuery(this).attr('data-height_auto', jQuery(this).height()); 839 } 840 }); 841 } 842} 843 844// Sliders: Resize 845function sevenhills_sc_sliders_resize() { 846 "use strict"; 847 var slider = arguments[0]!==undefined ? arguments[0] : '.sc_slider_swiper.inited'; 848 var resize = arguments[1]!==undefined ? arguments[1] : true; 849 850 jQuery(slider).each(function() { 851 "use strict"; 852 var id = jQuery(this).attr('id'); 853 var width = jQuery(this).width(); 854 var last_width = jQuery(this).data('last-width'); 855 if (isNaN(last_width)) last_width = 0; 856 857 // Change slides_per_view 858 if (last_width==0 || last_width!=width) { 859 var spv = jQuery(this).data('slides-per-view'); 860 if (spv == undefined) spv = 1; 861 var min_width = jQuery(this).data('slides-min-width'); 862 if (min_width == undefined) min_width = 50; 863 if (width / spv < min_width) spv = Math.max(1, Math.floor(width / min_width)); 864 jQuery(this).data('last-width', width); 865 if (SEVENHILLS_STORAGE['swipers'][id].params.slidesPerView != spv) { 866 SEVENHILLS_STORAGE['swipers'][id].params.slidesPerView = spv; 867 SEVENHILLS_STORAGE['swipers'][id].params.loopedSlides = spv; 868 //SEVENHILLS_STORAGE['swipers'][id].reInit(); 869 } 870 SEVENHILLS_STORAGE['swipers'][id].onResize(); 871 } 872 873 // Resize slider 874 if ( resize && !jQuery(this).hasClass('sc_slider_height_fixed') ) { 875 var h = 0; 876 if ( jQuery(this).find('.swiper-slide > img').length > 0 ) { 877 jQuery(this).find('.swiper-slide > img').each(function() { 878 "use strict"; 879 if (jQuery(this).height() > h) h = jQuery(this).height(); 880 }); 881 jQuery(this).height(h); 882 } else if ( jQuery(this).find('.swiper-slide').css('backgroundImage')!='none' ) { 883 h = Math.floor(width/16*9); 884 jQuery(this).height(h).find('.swiper-slide').height(h); 885 } 886 } 887 }); 888 889 // Resize slider pagination area 890 jQuery('.sc_slider_pagination_area').each(function() { 891 "use strict";
892 var h = jQuery(this).find('.sc_slider').height(); 893 if (h) { 894 jQuery(this).height(h); 895 jQuery(this).find('.sc_slider_pagination').height(h); 896 jQuery(this).find('.sc_slider_pagination .sc_scroll_vertical').height(h); 897 } 898 }); 899} 900 901// Equal height for items in the row 902function sevenhills_sc_equal_height() { 903 "use strict"; 904 jQuery('[data-equal-height]').each(function() { 905 "use strict"; 906 var eh_wrap = jQuery(this); 907 var eh_items_selector = eh_wrap.data('equal-height'); 908 if (eh_items_selector) { 909 var max_h = 0; 910 var items = []; 911 var row_y = 0; 912 var i=0; 913 eh_wrap.find(eh_items_selector).each(function() { 914 "use strict"; 915 var el = jQuery(this); 916 el.height('auto'); 917 var el_height = el.height(); 918 var el_offset = el.offset().top; 919 if (row_y == 0) row_y = el_offset; 920 if (row_y < el_offset) { 921 if (items.length > 0) { 922 if (max_h > 0) { 923 for (i=0; i<items.length; i++) 924 items[i].height(max_h); 925 } 926 items = []; 927 max_h = 0; 928 } 929 row_y = el_offset; 930 } 931 if (el_height > max_h) max_h = el_height; 932 items.push(el); 933 }); 934 if (items.length > 0 && max_h > 0) { 935 for (i=0; i<items.length; i++) 936 items[i].height(max_h); 937 } 938 } 939 }); 940} 941 942 943// Skills init 944function sevenhills_sc_init_skills(container) { 945 "use strict"; 946 if (arguments.length==0) var container = jQuery('body'); 947 var scrollPosition = jQuery(window).scrollTop() + jQuery(window).height(); 948 949 container.find('.sc_skills_item:not(.inited)').each(function () { 950 "use strict"; 951 var skillsItem = jQuery(this); 952 var scrollSkills = skillsItem.offset().top; 953 if (scrollPosition > scrollSkills) { 954 skillsItem.addClass('inited'); 955 var skills = skillsItem.parents('.sc_skills').eq(0); 956 var type = skills.data('type'); 957 var total = (type=='pie' && skills.hasClass('sc_skills_compact_on')) ? skillsItem.find('.sc_skills_data .pie') : skillsItem.find('.sc_skills_total').eq(0); 958 var start = parseInt(total.data('start')); 959 var stop = parseInt(total.data('stop')); 960 var maximum = parseInt(total.data('max')); 961 var startPercent = Math.round(start/maximum*100); 962 var stopPercent = Math.round(stop/maximum*100); 963 var ed = total.data('ed'); 964 var duration = parseInt(total.data('duration')); 965 var speed = parseInt(total.data('speed')); 966 var step = parseInt(total.data('step')); 967 if (type == 'bar') { 968 var dir = skills.data('dir'); 969 var count = skillsItem.find('.sc_skills_count').eq(0); 970 if (dir=='horizontal') 971 count.css('width', startPercent + '%').animate({ width: stopPercent + '%' }, duration); 972 else if (dir=='vertical') 973 count.css('height', startPercent + '%').animate({ height: stopPercent + '%' }, duration); 974 sevenhills_sc_animate_skills_counter(start, stop, speed-(dir!='unknown' ? 5 : 0), step, ed, total); 975 } else if (type == 'counter') { 976 sevenhills_sc_animate_skills_counter(start, stop, speed - 5, step, ed, total); 977 } else if (type == 'pie') { 978 var steps = parseInt(total.data('steps')); 979 var bg_color = total.data('bg_color'); 980 var border_color = total.data('border_color'); 981 var cutout = parseInt(total.data('cutout')); 982 var easing = total.data('easing'); 983 var options = { 984 segmentShowStroke: true, 985 segmentStrokeColor: border_color, 986 segmentStrokeWidth: 1, 987 percentageInnerCutout : cutout, 988 animationSteps: steps, 989 animationEasing: easing, 990 animateRotate: true, 991 animateScale: false, 992 }; 993 var pieData = []; 994 total.each(function() { 995 "use strict"; 996 var color = jQuery(this).data('color'); 997 var stop = parseInt(jQuery(this).data('stop')); 998 var stopPercent = Math.round(stop/maximum*100); 999 pieData.push({ 1000 value: stopPercent, 1001 color: color 1002 }); 1003 }); 1004 if (total.length == 1) { 1005 sevenhills_sc_animate_skills_counter(start, stop, Math.round(1500/steps), step, ed, total); 1006 pieData.push({ 1007 value: 100-stopPercent, 1008 color: bg_color 1009 }); 1010 } 1011 var canvas = skillsItem.find('canvas'); 1012 canvas.attr({width: skillsItem.width(), height: skillsItem.width()}).css({width: skillsItem.width(), height: skillsItem.height()}); 1013 new Chart(canvas.get(0).getContext("2d")).Doughnut(pieData, options); 1014 } 1015 } 1016 }); 1017} 1018 1019// Skills counter animation 1020function sevenhills_sc_animate_skills_counter(start, stop, speed, step, ed, total) { 1021 "use strict"; 1022 start = Math.min(stop, start + step); 1023 total.text(start+ed); 1024 if (start < stop) { 1025 setTimeout(function () { 1026 sevenhills_sc_animate_skills_counter(start, stop, speed, step, ed, total); 1027 }, speed); 1028 } 1029} 1030 1031// Skills arc init 1032function sevenhills_sc_init_skills_arc(container) { 1033 "use strict"; 1034 if (arguments.length==0) var container = jQuery('body');
1035 container.find('.sc_skills_arc:not(.inited)').each(function () { 1036 var arc = jQuery(this); 1037 arc.addClass('inited'); 1038 var items = arc.find('.sc_skills_data .arc'); 1039 var canvas = arc.find('.sc_skills_arc_canvas').eq(0); 1040 var legend = arc.find('.sc_skills_legend').eq(0); 1041 var w = Math.round(arc.width() - legend.width()); 1042 var c = Math.floor(w/2); 1043 var o = { 1044 random: function(l, u){ 1045 "use strict"; 1046 return Math.floor((Math.random()*(u-l+1))+l); 1047 }, 1048 diagram: function(){ 1049 "use strict"; 1050 var r = Raphael(canvas.attr('id'), w, w), 1051 hover = Math.round(w/2/items.length), 1052 rad = hover, 1053 step = Math.round(((w-20)/2-rad)/items.length), 1054 stroke = Math.round(w/9/items.length), 1055 speed = 400; 1056 1057 1058 r.circle(c, c, Math.round(w/2)).attr({ stroke: 'none', fill: SEVENHILLS_STORAGE['theme_bg_color'] ? SEVENHILLS_STORAGE['theme_bg_color'] : '#ffffff' }); 1059 1060 var title = r.text(c, c, arc.data('caption')).attr({ 1061 font: Math.round(rad*0.75)+'px "'+SEVENHILLS_STORAGE['theme_font']+'"', 1062 fill: SEVENHILLS_STORAGE['theme_color'] ? SEVENHILLS_STORAGE['theme_color'] : '#909090' 1063 }).toFront(); 1064 1065 rad -= Math.round(step/2); 1066 1067 r.customAttributes.arc = function(value, color, rad){ 1068 "use strict"; 1069 var v = 3.6 * value, 1070 alpha = v == 360 ? 359.99 : v, 1071 rand = o.random(91, 240), 1072 a = (rand-alpha) * Math.PI/180, 1073 b = rand * Math.PI/180, 1074 sx = c + rad * Math.cos(b), 1075 sy = c - rad * Math.sin(b), 1076 x = c + rad * Math.cos(a), 1077 y = c - rad * Math.sin(a), 1078 path = [['M', sx, sy], ['A', rad, rad, 0, +(alpha > 180), 1, x, y]]; 1079 return { path: path, stroke: color } 1080 } 1081 1082 items.each(function(i){ 1083 "use strict"; 1084 var t = jQuery(this), 1085 color = t.find('.color').val(), 1086 value = t.find('.percent').val(), 1087 text = t.find('.text').text(); 1088 1089 rad += step; 1090 var z = r.path().attr({ arc: [value, color, rad], 'stroke-width': stroke }); 1091 1092 z.mouseover(function(){ 1093 "use strict"; 1094 this.animate({ 'stroke-width': hover, opacity: .75 }, 1000, 'elastic'); 1095 if (Raphael.type != 'VML') //solves IE problem 1096 this.toFront(); 1097 title.stop().animate({ opacity: 0 }, speed, '>', function(){ 1098 this.attr({ text: (text ? text + '\n' : '') + value + '%' }).animate({ opacity: 1 }, speed, '<'); 1099 }); 1100 }).mouseout(function(){ 1101 "use strict"; 1102 this.stop().animate({ 'stroke-width': stroke, opacity: 1 }, speed*4, 'elastic'); 1103 title.stop().animate({ opacity: 0 }, speed, '>', function(){ 1104 title.attr({ text: arc.data('caption') }).animate({ opacity: 1 }, speed, '<'); 1105 }); 1106 }); 1107 1108 }); 1109 1110 } 1111 } 1112 o.diagram(); 1113 }); 1114} 1115 1116 1117// Countdown update 1118function sevenhills_countdown(dt) { 1119 "use strict"; 1120 var counter = jQuery(this).parent(); 1121 for (var i=3; i<dt.length; i++) { 1122 var v = (dt[i]<10 ? '0' : '') + dt[i]; 1123 counter.find('.sc_countdown_item').eq(i-3).find('.sc_countdown_digits span').addClass('hide'); 1124 for (var ch=v.length-1; ch>=0; ch--) { 1125 counter.find('.sc_countdown_item').eq(i-3).find('.sc_countdown_digits span').eq(ch+(i==3 && v.length<3 ? 1 : 0)).removeClass('hide').text(v.substr(ch, 1)); 1126 } 1127 } 1128} 1129 1130 1131// Contact form handlers 1132function sevenhills_sc_form_validate(form){ 1133 "use strict"; 1134 var url = form.attr('action'); 1135 if (url == '') return false; 1136 form.find('input').removeClass('error_fields_class'); 1137 var error = false; 1138 var form_custom = form.data('formtype')=='form_custom'; 1139 if (!form_custom) { 1140 1141 var rules = [], rule = {}; 1142 1143 if (form.find('[name="username"]').length > 0) { 1144 rule = { 1145 field: "username", 1146 max_length: { value: 60, message: SEVENHILLS_STORAGE['strings']['name_long'] } 1147 }; 1148 if (form.find('[name="username"]').length > 0) 1149 rule['min_length'] = { value: 1, message: SEVENHILLS_STORAGE['strings']['name_empty'] }; 1150 rules.push(rule); 1151 } 1152 1153 if (form.find('[name="email"]').length > 0) { 1154 rule = { 1155 field: "email", 1156 max_length: { value: 60, message: SEVENHILLS_STORAGE['strings']['email_long'] }, 1157 mask: { value: SEVENHILLS_STORAGE['email_mask'], message: SEVENHILLS_STORAGE['strings']['email_not_val
1157id'] } 1158 }; 1159 if (form.find('[name="email"]').length > 0) 1160 rule['min_length'] = { value: 7, message: SEVENHILLS_STORAGE['strings']['email_empty'] }; 1161 rules.push(rule); 1162 } 1163 1164 if (form.find('[name="message"]').length > 0) { 1165 rule = { 1166 field: "message", 1167 max_length: { value: SEVENHILLS_STORAGE['contacts_maxlength'], message: SEVENHILLS_STORAGE['strings']['text_long'] } 1168 }; 1169 if (form.find('[name="message"]').length > 0) 1170 rule['min_length'] = { value: 1, message: SEVENHILLS_STORAGE['strings']['text_empty'] }; 1171 rules.push(rule); 1172 } 1173 1174 error = sevenhills_form_validate(form, { 1175 error_message_show: true, 1176 error_message_time: 4000, 1177 error_message_class: "sc_infobox sc_infobox_style_error", 1178 error_fields_class: "error_fields_class", 1179 exit_after_first_error: false, 1180 rules: rules 1181 }); 1182 } 1183 if (!error && url!='#') { 1184 jQuery.post(url, { 1185 action: "send_form", 1186 nonce: SEVENHILLS_STORAGE['ajax_nonce'], 1187 type: form.data('formtype'), 1188 data: form.serialize() 1189 }).done(function(response) { 1190 "use strict"; 1191 var rez = {}; 1192 try { 1193 rez = JSON.parse(response); 1194 } catch (e) { 1195 rez = { error: SEVENHILLS_STORAGE['ajax_error'] }; 1196 console.log(response); 1197 } 1198 var result = form.find(".result").toggleClass("sc_infobox_style_error", false).toggleClass("sc_infobox_style_success", false); 1199 if (rez.error === '') { 1200 form.get(0).reset(); 1201 result.addClass("sc_infobox_style_success").html(SEVENHILLS_STORAGE['strings']['send_complete']); 1202 var return_url = form.find('input[name="return_url"]'); 1203 if (return_url.length > 0 && return_url.val()!='') { 1204 setTimeout(function() { 1205 "use strict"; 1206 window.location.href = return_url.val(); 1207 }, 3300); 1208 } 1209 } else { 1210 result.addClass("sc_infobox_style_error").html(SEVENHILLS_STORAGE['strings']['send_error'] + ' ' + rez.error); 1211 } 1212 result.fadeIn().delay(3000).fadeOut(); 1213 }); 1214 } 1215 return !error; 1216} 1217 1218 1219 1220// Get players by category 1221function sevenhills_select_players_category(sel) { 1222 var value = sel.find(':selected').data('cat'); 1223 var table = sel.parents('.sc_players_table'); 1224 if (value == 'all') 1225 jQuery(table).find('.sc_table tr:nth-child(n+2)').show(); 1226 else { 1227 jQuery(table).find('.sc_table tr:nth-child(n+2)').hide(); 1228 jQuery(table).find('.sc_table tr').each(function() { 1229 var cat = jQuery(this).data('cat'); 1230 if (cat != null && cat.indexOf(value)!=-1) 1231 jQuery(this).show(); 1232 }); 1233 } 1234} 1235 1236 1237 1238// Display menuitem in the popup 1239function sevenhills_menuitems_show_popup(obj) { 1240 "use strict"; 1241 1242 // First init vars 1243 if (typeof SEVENHILLS_STORAGE['menuitem_load'] == 'undefined') { 1244 SEVENHILLS_STORAGE['menuitem_load'] = false; 1245 SEVENHILLS_STORAGE['menuitems_list'] = []; 1246 1247 // If busy - return 1248 } else if ( SEVENHILLS_STORAGE['menuitem_load'] ) { 1249 return; 1250 } 1251 1252 // Show preloader 1253 jQuery('#page_preloader').data('bg-color', jQuery('#page_preloader').css('background-color')).css({display: 'block', opacity: 0, backgroundColor: 'transparent'}).animate({opacity:0.8}, 300); 1254 1255 // Get items list on first click 1256 if (SEVENHILLS_STORAGE['menuitems_list'].length == 0) { 1257 var menuitems_list_id = obj.parents('.sc_menuitems').attr("id"); 1258 SEVENHILLS_STORAGE['menuitems_list'] = SEVENHILLS_STORAGE['menuitems'][menuitems_list_id].split(","); 1259 } 1260 1261 var menuitem_id = obj.attr('rel'); 1262 1263 SEVENHILLS_STORAGE['menuitem_load'] = true; 1264 1265 jQuery.post(SEVENHILLS_STORAGE['ajax_url'], { 1266 action: 'ajax_menuitem', 1267 nonce: SEVENHILLS_STORAGE['ajax_nonce'], 1268 text: menuitem_id 1269 }).done(function(response) { 1270 "use strict"; 1271 SEVENHILLS_STORAGE['menuitem_load'] = false; 1272 var rez = {}; 1273 try { 1274 rez = JSON.parse(response); 1275 } catch (e) { 1276 rez = { error: SEVENHILLS_STORAGE['ajax_error'] + '<br>' + response }; 1277 } 1278 jQuery('#page_preloader').animate({opacity:0}
1278, 500, function() { jQuery(this).css({display: 'none', backgroundColor: jQuery(this).data('bg-color')}); }); 1279 if (rez.error === '') { 1280 var delay = 0; 1281 // Create popup 1282 if (jQuery('.popup_menuitem').length == 0) { 1283 jQuery('body').append('<div id="overlay"></div><div class="popup_menuitem"></div>'); 1284 jQuery('#overlay').fadeIn(500); 1285 } else { 1286 delay = 500; 1287 jQuery('.popup_menuitem').fadeOut(delay); 1288 } 1289 // Add new content in the popup 1290 setTimeout(function() { 1291 jQuery('.popup_menuitem').html(rez.data); 1292 jQuery('.popup_menuitem .sc_menuitems_wrap').append("<a class='close_menuitem' href='#'><span class='icon-cancel'></span></a>"); 1293 if ( SEVENHILLS_STORAGE['menuitems_list'].length > 1 ) { 1294 var idx = 0; 1295 for (var i=0; i<SEVENHILLS_STORAGE['menuitems_list'].length; i++ ) { 1296 if ( SEVENHILLS_STORAGE['menuitems_list'][i] === menuitem_id ) { 1297 idx = i; 1298 break; 1299 } 1300 } 1301 var prev = (idx - 1 + SEVENHILLS_STORAGE['menuitems_list'].length) % SEVENHILLS_STORAGE['menuitems_list'].length; 1302 var next = (idx + 1) % SEVENHILLS_STORAGE['menuitems_list'].length; 1303 jQuery('.popup_menuitem .sc_menuitems_wrap .sc_menuitem_content').append( 1304 "<a class='prev_menuitem prevnext_menuitem show_popup_menuitem' rel='"+SEVENHILLS_STORAGE['menuitems_list'][prev]+"' href='#'><span class='icon-left'></span></a>" 1305 + "<a class='next_menuitem prevnext_menuitem show_popup_menuitem' rel='"+SEVENHILLS_STORAGE['menuitems_list'][next]+"' href='#'><span class='icon-right'></span></a>" 1306 ); 1307 } 1308 jQuery('.popup_menuitem').fadeIn(500); 1309 }, delay); 1310 } else { 1311 sevenhills_message_warning(SEVENHILLS_STORAGE['strings']['search_error']); 1312 } 1313 }); 1314} 1315 1316// Hide popup with menuitem 1317function sevenhills_menuitems_hide_popup() { 1318 "use strict"; 1319 jQuery('#overlay').fadeOut(); 1320 jQuery('.popup_menuitem').fadeOut(function() { 1321 SEVENHILLS_STORAGE['menuitem_load'] = false; 1322 SEVENHILLS_STORAGE['menuitems_list'] = []; 1323 jQuery('#overlay').remove(); 1324 jQuery(this).remove(); 1325 }); 1326}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.