public
Description: Simple app for my jQuery + Rails tutorial
Homepage: http://drogomir.com/blog
Clone URL: git://github.com/drogus/mugshots.git
Some fixes for safari (preloading images and little typo)
drogus (author)
Wed Jul 02 11:18:53 -0700 2008
commit  48e953b9c73191288f9c706135063664db55e8a0
tree    d61af64d87e2d4ae218b1c1e65fe62e7a241d191
parent  37c9de00079000ad9d0f8734f164339522963c03
...
49
50
51
52
53
54
55
 
56
57
58
...
49
50
51
 
52
53
 
54
55
56
57
0
@@ -49,10 +49,9 @@
0
           $('#lOverlay').css({display: 'table'});
0
           $('#lOverlay #lWindow').css({display: 'table-cell'});
0
       }
0
- $('#lightboxfu').hide();
0
       $('#lOverlay').css({position: 'fixed', top: 0, left: 0, width: "100%", height: "100%"});
0
       $('#lOverlay #lWindow').css({'vertical-align': 'middle'});
0
- $('#lOverlay #lInner').css({width: '300px', 'background-color': '#fff', '-webkit-border-radius': '10px;', '-moz-border-radius': '10px', 'max-height': '350px', margin: '0 auto', padding: '15px', overflow: 'auto'});
0
+ $('#lOverlay #lInner').css({width: '300px', 'background-color': '#fff', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', 'max-height': '350px', margin: '0 auto', padding: '15px', overflow: 'auto'});
0
     }
0
   });
0
   
...
9
10
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
 
 
 
 
13
14
15
...
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
...
86
87
88
89
90
91
 
92
93
94
 
95
96
97
...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
...
64
65
66
 
 
 
 
 
 
 
 
 
 
 
 
 
67
68
69
...
93
94
95
 
 
 
96
97
98
 
99
100
101
102
0
@@ -9,7 +9,27 @@
0
  */
0
 (function($) {
0
   $.fn.uploadProgress = function(options) {
0
+ options = $.extend({
0
+ interval: 2000,
0
+ progressBar: "#progressbar",
0
+ progressUrl: "/progress",
0
+ start: function() {},
0
+ uploading: function() {},
0
+ complete: function() {},
0
+ success: function() {},
0
+ error: function() {},
0
+ preloadImages: [],
0
+ uploadProgressPath: '/javascripts/jquery.uploadProgress.js',
0
+ jqueryPath: '/javascripts/jquery.js',
0
+ timer: ""
0
+ }, options);
0
+
0
   $(function() {
0
+ //preload images
0
+ for(var i = 0; i<options.preloadImages.length; i++)
0
+ {
0
+ options.preloadImages[i] = $("<img>").attr("src", options.preloadImages[i]);
0
+ }
0
     /* tried to add iframe after submit (to not always load it) but it won't work.
0
     safari can't get scripts properly while submitting files */
0
     if($.browser.safari && top.document == document) {
0
@@ -44,19 +64,6 @@
0
       var uuid = "";
0
       for (i = 0; i < 32; i++) { uuid += Math.floor(Math.random() * 16).toString(16); }
0
       
0
- options = $.extend({
0
- interval: 2000,
0
- progressBar: "#progressbar",
0
- progressUrl: "/progress",
0
- start: function() {},
0
- uploading: function() {},
0
- complete: function() {},
0
- success: function() {},
0
- error: function() {},
0
- uploadProgressPath: '/javascripts/jquery.js',
0
- jqueryPath: '/javascripts/jquery.uploadProgress.js',
0
- timer: ""
0
- }, options);
0
                         /* update uuid */
0
                         options.uuid = uuid;
0
       /* start callback */
0
@@ -86,12 +93,10 @@ jQuery.uploadProgress = function(e, options) {
0
     },
0
     success: function(upload) {
0
       if (upload.state == 'uploading') {
0
- upload = $.extend({
0
- percents: Math.floor((upload.received / upload.size)*1000)/10
0
- }, upload);
0
+ upload.percents = Math.floor((upload.received / upload.size)*1000)/10;
0
         
0
         var bar = $.browser.safari ? $(options.progressBar, parent.document) : $(options.progressBar);
0
- bar.width(Math.floor(upload.percents) + '%');
0
+ bar.css({width: upload.percents+'%'});
0
          options.uploading(upload);
0
       }
0
       
...
2
3
4
 
5
6
7
...
23
24
25
26
 
 
27
28
29
...
2
3
4
5
6
7
8
...
24
25
26
 
27
28
29
30
31
0
@@ -2,6 +2,7 @@
0
 // was used, jQuery is passed as argument in document ready
0
 // so we can name it $
0
 jQuery(function($) {
0
+ $.lightBoxFu.initialize({imagesPath: '/images/', stylesheetsPath: '/stylesheets/'});
0
   //enable lightbox
0
   $('#mugshots li a').lightBox();
0
     
0
@@ -23,7 +24,8 @@ jQuery(function($) {
0
       jQuery('#size').html(parseInt(upload.size/1024)+" kB");
0
       jQuery('#percent').html(upload.percents+"%");
0
     },
0
- interval: 2000
0
+ interval: 2000,
0
+ preloadImages: ["/images/overlay.png", "/images/ajax-loader.gif"]
0
   });
0
   
0
   $('.multi-file').each(function() {
...
64
65
66
67
 
 
68
69
70
...
64
65
66
 
67
68
69
70
71
0
@@ -64,6 +64,7 @@ jQuery(function($) {
0
       // lightbox with error after 2 seconds
0
       window.setTimeout($.lightBoxFu.close, 2000);
0
     },
0
- interval: 2000
0
+ interval: 2000,
0
+ preloadImages: ["/images/overlay.png", "/images/ajax-loader.gif"]
0
   });
0
 });
0
\ No newline at end of file

Comments

    No one has commented yet.