<commit_before>/*
 * fixmystreet.js
 * FixMyStreet JavaScript
 */

function form_category_onchange() {
    var cat = $('#form_category');
    var args = {
        category: cat.val()
    };

    if ( typeof fixmystreet !== 'undefined' ) {
        args.latitude = fixmystreet.latitude;
        args.longitude = fixmystreet.longitude;
    } else {
        args.latitude = $('input[name="latitude"]').val();
        args.longitude = $('input[name="longitude"]').val();
    }

    $.getJSON('/report/new/category_extras', args, function(data) {
        if ( data.category_extra ) {
            if ( $('#category_meta').size() ) {
                $('#category_meta').html( data.category_extra);
            } else {
                $('#form_category_row').after( data.category_extra );
            }
        } else {
            $('#category_meta').empty();
        }
    });
}

/*
 * general height fixing function
 *
 * elem1: element to check against
 * elem2: target element
 * offest: this will be added (if present) to the final value, useful for height errors
 */
function heightFix(elem1, elem2, offset){
    var h1 = $(elem1).height(),
        h2 = $(elem2).height();
    if(offset === undefined){
        offset = 0;
    }
    if(h1 > h2){
        $(elem2).css({'min-height':h1+offset});
    }
}


/*
 * very simple tab function
 *
 * elem: trigger element, must have an href attribute (so probably needs to be an <a>)
 */
function tabs(elem)
{
    var href = elem.attr('href');
    //stupid IE sometimes adds the full uri into the href attr, so trim
    var start = href.indexOf('#'),
        target = href.slice(start, href.length);

    if(!$(target).hasClass('open'))
    {
        //toggle class on nav
        $('.tab-nav .active').removeClass('active');
        elem.addClass('active');
 
        //hide / show the right tab
        $('.tab.open').hide().removeClass('open');
        $(target).show().addClass('open');
    }
}


$(function(){
    $('html').removeClass('no-js').addClass('js');

    //add mobile class if small screen
    if(Modernizr.mq('only screen and (max-width:48em)')) {
        $('html').addClass('mobile');
// XXX Make map full screen here?
//        if (fixmystreet.page == 'around') {
//            $('#map_box').css({
//                height: $(window).height(),
//                margin: 0
//            });
//        }
    } else {
        // Make map full screen on non-mobile sizes.
        var map_pos = 'fixed', map_height = '100%';
        if ($('html').hasClass('ie6')) {
            map_pos = 'absolute';
            map_height = $(window).height();
        }
        $('#map_box').prependTo('.wrapper').css({
            zIndex: 0, position: map_pos,
            top: 0, left: 0, right: 0, bottom: 0,
            width: '100%', height: map_height,
            margin: 0
        }).data('size', 'full');
    }

    //heightfix the desktop .content div
    if(Modernizr.mq('only screen and (min-width:48em)')) {
        if (!($('body').hasClass('frontpage'))){
            heightFix(window, '.content', -176);
        }
    }

    $('#pc').focus();

    $('input[type=submit]').removeAttr('disabled');
    /*
    $('#mapForm').submit(function() {<commit_msg>For #258, immediately go full screen map on mobile around page.<commit_after>/*
 * fixmystreet.js
 * FixMyStreet JavaScript
 */

function form_category_onchange() {
    var cat = $('#form_category');
    var args = {
        category: cat.val()
    };

    if ( typeof fixmystreet !== 'undefined' ) {
        args.latitude = fixmystreet.latitude;
        args.longitude = fixmystreet.longitude;
    } else {
        args.latitude = $('input[name="latitude"]').val();
        args.longitude = $('input[name="longitude"]').val();
    }

    $.getJSON('/report/new/category_extras', args, function(data) {
        if ( data.category_extra ) {
            if ( $('#category_meta').size() ) {
                $('#category_meta').html( data.category_extra);
            } else {
                $('#form_category_row').after( data.category_extra );
            }
        } else {
            $('#category_meta').empty();
        }
    });
}

/*
 * general height fixing function
 *
 * elem1: element to check against
 * elem2: target element
 * offest: this will be added (if present) to the final value, useful for height errors
 */
function heightFix(elem1, elem2, offset){
    var h1 = $(elem1).height(),
        h2 = $(elem2).height();
    if(offset === undefined){
        offset = 0;
    }
    if(h1 > h2){
        $(elem2).css({'min-height':h1+offset});
    }
}


/*
 * very simple tab function
 *
 * elem: trigger element, must have an href attribute (so probably needs to be an <a>)
 */
function tabs(elem)
{
    var href = elem.attr('href');
    //stupid IE sometimes adds the full uri into the href attr, so trim
    var start = href.indexOf('#'),
        target = href.slice(start, href.length);

    if(!$(target).hasClass('open'))
    {
        //toggle class on nav
        $('.tab-nav .active').removeClass('active');
        elem.addClass('active');
 
        //hide / show the right tab
        $('.tab.open').hide().removeClass('open');
        $(target).show().addClass('open');
    }
}


$(function(){
    $('html').removeClass('no-js').addClass('js');

    //add mobile class if small screen
    if(Modernizr.mq('only screen and (max-width:48em)')) {
        $('html').addClass('mobile');
        if (fixmystreet.page == 'around') {
            // Immediately go full screen map if on around page
            $('#site-header').hide();
            $('#map_box').prependTo('.wrapper').css({
                height: $(window).height(),
                margin: 0
            });
        }
    } else {
        // Make map full screen on non-mobile sizes.
        var map_pos = 'fixed', map_height = '100%';
        if ($('html').hasClass('ie6')) {
            map_pos = 'absolute';
            map_height = $(window).height();
        }
        $('#map_box').prependTo('.wrapper').css({
            zIndex: 0, position: map_pos,
            top: 0, left: 0, right: 0, bottom: 0,
            width: '100%', height: map_height,
            margin: 0
        }).data('size', 'full');
    }

    //heightfix the desktop .content div
    if(Modernizr.mq('only screen and (min-width:48em)')) {
        if (!($('body').hasClass('frontpage'))){
            heightFix(window, '.content', -176);
        }
    }

    $('#pc').focus();

    $('input[type=submit]').removeAttr('disabled');
    /*
    $('#mapForm').submit(function() {
{'fraction_non_alphanumeric': 0.1793577981651376, 'fraction_numerical': 0.010856269113149847, 'mean_word_length': 2.1783284742468414, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3856049', 'n_tokens_mistral': 2021, 'n_tokens_neox': 1941, 'n_words': 464}