Created
June 4, 2014 01:55
-
-
Save ckahle33/f3f80342a04c2a4e8920 to your computer and use it in GitHub Desktop.
landworks js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Author:Craig Kahle 2014 | |
| */ | |
| // initialize bxslider | |
| $(document).ready(function(){ | |
| $(".bxslider").bxSlider({ | |
| speed: 500, | |
| controls: false, | |
| auto: true, | |
| infiniteLoop: true, | |
| onSliderLoad: function(){ | |
| $(".bx-wrapper").css("visibility", "visible"); | |
| } | |
| }); | |
| }); | |
| //search results button | |
| $(function(){ | |
| var submit = $('.results-search .search-submit'); | |
| submit.html('Search'); | |
| }); | |
| //Bind readmore/less links with the plus icon - careers | |
| $(function(){ | |
| $('.readmore-toggle').on('click', function(event) { | |
| var toggle = $(this.parentNode.parentNode.parentNode).find('.js-toggle'); | |
| if (event.target === toggle[0]) { | |
| return false; | |
| } | |
| toggle.trigger('click'); | |
| return false; | |
| }); | |
| }); | |
| //Bind readmore/less links with the plus icon -contact | |
| $(function(){ | |
| $('.readmore-toggle').on('click', function(event) { | |
| var toggle = $(this.parentNode.parentNode.parentNode).find('.js-toggle-contact'); | |
| if (event.target === toggle[0]) { | |
| return false; | |
| } | |
| toggle.trigger('click'); | |
| return false; | |
| }); | |
| }); | |
| //Career information sliding around by toggling a class | |
| $(function(){ | |
| function resizer(id, height) { | |
| if (id.hasClass("active")) { | |
| id.animate({height: height}, 400); | |
| //$($(this).parent().find(".careerbox")).animate({width: '600px'}, 500); | |
| $(".js-careerDesc", id).animate({width: '500px'}, 200); | |
| $(".js-careerReqs", id).animate({margin: '40px 0 0 0'}, 900); | |
| } else { | |
| id.animate({height: '100px'}, 400); | |
| $(".js-careerDesc", id).animate({width: '800px'}, 200); | |
| $(".js-careerReqs", id).animate({margin: '200px 0 0 0'}, 200); | |
| } | |
| } | |
| $('.js-toggle').on('click', function(event) { | |
| //icon animation | |
| var el; | |
| el = $(this).find("span"); | |
| if (el.hasClass("expanded")) { | |
| el.removeClass("expanded").addClass("collapsed"); | |
| } else { | |
| el.removeClass("collapsed").addClass("expanded"); | |
| } | |
| event.preventDefault(); | |
| //hiding the readmore text | |
| $(this.parentNode.parentNode).find('.body-text').toggleClass('hide'); | |
| // console.log($(this).contents().find('.body-text')); | |
| var careerID = $(this).data('career'); | |
| var career = $("#"+careerID); | |
| career.toggleClass("active"); | |
| var careerID = $(this).data('career'); | |
| var career = $("#"+careerID); | |
| var height = $(this.parentNode.parentNode).find(".js-getHeight").height(); | |
| var fulltext = $(this.parentNode.parentNode).find('.body-text-full').height(); | |
| //get the height of narrower text element | |
| var bodyFull = $(this.parentNode.parentNode).find('.body-text-full'); | |
| bodyFull.css('width', '500px'); | |
| trueHeight = bodyFull.height(); | |
| // console.log(trueHeight); | |
| bodyFull.css('width', 'auto'); | |
| resizer(career, trueHeight + 250); | |
| // resizer(contact, trueHeight + 250); | |
| event.preventDefault(); | |
| }); | |
| }); | |
| (function() { | |
| $(".js-toggle-contact").on("click", function(event) { | |
| var el; | |
| el = $(this).find("span"); | |
| if (el.hasClass("expanded")) { | |
| el.removeClass("expanded").addClass("collapsed"); | |
| } else { | |
| el.removeClass("collapsed").addClass("expanded"); | |
| } | |
| event.preventDefault(); | |
| }); | |
| }).call(this); | |
| (function() { | |
| //Search bar sliding script | |
| button = $("#logo-nav button.search-submit"); | |
| // inputCheck(); | |
| button.on('click', function(event){ | |
| topnav = $("#topnav"); | |
| form = $("#logo-nav form.search-form.form-inline"); | |
| //if class is blue or value is not empty | |
| if (form.hasClass('blue') && input.val() !== '') { | |
| button.submit(); | |
| // return true; | |
| // alert('thisfarthar') | |
| } else { | |
| event.preventDefault(); | |
| event.stopPropagation(); | |
| input.animate({width: "161px"}, 500); | |
| topnav.animate({margin: "40px 0 0 0px"}, 500); | |
| form.addClass('blue'); | |
| input.focus(); | |
| } | |
| }); | |
| var input = $("#logo-nav .search-field.form-control"); | |
| input.on('click', function(){ | |
| input.focusout(function(){ | |
| input.stop(); | |
| topnav.stop(); | |
| input.animate({width: "0"}, 500); | |
| topnav.animate({margin: "40px 0 0 155px"}, 500); | |
| form.removeClass('blue'); | |
| }); | |
| }); | |
| // }); | |
| // if (input.val() == '') { | |
| // } | |
| //script to make all dropdown li's links to child a tag | |
| $(".dropdown-menu li").on('click', function(){ | |
| window.location=$(this).find("a").attr("href"); | |
| return false; | |
| }); | |
| //Tertiary slide toggle bars | |
| var featurestext = $(".features-text"); | |
| var featurestitle = $(".features-title"); | |
| var benefitstext = $(".benefits-text"); | |
| var benefitstitle = $(".benefits-title"); | |
| var advantagestext = $(".advantages-text"); | |
| var advantagestitle = $(".advantages-title"); | |
| featurestitle.on('click', function() { | |
| featurestext.slideToggle(); | |
| $(this).toggleClass('active'); | |
| }); | |
| benefitstitle.on('click', function() { | |
| benefitstext.slideToggle(); | |
| $(this).toggleClass('active'); | |
| }); | |
| advantagestitle.on('click', function() { | |
| advantagestext.slideToggle(); | |
| $(this).toggleClass('active'); | |
| }); | |
| })(jQuery); | |
| //based on isotope docs | |
| $(window).load(function(){ | |
| var $container; | |
| var filters = {}; | |
| $(function(){ | |
| $container = $('#container'); | |
| var $filterDisplay = $('#filter-display'); | |
| $container.isotope(); | |
| // do stuff when checkbox change | |
| $('#options').on( 'change', function( jQEvent ) { | |
| var $checkbox = $( jQEvent.target ); | |
| manageCheckbox( $checkbox ); | |
| var comboFilter = getComboFilter( filters ); | |
| $container.isotope({ filter: comboFilter }); | |
| $filterDisplay.text( comboFilter ); | |
| }); | |
| $('#options2').on( 'change', function( jQEvent ) { | |
| var $checkbox = $( jQEvent.target ); | |
| manageCheckbox( $checkbox ); | |
| var comboFilter = getComboFilter( filters ); | |
| $container.isotope({ filter: comboFilter }); | |
| $filterDisplay.text( comboFilter ); | |
| }); | |
| }); | |
| //a codepen Dave Desandro made(isotope creator) for using groups of checkboxes. | |
| function getComboFilter( filters ) { | |
| var i = 0; | |
| var comboFilters = []; | |
| var message = []; | |
| for ( var prop in filters ) { | |
| message.push( filters[ prop ].join(' ') ); | |
| var filterGroup = filters[ prop ]; | |
| // skip to next filter group if it doesn't have any values | |
| if ( !filterGroup.length ) { | |
| continue; | |
| } | |
| if ( i === 0 ) { | |
| // copy to new array | |
| comboFilters = filterGroup.slice(0); | |
| } else { | |
| var filterSelectors = []; | |
| // copy to fresh array | |
| var groupCombo = comboFilters.slice(0); // [ A, B ] | |
| // merge filter Groups | |
| for (var k=0, len3 = filterGroup.length; k < len3; k++) { | |
| for (var j=0, len2 = groupCombo.length; j < len2; j++) { | |
| filterSelectors.push( groupCombo[j] + filterGroup[k] ); // [ 1, 2 ] | |
| } | |
| } | |
| // apply filter selectors to combo filters for next group | |
| comboFilters = filterSelectors; | |
| } | |
| i++; | |
| } | |
| var comboFilter = comboFilters.join(', '); | |
| return comboFilter; | |
| } | |
| function manageCheckbox( $checkbox ) { | |
| var checkbox = $checkbox[0]; | |
| var group = $checkbox.parents('.option-set').attr('data-group'); | |
| // create array for filter group, if not there yet | |
| var filterGroup = filters[ group ]; | |
| if ( !filterGroup ) { | |
| filterGroup = filters[ group ] = []; | |
| } | |
| var isAll = $checkbox.hasClass('all'); | |
| // reset filter group if the all box was checked | |
| if ( isAll ) { | |
| delete filters[ group ]; | |
| if ( !checkbox.checked ) { | |
| checkbox.checked = 'checked'; | |
| } | |
| } | |
| // index of | |
| var index = $.inArray( checkbox.value, filterGroup ); | |
| if ( checkbox.checked ) { | |
| var selector = isAll ? 'input' : 'input.all'; | |
| $checkbox.siblings( selector ).removeAttr('checked'); | |
| if ( !isAll && index === -1 ) { | |
| // add filter to group | |
| filters[ group ].push( checkbox.value ); | |
| } | |
| } else if ( !isAll ) { | |
| // remove filter from group | |
| filters[ group ].splice( index, 1 ); | |
| // if unchecked the last box, check the all | |
| if ( !$checkbox.siblings('[checked]').length ) { | |
| $checkbox.siblings('input.all').attr('checked', 'checked'); | |
| } | |
| } | |
| } | |
| }); | |
| //isotope checkbox dropdown toggle | |
| $(function(){ | |
| var productTitle = $(".product-box .title"); | |
| var industryTitle = $(".industry-box .title"); | |
| var selectbox1 = $(".select-box-inner1"); | |
| var selectbox2 = $(".select-box-inner2"); | |
| productTitle.on('click', function(){ | |
| selectbox1.slideToggle(); | |
| productTitle.toggleClass('active'); | |
| }); | |
| industryTitle.on('click', function(){ | |
| selectbox2.slideToggle(); | |
| industryTitle.toggleClass('active'); | |
| }); | |
| }); | |
| //End Isotope stuff | |
| //Homepage image hover effects with text overlay | |
| $(function(){ | |
| $('.img').on({ mouseenter: function(){ | |
| $(this).find('.text-overlay').css("display", "block"); }, | |
| mouseleave: function() { | |
| $(this).find('.text-overlay').css("display", "none"); | |
| } | |
| }); | |
| }); | |
| //script that changes default file input to an image | |
| $(document).ready(function() { | |
| $('input[type=file]').each(function(){ | |
| var input = $(this); | |
| input.parent().append($('<div class="fakefile '+input.attr('id')+'" />').append($('<a class="file" href="#">Chose File</a>' + '<span class="italic">No File Chosen</span>'))); | |
| var fakefile = $('.fakefile.'+input.attr('id')); | |
| var fakefileSpan = $('.fakefile.'+input.attr('id')+' span'); | |
| fakefile.on('click', function(e){ | |
| input.click(); | |
| e.preventDefault(); | |
| }); | |
| input.on('change',function(){ | |
| fakefileSpan.html(this.value.replace("C:\\fakepath\\", " ")); | |
| if ($(this).find('.italic').text() !== 'No File Chosen') { | |
| $(this.parentNode.parentNode).find('.file').css('background', '#e0e0e0'); | |
| $(this.parentNode.parentNode).find('.file').text('Remove File'); | |
| } | |
| input.on('change', function(){ | |
| $(this.parentNode.parentNode).find('.file').css('background', '#bbc064'); | |
| $(this.parentNode.parentNode).find('.file').text('Choose File'); | |
| $(this.parentNode.parentNode).find('.italic').text('No File Chosen'); | |
| }); | |
| }); | |
| }); | |
| }); | |
| //plus toggle icon - careers | |
| $(function(){ | |
| $('.js-toggle-contact').on('click', function(event) { | |
| var contactbox = $(this).closest('.contactbox'); | |
| contactbox.toggleClass('active'); | |
| if (contactbox.hasClass('active')) { | |
| contactbox.animate({'height' : '500px'}); | |
| } else { | |
| contactbox.animate({'height' : '100px'}); | |
| } | |
| }); | |
| }); | |
| //Search text for search page button | |
| $(function(){ | |
| var button = $('#search-meta .search-submit'); | |
| button.html('Search'); | |
| }); | |
| //adding 'X' to career modal | |
| $(function(){ | |
| var careerForm = $('#careerForm'); | |
| // alert(careerForm.has('blue').text()); | |
| if ($('.gform_confirmation_message_1').is(':visible')) { | |
| // alert('passed'); | |
| careerForm.prepend('<a href="#" class="closeForm" onclick="history.back()"><img src="/assets/img/close.png"></a>'); | |
| $('.blue-career').css('display', 'none'); | |
| } else if (careerForm.has('#gform_submit_button_1')) { | |
| careerForm.stop(); | |
| } | |
| $('.closeForm').on('click', function(e){ | |
| // careerForm.css('display', 'none'); | |
| e.preventDefault }); | |
| }); | |
| $('.dropdown-toggle').on({ | |
| mouseenter: function () { | |
| var parent = $(this).parent(); | |
| $('.dropdown-menu', parent).addClass('dropdown-menu-zindex'); | |
| }, | |
| mouseleave: function () { | |
| var parent = $(this).parent(); | |
| $('.dropdown-menu', parent).removeClass('dropdown-menu-zindex'); | |
| } | |
| }); | |
| $('.dropdown-menu').on({ | |
| mouseenter: function () { | |
| var parent = $(this).parent(); | |
| $('.dropdown-menu', parent).addClass('dropdown-menu-zindex'); | |
| }, | |
| mouseleave: function () { | |
| var parent = $(this).parent(); | |
| $('.dropdown-menu', parent).removeClass('dropdown-menu-zindex'); | |
| } | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment