This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko.extenders.filter = function (target, pattern) { | |
var result = ko.computed({ | |
read: target, | |
write: function (value) { | |
if (typeof value !== "string") { | |
target(value); | |
return; | |
} | |
var current = target(); | |
var filtered = value.replace(pattern, ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function log(value) { | |
console.log(typeof value + ": " + value); | |
} | |
ko.extenders.numeric1 = function (target) { | |
return ko.computed({ | |
read: target, | |
write: function (value) { | |
var number = parseFloat(value); | |
target(isNaN(number) ? value : number); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko.extenders.observe = function (target, source) { | |
target(source); | |
var result = ko.computed({ | |
read: function () { | |
return target()(); | |
}, | |
write: function (value) { | |
target()(value); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
ko.bindingHandlers.slide = { | |
enabled: true, | |
queue: "ko.bindingHandlers.slide", | |
init: function (element, valueAccessor) { | |
var visible = Boolean(ko.unwrap(valueAccessor())); | |
$(element).toggle(visible); | |
}, | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
ko.bindingHandlers.sortable = { | |
normalize: function (valueAccessor) { | |
var value = ko.unwrap(valueAccessor()); | |
if (typeof value === "object" && "data" in value) { | |
return value; | |
} else { | |
return { data: valueAccessor() }; | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
ko.bindingHandlers.tooltip = { | |
normalize: function (valueAccessor) { | |
var value = ko.unwrap(valueAccessor()); | |
if (typeof value === "object" && "data" in value) { | |
return value; | |
} else { | |
return { data: value }; | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
ko.bindingHandlers.validationPopover = { | |
init: function (element, valueAccessor, allBindings) { | |
if (!allBindings.has("value")) { | |
return; | |
} | |
var $element = $(element); | |
var value = allBindings.get("value"); | |
$element.popover($.extend({}, ko.unwrap(valueAccessor()), { | |
content: function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.widget("scw.toggler", { | |
options: { | |
active: true, | |
animated: true, | |
duration: "_default", | |
cssClass: "toggler-active" | |
}, | |
_finish: function () { | |
while (this.element.queue().length > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
public class ObservableObject : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected ObservableObject() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
public static class STATask | |
{ | |
public static Task Start(Action action) | |
{ | |
TaskCompletionSource<object> source = new TaskCompletionSource<object>(); | |
Thread thread = new Thread(() => |