transit 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/Gemfile +19 -11
  2. data/app/assets/images/transit/icon24x24.png +0 -0
  3. data/app/assets/images/transit/icon24x24_files.png +0 -0
  4. data/app/assets/images/transit/jplayer.swf +0 -0
  5. data/app/assets/images/transit/uploadify.swf +0 -0
  6. data/app/assets/images/transit/video_player.swf +0 -0
  7. data/app/assets/javascripts/jqtools/expose.js +224 -0
  8. data/app/assets/javascripts/jqtools/flashembed.js +300 -0
  9. data/app/assets/javascripts/jqtools/overlay.js +294 -0
  10. data/app/assets/javascripts/jqtools/scrollable.js +3 -0
  11. data/app/assets/javascripts/jqtools/scrollable/autoscroll.js +81 -0
  12. data/app/assets/javascripts/jqtools/scrollable/base.js +335 -0
  13. data/app/assets/javascripts/jqtools/scrollable/navigator.js +139 -0
  14. data/app/assets/javascripts/jqtools/validator.js +590 -0
  15. data/app/assets/javascripts/jqueryui/accordion.js +611 -0
  16. data/app/assets/javascripts/jqueryui/autocomplete.js +612 -0
  17. data/app/assets/javascripts/jqueryui/button.js +388 -0
  18. data/app/assets/javascripts/jqueryui/core.js +312 -0
  19. data/app/assets/javascripts/jqueryui/datepicker.js +1791 -0
  20. data/app/assets/javascripts/jqueryui/dialog.js +878 -0
  21. data/app/assets/javascripts/jqueryui/draggable.js +815 -0
  22. data/app/assets/javascripts/jqueryui/droppable.js +285 -0
  23. data/app/assets/javascripts/jqueryui/effects/blind.js +49 -0
  24. data/app/assets/javascripts/jqueryui/effects/bounce.js +78 -0
  25. data/app/assets/javascripts/jqueryui/effects/clip.js +54 -0
  26. data/app/assets/javascripts/jqueryui/effects/core.js +746 -0
  27. data/app/assets/javascripts/jqueryui/effects/drop.js +50 -0
  28. data/app/assets/javascripts/jqueryui/effects/explode.js +79 -0
  29. data/app/assets/javascripts/jqueryui/effects/fade.js +32 -0
  30. data/app/assets/javascripts/jqueryui/effects/fold.js +56 -0
  31. data/app/assets/javascripts/jqueryui/effects/highlight.js +50 -0
  32. data/app/assets/javascripts/jqueryui/effects/pulsate.js +51 -0
  33. data/app/assets/javascripts/jqueryui/effects/scale.js +178 -0
  34. data/app/assets/javascripts/jqueryui/effects/shake.js +57 -0
  35. data/app/assets/javascripts/jqueryui/effects/slide.js +50 -0
  36. data/app/assets/javascripts/jqueryui/effects/transfer.js +45 -0
  37. data/app/assets/javascripts/jqueryui/mouse.js +160 -0
  38. data/app/assets/javascripts/jqueryui/position.js +252 -0
  39. data/app/assets/javascripts/jqueryui/progressbar.js +109 -0
  40. data/app/assets/javascripts/jqueryui/resizable.js +814 -0
  41. data/app/assets/javascripts/jqueryui/selectable.js +266 -0
  42. data/app/assets/javascripts/jqueryui/slider.js +666 -0
  43. data/app/assets/javascripts/jqueryui/sortable.js +1077 -0
  44. data/app/assets/javascripts/jqueryui/tabs.js +758 -0
  45. data/app/assets/javascripts/jqueryui/widget.js +262 -0
  46. data/app/assets/javascripts/libs/backbone.js +1152 -0
  47. data/app/assets/javascripts/libs/cookie.js +89 -0
  48. data/app/assets/javascripts/libs/fileinput.js +130 -0
  49. data/app/assets/javascripts/libs/jplayer.js +1768 -0
  50. data/app/assets/javascripts/libs/proper.js +541 -0
  51. data/app/assets/javascripts/libs/sanitize.js +282 -0
  52. data/app/assets/javascripts/libs/selecttolist.js +75 -0
  53. data/app/assets/javascripts/libs/underscore.js +807 -0
  54. data/app/assets/javascripts/libs/uploadify.js +677 -0
  55. data/app/assets/javascripts/libs/wymeditor.js +9538 -0
  56. data/app/assets/javascripts/transit.js +4 -0
  57. data/app/assets/javascripts/transit/admin.js +22 -0
  58. data/app/assets/javascripts/transit/admin/contexts.js +52 -0
  59. data/app/assets/javascripts/transit/admin/fields.js +36 -0
  60. data/app/assets/javascripts/transit/admin/upload.js +109 -0
  61. data/app/assets/javascripts/transit/config.js.erb +101 -0
  62. data/app/assets/javascripts/transit/contexts/audio.js +39 -0
  63. data/app/assets/javascripts/transit/contexts/video.js +79 -0
  64. data/app/assets/javascripts/transit/core.js +171 -0
  65. data/app/assets/javascripts/transit/frontend.js +3 -0
  66. data/app/assets/javascripts/transit/lib/base64.js +120 -0
  67. data/app/assets/javascripts/transit/lib/editor.js +177 -0
  68. data/app/assets/javascripts/transit/views/audio_player.jst +22 -0
  69. data/app/assets/javascripts/transit/views/editor_toolbar.jst +12 -0
  70. data/app/assets/javascripts/transit/views/file_upload.jst +5 -0
  71. data/app/assets/javascripts/transit/views/video_player.jst +20 -0
  72. data/app/assets/javascripts/transit/views/wym_box.jst +4 -0
  73. data/app/assets/javascripts/transit/views/wym_iframe.jst +3 -0
  74. data/app/assets/stylesheets/transit.css.scss.erb +42 -0
  75. data/app/assets/stylesheets/transit/forms.css.scss +66 -0
  76. data/app/assets/stylesheets/transit/media/audio.css.scss +65 -0
  77. data/app/assets/stylesheets/transit/media/video.css.scss +30 -0
  78. data/app/assets/stylesheets/transit/panel.css.scss +100 -0
  79. data/app/assets/stylesheets/transit/ui.css.scss +507 -0
  80. data/app/controllers/pages_controller.rb +3 -0
  81. data/app/controllers/posts_controller.rb +3 -0
  82. data/app/controllers/transit/assets_controller.rb +38 -0
  83. data/app/controllers/transit/contexts_controller.rb +12 -9
  84. data/app/controllers/transit/pages_controller.rb +26 -0
  85. data/app/controllers/transit/posts_controller.rb +31 -0
  86. data/app/controllers/transit/topics_controller.rb +5 -0
  87. data/app/controllers/transit_controller.rb +16 -0
  88. data/app/helpers/transit/admin_helper.rb +43 -0
  89. data/app/helpers/transit/form_helper.rb +17 -0
  90. data/app/helpers/transit/package_helper.rb +41 -0
  91. data/app/helpers/transit/pagination_helper.rb +58 -0
  92. data/app/helpers/transit_helper.rb +42 -0
  93. data/app/models/comment.rb +37 -0
  94. data/app/models/contexts/audio.rb +12 -0
  95. data/app/models/{text.rb → contexts/text.rb} +0 -0
  96. data/app/models/contexts/video.rb +24 -0
  97. data/app/models/topic.rb +19 -0
  98. data/app/models/transit/asset.rb +68 -0
  99. data/{lib → app/models}/transit/context.rb +29 -0
  100. data/app/views/contexts/_text.html.erb +1 -1
  101. data/app/views/posts/index.rss.builder +18 -0
  102. data/app/views/transit/assets/_file.html.erb +4 -0
  103. data/app/views/transit/assets/_image.html.erb +13 -0
  104. data/app/views/transit/assets/create.js.erb +8 -0
  105. data/app/views/transit/assets/destroy.js.erb +3 -0
  106. data/app/views/transit/assets/manage.html.erb +20 -0
  107. data/app/views/transit/contexts/_audio.html.erb +18 -0
  108. data/app/views/transit/contexts/_text.html.erb +6 -0
  109. data/app/views/transit/contexts/_video.html.erb +13 -0
  110. data/app/views/transit/contexts/destroy.js.erb +1 -0
  111. data/app/views/transit/contexts/index.html.erb +5 -0
  112. data/app/views/transit/contexts/new.js.erb +7 -0
  113. data/app/views/transit/contexts/show.html.erb +8 -0
  114. data/app/views/transit/index.html.erb +26 -0
  115. data/app/views/transit/index.js.erb +1 -0
  116. data/app/views/transit/interface/post_panel.html.erb +96 -0
  117. data/app/views/transit/pages/_table.html.erb +7 -0
  118. data/app/views/transit/pages/edit.html.erb +17 -0
  119. data/app/views/transit/pages/index.html.erb +17 -0
  120. data/app/views/transit/pages/update.js.erb +1 -0
  121. data/app/views/transit/posts/_form.html.erb +49 -0
  122. data/app/views/transit/posts/edit.html.erb +14 -0
  123. data/app/views/transit/posts/new.html.erb +21 -0
  124. data/app/views/transit/table.html.erb +13 -0
  125. data/app/views/transit/table.js.erb +8 -0
  126. data/app/views/transit/topics/manage.html.erb +28 -0
  127. data/config/locales/en.yml +22 -0
  128. data/config/routes.rb +3 -3
  129. data/lib/transit.rb +51 -17
  130. data/lib/transit/admin.rb +85 -0
  131. data/lib/transit/builders/form_builder.rb +319 -0
  132. data/lib/transit/builders/jst_builder.rb +38 -0
  133. data/lib/transit/builders/package_builder.rb +45 -0
  134. data/lib/transit/config.rb +20 -0
  135. data/lib/transit/controller/generator.rb +42 -0
  136. data/lib/transit/controller/responder.rb +34 -0
  137. data/lib/transit/core_ext.rb +18 -0
  138. data/lib/transit/errors/resource_not_found.rb +6 -0
  139. data/lib/transit/model/assets.rb +14 -0
  140. data/lib/transit/model/attachments.rb +55 -0
  141. data/lib/transit/model/auto_increment.rb +22 -0
  142. data/lib/transit/model/base.rb +56 -0
  143. data/lib/transit/model/comments.rb +19 -0
  144. data/lib/transit/model/hooks.rb +38 -0
  145. data/lib/transit/model/owners.rb +14 -0
  146. data/lib/transit/model/paginator.rb +92 -0
  147. data/lib/transit/model/topics.rb +14 -0
  148. data/lib/transit/package/page.rb +20 -12
  149. data/lib/transit/package/post.rb +87 -33
  150. data/lib/transit/package/post/validations.rb +14 -0
  151. data/lib/transit/rails/engine.rb +29 -13
  152. data/lib/transit/rails/railtie.rb +31 -0
  153. data/lib/transit/rails/routing.rb +11 -6
  154. data/lib/transit/services.rb +13 -0
  155. data/lib/transit/services/base.rb +14 -0
  156. data/lib/transit/services/facebook.rb +13 -0
  157. data/lib/transit/services/ted.rb +10 -0
  158. data/lib/transit/services/twitter.rb +13 -0
  159. data/lib/transit/services/vimeo.rb +10 -0
  160. data/lib/transit/services/you_tube.rb +12 -0
  161. data/lib/transit/version.rb +1 -1
  162. metadata +178 -31
  163. data/app/assets/stylesheets/includes/_compat.scss +0 -24
  164. data/app/assets/stylesheets/includes/_defaults.scss +0 -99
  165. data/app/assets/stylesheets/includes/_global.scss +0 -16
  166. data/app/assets/stylesheets/includes/_imports.scss +0 -27
  167. data/app/assets/stylesheets/includes/_mixins.scss +0 -38
  168. data/app/assets/stylesheets/includes/_setup.scss +0 -85
  169. data/app/assets/stylesheets/layout.css.scss +0 -29
  170. data/app/assets/stylesheets/transit.css +0 -3
  171. data/app/controllers/application_controller.rb +0 -5
  172. data/app/controllers/transit/index_controller.rb +0 -7
  173. data/app/controllers/transit/packages_controller.rb +0 -64
  174. data/app/controllers/transit/transit_controller.rb +0 -4
  175. data/app/helpers/routing_helpers.rb +0 -7
  176. data/app/models/audio.rb +0 -4
  177. data/app/models/package_asset.rb +0 -11
  178. data/app/models/video.rb +0 -8
  179. data/app/views/contexts/_audio.html.erb +0 -1
  180. data/app/views/contexts/_video.html.erb +0 -1
  181. data/app/views/layouts/transit.html.erb +0 -31
  182. data/app/views/transit/index/index.html.erb +0 -0
  183. data/lib/transit/helpers/controller_helpers.rb +0 -40
  184. data/lib/transit/helpers/model_helpers.rb +0 -26
  185. data/lib/transit/package.rb +0 -25
  186. data/lib/transit/package/base.rb +0 -49
@@ -0,0 +1,677 @@
1
+ /*
2
+ SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
3
+
4
+ mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
5
+
6
+ SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
7
+ http://www.opensource.org/licenses/mit-license.php
8
+
9
+ SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
10
+ http://www.opensource.org/licenses/mit-license.php
11
+ */
12
+
13
+ var SWFUpload;if(SWFUpload==undefined){SWFUpload=function(a){this.initSWFUpload(a)}}SWFUpload.prototype.initSWFUpload=function(b){try{this.customSettings={};this.settings=b;this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings();this.loadFlash();this.displayDebugInfo()}catch(a){delete SWFUpload.instances[this.movieName];throw a}};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.2.0 2009-03-25";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290};SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5};SWFUpload.BUTTON_ACTION={SELECT_FILE:-100,SELECT_FILES:-110,START_UPLOAD:-120};SWFUpload.CURSOR={ARROW:-1,HAND:-2};SWFUpload.WINDOW_MODE={WINDOW:"window",TRANSPARENT:"transparent",OPAQUE:"opaque"};SWFUpload.completeURL=function(a){if(typeof(a)!=="string"||a.match(/^https?:\/\//i)||a.match(/^\//)){return a}var c=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"");var b=window.location.pathname.lastIndexOf("/");if(b<=0){path="/"}else{path=window.location.pathname.substr(0,b)+"/"}return path+a};SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(b,a){this.settings[b]=(this.settings[b]==undefined)?a:this.settings[b]};this.ensureDefault("upload_url","");this.ensureDefault("preserve_relative_urls",false);this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("requeue_on_error",false);this.ensureDefault("http_success",[]);this.ensureDefault("assume_success_timeout",0);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload.swf");this.ensureDefault("prevent_swf_caching",true);this.ensureDefault("button_image_url","");this.ensureDefault("button_width",1);this.ensureDefault("button_height",1);this.ensureDefault("button_text","");this.ensureDefault("button_text_style","color: #000000; font-size: 16pt;");this.ensureDefault("button_text_top_padding",0);this.ensureDefault("button_text_left_padding",0);this.ensureDefault("button_action",SWFUpload.BUTTON_ACTION.SELECT_FILES);this.ensureDefault("button_disabled",false);this.ensureDefault("button_placeholder_id","");this.ensureDefault("button_placeholder",null);this.ensureDefault("button_cursor",SWFUpload.CURSOR.ARROW);this.ensureDefault("button_window_mode",SWFUpload.WINDOW_MODE.WINDOW);this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;if(!!this.settings.prevent_swf_caching){this.settings.flash_url=this.settings.flash_url+(this.settings.flash_url.indexOf("?")<0?"?":"&")+"preventswfcaching="+new Date().getTime()}if(!this.settings.preserve_relative_urls){this.settings.upload_url=SWFUpload.completeURL(this.settings.upload_url);this.settings.button_image_url=SWFUpload.completeURL(this.settings.button_image_url)}delete this.ensureDefault};SWFUpload.prototype.loadFlash=function(){var a,b;if(document.getElementById(this.movieName)!==null){throw"ID "+this.movieName+" is already in use. The Flash Object could not be added"}a=document.getElementById(this.settings.button_placeholder_id)||this.settings.button_placeholder;if(a==undefined){throw"Could not find the placeholder element: "+this.settings.button_placeholder_id}b=document.createElement("div");b.innerHTML=this.getFlashHTML();a.parentNode.replaceChild(b.firstChild,a);if(window[this.movieName]==undefined){window[this.movieName]=this.getMovieElement()}};SWFUpload.prototype.getFlashHTML=function(){return['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="',this.settings.button_width,'" height="',this.settings.button_height,'" class="swfupload">','<param name="wmode" value="',this.settings.button_window_mode,'" />','<param name="movie" value="',this.settings.flash_url,'" />','<param name="quality" value="high" />','<param name="menu" value="false" />','<param name="allowScriptAccess" value="always" />','<param name="flashvars" value="'+this.getFlashVars()+'" />',"</object>"].join("")};SWFUpload.prototype.getFlashVars=function(){var b=this.buildParamString();var a=this.settings.http_success.join(",");return["movieName=",encodeURIComponent(this.movieName),"&amp;uploadURL=",encodeURIComponent(this.settings.upload_url),"&amp;useQueryString=",encodeURIComponent(this.settings.use_query_string),"&amp;requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),"&amp;httpSuccess=",encodeURIComponent(a),"&amp;assumeSuccessTimeout=",encodeURIComponent(this.settings.assume_success_timeout),"&amp;params=",encodeURIComponent(b),"&amp;filePostName=",encodeURIComponent(this.settings.file_post_name),"&amp;fileTypes=",encodeURIComponent(this.settings.file_types),"&amp;fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&amp;fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&amp;fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&amp;fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&amp;debugEnabled=",encodeURIComponent(this.settings.debug_enabled),"&amp;buttonImageURL=",encodeURIComponent(this.settings.button_image_url),"&amp;buttonWidth=",encodeURIComponent(this.settings.button_width),"&amp;buttonHeight=",encodeURIComponent(this.settings.button_height),"&amp;buttonText=",encodeURIComponent(this.settings.button_text),"&amp;buttonTextTopPadding=",encodeURIComponent(this.settings.button_text_top_padding),"&amp;buttonTextLeftPadding=",encodeURIComponent(this.settings.button_text_left_padding),"&amp;buttonTextStyle=",encodeURIComponent(this.settings.button_text_style),"&amp;buttonAction=",encodeURIComponent(this.settings.button_action),"&amp;buttonDisabled=",encodeURIComponent(this.settings.button_disabled),"&amp;buttonCursor=",encodeURIComponent(this.settings.button_cursor)].join("")};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName)}if(this.movieElement===null){throw"Could not find Flash element"}return this.movieElement};SWFUpload.prototype.buildParamString=function(){var c=this.settings.post_params;var b=[];if(typeof(c)==="object"){for(var a in c){if(c.hasOwnProperty(a)){b.push(encodeURIComponent(a.toString())+"="+encodeURIComponent(c[a].toString()))}}}return b.join("&amp;")};SWFUpload.prototype.destroy=function(){try{this.cancelUpload(null,false);var a=null;a=this.getMovieElement();if(a&&typeof(a.CallFunction)==="unknown"){for(var c in a){try{if(typeof(a[c])==="function"){a[c]=null}}catch(e){}}try{a.parentNode.removeChild(a)}catch(b){}}window[this.movieName]=null;SWFUpload.instances[this.movieName]=null;delete SWFUpload.instances[this.movieName];this.movieElement=null;this.settings=null;this.customSettings=null;this.eventQueue=null;this.movieName=null;return true}catch(d){return false}};SWFUpload.prototype.displayDebugInfo=function(){this.debug(["---SWFUpload Instance Info---\n","Version: ",SWFUpload.version,"\n","Movie Name: ",this.movieName,"\n","Settings:\n","\t","upload_url: ",this.settings.upload_url,"\n","\t","flash_url: ",this.settings.flash_url,"\n","\t","use_query_string: ",this.settings.use_query_string.toString(),"\n","\t","requeue_on_error: ",this.settings.requeue_on_error.toString(),"\n","\t","http_success: ",this.settings.http_success.join(", "),"\n","\t","assume_success_timeout: ",this.settings.assume_success_timeout,"\n","\t","file_post_name: ",this.settings.file_post_name,"\n","\t","post_params: ",this.settings.post_params.toString(),"\n","\t","file_types: ",this.settings.file_types,"\n","\t","file_types_description: ",this.settings.file_types_description,"\n","\t","file_size_limit: ",this.settings.file_size_limit,"\n","\t","file_upload_limit: ",this.settings.file_upload_limit,"\n","\t","file_queue_limit: ",this.settings.file_queue_limit,"\n","\t","debug: ",this.settings.debug.toString(),"\n","\t","prevent_swf_caching: ",this.settings.prevent_swf_caching.toString(),"\n","\t","button_placeholder_id: ",this.settings.button_placeholder_id.toString(),"\n","\t","button_placeholder: ",(this.settings.button_placeholder?"Set":"Not Set"),"\n","\t","button_image_url: ",this.settings.button_image_url.toString(),"\n","\t","button_width: ",this.settings.button_width.toString(),"\n","\t","button_height: ",this.settings.button_height.toString(),"\n","\t","button_text: ",this.settings.button_text.toString(),"\n","\t","button_text_style: ",this.settings.button_text_style.toString(),"\n","\t","button_text_top_padding: ",this.settings.button_text_top_padding.toString(),"\n","\t","button_text_left_padding: ",this.settings.button_text_left_padding.toString(),"\n","\t","button_action: ",this.settings.button_action.toString(),"\n","\t","button_disabled: ",this.settings.button_disabled.toString(),"\n","\t","custom_settings: ",this.settings.custom_settings.toString(),"\n","Event Handlers:\n","\t","swfupload_loaded_handler assigned: ",(typeof this.settings.swfupload_loaded_handler==="function").toString(),"\n","\t","file_dialog_start_handler assigned: ",(typeof this.settings.file_dialog_start_handler==="function").toString(),"\n","\t","file_queued_handler assigned: ",(typeof this.settings.file_queued_handler==="function").toString(),"\n","\t","file_queue_error_handler assigned: ",(typeof this.settings.file_queue_error_handler==="function").toString(),"\n","\t","upload_start_handler assigned: ",(typeof this.settings.upload_start_handler==="function").toString(),"\n","\t","upload_progress_handler assigned: ",(typeof this.settings.upload_progress_handler==="function").toString(),"\n","\t","upload_error_handler assigned: ",(typeof this.settings.upload_error_handler==="function").toString(),"\n","\t","upload_success_handler assigned: ",(typeof this.settings.upload_success_handler==="function").toString(),"\n","\t","upload_complete_handler assigned: ",(typeof this.settings.upload_complete_handler==="function").toString(),"\n","\t","debug_handler assigned: ",(typeof this.settings.debug_handler==="function").toString(),"\n"].join(""))};SWFUpload.prototype.addSetting=function(b,c,a){if(c==undefined){return(this.settings[b]=a)}else{return(this.settings[b]=c)}};SWFUpload.prototype.getSetting=function(a){if(this.settings[a]!=undefined){return this.settings[a]}return""};SWFUpload.prototype.callFlash=function(functionName,argumentArray){argumentArray=argumentArray||[];var movieElement=this.getMovieElement();var returnValue,returnString;try{returnString=movieElement.CallFunction('<invoke name="'+functionName+'" returntype="javascript">'+__flash__argumentsToXML(argumentArray,0)+"</invoke>");returnValue=eval(returnString)}catch(ex){throw"Call to "+functionName+" failed"}if(returnValue!=undefined&&typeof returnValue.post==="object"){returnValue=this.unescapeFilePostParams(returnValue)}return returnValue};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile")};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles")};SWFUpload.prototype.startUpload=function(a){this.callFlash("StartUpload",[a])};SWFUpload.prototype.cancelUpload=function(a,b){if(b!==false){b=true}this.callFlash("CancelUpload",[a,b])};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload")};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats")};SWFUpload.prototype.setStats=function(a){this.callFlash("SetStats",[a])};SWFUpload.prototype.getFile=function(a){if(typeof(a)==="number"){return this.callFlash("GetFileByIndex",[a])}else{return this.callFlash("GetFile",[a])}};SWFUpload.prototype.addFileParam=function(a,b,c){return this.callFlash("AddFileParam",[a,b,c])};SWFUpload.prototype.removeFileParam=function(a,b){this.callFlash("RemoveFileParam",[a,b])};SWFUpload.prototype.setUploadURL=function(a){this.settings.upload_url=a.toString();this.callFlash("SetUploadURL",[a])};SWFUpload.prototype.setPostParams=function(a){this.settings.post_params=a;this.callFlash("SetPostParams",[a])};SWFUpload.prototype.addPostParam=function(a,b){this.settings.post_params[a]=b;this.callFlash("SetPostParams",[this.settings.post_params])};SWFUpload.prototype.removePostParam=function(a){delete this.settings.post_params[a];this.callFlash("SetPostParams",[this.settings.post_params])};SWFUpload.prototype.setFileTypes=function(a,b){this.settings.file_types=a;this.settings.file_types_description=b;this.callFlash("SetFileTypes",[a,b])};SWFUpload.prototype.setFileSizeLimit=function(a){this.settings.file_size_limit=a;this.callFlash("SetFileSizeLimit",[a])};SWFUpload.prototype.setFileUploadLimit=function(a){this.settings.file_upload_limit=a;this.callFlash("SetFileUploadLimit",[a])};SWFUpload.prototype.setFileQueueLimit=function(a){this.settings.file_queue_limit=a;this.callFlash("SetFileQueueLimit",[a])};SWFUpload.prototype.setFilePostName=function(a){this.settings.file_post_name=a;this.callFlash("SetFilePostName",[a])};SWFUpload.prototype.setUseQueryString=function(a){this.settings.use_query_string=a;this.callFlash("SetUseQueryString",[a])};SWFUpload.prototype.setRequeueOnError=function(a){this.settings.requeue_on_error=a;this.callFlash("SetRequeueOnError",[a])};SWFUpload.prototype.setHTTPSuccess=function(a){if(typeof a==="string"){a=a.replace(" ","").split(",")}this.settings.http_success=a;this.callFlash("SetHTTPSuccess",[a])};SWFUpload.prototype.setAssumeSuccessTimeout=function(a){this.settings.assume_success_timeout=a;this.callFlash("SetAssumeSuccessTimeout",[a])};SWFUpload.prototype.setDebugEnabled=function(a){this.settings.debug_enabled=a;this.callFlash("SetDebugEnabled",[a])};SWFUpload.prototype.setButtonImageURL=function(a){if(a==undefined){a=""}this.settings.button_image_url=a;this.callFlash("SetButtonImageURL",[a])};SWFUpload.prototype.setButtonDimensions=function(c,a){this.settings.button_width=c;this.settings.button_height=a;var b=this.getMovieElement();if(b!=undefined){b.style.width=c+"px";b.style.height=a+"px"}this.callFlash("SetButtonDimensions",[c,a])};SWFUpload.prototype.setButtonText=function(a){this.settings.button_text=a;this.callFlash("SetButtonText",[a])};SWFUpload.prototype.setButtonTextPadding=function(b,a){this.settings.button_text_top_padding=a;this.settings.button_text_left_padding=b;this.callFlash("SetButtonTextPadding",[b,a])};SWFUpload.prototype.setButtonTextStyle=function(a){this.settings.button_text_style=a;this.callFlash("SetButtonTextStyle",[a])};SWFUpload.prototype.setButtonDisabled=function(a){this.settings.button_disabled=a;this.callFlash("SetButtonDisabled",[a])};SWFUpload.prototype.setButtonAction=function(a){this.settings.button_action=a;this.callFlash("SetButtonAction",[a])};SWFUpload.prototype.setButtonCursor=function(a){this.settings.button_cursor=a;this.callFlash("SetButtonCursor",[a])};SWFUpload.prototype.queueEvent=function(b,c){if(c==undefined){c=[]}else{if(!(c instanceof Array)){c=[c]}}var a=this;if(typeof this.settings[b]==="function"){this.eventQueue.push(function(){this.settings[b].apply(this,c)});setTimeout(function(){a.executeNextEvent()},0)}else{if(this.settings[b]!==null){throw"Event handler "+b+" is unknown or is not a function"}}};SWFUpload.prototype.executeNextEvent=function(){var a=this.eventQueue?this.eventQueue.shift():null;if(typeof(a)==="function"){a.apply(this)}};SWFUpload.prototype.unescapeFilePostParams=function(c){var e=/[$]([0-9a-f]{4})/i;var f={};var d;if(c!=undefined){for(var a in c.post){if(c.post.hasOwnProperty(a)){d=a;var b;while((b=e.exec(d))!==null){d=d.replace(b[0],String.fromCharCode(parseInt("0x"+b[1],16)))}f[d]=c.post[a]}}c.post=f}return c};SWFUpload.prototype.testExternalInterface=function(){try{return this.callFlash("TestExternalInterface")}catch(a){return false}};SWFUpload.prototype.flashReady=function(){var a=this.getMovieElement();if(!a){this.debug("Flash called back ready but the flash movie can't be found.");return}this.cleanUp(a);this.queueEvent("swfupload_loaded_handler")};SWFUpload.prototype.cleanUp=function(a){try{if(this.movieElement&&typeof(a.CallFunction)==="unknown"){this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for(var c in a){try{if(typeof(a[c])==="function"){a[c]=null}}catch(b){}}}}catch(d){}window.__flash__removeCallback=function(e,f){try{if(e){e[f]=null}}catch(g){}}};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler")};SWFUpload.prototype.fileQueued=function(a){a=this.unescapeFilePostParams(a);this.queueEvent("file_queued_handler",a)};SWFUpload.prototype.fileQueueError=function(a,c,b){a=this.unescapeFilePostParams(a);this.queueEvent("file_queue_error_handler",[a,c,b])};SWFUpload.prototype.fileDialogComplete=function(b,c,a){this.queueEvent("file_dialog_complete_handler",[b,c,a])};SWFUpload.prototype.uploadStart=function(a){a=this.unescapeFilePostParams(a);this.queueEvent("return_upload_start_handler",a)};SWFUpload.prototype.returnUploadStart=function(a){var b;if(typeof this.settings.upload_start_handler==="function"){a=this.unescapeFilePostParams(a);b=this.settings.upload_start_handler.call(this,a)}else{if(this.settings.upload_start_handler!=undefined){throw"upload_start_handler must be a function"}}if(b===undefined){b=true}b=!!b;this.callFlash("ReturnUploadStart",[b])};SWFUpload.prototype.uploadProgress=function(a,c,b){a=this.unescapeFilePostParams(a);this.queueEvent("upload_progress_handler",[a,c,b])};SWFUpload.prototype.uploadError=function(a,c,b){a=this.unescapeFilePostParams(a);this.queueEvent("upload_error_handler",[a,c,b])};SWFUpload.prototype.uploadSuccess=function(b,a,c){b=this.unescapeFilePostParams(b);this.queueEvent("upload_success_handler",[b,a,c])};SWFUpload.prototype.uploadComplete=function(a){a=this.unescapeFilePostParams(a);this.queueEvent("upload_complete_handler",a)};SWFUpload.prototype.debug=function(a){this.queueEvent("debug_handler",a)};SWFUpload.prototype.debugMessage=function(c){if(this.settings.debug){var a,d=[];if(typeof c==="object"&&typeof c.name==="string"&&typeof c.message==="string"){for(var b in c){if(c.hasOwnProperty(b)){d.push(b+": "+c[b])}}a=d.join("\n")||"";d=a.split("\n");a="EXCEPTION: "+d.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(a)}else{SWFUpload.Console.writeLine(c)}}};SWFUpload.Console={};SWFUpload.Console.writeLine=function(d){var b,a;try{b=document.getElementById("SWFUpload_Console");if(!b){a=document.createElement("form");document.getElementsByTagName("body")[0].appendChild(a);b=document.createElement("textarea");b.id="SWFUpload_Console";b.style.fontFamily="monospace";b.setAttribute("wrap","off");b.wrap="off";b.style.overflow="auto";b.style.width="700px";b.style.height="350px";b.style.margin="5px";a.appendChild(b)}b.value+=d+"\n";b.scrollTop=b.scrollHeight-b.clientHeight}catch(c){alert("Exception: "+c.name+" Message: "+c.message)}};
14
+
15
+ /*
16
+ Uploadify v3.0.0
17
+ Copyright (c) 2010 Ronnie Garcia
18
+
19
+ Permission is hereby granted, free of charge, to any person obtaining a copy
20
+ of this software and associated documentation files (the "Software"), to deal
21
+ in the Software without restriction, including without limitation the rights
22
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
+ copies of the Software, and to permit persons to whom the Software is
24
+ furnished to do so, subject to the following conditions:
25
+
26
+ The above copyright notice and this permission notice shall be included in
27
+ all copies or substantial portions of the Software.
28
+
29
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35
+ THE SOFTWARE.
36
+ */
37
+
38
+ if(jQuery)(
39
+ function(jQuery){
40
+ jQuery.extend(jQuery.fn,{
41
+ uploadify:function(options,swfUploadOptions) {
42
+ jQuery(this).each(function() {
43
+ var clone = jQuery(this).clone();
44
+ var settings = jQuery.extend({
45
+ // Required Settings
46
+ id : jQuery(this).attr('id'),
47
+ swf : 'uploadify.swf',
48
+ uploader : 'uploadify.php',
49
+
50
+ // Options
51
+ auto : false,
52
+ buttonClass : '',
53
+ buttonCursor : 'hand',
54
+ buttonImage : false,
55
+ buttonText : 'SELECT FILES',
56
+ cancelImage : 'uploadify-cancel.png',
57
+ checkExisting : 'uploadify-check-existing.php',
58
+ debug : false,
59
+ fileObjName : 'Filedata',
60
+ fileSizeLimit : 0,
61
+ fileTypeDesc : 'All Files (*.*)',
62
+ fileTypeExts : '*.*',
63
+ height : 30,
64
+ method : 'post',
65
+ multi : false,
66
+ queueID : false,
67
+ queueSizeLimit : 999,
68
+ removeCompleted : true,
69
+ removeTimeout : 3,
70
+ requeueErrors : true,
71
+ postData : {},
72
+ preventCaching : true,
73
+ progressData : 'percentage',
74
+ // simUploadLimit : 1, // Not possible with swfUpload
75
+ successTimeout : 30,
76
+ transparent : true,
77
+ uploadLimit : 999,
78
+ uploaderType : 'html5', // the other option is 'flash'
79
+ width : 120,
80
+
81
+ // Events
82
+ skipDefault : [],
83
+ onClearQueue : function() {},
84
+ onDialogOpen : function() {},
85
+ onDialogClose : function() {},
86
+ onInit : function() {},
87
+ onQueueComplete : function() {},
88
+ onSelectError : function() {},
89
+ onSelect : function() {},
90
+ onSWFReady : function() {},
91
+ onUploadCancel : function() {},
92
+ onUploadComplete : function() {},
93
+ onUploadError : function() {},
94
+ onUploadProgress : function() {},
95
+ onUploadStart : function() {}
96
+ }, options);
97
+
98
+ var swfUploadSettings = {
99
+ assume_success_timeout : settings.successTimeout,
100
+ button_placeholder_id : settings.id,
101
+ button_image_url : settings.buttonImage,
102
+ button_width : settings.width,
103
+ button_height : settings.height,
104
+ button_text : null,
105
+ button_text_style : null,
106
+ button_text_top_padding : 0,
107
+ button_text_left_padding : 0,
108
+ button_action : (settings.multi ? SWFUpload.BUTTON_ACTION.SELECT_FILES : SWFUpload.BUTTON_ACTION.SELECT_FILE),
109
+ button_disabled : false,
110
+ button_cursor : (settings.buttonCursor == 'arrow' ? SWFUpload.CURSOR.ARROW : SWFUpload.CURSOR.HAND),
111
+ button_window_mode : (settings.transparent && !settings.buttonImage ? SWFUpload.WINDOW_MODE.TRANSPARENT : SWFUpload.WINDOW_MODE.OPAQUE),
112
+ debug : settings.debug,
113
+ requeue_on_error : settings.requeueErrors,
114
+ file_post_name : settings.fileObjName,
115
+ file_size_limit : settings.fileSizeLimit,
116
+ file_types : settings.fileTypeExts,
117
+ file_types_description : settings.fileTypeDesc,
118
+ file_queue_limit : settings.queueSizeLimit,
119
+ file_upload_limit : settings.uploadLimit,
120
+ flash_url : settings.swf,
121
+ prevent_swf_caching : settings.preventCaching,
122
+ post_params : settings.postData,
123
+ upload_url : settings.uploader,
124
+ use_query_string : (settings.method == 'get'),
125
+
126
+ // Event Handlers
127
+ file_dialog_complete_handler : onDialogClose,
128
+ file_dialog_start_handler : onDialogOpen,
129
+ file_queued_handler : onSelect,
130
+ file_queue_error_handler : onSelectError,
131
+ flash_ready_handler : settings.onSWFReady,
132
+ upload_complete_handler : onUploadComplete,
133
+ upload_error_handler : onUploadError,
134
+ upload_progress_handler : onUploadProgress,
135
+ upload_start_handler : onUploadStart,
136
+ upload_success_handler : onUploadSuccess
137
+ }
138
+ if (swfUploadOptions) {
139
+ swfUploadSettings = jQuery.extend(swfUploadSettings,swfUploadOptions);
140
+ }
141
+ swfUploadSettings = jQuery.extend(swfUploadSettings,settings);
142
+
143
+ // Create the swfUpload instance
144
+ window['uploadify_' + settings.id] = new SWFUpload(swfUploadSettings);
145
+ var swfuploadify = window['uploadify_' + settings.id];
146
+ swfuploadify.original = clone;
147
+
148
+ // Wrap the uploadify instance
149
+ var wrapper = jQuery('<div />',{
150
+ id : settings.id,
151
+ 'class' : 'uploadify',
152
+ css : {
153
+ 'height' : settings.height + 'px',
154
+ 'position' : 'relative',
155
+ 'width' : settings.width + 'px'
156
+ }
157
+ });
158
+ jQuery('#' + swfuploadify.movieName).wrap(wrapper);
159
+
160
+ // Create the file queue
161
+ if (!settings.queueID) {
162
+ var queue = jQuery('<div />', {
163
+ id : settings.id + '_queue',
164
+ 'class' : 'uploadifyQueue'
165
+ });
166
+ jQuery('#' + settings.id).after(queue);
167
+ swfuploadify.settings.queueID = settings.queueID = settings.id + '_queue';
168
+ }
169
+
170
+ // Create some queue related objects and variables
171
+ swfuploadify.queue = {
172
+ files : {}, // The files in the queue
173
+ filesSelected : 0, // The number of files selected in the last select operation
174
+ filesQueued : 0, // The number of files added to the queue in the last select operation
175
+ filesReplaced : 0, // The number of files replaced in the last select operation
176
+ filesCancelled : 0, // The number of files that were cancelled instead of replaced
177
+ filesErrored : 0, // The number of files that caused error in the last select operation
178
+ averageSpeed : 0, // The average speed of the uploads in KB
179
+ queueLength : 0, // The number of files in the queue
180
+ queueSize : 0, // The size in bytes of the entire queue
181
+ uploadSize : 0, // The size in bytes of the upload queue
182
+ queueBytesUploaded : 0, // The size in bytes that have been uploaded for the current upload queue
183
+ uploadQueue : [], // The files currently to be uploaded
184
+ errorMsg : 'Some files were not added to the queue:'
185
+ };
186
+
187
+ // Create the button
188
+ if (!settings.buttonImage) {
189
+ var button = jQuery('<a />', {
190
+ id : settings.id + '_button',
191
+ 'class' : 'uploadifyButton ' + settings.buttonClass,
192
+ html : settings.buttonText
193
+ });
194
+ jQuery('#' + settings.id).append(button);
195
+ jQuery('#' + swfuploadify.movieName).css({position: 'absolute', 'z-index': 1});
196
+ } else {
197
+ jQuery('#' + swfuploadify.movieName).addClass(settings.buttonClass);
198
+ }
199
+
200
+ // -----------------------------
201
+ // Begin Event Handler Functions
202
+ // -----------------------------
203
+
204
+ // Triggered once when file dialog is closed
205
+ function onDialogClose(filesSelected,filesQueued,queueLength) {
206
+ var stats = swfuploadify.getStats();
207
+ swfuploadify.queue.filesErrored = filesSelected - filesQueued;
208
+ swfuploadify.queue.filesSelected = filesSelected;
209
+ swfuploadify.queue.filesQueued = filesQueued - swfuploadify.queue.filesCancelled;
210
+ swfuploadify.queue.queueLength = queueLength;
211
+ if (jQuery.inArray('onDialogClose',swfuploadify.settings.skipDefault) < 0) {
212
+ if (swfuploadify.queue.filesErrored > 0) {
213
+ alert(swfuploadify.queue.errorMsg);
214
+ }
215
+ }
216
+ if (swfuploadify.settings.onDialogClose) swfuploadify.settings.onDialogClose(swfuploadify.queue);
217
+ if (swfuploadify.settings.auto) jQuery('#' + swfuploadify.settings.id).uploadifyUpload('*');
218
+ }
219
+
220
+ function onDialogOpen() {
221
+ // Reset some queue info
222
+ swfuploadify.queue.errorMsg = 'Some files were not added to the queue:';
223
+ swfuploadify.queue.filesReplaced = 0;
224
+ swfuploadify.queue.filesCancelled = 0;
225
+ if (swfuploadify.settings.onDialogOpen) swfuploadify.settings.onDialogOpen();
226
+ }
227
+
228
+ // Triggered once for each file added to the queue
229
+ function onSelect(file) {
230
+ if (jQuery.inArray('onSelect',swfuploadify.settings.skipDefault) < 0) {
231
+ // Check if a file with the same name exists in the queue
232
+ var queuedFile = {};
233
+ for (var n in swfuploadify.queue.files) {
234
+ queuedFile = swfuploadify.queue.files[n];
235
+ if (queuedFile.name == file.name) {
236
+ var replaceQueueItem = confirm('The file named "' + file.name + '" is already in the queue.\nDo you want to replace the existing item in the queue?');
237
+ if (!replaceQueueItem) {
238
+ swfuploadify.cancelUpload(file.id);
239
+ swfuploadify.queue.filesCancelled++;
240
+ return false;
241
+ } else {
242
+ jQuery('#' + queuedFile.id).remove();
243
+ swfuploadify.cancelUpload(queuedFile.id);
244
+ swfuploadify.queue.filesReplaced++;
245
+ }
246
+ }
247
+ }
248
+
249
+ // Get the size of the file
250
+ var fileSize = Math.round(file.size / 1024);
251
+ var suffix = 'KB';
252
+ if (fileSize > 1000) {
253
+ fileSize = Math.round(fileSize / 1000);
254
+ suffix = 'MB';
255
+ }
256
+ var fileSizeParts = fileSize.toString().split('.');
257
+ fileSize = fileSizeParts[0];
258
+ if (fileSizeParts.length > 1) {
259
+ fileSize += '.' + fileSizeParts[1].substr(0,2);
260
+ }
261
+ fileSize += suffix;
262
+
263
+ // Truncate the filename if it's too long
264
+ var fileName = file.name;
265
+ if (fileName.length > 25) {
266
+ fileName = fileName.substr(0,25) + '...';
267
+ }
268
+
269
+ // Add the file item to the queue
270
+ jQuery('#' + swfuploadify.settings.queueID).append('<div id="' + file.id + '" class="uploadifyQueueItem">\
271
+ <div class="cancel">\
272
+ <a href="javascript:jQuery(\'#' + swfuploadify.settings.id + '\').uploadifyCancel(\'' + file.id + '\')"><img src="' + swfuploadify.settings.cancelImage + '" border="0" /></a>\
273
+ </div>\
274
+ <span class="fileName">' + fileName + ' (' + fileSize + ')</span><span class="data"></span>\
275
+ <div class="uploadifyProgress">\
276
+ <div class="uploadifyProgressBar"><!--Progress Bar--></div>\
277
+ </div>\
278
+ </div>');
279
+ swfuploadify.queue.queueSize += file.size;
280
+ }
281
+ swfuploadify.queue.files[file.id] = file;
282
+ if (swfuploadify.settings.onSelect) swfuploadify.settings.onSelect(file);
283
+ }
284
+
285
+ // Triggered when a file is not added to the queue
286
+ function onSelectError(file,errorCode,errorMsg) {
287
+ if (jQuery.inArray('onSelectError',swfuploadify.settings.skipDefault) < 0) {
288
+ switch(errorCode) {
289
+ case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
290
+ if (swfuploadify.settings.queueSizeLimit > errorMsg) {
291
+ swfuploadify.queue.errorMsg += '\nThe number of files selected exceeds the remaining upload limit (' + errorMsg + ').';
292
+ } else {
293
+ swfuploadify.queue.errorMsg += '\nThe number of files selected exceeds the queue size limit (' + swfuploadify.settings.queueSizeLimit + ').';
294
+ }
295
+ break;
296
+ case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
297
+ swfuploadify.queue.errorMsg += '\nThe file "' + file.name + '" exceeds the size limit (' + swfuploadify.settings.fileSizeLimit + ').';
298
+ break;
299
+ case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
300
+ swfuploadify.queue.errorMsg += '\nThe file "' + file.name + '" is empty.';
301
+ break;
302
+ case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
303
+ swfuploadify.queue.errorMsg += '\nThe file "' + file.name + '" is not an accepted file type (' + swfuploadify.settings.fileTypeDesc + ').';
304
+ break;
305
+ }
306
+ }
307
+ if (errorCode != SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
308
+ delete swfuploadify.queue.files[file.id];
309
+ }
310
+ if (swfuploadify.settings.onSelectError) swfuploadify.settings.onSelectError(file,errorCode,errorMsg);
311
+ }
312
+
313
+ // Triggered when all the files in the queue have been processed
314
+ function onQueueComplete() {
315
+ var stats = swfuploadify.getStats();
316
+ if (swfuploadify.settings.onQueueComplete) swfuploadify.settings.onQueueComplete(stats);
317
+ }
318
+
319
+ // Triggered when a file upload successfully completes
320
+ function onUploadComplete(file) {
321
+ var stats = swfuploadify.getStats();
322
+ swfuploadify.queue.queueLength = stats.files_queued;
323
+ if (swfuploadify.queue.uploadQueue[0] == '*') {
324
+ if (swfuploadify.queue.queueLength > 0) {
325
+ swfuploadify.startUpload();
326
+ } else {
327
+ swfuploadify.queue.uploadQueue = [];
328
+ if (swfuploadify.settings.onQueueComplete) swfuploadify.settings.onQueueComplete(stats);
329
+ }
330
+ } else {
331
+ if (swfuploadify.queue.uploadQueue.length > 0) {
332
+ swfuploadify.startUpload(swfuploadify.queue.uploadQueue.shift());
333
+ } else {
334
+ swfuploadify.queue.uploadQueue = [];
335
+ if (swfuploadify.settings.onQueueComplete) settings.onQueueComplete(stats);
336
+ }
337
+ }
338
+ if (jQuery.inArray('onUploadComplete',swfuploadify.settings.skipDefault) < 0) {
339
+ if (swfuploadify.settings.removeCompleted) {
340
+ switch (file.filestatus) {
341
+ case SWFUpload.FILE_STATUS.COMPLETE:
342
+ setTimeout(function() {
343
+ if (jQuery('#' + file.id)) {
344
+ swfuploadify.queue.queueSize -= file.size;
345
+ delete swfuploadify.queue.files[file.id]
346
+ jQuery('#' + file.id).fadeOut(500,function() {
347
+ jQuery(this).remove();
348
+ });
349
+ }
350
+ },swfuploadify.settings.removeTimeout * 1000);
351
+ break;
352
+ case SWFUpload.FILE_STATUS.ERROR:
353
+ if (!swfuploadify.settings.requeueErrors) {
354
+ setTimeout(function() {
355
+ if (jQuery('#' + file.id)) {
356
+ swfuploadify.queue.queueSize -= file.size;
357
+ delete swfuploadify.queue.files[file.id];
358
+ jQuery('#' + file.id).fadeOut(500,function() {
359
+ jQuery(this).remove();
360
+ });
361
+ }
362
+ },swfuploadify.settings.removeTimeout * 1000);
363
+ }
364
+ break;
365
+ }
366
+ }
367
+ }
368
+ if (swfuploadify.settings.onUploadComplete) swfuploadify.settings.onUploadComplete(file,swfuploadify.queue);
369
+ }
370
+
371
+ // Triggered when a file upload returns an error
372
+ function onUploadError(file,errorCode,errorMsg) {
373
+ var errorString = 'Error';
374
+ if (errorCode != SWFUpload.UPLOAD_ERROR.FILE_CANCELLED && errorCode != SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED) {
375
+ jQuery('#' + file.id).addClass('uploadifyError');
376
+ }
377
+ jQuery('#' + file.id).find('.uploadifyProgressBar').css('width','1px');
378
+ switch(errorCode) {
379
+ case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
380
+ errorString = 'HTTP Error (' + errorMsg + ')';
381
+ break;
382
+ case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
383
+ errorString = 'Missing Upload URL';
384
+ break;
385
+ case SWFUpload.UPLOAD_ERROR.IO_ERROR:
386
+ errorString = 'IO Error';
387
+ break;
388
+ case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
389
+ errorString = 'Security Error';
390
+ break;
391
+ case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
392
+ alert('The upload limit has been reached (' + errorMsg + ').');
393
+ errorString = 'Exceeds Upload Limit';
394
+ break;
395
+ case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
396
+ errorString = 'Failed';
397
+ break;
398
+ case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
399
+ break;
400
+ case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
401
+ errorString = 'Validation Error';
402
+ break;
403
+ case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
404
+ errorString = 'Cancelled';
405
+ swfuploadify.queue.queueSize -= file.size;
406
+ if (file.status == SWFUpload.FILE_STATUS.IN_PROGRESS || jQuery.inArray(file.id,swfuploadify.queue.uploadQueue) >= 0) {
407
+ swfuploadify.queue.uploadSize -= file.size;
408
+ }
409
+ delete swfuploadify.queue.files[file.id];
410
+ break;
411
+ case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
412
+ errorString = 'Stopped';
413
+ break;
414
+ }
415
+ if (errorCode != SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND && file.status != SWFUpload.FILE_STATUS.COMPLETE) {
416
+ jQuery('#' + file.id).find('.data').html(' - ' + errorString);
417
+ }
418
+ if (swfuploadify.settings.onUploadError) swfuploadify.settings.onUploadError(file,errorCode,errorMsg,errorString,swfuploadify.queue);
419
+ }
420
+
421
+ // Triggered periodically during a file upload
422
+ function onUploadProgress(file,fileBytesLoaded,fileTotalBytes) {
423
+ var timer = new Date();
424
+ var newTime = timer.getTime();
425
+ var lapsedTime = newTime - swfuploadify.timer;
426
+ swfuploadify.timer = newTime;
427
+ var lapsedBytes = fileBytesLoaded - swfuploadify.bytesLoaded;
428
+ swfuploadify.bytesLoaded = fileBytesLoaded;
429
+ var queueBytesLoaded = swfuploadify.queue.queueBytesUploaded + fileBytesLoaded;
430
+ var percentage = Math.round(fileBytesLoaded / fileTotalBytes * 100);
431
+
432
+ // Calculate the average speed
433
+ var mbs = 0;
434
+ var kbs = (lapsedBytes / 1024) / (lapsedTime / 1000);
435
+ kbs = Math.floor(kbs * 10) / 10;
436
+ if (swfuploadify.queue.averageSpeed > 0) {
437
+ swfuploadify.queue.averageSpeed = (swfuploadify.queue.averageSpeed + kbs) / 2;
438
+ } else {
439
+ swfuploadify.queue.averageSpeed = kbs;
440
+ }
441
+ if (kbs > 1000) {
442
+ mbs = (kbs * .001);
443
+ swfuploadify.queue.averageSpeed = mbs;
444
+ }
445
+ var suffix = 'KB/s';
446
+ if (mbs > 0) {
447
+ suffix = 'MB/s';
448
+ }
449
+
450
+ if (jQuery.inArray('onUploadProgress',swfuploadify.settings.skipDefault) < 0) {
451
+ if (swfuploadify.settings.progressData == 'percentage') {
452
+ jQuery('#' + file.id).find('.data').html(' - ' + percentage + '%');
453
+ } else if (swfuploadify.settings.progressData == 'speed') {
454
+ jQuery('#' + file.id).find('.data').html(' - ' + percentage + suffix);
455
+ }
456
+ jQuery('#' + file.id).find('.uploadifyProgressBar').css('width',percentage + '%');
457
+ }
458
+ if (swfuploadify.settings.onUploadProgress) swfuploadify.settings.onUploadProgress(file,fileBytesLoaded,fileTotalBytes,queueBytesLoaded,swfuploadify.queue.uploadSize);
459
+ }
460
+
461
+ // Triggered right before a file is uploaded
462
+ function onUploadStart(file) {
463
+ var timer = new Date();
464
+ swfuploadify.timer = timer.getTime();
465
+ swfuploadify.bytesLoaded = 0;
466
+ if (swfuploadify.queue.uploadQueue.length == 0) {
467
+ swfuploadify.queue.uploadSize = file.size;
468
+ }
469
+ if (swfuploadify.settings.checkExisting !== false) {
470
+ jQuery.ajax({
471
+ type : 'POST',
472
+ async : false,
473
+ url : swfuploadify.settings.checkExisting,
474
+ data : {filename: file.name},
475
+ success : function(data) {
476
+ if (data == 1) {
477
+ var overwrite = confirm('A file with the name "' + file.name + '" already exists on the server.\nWould you like to replace the existing file?');
478
+ if (!overwrite) {
479
+ swfuploadify.cancelUpload(file.id);
480
+ jQuery('#' + file.id).remove();
481
+ if (swfuploadify.queue.uploadQueue.length > 0 && swfuploadify.queue.queueLength > 0) {
482
+ if (swfuploadify.queue.uploadQueue[0] == '*') {
483
+ swfuploadify.startUpload();
484
+ } else {
485
+ swfuploadify.startUpload(swfuploadify.queue.uploadQueue.shift());
486
+ }
487
+ }
488
+ }
489
+ }
490
+ }
491
+ });
492
+ }
493
+ if (swfuploadify.settings.onUploadStart) swfuploadify.settings.onUploadStart(file);
494
+ }
495
+
496
+ // Triggered when a file upload returns a successful code
497
+ function onUploadSuccess(file,data,response) {
498
+ swfuploadify.queue.queueBytesUploaded += file.size;
499
+ jQuery('#' + file.id).find('.data').html(' - Complete');
500
+ if (swfuploadify.settings.onUploadSuccess) swfuploadify.settings.onUploadSuccess(file,data,response);
501
+ }
502
+
503
+ // ---------------------------
504
+ // End Event Handler Functions
505
+ // ---------------------------
506
+ });
507
+ },
508
+
509
+ // Cancel a file upload and remove it from the queue
510
+ uploadifyCancel:function(fileID) {
511
+ var id = jQuery(this).selector.replace('#','');
512
+ var swfuploadify = window['uploadify_' + id];
513
+ var delay = -1;
514
+ if (arguments[0]) {
515
+ if (arguments[0] == '*') {
516
+ jQuery('#' + swfuploadify.settings.queueID).find('.uploadifyQueueItem').each(function() {
517
+ delay++;
518
+ swfuploadify.cancelUpload(jQuery(this).attr('id'));
519
+ jQuery(this).delay(100 * delay).fadeOut(500,function() {
520
+ jQuery(this).remove();
521
+
522
+ });
523
+ });
524
+ swfuploadify.queue.queueSize = 0;
525
+ } else {
526
+ for (var n = 0; n < arguments.length; n++) {
527
+ swfuploadify.cancelUpload(arguments[n]);
528
+ jQuery('#' + arguments[n]).delay(100 * n).fadeOut(500,function() {
529
+ jQuery(this).remove();
530
+ });
531
+ }
532
+ }
533
+ } else {
534
+ jQuery('#' + swfuploadify.settings.queueID).find('.uploadifyQueueItem').get(0).fadeOut(500,function() {
535
+ jQuery(this).remove();
536
+ swfuploadify.cancelUpload(jQuery(this).attr('id'));
537
+ });
538
+ }
539
+ },
540
+
541
+ // Get rid of the instance of Uploadify
542
+ uploadifyDestroy:function() {
543
+ var id = jQuery(this).selector.replace('#','');
544
+ var swfuploadify = window['uploadify_' + id];
545
+ swfuploadify.destroy();
546
+ jQuery('#' + id + '_queue').remove();
547
+ jQuery('#' + id).replaceWith(swfuploadify.original);
548
+ delete window['uploadify_' + id];
549
+ },
550
+
551
+ // Disable the select button
552
+ uploadifyDisable:function(isDisabled) {
553
+ var id = jQuery(this).selector.replace('#','');
554
+ var swfuploadify = window['uploadify_' + id];
555
+ swfuploadify.setButtonDisabled(isDisabled);
556
+ },
557
+
558
+ // Update or retrieve a setting
559
+ uploadifySettings:function(name,value,resetObjects) {
560
+ var id = jQuery(this).selector.replace('#','');
561
+ var swfuploadify = window['uploadify_' + id];
562
+ if (typeof(arguments[0]) == 'object') {
563
+ for (var n in value) {
564
+ setData(n,value[n]);
565
+ }
566
+ }
567
+ if (arguments.length == 1) {
568
+ return swfuploadify.settings[name];
569
+ } else {
570
+ setData(name,value,resetObjects);
571
+ }
572
+
573
+ function setData(settingName,settingValue,resetObjects) {
574
+ switch (settingName) {
575
+ case 'uploader':
576
+ swfuploadify.setUploadURL(settingValue);
577
+ break;
578
+ case 'postData':
579
+ if (!resetObjects) {
580
+ value = jQuery.extend(swfuploadify.settings.postData,settingValue);
581
+ }
582
+ swfuploadify.setPostParams(settingValue);
583
+ break;
584
+ case 'method':
585
+ if (settingValue == 'get') {
586
+ swfuploadify.setUseQueryString(true);
587
+ } else {
588
+ swfuploadify.setUseQueryString(false);
589
+ }
590
+ break;
591
+ case 'fileObjName':
592
+ swfuploadify.setFilePostName(settingValue);
593
+ break;
594
+ case 'fileTypeExts':
595
+ swfuploadify.setFileTypes(settingValue,swfuploadify.settings.fileTypeDesc);
596
+ break;
597
+ case 'fileTypeDesc':
598
+ swfuploadify.setFileTypes(swfuploadify.settings.fileTypeExts,settingValue);
599
+ break;
600
+ case 'fileSizeLimit':
601
+ swfuploadify.setFileSizeLimit(settingValue);
602
+ break;
603
+ case 'uploadLimit':
604
+ swfuploadify.setFileUploadLimit(settingValue);
605
+ break;
606
+ case 'queueSizeLimit':
607
+ swfuploadify.setFileQueueLimit(settingValue);
608
+ break;
609
+ case 'buttonImage':
610
+ jQuery('#' + swfuploadify.settings.id + '_button').remove();
611
+ swfuploadify.setButtonImageURL(settingValue);
612
+ break;
613
+ case 'buttonCursor':
614
+ if (settingValue == 'arrow') {
615
+ swfuploadify.setButtonCursor(SWFUpload.CURSOR.ARROW);
616
+ } else {
617
+ swfuploadify.setButtonCursor(SWFUpload.CURSOR.HAND);
618
+ }
619
+ break;
620
+ case 'buttonText':
621
+ jQuery('#' + swfuploadify.settings.id + '_button').find('.uploadifyButtonText').html(settingValue);
622
+ break;
623
+ case 'width':
624
+ swfuploadify.setButtonDimensions(settingValue,swfuploadify.settings.height);
625
+ break;
626
+ case 'height':
627
+ swfuploadify.setButtonDimensions(swfuploadify.settings.width,settingValue);
628
+ break;
629
+ case 'multi':
630
+ if (settingValue) {
631
+ swfuploadify.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILES);
632
+ } else {
633
+ swfuploadify.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILE);
634
+ }
635
+ break;
636
+ }
637
+ swfuploadify.settings[settingName] = value;
638
+ }
639
+ },
640
+
641
+ // Stop the current upload and requeue what is in progress
642
+ uploadifyStop:function() {
643
+ var id = jQuery(this).selector.replace('#','');
644
+ var swfuploadify = window['uploadify_' + id];
645
+ swfuploadify.stopUpload();
646
+ },
647
+
648
+ // Upload the first file, a select number of files, or all the files in the queue
649
+ uploadifyUpload:function() {
650
+ var id = jQuery(this).selector.replace('#','');
651
+ var swfuploadify = window['uploadify_' + id];
652
+
653
+ // Reset the queue information
654
+ swfuploadify.queue.averageSpeed = 0;
655
+ swfuploadify.queue.uploadSize = 0;
656
+ swfuploadify.queue.bytesUploaded = 0;
657
+ swfuploadify.queue.uploadQueue = [];
658
+
659
+ if (arguments[0]) {
660
+ if (arguments[0] == '*') {
661
+ swfuploadify.queue.uploadSize = swfuploadify.queue.queueSize;
662
+ swfuploadify.queue.uploadQueue.push('*');
663
+ swfuploadify.startUpload();
664
+ } else {
665
+ for (var n = 0; n < arguments.length; n++) {
666
+ swfuploadify.queue.uploadSize += swfuploadify.queue.files[arguments[n]].size;
667
+ swfuploadify.queue.uploadQueue.push(arguments[n]);
668
+ }
669
+ swfuploadify.startUpload(swfuploadify.queue.uploadQueue.shift());
670
+ }
671
+ } else {
672
+ swfuploadify.startUpload();
673
+ }
674
+ }
675
+ })
676
+ }
677
+ )(jQuery);