A Pen by Ludvig Lindblom on CodePen.
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
var ko = require('knockout'); | |
ko.components.register('simple-name', require('./components/simple-name/simple-name.js')); | |
ko.applyBindings({ userName: ko.observable() }); |
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
Choose a ticket class: <select id="tickets"></select> | |
<p id="ticketOutput"></p> | |
<script id="ticketTemplate" type="text/x-jquery-tmpl"> | |
{{if chosenTicket}} | |
You have chosen <b>${ chosenTicket().name }</b> | |
($${ chosenTicket().price }) | |
<button data-bind="click: resetTicket">Clear</button> | |
{{/if}} |
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(knockout){ | |
var knockoutElementMapping = function(knockoutElement, dataElement) | |
{ | |
if(typeof(knockoutElement.mergeConstructor) == "undefined") | |
{ | |
if (!knockout.isComputed(knockoutElement)) | |
{ | |
if(knockoutElement.mergeMethod) | |
{ knockoutElement.mergeMethod(knockoutElement, dataElement); } |
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
define(['jquery', 'knockout', 'knockout.mapping', 'knockout.validation'], | |
function ($, ko) { | |
/** The module. */ | |
var self = {}; | |
/** The knockout view model. */ | |
self.viewModel = {}; | |
/** The knockout container. */ | |
self.container = null; |
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
//make a limited set of underscore functions transparently unwrap knockout observables | |
(function knockoutifyUnderscore(_) { | |
var unwrap = ko.utils.unwrapObservable; | |
//These can be shimed in a standard way | |
var koFriendly = ['map', 'filter', 'find', 'each', 'findBy', 'first', 'last', 'head', 'tail', 'union', 'compact', 'flatten', 'difference', 'without']; | |
var oldMap = _.map; | |
for (var _i = 0; _i < koFriendly.length; _i++) { | |
(function(fnName) { | |
var originalFn = _[fnName]; |
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 = {}; | |
ko.Observable = function(value) { | |
this.value = value; | |
this.subscribers = []; | |
}; | |
ko.Observable.prototype.get = function() { | |
return this.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
//ckEditor inline binding handler... | |
ko.bindingHandlers.ckEditor = { | |
initialized: ko.observable(false), | |
initializeCKEditor: function(ckeditor) | |
{ | |
ckeditor.config.toolbar_HE = [['Undo', 'Redo', '-'], ['Styles', 'Font', 'FontSize'],'/', |
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
<Grid | |
xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:system = "clr-namespace:System;assembly=mscorlib" | |
xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" | |
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"> | |
<Grid.Resources> | |
<!-- Particle Styling --> | |
<SolidColorBrush x:Key = "ParticleColor" Color = "#7E0950D1"/> | |
<SolidColorBrush x:Key = "ParticleBackgroundColor" Color = "Transparent"/> |
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
var eventsystem = (function (eventsystem) { | |
var topics = {}; | |
eventsystem = eventsystem || { | |
subscribe: function (topic, listener) { | |
// Create the topic's object if not yet created | |
if (!topics[topic]) topics[topic] = { queue: [] }; | |
// Add the listener to queue | |
var index = topics[topic].queue.push(listener) - 1; |