Skip to content
Browse files

options.jqueryPath and options.uploadProgressPath to set scripts loac…

…tion for safari
  • Loading branch information...
1 parent ba01150 commit ac088332e4054de8cf9b38d7106921db503c39a9 @drogus committed Jun 30, 2008
Showing with 17 additions and 8 deletions.
  1. +3 −0 example/index.html
  2. +14 −8 jquery.uploadProgress.js
View
3 example/index.html
@@ -9,6 +9,9 @@
<script type="text/javascript">
$(function() {
$('form').uploadProgress({
+ /* scripts locations for safari */
+ jqueryPath: "../lib/jquery.js",
+ uploadProgressPath: "../jquery.uploadProgress.js",
start:function(){},
uploading: function(upload) {$('#percents').html(upload.percents+'%');},
interval: 2000
View
22 jquery.uploadProgress.js
@@ -8,8 +8,13 @@
*
*/
(function($) {
- if($.browser.safari && $('iframe[name=progressFrame]', parent.document).length == 0) {
- $(function() {
+ $.fn.uploadProgress = function(options) {
+ $(function() {
+ /* tried to add iframe after submit (to not always load it) but it won't work.
+ safari can't get scripts properly while submitting files */
+ if($.browser.safari && $('iframe[name=progressFrame]', parent.document).length == 0) {
+ /* iframe to send ajax requests in safari
+ thanks to Michele Finotto for idea */
iframe = document.createElement('iframe');
iframe.name = "progressFrame";
$(iframe).css({width: '0', height: '0', position: 'absolute', top: -3000});
@@ -23,18 +28,17 @@
var b = d.body;
var s = d.createElement('script');
- s.src = "../lib/jquery.js";
+ s.src = options.jqueryPath;
/* must be sure that jquery is loaded */
s.onload = function() {
var s1 = d.createElement('script');
- s1.src = "../jquery.uploadProgress.js";
+ s1.src = options.uploadProgressPath;
b.appendChild(s1);
}
b.appendChild(s);
- });
- }
-
- $.fn.uploadProgress = function(options) {
+ }
+ });
+
return this.each(function(){
$(this).bind('submit', function() {
var uuid = "";
@@ -49,6 +53,8 @@
complete: function() {},
success: function() {},
error: function() {},
+ uploadProgressPath: '/javascripts/jquery.js',
+ jqueryPath: '/javascripts/jquery.uploadProgress.js',
timer: ""
}, options);
/* update uuid */

0 comments on commit ac08833

Please sign in to comment.
Something went wrong with that request. Please try again.