-
Open source https://github.com/c9/typescript
-
Superset of Javascript - So javascript is valid typescript, then type script add some features
-
Adds types and OO
This file contains hidden or 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
Object.prototype.tryGet = function(props){ | |
return (props || '').split('.').reduce( (a, b, i, l) => | |
(a[b] || (i+1 === l.length ? '': {}) | |
, this) | |
} |
This file contains hidden or 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
<template> | |
<ul> | |
<li repeat.for="item of items"> | |
<input | |
type="radio" | |
name="item" | |
value.bind="item" | |
checked.bind="selected"> | |
${selected == item} | |
</li> |
This file contains hidden or 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
this.$rootScope.$on('f7:pageBeforeInit', (e, data) => { | |
const pageData = data.detail.pageData; | |
this.$F7Router.findRouteByUrl(pageData.url) | |
.then((route) => { | |
const config = route.config; | |
const navbar = data.detail.pageData.navbarInnerContainer; | |
const $scope = this.$rootScope.$new(); | |
this.$controller(config.controller, {$scope}, null, config.controllerAs); | |
this.$timeout(() => { | |
var template = angular.element(pageData.container); |
This file contains hidden or 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(factory, global) { | |
if (global.define && global.define.amd) { | |
global.define(['ko'], factory); | |
} else { | |
factory(global.ko); | |
} | |
})(function(ko) { | |
var deepObservifyArray = function(arr, deep) { | |
for (var i = 0, len = arr.length; i < len; i++) { |
TypeScript Links
This file contains hidden or 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
// Compiles fine even though the code is broken. | |
// This is because arrays are covariant and mutable. | |
// | |
// TypeScript team: Please fix either of those things. Preferably mutability :) | |
class Animal {} | |
class Snake extends Animal { | |
slither() { | |
alert("Slithering!") |
This file contains hidden or 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 RemoveAccents(strAccents) { | |
var strAccents = strAccents.split(''); | |
var strAccentsOut = new Array(); | |
var strAccentsLen = strAccents.length; | |
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; | |
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz"; | |
for (var y = 0; y < strAccentsLen; y++) { | |
if (accents.indexOf(strAccents[y]) != -1) { | |
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1); | |
} else |
This file contains hidden or 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
//demo: http://jsfiddle.net/uPvTm/8/ | |
;(function($) { | |
$.labelFadeInput = function () { | |
///use to set labelFadeInput in All input's with title | |
///ex: <input type='text' title='Any text here' />, use $.labelFadeinput(); | |
$('input:text[title]').each(function() { | |
setEvents.call(this); | |
}); |
This file contains hidden or 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
///<summary> Sample: </summary> | |
///<code> | |
/// $.getJson("url", function(data){ | |
/// //data : [{Value:1, Text: 'value 1', Selected:false},{Value:2, Text: 'value 2', Selected: true}] | |
/// $("#mySelect").loadOptions(data); | |
/// }); | |
/// or | |
/// $.getJson("url", function(data){ | |
/// //data : [{id:1, name: 'value 1'},{id:2, name: 'value 2'}] | |
/// $("#mySelect").loadOptions(data, {value: 'id', text: 'name'}); |
NewerOlder