<commit_before>
CMSForm = Class.extend('ChangeTracker').extend('Observable');
CMSForm.prototype = {
	initialize : function(fn) {
		this.ChangeTracker.initialize();
		this.formName = fn;
		this.prepareForm();
	},
	
	/**
	 * Trigger normal save event, helpful e.g. when enter key is pressed in
	 * single line input fields.
	 */
	onsubmit: function(e) {
		this.save();
		
		Event.stop(e);
		return false;
	},
	
	/**
	 * Processing called whenever a page is loaded in the right - including the initial one
	 */
	prepareForm : function() {
		ajaxActionsAtTop(this.id, 'form_actions_' + this.formName, this.formName);
		
		// Update the nav items down the bottom
		if($('AjaxSwitchView')) {
			$('SwitchView').innerHTML = $('AjaxSwitchView').innerHTML;
			$('AjaxSwitchView').innerHTML = '';
			Behaviour.apply('SwitchView'); // This is needed so calendar still works
		}
	},
	
	/**
	 * Load actions from a string containing the HTML content
	 */
	loadActionsFromString : function(actionHTML) {
		var actionHolder = $('form_actions_' + this.formName);
		actionHolder.innerHTML = actionHTML;
		prepareAjaxActions(actionHolder, this.id, this.formName);
	},

	/**
	 * Close the form down without any corrective action, after its been deleted.
	 */
	closeIfSetTo: function(id) {
		if(this.elements.ID && this.elements.ID.value == id) {
    		// Note: TinyMCE coupling
			tinymce_removeAll();<commit_msg>BUGFIX Checking for existence of $('SwitchView') (fixes #5282)<commit_after>
CMSForm = Class.extend('ChangeTracker').extend('Observable');
CMSForm.prototype = {
	initialize : function(fn) {
		this.ChangeTracker.initialize();
		this.formName = fn;
		this.prepareForm();
	},
	
	/**
	 * Trigger normal save event, helpful e.g. when enter key is pressed in
	 * single line input fields.
	 */
	onsubmit: function(e) {
		this.save();
		
		Event.stop(e);
		return false;
	},
	
	/**
	 * Processing called whenever a page is loaded in the right - including the initial one
	 */
	prepareForm : function() {
		ajaxActionsAtTop(this.id, 'form_actions_' + this.formName, this.formName);
		
		// Update the nav items down the bottom
		if($('SwitchView') && $('AjaxSwitchView')) {
			$('SwitchView').innerHTML = $('AjaxSwitchView').innerHTML;
			$('AjaxSwitchView').innerHTML = '';
			Behaviour.apply('SwitchView'); // This is needed so calendar still works
		}
	},
	
	/**
	 * Load actions from a string containing the HTML content
	 */
	loadActionsFromString : function(actionHTML) {
		var actionHolder = $('form_actions_' + this.formName);
		actionHolder.innerHTML = actionHTML;
		prepareAjaxActions(actionHolder, this.id, this.formName);
	},

	/**
	 * Close the form down without any corrective action, after its been deleted.
	 */
	closeIfSetTo: function(id) {
		if(this.elements.ID && this.elements.ID.value == id) {
    		// Note: TinyMCE coupling
			tinymce_removeAll();
{'fraction_non_alphanumeric': 0.13830532212885155, 'fraction_numerical': 0.0014005602240896359, 'mean_word_length': 3.8423728813559324, 'pattern_counts': {'":': 0, '<': 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': '4715720', 'n_tokens_mistral': 967, 'n_tokens_neox': 856, 'n_words': 231}