/*
https://habr.com/ru/post/37595/
*/
/*
javascript:((function(){
if(jQuery.fn.jquery != '3.2.1'){
window.jQuery="loading";
var a=document.createElement("script");
a.type="text/javascript";
a.src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";
a.onload=function(){console.log("jQuery "+jQuery.fn.jquery+" loaded successfully."); jQuery.noConflict();};
a.onerror=function(){delete jQuery;alert("Error while loading jQuery!")};
document.getElementsByTagName("head")[0].appendChild(a);
}
})());
*/
lang='ru';
$(window).on("resize",function(){
/*
w_top = ($("body").outerHeight()-$("#muz_widget").outerHeight())/2+$("body").scrollTop();
if(w_top<50) w_top=60;
$('#muz_widget').css({
"top" : w_top + "px",
"left" : ($("body").outerWidth()-$("#muz_widget").outerWidth())/2+$("body").scrollLeft() + "px"
});
$('#widget_curtain').css({
width: $("body").outerWidth(),
height: $("body").outerHeight()
}); */
});
$("head").append(' ');
function close_widget(){
$("#widget_curtain").remove();
$("#muz_widget").remove();
}
var muz_tickets = {
jsonp:function (uri) {
return new Promise(function(resolve, reject) {
var id = '_' + Math.round(10000 * Math.random());
var callbackName = 'jsonp_callback_' + id;
window[callbackName] = function(data) {
delete window[callbackName];
var ele = document.getElementById(id);
ele.parentNode.removeChild(ele);
resolve(data);
}
var src = uri + '&callback=' + callbackName;
var script = document.createElement('script');
script.src = src;
script.id = id;
script.addEventListener('error', reject);
(document.getElementsByTagName('head')[0] || document.body || document.documentElement).appendChild(script)
});
},
declOfNum:function(n, text_forms) {
n = Math.abs(n) % 100; var n1 = n % 10;
if (n > 10 && n < 20) { return text_forms[2]; }
if (n1 > 1 && n1 < 5) { return text_forms[1]; }
if (n1 == 1) { return text_forms[0]; }
return text_forms[2];
},
get_spec_scheme:function (func_parameters){
ym(51759599,'reachGoal','buy_button');
id_spec=func_parameters['id_spec'];
if(func_parameters['promocode'] !== undefined){lang=func_parameters['lang'];}else{lang='ru';}
if(func_parameters['e'] !== undefined){
event=func_parameters['e'];
event.preventDefault();
}
if(func_parameters['promocode'] !== undefined) promocode=func_parameters['promocode'];
else promocode='';
var config=[];
config['ru']=[];
config['en']=[];
config['ru']['place1']='место';
config['ru']['place2']='места';
config['ru']['place3']='мест';
config['ru']['in_basket']='В корзине';
config['ru']['rub']='₽';
config['ru']['for']='на';
config['ru']['sel_places']='Выделенные места';
config['ru']['symbols']='Условные обозначения';
config['ru']['sold_pl']='Проданные места';
config['ru']['lv']='место с ограниченной видимостью';
config['ru']['Price']='Цена';
config['ru']['Place']='Место';
config['ru']['Box']='Ложа';
config['ru']['Row']='Ряд';
config['ru']['applied_promocode']='Применен промокод';
config['ru']['promocode']='Помокод';
config['ru']['not_use']=' не применим ';
config['ru']['no_tickets_info']='
Извините, в настоящее время на этот спектакль билетов на сайте в продаже нет. Вы можете приобрести билеты на этот спектакль за 1 час до начала спектакля в кассе театра по адресу: Санкт-Петербург, ул.Итальянская, д.13
';
config['en']['place1']='place';
config['en']['place2']='place';
config['en']['place3']='place';
config['en']['in_basket']='in the basket';
config['en']['rub']='₽';
config['en']['for']='for';
config['en']['sel_places']='Selected places';
config['en']['symbols']='Symbols';
config['en']['sold_pl']='Sold places';
config['en']['lv']='Limited view seat';
config['en']['Price']='Price';
config['en']['Place']='Place';
config['en']['Box']='Box';
config['en']['Row']='Row';
config['en']['applied_promocode']='Promo code applied ';
config['en']['promocode']='Promo code ';
config['en']['not_use']='not applicable ';
config['en']['no_tickets_info']='Unfortunately tickets for this performance are not currently on sale on the website.
';
var colors=['peru','dark_red','lime','dark_blue','turquoise','orange','light_green','olive','green','purple','pink','blue','red','FF00CC', 'c17a2b8', 'Aquamarine', 'teal', 'OrangeRed', 'Goldenrod', 'SandyBrown', 'Plum' ];
var price_to_color = new Array();
var $widget_curtain = $('
').appendTo('body');
$widget_curtain.prop('id', 'widget_curtain');
/* $widget_curtain.css({
'position':'absolute',
'height':$("body").outerHeight(),
'width':$("body").outerWidth(),
'opacity':'0.7',
'z-index':'10000',
'backgroundColor':'#000000',
'top':'0px',
'left':'0px'
}); */
/* $widget_curtain.css({
'background':' rgba(0, 0, 0, 0.3)',
'height':' 100%',
'top':' 0',
'left':' 0',
'bottom':' 0',
'right':' 0',
'position':' absolute',
'width':' 100%',
'z-index':' 9999999',
'overflow':' scroll'
});
*/
var $muz_widget = $('
').appendTo('#widget_curtain');
$muz_widget.prop('id', 'muz_widget');
/* w_top = ($(window).outerHeight()-$("#muz_widget").outerHeight())/2+$(window).scrollTop();
if(w_top<50) w_top=60;
$muz_widget.css({
"top" : w_top + "px",
"left" : ($(window).outerWidth()-$("#muz_widget").outerWidth())/2+$(window).scrollLeft() + "px"
});
*/
var $close_widget = $('
').appendTo('#muz_widget');
$close_widget.prop('id', 'close_widget');
var $close_widget_img = $(' ').appendTo('#close_widget');
$close_widget_img.prop('class', 'close_widget_img');
$close_widget_img.prop('align', 'right');
$close_widget_img.prop('height', '35');
$close_widget_img.prop('width', '35');
$close_widget_img.prop('style', 'padding:5px;');
$close_widget_img.prop('src', 'https://tickets.muzcomedy.ru/widget/images/close-icon.png');
var $spec_info_container = $('
').appendTo('#muz_widget');
$spec_info_container.prop('id', 'spec_info_container');
var $widget_basket_container = $('
').appendTo('#muz_widget');
$widget_basket_container.prop('id', 'widget_basket_container');
$widget_basket_container.prop('align', 'center');
$widget_basket_container.prop('style', 'margin:5px;');
var $widget_container = $('
').appendTo('#muz_widget');
$widget_container.prop('id', 'widget_container');
var $price_filter_title = $('
').appendTo('#muz_widget');
$price_filter_title.prop('id', 'price_filter_title');
var $price_filter = $('
').appendTo('#muz_widget');
$price_filter.prop('id', 'price_filter');
/*https://tickets.muzcomedy.ru/widget/getPerformanceFreeSits.php?id_spec=1809
https://tickets.muzcomedy.ru/widget/GetHallInfo.php?id_spec=14*/
color_to_count=[];
$.getJSON('https://tickets.muzcomedy.ru/widget/getPerformanceFreeSits.php', {
id_spec: id_spec,
format: "json",
promocode: promocode,
lang: lang
}).done(function(data){
spec_data = data;
id_sch_pl=spec_data.data.spec_info.id_scheme_place;
var $date = $('
').appendTo('#spec_info_container');
$date.prop('class', 'spec_date');
$date.html(spec_data.data.spec_info.spec_date_str);
var $spec_name = $('
').appendTo('#spec_info_container');
$spec_name.prop('class', 'spec_name');
$spec_name.html(spec_data.data.spec_info.spec_name);
var $hall_name = $('
').appendTo('#spec_info_container');
$hall_name.prop('class', 'hall_name');
$hall_name.html(spec_data.data.spec_info.hall_name);
var $typeshow = $('
').appendTo('#spec_info_container');
$typeshow.prop('class', 'typeshow');
$typeshow.html(spec_data.data.spec_info.typeshow);
if(spec_data.data.spec_info.promocode !== undefined && spec_data.data.spec_info.promocode !==''){
var $typeshow = $('
').appendTo('#spec_info_container');
$typeshow.prop('class', 'promocode_cont');
if(spec_data.data.spec_info.apply_promocode==1){
$typeshow.html(config[lang]['applied_promocode']+':'+promocode+' ');
}else{
$typeshow.html(config[lang]['promocode']+' '+promocode+' '+config[lang]['not_use']);
}
}
/*var $to_basket = $('
').appendTo('#spec_info_container');
$to_basket.prop('align', 'center');
var $to_basket_button = $(' ').appendTo($to_basket);
$to_basket_button.prop('class', 'to_basket_button');
$to_basket_button.text('Положить в корзину');
$to_basket_button.prop('style', 'background-color:#fff006; border:1px solid #e8e505; border-radius:20px; padding:5px 15px; cursor:pointer; color:#054f80; margin: 10px 0px 2px 0px;');
*/
GetBasket_promocode_url='';
if(promocode!='') GetBasket_promocode_url='&promocode='+promocode;
muz_tickets.jsonp('https://tickets.muzcomedy.ru/widget/GetBasket.js?format=json'+GetBasket_promocode_url).then(function(data){
if(data.data.basket_info.t_cnt>0){
$('#widget_basket_container').html(' '+config[lang]['in_basket']+' '+data.data.basket_info.t_cnt+' '+muz_tickets.declOfNum(parseInt(data.data.basket_info.t_cnt), [config[lang]['place1'], config[lang]['place2'], config[lang]['place3']])+', '+config[lang]['for']+' '+((data.data.basket_info.all_sum !== undefined && data.data.basket_info.all_sum > data.data.basket_info.sum)?' '+data.data.basket_info.all_sum+' ':'')+data.data.basket_info.sum+' '+config[lang]['rub']+' '+data.data.basket_info.button_inf);
}else{
$('#widget_basket_container').html('');
}
});
//arr=spec_data.data.tickets;
//console.log(spec_data.data.tickets);
//if(arr.lenght<=0){
if(typeof(spec_data.data.tickets) === "undefined"){
$('#widget_container').html(config[lang]['no_tickets_info']);
}else{
$.getJSON('https://tickets.muzcomedy.ru/widget/GetHallInfo.php', {
id_sch_pl: id_sch_pl,
format: "json",
lang: lang
}).done(function(data){
hall_data=data;
var pl_arr=[];
$.each(hall_data.data[id_sch_pl].places, function( i, item2 ) {
pl_arr[item2.sort]=item2;
});
PLACES='';
red_color_counter=1;
pl_arr.forEach(function(item) {
color='gray';
if(typeof(spec_data.data.tickets[item.id_place]) === "undefined"){
}else{
t_price=spec_data.data.tickets[item.id_place].prices[1].price;
if(promocode!=''){
if(spec_data.data.tickets[item.id_place].prices[6] !== undefined && spec_data.data.tickets[item.id_place].prices[6].price > 0){
t_price=spec_data.data.tickets[item.id_place].prices[6].price;
}
}
//color_to_count[t_price]=parseInt(color_to_count[t_price])+1;
find=false;
len=0;
for(key in price_to_color){
if(t_price == key){
find=true;
break;
}
len=parseInt(len)+1;
}
if(find){// цена есть в массиве
color=price_to_color[t_price];
color_to_count[t_price]=parseInt(color_to_count[t_price]) + 1;
}else{
color_to_count[t_price]=1;
if(len>=21){
color='red'+red_color_counter;
red_color_counter++;
}else{
color=colors[len];
}
price_to_color[t_price]=color;
}
}
pl_tpl = hall_data.data[id_sch_pl].place_tpls[item.it];
pl_tpl = pl_tpl.replace('%%PLACE%%', item.place);
pl_tpl = pl_tpl.replace('%%COLOR%%', color);
pl_tpl = pl_tpl.replace('%%X%%', item.x);
pl_tpl = pl_tpl.replace('%%Y%%', item.y);
//pl_tpl = pl_tpl.replace('%%DATA%%', item.id_place);
pl_tpl = pl_tpl.replace('%%DATA%%', item.id_place);
pl_tpl = pl_tpl.replace('%%SCALE%%', item.scale);
pl_tpl = pl_tpl.replace('%%ANGLE%%', item.angle);
//pl_tpl = pl_tpl.replace('%%IT%%', item.it);
PLACES=PLACES+pl_tpl;
});
var calc_color_price_html='';
legend_place_tpl = hall_data.data[id_sch_pl].place_tpls[1];
legend_place_tpl = legend_place_tpl.replace('%%PLACE%%', '');
legend_place_tpl = legend_place_tpl.replace('%%X%%', '0');
legend_place_tpl = legend_place_tpl.replace('%%Y%%', '0');
legend_place_tpl = legend_place_tpl.replace('%%DATA%%', '');
legend_place_tpl = legend_place_tpl.replace('%%SCALE%%', '1');
for(price in price_to_color){
color=price_to_color[price];
count=color_to_count[price];
legend_place = legend_place_tpl.replace('%%COLOR%%', color);
calc_color_price_html=calc_color_price_html+' '+legend_place+' '+price+' ₽ '+count+' '+muz_tickets.declOfNum(count, [config[lang]['place1'], config[lang]['place2'], config[lang]['place3']])+' ';
}
gray=legend_place_tpl.replace('%%COLOR%%', 'gray');
yellow=legend_place_tpl.replace('%%COLOR%%', 'yellow');
$("#price_filter" ).html(''+calc_color_price_html+'
'+gray+' '+config[lang]['sold_pl']+' '+yellow+' '+config[lang]['sel_places']+'
');
$("#price_filter_title" ).html(config[lang]['symbols']);
str_out=' '+get_svg_defs(id_sch_pl)+PLACES+' ';
//var h = (((hall_data.data[id_sch_pl].scheme.h) * $('#muz_widget').outerWidth()) / hall_data.data[id_sch_pl].scheme.w);
$(str_out).appendTo('#widget_container');
$('#widget_container').css({position:'relative', overflow:'hidden', width:'100%'});//, height : h+'px'
/* w_top = ($(window).outerHeight()-$("#muz_widget").outerHeight())/2+$(window).scrollTop();
if(w_top<50) w_top=60;
$muz_widget.css({
"top" : w_top + "px",
"left" : ($(window).outerWidth()-$("#muz_widget").outerWidth())/2+$(window).scrollLeft() + "px"
}); */
});
}
}).fail(function() {
console.log( "error" );
});
$(".close_widget_img").on("click",function(){
close_widget();
});
/* $("#widget_curtain").on("click",function(){
close_widget();
}); */
$("body").on('mouseenter', '#muz_widget_svg .place:not(.temp_hide):not(.gray)', function() {
place_info = spec_data.data.tickets[$( this ).attr('data')];
if(typeof(place_info) === "undefined"){
}else{
var $place_info_div = $('
').appendTo('#widget_container');
$place_info_div.prop('id', 'place_info');
place_info_text='';
pl=hall_data.data[id_sch_pl].places[place_info['pid']];
if(pl.region!='') place_info_text += ''+pl.region+' '+pl.side+'
';
section='';
if(pl.section!='') section=config[lang]['Box']+': '+pl.section;
row='';
if(pl.row!='') row=config[lang]['Row']+': '+pl.row;
place='';
if(pl.place!='') place=config[lang]['Place']+': '+pl.place;
place_info_text += ''+section +' '+row+' '+place+'
';
price=place_info['prices']['1']['price'];
if(promocode!=''){
if(place_info['prices']['6'] !== undefined && place_info['prices']['6']['price'] > 0){
price=place_info['prices']['6']['price'];
}
}
place_info_text += ''+config[lang]['Price']+': '+price+' ₽
';
if(pl.lv=='1') place_info_text += ''+config[lang]['lv']+'
';
$('#place_info').html(place_info_text);
var offset = $( this ).offset();
var offset_wc = $( '#widget_container' ).offset();
$('#place_info').css({
'background-color':'white',
'opacity':0.9,
'border':'1px solid #e8e505',
'border-radius':'20px',
'padding':'10px',
'width':'150px',
'color':'#054f80',
'position':'absolute',
'top' :offset.top-offset_wc.top,
'display' :'block'
});
if( $( '#widget_container' ).width() - ( offset.left-offset_wc.left+25) > 170){
$('#place_info').css({
'left' :offset.left-offset_wc.left+25
});
}else{
$('#place_info').css({
'left' :offset.left-offset_wc.left-175
});
}
}
});
$("body").on('mouseleave', '#muz_widget_svg .place', function() {
$('#place_info').remove();
});
/*$('body').on("click", '#muz_widget .to_basket_button', function(){
ticket_list_ids='';
counter=0;
$('#muz_widget_svg .place.yellow').each(function( index ) {
tid = spec_data.data.tickets[$( this ).attr('data')].tid;
ticket_list_ids += '&t[]='+tid;
counter=counter+1;
});
if(counter > 0){
$.ajax({
url: 'https://tickets.muzcomedy.ru/'+lang+'/basket/',
method: "POST",
type: 'POST',
timeout: 5000,
data: "ajax=1&action=add&option=1"+ticket_list_ids,
error: function(XMLHttpRequest, status){
},
success: function (data) {
setTimeout("window.location.href='//tickets.muzcomedy.ru/"+lang+"/basket/'",'1000');
}
});
}
});*/
/*
$("#price_filter").on("click", ".range_enable.on img",function(){
$(this).parent().removeClass('on');
$(this).parent().addClass('off');
$(this).attr('src',$(this).attr('src').replace('show_a', 'show_p'));
//$("#muz_widget_svg .place.temp_hide").attr('class', function(index, classNames) {// показать все скрытые
// return classNames.replace('temp_hide', '');
//});
if($("#price_filter .range_enable.on img").length > 0){
$("#muz_widget_svg .place:not(.temp_hide)").attr('class', function(index, classNames) { // скрыть все показанные
return classNames + ' temp_hide';
});
$( "#price_filter .range_enable.on" ).each(function( index ) {
$("#muz_widget_svg .place."+$(this).attr('rel')).attr('class', function(index, classNames) {
return classNames.replace('temp_hide', '');
});
});
}else{
$("#muz_widget_svg .place.temp_hide").attr('class', function(index, classNames) {// показать все скрытые
return classNames.replace('temp_hide', '');
});
}
});
$("#price_filter").on("click", ".range_enable.off img",function(){
$(this).parent().removeClass('off');
$(this).parent().addClass('on');
$(this).attr('src',$(this).attr('src').replace('show_p', 'show_a'));
$("#muz_widget_svg .place.temp_hide").attr('class', function(index, classNames) {
return classNames.replace('temp_hide', '');
});
$("#muz_widget_svg .place").attr('class', function(index, classNames) {
return classNames + ' temp_hide';
});
$( "#price_filter .range_enable.on" ).each(function( index ) {
$("#muz_widget_svg .place."+$(this).attr('rel')).attr('class', function(index, classNames) {
return classNames.replace('temp_hide', '');
});
});
});
*/
$("#price_filter").on("click", ".price_color_block.on",function(){
$(this).removeClass('on');
$(this).addClass('off');
$(this).find('.range_enable img').attr('src',function(index, srcStr) { // скрыть все показанные
srcStr=srcStr.replace('show_a', 'show_p');
return srcStr;
});
//$(this).attr('src').replace('show_a', 'show_p'));
//$("#muz_widget_svg .place.temp_hide").attr('class', function(index, classNames) {// показать все скрытые
// return classNames.replace('temp_hide', '');
//});
if($("#price_filter .price_color_block.on").length > 0){
$("#muz_widget_svg .place:not(.temp_hide)").attr('class', function(index, classNames) { // скрыть все показанные
return classNames + ' temp_hide';
});
$( "#price_filter .price_color_block.on" ).each(function( index ) {
$("#muz_widget_svg .place."+$(this).attr('rel')).attr('class', function(index, classNames) {
return classNames.replace('temp_hide', '');
});
});
}else{
$("#muz_widget_svg .place.temp_hide").attr('class', function(index, classNames) {// показать все скрытые
return classNames.replace('temp_hide', '');
});
}
});
$("#price_filter").on("click", ".price_color_block.off",function(){
$(this).removeClass('off');
$(this).addClass('on');
$(this).find('.range_enable img').attr('src',function(index, srcStr) { // скрыть все показанные
srcStr=srcStr.replace('show_p', 'show_a');
return srcStr;
});
//$(this).attr('src',$(this).attr('src').replace('show_p', 'show_a'));
$("#muz_widget_svg .place.temp_hide").attr('class', function(index, classNames) {
return classNames.replace('temp_hide', '');
});
$("#muz_widget_svg .place").attr('class', function(index, classNames) {
return classNames + ' temp_hide';
});
$( "#price_filter .price_color_block.on" ).each(function( index ) {
$("#muz_widget_svg .place."+$(this).attr('rel')).attr('class', function(index, classNames) {
return classNames.replace('temp_hide', '');
});
});
});
scale=1;
$("body").on("click","#plus",function(){
scale=scale+0.5;
//console.log(scale);
$("#muz_widget_svg").css('transform', 'scale('+scale+')');
check_position(scale)
});
$("body").on("click","#minus",function(){
if(scale>1){
scale=scale-0.5;
//console.log(scale);
$("#muz_widget_svg").css('transform', 'scale('+scale+')');
}
check_position(scale);
});
$('body').on("click", '#muz_widget_svg .place', function(){
//alert($(this).attr('class')+' '+$(this).hasClass('yellow'));
//console.log('4444');
if($(this).attr('class').indexOf('gray') >= 0){
//****
}else{
if($(this).attr('class').indexOf('brake_click') < 0 ){
//$(this).attr('class', $(this).attr('class')+' brake_click');
$(this).attr('class', function(index, classNames){
return classNames+' brake_click';
});
setTimeout(() => {$(this).attr('class', $(this).attr('class').replace('brake_click', ''));}, 1000);
if($(this).attr('class').indexOf('yellow') >= 0){
$(this).attr('class', function(index, classNames){
tid = spec_data.data.tickets[$( this ).attr('data')].tid;
muz_tickets.jsonp('https://tickets.muzcomedy.ru/widget/removeFromBasket.js?t[]='+tid+'&promocode='+promocode).then(function(data){
//if(data.data.basket_info.t_cnt>0){
/*$('#widget_basket_container').html(' В корзине '+data.data.basket_info.t_cnt+' билетов, на '+data.data.basket_info.sum+' руб.'+data.data.basket_info.button_inf);*/
$('#widget_basket_container').html(' '+config[lang]['in_basket']+' '+data.data.basket_info.t_cnt+' '+muz_tickets.declOfNum(parseInt(data.data.basket_info.t_cnt), [config[lang]['place1'], config[lang]['place2'], config[lang]['place3']])+', '+config[lang]['for']+' '+((data.data.basket_info.all_sum !== undefined && data.data.basket_info.all_sum > data.data.basket_info.sum)?' '+data.data.basket_info.all_sum+' ':'')+data.data.basket_info.sum+' '+config[lang]['rub']+' '+data.data.basket_info.button_inf);
//$(this).attr('class', $(this).attr('class').replace('brake_click', ''));
/*}else{
$('#widget_basket_container').html('');
//return classNames;
}*/
});
classNames=classNames.replace('yellow', '');
//classNames=classNames.replace('brake_click', '');
return classNames;
});
}else{
$(this).attr('class', function(index, classNames){
tid = spec_data.data.tickets[$( this ).attr('data')].tid;
muz_tickets.jsonp('https://tickets.muzcomedy.ru/widget/intoBasket.js?t[]='+tid+'&promocode='+promocode).then(function(data){
ym(51759599,'reachGoal','booking_tickets');
//if(data.data.basket_info.t_cnt>0){
/*$('#widget_basket_container').html(' В корзине '+data.data.basket_info.t_cnt+' '+muz_tickets.declOfNum(parseInt(data.data.basket_info.t_cnt), [config[lang]['place1'], config[lang]['place2'], config[lang]['place3']])+', на '+data.data.basket_info.sum+' руб.'+data.data.basket_info.button_inf);*/
$('#widget_basket_container').html(' '+config[lang]['in_basket']+' '+data.data.basket_info.t_cnt+' '+muz_tickets.declOfNum(parseInt(data.data.basket_info.t_cnt), [config[lang]['place1'], config[lang]['place2'], config[lang]['place3']])+', '+config[lang]['for']+' '+((data.data.basket_info.all_sum !== undefined && data.data.basket_info.all_sum > data.data.basket_info.sum)?' '+data.data.basket_info.all_sum+' ':'')+data.data.basket_info.sum+' '+config[lang]['rub']+' '+data.data.basket_info.button_inf);
//$(this).attr('class', $(this).attr('class').replace('brake_click', ''));
//return classNames + ' yellow';
/*}else{
$('#widget_basket_container').html('');
//return classNames;
}*/
});
classNames=classNames + ' yellow';
//classNames=classNames.replace('brake_click', '');
return classNames;
});
}
}
}
});
$("#muz_widget").bind('mousewheel DOMMouseScroll', function(event){
if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {
event.preventDefault();
scale=scale+0.5;
//console.log(scale);
$("#muz_widget_svg").css('transform', 'scale('+scale+')');
}else {
event.preventDefault();
if(scale>1){
scale=scale-0.5;
//console.log(scale);
$("#muz_widget_svg").css('transform', 'scale('+scale+')');
}
}
check_position(scale);
});
function check_position(scale){
p_svg=$('#muz_widget_svg').position();
koefY=(scale-1) * $('#widget_container').height() / 2;
koefX=(scale-1) * $('#widget_container').width() / 2;
if(p_svg.top > koefY){$('#muz_widget_svg').css('top', koefY);}
if(p_svg.top < -koefY){$('#muz_widget_svg').css('top', -koefY);}
if(p_svg.left > koefX){$('#muz_widget_svg').css('left', koefX);}
if(p_svg.left < -koefX){$('#muz_widget_svg').css('left', -koefX);}
}
}
};
var shiftX=0;
var shiftY=0;
$(document).on("mousedown", '#muz_widget_svg', function(event) {
p = $('#muz_widget').position();
xx = parseInt($('#muz_widget_svg').css('left'));
yy = parseInt($('#muz_widget_svg').css('top'));
shiftX =event.pageX - p.left -xx ;
shiftY =event.pageY - p.top - $('#spec_info_container').outerHeight() - yy;
//moveAt(event.pageX, event.pageY);
// переносит мяч на координаты (pageX, pageY),
// дополнительно учитывая изначальный сдвиг относительно указателя мыши
function moveAt(X, Y) {
p = $('#muz_widget').position();
new_X=X - p.left -shiftX;
new_Y=Y - p.top - $('#spec_info_container').outerHeight() -shiftY +$('#muz_widget').scrollTop();
koefY=(scale-1) * $('#widget_container').height() / 2;
koefX=(scale-1) * $('#widget_container').width() / 2;
if(new_Y <= koefY && new_Y >= -koefY){
$('#muz_widget_svg').css('top' , new_Y + 'px');
}
if(new_X <= koefX && new_X >= -koefX){
$('#muz_widget_svg').css('left', new_X + 'px');
}
}
function onMouseMove(event) {
moveAt(event.pageX, event.pageY);
}
document.addEventListener('mousemove', onMouseMove);
$(this).onmouseup = function() {
document.removeEventListener('mousemove', onMouseMove);
$(this).onmouseup = null;
};
$(document).on("mouseup", '#muz_widget *, #widget_curtain', function(event) {
document.removeEventListener('mousemove', onMouseMove);
$('#muz_widget_svg').onmouseup = null;
});
$('#muz_widget_svg').ondragstart = function(){
return false;
};
});
$('#muz_widget').on('dragstart','#muz_widget_svg', function(event) {
event.preventDefault();
return false;
});
document.addEventListener("dragstart", function(event) {event.preventDefault(); return false; });
$('#muz_widget_svg').onload=function(){
$('#muz_widget_svg').ondragstart = function() { return false; }
}
$(document).ondragstart = function(event) {return false;};
function array_key_exists(key, search){
if( !search || (search.constructor !== Array && search.constructor !== Object) ){
return false;
}
return search[key] !== undefined;
}
function get_svg_defs(id_sch_pl){
defs = new Array();
defs[1]=' \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n';
defs[3]=' \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n';
defs[4]=' \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n';
defs[14]=' \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n';
/*
defs[2]=' ';
*/
defs[2]=' ';
defs[9]=' ';
return ''+defs[id_sch_pl]+' ';
}