Skip to content

Instantly share code, notes, and snippets.

@kjelelokk
kjelelokk / dojo_moduleConfig.xml
Created November 29, 2012 11:46
Dojo epi module.config
<dojoModules>
<add name="alloy" path="Scripts" />
</dojoModules>
@kjelelokk
kjelelokk / dojo_epiComponent.cs
Created November 29, 2012 11:46
Dojo episerver component
using EPiServer.Shell.ViewComposition;
using EPiServer.Shell.Web;
using EPiServer.Cms.Shell;
using EPiServer.Cms.Shell.UI;
namespace testepi7.MyWidgets
{
[Component(
PlugInAreas = "/episerver/cms/assets",
Categories = "cms",
@kjelelokk
kjelelokk / dojo_deffered.js
Created November 29, 2012 11:45
Dojo deffered
var deffered = xhr.get({
url: '/getSomePage'
});
deffered.then(function (result) {
result.property = 'Something more';
return result;
}).then(function (resultWithObjectProperty) {
// Gjør noe
}, function (err) {
@kjelelokk
kjelelokk / dojo_aspects.js
Created November 29, 2012 10:33
Dojo aspects
require(['dojo/aspect'], function (aspect) {
var original = {
someMethod: function (arg1, arg2) {
console.warn('original.someMethod called:', arg1, arg2);
return 'Hello ' + arg1 + ' ' + arg2;
}
};
// aspect.before
aspect.before(original, 'someMethod', function (arg1, arg2) {
@kjelelokk
kjelelokk / dojo_templateIndex.html
Created November 29, 2012 10:29
Dojo template index html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>Dojo test</title>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.8.1/dijit/themes/claro/claro.css">
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.8.1/dojo/dojo.js" data-dojo-config="isDebug: true, async: true, parseOnLoad: true"></script>
</head>
<body class="claro">
<h1>This is a template test:</h1>
@kjelelokk
kjelelokk / dojo_myTemplateModule.js
Created November 29, 2012 10:24
Dojo myTemplateModule
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'dijit/_TemplatedMixin',
'dojo/text!./templates/template.html',
'dijit/form/Button'
], function (declare, _WidgetBase, _TemplatedMixin, template, button) {
return declare('myWidget', [_WidgetBase, _TemplatedMixin], {
templateString: template,
@kjelelokk
kjelelokk / dojo_template.html
Created November 29, 2012 10:23
Dojo template html
<div>
<p>This is from a template.</p>
<button data-dojo-type="dijit.form.Button" >My button</button>
</div>
@kjelelokk
kjelelokk / dojo_require.html
Created November 29, 2012 10:22
Dojo require
<html>
...
<div data-dojo-type="myWidget"></div>
<script>
require(
['demo/myWidget',
'dojo/parser',
'dojo/domReady!'],
@kjelelokk
kjelelokk / dojo_define.js
Created November 29, 2012 10:15
Dojo define
define([
'_MyMixin',
'myWidget'
], function (_MyMixin, myWidget)
{
return declare('my.widget.name', [_MyMixin, myWidget], {
myProperty: 'prop',
myFunction: function () {
console.log('hei hei ' + propertyFromMyWidget);
},
@kjelelokk
kjelelokk / dojo_classInheritanceResult
Created November 29, 2012 10:10
Dojo class inheritance result
A: No
B: 99
C: true
D: false