// File inputs
jQuery( function ( $ ) {

    // Teacher Skills
    $('.yolo-teacher-skills-meta-box').on('click','a.insert',function(){
        $(this).closest('.yolo-teacher-skills-meta-box').find('tbody').append( $(this).data( 'row' ) );
        return false;
    });
    $('.yolo-teacher-skills-meta-box').on('click','a.delete',function(){
        $(this).closest('tr').remove();
        return false;
    });

    $('.yolo-teacher-skills-meta-box tbody').sortable({
        items:'tr',
        cursor:'move',
        axis:'y',
        handle: 'td.sort',
        scrollSensitivity:40,
        forcePlaceholderSize: true,
        helper: 'clone',
        opacity: 0.65
    });


    // Teacher Performance
    $('.yolo-performance-meta-box').on('click','a.insert',function(){
        $(this).closest('.yolo-performance-meta-box').find('tbody').append( $(this).data( 'row' ) );
        return false;
    });
    $('.yolo-performance-meta-box').on('click','a.delete',function(){
        $(this).closest('tr').remove();
        return false;
    });

    $('.yolo-performance-meta-box tbody').sortable({
        items:'tr',
        cursor:'move',
        axis:'y',
        handle: 'td.sort',
        scrollSensitivity:40,
        forcePlaceholderSize: true,
        helper: 'clone',
        opacity: 0.65
    });

    // Event Activities
    $('.yolo-activities-meta-box').on('click','a.insert',function(){
        $(this).closest('.yolo-activities-meta-box').find('tbody').append( $(this).data( 'row' ) );
        return false;
    });
    $('.yolo-activities-meta-box').on('click','a.delete',function(){
        $(this).closest('tr').remove();
        return false;
    });

    $('.yolo-activities-meta-box tbody').sortable({
        items:'tr',
        cursor:'move',
        axis:'y',
        handle: 'td.sort',
        scrollSensitivity:40,
        forcePlaceholderSize: true,
        helper: 'clone',
        opacity: 0.65
    });

    // Course Quality
    $('.yolo-quality-meta-box').on('click','a.insert',function(){
        $(this).closest('.yolo-quality-meta-box').find('tbody').append( $(this).data( 'row' ) );
        return false;
    });
    $('.yolo-quality-meta-box').on('click','a.delete',function(){
        $(this).closest('tr').remove();
        return false;
    });

    $('.yolo-quality-meta-box tbody').sortable({
        items:'tr',
        cursor:'move',
        axis:'y',
        handle: 'td.sort',
        scrollSensitivity:40,
        forcePlaceholderSize: true,
        helper: 'clone',
        opacity: 0.65
    });
    // Course Skills
    // Teacher Skills
    $('.yolo-course-skills-meta-box').on('click','a.insert',function(){
        $(this).closest('.yolo-course-skills-meta-box').find('tbody').append( $(this).data( 'row' ) );
        return false;
    });
    $('.yolo-course-skills-meta-box').on('click','a.delete',function(){
        $(this).closest('tr').remove();
        return false;
    });

    $('.yolo-course-skills-meta-box tbody').sortable({
        items:'tr',
        cursor:'move',
        axis:'y',
        handle: 'td.sort',
        scrollSensitivity:40,
        forcePlaceholderSize: true,
        helper: 'clone',
        opacity: 0.65
    });

    // Plan Additional
    $('.yolo-additional-meta-box').on('click','a.insert',function(){
        $(this).closest('.yolo-additional-meta-box').find('tbody').append( $(this).data( 'row' ) );
        return false;
    });
    $('.yolo-additional-meta-box').on('click','a.delete',function(){
        $(this).closest('tr').remove();
        return false;
    });

    $('.yolo-additional-meta-box tbody').sortable({
        items:'tr',
        cursor:'move',
        axis:'y',
        handle: 'td.sort',
        scrollSensitivity:40,
        forcePlaceholderSize: true,
        helper: 'clone',
        opacity: 0.65
    });


    $('.yolo-attach-meta-box').on('click','a.insert-attach',function(){
        $(this).closest('.yolo-attach-meta-box').find('tbody').append( $(this).data( 'row' ) );
        return false;
    });
    $('.yolo-attach-meta-box').on('click','a.delete',function(){
        $(this).closest('tr').remove();
        return false;
    });

    $('.yolo-attach-meta-box tbody').sortable({
        items:'tr',
        cursor:'move',
        axis:'y',
        handle: 'td.sort',
        scrollSensitivity:40,
        forcePlaceholderSize: true,
        helper: 'clone',
        opacity: 0.65
    });
    
});