typescript TYPO3中的语言切换器,支持tx_news

TYPO3中的语言切换器,支持tx_news

lib.menu.language.ts
lib.menuLanguage = COA
lib.menuLanguage {
  10 = HMENU
  10 {
    special = language
    special.value = 1,2
    stdWrap.wrap = <ul class="language-select">|</ul>
    1 = TMENU
    1 {
      # Normal link to language that exists:
      NO = 1
      NO {
        additionalParams.cObject = TEXT
        additionalParams.cObject {
          data = GP:tx_news_pi1|news
          stdWrap.wrap = &tx_news_pi1[news]=|
          stdWrap.required = 1
        }
        allWrap = <li class="en">|</li> |*| <li class="ru">|</li>
        stdWrap {
          setCurrent = Englisch || Pусский
          current = 1
        }
      }

      # Translation does not exist
      USERDEF1 < .NO
      USERDEF1.allWrap = <li style="display:none;">|</li>
      USERDEF1.doNotLinkIt = 1
    }
  }
}

typescript 用于转义双花括号的小功能

用于转义双花括号的小功能

escape-double-curly-brackets.ts
var entityMap = {
    "{{": "<span>{{</span>",
    "}}": "<span>}}</span>"
};

function escapeCurlyBrackets(source: string) {
    return String(source).replace(/{{|}}/g, s => entityMap[s]);
}

typescript 用于转义html字符的小功能(在TypeScript中)

用于转义html字符的小功能(在TypeScript中)

escape-html.ts
// From Tom Gruner @ http://stackoverflow.com/a/12034334/1660815
var entityMap = {
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;",
    '"': '&quot;',
    "'": '&#39;',
    "/": '&#x2F;'
};

function escapeHtml(source: string) {
    return String(source).replace(/[&<>"'\/]/g, s => entityMap[s]);
}

typescript 包含在tt_content div中的类别

包含在tt_content div中的类别

tt_content_category.ts
# wrap layout, language and tt_content uid around
tt_content.stdWrap.innerWrap.cObject.default.20.stdWrap.noTrimWrap = | class="| layout-{field:layout} language-{field:sys_language_uid} uid-{field:uid}"|
tt_content.stdWrap.innerWrap.cObject.default.20.stdWrap.insertData = 1

# wrap content category around
tt_content.stdWrap.innerWrap.cObject.default.20 = COA
tt_content.stdWrap.innerWrap.cObject.default.20 {
	10 = CONTENT
	10 {
		wrap =|
		if.isTrue.field = categories
		table = tt_content
		select {
			uidInList.field = uid
			join = sys_category_record_mm ON tt_content.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
			orderBy = sys_category.sorting
		}
		renderObj = TEXT
		renderObj {
			field = title
			noTrimWrap = |cat-| |
			stdWrap.case = lower
		}
	}
	20 = TEXT
	20 {
		value = cat-undefined
		if.isFalse.field = categories
	}
}

typescript 包含在tt_content div中的类别

包含在tt_content div中的类别

tt_content_category.ts
# wrap layout, language and tt_content uid around
tt_content.stdWrap.innerWrap.cObject.default.20.stdWrap.noTrimWrap = | class="| layout-{field:layout} language-{field:sys_language_uid} uid-{field:uid}"|
tt_content.stdWrap.innerWrap.cObject.default.20.stdWrap.insertData = 1

# wrap content category around
tt_content.stdWrap.innerWrap.cObject.default.20 = COA
tt_content.stdWrap.innerWrap.cObject.default.20 {
	10 = CONTENT
	10 {
		wrap =|
		if.isTrue.field = categories
		table = tt_content
		select {
			uidInList.field = uid
			join = sys_category_record_mm ON tt_content.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
			orderBy = sys_category.sorting
		}
		renderObj = TEXT
		renderObj {
			field = title
			noTrimWrap = |cat-| |
			stdWrap.case = lower
		}
	}
	20 = TEXT
	20 {
		value = cat-undefined
		if.isFalse.field = categories
	}
}

typescript angular.ts

angular.ts
/// <reference path="../../typings/tsd.d.ts" />
function HelloWorldController($scope) {
    $scope.message = 'Hello World!!';
}
function SampleController($scope) {
    $scope.simple = '簡易記法を使った方法';
    $scope.directive = 'ディレクティブを使った方法';
}
function SampleController2($scope) {
    $scope.text = 'TextBox';
    $scope.checkbox = true;
    $scope.radio = 'FUGA';
    $scope.select = 'foo';
}
function SampleController3($scope) {
    $scope.click = () => {
        $scope.message = 'click button!';
    };
}
function SampleController4($scope) {
    $scope.items = [
        {key: 'hoge', value: 'HOGE'},
        {key: 'fuga', value: 'FUGA'},
        {key: 'piyo', value: 'PIYO'}
    ]
}
function SampleController5($scope) {
    $scope.hidden = true;
    $scope.click = () => {
        $scope.hidden = !$scope.hidden;
    };
}
function SampleController6($scope) {
    $scope.hoge = 'red solid-border';
    $scope.isRed = true;
    $scope.isDotted = true;
}
function SampleController7($scope) {
    $scope.url = 'http://mono0926.com/';
    $scope.imageFileName = 'mate.png';
}
function SampleController8($scope) {
    $scope.message = 'hoge'
    $scope.change = () => {
        $scope.message = 'change!!'
    }
}
function SampleController9($scope) {
    $scope.hoge = 0;
    $scope.fuga = 0;
    $scope.sum = 0;
    // Angular式
//    $scope.$watch('hoge + fuga', 'sum = hoge + fuga');
    // 関数式
    $scope.$watch(() => $scope.hoge + $scope.fuga,
        () => {
            $scope.sum = $scope.hoge + $scope.fuga;
        });
}
(function() {
    var myModule = angular.module('myModule', ['ngRoute']);

    // モジュールを定義する
    myModule.controller('SampleController10', $scope => {
        $scope.message = 'module';
    });

    // 依存するインスタンス(サービス)をインジェクションする
    myModule.service('sampleService', SampleService);
    myModule.controller('SampleController11', ($scope, sampleService) => {
        $scope.message = sampleService.method();
    });

    function SampleService() {
        this.method = () => {
            return 'sample service';
        };
    }
    // フィルターを自作する
    myModule.filter('myFilter', function() {
        return function(value, param1, param2) {
            return param1 + value + param2;
        };
    });
    // ngRouteモジュールを追加する
    myModule.config($routeProvider => {
        $routeProvider
            .when('/', {
                controller: 'RootController',
                templateUrl: 'users'
            });
    });
    myModule.controller('RootController', function($scope) {
        $scope.message = 'message by RootController.';
    });
})();
function SampleController12($scope) {
    $scope.money = 1000;
}
function SampleController13($scope) {
    $scope.array1 = ["hoge", "fuga", "piyo"];
    $scope.array2 = [
        "hoge",
        "fuga",
        {a: "hoge"},
        {a: "fuga"},
        {b: {c: "hoge"}},
        {b: {c: "fuga"}},
    ];
}
function SampleController14($scope) {
    $scope.physicists = [
        {firstName: 'Johannes', lastName: 'Kepler'},
        {firstName: 'Galileo',  lastName: 'Galilei'},
        {firstName: 'Thomas',   lastName: 'Young'},
        {firstName: 'Michael',  lastName: 'Faraday'},
        {firstName: 'Edward',   lastName: 'Morley'},
        {firstName: 'Niels',    lastName: 'Bohr'}
    ];
}
function SampleController15($scope) {
    $scope.isEvenNumber = number => number % 2 == 0;
}
function SampleController16($scope) {
    $scope.contains = (actual, expected) =>
        actual.indexOf(expected) != -1;
}

typescript main.ts

main.ts
/// <reference path="typings/node/node.d.ts" />
/// <reference path="bower_components/dt-request/request.d.ts" />

import http = require("http");
var request:Request.IRequest = require("request");

request.get("http://lacolaco.net/", (error:Error, response:http.ClientResponse, body:string)=> {
    console.log(response.statusCode);
    console.log(error);
    console.log(body.length);
});

typescript 添加像Jquery插件这样的对象的功能,以支持TypeScript <br/>基于 - http://sravi-kiran.blogspot.co.il/2012/10/CreatingTypeS

添加像Jquery插件这样的对象的功能,以支持TypeScript <br/>基于 - http://sravi-kiran.blogspot.co.il/2012/10/CreatingTypeScriptTypeDeclarationFileForAnExistingJQueryPlugin.html

UsingThePlugin.ts
(<JquweryPlugin>$(document)).someFunction(someParams); // can be used with any Jquery selector.
IJqueryPlugin.d.ts
// the plugin interface, base on Jquery.d.ts refferenced. 
interface JquweryPlugin extends Jquery {
  someFunction(someParams:any) : any // the method signature
}

typescript 这是* my *当前的临时修复,可以在typescript中使用SugarJS的静态方法添加。

这是* my *当前的临时修复,可以在typescript中使用SugarJS的静态方法添加。

tmpSugarFix.ts
/// <reference path="../path/to/sugar.d.ts" />

/**
 * Usage Examples:
 *   sgObject.isArray([1]); // -> true
 */
 
declare var sgObject:ObjectStatic;
declare var sgNumber:NumberStatic;
declare var sgDate:DateStatic;
declare var sgRegExp:RegExpStatic;

eval(
	"sgObject 	= Object;" +
	"sgNumber 	= Number;" +
	"sgDate 	= Date;" +
	"sgRegExp 	= RegExp;"
);