<commit_before>if(!tc){ var tc = {}; }
if(!tc.gam){ tc.gam = {}; }

tc.gam.ideas_invite = function(app,elements) {
	// Invite
	elements.bind('click',{
		app:app,
		source_element:tc.jQ('.modal-content.invite-user'),
		init:function(modal,event_target,callback){
			var modal_merlin;
			modal_merlin = new tc.merlin(app,{
				name:'ideas_invite',
				dom:modal.options.element.find('.invite-user'),
				next_button: tc.jQ('a.submit'),
				first_step: 'invite-message-project-info',
				data:{
					project_id: null,
					idea_id: null,
					message: null
				},
				steps:{
					'invite-message-project-info':{
						selector:'.invite-message-project-info',
						next_step:'invite-message-info',
						inputs:{
							project_radios:{
								selector:'.project-radio'
							}
						},
						init: function(merlin, dom) {
							var name;
							
							if(dom.find('.project-radio').length == 1){
								dom.find('.project-radio').first().attr('checked',true);
								window.location.hash = 'ideas_invite,invite-message-info';
							}
							
							name = tc.jQ(event_target).attr("href").split(",")[2];
							if (name) {
								dom.find(".no-name").hide();
								dom.find(".name").text(name);
							} else {
								dom.find(".has-name").hide();
							}
							
							dom.find('input[type=checkbox],input[type=radio]').prettyCheckboxes();
							
						},
						finish: function(merlin, dom) {
							if(!merlin.current_step.inputs.project_radios.dom.filter(":checked").length){
								merlin.options.data.project_id = null;
								return false;
							}
							merlin.options.data = tc.jQ.extend(merlin.options.data, {
								project_id: merlin.current_step.inputs.project_radios.dom.filter(":checked").attr("rel").split(",")[1]
							});
							
							return true;
						}
					},
					'invite-message-info':{
						selector:'.invite-message-info',
						next_step:'invite-message-submit',
						inputs:{
							invite_message:{
								selector:'textarea.invite-message',
								validators:['max-200'],
								counter:{
									selector:'.charlimit.invite-message',
									limit:200
								}
							}
						},
						init:function(merlin,dom){
							var name;
							
							if(!merlin.options.data.project_id){
								window.location.hash = 'ideas_invite,invite-message-project-info'
							}
							
							name = tc.jQ(event_target).attr("href").split(",")[2];
							if (name) {
								dom.find(".no-name").hide();
								dom.find(".name").text(name);
							} else {
								dom.find(".has-name").hide();
							}
							
						},
						finish: function(merlin, dom) {
							merlin.options.data = tc.jQ.extend(merlin.options.data, {
								idea_id: tc.jQ(event_target).attr("href").split(",")[1],
								message: merlin.current_step.inputs.invite_message.dom.val()
							});
						}
					},
					'invite-message-submit':{
						selector:'.invite-message-submit',
						init: function(merlin, dom) {
							tc.jQ.ajax({
								type:"POST",
								url:"/project/invite",
								data:merlin.options.data,
								context:merlin,
								dataType:"text",
								success: function(data, ts, xhr) {
									if (data == "False") {
										window.location.hash = "ideas_invite,invite-message-error";
										return false;
									}
									tc.jQ(event_target).addClass("disabled").text("Invited").unbind("click").bind("click", function(e) {
										e.preventDefault();
									});
									tc.timer(1000, function() {
										modal.hide();
									});
								}
							});
						}
					},
					"invite-message-error": {
						selector:".invite-message-error",
						init: function(merlin, dom) {
							tc.timer(1000, function() {
								modal.hide();
							});
						}
					}
				}
			});
			
			modal.cleanup = function() {
				modal_merlin.deallocate_magic();
			};
			
			if(tc.jQ.isFunction(callback)){<commit_msg>fixed invite bugs on search page (#1596)<commit_after>if(!tc){ var tc = {}; }
if(!tc.gam){ tc.gam = {}; }

tc.gam.ideas_invite = function(app,elements) {
	// Invite
	elements.bind('click',{
		app:app,
		source_element:tc.jQ('.modal-content.invite-user'),
		init:function(modal,event_target,callback){
			var modal_merlin;
			modal_merlin = new tc.merlin(app,{
				use_hashchange: false,
				name:'ideas_invite',
				dom:modal.options.element.find('.invite-user'),
				next_button: tc.jQ('a.submit'),
				first_step: 'invite-message-project-info',
				data:{
					project_id: null,
					idea_id: null,
					message: null
				},
				steps:{
					'invite-message-project-info':{
						selector:'.invite-message-project-info',
						next_step:'invite-message-info',
						inputs:{
							project_radios:{
								selector:'.project-radio'
							}
						},
						init: function(merlin, dom) {
							var name;
							
							if(dom.find('.project-radio').length == 1){
								dom.find('.project-radio').first().attr('checked',true);
								merlin.show_step("invite-message-info");
								return;
							}
							
							name = tc.jQ(event_target).attr("href").split(",")[2];
							if (name) {
								dom.find(".no-name").hide();
								dom.find(".name").text(name);
							} else {
								dom.find(".has-name").hide();
							}
							
							dom.find('input[type=checkbox],input[type=radio]').prettyCheckboxes();
							
						},
						finish: function(merlin, dom) {
							if(!merlin.current_step.inputs.project_radios.dom.filter(":checked").length){
								merlin.options.data.project_id = null;
								return false;
							}
							merlin.options.data = tc.jQ.extend(merlin.options.data, {
								project_id: merlin.current_step.inputs.project_radios.dom.filter(":checked").attr("rel").split(",")[1]
							});
							
							return true;
						}
					},
					'invite-message-info':{
						selector:'.invite-message-info',
						next_step:'invite-message-submit',
						inputs:{
							invite_message:{
								selector:'textarea.invite-message',
								validators:['max-200'],
								counter:{
									selector:'.charlimit.invite-message',
									limit:200
								}
							}
						},
						init:function(merlin,dom){
							var name;
							
							if(!merlin.options.data.project_id){
								merlin.show_step("invite-message-project-info");
								return;
							}
							
							name = tc.jQ(event_target).attr("href").split(",")[2];
							if (name) {
								dom.find(".no-name").hide();
								dom.find(".name").text(name);
							} else {
								dom.find(".has-name").hide();
							}
							
						},
						finish: function(merlin, dom) {
							merlin.options.data = tc.jQ.extend(merlin.options.data, {
								idea_id: tc.jQ(event_target).attr("href").split(",")[1],
								message: merlin.current_step.inputs.invite_message.dom.val()
							});
						}
					},
					'invite-message-submit':{
						selector:'.invite-message-submit',
						init: function(merlin, dom) {
							tc.jQ.ajax({
								type:"POST",
								url:"/project/invite",
								data:merlin.options.data,
								context:merlin,
								dataType:"text",
								success: function(data, ts, xhr) {
									if (data == "False") {
										merlin.show_step("invite-message-error");
										return false;
									}
									tc.jQ(event_target).addClass("disabled").text("Invited").unbind("click").bind("click", function(e) {
										e.preventDefault();
									});
									tc.timer(1000, function() {
										modal.hide();
									});
								}
							});
						}
					},
					"invite-message-error": {
						selector:".invite-message-error",
						init: function(merlin, dom) {
							tc.timer(1000, function() {
								modal.hide();
							});
						}
					}
				}
			});
			
			modal.cleanup = function() {
				modal_merlin.deallocate_magic();
			};
			
			if(tc.jQ.isFunction(callback)){
{'fraction_non_alphanumeric': 0.17483597066769588, 'fraction_numerical': 0.005403319181783096, 'mean_word_length': 2.0996810207336525, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3846547', 'n_tokens_mistral': 4023, 'n_tokens_neox': 2533, 'n_words': 292}