Advertisement
Apina

seating_chart,js hack

Jun 3rd, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.27 KB | None | 0 0
  1. // JavaScript Document
  2.  
  3. var ee_current_seat = "";
  4. var current_seat_id = 0;
  5. var selected_custom_tag = "";
  6. var current_seat_select_obj;
  7. var disable_selection = false;
  8. function display_seating_chart() {
  9. disable_selection = false;
  10. current_seat_select_obj = jQuery(this);
  11. event_id = 0;
  12. seating_chart_id = 0;
  13. var event_id_attr = current_seat_select_obj.attr('event_id');
  14. var seating_chart_id_attr = current_seat_select_obj.attr('seating_chart_id');
  15. var disable_selection_attr = current_seat_select_obj.attr('disable_section');
  16. if ( typeof event_id_attr !== 'undefined' && event_id_attr !== false) {
  17. event_id = current_seat_select_obj.attr('event_id');
  18. }
  19. if ( typeof seating_chart_id_attr !== 'undefined' && seating_chart_id_attr !== false) {
  20. seating_chart_id = current_seat_select_obj.attr('seating_chart_id');
  21. }
  22. if ( typeof disable_selection_attr !== 'undefined' && disable_selection_attr !== false) {
  23. disable_selection = true;
  24. }
  25. postData = 'event_id='+event_id+'&seating_chart_id='+seating_chart_id;
  26. jQuery.ajax({
  27. type:"POST"
  28. ,url:ee_seating_chart_vars.callback_url+"request.php?seating_chart_action=get_event_seating_chart"
  29. ,data: postData
  30. ,dataType:"text"
  31. ,error:function(data) {
  32. alert("Failed to access "+ee_seating_chart_vars.callback_url+"request.php");
  33. }
  34. ,success: function(data) {
  35. data = jQuery.trim(data);
  36. if ( data != '' )
  37. {
  38. jQuery('#seating_chart_content').html(data);
  39. jQuery('#seating_chart_page').height(jQuery(document).height());
  40. jQuery('#seating_chart_page').width(jQuery(document).width());
  41. jQuery('#seating_chart_info').css('height','0px');
  42. jQuery('.ee_s_row').each(function(){
  43. var seat_count = jQuery(this).children('.ee_s_seat').length;
  44. var placeholder_count=jQuery(this).children('.ee_s_seat_placeholder').length;
  45. var reserved_count=jQuery(this).children('.ee_s_seat_reserved').length;
  46. var width = (seat_count+placeholder_count+reserved_count)*25;
  47. jQuery(this).css('width',width+'px');
  48. });
  49. jQuery('.ee_s_section').each(function() {
  50. var row_count = jQuery(this).children('.ee_s_row').length;
  51. var height = (row_count * 30)+30;
  52. // jQuery(this).css('height',height+'px');
  53. var width = 0;
  54. jQuery(this).children('.ee_s_row').each(function(){
  55. if ( jQuery(this).width() > width ) {
  56. width = jQuery(this).width();
  57. }
  58. });
  59. width += 50;
  60. jQuery(this).css('width',width+'px');
  61.  
  62. });
  63.  
  64.  
  65. var widest_level = 0;
  66. var total_level_heights = 0;
  67. jQuery('.ee_s_level').each(function(){
  68. var level_width = 0;
  69. var level_height = 30;
  70. jQuery(this).children('.ee_s_section').each(function(){
  71. level_width += jQuery(this).width()+10;
  72. // level_height += jQuery(this).height();
  73. });
  74. if ( level_width > widest_level) {
  75. widest_level = level_width;
  76. }
  77. total_level_heights += level_height;
  78. });
  79. if ( total_level_heights > jQuery(window).height()) {
  80. jQuery('#ee_s_layout').height(jQuery(window).height()-150);
  81. jQuery('#ee_s_layout').css('overflow-y','auto');
  82. jQuery('#seating_wrp').height(jQuery(window).height()-20);
  83. } else {
  84.  
  85. jQuery('#seating_wrp').height(total_level_heights + 200);
  86. if ( jQuery('#seating_wrp').height() < 600 ) {
  87. jQuery('#seating_wrp').height(600);
  88. }
  89. }
  90.  
  91. jQuery('.ee_s_level').css('width',widest_level+'px');
  92. if ( (widest_level+40) > jQuery(window).width()) {
  93. jQuery('#ee_s_layout').width(jQuery(window).width()-60);
  94. jQuery('#seating_wrp').width(jQuery(window).width()-20);
  95. } else {
  96. jQuery('#ee_s_layout').width(widest_level + 20);
  97. jQuery('#seating_wrp').width(widest_level + 80);
  98. if ( jQuery('#seating_wrp').width() < 700 ) {
  99. jQuery('#seating_wrp').width(700);
  100. }
  101. }
  102.  
  103.  
  104.  
  105. jQuery('#seating_chart_page').show();
  106. jQuery('#seating_chart_content').show();
  107. jQuery('#seating_chart_close_button').show();
  108. var calc_height = 0;
  109. jQuery('#seating_wrp').children().each(function(){
  110. calc_height += jQuery(this).height();
  111. });
  112. if ( calc_height > jQuery('#seating_wrp').height()) {
  113. jQuery('#seating_wrp').height(calc_height);
  114. }
  115. var left = ((jQuery(window).width() - jQuery('#seating_wrp').width()) / 2);
  116. var top = ((jQuery(window).height() - jQuery('#seating_wrp').height()) / 2);
  117.  
  118. jQuery('#seating_wrp').css('top',(top+5)+'px');
  119. jQuery('#seating_wrp').css('left',left+'px');
  120. jQuery('#seating_chart_info').css('height','auto');
  121. scroll(0,0);
  122.  
  123.  
  124. var dean = jQuery('.ee_s_select_seat').prop('dean');
  125. jQuery('#'+dean).addClass("dean");
  126.  
  127. }
  128. else
  129. {
  130. alert('Seating chart not available.');
  131. }
  132. }
  133. });
  134. return false;
  135. }
  136.  
  137. function book_a_seat(obj)
  138. {
  139. jQuery('#seating_chart_info').css('display','none');
  140. var seat_id = obj.attr('seat_id');
  141. var event_id = obj.attr('event_id');
  142. var booking_info = current_seat_select_obj.val();
  143. var current_booking_id = 0;
  144. booking_info = jQuery.trim(booking_info);
  145. if ( booking_info != "" )
  146. {
  147. var tmpar = booking_info.split("|");
  148. if ( tmpar.length > 1 )
  149. {
  150. var tmpar2 = tmpar[tmpar.length-1].split(":");
  151. if (tmpar2.length == 2 )
  152. {
  153. var tmp = tmpar2[1];
  154. current_booking_id = parseInt(tmp);
  155. }
  156. }
  157. }
  158. else
  159. {
  160. current_booking_id = 0;
  161. }
  162. selected_custom_tag = obj.children('.ee_s_custom_tag').html();
  163. var postData = "seat_id="+seat_id+"&event_id="+event_id+"&booking_id="+current_booking_id;
  164. jQuery.ajax({
  165. type:"POST"
  166. ,url:ee_seating_chart_vars.callback_url+"request.php?seating_chart_action=book_a_seat"
  167. ,data: postData
  168. ,dataType:"text"
  169. ,success: function(data) {
  170. data = jQuery.trim(data);
  171. if ( data != '' )
  172. {
  173. var current_booking_id = parseInt(data);
  174.  
  175. if ( current_booking_id > 0 )
  176. {
  177. //jQuery('#h_'+ee_current_seat).val(current_booking_id);
  178. var tag = selected_custom_tag+" | Booking ID:"+current_booking_id;
  179. current_seat_select_obj.val(tag);
  180.  
  181.  
  182. var dean = obj.attr('id');
  183. jQuery('.ee_s_select_seat').prop('dean', dean);
  184.  
  185. alert(selected_custom_tag+" has been reserved for you.\nIt will be released if you do not confirm your registration within next 1 hour.\nContinue to submit this form to confirm.");
  186. close_seating_chart();
  187. }
  188. else
  189. {
  190. alert("Seat is not available");
  191. }
  192. jQuery('#seating_chart_info').css('display','none');
  193. }
  194. else
  195. {
  196. alert('Failed to connect to server.');
  197. }
  198. }
  199. });
  200. }
  201.  
  202. function close_seating_chart()
  203. {
  204. //jQuery('#seating_chart_info').hide();
  205. jQuery('#seating_chart_info').css('display','none');
  206. jQuery('#seating_chart_close_button').hide();
  207. jQuery('#seating_chart_content').hide();
  208. jQuery('#seating_chart_page').hide();
  209. return false;
  210. }
  211.  
  212. jQuery(document).ready(function(){
  213.  
  214. jQuery('body').append('<div id="seating_chart_page"><div id="seating_wrp"><div id="seating_chart_close_button">Close</div><div id="seating_chart_content"></div><p>Seating charts reflect the general layout for the venue at this time. For some events, the layout and specific seat locations may vary without notice.<p><div id="seating_chart_info"></div></div></div>');
  215. jQuery('#seating_chart_page').live('click',close_seating_chart);
  216. jQuery('.ee_s_select_seat').live('click',display_seating_chart);
  217. jQuery('#seating_chart_close_button').live('click',close_seating_chart);
  218.  
  219.  
  220.  
  221. jQuery('.ee_s_seat').live('mouseenter',function(){
  222. p1 = jQuery('#seating_chart_content').position();
  223. p = jQuery(this).position();
  224. obj = jQuery('#seating_chart_info')
  225.  
  226. newTop = parseInt(p1.top)+parseInt(p.top)+20;
  227. newLeft = parseInt(p1.left)+parseInt(p.left)+20;
  228.  
  229. obj.css('top',newTop+'px');
  230. obj.css('left',newLeft+'px');
  231. obj.css('height','auto');
  232. obj.css('width','auto');
  233. html = "Seat: "+jQuery(this).children('.ee_s_custom_tag').html()+"<br/>";
  234. html += "Price: "+ee_seating_chart_vars.currency_symbol+jQuery(this).attr('price')+"<br/>";
  235. html += "Level: "+jQuery(this).attr('level')+"<br/>";
  236. html += "Section: "+jQuery(this).attr('section')+"<br/>";
  237. html += "Row: "+jQuery(this).attr('row')+"<br/>";
  238. html += "Description: "+jQuery(this).children('.ee_s_description').html()+"<br/>";
  239. obj.html(html);
  240. obj.show();
  241. var viewport_w = jQuery(window).width();
  242.  
  243. if ( (newLeft + obj.width()+40) > viewport_w ) {
  244. newLeft = parseInt(p1.left)+parseInt(p.left)- parseInt(obj.width()) - 96;
  245.  
  246. obj.css('left',newLeft+'px');
  247. }
  248. });
  249.  
  250. jQuery('.ee_s_seat').live('mouseout',function() {
  251. jQuery('#seating_chart_info').hide();
  252. });
  253.  
  254. jQuery('.ee_s_seat').live('click',function() {
  255. if ( !disable_selection) {
  256. book_a_seat(jQuery(this));
  257. }
  258. return false;
  259. });
  260.  
  261.  
  262. });
  263.  
  264.  
  265. jQuery(document).ready(function(){
  266. jQuery('#bulk_edit').click(function(){ submit_bulk_edit();});
  267.  
  268. jQuery('#bulk_edit_cancel').click(function(){
  269. jQuery('#bulk_seat_table').hide();
  270. jQuery('#bulk-titles').html('');
  271. jQuery('.seat_ids').filter(':checked').each(function(){
  272. jQuery('.seat_ids').attr('checked',false);
  273. });
  274. });
  275.  
  276. jQuery('.seat_submitdelete').click(function(){
  277. var seat_id = jQuery(this).attr('seat_id');
  278. jQuery('.seat_ids').each(function(){
  279. jQuery(this).attr('checked',false);
  280. });
  281. jQuery('#chk_'+seat_id).attr('checked',true);
  282. delete_bulk_seats();
  283. });
  284.  
  285. jQuery('.seat_editinline').click(function(){
  286. var seat_id = jQuery(this).attr('seat_id');
  287. if(!jQuery('#chk_'+seat_id).is(':checked')) {
  288. jQuery('#seat_list_action').val('edit');
  289. jQuery('#chk_'+seat_id).attr('checked',true);
  290. edit_bulk_seats();
  291. }
  292. });
  293.  
  294. jQuery('.bulk_remove_seat').live('click',function() {
  295. var seat_id = jQuery(this).attr('seat_id');
  296. jQuery('#bulk_'+seat_id).remove();
  297. jQuery('#chk_'+seat_id).attr('checked',false);
  298. });
  299.  
  300. jQuery('.seat_ids').click(function() {
  301. if ( !jQuery(this).is(':checked')) {
  302. if ( jQuery('#bulk_'+jQuery(this).val()).length > 0) {
  303. jQuery('#bulk_'+jQuery(this).val()).remove();
  304. }
  305. } else {
  306. add_seat_to_bulk_edit(jQuery(this).val());
  307. }
  308. });
  309.  
  310. jQuery('#seat_list_doaction').click(function(){
  311. jQuery('#bulk-titles').html('');
  312.  
  313. var selection_count = jQuery('.seat_ids').filter(':checked').length;
  314. if ( selection_count > 0 ) {
  315. var action = jQuery('#seat_list_action').val();
  316. switch(action) {
  317. case 'edit':
  318. edit_bulk_seats();
  319. break;
  320. case 'trash':
  321. delete_bulk_seats();
  322. break;
  323. default:
  324. alert('Please select an action!');
  325. break;
  326. }
  327. } else {
  328. alert('Please select at least one seat!');
  329. }
  330. });
  331.  
  332.  
  333. });
  334.  
  335. function delete_bulk_seats() {
  336. jQuery('#bulk_seat_action').val('bulk_delete');
  337. jQuery('#frm_bulk_seat_action').submit();
  338. }
  339.  
  340. function edit_bulk_seats() {
  341. //"<div class="type1">Level</div><div class="type1">Section</div><div class="type1">Row</div><div class="type1">Seat</div><div class="type2">Tag</div>"
  342. jQuery('#bulk-titles').html('<div class="bulk_seat bulk_seat_head"><div class="type0">&nbsp;</div><div class="type1">Level</div><div class="type1">Section</div><div class="type1">Row</div><div class="type1">Seat</div><div class="type2">Tag</div></div>');
  343. jQuery('.seat_ids').filter(':checked').each(function(){
  344. var seat_id = jQuery(this).val();
  345. add_seat_to_bulk_edit(seat_id);
  346. });
  347.  
  348. if(jQuery('#bulk_seat_table').is(':hidden')) {
  349. jQuery('#bulk_seat_table').slideDown('slow');
  350. }
  351. }
  352.  
  353. function add_seat_to_bulk_edit(seat_id) {
  354. var bstring = '';
  355. bstring += '<div id="bulk_'+seat_id+'" seat_id='+seat_id+' class="bulk_seat"><div class="type0"><a title="Remove from bulk edit" class="bulk_remove_seat" seat_id="'+seat_id+'">X</a></div>';
  356. bstring += '<div class="type1">'+jQuery('#level_'+seat_id).html()+'</div>';
  357. bstring += '<div class="type1">'+jQuery('#section_'+seat_id).html()+'</div>';
  358. bstring += '<div class="type1">'+jQuery('#row_'+seat_id).html()+'</div>';
  359. bstring += '<div class="type1">'+jQuery('#seat_'+seat_id).html()+'</div>';
  360. bstring += '<div class="type2">'+jQuery('#custom_tag_'+seat_id).html()+'</div>';
  361. bstring += '</div>';
  362. //<div id="ttle11"><a title="Remove From Bulk Edit" class="ntdelbutton" id="_11">X</a>General 1 3 5</div>
  363. jQuery('#bulk-titles').html(jQuery('#bulk-titles').html()+bstring);
  364. //jQuery('#chk_'+seat_id).attr('checked',true);
  365. }
  366.  
  367. function submit_bulk_edit() {
  368. var selection_count = jQuery('.seat_ids').filter(':checked').length;
  369. if ( selection_count > 0 ) {
  370. jQuery('#bulk_seat_action').val('bulk_edit');
  371. jQuery('#frm_bulk_seat_action').submit();
  372. } else {
  373. alert('Please select a seat first!');
  374. }
  375. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement