66900b43227bf441b6a6b1084af2c96ce2c747c8Allen RabinovichYUI({
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich base: '../../../../build/',
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich lang: "en",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich filter: "raw",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich debug: true,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich useBrowserConsole: true
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich}).use('cssbutton', 'uploader', 'node', 'console', function(Y) {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich// Force Flash uploader
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich// Y.Uploader = Y.UploaderFlash;
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich// Force HTML5 uploader
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich// Y.Uploader = Y.UploaderHTML5;
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovichvar myuploader;
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovichif (Y.Uploader.TYPE != "none") {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich myuploader = new Y.Uploader({ multipleFiles: true,
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich uploadURL: "http://www.yswfblog.com/upload/simpleupload.php",
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich dragAndDropArea: "#droparea",
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich tabIndex: "0",
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich width: "100%",
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich height: "100%",
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich swfURL: "assets/flashuploader.swf?t=" + Math.random(),
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich tabElements: {from: "#pageTitle", to: "#uploadButton"}
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich });
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich if (Y.Uploader.TYPE === "html5") {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Y.one("#pageTitle").setContent("Using uploader: HTML5");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich var dropArea = Y.Node.create('<div id="droparea" style="width:500px;height:150px;background:#cccccc;">Drop some files here!</div>');
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Y.one("body").prepend(dropArea);
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.set("dragAndDropArea", dropArea);
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich }
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich else if (Y.Uploader.TYPE === "flash") {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Y.one("#pageTitle").setContent("Using uploader: Flash");
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich }
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich myuploader.render("#fileselection");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.set("multipleFiles", true);
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.set("appendNewFiles", true);
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.set("simLimit", 3);
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich var out = Y.one("#uploadinfo");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich var postVars = [];
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.after("fileListChange", function (ev) {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich out.setContent("");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich postVars = [];
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Y.each(myuploader.get("fileList"), function (value) {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich out.append("<div id='" + value.get("id") + "'>" + value.get("name") + " | " + 0 + "%</div>");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich postVars[value.get("id")] = {filename: value.get("name"), filesize: value.get("size")};
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich });
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.set("postVarsPerFile", postVars);
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich });
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.on("uploadprogress", function (ev) {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich out.one("#" + ev.file.get("id")).setContent(ev.file.get("name") + " | " + ev.percentLoaded + "%");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich });
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.on("uploadcomplete", function (ev) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich out.one("#" + ev.file.get("id")).setContent(ev.file.get("name") + " | " + "Finished!");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich out.one("#" + ev.file.get("id")).append("<p>DATA:<br> " + ev.data + "</p>");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich });
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.on("totaluploadprogress", function (ev) {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Y.one("#totalpercent").setContent("Total upload progress: " + ev.percentLoaded);
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich });
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.on("alluploadscomplete", function (ev) {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Y.one("#totalpercent").setContent("<p>Upload complete!</p>");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich });
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Y.one("#uploadButton").on("click", function () {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich myuploader.uploadAll();
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich });
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich Y.one("#triggerButton").on("click", function () {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich if (myuploader.get("enabled")) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich myuploader.set("enabled", false);
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich }
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich else {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich myuploader.set("enabled", true);
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich }
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich });
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich}
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovichelse {
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Y.one("body").prepend("Neither HTML5 nor Flash uploaders can be used on this system");
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich});