jQuery -> # extending getScript to include cache jQuery.cachedScript = (url, options) -> options = $.extend(options or {}, dataType: "script" cache: true url: url ) jQuery.ajax options # delete closest row for remote deletes $(".tr_remote_delete").bind "ajax:success", -> $(this).closest("tr").fadeOut() # add "first" class to first tr in tables $('#project-body').find('tr:first').addClass('first') $('#fleet-body').find('tr:first').addClass('first') $('#user-body').find('tr:first').addClass('first') $(".timeago").timeago() # enable chosen js $('.chzn-select').chosen allow_single_deselect: false no_results_text: 'No results matched' width: '250px' $('.chzn-select-deselect').chosen allow_single_deselect: true no_results_text: 'No results matched' width: '250px' $(document).on "click", ".ajaxed .pagination a", (event) -> window.history.pushState(null, "", @href) $(".pagination > ul > li.active").removeClass("active") $(this).parent().addClass("active") $.getScript(this.href) $('#project-body').html("


Loading....

"); false $(window).bind "popstate", -> $.getScript location.href return # just a popup helper $("a[data-popup]").on "click", (e) -> window.open $(this).attr("href"), "Certifications", "height=800, width=800" e.preventDefault() #wish form submit $("form#wish-form").bind "submit", (event) -> url = "/wishes" # the action to submit the wishes to. $.ajax type: "POST" url: url data: $("form#wish-form").serialize() # serializes the form's elements. $("#wish-form-div").html "
Thank you for your feedback!
" return false #prevents double submit. #used for address fields in fleets. $("#remote-add-fields").click -> $(".address-button").click() #global input masks. $(".date_mask").inputmask "d/m/y" $(".phone_mask").inputmask "(999) 999-9999", placeholder: " ", rightAlignNumerics: false $(".phone_mask_ext").inputmask "(999) 999-9999 [9999]", placeholder: " ", rightAlignNumerics: false $(".zip_mask").inputmask "99999", { rightAlignNumerics: false } $(".vin_mask").inputmask "*****************", { rightAlignNumerics: false } $(".numeric_mask").inputmask("integer", { radixPoint: ",", autoGroup: true, groupSeparator: ",", groupSize: 3, rightAlignNumerics: false }) #$(".percent_decimal_mask").inputmask "decimal", { autoGroup: true, groupSeparator: ".", groupSize: 2 } # $("[id^=edit_vehicle]").submit -> # $('#vehicle_odometer').inputmask("unmaskedvalue") # datepicker $(".followup_datepicker").datepicker format: 'mm/dd/yyyy' autoclose: true re = new RegExp(/\d\d\d\d-\d\d-\d\d/) dpg = $.fn.datepicker.DPGlobal $("input.datepicker").each -> if re.test(@value) d = dpg.parseDate(@value, dpg.parseFormat("yyyy-mm-dd")) date = d.getUTCDate() month = d.getUTCMonth() year = d.getUTCFullYear() # January = 0, Feb = 1, etc @value = (month + 1) + "/" + date + "/" + year return # help-guide menu if $('#help-guide').length $('#help-menu').toggle() $('#help-menu-divider').toggle() else $('#help-menu').hide() #Project Search $("#search-toggle").click -> $("#search-toggle").toggleClass "active" $("#project-search").slideToggle "fast"