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
// | |
// Observable CSS Class Binding | |
// | |
// See Fiddle for usage: http://jsfiddle.net/kamranayub/3ahUA/ | |
// | |
ko.bindingHandlers['class'] = { | |
update: function (element, valueAccessor) { | |
var currentValue = ko.utils.unwrapObservable(valueAccessor()), | |
prevValue = element['__ko__previousClassValue__'], | |
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
<VisualState x:Name="NextTransition"> | |
<Storyboard> | |
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)"> | |
<EasingDoubleKeyFrame KeyTime="0" Value="0"/> | |
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"> | |
<EasingDoubleKeyFrame.EasingFunction> | |
<ExponentialEase EasingMode="EaseOut" Exponent="6"/> | |
</EasingDoubleKeyFrame.EasingFunction> | |
</EasingDoubleKeyFrame> | |
</DoubleAnimationUsingKeyFrames> |
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
public static class TaskExtensions { | |
/// <summary> | |
/// A CommonJS Promise-like method that will execute a success and error callback, or just bubble up errors if not handled | |
/// </summary> | |
/// <typeparam name="TFirst"></typeparam> | |
/// <typeparam name="TNext"></typeparam> | |
/// <param name="first"></param> | |
/// <param name="success"></param> | |
/// <param name="error"></param> |
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.Security.Cryptography; | |
namespace Extensions { | |
public static class CryptoExtensions { | |
private static readonly SHA1 Sha1 = SHA1.Create(); | |
private static readonly MD5 Md5 = MD5.Create(); | |
/// <summary> | |
/// Performs an MD5 hash on the string and returns a 32 character hex format. | |
/// </summary> |
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
// RenderRoutes extension | |
// | |
// Use with AttributeRouting and JSON.NET to | |
// render out a JSON object that contains all your | |
// named routes for use in your client scripts. | |
public static class RouteExtensions { | |
/// <summary> | |
/// Renders a JSON object of routes |
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
// Now you can bind your checkbox selection to an observable array of model | |
// properties, instead of having to bind it to a property on the item | |
// itself (e.g. `isSelected`). | |
// For more information, see: | |
// http://kamranicus.com/Blog/Posts/61/a-smarter-checked-binding-for-knockoutjs | |
// For a demo, see: | |
// http://jsfiddle.net/kamranayub/G8YZU | |
var oldValueBinding = ko.bindingHandlers['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
// | |
// Via Kamranicus: http://kamranicus.com/Blog/Posts/59/using-knockout-bindings-in-your-winjs-application | |
// | |
// Include this before the rest of your app code (before default.js) | |
// | |
// <!-- WinJS references --> | |
// ... | |
// | |
// <script src="/scripts/knockout-2.2.js"> | |
// <script src="/scripts/ko-winjs.js"> |
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
// XML Formatter | |
// ============= | |
// A small jQuery plugin that works in conjunction with [jquery.xml](https://github.com/kamranayub/jQuery-XML-Helper) to format | |
// an XML DOM structure. | |
// | |
// | |
// Usage: | |
// ------ | |
// | |
// $(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
// in a method | |
// alorithm = SymmetricAlgorithm | |
// keySize = int (in bits) | |
if (algorithm.ValidKeySize(keySize)) | |
{ | |
algorithm.KeySize = keySize; | |
} | |
else | |
{ |
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
// jQuery.tmpl Compiled Source Plugin for Knockout 2.0 | |
// Kamran Ayub - http://kamranicus.com | |
// | |
// Adds support for referencing named pre-compiled templates | |
// e.g. $.template('name', 'markup') | |
// | |
// Specifically, this makes Cassette Knockout compiled templates | |
// work in KO 2.0.0 | |
(function (ko) { | |
ko.templateSources.compiledTemplateSource = function (name) { |