+++ /dev/null
-$(function(){
-
- var showForm = function() {
- $('#add-note-form').show();
- $('#add-note-btn').hide();
- };
- var hideForm = function() {
- $('#add-note-form').hide();
- $('#add-note-btn').show();
- };
-
- // some but not all validation happens here
- var validateAndSubmit = function() {
- var year = $('#id_year').val()
- if (year.match(/\d{4}/) || year === '') {
- $('form#add-note').submit();
- } else {
- $("#id_year").css({'background-color': '#f05a28'});
- console.log('Date is invalid');
- };
- };
-
- // check if we arrived at this page planning on uploading a note
- if(window.location.hash) {
-
- // Get the first hash, remove the # character
- var hash = window.location.hash.substring(1);
- if (hash === 'upload-note'){
- showForm();
- }
- }
-
- $('#add-note-btn').click(function(){
- // hide the thankyou message on add-another uploads
- $('#thankyou-wrapper').hide();
- showForm();
- // Bring up the file picker automatically
- $('input#file_upload_input').click();
- // disable the save button -- it will be enabled when the upload is complete
- $('#save-btn').addClass('disabled');
- });
-
-
- // Dismiss x click
- $(".icon-remove-sign").click(function() {
- hideForm();
- });
-
- var uploader = new qq.FileUploader( {
- action: ajax_upload_url, // added to page via template var
- element: $('#file-uploader')[0],
- multiple: false,
-
- onSubmit: function (id, fileName) {
- $('#file-uploader').hide();
- $('div.upload-status').show();
- // hide the button added by qq
- $('#file-uploader').hide();
- // show the progress bar
- $('div.upload-status').show();
- console.log('fileName:', fileName);
- },
- onError: function (id, fileName, errorReason) {
- console.log('FileUploader error:', errorReason);
- },
- onCancel: function (id, fileName) {
- console.log('FileUploader cancel:', onCancel);
- },
- onComplete: function( id, fileName, responseJSON ) {
- if( responseJSON.success ) {
- console.log("responseJSON.note_url " + responseJSON.note_url);
- // activate the form for submitting
- $('form#add-note').attr('action', responseJSON.note_url);
- // inform the user of success
- $('#add-note-status').text('Uploaded');
- // activate the save button
- $('#save-btn').removeClass('disabled');
- // add a click handler to submit the add-note form
- $('#save-btn').click(function(){
- validateAndSubmit();
- });
- }
- },
- onAllComplete: function( uploads ) {
- // uploads is an array of maps
- // the maps look like this: { file: FileObject, response: JSONServerResponse }
- console.log( "All complete!" );
- },
- onProgress: function(id, fileName, loaded, total) {
- console.log("running onProgress " + fileName + " " + loaded);
- console.log(String((100*loaded/total)+'%'));
- // Animate the progress bar
- $('#progress-fill').animate({
- width: String((100*loaded/total)+'%')}, 200);
- // fill out the filename
- $('#filename').text(fileName);
- $('#id_name').attr('placeholder', fileName);
- },
- params: {
- 'csrf_token': csrf_token,
- 'csrf_name': 'csrfmiddlewaretoken',
- 'csrf_xname': 'X-CSRFToken',
- 'course_id': courseId, // added to page via template var
- },
- }) ;
-});
+++ /dev/null
-<!-- This file is obsolete now that we have added the filepicker partial -->
-
-{% load url from future %}
-{% include 'partial/opentip.html' %}
-<section id=add-note-form class="extend-form">
- <script>
- var ajax_upload_url = "{% url 'ajax_upload' %}";
- //var csrf_token = "{{ csrf_token }}";
- </script>
-
- <form id=add-note class="dropzone" method="POST">
- {% csrf_token %}
-
- <div class="row">
- <div class="small-8 small-offset-1 columns large-4 large-offset-1 upload-status" style="display:none">
- <legend><span id=add-note-status>Uploading</span> <span id=filename>note</span>...</legend>
- <div class=progress> <div id="progress-fill"></div> </div>
- </div>
- <div id=file-uploader class="small-8 small-offset-1 columns large-4 large-offset-1">
- <!-- the upload button gets attached here -->
- </div>
-
- <div class="small-2 columns large-1">
- <!-- TODO: only show after file selected-->
- <i class="icon-remove-sign awesome-action"></i>
- </div>
-
- <div id="drpbx-btn" class="small-2 columns large-1 end"
- data-ot="Upload directly from Dropbox"
- data-ot-target="true"
- data-ot-tip-joint="top center"
- data-ot-target-joint="bottom center"
- data-ot-background="white"
- data-ot-border-color="black" >
- <i class="icon-dropbox icon-2x"></i>
-
- <input type="text" class="hidden" id="id_drpbxURL" name="dropbxURL" style="display: none"/>
- </div>
-
-
- </div>
- <div class="row">
- <div class="small-10 small-offset-1 columns large-8 large-offset-1">
- <legend>Title of Note <small class="form">* Required</small></legend>
- <input type="text" class="intext" id="id_name" name="name"
- placeholder="ENG 102 - Chaucer to Shakespeare">
- </div>
- <div class="small-10 small-offset-1 columns large-2 large-offset-0 end">
- <legend>Academic Year</legend>
- <input type="text" class="" id="id_year" name="year"
- placeholder="2013"> {# FIXME: fill in with current year #}
- </div>
- </div>
- <div class="row">
- <div class="small-10 small-offset-1 columns large-8 large-offset-1">
- <legend>Tags (comma seperated)</legend>
- <input type="text" id="id_tags" name="tags" class="taggit-tags"
- placeholder="Chaucer, Shakespeare, literature, review">
- </div>
- </div>
-
- <div class="row">
- <div class="small-8 small-offset-1 columns large-4 small-centered">
- <div id="save-btn" class="disabled">
- <i class=icon-save></i> Save
- </div>
- </div>
- </div>
-
-
- </form> <!-- #upload_form -->
- {% include 'partial/dropbox_support.html' %}
-</section>