updated Uikit v2
This commit is contained in:
@ -1,15 +1,15 @@
|
||||
/*! UIkit 2.25.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
(function(addon) {
|
||||
|
||||
var component;
|
||||
|
||||
if (window.UIkit) {
|
||||
component = addon(UIkit);
|
||||
if (window.UIkit2) {
|
||||
component = addon(UIkit2);
|
||||
}
|
||||
|
||||
if (typeof define == "function" && define.amd) {
|
||||
define("uikit-upload", ["uikit"], function(){
|
||||
return component || addon(UIkit);
|
||||
if (typeof define == 'function' && define.amd) {
|
||||
define('uikit-upload', ['uikit'], function(){
|
||||
return component || addon(UIkit2);
|
||||
});
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
var $this = this;
|
||||
|
||||
this.on("change", function() {
|
||||
this.on('change', function() {
|
||||
xhrupload($this.element[0].files, $this.options);
|
||||
var twin = $this.element.clone(true).data('uploadSelect', $this);
|
||||
$this.element.replaceWith(twin);
|
||||
@ -42,23 +42,23 @@
|
||||
|
||||
var $this = this, hasdragCls = false;
|
||||
|
||||
this.on("drop", function(e){
|
||||
this.on('drop', function(e){
|
||||
|
||||
if (e.dataTransfer && e.dataTransfer.files) {
|
||||
if (e.originalEvent.dataTransfer && e.originalEvent.dataTransfer.files) {
|
||||
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
$this.element.removeClass($this.options.dragoverClass);
|
||||
$this.element.trigger('dropped.uk.upload', [e.dataTransfer.files]);
|
||||
$this.element.trigger('dropped.uk.upload', [e.originalEvent.dataTransfer.files]);
|
||||
|
||||
xhrupload(e.dataTransfer.files, $this.options);
|
||||
xhrupload(e.originalEvent.dataTransfer.files, $this.options);
|
||||
}
|
||||
|
||||
}).on("dragenter", function(e){
|
||||
}).on('dragenter', function(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}).on("dragover", function(e){
|
||||
}).on('dragover', function(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
$this.element.addClass($this.options.dragoverClass);
|
||||
hasdragCls = true;
|
||||
}
|
||||
}).on("dragleave", function(e){
|
||||
}).on('dragleave', function(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
$this.element.removeClass($this.options.dragoverClass);
|
||||
@ -93,9 +93,6 @@
|
||||
return supportFileAPI() && supportAjaxUploadProgressEvents() && supportFormData();
|
||||
})();
|
||||
|
||||
if (UI.support.ajaxupload){
|
||||
UI.$.event.props.push("dataTransfer");
|
||||
}
|
||||
|
||||
function xhrupload(files, settings) {
|
||||
|
||||
@ -175,21 +172,25 @@
|
||||
for (var p in settings.params) { formData.append(p, settings.params[p]); }
|
||||
|
||||
// Add any event handlers here...
|
||||
xhr.upload.addEventListener("progress", function(e){
|
||||
xhr.upload.addEventListener('progress', function(e){
|
||||
var percent = (e.loaded / e.total)*100;
|
||||
settings.progress(percent, e);
|
||||
}, false);
|
||||
|
||||
xhr.addEventListener("loadstart", function(e){ settings.loadstart(e); }, false);
|
||||
xhr.addEventListener("load", function(e){ settings.load(e); }, false);
|
||||
xhr.addEventListener("loadend", function(e){ settings.loadend(e); }, false);
|
||||
xhr.addEventListener("error", function(e){ settings.error(e); }, false);
|
||||
xhr.addEventListener("abort", function(e){ settings.abort(e); }, false);
|
||||
xhr.addEventListener('loadstart', function(e){ settings.loadstart(e); }, false);
|
||||
xhr.addEventListener('load', function(e){ settings.load(e); }, false);
|
||||
xhr.addEventListener('loadend', function(e){ settings.loadend(e); }, false);
|
||||
xhr.addEventListener('error', function(e){ settings.error(e); }, false);
|
||||
xhr.addEventListener('abort', function(e){ settings.abort(e); }, false);
|
||||
|
||||
xhr.open(settings.method, settings.action, true);
|
||||
|
||||
if (settings.type=="json") {
|
||||
xhr.setRequestHeader("Accept", "application/json");
|
||||
if (settings.type=='json') {
|
||||
xhr.setRequestHeader('Accept', 'application/json');
|
||||
}
|
||||
|
||||
for (var h in settings.headers) {
|
||||
xhr.setRequestHeader(h, settings.headers[h]);
|
||||
}
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
@ -200,7 +201,7 @@
|
||||
|
||||
var response = xhr.responseText;
|
||||
|
||||
if (settings.type=="json") {
|
||||
if (settings.type=='json') {
|
||||
try {
|
||||
response = UI.$.parseJSON(response);
|
||||
} catch(e) {
|
||||
@ -217,29 +218,30 @@
|
||||
}
|
||||
|
||||
xhrupload.defaults = {
|
||||
'action': '',
|
||||
'single': true,
|
||||
'method': 'POST',
|
||||
'param' : 'files[]',
|
||||
'params': {},
|
||||
'allow' : '*.*',
|
||||
'type' : 'text',
|
||||
'filelimit': false,
|
||||
action: '',
|
||||
single: true,
|
||||
method: 'POST',
|
||||
param : 'files[]',
|
||||
params: {},
|
||||
allow : '*.*',
|
||||
type : 'text',
|
||||
filelimit: false,
|
||||
headers: {},
|
||||
|
||||
// events
|
||||
'before' : function(o){},
|
||||
'beforeSend' : function(xhr){},
|
||||
'beforeAll' : function(){},
|
||||
'loadstart' : function(){},
|
||||
'load' : function(){},
|
||||
'loadend' : function(){},
|
||||
'error' : function(){},
|
||||
'abort' : function(){},
|
||||
'progress' : function(){},
|
||||
'complete' : function(){},
|
||||
'allcomplete' : function(){},
|
||||
'readystatechange': function(){},
|
||||
'notallowed' : function(file, settings){ alert('Only the following file types are allowed: '+settings.allow); }
|
||||
before : function(o){},
|
||||
beforeSend : function(xhr){},
|
||||
beforeAll : function(){},
|
||||
loadstart : function(){},
|
||||
load : function(){},
|
||||
loadend : function(){},
|
||||
error : function(){},
|
||||
abort : function(){},
|
||||
progress : function(){},
|
||||
complete : function(){},
|
||||
allcomplete : function(){},
|
||||
readystatechange: function(){},
|
||||
notallowed : function(file, settings){ alert('Only the following file types are allowed: '+settings.allow); }
|
||||
};
|
||||
|
||||
function matchName(pattern, path) {
|
||||
|
Reference in New Issue
Block a user