1// If JavaScript is enabled remove 'no-js' class and give 'js' class 2jQuery('html').removeClass('no-js').addClass('js'); 3 4// Add .osx class to html if on Os/x 5if ( navigator.appVersion.indexOf("Mac")!=-1 ) 6 jQuery('html').addClass('osx'); 7 8// When DOM is fully loaded 9jQuery(document).ready(function($) { 10 11/* -------------------------------------------------------- 12 External Links 13 -------------------------------------------------------- */ 14 15 (function() { 16 $(window).load(function() { 17 $('a[rel=external]').attr('target','_blank'); 18 }); 19 })(); 20 21/* -------------------------------------------------------- 22 Tooltips 23 -------------------------------------------------------- */ 24 25 (function() { 26 $('body').tooltip({ 27 delay: { show: 300, hide: 0 }, 28 selector: '[data-toggle=tooltip]:not([disabled])' 29 }); 30 })(); 31 32/* -------------------------------------------------------- 33 Responsive Navigation 34 -------------------------------------------------------- */ 35 36 (function() { 37 38 var $mainNav = $('.navbar .nav'), 39 responsiveNav = ''; 40 41 // Responsive nav 42 $mainNav.find('li').each(function() { 43 var $this = $(this), 44 $link = $this.children('a'), 45 depth = $this.parents('ul').length - 1, 46 indent = ''; 47 48 if( depth ) { 49 while( depth > 0 ) { 50 indent += ' - '; 51 depth--; 52 } 53 } 54 55 if ($link.text()) 56 responsiveNav += '<option ' + ($this.hasClass('active') ? 'selected="selected"':'') + ' value="' + $link.attr('href') + '">' + indent + ' ' + $link.text() + '</option>'; 57 58 }).end().after('<select class="nav-responsive">' + responsiveNav + '</select>'); 59 60 $('.nav-responsive').on('change', function() { 61 window.location = $(this).val(); 62 }); 63 64 })(); 65 66/* -------------------------------------------------------- 67 Gallery 68 -------------------------------------------------------- */ 69 70 (function() { 71 $(window).load(function(){ 72 // container 73 var $container = $('#portfolio-items'); 74 function filter_projects(tag) 75 { 76 // filter projects 77 $container.isotope({ filter: tag }); 78 // clear active class 79 $('li.active').removeClass('active'); 80 // add active class to filter selector 81 $('#portfolio-filter').find("[data-filter='" + tag + "']").parent().addClass('active'); 82 // update location hash 83 if (tag!='*') 84 window.location.hash=tag.replace('.',''); 85 if (tag=='*') 86 window.location.hash=''; 87 } 88 if ($container.length) { 89 // conver data-tags to classes 90 $('.project').each(function(){ 91 $this = $(this); 92 var tags = $this.data('tags'); 93 if (tags) { 94 var classes = tags.split(','); 95 for (var i = classes.length - 1; i >= 0; i--) {
96 $this.addClass(classes[i]); 97 }; 98 } 99 }) 100 // initialize isotope 101 $container.isotope({ 102 // options... 103 itemSelector : '.project', 104 layoutMode : 'fitRows' 105 }); 106 // filter items 107 $('#portfolio-filter li a').click(function(){ 108 var selector = $(this).attr('data-filter'); 109 filter_projects(selector); 110 return false; 111 }); 112 // filter tags if location.has is available. e.g. http://example.com/work.html#design will filter projects within this category 113 if (window.location.hash!='') 114 { 115 filter_projects( '.' + window.location.hash.replace('#','') ); 116 } 117 } 118 }) 119 120 })(); 121 122/* -------------------------------------------------------- 123 Footer Contact Form 124 -------------------------------------------------------- */ 125 126 $('#send').click(function(){ // when the button is clicked the code executes 127 $('.error').fadeOut('slow'); // reset the error messages (hides them) 128 129 var error = false; // we will set this true if the form isn't valid 130 131 var name = $('input#name').val(); // get the value of the input field 132 if(name == "" || name == " " || name == "Name") { 133 $('#err-name').fadeIn('slow'); // show the error message 134 error = true; // change the error state to true 135 } 136 137 var email_compare = /^([a-z0-9_.-]+)@([da-z.-]+).([a-z.]{2,6})$/; // Syntax to compare against input 138 var email = $('input#email').val(); // get the value of the input field 139 if (email == "" || email == " " || email == "E-mail") { // check if the field is empty 140 $('#err-email').fadeIn('slow'); // error - empty 141 error = true; 142 }else if (!email_compare.test(email)) { // if it's not empty check the format against our email_compare variable 143 $('#err-emailvld').fadeIn('slow'); // error - not right format 144 error = true; 145 } 146 147 var message = $('textarea#message').val(); // get the value of the input field 148 if(message == "" || message == " " || message == "Message") { 149 $('#err-message').fadeIn('slow'); // show the error message 150 error = true; // change the error state to true 151 } 152 153 if(error == true) { 154 $('#err-form').slideDown('slow'); 155 return false; 156 } 157 158 var data_string = $('#ajax-form').serialize(); // Collect data from form 159 //alert(data_string); 160 161 $.ajax({ 162 type: "POST", 163 url: $('#ajax-form').attr('action'), 164 data: data_string, 165 timeout: 6000, 166 error: function(request,error) { 167 if (error == "timeout") { 168 $('#err-timedout').slideDown('slow'); 169 } 170 else { 171 $('#err-state').slideDown('slow'); 172 $("#err-state").html('An error occurred: ' + error + ''); 173 } 174 }, 175 success: function() { 176 //$('#ajax-form').slideUp('slow'); 177 $('#ajaxsuccess').slideDown('slow'); 178 $('#ajaxsuccess').delay(4000); 179 $('#ajaxsuccess').fadeOut(1000); 180 181 $("#name").val(''); 182 $("#email").val(''); 183 $("#message").val(''); 184 } 185 }); 186 187 return false; // stops user browser being directed to the php file 188 }); // end click function 189 190/* -------------------------------------------------------- 191 Flex Initialize 192 -------------------------------------------------------- */ 193 194$(window).load(function() { 195 $('.slider1').flexslider({ 196 animation: "slide", 197 start: function(slider){ 198 $('body').removeClass('loading'); 199 }, 200 }); 201 202 $('.slider2').flexslider({ 203 animation: "slide", 204 slideshow: false, 205 animationLoop: false 206 }); 207}); 208 209});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.