I’ve been doing a lot of WinJS work recently, and I am an avid user of the JustCode Template functionality. So, I thought I’d share my templates as I have them now, and will update this post as I update them or create more. For more information on creating JustCode templates, please see this help content.
For each template, I show my acronym in parenthesis. For example, the first template’s acronym is “winjsfile”. I also don’t show the results for every template, since some of them are obvious.
This template and the related templates following are used when I have created a new, blank JavaScript file.
Template (winjsfullfile):
/// <reference path="//Microsoft.WinJS.1.0/js/ui.js" />
/// <reference path="//Microsoft.WinJS.1.0/js/base.js" />
(function () {
"use strict";
WinJS.Namespace.define("$1$", {
|});})();
Template (winjsfile):
/// <reference path="//Microsoft.WinJS.1.0/js/ui.js" />
/// <reference path="//Microsoft.WinJS.1.0/js/base.js" />
(function () {
"use strict";
|})();
Template (references):
/// <reference path="//Microsoft.WinJS.1.0/js/ui.js" />
/// <reference path="//Microsoft.WinJS.1.0/js/base.js" />
|
Template (sefunc):
(function () {
"use strict";
|})();
Template (namespace):
WinJS.Namespace.define("$1$", {
|});
I’ve created several templates for common items in namespaces, such as property functions, observable properties, and class definitions.
Template (propfunc):
$1$: function ($2$) {
|},
Template (bindingprop):
$1$: WinJS.Binding.as({|}),
Template (winjsclass):
$1$:WinJS.Class.define(function($2$) {
this._initObservable();
this.$2$ = $2$;
|}),
WinJS.Class.mix($1$,WinJS.Binding.mixin,WinJS.Binding.expandProperties({ $2$: "", $3$: ""}));
Template (bindinglist):
var $1$ = new WinJS.Binding.List();
Template (listener):
$1=SELECT_VARIABLE()$.addEventListener('$2=SELECT(click,change,focus,load,select,submit)$', function (e) {|});
Template (pages):
WinJS.UI.Pages.define("/$1$.html", {
ready: function(element) {
|},});
I hope these help. If you have some great templates, share them with me!
Happy Coding!
Philip Japikse is an international speaker, a Microsoft MVP, ASPInsider, INETA Community Champion, MCSD, CSM/ CSP, and a passionate member of the developer community. Phil has been working with .Net since the first betas, developing software for over 20 years, and heavily involved in the agile community since 2005. Phil also hosts the Hallway Conversations podcast (www.hallwayconversations.com) and serves as the Lead Director for the Cincinnati .Net User’s Group (http://www.cinnug.org). You can follow Phil on twitter via www.twitter.com/skimedic, or read his personal blog at www.skimedic.com/blog.