<div class="wrap">

    <div id="icon-fontbird" class="icon32"><br /></div>
    <h2>Upload fonts</h2>

    <form action="" method="POST" name="new-font">
        <ul class="form">
            <li>
                <input type="file" id="file-upload" name="font" value="" />
            </li>
        </ul>
    </form>

    <div id="uploaded-container">
        <ul style="margin: 5px" id="uploaded-file"></ul>
        <div id="queue-file"></div>
    </div>

    <script language="JavaScript" type="text/javascript">
        jQuery(document).ready(function($) {
                
            function completeUpload (event, ID, fileObj, response, data)  {
                    
                var object = jQuery.parseJSON(response);
                if (object.error) {
                    alert('Upload error: ' + object.msg);
                    return true;
                }
                $(object.msg).fadeIn('slow').appendTo('#uploaded-file');
                $.post('admin.php?page=fontbird/font&uri=fontbird/font/add', {
                    'name' : object.filename
                });
                return true;
            }

            var scriptData = {
            }

            $('#file-upload').uploadify({
                'uploader'  : '<?php echo $this->getUrl('assets/js/uploadify/uploadify.swf') ?>',
                'script'    : '<?php echo $this->getUrl('upload.php') ?>',
                'cancelImg' : '<?php echo $this->getUrl('assets/js/uploadify/cancel.png') ?>',
                //'buttonImg'    : '<?php echo $this->getUrl('assets/images/select.png') ?>',
                'buttonText'    : 'Add Fonts',
                'folder'    : 'assets/media/',
                'fileExt'    : '*.ttf;*.otf;',
                'fileDesc'    : 'Image Files',
                'sizeLimit'    : 1024 * 1000,
                'auto'      : true,
                'multi'     : true,
                'queueID' : 'queue-file',
                'fileDataName' : 'font',
                'scriptData' : scriptData,
                removeCompleted: true,
                'onComplete' : function (event, ID, fileObj, response, data)  {
                    console.log(response);
                    var object = jQuery.parseJSON(response);

                    if (object.error) {
                        alert('Upload error: ' + object.msg);
                        return true;
                    }
                    $(object.msg).fadeIn('slow').appendTo('#uploaded-file');
                    $.post('admin.php?page=fontbird/font&uri=fontbird/font/add', {
                        'name' : object.filename
                    });
                    return true;

                }
            })
        });

    </script>

    <div style="clear: both"></div>
</div>