Skip to content

Instantly share code, notes, and snippets.

View valerysntx's full-sized avatar
🔋
99%

valery sntx valerysntx

🔋
99%
  • Ukraine, Uzhgorod
View GitHub Profile
directive('tab', ['NavStateDelegate', '$scope', function(NavStateDelegate, $scope) {
return {
//
link: function($scope, $element, $attr) {
// Indicate to this delegate we want to control a nav bar
NavStateDelegate.enable(scope);
}
}
}])
@valerysntx
valerysntx / templify-bind.html
Last active August 29, 2015 14:06 — forked from vmysla/gist:f33a50f802c1e8a8c45f
templifyed data binding example
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.js"></script>
<script>
(function Templify(undefined) {
var models = {};
function replace(template, pattern, value){
var expression = new RegExp('\\['+pattern+'\\]');
@valerysntx
valerysntx / app.js
Last active August 29, 2015 14:07 — forked from mshwery/app.js
var ko = require('knockout');
ko.components.register('simple-name', require('./components/simple-name/simple-name.js'));
ko.applyBindings({ userName: ko.observable() });
@valerysntx
valerysntx / example.html
Last active August 29, 2015 14:09 — forked from joelnet/example.html
jquery.unobtrusive-knockout.js
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}}
(function(knockout){
var knockoutElementMapping = function(knockoutElement, dataElement)
{
if(typeof(knockoutElement.mergeConstructor) == "undefined")
{
if (!knockout.isComputed(knockoutElement))
{
if(knockoutElement.mergeMethod)
{ knockoutElement.mergeMethod(knockoutElement, dataElement); }
@valerysntx
valerysntx / knockoutifyUnderscore.js
Last active August 29, 2015 14:10 — forked from togakangaroo/knockoutifyUnderscore
Underscore functions transparently unwrap knockout observables
//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];