Permalink
Browse files

overwritten with changes from maik

  • Loading branch information...
1 parent 6ba5b0b commit 473b35b1295c32f184b541aac2a328cef7246902 @stefanfoulis committed Jun 23, 2009
View
246 image_filer/media/image_filer/js/jquery.uploadify-v1.6.2/jquery.uploadify (Source).js
@@ -0,0 +1,246 @@
+/*
+Uploadify v1.6.2
+Copyright (C) 2009 by Ronnie Garcia
+Co-developed by Travis Nickels
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+var flashVer = -1;
+if (navigator.plugins != null && navigator.plugins.length > 0) {
+ if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
+ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+ var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+ var descArray = flashDescription.split(" ");
+ var tempArrayMajor = descArray[2].split(".");
+ var versionMajor = tempArrayMajor[0];
+ var versionMinor = tempArrayMajor[1];
+ var versionRevision = descArray[3];
+ if (versionRevision == "") {
+ versionRevision = descArray[4];
+ }
+ if (versionRevision[0] == "d") {
+ versionRevision = versionRevision.substring(1);
+ } else if (versionRevision[0] == "r") {
+ ersionRevision = versionRevision.substring(1);
+ if (versionRevision.indexOf("d") > 0) {
+ versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
+ }
+ }
+ var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
+ }
+} else if ( $.browser.msie ) {
+ var version;
+ var axo;
+ var e;
+ try {
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+ flashVer = version.replace("WIN ","").replace(",",".");
+}
+flashVer = flashVer.split(".")[0];
+
+if(jQuery)(
+ function($){
+ $.extend($.fn,{
+ fileUpload:function(options) {
+ if (flashVer >= 9) {
+ $(this).each(function(){
+ settings = $.extend({
+ uploader: 'uploader.swf',
+ script: 'uploader.php',
+ folder: '',
+ height: 30,
+ width: 110,
+ cancelImg: 'cancel.png',
+ wmode: 'opaque',
+ scriptAccess: 'sameDomain',
+ fileDataName: 'Filedata',
+ displayData: 'percentage',
+ onInit: function() {},
+ onSelect: function() {},
+ onCheck: function() {},
+ onCancel: function() {},
+ onError: function() {},
+ onProgress: function() {},
+ onComplete: function() {}
+ }, options);
+ var pagePath = location.pathname;
+ pagePath = pagePath.split('/');
+ pagePath.pop();
+ pagePath = pagePath.join('/') + '/';
+ var data = '&pagepath=' + pagePath;
+ if (settings.buttonImg) data += '&buttonImg=' + escape(settings.buttonImg);
+ if (settings.buttonText) data += '&buttonText=' + escape(settings.buttonText);
+ if (settings.rollover) data += '&rollover=true';
+ data += '&script=' + settings.script;
+ data += '&folder=' + escape(settings.folder);
+ if (settings.scriptData) {
+ var scriptDataString = '';
+ for (var name in settings.scriptData) {
+ scriptDataString += '&' + name + '=' + settings.scriptData[name];
+ }
+ data += '&scriptData=' + escape(scriptDataString);
+ }
+ data += '&btnWidth=' + settings.width;
+ data += '&btnHeight=' + settings.height;
+ data += '&wmode=' + settings.wmode;
+ if (settings.hideButton) data += '&hideButton=true';
+ if (settings.fileDesc) data += '&fileDesc=' + settings.fileDesc + '&fileExt=' + settings.fileExt;
+ if (settings.multi) data += '&multi=true';
+ if (settings.auto) data += '&auto=true';
+ if (settings.sizeLimit) data += '&sizeLimit=' + settings.sizeLimit;
+ if (settings.simUploadLimit) data += '&simUploadLimit=' + settings.simUploadLimit;
+ if (settings.checkScript) data += '&checkScript=' + settings.checkScript;
+ if (settings.fileDataName) data += '&fileDataName=' + settings.fileDataName;
+ if ($.browser.msie) {
+ flashElement = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + settings.width + '" height="' + settings.height + '" id="' + $(this).attr("id") + 'Uploader" class="fileUploaderBtn">\
+ <param name="movie" value="' + settings.uploader + '?fileUploadID=' + $(this).attr("id") + data + '" />\
+ <param name="quality" value="high" />\
+ <param name="wmode" value="' + settings.wmode + '" />\
+ <param name="allowScriptAccess" value="' + settings.scriptAccess + '">\
+ <param name="swfversion" value="9.0.0.0" />\
+ </object>';
+ } else {
+ flashElement = '<embed src="' + settings.uploader + '?fileUploadID=' + $(this).attr("id") + data + '" quality="high" width="' + settings.width + '" height="' + settings.height + '" id="' + $(this).attr("id") + 'Uploader" class="fileUploaderBtn" name="' + $(this).attr("id") + 'Uploader" allowScriptAccess="' + settings.scriptAccess + '" wmode="' + settings.wmode + '" type="application/x-shockwave-flash" />';
+ }
+ if (settings.onInit() !== false) {
+ $(this).css('display','none');
+ if ($.browser.msie) {
+ $(this).after('<div id="' + $(this).attr("id") + 'Uploader"></div>');
+ document.getElementById($(this).attr("id") + 'Uploader').outerHTML = flashElement;
+ } else {
+ $(this).after(flashElement);
+ }
+ $("#" + $(this).attr('id') + "Uploader").after('<div id="' + $(this).attr('id') + 'Queue" class="fileUploadQueue"></div>');
+ }
+ $(this).bind("rfuSelect", {'action': settings.onSelect}, function(event, queueID, fileObj) {
+ if (event.data.action(event, queueID, fileObj) !== false) {
+ var byteSize = Math.round(fileObj.size / 1024 * 100) * .01;
+ var suffix = 'KB';
+ if (byteSize > 1000) {
+ byteSize = Math.round(byteSize *.001 * 100) * .01;
+ suffix = 'MB';
+ }
+ var sizeParts = byteSize.toString().split('.');
+ if (sizeParts.length > 1) {
+ byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2);
+ } else {
+ byteSize = sizeParts[0];
+ }
+ if (fileObj.name.length > 20) {
+ fileName = fileObj.name.substr(0,20) + '...';
+ } else {
+ fileName = fileObj.name;
+ }
+ $('#' + $(this).attr('id') + 'Queue').append('<div id="' + $(this).attr('id') + queueID + '" class="fileUploadQueueItem">\
+ <div class="cancel">\
+ <a href="javascript:$(\'#' + $(this).attr('id') + '\').fileUploadCancel(\'' + queueID + '\')"><img src="' + settings.cancelImg + '" border="0" /></a>\
+ </div>\
+ <span class="fileName">' + fileName + ' (' + byteSize + suffix + ')</span><span class="percentage">&nbsp;</span>\
+ <div class="fileUploadProgress" style="width: 100%;">\
+ <div id="' + $(this).attr('id') + queueID + 'ProgressBar" class="fileUploadProgressBar" style="width: 1px; height: 3px;"></div>\
+ </div>\
+ </div>');
+ }
+ });
+ if (typeof(settings.onSelectOnce) == 'function') {
+ $(this).bind("rfuSelectOnce", settings.onSelectOnce);
+ }
+ $(this).bind("rfuCheckExist", {'action': settings.onCheck}, function(event, checkScript, fileQueue, folder, single) {
+ var postData = new Object();
+ postData.folder = pagePath + folder;
+ for (var queueID in fileQueue) {
+ postData[queueID] = fileQueue[queueID];
+ if (single) {
+ var singleFileID = queueID;
+ }
+ }
+ $.post(checkScript, postData, function(data) {
+ for(var key in data) {
+ if (event.data.action(event, checkScript, fileQueue, folder, single) !== false) {
+ var replaceFile = confirm('Do you want to replace the file \'' + data[key] + '\'?');
+ if (!replaceFile) {
+ document.getElementById($(event.target).attr('id') + 'Uploader').cancelFileUpload(key);
+ }
+ }
+ }
+ if (single) {
+ document.getElementById($(event.target).attr('id') + 'Uploader').startFileUpload(singleFileID, true);
+ } else {
+ document.getElementById($(event.target).attr('id') + 'Uploader').startFileUpload(null, true);
+ }
+ }, "json");
+ });
+ $(this).bind("rfuCancel", {'action': settings.onCancel}, function(event, queueID, fileObj, data) {
+ if (event.data.action(event, queueID, fileObj, data) !== false) {
+ $("#" + $(this).attr('id') + queueID).fadeOut(250, function() { $("#" + $(this).attr('id') + queueID).remove()});
+ }
+ });
+ $(this).bind("rfuClearQueue", {'action': settings.onClearQueue}, function() {
+ if (event.data.action() !== false) {
+ $('#' + $(this).attr('id') + 'Queue').contents().fadeOut(250, function() {$('#' + $(this).attr('id') + 'Queue').empty()});
+ }
+ });
+ $(this).bind("rfuError", {'action': settings.onError}, function(event, queueID, fileObj, errorObj) {
+ if (event.data.action(event, queueID, fileObj, errorObj) !== false) {
+ $("#" + $(this).attr('id') + queueID + " .fileName").text(errorObj.type + " Error - " + fileObj.name);
+ $("#" + $(this).attr('id') + queueID).css({'border': '3px solid #FBCBBC', 'background-color': '#FDE5DD'});
+ }
+ });
+ $(this).bind("rfuProgress", {'action': settings.onProgress, 'toDisplay': settings.displayData}, function(event, queueID, fileObj, data) {
+ if (event.data.action(event, queueID, fileObj, data) !== false) {
+ $("#" + $(this).attr('id') + queueID + "ProgressBar").css('width', data.percentage + '%');
+ if (event.data.toDisplay == 'percentage') displayData = ' - ' + data.percentage + '%';
+ if (event.data.toDisplay == 'speed') displayData = ' - ' + data.speed + 'KB/s';
+ if (event.data.toDisplay == null) displayData = ' ';
+ $("#" + $(this).attr('id') + queueID + " .percentage").text(displayData);
+ }
+ });
+ $(this).bind("rfuComplete", {'action': settings.onComplete}, function(event, queueID, fileObj, response, data) {
+ if (event.data.action(event, queueID, fileObj, unescape(response), data) !== false) {
+ $("#" + $(this).attr('id') + queueID).fadeOut(250, function() { $("#" + $(this).attr('id') + queueID).remove()});
+ $("#" + $(this).attr('id') + queueID + " .percentage").text(' - Completed');
+ }
+ });
+ if (typeof(settings.onAllComplete) == 'function') {
+ $(this).bind("rfuAllComplete", settings.onAllComplete);
+ }
+ });
+ }
+ },
+ fileUploadSettings:function(settingName, settingValue) {
+ $(this).each(function() {
+ document.getElementById($(this).attr('id') + 'Uploader').updateSettings(settingName,settingValue);
+ });
+ },
+ fileUploadStart:function(queueID) {
+ $(this).each(function() {
+ document.getElementById($(this).attr('id') + 'Uploader').startFileUpload(queueID, false);
+ });
+ },
+ fileUploadCancel:function(queueID) {
+ $(this).each(function() {
+ document.getElementById($(this).attr('id') + 'Uploader').cancelFileUpload(queueID);
+ });
+ },
+ fileUploadClearQueue:function() {
+ $(this).each(function() {
+ document.getElementById($(this).attr('id') + 'Uploader').clearFileUploadQueue();
+ });
+ }
+ })
+})(jQuery);
View
34 image_filer/templates/image_filer/directory_listing.html
@@ -16,38 +16,7 @@
table thead th.thumbHeader {
width: 52px;
}
- #fileUploadFakeLink {
- position: relative;
-
- }
- #fileInputUploaderContainer {
- position: absolute;
- top:0;
- left: -8px;
- }
- #fileInputUploader {
- }
- .fileUploadQueueItem .fileUploadProgress .fileUploadProgressBar {
- background-color: black;
- }
- .loadingThumb {
- width: 32px;
- height: 32px;
- background-image: url({{ MEDIA_URL }}image_filer/img/loading_animation.gif);
- background-repeat:no-repeat;
-
- }
-
-
</style>
-{# upload stuff #}
-<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
-{# <script type="text/javascript" src="/media/image_filer/js/jquery.uploadify-v1.6.2/jquery-1.3.2.min.js"></script> #}
-<script type="text/javascript" src="/media/image_filer/js/jquery.uploadify-v1.6.2/jquery.uploadify.modified.js"></script>
-<script src="http://dev.jquery.com/view/tags/ui/latest/ui/effects.core.js"></script>
-<script src="http://dev.jquery.com/view/tags/ui/latest/ui/effects.highlight.js"></script>
-<script type="text/javascript" src="/media/image_filer/js/jquery.cookie.js"></script>
-
{% endblock %}
{% block coltype %}colMS{% endblock %}
@@ -81,8 +50,7 @@
<div id="content-main">
<ul class="object-tools">
{% if folder.can_have_subfolders %}<li><a id="id_new_folder" href="{% url image_filer-directory_listing-make_root_folder %}?parent_id={{ folder.id }}" class="addlink" onclick="return showAddAnotherPopup(this);">{% trans "New Folder" %}</a>{% endif %}</li>
- {% comment %}<li><a id="id_upload_files" href="{% url image_filer-upload %}" class="addlink" onclick="return showAddAnotherPopup(this);">{% trans "Upload" %}</a></li>{% endcomment %}
- <li>{% include "image_filer/include/upload_button.html" %}</li>
+ <li><a id="id_upload_files" href="{% url image_filer-upload %}" class="addlink" onclick="return showAddAnotherPopup(this);">{% trans "Upload" %}</a></li>
<li><a id="id_directory_root" href="{% url image_filer-directory_listing-root %}{% if is_popup %}?_popup=1{% endif %}" class="link">Root</a></li>
<li><a id="id_missing_data_images" href="{% url image_filer-directory_listing-images_with_missing_data %}{% if is_popup %}?_popup=1{% endif %}" class="link">Incomplete Images</a></li>
<li><a id="id_unfiled_images" href="{% url image_filer-directory_listing-unfiled_images %}{% if is_popup %}?_popup=1{% endif %}" class="link">Unfiled Images</a></li>
View
14 image_filer/templates/image_filer/include/clipboard.html
@@ -1,14 +1,18 @@
{% load thumbnail %}
{% for clipboard in user.clipboards.all %}
-<table style="width: 100%; border: 1px solid #DDDDDD;" class="clipboard">
+<table style="width: 100%; border: 1px solid #DDDDDD;">
<thead>
<th colspan=3>Clipboard</th>
</thead>
- <tbody id="fileInputQueue" class="fileUploadQueue">{% if clipboard.files.count %}{% with clipboard.files.all as items %}
- {% include "image_filer/include/clipboard_item_rows.html" %}
- {% endwith %}
+ <tbody>{% if clipboard.files.count %}{% for item in clipboard.files.all %}
+ <tr>
+ <td><img src="{{ item.file.extra_thumbnails.admin_clipboard_icon }}" alt="{{ item.default_alt_text }}" /></td>
+ <td>{{ item.label }}</td>
+ <td></td>
+ </tr>
+ {% endfor %}
{% else %}
- <tr class="noItemsRow">
+ <tr>
<td colspan=3 style="color: gray;text-align: center; height: 48px; vertical-align: middle;">the clipboard is empty</td>
</tr>
{% endif %}
View
245 image_filer/templates/image_filer/include/upload_dialog.html
@@ -0,0 +1,245 @@
+<style>
+#selectFilesLink a, #uploadFilesLink a, #clearFilesLink a {
+ color: #0000CC;
+ background-color: #FFFFFF;
+}
+
+#selectFilesLink a:visited, #uploadFilesLink a:visited, #clearFilesLink a:visited {
+ color: #0000CC;
+ background-color: #FFFFFF;
+}
+
+#uploadFilesLink a:hover, #clearFilesLink a:hover {
+ color: #FFFFFF;
+ background-color: #000000;
+}
+</style>
+
+<div id="uploadDialog" style="visibility: hidden;">
+ <div class="hd">File Upload</div>
+ <div class="bd">
+
+ <div id="uiElements" style="display:inline;">
+ <div id="uploaderContainer">
+ <div id="uploaderOverlay" style="position:absolute; z-index:2"></div>
+ <div id="selectFilesLink" style="z-index:1"><a id="selectLink" href="#">Select Files</a></div>
+ </div>
+ </div>
+
+ <div id="simUploads"> Number of simultaneous uploads:
+ <select id="simulUploads">
+ <option value="1">1</option>
+ <option value="2">2</option>
+ <option value="3">3</option>
+ <option value="4">4</option>
+ </select>
+ </div>
+
+ <div id="dataTableContainer"></div>
+ </div>
+ <div class="ft">foot</div>
+</div>
+
+<script type="text/javascript">
+ function initUploadDialog() {
+ var handleCancel = function() {
+ this.cancel();
+ }
+ var handleUpload = function() {
+ upload();
+ }
+ var onSuccess = function() {
+ //window.location=".";
+ }
+ var myButtons = [ { text: "Upload Files", handler: handleUpload, isDefault: true },
+ { text: "Cancel", handler: handleCancel} ];
+ YAHOO.log("starting upload dialog load");
+ var uploadDialog = new YAHOO.widget.Dialog("uploadDialog");
+ uploadDialog.cfg.queueProperty("buttons", myButtons);
+ uploadDialog.callback.success = onSuccess;
+ function showUploadDialog() {
+ uploadDialog.render();
+ uploadDialog.show();
+ }
+
+
+ YAHOO.log("upload dialog loaded");
+
+ YAHOO.util.Event.addListener("uploadButton", "click", showUploadDialog);
+
+ };
+ YAHOO.log("about to add the event thing");
+ YAHOO.util.Event.onDOMReady(initUploadDialog);
+</script>
+
+<script type="text/javascript">
+
+YAHOO.util.Event.onDOMReady(function () {
+ var uiLayer = YAHOO.util.Dom.getRegion('selectLink');
+ var overlay = YAHOO.util.Dom.get('uploaderOverlay');
+ YAHOO.util.Dom.setStyle(overlay, 'width', uiLayer.right-uiLayer.left + "px");
+ YAHOO.util.Dom.setStyle(overlay, 'height', uiLayer.bottom-uiLayer.top + "px");
+});
+
+ // Custom URL for the uploader swf file (same folder).
+ YAHOO.widget.Uploader.SWFURL = "/media/frameworks/uploader.swf";
+
+ // Instantiate the uploader and write it to its placeholder div.
+ var uploader = new YAHOO.widget.Uploader( "uploaderOverlay" );
+
+ // Add event listeners to various events on the uploader.
+ // Methods on the uploader should only be called once the
+ // contentReady event has fired.
+
+ uploader.addListener('contentReady', handleContentReady);
+ uploader.addListener('fileSelect', onFileSelect)
+ uploader.addListener('uploadStart', onUploadStart);
+ uploader.addListener('uploadProgress', onUploadProgress);
+ uploader.addListener('uploadCancel', onUploadCancel);
+ uploader.addListener('uploadComplete', onUploadComplete);
+ uploader.addListener('uploadCompleteData', onUploadResponse);
+ uploader.addListener('uploadError', onUploadError);
+ uploader.addListener('rollOver', handleRollOver);
+ uploader.addListener('rollOut', handleRollOut);
+ uploader.addListener('click', handleClick);
+
+ // Variable for holding the filelist.
+ var fileList;
+
+ // When the mouse rolls over the uploader, this function
+ // is called in response to the rollOver event.
+ // It changes the appearance of the UI element below the Flash overlay.
+ function handleRollOver () {
+ YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'color', "#FFFFFF");
+ YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'background-color', "#000000");
+ }
+
+ // On rollOut event, this function is called, which changes the appearance of the
+ // UI element below the Flash layer back to its original state.
+ function handleRollOut () {
+ YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'color', "#0000CC");
+ YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'background-color', "#FFFFFF");
+ }
+
+ // When the Flash layer is clicked, the "Browse" dialog is invoked.
+ // The click event handler allows you to do something else if you need to.
+ function handleClick () {
+ }
+
+ // When contentReady event is fired, you can call methods on the uploader.
+ function handleContentReady () {
+ // Allows the uploader to send log messages to trace, as well as to YAHOO.log
+ uploader.setAllowLogging(true);
+
+ // Allows multiple file selection in "Browse" dialog.
+ uploader.setAllowMultipleFiles(true);
+
+ // New set of file filters.
+ var ff = new Array({description:"Images", extensions:"*.jpg;*.png;*.gif"},
+ //{description:"Videos", extensions:"*.avi;*.mov;*.mpg"},
+ {description:"Archives", extensions:"*.zip;*.gz"}
+ );
+
+ // Apply new set of file filters to the uploader.
+ uploader.setFileFilters(ff);
+ }
+
+ // Actually uploads the files. In this case,
+ // uploadAll() is used for automated queueing and upload
+ // of all files on the list.
+ // You can manage the queue on your own and use "upload" instead,
+ // if you need to modify the properties of the request for each
+ // individual file.
+ function upload() {
+ YAHOO.log("upload initiated");
+ YAHOO.log("")
+ if (fileList != null) {
+ YAHOO.log("upload initiated: fileList is not nul");
+ uploader.setSimUploadLimit(parseInt(document.getElementById("simulUploads").value));
+ var docCookie = YAHOO.util.Cookie.get("sessionid");
+ uploader.uploadAll("{% if folder.id %}{% url image_filer-upload folder.id %}{% else %}{% url image_filer-upload %}{% endif %}", "POST", {cookieVar:docCookie }, "Filedata");
+ }
+ }
+
+ // Fired when the user selects files in the "Browse" dialog
+ // and clicks "Ok".
+ function onFileSelect(event) {
+ YAHOO.log("onFileSelect fired" + event.fileList);
+ if('fileList' in event && event.fileList != null) {
+ YAHOO.log("onFileSelect fired inside");
+ fileList = event.fileList;
+ createDataTable(fileList);
+ }
+ }
+
+ function createDataTable(entries) {
+ rowCounter = 0;
+ this.fileIdHash = {};
+ this.dataArr = [];
+ for(var i in entries) {
+ var entry = entries[i];
+ entry["progress"] = "<div style='height:5px;width:100px;background-color:#CCC;'></div>";
+ dataArr.unshift(entry);
+ }
+
+ for (var j = 0; j < dataArr.length; j++) {
+ this.fileIdHash[dataArr[j].id] = j;
+ }
+
+ var myColumnDefs = [
+ {key:"name", label: "File Name", sortable:false},
+ {key:"size", label: "Size", sortable:false},
+ {key:"progress", label: "Upload progress", sortable:false}
+ ];
+
+ this.myDataSource = new YAHOO.util.DataSource(dataArr);
+ this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
+ this.myDataSource.responseSchema = {
+ fields: ["id","name","created","modified","type", "size", "progress"]
+ };
+
+ this.singleSelectDataTable = new YAHOO.widget.DataTable("dataTableContainer",
+ myColumnDefs, this.myDataSource, {
+ caption:"Files To Upload",
+ selectionMode:"single"
+ });
+ }
+
+ // Do something on each file's upload start.
+ function onUploadStart(event) {
+
+ }
+
+ // Do something on each file's upload progress event.
+ function onUploadProgress(event) {
+ rowNum = fileIdHash[event["id"]];
+ prog = Math.round(100*(event["bytesLoaded"]/event["bytesTotal"]));
+ progbar = "<div style='height:5px;width:100px;background-color:#CCC;'><div style='height:5px;background-color:#F00;width:" + prog + "px;'></div></div>";
+ singleSelectDataTable.updateRow(rowNum, {name: dataArr[rowNum]["name"], size: dataArr[rowNum]["size"], progress: progbar});
+ }
+
+ // Do something when each file's upload is complete.
+ function onUploadComplete(event) {
+ rowNum = fileIdHash[event["id"]];
+ prog = Math.round(100*(event["bytesLoaded"]/event["bytesTotal"]));
+ progbar = "<div style='height:5px;width:100px;background-color:#CCC;'><div style='height:5px;background-color:#F00;width:100px;'></div></div>";
+ singleSelectDataTable.updateRow(rowNum, {name: dataArr[rowNum]["name"], size: dataArr[rowNum]["size"], progress: progbar});
+ YAHOO.log("finished upload of " + rowNum + len(files));
+ }
+ // Do something if a file upload throws an error.
+ // (When uploadAll() is used, the Uploader will
+ // attempt to continue uploading.
+ function onUploadError(event) {
+
+ }
+
+ // Do something if an upload is cancelled.
+ function onUploadCancel(event) {
+
+ }
+
+ // Do something when data is received back from the server.
+ function onUploadResponse(event) {
+
+ }
+</script>
View
21 image_filer/templates/image_filer/upload.html
@@ -1,5 +1,18 @@
+{% extends "admin/change_form.html" %}
{% load i18n admin_modify adminmedia %}
+{% block extrahead %}{{ block.super }}
+<script type="text/javascript" src="/media/admin/js/admin/RelatedObjectLookups.js"></script>
+<script type="text/javascript" src="/media/image_filer/js/jquery.uploadify-v1.6.2/jquery-1.3.2.min.js"></script>
+<script type="text/javascript" src="/media/image_filer/js/jquery.uploadify-v1.6.2/jquery.uploadify.js"></script>
+<script type="text/javascript" src="/media/image_filer/js/jquery.cookie.js"></script>
+{% endblock %}
+
+
+{% block breadcrumbs %}{% endblock %}
+
+{% block content %}
+
<input type="file" name="fileInput" id="fileInput" />
<script type="text/javascript">
$(document).ready(function() {
@@ -13,13 +26,13 @@
'buttonText': 'select files',
'simUploadLimit': 1,
'scriptData':{'stuff':'there','jsessionid':$.cookie('sessionid')},
- 'onAllComplete': function() {
- setTimeout(closeTheWindow(),1000);
- }
+ 'onAllComplete': function() {setTimeout(closeTheWindow(),1000);}
});
});
function closeTheWindow() {
//alert('going to close the window...');
opener.dismissPopupAndReload(window);
};
-</script>
+</script>
+{% comment %}<a href="javascript:window.close()">Cancel</a>{% endcomment %}
+{% endblock %}
View
4 image_filer/urls.py
@@ -23,7 +23,7 @@
url(r'^image/(?P<image_id>\d+)/export/$', 'export_image', name='image_filer-export_image'),
) + patterns('django.views.generic.simple',
- #(r'^folder/$', 'redirect_to', {'url': '/admin/image_filer/directory/'}),
- #(r'^image/$', 'redirect_to', {'url': '/admin/image_filer/directory/'})
+ (r'^folder/$', 'redirect_to', {'url': '/admin/image_filer/directory/'}),
+ (r'^image/$', 'redirect_to', {'url': '/admin/image_filer/directory/'})
)
View
5 image_filer/utils/files.py
@@ -9,10 +9,7 @@ def generic_handle_file(file, original_filename):
"""
#print "entering generic_handle_file(file=%s, original_filename=%s)" % (file, original_filename)
files = []
- try:
- filetype = os.path.splitext(original_filename)[1].lower()
- except:
- filetype = ''
+ filetype = os.path.splitext(original_filename)[1].lower()
#print filetype
if filetype=='.zip':
unpacked_files = unzip(file)
View
11 image_filer/views.py
@@ -219,19 +219,15 @@ def ajax_upload(request, folder_id=None):
#print request.session
# upload and save the file
if not request.method == 'POST':
- pass#return HttpResponse("must be POST")
+ return HttpResponse("must be POST")
original_filename = request.POST.get('Filename')
file = request.FILES.get('Filedata')
#print request.FILES
#print original_filename, file
clipboard, was_clipboard_created = Clipboard.objects.get_or_create(user=request.user)
files = generic_handle_file(file, original_filename)
- file_items = []
for ifile, iname in files:
- try:
- iext = os.path.splitext(iname)[1].lower()
- except:
- iext = ''
+ iext = os.path.splitext(iname)[1].lower()
#print "extension: ", iext
if iext in ['.jpg','.jpeg','.png','.gif']:
imageform = UploadFileForm({'original_filename':iname,'owner': request.user.pk}, {'file':ifile})
@@ -240,7 +236,6 @@ def ajax_upload(request, folder_id=None):
try:
image = imageform.save(commit=False)
image.save()
- file_items.append(image)
except Exception, e:
print e
#print "save %s" % image
@@ -250,7 +245,7 @@ def ajax_upload(request, folder_id=None):
else:
pass#print imageform.errors
- return render_to_response('image_filer/include/clipboard_item_rows.html', {'items': file_items }, context_instance=RequestContext(request))
+ return HttpResponse("ok")
@login_required
def paste_clipboard_to_folder(request):

0 comments on commit 473b35b

Please sign in to comment.