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.
Templates for New JavaScript File
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$", {
|
});
})();
Related templates
Microsoft WinJS References and Self Executing Function
Template (winjsfile):
/// <reference path="//Microsoft.WinJS.1.0/js/ui.js" />
/// <reference path="//Microsoft.WinJS.1.0/js/base.js" />
(function () {
"use strict";
|
})();
Microsoft WinJS References
Template (references):
/// <reference path="//Microsoft.WinJS.1.0/js/ui.js" />
/// <reference path="//Microsoft.WinJS.1.0/js/base.js" />
|
Self Executing Function
Template (sefunc):
(function () {
"use strict";
|
})();
WinJS Namespace
Template (namespace):
WinJS.Namespace.define("$1$", {
|
});
Namespace Templates
I’ve created several templates for common items in namespaces, such as property functions, observable properties, and class definitions.
Property Function
Template (propfunc):
$1$: function ($2$) {
|
},
Observable Property
Template (bindingprop):
$1$: WinJS.Binding.as({
|
}),
WinJS Class (within a namespace)
Template (winjsclass):
$1$:WinJS.Class.define(function($2$) {
this._initObservable();
this.$2$ = $2$;
|
}),
WinJS Class Binding Mixin
WinJS.Class.mix($1$,
WinJS.Binding.mixin,
WinJS.Binding.expandProperties({ $2$: "", $3$: ""})
);
Miscellaneous Templates
Binding List
Template (bindinglist):
var $1$ = new WinJS.Binding.List();
Event Listener
Template (listener):
$1=SELECT_VARIABLE()$.addEventListener('$2=SELECT(click,change,focus,load,select,submit)$', function (e) {
|
});
Pages
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!
About the author
Philip Japikse
|
Philip Japikse an international speaker, a Microsoft MVP, INETA Community Champion, MCSD, CSM/ CSP, and a passionate member of the developer community, Phil Japikse 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 works as a Developer Evangelist for Telerik's RadControls for Windows 8 as well as the Just family of products (JustCode, JustMock, JustTrace, and JustDecompile) and hosts the Zero To Agile podcast (www.telerik.com/zerotoagile). Phil is also 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 and read his personal blog at www.skimedic.com/blog. |
29e8d996-5e28-41a9-9ef9-64f4ee3bf7a6|0|.0|27604f05-86ad-47ef-9e05-950bb762570c