{I" class:ETI"ProcessedAsset;FI"logical_path;TI"fae/admin.js;FI" pathname;TI"X/Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/admin.js.erb;FI"content_type;TI"application/javascript;TI" mtime;Tl+wl%UI" length;Tiv7I" digest;TI"%9eb5dc87be0a655c4fefb28f889f60bd;FI" source;TI"v7var Admin = { path: '/admin', breakpoints: { desktop: 800 }, init: function(){ var that = this; $(".datepicker input").datepicker({ dateFormat: "M dd, yy", inline: true, showOtherMonths: true, dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] }); $.dateRangePickerLanguages['custom'] = { 'selected': 'Choosed:', 'days': 'Days', 'apply': 'Close', 'week-1' : 'Mon', 'week-2' : 'Tue', 'week-3' : 'Wed', 'week-4' : 'Thu', 'week-5' : 'Fri', 'week-6' : 'Sat', 'week-7' : 'Sun', 'month-name': ['January','February','March','April','May','June','July','August','September','October','November','December'], 'previous' : 'Previous', 'prev-week' : 'Week', 'prev-month' : 'Month', 'prev-quarter' : 'Quarter', 'prev-year' : 'Year', 'less-than' : 'Date range should longer than %d days', 'more-than' : 'Date range should less than %d days', 'default-more' : 'Please select a date range longer than %d days', 'default-less' : 'Please select a date range less than %d days', 'default-range' : 'Please select a date range between %d and %d days', 'default-default': 'Please select a date' }; // daterangepicker instantiation if ($(".daterangepicker").length > 0) { $(".daterangepicker").dateRangePicker({ format: "MMM DD, YYYY", separator : ' to ', showShortcuts: false, language: 'custom', getValue: function() { if ($('.js-start_date').val() && $('.js-end_date').val() ) return $('.js-start_date').val() + ' to ' + $('.js-end_date').val(); else return ''; }, setValue: function(s,s1,s2) { $('.js-start_date').val(s1); $('.js-end_date').val(s2); } }); }; Admin.image_delete_links(); // input type=file customization $(".input.file").fileinputer({delete_class: "icon-delete_x file_input-delete"}); // make all the hint areas $(".hint").hinter(); // checkboxes customizaitons $("th.main_table-checkbox").checkboxer(); // sticket header for the content area $(".main_content-header").sticky({ offset: 0, min_desktop: true }); $("#main_nav").sticky({ offset: 0, make_placeholder: false, min_desktop: true}); // sort columns in tables if applicable $(".main_table-sort_columns").tablesorter(); $(".main_table-sort_columns-cities").tablesorter({ sortList: [[1,0]] }); // button dropdown class toggle $(".button-dropdown").click(function(){ $(this).toggleClass("button-dropdown--opened"); }); // button dropdown click anywhere but the dropdown close $("body").click(function(e){ if ($(e.target).closest(".button-dropdown").length === 0) { $(".button-dropdown").removeClass("button-dropdown--opened"); } }); // scroll_to event for non-ajax'd table forms $(".table-add-link-visible").click("on", function(){ var $parent = $(this).closest('section'); that.scroll_to($parent.find("tbody tr:last-child"), 90); }); //image modals $(".js-image-modal").click(function(e){ e.preventDefault(); var $this = $(this); // create invisi-image to get natural width/height var image = new Image(); image.src = $this.attr('src'); var image_width = image.width; var image_height = image.height; $this.modal({ minHeight: image_height, minWidth: image_width, overlayClose: true }); }); // Login page checkbox $(".login-body").on('click', 'label.boolean', function(e){ $(this).toggleClass("js-active"); }).on('click', '.input.boolean :checkbox', function(e){ e.stopPropagation(); }); // attaching click handlers to #main_content to allow ajax replacement $('#main_content') // for the yes/no slider .on('click', '.slider-wrapper', function(e){ e.preventDefault(); $(this).toggleClass("slider-yes-selected"); }) // The settings menu for tables .on('click', '.main_table-action_menu-trigger', function(e){ $(this).toggleClass("js-active"); }) // for checkboxes .on('click', '.boolean label, .checkbox_collection--vertical label, .checkbox_collection--horizontal label', function(e){ $(this).toggleClass("js-active"); }) // stop the event bubbling and running the above toggleClass twice .on('click', '.boolean :checkbox, .checkbox_collection--vertical :checkbox, .checkbox_collection--horizontal :checkbox', function(e){ e.stopPropagation(); }) // for ajax forms. gotta hijack before it's submitted for some slide up action. .on('click', '.js-addedit-form-wrapper input[type=submit]', function(e){ // e.preventDefault(); // var $form = $(this).closest('form'); // that.scroll_to($(this).closest('.js-addedit-form')); // $(this).closest('.js-addedit-form-wrapper').slideUp(function(){ // $form.submit(); // that.sortable(); // }); }); // Run through the checkboxes and see if they are checked. apply js class for styling. $('.boolean label, .checkbox_collection--vertical label, .checkbox_collection--horizontal label').each(function(){ if ($(this).find(":checkbox:checked").length > 0) { $(this).addClass("js-active"); } }); // utility nav drop down $('.utility_nav-user > a, .utility_nav-view > a').on('click', function(e) { e.preventDefault(); e.stopPropagation(); var $sub_nav = $(this); // there could be more than one. so remove all of the clicked statuses and add to the specific one $('.utility_nav-clicked').removeClass('utility_nav-clicked'); $sub_nav.addClass('utility_nav-clicked'); // assign a once function to close the menus $(document).on('click.utility_nav', function(e){ // as long as the click is not in the menu if ($(e.target).closest('.utility_sub_nav').length === 0) { // remove the class from the utility nav $sub_nav.removeClass('utility_nav-clicked'); // unbind the click from the document, no need to keep it around. $(document).off('click.utility_nav'); } }); }); // initialize modal for markdown-hint $('.markdown-support').click(function(){ var markdown_hint_width = $('.markdown-hint').width() + 40; $('.markdown-hint-wrapper').modal({ minHeight: 430, minWidth: markdown_hint_width, overlayClose: true, zIndex: 1100 }); }); this.sortable(); this.fade_notices(); this.city_district_selector(); this.slugger(); this.ad_form.init(); this.selects(); this.detect_cancelled_urls(); this.add_cancel_param(); }, sortable: function() { //Make table Sortable by user $(".main_content-sortable").sortable({ items: "tbody tr", opacity: 0.8, handle: (".main_content-sortable-handle"), //helper funciton to preserve the width of the table row helper: function(e, tr) { var $originals = tr.children(); var $helper = tr.clone(); var $ths = $(tr).closest("table").find("th"); $helper.children().each(function(index) { // Set helper cell sizes to match the original sizes $(this).width($originals.eq(index).width()); //set the THs width so they don't go collapsey $ths.eq(index).width($ths.eq(index).width()); }); return $helper; }, // on stop, set the THs back to no inline width for repsonsivity stop: function(e, ui) { $(ui.item).closest("table").find("th").css("width", ""); }, update: function() { var $this = $(this); var serial = $this.sortable('serialize'); var object = serial.substr(0, serial.indexOf('[')); $.ajax({ url: Admin.path+'/sort/'+object, type: 'post', data: serial, dataType: 'script', complete: function(request){ // sort complete messaging can go here } }); } }).disableSelection(); }, //ajax image delete links image_delete_links: function() { $('.imageDeleteLink').click(function(e) { e.preventDefault(); if (confirm('Are you sure you want to delete this image?')) { $.post($(this).attr('href'),'html'); $(this).parent().next().show(); $(this).parent().hide(); } }); }, scroller: function(elm) { if (location.pathname.replace(/^\//,'') == elm.pathname.replace(/^\//,'') && location.hostname == elm.hostname) { var target = $(elm.hash); target = target.length ? target : $("[name=" + elm.hash.slice(1) + "]"); if (target.length) { var newScrollTop = target.offset().top - 116; $("html, body").animate({ scrollTop: newScrollTop }, 500); return false; } } }, scroll_to: function(to_elm, adjustment) { if (typeof adjustment == 'undefined') { // set the default adjustment adjustment = 130; } $('html, body').animate({ scrollTop: $(to_elm).offset().top - adjustment }, 500); }, fade_notices: function() { $('.notice, .alert, .error').not('.input .error').delay(3000).slideUp('fast'); }, city_district_selector: function() { var $city_select = $('.js-city-selector'); var $district_select_wrap = $('.js-district-selector'); $district_select_wrap.hide(); Admin.update_district_select($district_select_wrap, $city_select.val()); $city_select.on('change', function() { Admin.update_district_select($district_select_wrap, $city_select.val()); }); }, update_district_select: function($district_select_wrap, city_id) { var $city_options = $district_select_wrap.find('option[data-city='+city_id+']'); if (city_id && $city_options.length) { $district_select_wrap.find('option:not(:first)').addClass('chosen-hide'); $city_options.removeClass('chosen-hide'); $district_select_wrap.find('select').trigger("chosen:updated"); // $district_select_wrap.find('span.error').remove(); $district_select_wrap.fadeIn('fast'); } else { $district_select_wrap.fadeOut('fast'); } }, slugger: function() { var slug_text = null; var $slug = $('.slug'); if ($slug.val() !== '') { $('.slugger').removeClass('slugger'); } $('.slugger').keyup(function(){ slug_text = Admin.digest_slug(); $slug.val(slug_text); }); }, digest_slug: function() { var $slug = $('.slugger'); var slug_text = [] $slug.each(function() { if ($(this).val().length > 0) { slug_text.push($(this).val()); } }) slug_text = slug_text.join(' ').toLowerCase().replace(/\\|\'/g,'').replace(/[^a-zA-Z0-9]+/g,'-').replace(/(^-)|(-$)/g, ""); return slug_text; }, ad_form: { init: function() { if ($('#new_ad, .edit_ad').length) { Admin.ad_form.$type_select = $('#ad_ad_type_id'); Admin.ad_form.$ad_fields = $('div.ad-fields-wrapper'); Admin.ad_form.toggle_fields(0); Admin.ad_form.$type_select.change(function() { Admin.ad_form.toggle_fields(200); }); } }, toggle_fields: function(fade_speed) { if (Admin.ad_form.$type_select.val() == '') { Admin.ad_form.$ad_fields.hide(); } else { Admin.ad_form.$ad_fields.fadeOut(fade_speed, function() { $('div[data-types]').hide(); $('div[data-types~='+Admin.ad_form.$type_select.val()+'], div[data-types=all]').show(); Admin.ad_form.$ad_fields.fadeIn(fade_speed); }); } }, $type_select: '', $ad_fields: '' }, selects: function() { var availableItemsStr = " Available Items"; var addedItemsStr = " Added Items"; $("select").each(function(index, elm){ var $select = $(this); if($select.hasClass("multiselect")) { $select.multiSelect({ selectableHeader: "
", selectionHeader: "
" }); var selectableCount = $select.next('.ms-container').find('.ms-selectable li').not('.ms-selected').length var selectedCount = $select.next('.ms-container').find('.ms-selection .ms-selected').length; $('.ms-selectable .custom-header').text(selectableCount + availableItemsStr); $('.ms-selection .custom-header').text(selectedCount + addedItemsStr); } else { $select.fae_chosen(); } }); var $selectable = $('.ms-selectable .custom-header'); var $selection = $('.ms-selection .custom-header'); $('.ms-selectable li').on('click', function(){ $selectable.text(parseInt($selectable.text()) -1 + availableItemsStr); $selection.text(parseInt($selection.text()) +1 + addedItemsStr); }); $('.ms-selection li').on('click', function(){ $selectable.text(parseInt($selectable.text()) + 1 + availableItemsStr); $selection.text(parseInt($selection.text()) -1 + addedItemsStr); }) }, detect_cancelled_urls: function() { var params = window.location.search; if (params.length > 0 && params.toLowerCase().indexOf("cancelled") >= 0 && params.indexOf("&") !== 0) { window.history.replaceState(null, null, window.location.pathname); }; }, add_cancel_param: function() { var update_cancel = function () { var $cancel_btn = $('#main_content-header-save-cancel'); var new_href = $cancel_btn.attr('href') + '?cancelled=true'; $cancel_btn.attr('href', new_href); $('form').off('change', 'input, textarea, select', update_cancel); } $('form').on('change', 'input, textarea, select', update_cancel); } }; $(function() { FaeNavigation.init(); Accordion.init(); Admin.init(); AjaxForms.init(); SubnavHighlighter.init(); Validator.init(); }); ;TI"dependency_digest;TI"%b1639a0b66244a8614522262c5f02da2;FI"required_paths;T[I"X/Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/admin.js.erb;FI"dependency_paths;T[{I" path;TI"X/Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/admin.js.erb;FI" mtime;TI"2015-04-08T10:59:19-07:00;TI" digest;TI"%27a56bea0d2cbff99cc06d9e7693e45a;FI" _version;TI"%64e62ddc273c2f5847f30d698ca14b67;F