Files
dbois/public/js/lib/main.js
T
2017-12-22 14:59:54 +01:00

36 lines
1007 B
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 ) {
// Initially set the element to be instantly visible/hidden depending on the value
var value = valueAccessor();
$( element ).toggle( ko.unwrap( value ) ); // Use "unwrapObservable" so we can handle values that may or may not be observable
},
update: function ( element, valueAccessor ) {
// Whenever the value subsequently changes, slowly fade the element in or out
var value = valueAccessor();
ko.unwrap( value ) ? $( element ).fadeIn( 500 ) : $( element ).fadeOut( 500 );
}
};
});