muck-contents 0.1.12 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +122 -15
- data/VERSION +1 -1
- data/app/controllers/muck/tiny_mce_controller.rb +47 -0
- data/app/helpers/tinymce_helper.rb +23 -8
- data/app/views/contents/_form.html.erb +1 -2
- data/app/views/contents/new.html.erb +1 -0
- data/app/views/layouts/tiny_mce.html.erb +25 -0
- data/app/views/tiny_mce/files.html.erb +136 -0
- data/app/views/tiny_mce/images.html.erb +312 -0
- data/{public/javascripts/tiny_mce/plugins/advlinktoo/link.htm → app/views/tiny_mce/links.html.erb} +328 -344
- data/config/muck_contents_routes.rb +6 -0
- data/lib/action_controller/acts/muck_content_handler.rb +1 -1
- data/locales/en.yml +2 -0
- data/muck-contents.gemspec +153 -25
- data/public/{javascripts/tiny_mce/plugins/advimagetoo/img → images/tinymce}/sample.gif +0 -0
- data/public/{javascripts/tiny_mce/plugins/advfiletoo/img → images/tinymce}/upload.gif +0 -0
- data/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin.js +9 -22
- data/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin_src.js +41 -54
- data/public/javascripts/tiny_mce/plugins/advfiletoo/js/functions.js +0 -139
- data/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin.js +9 -17
- data/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin_src.js +40 -50
- data/public/javascripts/tiny_mce/plugins/advimagetoo/js/functions.js +0 -152
- data/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin.js +3 -14
- data/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin_src.js +3 -14
- data/public/{javascripts/tiny_mce/plugins/advfiletoo/css/advfile.css → stylesheets/tinymce.css} +33 -12
- data/test/rails_root/Rakefile +2 -1
- data/test/rails_root/app/controllers/uploads_controller.rb +57 -0
- data/test/rails_root/app/models/upload.rb +94 -0
- data/test/rails_root/app/models/user.rb +5 -0
- data/test/rails_root/config/environment.rb +2 -0
- data/test/rails_root/config/initializers/mce_options.rb +12 -8
- data/test/rails_root/config/initializers/s3_credentials.rb +9 -0
- data/test/rails_root/db/migrate/{20090602041838_create_users.rb → 20090327231918_create_users.rb} +11 -10
- data/test/rails_root/db/migrate/20090402234137_create_languages.rb +18 -0
- data/test/rails_root/db/migrate/20090426041056_create_countries.rb +15 -0
- data/test/rails_root/db/migrate/20090426041103_create_states.rb +18 -0
- data/test/rails_root/db/migrate/{20090704220120_acts_as_taggable_on_migration.rb → 20090506000404_acts_as_taggable_on_migration.rb} +31 -29
- data/test/rails_root/db/migrate/20090517040220_create_uploads.rb +38 -0
- data/test/rails_root/db/migrate/20090730044139_add_comment_cache.rb +9 -0
- data/test/rails_root/db/migrate/20090818204527_add_activity_indexes.rb +9 -0
- data/test/rails_root/db/migrate/20090819030523_add_attachable_to_activities.rb +13 -0
- data/test/rails_root/lib/daemons/amazonaws.rb +36 -0
- data/test/rails_root/lib/tasks/muck.rake +7 -0
- data/test/rails_root/public/images/SWFUploadButton.png +0 -0
- data/test/rails_root/public/images/arrow_down.gif +0 -0
- data/test/rails_root/public/images/arrow_up.gif +0 -0
- data/test/rails_root/public/images/cancelbutton.gif +0 -0
- data/test/rails_root/public/images/fancybox/fancy_closebox.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_left.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_progress.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_right.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_e.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_n.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_ne.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_nw.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_s.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_se.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_sw.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_w.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_title_left.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_title_main.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_title_right.png +0 -0
- data/test/rails_root/public/images/file_icons/excel.gif +0 -0
- data/test/rails_root/public/images/file_icons/file.gif +0 -0
- data/test/rails_root/public/images/file_icons/file.png +0 -0
- data/test/rails_root/public/images/file_icons/file_aac.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_ai.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_avi.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_bin.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_bmp.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_cue.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_divx.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_doc.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_eps.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_flac.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_flv.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_gif.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_html.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_ical.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_indd.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_inx.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_iso.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_jpg.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_mov.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_mp3.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_mpg.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_pdf.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_php.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_png.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_pps.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_ppt.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_psd.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_qxd.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_qxp.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_raw.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_rtf.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_svg.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_tif.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_txt.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_vcf.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_wav.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_wma.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_xls.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_xml.gif +0 -0
- data/test/rails_root/public/images/file_icons/mp3.gif +0 -0
- data/test/rails_root/public/images/file_icons/pdf.gif +0 -0
- data/test/rails_root/public/images/file_icons/pdf.png +0 -0
- data/test/rails_root/public/images/file_icons/text.gif +0 -0
- data/test/rails_root/public/images/file_icons/text.png +0 -0
- data/test/rails_root/public/images/file_icons/word.gif +0 -0
- data/test/rails_root/public/images/icons/blue_guy.png +0 -0
- data/test/rails_root/public/images/icons/button_background.png +0 -0
- data/test/rails_root/public/images/icons/cancel.png +0 -0
- data/test/rails_root/public/images/icons/close.png +0 -0
- data/test/rails_root/public/images/icons/comment.png +0 -0
- data/test/rails_root/public/images/icons/exclaim.png +0 -0
- data/test/rails_root/public/images/icons/external.png +0 -0
- data/test/rails_root/public/images/icons/feed.png +0 -0
- data/test/rails_root/public/images/icons/grey_guy.png +0 -0
- data/test/rails_root/public/images/icons/hide.png +0 -0
- data/test/rails_root/public/images/icons/information.png +0 -0
- data/test/rails_root/public/images/icons/minus.png +0 -0
- data/test/rails_root/public/images/icons/pending.png +0 -0
- data/test/rails_root/public/images/icons/question.png +0 -0
- data/test/rails_root/public/images/icons/search_box.png +0 -0
- data/test/rails_root/public/images/icons/star.png +0 -0
- data/test/rails_root/public/images/icons/stop.png +0 -0
- data/test/rails_root/public/images/icons/thumb_down.png +0 -0
- data/test/rails_root/public/images/icons/thumb_up.png +0 -0
- data/test/rails_root/public/images/nothing.png +0 -0
- data/test/rails_root/public/{javascripts/tiny_mce/plugins/advimagetoo/img → images/tinymce}/sample.gif +0 -0
- data/test/rails_root/public/{javascripts/tiny_mce/plugins/advfiletoo/img → images/tinymce}/upload.gif +0 -0
- data/test/rails_root/public/javascripts/jquery/colorpicker.js +450 -0
- data/test/rails_root/public/javascripts/jquery/jquery.autocomplete.js.readme +6 -0
- data/test/rails_root/public/javascripts/jquery/jquery.autocomplete.min.js +15 -0
- data/test/rails_root/public/javascripts/jquery/jquery.autocomplete.pack.js +767 -0
- data/test/rails_root/public/javascripts/jquery/jquery.easing.js +1 -0
- data/test/rails_root/public/javascripts/jquery/jquery.fancybox.js +9 -0
- data/test/rails_root/public/javascripts/jquery/jquery.metadata.min.js +13 -0
- data/test/rails_root/public/javascripts/jquery/jquery.queryString.js +33 -0
- data/test/rails_root/public/javascripts/jquery/jquery.swapimage.js +66 -0
- data/test/rails_root/public/javascripts/jquery/jquery.swapimage.min.js +11 -0
- data/test/rails_root/public/javascripts/jquery/jrails.js +1 -0
- data/test/rails_root/public/javascripts/muck.js +11 -6
- data/test/rails_root/public/javascripts/muck_activities.js +5 -6
- data/test/rails_root/public/javascripts/muck_time/en.js +53 -0
- data/test/rails_root/public/javascripts/swfupload/fileprogress.js +151 -0
- data/test/rails_root/public/javascripts/swfupload/handlers.js +201 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.cookies.js +53 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.js +980 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.queue.js +98 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.speed.js +342 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.swfobject.js +111 -0
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin.js +9 -22
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin_src.js +41 -54
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/js/functions.js +0 -139
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin.js +9 -17
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin_src.js +40 -50
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/image.htm +10 -9
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/js/functions.js +0 -152
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin.js +3 -14
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin_src.js +3 -14
- data/test/rails_root/public/javascripts/tiny_mce/templates/example.htm +14 -0
- data/test/rails_root/public/javascripts/tree.js +107 -0
- data/test/rails_root/public/stylesheets/jquery/jquery.autocomplete.css +15 -0
- data/test/rails_root/public/stylesheets/jquery/jquery.fancybox.css +44 -0
- data/test/rails_root/public/stylesheets/muck-activities.css +39 -0
- data/test/rails_root/public/stylesheets/styles.css +10 -3
- data/test/rails_root/public/stylesheets/swfupload.css +26 -0
- data/test/rails_root/public/{javascripts/tiny_mce/plugins/advfiletoo/css/advfile.css → stylesheets/tinymce.css} +33 -12
- data/test/rails_root/public/system/locals/000/000/026/original/deploy-1.rb +75 -0
- metadata +153 -25
- data/public/javascripts/tiny_mce/plugins/advfiletoo/file.htm +0 -139
- data/public/javascripts/tiny_mce/plugins/advimagetoo/css/advimage.css +0 -32
- data/public/javascripts/tiny_mce/plugins/advimagetoo/image.htm +0 -303
- data/public/javascripts/tiny_mce/plugins/advlinktoo/css/advlink.css +0 -8
- data/test/rails_root/db/migrate/20090608073052_create_friends.rb +0 -16
- data/test/rails_root/db/migrate/20090808005918_add_scope_index_to_slugs.rb +0 -9
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/file.htm +0 -139
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/css/advimage.css +0 -32
- data/test/rails_root/public/javascripts/tiny_mce/templates/bio.htm +0 -31
- data/test/rails_root/public/javascripts/tiny_mce/templates/country.htm +0 -59
@@ -0,0 +1,98 @@
|
|
1
|
+
/*
|
2
|
+
Queue Plug-in
|
3
|
+
|
4
|
+
Features:
|
5
|
+
*Adds a cancelQueue() method for cancelling the entire queue.
|
6
|
+
*All queued files are uploaded when startUpload() is called.
|
7
|
+
*If false is returned from uploadComplete then the queue upload is stopped.
|
8
|
+
If false is not returned (strict comparison) then the queue upload is continued.
|
9
|
+
*Adds a QueueComplete event that is fired when all the queued files have finished uploading.
|
10
|
+
Set the event handler with the queue_complete_handler setting.
|
11
|
+
|
12
|
+
*/
|
13
|
+
|
14
|
+
var SWFUpload;
|
15
|
+
if (typeof(SWFUpload) === "function") {
|
16
|
+
SWFUpload.queue = {};
|
17
|
+
|
18
|
+
SWFUpload.prototype.initSettings = (function (oldInitSettings) {
|
19
|
+
return function () {
|
20
|
+
if (typeof(oldInitSettings) === "function") {
|
21
|
+
oldInitSettings.call(this);
|
22
|
+
}
|
23
|
+
|
24
|
+
this.queueSettings = {};
|
25
|
+
|
26
|
+
this.queueSettings.queue_cancelled_flag = false;
|
27
|
+
this.queueSettings.queue_upload_count = 0;
|
28
|
+
|
29
|
+
this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
|
30
|
+
this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
|
31
|
+
this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
|
32
|
+
this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
|
33
|
+
|
34
|
+
this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
|
35
|
+
};
|
36
|
+
})(SWFUpload.prototype.initSettings);
|
37
|
+
|
38
|
+
SWFUpload.prototype.startUpload = function (fileID) {
|
39
|
+
this.queueSettings.queue_cancelled_flag = false;
|
40
|
+
this.callFlash("StartUpload", [fileID]);
|
41
|
+
};
|
42
|
+
|
43
|
+
SWFUpload.prototype.cancelQueue = function () {
|
44
|
+
this.queueSettings.queue_cancelled_flag = true;
|
45
|
+
this.stopUpload();
|
46
|
+
|
47
|
+
var stats = this.getStats();
|
48
|
+
while (stats.files_queued > 0) {
|
49
|
+
this.cancelUpload();
|
50
|
+
stats = this.getStats();
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
SWFUpload.queue.uploadStartHandler = function (file) {
|
55
|
+
var returnValue;
|
56
|
+
if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
|
57
|
+
returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
|
58
|
+
}
|
59
|
+
|
60
|
+
// To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
|
61
|
+
returnValue = (returnValue === false) ? false : true;
|
62
|
+
|
63
|
+
this.queueSettings.queue_cancelled_flag = !returnValue;
|
64
|
+
|
65
|
+
return returnValue;
|
66
|
+
};
|
67
|
+
|
68
|
+
SWFUpload.queue.uploadCompleteHandler = function (file) {
|
69
|
+
var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
|
70
|
+
var continueUpload;
|
71
|
+
|
72
|
+
if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
|
73
|
+
this.queueSettings.queue_upload_count++;
|
74
|
+
}
|
75
|
+
|
76
|
+
if (typeof(user_upload_complete_handler) === "function") {
|
77
|
+
continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
|
78
|
+
} else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
|
79
|
+
// If the file was stopped and re-queued don't restart the upload
|
80
|
+
continueUpload = false;
|
81
|
+
} else {
|
82
|
+
continueUpload = true;
|
83
|
+
}
|
84
|
+
|
85
|
+
if (continueUpload) {
|
86
|
+
var stats = this.getStats();
|
87
|
+
if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
|
88
|
+
this.startUpload();
|
89
|
+
} else if (this.queueSettings.queue_cancelled_flag === false) {
|
90
|
+
this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
|
91
|
+
this.queueSettings.queue_upload_count = 0;
|
92
|
+
} else {
|
93
|
+
this.queueSettings.queue_cancelled_flag = false;
|
94
|
+
this.queueSettings.queue_upload_count = 0;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
};
|
98
|
+
}
|
@@ -0,0 +1,342 @@
|
|
1
|
+
/*
|
2
|
+
Speed Plug-in
|
3
|
+
|
4
|
+
Features:
|
5
|
+
*Adds several properties to the 'file' object indicated upload speed, time left, upload time, etc.
|
6
|
+
- currentSpeed -- String indicating the upload speed, bytes per second
|
7
|
+
- averageSpeed -- Overall average upload speed, bytes per second
|
8
|
+
- movingAverageSpeed -- Speed over averaged over the last several measurements, bytes per second
|
9
|
+
- timeRemaining -- Estimated remaining upload time in seconds
|
10
|
+
- timeElapsed -- Number of seconds passed for this upload
|
11
|
+
- percentUploaded -- Percentage of the file uploaded (0 to 100)
|
12
|
+
- sizeUploaded -- Formatted size uploaded so far, bytes
|
13
|
+
|
14
|
+
*Adds setting 'moving_average_history_size' for defining the window size used to calculate the moving average speed.
|
15
|
+
|
16
|
+
*Adds several Formatting functions for formatting that values provided on the file object.
|
17
|
+
- SWFUpload.speed.formatBPS(bps) -- outputs string formatted in the best units (Gbps, Mbps, Kbps, bps)
|
18
|
+
- SWFUpload.speed.formatTime(seconds) -- outputs string formatted in the best units (x Hr y M z S)
|
19
|
+
- SWFUpload.speed.formatSize(bytes) -- outputs string formatted in the best units (w GB x MB y KB z B )
|
20
|
+
- SWFUpload.speed.formatPercent(percent) -- outputs string formatted with a percent sign (x.xx %)
|
21
|
+
- SWFUpload.speed.formatUnits(baseNumber, divisionArray, unitLabelArray, fractionalBoolean)
|
22
|
+
- Formats a number using the division array to determine how to apply the labels in the Label Array
|
23
|
+
- factionalBoolean indicates whether the number should be returned as a single fractional number with a unit (speed)
|
24
|
+
or as several numbers labeled with units (time)
|
25
|
+
*/
|
26
|
+
|
27
|
+
var SWFUpload;
|
28
|
+
if (typeof(SWFUpload) === "function") {
|
29
|
+
SWFUpload.speed = {};
|
30
|
+
|
31
|
+
SWFUpload.prototype.initSettings = (function (oldInitSettings) {
|
32
|
+
return function () {
|
33
|
+
if (typeof(oldInitSettings) === "function") {
|
34
|
+
oldInitSettings.call(this);
|
35
|
+
}
|
36
|
+
|
37
|
+
this.ensureDefault = function (settingName, defaultValue) {
|
38
|
+
this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
|
39
|
+
};
|
40
|
+
|
41
|
+
// List used to keep the speed stats for the files we are tracking
|
42
|
+
this.fileSpeedStats = {};
|
43
|
+
this.speedSettings = {};
|
44
|
+
|
45
|
+
this.ensureDefault("moving_average_history_size", "10");
|
46
|
+
|
47
|
+
this.speedSettings.user_file_queued_handler = this.settings.file_queued_handler;
|
48
|
+
this.speedSettings.user_file_queue_error_handler = this.settings.file_queue_error_handler;
|
49
|
+
this.speedSettings.user_upload_start_handler = this.settings.upload_start_handler;
|
50
|
+
this.speedSettings.user_upload_error_handler = this.settings.upload_error_handler;
|
51
|
+
this.speedSettings.user_upload_progress_handler = this.settings.upload_progress_handler;
|
52
|
+
this.speedSettings.user_upload_success_handler = this.settings.upload_success_handler;
|
53
|
+
this.speedSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
|
54
|
+
|
55
|
+
this.settings.file_queued_handler = SWFUpload.speed.fileQueuedHandler;
|
56
|
+
this.settings.file_queue_error_handler = SWFUpload.speed.fileQueueErrorHandler;
|
57
|
+
this.settings.upload_start_handler = SWFUpload.speed.uploadStartHandler;
|
58
|
+
this.settings.upload_error_handler = SWFUpload.speed.uploadErrorHandler;
|
59
|
+
this.settings.upload_progress_handler = SWFUpload.speed.uploadProgressHandler;
|
60
|
+
this.settings.upload_success_handler = SWFUpload.speed.uploadSuccessHandler;
|
61
|
+
this.settings.upload_complete_handler = SWFUpload.speed.uploadCompleteHandler;
|
62
|
+
|
63
|
+
delete this.ensureDefault;
|
64
|
+
};
|
65
|
+
})(SWFUpload.prototype.initSettings);
|
66
|
+
|
67
|
+
|
68
|
+
SWFUpload.speed.fileQueuedHandler = function (file) {
|
69
|
+
if (typeof this.speedSettings.user_file_queued_handler === "function") {
|
70
|
+
file = SWFUpload.speed.extendFile(file);
|
71
|
+
|
72
|
+
return this.speedSettings.user_file_queued_handler.call(this, file);
|
73
|
+
}
|
74
|
+
};
|
75
|
+
|
76
|
+
SWFUpload.speed.fileQueueErrorHandler = function (file, errorCode, message) {
|
77
|
+
if (typeof this.speedSettings.user_file_queue_error_handler === "function") {
|
78
|
+
file = SWFUpload.speed.extendFile(file);
|
79
|
+
|
80
|
+
return this.speedSettings.user_file_queue_error_handler.call(this, file, errorCode, message);
|
81
|
+
}
|
82
|
+
};
|
83
|
+
|
84
|
+
SWFUpload.speed.uploadStartHandler = function (file) {
|
85
|
+
if (typeof this.speedSettings.user_upload_start_handler === "function") {
|
86
|
+
file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
|
87
|
+
return this.speedSettings.user_upload_start_handler.call(this, file);
|
88
|
+
}
|
89
|
+
};
|
90
|
+
|
91
|
+
SWFUpload.speed.uploadErrorHandler = function (file, errorCode, message) {
|
92
|
+
file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
|
93
|
+
SWFUpload.speed.removeTracking(file, this.fileSpeedStats);
|
94
|
+
|
95
|
+
if (typeof this.speedSettings.user_upload_error_handler === "function") {
|
96
|
+
return this.speedSettings.user_upload_error_handler.call(this, file, errorCode, message);
|
97
|
+
}
|
98
|
+
};
|
99
|
+
SWFUpload.speed.uploadProgressHandler = function (file, bytesComplete, bytesTotal) {
|
100
|
+
this.updateTracking(file, bytesComplete);
|
101
|
+
file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
|
102
|
+
|
103
|
+
if (typeof this.speedSettings.user_upload_progress_handler === "function") {
|
104
|
+
return this.speedSettings.user_upload_progress_handler.call(this, file, bytesComplete, bytesTotal);
|
105
|
+
}
|
106
|
+
};
|
107
|
+
|
108
|
+
SWFUpload.speed.uploadSuccessHandler = function (file, serverData) {
|
109
|
+
if (typeof this.speedSettings.user_upload_success_handler === "function") {
|
110
|
+
file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
|
111
|
+
return this.speedSettings.user_upload_success_handler.call(this, file, serverData);
|
112
|
+
}
|
113
|
+
};
|
114
|
+
SWFUpload.speed.uploadCompleteHandler = function (file) {
|
115
|
+
file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
|
116
|
+
SWFUpload.speed.removeTracking(file, this.fileSpeedStats);
|
117
|
+
|
118
|
+
if (typeof this.speedSettings.user_upload_complete_handler === "function") {
|
119
|
+
return this.speedSettings.user_upload_complete_handler.call(this, file);
|
120
|
+
}
|
121
|
+
};
|
122
|
+
|
123
|
+
// Private: extends the file object with the speed plugin values
|
124
|
+
SWFUpload.speed.extendFile = function (file, trackingList) {
|
125
|
+
var tracking;
|
126
|
+
|
127
|
+
if (trackingList) {
|
128
|
+
tracking = trackingList[file.id];
|
129
|
+
}
|
130
|
+
|
131
|
+
if (tracking) {
|
132
|
+
file.currentSpeed = tracking.currentSpeed;
|
133
|
+
file.averageSpeed = tracking.averageSpeed;
|
134
|
+
file.movingAverageSpeed = tracking.movingAverageSpeed;
|
135
|
+
file.timeRemaining = tracking.timeRemaining;
|
136
|
+
file.timeElapsed = tracking.timeElapsed;
|
137
|
+
file.percentUploaded = tracking.percentUploaded;
|
138
|
+
file.sizeUploaded = tracking.bytesUploaded;
|
139
|
+
|
140
|
+
} else {
|
141
|
+
file.currentSpeed = 0;
|
142
|
+
file.averageSpeed = 0;
|
143
|
+
file.movingAverageSpeed = 0;
|
144
|
+
file.timeRemaining = 0;
|
145
|
+
file.timeElapsed = 0;
|
146
|
+
file.percentUploaded = 0;
|
147
|
+
file.sizeUploaded = 0;
|
148
|
+
}
|
149
|
+
|
150
|
+
return file;
|
151
|
+
};
|
152
|
+
|
153
|
+
// Private: Updates the speed tracking object, or creates it if necessary
|
154
|
+
SWFUpload.prototype.updateTracking = function (file, bytesUploaded) {
|
155
|
+
var tracking = this.fileSpeedStats[file.id];
|
156
|
+
if (!tracking) {
|
157
|
+
this.fileSpeedStats[file.id] = tracking = {};
|
158
|
+
}
|
159
|
+
|
160
|
+
// Sanity check inputs
|
161
|
+
bytesUploaded = bytesUploaded || tracking.bytesUploaded || 0;
|
162
|
+
if (bytesUploaded < 0) {
|
163
|
+
bytesUploaded = 0;
|
164
|
+
}
|
165
|
+
if (bytesUploaded > file.size) {
|
166
|
+
bytesUploaded = file.size;
|
167
|
+
}
|
168
|
+
|
169
|
+
var tickTime = (new Date()).getTime();
|
170
|
+
if (!tracking.startTime) {
|
171
|
+
tracking.startTime = (new Date()).getTime();
|
172
|
+
tracking.lastTime = tracking.startTime;
|
173
|
+
tracking.currentSpeed = 0;
|
174
|
+
tracking.averageSpeed = 0;
|
175
|
+
tracking.movingAverageSpeed = 0;
|
176
|
+
tracking.movingAverageHistory = [];
|
177
|
+
tracking.timeRemaining = 0;
|
178
|
+
tracking.timeElapsed = 0;
|
179
|
+
tracking.percentUploaded = bytesUploaded / file.size;
|
180
|
+
tracking.bytesUploaded = bytesUploaded;
|
181
|
+
} else if (tracking.startTime > tickTime) {
|
182
|
+
this.debug("When backwards in time");
|
183
|
+
} else {
|
184
|
+
// Get time and deltas
|
185
|
+
var now = (new Date()).getTime();
|
186
|
+
var lastTime = tracking.lastTime;
|
187
|
+
var deltaTime = now - lastTime;
|
188
|
+
var deltaBytes = bytesUploaded - tracking.bytesUploaded;
|
189
|
+
|
190
|
+
if (deltaBytes === 0 || deltaTime === 0) {
|
191
|
+
return tracking;
|
192
|
+
}
|
193
|
+
|
194
|
+
// Update tracking object
|
195
|
+
tracking.lastTime = now;
|
196
|
+
tracking.bytesUploaded = bytesUploaded;
|
197
|
+
|
198
|
+
// Calculate speeds
|
199
|
+
tracking.currentSpeed = (deltaBytes * 8 ) / (deltaTime / 1000);
|
200
|
+
tracking.averageSpeed = (tracking.bytesUploaded * 8) / ((now - tracking.startTime) / 1000);
|
201
|
+
|
202
|
+
// Calculate moving average
|
203
|
+
tracking.movingAverageHistory.push(tracking.currentSpeed);
|
204
|
+
if (tracking.movingAverageHistory.length > this.settings.moving_average_history_size) {
|
205
|
+
tracking.movingAverageHistory.shift();
|
206
|
+
}
|
207
|
+
|
208
|
+
tracking.movingAverageSpeed = SWFUpload.speed.calculateMovingAverage(tracking.movingAverageHistory);
|
209
|
+
|
210
|
+
// Update times
|
211
|
+
tracking.timeRemaining = (file.size - tracking.bytesUploaded) * 8 / tracking.movingAverageSpeed;
|
212
|
+
tracking.timeElapsed = (now - tracking.startTime) / 1000;
|
213
|
+
|
214
|
+
// Update percent
|
215
|
+
tracking.percentUploaded = (tracking.bytesUploaded / file.size * 100);
|
216
|
+
}
|
217
|
+
|
218
|
+
return tracking;
|
219
|
+
};
|
220
|
+
SWFUpload.speed.removeTracking = function (file, trackingList) {
|
221
|
+
try {
|
222
|
+
trackingList[file.id] = null;
|
223
|
+
delete trackingList[file.id];
|
224
|
+
} catch (ex) {
|
225
|
+
}
|
226
|
+
};
|
227
|
+
|
228
|
+
SWFUpload.speed.formatUnits = function (baseNumber, unitDivisors, unitLabels, singleFractional) {
|
229
|
+
var i, unit, unitDivisor, unitLabel;
|
230
|
+
|
231
|
+
if (baseNumber === 0) {
|
232
|
+
return "0 " + unitLabels[unitLabels.length - 1];
|
233
|
+
}
|
234
|
+
|
235
|
+
if (singleFractional) {
|
236
|
+
unit = baseNumber;
|
237
|
+
unitLabel = unitLabels.length >= unitDivisors.length ? unitLabels[unitDivisors.length - 1] : "";
|
238
|
+
for (i = 0; i < unitDivisors.length; i++) {
|
239
|
+
if (baseNumber >= unitDivisors[i]) {
|
240
|
+
unit = (baseNumber / unitDivisors[i]).toFixed(2);
|
241
|
+
unitLabel = unitLabels.length >= i ? " " + unitLabels[i] : "";
|
242
|
+
break;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
return unit + unitLabel;
|
247
|
+
} else {
|
248
|
+
var formattedStrings = [];
|
249
|
+
var remainder = baseNumber;
|
250
|
+
|
251
|
+
for (i = 0; i < unitDivisors.length; i++) {
|
252
|
+
unitDivisor = unitDivisors[i];
|
253
|
+
unitLabel = unitLabels.length > i ? " " + unitLabels[i] : "";
|
254
|
+
|
255
|
+
unit = remainder / unitDivisor;
|
256
|
+
if (i < unitDivisors.length -1) {
|
257
|
+
unit = Math.floor(unit);
|
258
|
+
} else {
|
259
|
+
unit = unit.toFixed(2);
|
260
|
+
}
|
261
|
+
if (unit > 0) {
|
262
|
+
remainder = remainder % unitDivisor;
|
263
|
+
|
264
|
+
formattedStrings.push(unit + unitLabel);
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
return formattedStrings.join(" ");
|
269
|
+
}
|
270
|
+
};
|
271
|
+
|
272
|
+
SWFUpload.speed.formatBPS = function (baseNumber) {
|
273
|
+
var bpsUnits = [1073741824, 1048576, 1024, 1], bpsUnitLabels = ["Gbps", "Mbps", "Kbps", "bps"];
|
274
|
+
return SWFUpload.speed.formatUnits(baseNumber, bpsUnits, bpsUnitLabels, true);
|
275
|
+
|
276
|
+
};
|
277
|
+
SWFUpload.speed.formatTime = function (baseNumber) {
|
278
|
+
var timeUnits = [86400, 3600, 60, 1], timeUnitLabels = ["d", "h", "m", "s"];
|
279
|
+
return SWFUpload.speed.formatUnits(baseNumber, timeUnits, timeUnitLabels, false);
|
280
|
+
|
281
|
+
};
|
282
|
+
SWFUpload.speed.formatBytes = function (baseNumber) {
|
283
|
+
var sizeUnits = [1073741824, 1048576, 1024, 1], sizeUnitLabels = ["GB", "MB", "KB", "bytes"];
|
284
|
+
return SWFUpload.speed.formatUnits(baseNumber, sizeUnits, sizeUnitLabels, true);
|
285
|
+
|
286
|
+
};
|
287
|
+
SWFUpload.speed.formatPercent = function (baseNumber) {
|
288
|
+
return baseNumber.toFixed(2) + " %";
|
289
|
+
};
|
290
|
+
|
291
|
+
SWFUpload.speed.calculateMovingAverage = function (history) {
|
292
|
+
var vals = [], size, sum = 0.0, mean = 0.0, varianceTemp = 0.0, variance = 0.0, standardDev = 0.0;
|
293
|
+
var i;
|
294
|
+
var mSum = 0, mCount = 0;
|
295
|
+
|
296
|
+
size = history.length;
|
297
|
+
|
298
|
+
// Check for sufficient data
|
299
|
+
if (size >= 8) {
|
300
|
+
// Clone the array and Calculate sum of the values
|
301
|
+
for (i = 0; i < size; i++) {
|
302
|
+
vals[i] = history[i];
|
303
|
+
sum += vals[i];
|
304
|
+
}
|
305
|
+
|
306
|
+
mean = sum / size;
|
307
|
+
|
308
|
+
// Calculate variance for the set
|
309
|
+
for (i = 0; i < size; i++) {
|
310
|
+
varianceTemp += Math.pow((vals[i] - mean), 2);
|
311
|
+
}
|
312
|
+
|
313
|
+
variance = varianceTemp / size;
|
314
|
+
standardDev = Math.sqrt(variance);
|
315
|
+
|
316
|
+
//Standardize the Data
|
317
|
+
for (i = 0; i < size; i++) {
|
318
|
+
vals[i] = (vals[i] - mean) / standardDev;
|
319
|
+
}
|
320
|
+
|
321
|
+
// Calculate the average excluding outliers
|
322
|
+
var deviationRange = 2.0;
|
323
|
+
for (i = 0; i < size; i++) {
|
324
|
+
|
325
|
+
if (vals[i] <= deviationRange && vals[i] >= -deviationRange) {
|
326
|
+
mCount++;
|
327
|
+
mSum += history[i];
|
328
|
+
}
|
329
|
+
}
|
330
|
+
|
331
|
+
} else {
|
332
|
+
// Calculate the average (not enough data points to remove outliers)
|
333
|
+
mCount = size;
|
334
|
+
for (i = 0; i < size; i++) {
|
335
|
+
mSum += history[i];
|
336
|
+
}
|
337
|
+
}
|
338
|
+
|
339
|
+
return mSum / mCount;
|
340
|
+
};
|
341
|
+
|
342
|
+
}
|
@@ -0,0 +1,111 @@
|
|
1
|
+
/*
|
2
|
+
SWFUpload.SWFObject Plugin
|
3
|
+
|
4
|
+
Summary:
|
5
|
+
This plugin uses SWFObject to embed SWFUpload dynamically in the page. SWFObject provides accurate Flash Player detection and DOM Ready loading.
|
6
|
+
This plugin replaces the Graceful Degradation plugin.
|
7
|
+
|
8
|
+
Features:
|
9
|
+
* swfupload_load_failed_hander event
|
10
|
+
* swfupload_pre_load_handler event
|
11
|
+
* minimum_flash_version setting (default: "9.0.28")
|
12
|
+
* SWFUpload.onload event for early loading
|
13
|
+
|
14
|
+
Usage:
|
15
|
+
Provide handlers and settings as needed. When using the SWFUpload.SWFObject plugin you should initialize SWFUploading
|
16
|
+
in SWFUpload.onload rather than in window.onload. When initialized this way SWFUpload can load earlier preventing the UI flicker
|
17
|
+
that was seen using the Graceful Degradation plugin.
|
18
|
+
|
19
|
+
<script type="text/javascript">
|
20
|
+
var swfu;
|
21
|
+
SWFUpload.onload = function () {
|
22
|
+
swfu = new SWFUpload({
|
23
|
+
minimum_flash_version: "9.0.28",
|
24
|
+
swfupload_pre_load_handler: swfuploadPreLoad,
|
25
|
+
swfupload_load_failed_handler: swfuploadLoadFailed
|
26
|
+
});
|
27
|
+
};
|
28
|
+
</script>
|
29
|
+
|
30
|
+
Notes:
|
31
|
+
You must provide set minimum_flash_version setting to "8" if you are using SWFUpload for Flash Player 8.
|
32
|
+
The swfuploadLoadFailed event is only fired if the minimum version of Flash Player is not met. Other issues such as missing SWF files, browser bugs
|
33
|
+
or corrupt Flash Player installations will not trigger this event.
|
34
|
+
The swfuploadPreLoad event is fired as soon as the minimum version of Flash Player is found. It does not wait for SWFUpload to load and can
|
35
|
+
be used to prepare the SWFUploadUI and hide alternate content.
|
36
|
+
swfobject's onDomReady event is cross-browser safe but will default to the window.onload event when DOMReady is not supported by the browser.
|
37
|
+
Early DOM Loading is supported in major modern browsers but cannot be guaranteed for every browser ever made.
|
38
|
+
*/
|
39
|
+
|
40
|
+
|
41
|
+
/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
|
42
|
+
Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
|
43
|
+
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
|
44
|
+
*/
|
45
|
+
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
var SWFUpload;
|
50
|
+
if (typeof(SWFUpload) === "function") {
|
51
|
+
SWFUpload.onload = function () {};
|
52
|
+
|
53
|
+
swfobject.addDomLoadEvent(function () {
|
54
|
+
if (typeof(SWFUpload.onload) === "function") {
|
55
|
+
SWFUpload.onload.call(window);
|
56
|
+
}
|
57
|
+
});
|
58
|
+
|
59
|
+
SWFUpload.prototype.initSettings = (function (oldInitSettings) {
|
60
|
+
return function () {
|
61
|
+
if (typeof(oldInitSettings) === "function") {
|
62
|
+
oldInitSettings.call(this);
|
63
|
+
}
|
64
|
+
|
65
|
+
this.ensureDefault = function (settingName, defaultValue) {
|
66
|
+
this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
|
67
|
+
};
|
68
|
+
|
69
|
+
this.ensureDefault("minimum_flash_version", "9.0.28");
|
70
|
+
this.ensureDefault("swfupload_pre_load_handler", null);
|
71
|
+
this.ensureDefault("swfupload_load_failed_handler", null);
|
72
|
+
|
73
|
+
delete this.ensureDefault;
|
74
|
+
|
75
|
+
};
|
76
|
+
})(SWFUpload.prototype.initSettings);
|
77
|
+
|
78
|
+
|
79
|
+
SWFUpload.prototype.loadFlash = function (oldLoadFlash) {
|
80
|
+
return function () {
|
81
|
+
var hasFlash = swfobject.hasFlashPlayerVersion(this.settings.minimum_flash_version);
|
82
|
+
|
83
|
+
if (hasFlash) {
|
84
|
+
this.queueEvent("swfupload_pre_load_handler");
|
85
|
+
if (typeof(oldLoadFlash) === "function") {
|
86
|
+
oldLoadFlash.call(this);
|
87
|
+
}
|
88
|
+
} else {
|
89
|
+
this.queueEvent("swfupload_load_failed_handler");
|
90
|
+
}
|
91
|
+
};
|
92
|
+
|
93
|
+
}(SWFUpload.prototype.loadFlash);
|
94
|
+
|
95
|
+
SWFUpload.prototype.displayDebugInfo = function (oldDisplayDebugInfo) {
|
96
|
+
return function () {
|
97
|
+
if (typeof(oldDisplayDebugInfo) === "function") {
|
98
|
+
oldDisplayDebugInfo.call(this);
|
99
|
+
}
|
100
|
+
|
101
|
+
this.debug(
|
102
|
+
[
|
103
|
+
"SWFUpload.SWFObject Plugin settings:", "\n",
|
104
|
+
"\t", "minimum_flash_version: ", this.settings.minimum_flash_version, "\n",
|
105
|
+
"\t", "swfupload_pre_load_handler assigned: ", (typeof(this.settings.swfupload_pre_load_handler) === "function").toString(), "\n",
|
106
|
+
"\t", "swfupload_load_failed_handler assigned: ", (typeof(this.settings.swfupload_load_failed_handler) === "function").toString(), "\n",
|
107
|
+
].join("")
|
108
|
+
);
|
109
|
+
};
|
110
|
+
}(SWFUpload.prototype.displayDebugInfo);
|
111
|
+
}
|
@@ -1,55 +1,42 @@
|
|
1
1
|
/**
|
2
|
-
*
|
3
|
-
*
|
4
|
-
* @
|
5
|
-
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
|
2
|
+
* Modified version of advfile
|
3
|
+
* @author Tatamae
|
4
|
+
* @copyright Copyright © 2009, Tatemae.
|
6
5
|
*/
|
7
|
-
|
8
6
|
(function() {
|
9
7
|
tinymce.create('tinymce.plugins.AdvancedFileTooPlugin', {
|
10
8
|
init : function(ed, url) {
|
11
9
|
// Register commands
|
12
10
|
ed.addCommand('mceAdvFileToo', function() {
|
13
11
|
var e = ed.selection.getNode();
|
14
|
-
|
15
12
|
// Internal file object like a flash placeholder
|
16
13
|
if (ed.dom.getAttrib(e, 'class').indexOf('mceItem') != -1)
|
17
14
|
return;
|
18
|
-
|
19
15
|
ed.windowManager.open({
|
20
|
-
file :
|
21
|
-
|
22
|
-
|
23
|
-
'&sessionkey=' + jQuery('#session-key').val() +
|
24
|
-
'&sessionid=' + jQuery('#session-id').val(),
|
25
|
-
width : 675 + parseInt(ed.getLang('advfiletoo.delta_width', 0)),
|
26
|
-
height : 540 + parseInt(ed.getLang('advfiletoo.delta_height', 0)),
|
16
|
+
file : jQuery('#tiny_mce_files_path').val(),
|
17
|
+
width : parseInt(jQuery('#tiny_mce_files_width').val()) + parseInt(ed.getLang('advfiletoo.delta_width', 0)),
|
18
|
+
height : parseInt(jQuery('#tiny_mce_files_height').val()) + parseInt(ed.getLang('advfiletoo.delta_height', 0)),
|
27
19
|
inline : 1
|
28
20
|
}, {
|
29
21
|
plugin_url : url
|
30
22
|
});
|
31
23
|
});
|
32
|
-
|
33
24
|
// Register button
|
34
25
|
ed.addButton('file', {
|
35
26
|
title : 'Upload Files',
|
36
27
|
cmd : 'mceAdvFileToo',
|
37
|
-
image :
|
28
|
+
image : '/images/tinymce/upload.gif'
|
38
29
|
});
|
39
|
-
|
40
30
|
},
|
41
|
-
|
42
31
|
getInfo : function() {
|
43
32
|
return {
|
44
33
|
longname : 'Advanced file',
|
45
|
-
author : '
|
46
|
-
authorurl : 'http://
|
47
|
-
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advfile',
|
34
|
+
author : 'Tatemae',
|
35
|
+
authorurl : 'http://Tatemae.com',
|
48
36
|
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
49
37
|
};
|
50
38
|
}
|
51
39
|
});
|
52
|
-
|
53
40
|
// Register plugin
|
54
41
|
tinymce.PluginManager.add('advfiletoo', tinymce.plugins.AdvancedFileTooPlugin);
|
55
42
|
})();
|