Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function($) {
- var timer = $.timer(function() {
- modal_ajax.color_box_on_open = function() {
- modal_ajax.color_box_on_complete = function () {
- $('.splash_screen_buttons li').on('click', function() {
- optional.data.button_pressed = 'tab';
- optional.data.button_value = $(this).attr("id");
- $("#colorbox").colorbox.close();
- $("#kiosk").ajaxSubmit(optional);
- });
- };
- $('#colorbox').addClass('full_screen_modal_splash_screen');
- $('html, body').animate({scrollTop: $("#colorbox").offset({top:15}).top}, 1000);
- };
- modal_ajax.color_box_on_closed = function() {
- $('#colorbox').removeClass('full_screen_modal_splash_screen');
- $('.splash_screen_buttons li').unbind();
- };
- modal_ajax.clean_up_yt_embeds = false;
- modal_ajax.data.button_id = "splash_screen_modal";
- modal_ajax.data.button_pressed = 'modal';
- modal_ajax.data.button_value = '';
- modal_ajax.color_box_width = '100%', modal_ajax.color_box_height = '100%';
- $.ajax(modal_ajax);
- });
- timer.set({ time : 5000, autostart : true });
- var button_pressed = 'tab';
- var button_id = '1';
- $(window).keydown(function(event) {// binds enter key to nothing, because we dont want it submitting the form
- if (event.keyCode == 13) {
- event.preventDefault();
- }
- });
- var optional = {
- url : kiosk_obj.ajaxurl,
- type : "POST",
- dataType : 'json',
- data : {
- action : "kiosk_controller",
- },
- beforeSend : function() {
- $('#loadingDiv').show();
- },
- success : function(data) {
- $('#loadingDiv').hide();
- $('.kiosk_outter_wrapper').empty();
- $('.kiosk_outter_wrapper').html(data.results);
- re_init();
- },
- };
- var color_box_width, color_box_height = 'Auto';
- var modal_ajax = {
- // Defaults. We need to be able to change parts of the object on the fly;
- color_box_on_open: function(){},
- color_box_on_closed: function(){},
- color_box_on_complete: function(){},
- color_box_width:'Auto',
- color_box_height:'Auto',
- clean_up_yt_embeds: true,
- url : kiosk_obj.ajaxurl,
- type : "POST",
- dataType : 'json',
- data : {
- action : "modal_controller",
- },
- success : function(data) {
- $.colorbox({
- html : data.results,
- width:this.color_box_width,
- height:this.color_box_height,
- onComplete : function() {
- if(modal_ajax.clean_up_yt_embeds) {
- optimizeYouTubeEmbeds();
- }
- modal_ajax.color_box_on_complete();
- },
- onOpen : function() {
- timer.reset();
- timer.pause();
- modal_ajax.color_box_on_open();
- },
- onClosed : function() {
- timer.play();
- modal_ajax.color_box_on_closed();
- modal_ajax.color_box_on_open = function(){};
- modal_ajax.color_box_on_closed = function(){};
- modal_ajax.color_box_on_complete = function(){};
- modal_ajax.color_box_width='auto';
- modal_ajax.color_box_height = 'auto';
- modal_ajax.clean_up_yt_embeds = true;
- $("ul.exercise_modal_menu li.menu_button").unbind();
- },
- onCleanup : function() {
- },
- });
- },
- };
- function color_box_binds() {// dynamically generated content, need to re-bind every call.
- $('li.work_out_list.exercise_item').on('click', function(e) {
- modal_ajax.data.button_id = 'exercise_item_modal';
- modal_ajax.data.button_pressed = 'modal';
- modal_ajax.data.button_value = $(this).attr("id");
- modal_ajax.color_box_width, modal_ajax.color_box_height = 'auto';
- modal_ajax.color_box_on_open = function() {
- };
- modal_ajax.color_box_on_closed = function() {
- };
- $.when($.ajax(modal_ajax)).then(function(data, textStatus, jqXHR) {
- optimizeYouTubeEmbeds();
- $('#modal_slider').bjqs({
- 'height' : 400,
- 'width' : 400,
- 'showcontrols' : true, // show next and prev controls
- 'showmarkers' : false, // Show individual slide markers
- 'responsive' : true
- });
- var has_not_killed = true;
- $("ul.exercise_modal_menu li.menu_button").on('click', function() {
- $("ul.exercise_modal_menu li.menu_button").each(function() {
- $(this).removeClass('active');
- });
- $(this).addClass('active');
- // since we want a video to stop playing when the user leaves the tab, we check which tab we're in. If it's the video, we need to reset the
- // variable so when the video tab is left, it will effectively kill and "refresh" the video to put it back in its initial state.
- // since there's no need to re-"kill" it every time a non-video tab is clicked, we just do it once and then toggle the has_not_killed variable.
- var toggle_which = $(this).attr('id');
- if(toggle_which=='video') {
- has_not_killed = true;
- }
- // Since we're using skipsers embed to make youtube video loading faster, which also insists on autoplaying them(so that when user clicks thumbnail
- // it will load AND play instead of just load the iframe in.
- // we need to strip the autoplay out of the url, since if we don't, after it re-injects the url into the iframe it autoplays it again
- // which is behavior we DONT want since the user wont be in the tab.
- if((toggle_which!='video') && (has_not_killed==true)) {
- has_not_killed = false;
- var snah = $(".exercise_modal_video:eq(0) iframe");
- var url = $(snah).attr("src");
- if (typeof url!='undefined') {
- var url = url.replace('?autoplay=1', '?autoplay=0');
- }
- $(snah).attr("src","");
- $(snah).attr("src", url);
- }
- $('.exercise_modal_media_wrapper').children('#media_box').each(function() {
- $(this).removeClass('show');
- $(this).addClass("hide");
- });
- $('.exercise_modal_' + toggle_which).removeClass('hide');
- $('.exercise_modal_' + toggle_which).fadeIn();
- });
- });
- });
- $(".exericse_full_view_images").colorbox({
- rel : 'exericse_full_view_images',
- transition : "none",
- width : "75%",
- height : "75%",
- onOpen : function() {
- $("#colorbox").addClass("exercise_full_view_images_modal");
- },
- onClosed : function() {
- $("#colorbox").removeClass("exercise_full_view_images_modal");
- },
- });
- }
- function header_modal_binds() {//Only need to bind once, since this portion is never re-loaded.
- $('.header button').on('click', function(e) {
- modal_ajax.data.button_id = $(this).attr("id");
- modal_ajax.data.button_pressed = $(this).attr("name");
- modal_ajax.data.button_value = $(this).attr("value");
- if (modal_ajax.data.button_id == 'feed_back_form') {
- $.colorbox({
- inline : true,
- href : "#gf_contact_form",
- height: 'auto',
- width: 'auto',
- onOpen : function() {
- timer.reset();
- timer.pause();
- $("#colorbox").addClass("contact_form_modal");
- },
- onClosed : function() {
- $("#colorbox").removeClass("contact_form_modal");
- timer.play();
- }
- });
- }
- if (modal_ajax.data.button_pressed == 'view_swap') {
- optional.data.button_pressed = $(this).attr("name");
- optional.data.button_value = $(this).attr("value");
- optional.data.button_id = $(this).attr("id");
- toggle_search_mode_button();
- $("#kiosk").ajaxSubmit(optional);
- }
- if ((modal_ajax.data.button_id != 'feed_back_form') && (modal_ajax.data.button_pressed != 'view_swap')) {
- if(modal_ajax.data.button_id=='how_it_works') {
- modal_ajax.color_box_width = ($(window).width()), modal_ajax.color_box_height = ($(window).height());
- modal_ajax.color_box_on_complete = function() {
- $('li.close_button').on('click', function(e) {
- $("#colorbox").colorbox.close();
- });
- };
- modal_ajax.color_box_on_open = function() {
- $('#colorbox').addClass('full_screen_modal');
- $('html, body').animate({scrollTop: $("#colorbox").offset({top:15}).top}, 1000);
- };
- modal_ajax.color_box_on_closed = function() {
- $('#colorbox').removeClass('full_screen_modal');
- };
- }
- $.ajax(modal_ajax);
- }
- });
- }
- function toggle_search_mode_button () {
- $(".header_search_button_wrapper").find('button').each(function() {
- $(this).toggleClass("show hide").fadeIn('200');
- });
- }
- function re_init() {
- color_box_binds();
- timer.reset(true);
- $('#kiosk button').on('click', function(e) {
- e.preventDefault();
- optional.data.button_pressed = $(this).attr("name")
- optional.data.button_value = $(this).attr("value")
- optional.data.button_id = $(this).attr("id")
- if (optional.data.button_value == 'Full') {
- $('.side_bar').fadeOut();
- $('.content_layer_1').fadeOut();
- $('.single_post_view').fadeOut();
- }
- if (optional.data.button_value == 'Short') {
- //$('.content_layer_1').fadeIn();
- //$('.side_bar').fadeIn();
- }
- if(optional.data.button_pressed == 'view_swap') {
- toggle_search_mode_button();
- }
- if (optional.data.button_pressed == 'Print') {
- var onPrintFinished = function(printed) {
- $("#print_area").empty();
- }
- modal_ajax.data.button_id = $(this).attr("id");
- modal_ajax.data.button_pressed = 'print';
- modal_ajax.data.button_value = $(this).attr("value");
- var temp = modal_ajax.success;
- // we're temporarily changing the modal callback function.
- modal_ajax.success = function(data) {
- $('#print_area').append(data.results);
- setTimeout(deferred_print, 500);
- };
- function deferred_print() {
- onPrintFinished(window.print());
- }
- $.ajax(modal_ajax)
- modal_ajax.success = temp;
- // now we're changing it back.
- }
- if (optional.data.button_pressed != 'Print') {
- $("#kiosk").ajaxSubmit(optional);
- }
- });
- }
- re_init();
- header_modal_binds();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement