Files
dbois/public/js/lib/main.js
T
2018-01-11 09:00:43 +01:00

47 lines
1.2 KiB
JavaScript

/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 22/12/2017
* Time: 12:13
*/
var dbo = {};
$( function () {
ko.bindingHandlers.stopBinding = {
init: function () {
return {controlsDescendantBindings: true};
}
};
ko.virtualElements.allowedBindings.stopBinding = true;
ko.bindingHandlers.fadeVisible = {
init : function ( element, valueAccessor ) {
var shouldDisplay = valueAccessor();
$( element ).toggle( shouldDisplay );
},
update: function ( element, valueAccessor ) {
// On update, fade in/out
var shouldDisplay = valueAccessor();
shouldDisplay ? $( element ).fadeIn( 750 ) : $( element ).fadeOut( 750 );
}
};
} );
function uploadFile(file, foreignID, tablename, callback){
var url = 'index.php/utils/fileUpload/upload/' + foreignID + '/' + tablename;
var xhr = new XMLHttpRequest();
var fd = new FormData();
xhr.open("POST", url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
callback();
}
};
fd.append("userfile", file);
xhr.send(fd);
}