Пример #1
0
function spider_calendar_big_front_end($id, $theme, $default, $select, $widget = 0)
{
    require_once "front_end/frontend_functions.php";
    ob_start();
    global $many_sp_calendar;
    global $wpdb;
    if ($widget === 1) {
        $themes = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'spidercalendar_widget_theme WHERE id=%d', $theme));
    } else {
        $themes = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'spidercalendar_theme WHERE id=%d', $theme));
    }
    $cal_width = $themes->width;
    ?>
  <input type="hidden" id="cal_width<?php 
    echo $many_sp_calendar;
    ?>
" value="<?php 
    echo $cal_width;
    ?>
" /> 
  <div id='bigcalendar<?php 
    echo $many_sp_calendar;
    ?>
'></div>
  <script> 
    var tb_pathToImage = "<?php 
    echo plugins_url('images/loadingAnimation.gif', __FILE__);
    ?>
";
    var tb_closeImage = "<?php 
    echo plugins_url('images/tb-close.png', __FILE__);
    ?>
"
	var randi;
    if (typeof showbigcalendar != 'function') {	
      function showbigcalendar(id, calendarlink, randi,widget) {
        var xmlHttp;
        try {
          xmlHttp = new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
        }
        catch (e) {
          try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
          }
          catch (e) {
            try {
              xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
              alert("No AJAX!?");
              return false;
            }
          }
        }
        xmlHttp.onreadystatechange = function () {
          if (xmlHttp.readyState == 4) {
            // document.getElementById(id).innerHTML = xmlHttp.responseText;
            jQuery('#' + id).html(xmlHttp.responseText);
          }
        }
        xmlHttp.open("GET", calendarlink, false);
        xmlHttp.send();
	 jQuery(document).ready(function (){
	  jQuery('#views_select').toggle(function () {	
		jQuery('#drop_down_views').stop(true, true).delay(200).slideDown(500);
		jQuery('#views_select .arrow-down').addClass("show_arrow");
		jQuery('#views_select .arrow-right').removeClass("show_arrow");
	  }, function () { 
		jQuery('#drop_down_views').stop(true, true).slideUp(500);
		jQuery('#views_select .arrow-down').removeClass("show_arrow");
		jQuery('#views_select .arrow-right').addClass("show_arrow");		
	  });
	});
if(widget!=1)
{
  if(jQuery(window).width() > 640)
  {
	jQuery('drop_down_views').hide();
		var parent_width = document.getElementById('bigcalendar'+randi).parentNode.clientWidth;
		var calwidth=  document.getElementById('cal_width'+randi).value;
		var responsive_width = (calwidth)/parent_width*100;
		document.getElementById('afterbig'+randi).setAttribute('style','width:'+responsive_width+'%;');
		jQuery('pop_table').css('height','100%');
  }
 else if(jQuery('#bigcalendar'+randi).parent().width() > 640)
  {
	jQuery('drop_down_views').hide();
		var parent_width = document.getElementById('bigcalendar'+randi).parentNode.clientWidth;
		var calwidth=  document.getElementById('cal_width'+randi).value;
		var responsive_width = (calwidth)/parent_width*100;
		document.getElementById('afterbig'+randi).setAttribute('style','width:'+responsive_width+'%;');
		jQuery('pop_table').css('height','100%');
  }
	else document.getElementById('afterbig'+randi).setAttribute('style','width:100%;');	
}
        var thickDims, tbWidth, tbHeight;
        jQuery(document).ready(function ($) {			
		 setInterval(function(){	
				if(jQuery("body").hasClass("modal-open")) jQuery("html").addClass("thickbox_open");
				else jQuery("html").removeClass("thickbox_open");
			},500);			
          thickDims = function () {		
             var tbWindow = jQuery('#TB_window'), H = jQuery(window).height(), W = jQuery(window).width(), w, h;
            if (tbWidth) {
              if (tbWidth < (W - 90)) w = tbWidth; else  w = W - 200;
            } else w = W - 200;
            if (tbHeight) {
              if (tbHeight < (H - 90)) h = tbHeight; else  h = H - 200;
            } else h = H - 200;			
            if (tbWindow.size()) {
              tbWindow.width(w).height(h);
              jQuery('#TB_iframeContent').width(w).height(h - 27);
              tbWindow.css({'margin-left':'-' + parseInt((w / 2), 10) + 'px'});
              if (typeof document.body.style.maxWidth != 'undefined')
                tbWindow.css({'top':(H - h) / 2, 'margin-top':'0'});
            }
			 if(jQuery(window).width() < 768 ){
			  var tb_left = parseInt((w / 2), 10) + 20;		  
				jQuery('#TB_window').css({"left": tb_left+ "px", "width": "90%", "margin-top": "-13%","height": "100%"})
				jQuery('#TB_window iframe').css({'height':'100%', 'width':'100%'});
			}
			 else jQuery('#TB_window').css('left','50%');
		if (typeof popup_width_from_src != "undefined") {
				popup_width_from_src=jQuery('.thickbox-previewbigcalendar'+randi).attr('href').indexOf('tbWidth=');
				str=jQuery('.thickbox-previewbigcalendar'+randi).attr('href').substr(popup_width_from_src+8,150)
				find_amp=str.indexOf('&');
				width_orig=str.substr(0,find_amp);				
				find_eq=str.indexOf('=');
				height_orig=str.substr(find_eq+1,5);
			jQuery('#TB_window').css({'max-width':width_orig+'px', 'max-height':height_orig+'px'});
			jQuery('#TB_window iframe').css('max-width',width_orig+'px');
			}	
          };
          thickDims();
          jQuery(window).resize(function () {
            thickDims();			
		  });		  
          jQuery('a.thickbox-preview' + id).click(function () {
            tb_click.call(this);
            var alink = jQuery(this).parents('.available-theme').find('.activatelink'), link = '', href = jQuery(this).attr('href'), url, text;
            var reg_with = new RegExp(xx_cal_xx + "tbWidth=[0-9]+");	
            if (tbWidth = href.match(reg_with))
              tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10);
            else
              tbWidth = jQuery(window).width() - 90;			  
            var reg_heght = new RegExp(xx_cal_xx + "tbHeight=[0-9]+");
            if (tbHeight = href.match(reg_heght))
              tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10);
            else
              tbHeight = jQuery(window).height() - 60;
            jQuery('#TB_ajaxWindowTitle').css({'float':'right'}).html(link);			
            thickDims();			
            return false;			
          });
		  
        });
      }
    }	
    document.onkeydown = function (evt) {
      evt = evt || window.event;
      if (evt.keyCode == 27) {
        document.getElementById('sbox-window').close();
      }
    };
    <?php 
    global $wpdb;
    $calendarr = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "spidercalendar_calendar WHERE id='%d'", $id));
    $year = $calendarr->def_year ? $calendarr->def_year : date("Y");
    $month = $calendarr->def_month ? $calendarr->def_month : date("m");
    $date = $year . '-' . $month;
    if ($default == 'day') {
        $date .= '-' . date('d');
    }
    if ($default == 'week') {
        $date .= '-' . date('d');
        $d = new DateTime($date);
        $weekday = $d->format('w');
        $diff = $weekday == 0 ? 6 : $weekday - 1;
        if ($widget === 1) {
            $theme_row = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "spidercalendar_widget_theme WHERE id='%d'", $theme));
        } else {
            $theme_row = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "spidercalendar_theme WHERE id='%d'", $theme));
        }
        $weekstart = $theme_row->week_start_day;
        if ($weekstart == "su") {
            $diff = $diff + 1;
        }
        $d->modify("-{$diff} day");
        $d->modify("-1 day");
        $prev_date = $d->format('Y-m-d');
        $prev_month = add_0((int) substr($prev_date, 5, 2) - 1);
        $this_month = add_0((int) substr($prev_date, 5, 2));
        $next_month = add_0((int) substr($prev_date, 5, 2) + 1);
        if ($next_month == '13') {
            $next_month = '01';
        }
        if ($prev_month == '00') {
            $prev_month = '12';
        }
    }
    if ($widget === 1) {
        $default .= '_widget';
    } else {
    }
    ?>
 showbigcalendar('bigcalendar<?php 
    echo $many_sp_calendar;
    ?>
', '<?php 
    echo add_query_arg(array('action' => 'spiderbigcalendar_' . $default, 'theme_id' => $theme, 'calendar' => $id, 'select' => $select, 'date' => $date, 'months' => $default == 'week' || $default == 'week_widget' ? $prev_month . ',' . $this_month . ',' . $next_month : '', 'many_sp_calendar' => $many_sp_calendar, 'cur_page_url' => urlencode(current_page_url_sc()), 'widget' => $widget, 'rand' => $many_sp_calendar), admin_url('admin-ajax.php'));
    ?>
','<?php 
    echo $many_sp_calendar;
    ?>
','<?php 
    echo $widget;
    ?>
');</script>
<style>
html.thickbox_open{
	overflow: hidden;
}
#TB_window iframe{
	margin-left: 0;
	margin-top: 0;
	padding-left: 0;
	padding-top: 0;
}

#TB_iframeContent{
	height: 100% !important;
	width: 100%;
}
#TB_window{
	z-index: 1000000;
	color: #dfdfdf;
	top: 100px !important;
}
#TB_title{
	background: #222;
}
.screen-reader-text,
#views_select .arrow-down,
#views_select .arrow-right{
	display: none;
}
#afterbig<?php 
    echo $many_sp_calendar;
    ?>
 li{
	list-style: none;
}
#bigcalendar<?php 
    echo $many_sp_calendar;
    ?>
 p{
	margin: 0;
	padding: 0;
}

#bigcalendar<?php 
    echo $many_sp_calendar;
    ?>
 table{
	table-layout: auto;
}

.general_table a,
.last_table a,
.week_list a,
.day_ev a{
	border: 0;
}

.show_arrow{
	display: inline-block !important;
}
@media screen and (max-width: 768px) {
	#bigcalendar<?php 
    echo $many_sp_calendar;
    ?>
 #cal_event p:not(.ev_name){
		 display: block; /* Fallback for non-webkit */
		 display: -webkit-box;
		 max-width: 400px;
		 height: 32px; /* Fallback for non-webkit */
		 margin: 0 auto;
		 font-size: 13px;
		 line-height: 15px;
		 -webkit-line-clamp: 2;
		 -webkit-box-orient: vertical;
		 overflow: hidden;
		 text-overflow: ellipsis;
	}
	div#afterbig<?php 
    echo $many_sp_calendar;
    ?>
{
		width: 100% !important;
		margin: 0;
	}
	#bigcalendar<?php 
    echo $many_sp_calendar;
    ?>
 .cala_day{
		max-width: 37px;
	}
}
</style>
  <?php 
    $many_sp_calendar++;
    $calendar = ob_get_contents();
    ob_end_clean();
    return $calendar;
}
Пример #2
0
function Spider_calendar_big_front_end($id, $theme, $wiidget = 0)
{
    ob_start();
    global $many_sp_calendar;
    ?>
	<div id='bigcalendar<?php 
    echo $many_sp_calendar;
    ?>
'></div>

<script>
var tb_pathToImage = "<?php 
    echo plugins_url('images/loadingAnimation.gif', __FILE__);
    ?>
";
var tb_closeImage = "<?php 
    echo plugins_url('images/tb-close.png', __FILE__);
    ?>
"
if(typeof showbigcalendar != 'function')
 {
function showbigcalendar(id,calendarlink)
{
var xmlHttp;
	try{	
		xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
	}
	catch (e){
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
		}
		catch (e){
		    try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				alert("No AJAX!?");
				return false;
			}
		}
	}
xmlHttp.onreadystatechange=function(){
	if(xmlHttp.readyState==4){
		document.getElementById(id).innerHTML=xmlHttp.responseText;
	}
}
xmlHttp.open("GET",calendarlink,false);
xmlHttp.send();
	var thickDims, tbWidth, tbHeight;
jQuery(document).ready(function($) {
        thickDims = function() {
                var tbWindow = $('#TB_window'), H = $(window).height(), W = $(window).width(), w, h;
				if(tbWidth){if(tbWidth < (W - 90)) w=tbWidth; else  w =  W - 200;} else w = W - 200;
				if(tbHeight){if(tbHeight < (H - 90)) h=tbHeight; else  h =  H - 200;} else h = H - 200;  
                if ( tbWindow.size() ) {
                        tbWindow.width(w).height(h);
                        $('#TB_iframeContent').width(w).height(h - 27);
                        tbWindow.css({'margin-left': '-' + parseInt((w / 2),10) + 'px'});
                        if ( typeof document.body.style.maxWidth != 'undefined' )
                                tbWindow.css({'top':(H-h)/2,'margin-top':'0'});
                }
        };
        thickDims();		
        $(window).resize( function() { thickDims() } );
        $('a.thickbox-preview'+id).click( function() {
                tb_click.call(this);
                var alink = $(this).parents('.available-theme').find('.activatelink'), link = '', href = $(this).attr('href'), url, text;
                var reg_with=new RegExp(xx_cal_xx+"tbWidth=[0-9]+");
				if ( tbWidth = href.match(reg_with) )
                        tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10);
                else
                        tbWidth = $(window).width() - 90;
				var reg_heght=new RegExp(xx_cal_xx+"tbHeight=[0-9]+");
                if ( tbHeight = href.match(reg_heght) )
                        tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10);
                else
                        tbHeight = $(window).height() - 60;
                if ( alink.length ) {
                        url = alink.attr('href') || '';
                        text = alink.attr('title') || '';
                        link = '&nbsp; <a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>';
                } else {
                        text = $(this).attr('title') || '';
                        link = '&nbsp; <span class="tb-theme-preview-link">' + text + '</span>';
                }
                $('#TB_title').css({'background-color':'#222','color':'#dfdfdf'});
                $('#TB_closeAjaxWindow').css({'float':'left'});
                $('#TB_ajaxWindowTitle').css({'float':'right'}).html(link);
                $('#TB_iframeContent').width('100%');
                thickDims();
                return false;
        } );
});  
}
 }
 document.onkeydown = function(evt) {
    evt = evt || window.event;
    if (evt.keyCode == 27) {     
		document.getElementById('sbox-window').close();		
    }
}; 
<?php 
    global $wpdb;
    $calendarr = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "spidercalendar_calendar WHERE id=%d", $id));
    if ($calendarr->start_month) {
        $date = substr($calendarr->start_month, 0, 7);
    } else {
        $date = date("Y") . '-' . date("m");
    }
    ?>
 showbigcalendar( 'bigcalendar<?php 
    echo $many_sp_calendar;
    ?>
','<?php 
    echo admin_url('admin-ajax.php?action=spiderbigcalendar') . '\'+xx_cal_xx+\'theme_id=' . $theme . '\'+xx_cal_xx+\'calendar=' . $id . '\'+xx_cal_xx+\'date=' . $date . '\'+xx_cal_xx+\'many_sp_calendar=' . $many_sp_calendar;
    echo '\'+xx_cal_xx+\'cur_page_url=' . urlencode(current_page_url_sc());
    if ($wiidget) {
        echo '\'+xx_cal_xx+\'widget=' . $wiidget;
    }
    ?>
')</script>
<?php 
    $many_sp_calendar++;
    $calendar = ob_get_contents();
    ob_end_clean();
    return $calendar;
}