var EDPWidget = DropDownWidget.build( {
style: {
frame: 'widget-frame',
focused_frame: 'widget-frame onFocus',
border: 'widget-border',
dropdown: 'widget-dropdown',
dropdown_active: 'widget-dropdown-active',
list: 'widget-dropdown-list',
choice: 'widget-dropdown-list-item',
selected: 'widget-dropdown-list-item selected',
scroll_frame: 'widget-scroll-frame',
scroll_border: 'widget-scroll-border',
scroll_up: 'widget-scroll-up',
scroll_up_active: 'widget-scroll-up-active',
scroll_down: 'widget-scroll-down',
scroll_down_active: 'widget-scroll-down-active',
scrub_frame: 'widget-scroll-scrub-frame',
scrub: 'widget-scroll-scrub',
scrub_active: 'widget-scroll-scrub-active'
}
} );
TicketInfoPopup = Class.create( {
initialize: function() {
this.popup = new Popup( 'ticket_type_info', {
close_id: 'ticket_type_info_close'
} );
this.content = {};
},
display_content: function( title, link_id ) {
if ( this.current_link != link_id ) {
this.current_link = link_id;
this.popup.hide();
var content = this.content[link_id];
$H(this.content).values().each( function ( other_content ) {
if ( content != other_content ) {
other_content.modules.each( function ( c ) {
c.detach();
} );
}
} );
content.modules.each( function ( c ) {
c.attach( $('ticket_type_info_content') );
} );
if ( content.is_amex_gold ) {
$('ticket_type_info_title').update( FeatureDisplay.amex_password_title );
$('ticket_type_info_content').style.overflow = "auto";
$('ticket_type_info_content').style.height = "250px";
}
else {
$('ticket_type_info_title').update( title );
$('ticket_type_info_content').style.overflow = "";
$('ticket_type_info_content').style.height = "auto";
}
}
},
set_content: function( link_id, content, is_amex_gold ) {
if ( !this.content[link_id] )
this.content[link_id] = { modules: [], is_amex_gold: is_amex_gold };
this.content[link_id].modules.push( content );
},
set_link: function( link_id, data ) {
var title = data.title;
var thisobj = this;
var link = {
link_id: link_id,
toggle: true,
anchor_align: {
x: 1,
y: -1
},
popup_align: {
x: -1,
y: -1
},
onShow: function() {
thisobj.display_content( title, link_id );
if (data.webtrend) {
dcsMultiTrack('DCS.dcsuri', data.webtrend,'WT.ti', data.webtrend);
}
}
};
this.popup.addLinks( [ link ] );
$(link_id).style.display = "";
}
} );
TicketTypeInfo = Class.create( Module, {
source: [ 'tt_info_text_source', { removeParent: true, inside: true } ],
unique_ids: [ 'tt_info_text', 'tt_info_link', 'tt_info_link_text' ],
initialize: function( $super, data ) {
$super();
if ( data.text ) {
this.$('tt_info_text').innerHTML = data.text;
this.$('tt_info_text').style.display = "";
}
if ( data.link_text ) {
this.$('tt_info_link').href = data.link;
this.$('tt_info_link_text').innerHTML = data.link_text;
this.$('tt_info_link').style.display = "";
}
if ( data.text && data.link_text ) {
this.$('tt_info_link').insert( { 'before': new Element( 'br' ) } );
}
}
} );
FeatureDisplay = Class.create( Module, {
source: [ 'feature_display', { removeParent: true } ],
unique_ids: [ 'feature_display', 'feature_title', 'ticket_type_info_link', 'offerCode', 'quantity_select', 'feature_select', 'qae_image' ],
initialize: function( $super, data ) {
$super();
this.$('feature_title').innerHTML = data.title;
this.title = data.title;
var password_info;
this.pw_prefill = "";
if ( data.password ) {
var offerCode = this.$('offerCode');
offerCode.observe( 'focus', function() {
$('pw_info_popup').update( data.password.prompt_text );
FeatureDisplay.pw_info_popup.show( {
anchor_id: offerCode.id,
anchor_align: {
x: 0,
y: -1
},
popup_align: {
x: 0,
y: 1
},
offset: {
x: 0,
y: -5
}
} );
} );
offerCode.observe( 'blur', function() {
FeatureDisplay.pw_info_popup.hide();
} );
offerCode.style.display = "";
if ( data.password.prefill )
this.pw_prefill = data.password.prefill;
password_info = data.password.password_info;
}
else
this.$('feature_select').removeClassName( 'margin10R' );
if( data.ticket_type_info || password_info ) {
FeatureDisplay.ticket_info_popup.set_link( this.id('ticket_type_info_link'), data );
if ( password_info ) {
var content = new Module( { source: [ password_info, { inside: true, removeParent: true }  ] } );
FeatureDisplay.ticket_info_popup.set_content( this.id('ticket_type_info_link'), content, data.password.is_amex_gold );
}
if ( data.ticket_type_info ) {
var content = new TicketTypeInfo( data.ticket_type_info );
if ( data.password && password_info ) {
content.$('tt_info_text').insert( { 'before': new Element( 'br' ) } );
}
FeatureDisplay.ticket_info_popup.set_content( this.id('ticket_type_info_link'), content );
}
}
this.clear_all();
this.quantity_dropdown = new EDPWidget( this.$('quantity_select'), { rows: 10 } );
this.feature_dropdown = new EDPWidget( this.$('feature_select'), { rows: 10 } );
this.set_quantity_options( data.quantity );
this.quantity_dropdown.build_options();
},
clear_all: function () {
this.reset_selected_quantity();
this.reset_selected_feature();
this.clear_feature_options();
this.clear_password();
},
clear_password: function () {
this.$('offerCode').value = this.pw_prefill;
},
clear_feature_options: function () {
this.$('feature_select').options.length = 0;
},
add_feature_option: function ( feature ) {
var select = this.$('feature_select');
var new_option = new Option( feature.text, feature.value );
select.options[select.options.length] = new_option;
if ( feature.selected )
select.selectedIndex = select.options.length - 1;
this.feature_dropdown.update_dropdown();
},
reset_selected_quantity: function() {
if ( this.$('quantity_select').options.length ) {
this.$('quantity_select').selectedIndex = 0;
this.quantity_dropdown.update_dropdown();
}
},
set_quantity_options: function ( quantity ) {
var select = this.$('quantity_select');
if ( quantity ) {
select.style.display = "";
var si = select.selectedIndex;
if ( !si || si < 0 )
si = 0;
select.options.length = 0;
if ( quantity.min > 0 )
select.options[select.options.length] = new Option( 0, 0 );
var step = quantity.step || 1;
for (var i = quantity.min ; i <= quantity.max ; i++) {
var remainder = i % step;
if (remainder == 0) {
select.options[select.options.length] = new Option( i, i );
}
}
select.selectedIndex = si;
this.quantity_dropdown.show();
this.quantity_dropdown.update_dropdown();
}
else {
select.style.display = "none";
this.quantity_dropdown.hide();
}
},
set_quantity: function( value ) {
var select = this.$('quantity_select');
var options = select.options;
for ( var i = 0 ; i < options.length ; i ++ ) {
if ( options[i].value == value ) {
select.selectedIndex = i;
this.quantity_dropdown.update_dropdown();
return;
}
}
},
get_selected_quantity: function() {
var select = this.$('quantity_select');
if ( select.selectedIndex >= 0 )
return parseInt( select.options[select.selectedIndex].value );
else
return 0;
},
reset_selected_feature: function() {
this.$('feature_select').selectedIndex = 0;;
},
get_selected_feature: function() {
var select = this.$('feature_select');
if ( select.selectedIndex >= 0 )
return select.options[select.selectedIndex].value;
else
return "";
}
});
FeatureDisplay.ticket_info_popup = new TicketInfoPopup();
FeatureDisplay.pw_info_popup = new Popup( "pw_info_popup" );
EventTicketDisplay = Class.create( Module, {
source: [ 'event_ticket', { removeParent: true } ],
unique_ids: [ 'event_ticket', 'event_ticket_types', 'event_ticket_groups', 'event_mastersearch', 'ticket_limit_info', 'ticket_limit_text', 'feature_submit_box', 'mapsell_box', 'aic_box' ]
});
TicketType = Class.create( {
initialize: function( ev_ticket, tt_info ) {
this.quantity = tt_info.quantity;
this.v = tt_info.v;
this.secnames = {};
this.prices = [];
this.masked_prices = [];
this.mask = 0;
this.event_ticket = ev_ticket;
this.password = tt_info.password;
this.description = tt_info.description;
this.suppress_any_price = tt_info.suppress_any_price;
this.discrete = tt_info.discrete;
this.set_discrete_offer( Discrete.id );
this.tt_info = tt_info;
if ( this.enabled )
this.setup_ticket_type();
},
setup_ticket_type: function() {
if ( this.password )
this.password.prefill = this.get_password_prefill();
this.display = new FeatureDisplay( { title: this.tt_info.description, ticket_type_info: this.tt_info.ticket_type_info, quantity: this.quantity, password: this.password, webtrend: this.tt_info.webtrend } );
Event.observe( this.display.quantity_dropdown.dropdown, 'dropdown:change', this.on_quantity_change.bind( this ) );
Event.observe( this.display.feature_dropdown.dropdown, 'dropdown:change', this.select_price.bind( this ) );
this.display.feature_dropdown.build_options( this.tt_info.price_options );
this.display.feature_dropdown.set_option( { value: -1, text: FeatureDisplay.not_applicable } );
this.display.feature_dropdown.set_option( { value: 0, text: FeatureDisplay.any_price } );
if ( this.tt_info.qa_enabled ) {
this.display.$('qae_image').show();
}
},
get_password_prefill: function() {
var index = this.password.index;
var val;
if ( !index )
val = getQry( 'tm_catr' );
if ( !val )
val = getQry( 'tm_cat' + index );
if ( !val )
val = new CookieTree( '_E', 'pp' ).get( index );
new CookieTree( '_E', 'pp' ).set( index, val );
return val ? val.slice(10) : "";
},
on_quantity_change: function() {
this.event_ticket.limit_ticket_quantities();
},
set_discrete_offer: function( code ) {
if ( this.event_ticket.mastersearch )
this.enabled = true;
else if ( code )
this.enabled = this.discrete.codes[code] ? true: false;
else
this.enabled = this.discrete.public_enable ? true : false;
},
_sort_prices: function( a, b ) {
if ( this.event_ticket.mastersearch ) {
if ( a.value > b.value )
return 1;
if ( a.value < b.value )
return -1;
}
else {
if ( a.price < b.price )
return 1;
if ( a.price > b.price )
return -1;
}
if ( a.secname > b.secname )
return 1;
if ( a.secname < b.secname )
return -1;
return 0;
},
update_display: function() {
if ( this.enabled && !this.mapsell_disabled )
this.display.$('feature_display').style.display = "";
else {
this.reset_all();
this.display.$('feature_display').style.display = "none";
}
var select = this.display.$('feature_select');
this.display.clear_feature_options();
if ( !this.prices.length ) {
select.style.display = "none";
this.display.feature_dropdown.hide();
}
else {
var num_choices = this.masked_prices.length;
if ( num_choices == 0 ) {
this.display.add_feature_option( { value: -1, text: FeatureDisplay.not_applicable } );
this.display.reset_selected_quantity();
}
else if ( !this.suppress_any_price && num_choices > 1 )
this.display.add_feature_option( { value: 0, text: FeatureDisplay.any_price } );
var last_charges;
var has_duplicates = false;
var prices = this.masked_prices.sort( this._sort_prices.bind( this ) );
for ( var i = 0 ; i < prices.length ; i ++ ) {
var price = prices[i];
if ( !last_charges ||
last_charges.face_value != price.charges.face_value ||
last_charges.sum_fees_and_taxes != price.charges.sum_fees_and_taxes ) {
this.display.add_feature_option( {
value: price.masks[1],
text: price.value,
selected: ( this.mask & price.masks[1] )
} );
last_charges = price.charges;
}
else {
var option = select.options[select.options.length-1];
option.value = option.value | price.masks[1];
has_duplicates = true;
if ( !this.display.feature_dropdown.options[option.value] )
this.display.feature_dropdown.set_option(
option,
this.display.feature_dropdown.options[price.masks[1]].choice
);
}
}
if ( has_duplicates && select.options.length == 2 ) {
if ( !this.suppress_any_price )
select.remove(0);
}
select.style.display = '';
this.display.feature_dropdown.show();
this.display.feature_dropdown.update_dropdown();
}
},
select_price: function() {
var select = this.display.$('feature_select');
this.mask = select.options[select.selectedIndex].value;
this.event_ticket.update_choices( this );
},
select_price_by_secname: function( price_level ) {
if ( this.secnames[price_level] )
this.mask = this.secnames[price_level].masks[1];
},
get_secname_description: function( price_level ) {
if ( this.secnames[price_level] )
return this.secnames[price_level].description;
return "";
},
get_masks: function() {
var masks;
for ( var p = 0 ; p < this.prices.length ; p ++ ) {
var price_level = this.prices[p];
if ( this.mask & price_level.masks[1] )
masks = masks ? merge_masks( masks, price_level.masks ) : Object.extend( {}, price_level.masks );
}
return masks;
},
mask_prices: function( masks ) {
this.masked_prices = [];
for( var i = 0 ; i < this.prices.length ; i ++ ) {
if ( this.prices[i].masks[1] & masks[1] )
this.masked_prices.push( this.prices[i] );
}
},
reset_prices: function () {
this.masked_prices = this.prices.clone();
if ( !this.choices_ready ) {
this.display.feature_dropdown.update_width();
this.display.quantity_dropdown.update_width();
this.choices_ready = true;
}
},
reset_all: function() {
this.mask = 0;
this.display.clear_all();
this.reset_prices();
},
add_price_level: function( price_info ) {
this.prices.push( price_info );
this.secnames[price_info.secname] = price_info;
},
limit_quantity: function ( max ) {
var quantity = {
step: this.quantity.step
};
if ( max < this.quantity.min ) {
quantity.min = 0;
quantity.max = 0;
}
else {
quantity.min = this.quantity.min;
quantity.max = this.quantity.max < max ? this.quantity.max : max;
}
this.display.set_quantity_options( quantity );
},
get_selected_quantity: function () {
return this.display.get_selected_quantity();
},
get_selection_mask: function() {
var select = this.display.$('feature_select');
return select.options.length ? select.options[select.selectedIndex].value : 0;
},
get_selected_price: function () {
var select = this.display.$('feature_select');
var mask = select.options[select.selectedIndex].value;
if ( mask )
for ( var i = 0 ; i < this.masked_prices.length ; i ++ )
if ( this.masked_prices[i].masks[1] & mask )
return this.masked_prices[i].price;
return 0;
},
add_form_values: function( form, mask ) {
var quantity = this.get_selected_quantity();
form.appendChild( new Element( 'input', { type: 'hidden', name: "w_ext_qty." + this.v, value: quantity } ) );
if ( quantity ) {
for ( var i = 0 ; i < this.masked_prices.length ; i ++ ) {
if ( this.masked_prices[i].masks[1] & mask )
form.appendChild( new Element( 'input', { type: 'hidden', name: "w_vv_ext_price." + this.v, value: this.masked_prices[i].v } ) );
}
}
else
form.appendChild( new Element( 'input', { type: 'hidden', name: "w_vv_ext_price." + this.v, value: "" } ) );
if ( this.password )
form.appendChild( new Element( 'input', { type: 'hidden', name: this.password.form_name, value: this.display.$('offerCode').value } ) );
}
} );
TicketGroup = Class.create( {
initialize: function( ev_ticket, group_info ) {
this.form_name = group_info.form_name;
this.sections = [];
this.masked_sections = [];
this.secnames = {};
this.event_ticket = ev_ticket;
this.title = group_info.title;
this.suppress_best_available = group_info.suppress_best_available;
this.group_id = group_info.gid;
this.display = new FeatureDisplay( { title: group_info.title } );
Event.observe( this.display.feature_dropdown.dropdown, 'dropdown:change', this.select_section.bind( this ) );
},
alpha_sort: function ( a, b ) {
if ( a.description > b.description )
return 1;
if ( a.description < b.description )
return -1;
return 0;
},
update_display: function() {
this.display.clear_feature_options();
var num_choices = this.masked_sections.length;
if ( num_choices == 0 )
this.display.add_feature_option( { value: -1, text: FeatureDisplay.not_applicable } );
else if ( !this.suppress_best_available )
this.display.add_feature_option( { value: 0, text: FeatureDisplay.best_available } );
var select = this.display.$('feature_select');
var sections = this.masked_sections.sort( this.alpha_sort );
for ( var i = 0 ; i < sections.length ; i ++ ) {
this.display.add_feature_option( {
value: sections[i].secname,
text: sections[i].description,
selected: (this.selection == sections[i].secname )
} );
}
this.display.feature_dropdown.show();
this.display.feature_dropdown.update_dropdown();
},
select_none: function() {
delete this.selection;
},
select_section: function() {
var select = this.display.$('feature_select');
var option = select.options[select.selectedIndex];
this.selection = option.value;
this.event_ticket.update_choices();
},
get_masks: function() {
if ( this.selection && this.secnames[this.selection] )
return this.secnames[this.selection].masks;
return false;
},
get_selection_description: function() {
return (this.selection && this.secnames[this.selection]) ? this.secnames[this.selection].description : false;
},
get_secname_description: function( secname ) {
if ( this.secnames[secname] )
return this.secnames[secname].description;
return false;
},
mask_choices: function ( masks ) {
this.masked_sections = [];
for( var i = 0 ; i < this.sections.length ; i ++ ) {
if ( this.sections[i].masks[this.group_id] & masks[this.group_id] )
this.masked_sections.push( this.sections[i] );
}
},
reset_choices: function() {
if ( !this.choices_ready ) {
for ( var i = 0 ; i < this.sections.length ; i ++ ) {
this.display.add_feature_option( {
value: this.sections[i].secname,
text: this.sections[i].description,
selected: false
} );
}
this.display.feature_dropdown.build_options();
this.display.feature_dropdown.set_option( { value: -1, text: FeatureDisplay.not_applicable } );
this.display.feature_dropdown.set_option( { value: 0, text: FeatureDisplay.best_available } );
this.display.feature_dropdown.config.max_width = 350;
this.display.feature_dropdown.update_width();
this.choices_ready = true;
}
this.masked_sections = this.sections.clone();
},
add_section: function( section ) {
this.sections.push( {
description: section.description,
v: section.v,
masks: section.masks,
secname: section.secname
} );
this.secnames[section.secname] = this.sections[this.sections.length-1];
},
add_form_values: function( form ) {
var v = "";
if ( this.selection && this.secnames[this.selection] )
v = this.secnames[this.selection].v;
form.appendChild( new Element( 'input', { type: 'hidden', name: this.form_name, value: v } ) );
}
} );
EventTicket = Class.create( {
initialize: function( event_info ) {
this.ticket_types = [];
this.groups = [];
this.ticket_limit = event_info.ticket_limit;
this.price_limit = event_info.price_limit;
this.did = event_info.did;
this.display = new EventTicketDisplay();
if ( event_info.ticket_limit_text ) {
this.display.$('ticket_limit_info').style.display = "";
this.display.$('ticket_limit_text').innerHTML = event_info.ticket_limit_text;
}
else {
this.display.$('ticket_limit_info').style.display = "none";
}
},
has_enabled_ticket_types: function() {
var has_enabled_tts = false;
for ( var ticket_type in this.ticket_types ) {
if ( this.ticket_types[ticket_type].enabled )
return true;
}
return false;
},
reset: function() {
this.price_levels = [];
this.selected_tts = [];
var thisobj = this;
this.ticket_types.each( function( tt ) {
if ( thisobj.mapsell && thisobj.mapsell.selection ) {
tt.display.reset_selected_quantity();
}
else
delete tt.mapsell_disabled;
} );
if ( !this.mapsell || !this.mapsell.selection ) {
var has_enabled_tickets = this.has_enabled_ticket_types();
this.ticket_types.each( function( tt ) {
if ( !has_enabled_tickets ) {
var enabled = tt.enabled;
tt.set_discrete_offer();
if ( enabled != tt.enabled && tt.enabled ) {
tt.setup_ticket_type();
tt.display.attach( this.display.$( 'event_ticket_types' ) );
}
}
if ( tt.enabled ) {
tt.reset_all();
tt.update_display();
}
}, this );
this.groups.each( function( group ) {
group.select_none();
group.reset_choices();
group.update_display();
group.display.$('feature_display').style.display = "";
} );
}
this.limit_ticket_quantities();
if ( this.mastersearch )
this.mastersearch.reset();
},
validate: function() {
var errors = [];
var total_tickets = this.get_selected_quantity();
if ( total_tickets > this.ticket_limit )
errors.push( FeatureDisplay.error.ticket_limit );
var missing_qty = [];
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( tt.enabled && tt.password && tt.get_selected_quantity() == 0 && tt.display.$('offerCode').value.replace(/^\s+/,'').replace(/\s+$/,'') )
missing_qty.push ( "\t* " + tt.description );
}
if ( missing_qty.length )
errors.push( FeatureDisplay.error.select_offer_quantity + ":\n" + missing_qty.join( "\n" ) );
else if ( total_tickets == 0 )
errors.push( FeatureDisplay.error.select_quantity );
var missing_codes = [];
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( tt.enabled && tt.password && tt.get_selected_quantity() > 0 && !tt.display.$('offerCode').value.replace(/^\s+/,'').replace(/\s+$/,'') )
missing_codes.push ( "\t* " + tt.description );
}
if ( missing_codes.length )
errors.push( FeatureDisplay.error.enter_code + ":\n" + missing_codes.join( "\n" ) );
if ( errors.length ) {
window.alert( FeatureDisplay.error.please_fix + "\n\n" + errors.join( "\n" ) );
return false;
}
if ( this.mapsell && this.mapsell.selection && this.mapsell.selection.num_seats > total_tickets ) {
window.alert( FeatureDisplay.error.map_sell );
return false;
}
return true;
},
add_ticket_type: function( tt_info ) {
var tt = new TicketType( this, tt_info );
this.ticket_types.push( tt );
if ( tt.enabled )
tt.display.attach( this.display.$( 'event_ticket_types' ) );
return tt;
},
add_group: function( group_info ) {
var group = new TicketGroup( this, group_info );
this.groups.push( group );
group.display.attach( this.display.$( 'event_ticket_groups' ) );
return group;
},
add_mastersearch: function( mastersearch ) {
this.mastersearch = mastersearch;
mastersearch.attach( this.display.$('event_mastersearch') );
this.display.$('event_mastersearch').style.display = "";
},
add_mapsell: function ( mapsell ) {
this.mapsell = mapsell;
mapsell.attach( this.display.$('mapsell_box') );
},
add_aic: function ( aic ) {
this.aic = aic;
aic.attach( this.display.$('aic_box') );
},
limit_mapsell_choices: function( secnames, price_level, num_seats ) {
var descriptions = [];
var num_disabled = 0;
var seats_selected = false;
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
tt.select_price_by_secname( price_level );
tt.update_display();
if ( tt.masks || !tt.enabled ) {
tt.mapsell_disabled = true;
num_disabled ++;
}
else if ( !seats_selected && tt.enabled ) {
tt.display.set_quantity( num_seats > this.ticket_limit ? this.ticket_limit : num_seats );
seats_selected = true;
descriptions.push( tt.get_secname_description( price_level ) );
}
}
for( var g = 0 ; g < this.groups.length ; g ++ ) {
for ( var s = 0 ; s < secnames.length ; s ++ ) {
var desc = this.groups[g].get_secname_description( secnames[s] );
if ( desc )
descriptions.push( desc );
}
this.groups[g].display.$('feature_display').style.display = "none";
}
this.update_choices();
if( num_disabled == this.ticket_types.length ) {
if ( Discrete.id )
window.alert( MapSell.no_tickets_with_offer );
else
window.alert( MapSell.no_tickets_without_offer );
this.mapsell.reset();
}
return descriptions;
},
update_choices: function() {
if ( arguments[0] ) {
var tt = arguments[0];
if ( tt.get_selection_mask() != 0 ) {
if ( this.selected_tts.indexOf( tt ) == -1 ) {
this.selected_tts.push( tt );
}
}
else {
this.selected_tts = this.selected_tts.without( tt );
}
}
var selected_price_masks;
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( tt.enabled && tt.mask && tt.mask != 0 && ( !this.selected_tts.length || tt != this.selected_tts.last() ) ) {
var masks = tt.get_masks();
if ( masks )
selected_price_masks = selected_price_masks ? combine_masks( selected_price_masks, tt.get_masks() ) : tt.get_masks();
}
}
var group_masks = [];
for( var g = 0 ; g < this.groups.length ; g ++ ) {
var masks = this.groups[g].get_masks();
if ( masks ) {
for ( var gm = 0 ; gm < this.groups.length ; gm ++ ) {
if ( group_masks.length < gm + 1 )
group_masks[gm] = false;
if ( gm != g )
group_masks[gm] = group_masks[gm] ? combine_masks( group_masks[gm], masks ) : masks;
}
}
}
var price_masks;
if( selected_price_masks )
price_masks = Object.extend( {}, selected_price_masks );
if ( this.selected_tts.length ) {
var tt = this.selected_tts.last();
price_masks = price_masks ? combine_masks( price_masks, tt.get_masks() ) : tt.get_masks();
}
for( var g = 0 ; g < this.groups.length ; g ++ ) {
var masks;
if ( price_masks )
masks = group_masks[g] ? combine_masks( group_masks[g], price_masks ) : price_masks;
else
masks = group_masks[g];
if ( masks )
this.groups[g].mask_choices( masks );
else
this.groups[g].reset_choices( masks );
this.groups[g].update_display();
}
for( var g = 0 ; g < this.groups.length ; g ++ ) {
var masks = this.groups[g].get_masks();
if ( masks ) {
selected_price_masks = selected_price_masks ? combine_masks( selected_price_masks, masks ) : masks;
price_masks = price_masks ? combine_masks( price_masks, masks ) : masks;
}
}
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( !tt.enabled )
continue;
if ( this.selected_tts.length && tt == this.selected_tts.last() ) {
if ( selected_price_masks )
tt.mask_prices( selected_price_masks );
else
tt.reset_prices();
}
else if ( price_masks )
tt.mask_prices( price_masks );
else
tt.reset_prices();
tt.update_display();
}
this.limit_ticket_quantities();
},
add_form_values: function( form ) {
var price_mask;
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( !tt.enabled )
continue;
var tt_mask = tt.get_selection_mask();
if ( tt.get_selected_quantity() && tt_mask && tt_mask != 0 )
price_mask = price_mask ? price_mask & tt_mask : tt_mask;
}
this.ticket_types.each( function( tt ) {
if ( tt.enabled )
tt.add_form_values( form, price_mask );
} );
this.groups.each( function( group ) {
group.add_form_values( form );
} );
if ( this.mastersearch )
this.mastersearch.add_form_values( form );
if ( this.mapsell )
this.mapsell.add_form_values ( form );
if ( this.aic )
this.aic.add_form_values ( form );
},
get_selected_quantity: function() {
var selected_quantity = 0;
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( tt.enabled )
selected_quantity += tt.get_selected_quantity();
}
return selected_quantity;
},
get_selected_sections: function() {
var sections = [];
for( var g = 0 ; g < this.groups.length ; g ++ ) {
var desc = this.groups[g].get_selection_description();
if ( desc )
sections.push( desc );
}
return sections.length ? sections : [ FeatureDisplay.best_available ];
},
get_ticket_quantity_descriptions: function() {
var descriptions = [];
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( tt.enabled && tt.get_selected_quantity() > 0 ) {
var desc = tt.get_selected_quantity().toString() + " " + tt.display.title;
descriptions.push ( desc );
}
}
return descriptions;
},
limit_ticket_quantities: function() {
if ( this.price_limit ) {
var total_purchase = 0;
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( tt.enabled )
total_purchase += tt.get_selected_quantity() * tt.get_selected_price();
}
var to_spend = this.price_limit - total_purchase;
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( !tt.enabled )
continue;
var max = Math.floor( to_spend / tt.get_selected_price() );
var selected_quantity = this.get_selected_quantity();
var tickets_left = this.ticket_limit - selected_quantity;
if ( max > tickets_left )
max = tickets_left;
tt.limit_quantity( max + tt.get_selected_quantity() );
}
}
else {
var selected_quantity = this.get_selected_quantity();
var ticket_limit = (this.mapsell && this.mapsell.selection) ? this.mapsell.selection.num_seats : this.ticket_limit;
var max = ticket_limit - selected_quantity;
for ( var i = 0 ; i < this.ticket_types.length ; i ++ ) {
var tt = this.ticket_types[i];
if ( tt.enabled )
tt.limit_quantity( max + tt.get_selected_quantity() );
}
}
}
} );
EventNotOnsale = Class.create( Module, {
source: [ 'event_not_onsale', { inside: true, removeParent: true } ],
unique_ids: [ 'not_onsale_submit_box', 'not_onsale_create_account', 'event_not_available_text', 'system_down', 'sign_up_info' ],
initialize: function ( $super, data ) {
$super();
if ( data.system_down ) {
this.$('event_not_available_text').style.display = "none";
this.$('system_down').style.display = "";
}
else {
this.$('event_not_available_text').style.display = "";
this.$('system_down').style.display = "none";
}
if( data.create_account_link ) {
this.$('not_onsale_create_account').observe( 'click', function() {
window.location = data.create_account_link;
} );
}
else {
this.$('sign_up_info').hide();
while ( this.$('not_onsale_submit_box').hasChildNodes() )
this.$('not_onsale_submit_box').removeChild( this.$('not_onsale_submit_box').firstChild );
}
}
} );
function combine_masks( m1, m2 ) {
masks = {};
for ( var g = 1 ; g <= 4 ; g ++ )
masks[g] = m1[g] & m2[g];
return masks;
}
function merge_masks( m1, m2 ) {
masks = {};
for ( var g = 1 ; g <= 4 ; g ++ )
masks[g] = m1[g] | m2[g];
return masks;
}
