Learn how to use jQuery at the Blog

Thomas Aull « visit

  • Added 9 months ago
  • 143 Lines of Code shown
  • 2 Links of Interest
http://thomas-aull.de
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to Thomas Aull - http://thomas-aull.de

// jQuery
var $j = jQuery.noConflict();

$j(document).ready(function() {
   
   // --------------
   //  CSS FIXES
   // --------------
   
   $j(".commentlist li div p:last-child").css("margin-bottom", "0");
   $j(".blog_element .the_content p:last-child").css("margin-bottom", "0");
   
   
   // ----------------------------
   //  KONTAKTFORMULAR KONTAKT
   // ----------------------------
   
	var validator = $j("#kontaktformular").validate({
		rules: {
			name: {
				required: true,
				minlength: 2
			},
			email: {
				required: true,
				email: true
			},
			nachricht: "required"
		},
		messages: {
			name: {
				required: "Bitte geben Sie ihren Namen an",
				minlength: "Bitte geben sie mind. 2 Zeichen ein"
			},
			email: {
				required: "Bitte geben Sie eine eMail-Adresse ein",
				email: "Diese eMail-Adresse ist ungültig"
			},
			nachricht: "Bitte geben Sie eine Nachricht ein"
		},
		submitHandler: function(form) {
			// do other stuff for a valid form
			senden(form);
		},
		errorElement: 'span',
		errorPlacement: function(error, element) {
			error.appendTo(element.next());
		},
		//wrapper: 'div class="error"'
		success: "valid"
		/*success: function(label) {
			label.addClass("valid");
		}*/
	});
   
   function senden(formular) {
		var eingaben = [];
		$j(':input', formular).each(function() {
			eingaben.push(this.name + '=' + escape(this.value));
		});
		jQuery.ajax({
			type:"POST",
			data: eingaben.join('&'),
			url: formular.action, 
			timeout: 2000,
			error: function() {
				console.log("Senden fehlgeschlagen");
			},
			success: function(k) {
				$j('#kontaktformular .label_nachricht').prepend('<span id="nachricht_verschickt">' + k + ' - <a href="#">neue Nachricht</a></span>');
				$j('#kontaktformular .label_nachricht span#nachricht_verschickt').hide().fadeIn();
				$j('#kontaktformular .label_nachricht a').click(reset);
			}
		});
		return false;
   };
   
   function reset(evt) {
   		evt.preventDefault()
   		validator.resetForm();
   		$j('#kontaktformular :input').val('');
   		$j('#kontaktformular .label_nachricht span#nachricht_verschickt').remove();
   }
   
   
   
   // ----------------------------
   //  KOMMENTAR FORMULAR
   // ----------------------------
   
   	$j("#commentform").validate({
		rules: {
			author: {
				required: true,
				minlength: 2
			},
			email: {
				required: true,
				email: true
			},
			comment: "required"
		},
		messages: {
			author: {
				required: "Bitte geben Sie ihren Namen an",
				minlength: "Bitte geben sie mind. 2 Zeichen ein"
			},
			email: {
				required: "Die eMail-Adresse fehlt",
				email: "ungültige eMail-Adresse"
			},
			comment: "Bitte geben Sie eine Nachricht ein"
		},
		submitHandler: function(form) {
			// do other stuff for a valid form
			form.submit();
		},
		errorElement: 'span',
		errorPlacement: function(error, element) {
			error.appendTo(element.next());
		},
		//wrapper: 'div class="error"'
		success: "valid"
		/*success: function(label) {
			label.addClass("valid");
		}*/
	});
   
 });



		$j(document).ready(function() {
			$j("#buttons277").jFlow({
				slides: "#portfolioBilder277",
				controller: ".jFlowControl", // must be class, use . sign
				slideWrapper : "#portfolioBildContainer277", // must be id, use # sign
				selectedWrapper: "aktiv",  // just pure text, no sign
				width: "474px",
				height: "354px",
				duration: 300
			});					
		 });