PageRenderTime 50ms CodeModel.GetById 15ms app.highlight 27ms RepoModel.GetById 1ms app.codeStats 1ms

/wp-includes/js/swfupload/swfupload.js

https://bitbucket.org/skyarch-iijima/wordpress
JavaScript | 140 lines | 121 code | 13 blank | 6 comment | 9 complexity | ccd72399988bf939dce13e2659526711 MD5 | raw file
  1/**
  2 * SWFUpload fallback
  3 *
  4 * @since 4.9.0
  5 */
  6
  7var SWFUpload;
  8
  9( function () {
 10	function noop() {}
 11
 12	if (SWFUpload == undefined) {
 13		SWFUpload = function (settings) {
 14			this.initSWFUpload(settings);
 15		};
 16	}
 17
 18	SWFUpload.prototype.initSWFUpload = function ( settings ) {
 19		function fallback() {
 20			var $ = window.jQuery;
 21			var $placeholder = settings.button_placeholder_id ? $( '#' + settings.button_placeholder_id ) : $( settings.button_placeholder );
 22
 23			if ( ! $placeholder.length ) {
 24				return;
 25			}
 26
 27			var $form = $placeholder.closest( 'form' );
 28
 29			if ( ! $form.length ) {
 30				$form = $( '<form enctype="multipart/form-data" method="post">' );
 31				$form.attr( 'action', settings.upload_url );
 32				$form.insertAfter( $placeholder ).append( $placeholder );
 33			}
 34
 35			$placeholder.replaceWith(
 36				$( '<div>' )
 37					.append(
 38						$( '<input type="file" multiple />' ).attr({
 39							name: settings.file_post_name || 'async-upload',
 40							accepts: settings.file_types || '*.*'
 41						})
 42					).append(
 43						$( '<input type="submit" name="html-upload" class="button" value="Upload" />' )
 44					)
 45			);
 46		}
 47
 48		try {
 49			// Try the built-in fallback.
 50			if ( typeof settings.swfupload_load_failed_handler === 'function' && settings.custom_settings ) {
 51
 52				window.swfu = {
 53					customSettings: settings.custom_settings
 54				};
 55
 56				settings.swfupload_load_failed_handler();
 57			} else {
 58				fallback();
 59			}
 60		} catch ( ex ) {
 61			fallback();
 62		}
 63	};
 64
 65	SWFUpload.instances = {};
 66	SWFUpload.movieCount = 0;
 67	SWFUpload.version = "0";
 68	SWFUpload.QUEUE_ERROR = {};
 69	SWFUpload.UPLOAD_ERROR = {};
 70	SWFUpload.FILE_STATUS = {};
 71	SWFUpload.BUTTON_ACTION = {};
 72	SWFUpload.CURSOR = {};
 73	SWFUpload.WINDOW_MODE = {};
 74
 75	SWFUpload.completeURL = noop;
 76	SWFUpload.prototype.initSettings = noop;
 77	SWFUpload.prototype.loadFlash = noop;
 78	SWFUpload.prototype.getFlashHTML = noop;
 79	SWFUpload.prototype.getFlashVars = noop;
 80	SWFUpload.prototype.getMovieElement = noop;
 81	SWFUpload.prototype.buildParamString = noop;
 82	SWFUpload.prototype.destroy = noop;
 83	SWFUpload.prototype.displayDebugInfo = noop;
 84	SWFUpload.prototype.addSetting = noop;
 85	SWFUpload.prototype.getSetting = noop;
 86	SWFUpload.prototype.callFlash = noop;
 87	SWFUpload.prototype.selectFile = noop;
 88	SWFUpload.prototype.selectFiles = noop;
 89	SWFUpload.prototype.startUpload = noop;
 90	SWFUpload.prototype.cancelUpload = noop;
 91	SWFUpload.prototype.stopUpload = noop;
 92	SWFUpload.prototype.getStats = noop;
 93	SWFUpload.prototype.setStats = noop;
 94	SWFUpload.prototype.getFile = noop;
 95	SWFUpload.prototype.addFileParam = noop;
 96	SWFUpload.prototype.removeFileParam = noop;
 97	SWFUpload.prototype.setUploadURL = noop;
 98	SWFUpload.prototype.setPostParams = noop;
 99	SWFUpload.prototype.addPostParam = noop;
100	SWFUpload.prototype.removePostParam = noop;
101	SWFUpload.prototype.setFileTypes = noop;
102	SWFUpload.prototype.setFileSizeLimit = noop;
103	SWFUpload.prototype.setFileUploadLimit = noop;
104	SWFUpload.prototype.setFileQueueLimit = noop;
105	SWFUpload.prototype.setFilePostName = noop;
106	SWFUpload.prototype.setUseQueryString = noop;
107	SWFUpload.prototype.setRequeueOnError = noop;
108	SWFUpload.prototype.setHTTPSuccess = noop;
109	SWFUpload.prototype.setAssumeSuccessTimeout = noop;
110	SWFUpload.prototype.setDebugEnabled = noop;
111	SWFUpload.prototype.setButtonImageURL = noop;
112	SWFUpload.prototype.setButtonDimensions = noop;
113	SWFUpload.prototype.setButtonText = noop;
114	SWFUpload.prototype.setButtonTextPadding = noop;
115	SWFUpload.prototype.setButtonTextStyle = noop;
116	SWFUpload.prototype.setButtonDisabled = noop;
117	SWFUpload.prototype.setButtonAction = noop;
118	SWFUpload.prototype.setButtonCursor = noop;
119	SWFUpload.prototype.queueEvent = noop;
120	SWFUpload.prototype.executeNextEvent = noop;
121	SWFUpload.prototype.unescapeFilePostParams = noop;
122	SWFUpload.prototype.testExternalInterface = noop;
123	SWFUpload.prototype.flashReady = noop;
124	SWFUpload.prototype.cleanUp = noop;
125	SWFUpload.prototype.fileDialogStart = noop;
126	SWFUpload.prototype.fileQueued = noop;
127	SWFUpload.prototype.fileQueueError = noop;
128	SWFUpload.prototype.fileDialogComplete = noop;
129	SWFUpload.prototype.uploadStart = noop;
130	SWFUpload.prototype.returnUploadStart = noop;
131	SWFUpload.prototype.uploadProgress = noop;
132	SWFUpload.prototype.uploadError = noop;
133	SWFUpload.prototype.uploadSuccess = noop;
134	SWFUpload.prototype.uploadComplete = noop;
135	SWFUpload.prototype.debug = noop;
136	SWFUpload.prototype.debugMessage = noop;
137	SWFUpload.Console = {
138		writeLine: noop
139	};
140}() );