/usr/share/javascript/yui3/file-flash/file-flash.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('file-flash', function(Y) {
/**
* The FileFlash class provides a wrapper for a file pointer stored in Flash. The File wrapper
* also implements the mechanics for uploading a file and tracking its progress.
* @module file-flash
*/
/**
* The class provides a wrapper for a file pointer in Flash.
* @class FileFlash
* @extends Base
* @constructor
* @param {Object} config Configuration object.
*/
var FileFlash = function(o) {
FileFlash.superclass.constructor.apply(this, arguments);
};
Y.extend(FileFlash, Y.Base, {
/**
* Construction logic executed during FileFlash instantiation.
*
* @method initializer
* @protected
*/
initializer : function (cfg) {
if (!this.get("id")) {
this._set("id", Y.guid("file"));
}
},
/**
* Handler of events dispatched by the Flash player.
*
* @method _swfEventHandler
* @param {Event} event The event object received from the Flash player.
* @protected
*/
_swfEventHandler: function (event) {
if (event.id === this.get("id")) {
switch (event.type) {
/**
* Signals that this file's upload has started.
*
* @event uploadstart
* @param event {Event} The event object for the `uploadstart` with the
* following payload:
* <dl>
* <dt>uploader</dt>
* <dd>The Y.SWF instance of Flash uploader that's handling the upload.</dd>
* </dl>
*/
case "uploadstart":
this.fire("uploadstart", {uploader: this.get("uploader")});
break;
case "uploadprogress":
/**
* Signals that progress has been made on the upload of this file.
*
* @event uploadprogress
* @param event {Event} The event object for the `uploadprogress` with the
* following payload:
* <dl>
* <dt>originEvent</dt>
* <dd>The original event fired by the Flash uploader instance.</dd>
* <dt>bytesLoaded</dt>
* <dd>The number of bytes of the file that has been uploaded.</dd>
* <dt>bytesTotal</dt>
* <dd>The total number of bytes in the file (the file size)</dd>
* <dt>percentLoaded</dt>
* <dd>The fraction of the file that has been uploaded, out of 100.</dd>
* </dl>
*/
this.fire("uploadprogress", {originEvent: event,
bytesLoaded: event.bytesLoaded,
bytesTotal: event.bytesTotal,
percentLoaded: Math.min(100, Math.round(10000*event.bytesLoaded/event.bytesTotal)/100)
});
this._set("bytesUploaded", event.bytesLoaded);
break;
case "uploadcomplete":
/**
* Signals that this file's upload has completed, but data has not yet been received from the server.
*
* @event uploadfinished
* @param event {Event} The event object for the `uploadfinished` with the
* following payload:
* <dl>
* <dt>originEvent</dt>
* <dd>The original event fired by the Flash player instance.</dd>
* </dl>
*/
this.fire("uploadfinished", {originEvent: event});
break;
case "uploadcompletedata":
/**
* Signals that this file's upload has completed and data has been received from the server.
*
* @event uploadcomplete
* @param event {Event} The event object for the `uploadcomplete` with the
* following payload:
* <dl>
* <dt>originEvent</dt>
* <dd>The original event fired by the Flash player instance.</dd>
* <dt>data</dt>
* <dd>The data returned by the server.</dd>
* </dl>
*/
this.fire("uploadcomplete", {originEvent: event,
data: event.data});
break;
case "uploadcancel":
/**
* Signals that this file's upload has been cancelled.
*
* @event uploadcancel
* @param event {Event} The event object for the `uploadcancel` with the
* following payload:
* <dl>
* <dt>originEvent</dt>
* <dd>The original event fired by the Flash player instance.</dd>
* </dl>
*/
this.fire("uploadcancel", {originEvent: event});
break;
case "uploaderror":
/**
* Signals that this file's upload has encountered an error.
*
* @event uploaderror
* @param event {Event} The event object for the `uploaderror` with the
* following payload:
* <dl>
* <dt>originEvent</dt>
* <dd>The original event fired by the Flash player instance.</dd>
* <dt>status</dt>
* <dd>The status code reported by the Flash player instance.</dd>
* <dt>statusText</dt>
* <dd>The text of the error event reported by the Flash player instance</dd>
* </dl>
*/
this.fire("uploaderror", {originEvent: event, statusText: event.text, status: event.status});
}
}
},
/**
* Starts the upload of a specific file.
*
* @method startUpload
* @param url {String} The URL to upload the file to.
* @param parameters {Object} (optional) A set of key-value pairs to send as variables along with the file upload HTTP request.
* @param fileFieldName {String} (optional) The name of the POST variable that should contain the uploaded file ('Filedata' by default)
*/
startUpload: function(url, parameters, fileFieldName) {
if (this.get("uploader")) {
var myUploader = this.get("uploader"),
fileField = fileFieldName || "Filedata",
id = this.get("id"),
params = parameters || null;
this._set("bytesUploaded", 0);
myUploader.on("uploadstart", this._swfEventHandler, this);
myUploader.on("uploadprogress", this._swfEventHandler, this);
myUploader.on("uploadcomplete", this._swfEventHandler, this);
myUploader.on("uploadcompletedata", this._swfEventHandler, this);
myUploader.on("uploaderror", this._swfEventHandler, this);
myUploader.callSWF("upload", [id, url, params, fileField]);
}
},
/**
* Cancels the upload of a specific file, if currently in progress.
*
* @method cancelUpload
*/
cancelUpload: function () {
if (this.get("uploader")) {
this.get("uploader").callSWF("cancel", [this.get("id")]);
}
}
}, {
/**
* The identity of the class.
*
* @property NAME
* @type String
* @default 'file'
* @readOnly
* @protected
* @static
*/
NAME: 'file',
/**
* The type of transport.
*
* @property TYPE
* @type String
* @default 'flash'
* @readOnly
* @protected
* @static
*/
TYPE: "flash",
/**
* Static property used to define the default attribute configuration of
* the File.
*
* @property ATTRS
* @type {Object}
* @protected
* @static
*/
ATTRS: {
/**
* A String containing the unique id of the file wrapped by the FileFlash instance.
* The id is supplied by the Flash player uploader.
*
* @attribute id
* @type {String}
* @initOnly
*/
id: {
writeOnce: "initOnly",
value: null
},
/**
* The size of the file wrapped by FileFlash. This value is supplied by the Flash player uploader.
*
* @attribute size
* @type {Number}
* @initOnly
*/
size: {
writeOnce: "initOnly",
value: 0
},
/**
* The name of the file wrapped by FileFlash. This value is supplied by the Flash player uploader.
*
* @attribute name
* @type {String}
* @initOnly
*/
name: {
writeOnce: "initOnly",
value: null
},
/**
* The date that the file wrapped by FileFlash was created on. This value is supplied by the Flash player uploader.
*
* @attribute dateCreated
* @type {Date}
* @initOnly
*/
dateCreated: {
writeOnce: "initOnly",
value: null
},
/**
* The date that the file wrapped by FileFlash was last modified on. This value is supplied by the Flash player uploader.
*
* @attribute dateModified
* @type {Date}
* @initOnly
*/
dateModified: {
writeOnce: "initOnly",
value: null
},
/**
* The number of bytes of the file that has been uploaded to the server. This value is
* non-zero only while a file is being uploaded.
*
* @attribute bytesUploaded
* @type {Date}
* @readOnly
*/
bytesUploaded: {
readOnly: true,
value: 0
},
/**
* The type of the file wrapped by FileFlash. This value is provided by the Flash player
* uploader.
*
* @attribute type
* @type {String}
* @initOnly
*/
type: {
writeOnce: "initOnly",
value: null
},
/**
* The instance of Y.SWF wrapping the Flash player uploader associated with this file.
*
* @attribute uploder
* @type {SWF}
* @initOnly
*/
uploader: {
writeOnce: "initOnly",
value: null
}
}
});
Y.FileFlash = FileFlash;
}, '3.5.1' ,{requires:['base']});
|