<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by Håkon Nordli</title><link href="http://world.optimizely.com" /><updated>2016-04-08T12:33:20.0000000Z</updated><id>https://world.optimizely.com/blogs/hakon-nordli/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>Episerver full-text search module</title><link href="https://world.optimizely.com/blogs/hakon-nordli/dates/2016/4/episerver-full-text-search-module2/" /><id>&lt;p&gt;Episerver full-text search module aka Standard Search Inspector&lt;/p&gt; &lt;p&gt;The last years I&#39;ve set up and worked with several sites using Episerver full-text search. Episerver Search is like you might already know, a search engine delivered together with Episerver CMS without any extra costs. It is based on Lucene which gives it a powerful foundation.  &lt;p&gt;Several of times I&#39;ve had issues when customers wanted something extra like facets or want an explanation on how the relevance work.  &lt;p&gt;For me it has been difficult to find good examples, good practices and/or blog posts about the search API. To solve this I&#39;ve started to develop a module. I hope this can be a module that more people contribute to.  &lt;p&gt;The goal is not to compete with Find. Find is still a better search engine with more functionality, and the search engine I recommend customers. But for different reasons some customers don&#39;t want Find.  &lt;p&gt;At the moment the module only have two functions:  &lt;ol&gt; &lt;li&gt;A search inspector which shows indexed items as JSON objects. This gives us as developers a lot more control on which data that are indexed.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/link/79fcde2c68a24059ab1f6a1a3a7e9555.aspx&quot;&gt;&lt;img title=&quot;blogg image1&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;blogg image1&quot; src=&quot;/link/aa9a2f7f615a468e9c698f8b75c58939.aspx&quot; width=&quot;763&quot; height=&quot;814&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt; &lt;li&gt;A reindexing page. As several of us know, the reindex page is a hidden feature in Episerver which is a bit annoying. To be honest I visit my colleague &lt;a href=&quot;http://sveinaandahl.blogspot.no/2013/06/how-to-install-episerver-search-for.html&quot;&gt;Svein Aandahls blog post&lt;/a&gt; everytime I need the URL to the reindex-page. Sorry Svein, your visit numbers might go down.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/link/5edf246f25b04a69afe643329a913444.aspx&quot;&gt;&lt;img title=&quot;blogg image2&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;blogg image2&quot; src=&quot;/link/056de0a0b2f5479e95e3ef2ef3f2313f.aspx&quot; width=&quot;806&quot; height=&quot;342&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;The module is available through Episervers nuget feed, &lt;a href=&quot;http://nuget.episerver.com/en/OtherPages/Package/?packageId=Knowit.EPiModules.StandardSearchInspector&quot;&gt;http://nuget.episerver.com/en/OtherPages/Package/?packageId=Knowit.EPiModules.StandardSearchInspector&lt;/a&gt; &lt;/p&gt; &lt;p&gt;It is also added to Github, &lt;a href=&quot;https://github.com/knowit/Knowit.EPiModules.StandardSearchInspector&quot;&gt;https://github.com/knowit/Knowit.EPiModules.StandardSearchInspector&lt;/a&gt;, where anyone may add pull requests. Please be brave and add features, that would be awesome!&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</id><updated>2016-04-08T12:33:20.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Dojo - How to keep the widget&#39;s scope</title><link href="https://world.optimizely.com/blogs/hakon-nordli/dates/2016/1/dojo---how-to-keep-the-widgets-scope/" /><id>&lt;p&gt;When binding an event in JavaScript the scope outside the binding is not the same as inside. Which means that &quot;this&quot; is not the same outside as inside the binding.  &lt;p&gt;Below there is a JavaScript example, which console.logs two different &quot;this&quot;. The first console.log prints the object Foo, the second console.log prints the button object.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;a href=&quot;/link/c7829cf2c319497689c9ea9193d46dc4.aspx&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;/link/a131293c02234bfdb98189d08344fbce.aspx&quot; width=&quot;598&quot; height=&quot;301&quot; /&gt;&lt;/a&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;However, sometimes we want to keep the scope. This is often solved by putting &quot;this&quot; in a variable, like the example below. This way both console.logs prints the Foo object.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;/link/99e5df8e8e1c4b469c8281178df04efb.aspx&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;/link/b3bd27470abf485298214576272b33a9.aspx&quot; width=&quot;592&quot; height=&quot;301&quot; /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In Dojo there is a built-in function, hitch, which can keep the scope. This can come in handy when developing Dijit widgets.  &lt;p&gt;In the example below hitch forces the on method to retain the original scope. In this way we keep &quot;this&quot; inside the callback, and we do not need to create a variable for &quot;this&quot; like we did above.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;a href=&quot;/link/dda8dfc60d9d41c186d2a9cecc24df14.aspx&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;/link/aa21c30f13c7459db8fb7eeb910146dc.aspx&quot; width=&quot;596&quot; height=&quot;203&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</id><updated>2016-01-08T13:59:42.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Extend Dojo&#39;s onChange event by using intermediateChanges</title><link href="https://world.optimizely.com/blogs/hakon-nordli/dates/2015/11/extend-dojos-onchange-event-by-using-intermediatechanges/" /><id>&lt;p&gt;One of JavaScripts built-in events are &#39;change&#39;. It is triggered different depending on which input type you are using. For text input it is fired when the element looses focus after its value has changed.&amp;nbsp; &lt;p&gt;Not suprisingly, onChange in Dojo works the same. However it is possible to make it fire whenever the value changes by using intermediateChanges.&amp;nbsp; &lt;p&gt;The built-in dijit property, intermediateChanges, is a part of dijit.form widgets. By default it is set to false, but when it is set to true, it fires the onChange event whenever the value of the form widget changes.&amp;nbsp; This way it is possible to trigger something while the user is editing a property and before a text input looses focus.&amp;nbsp;&amp;nbsp; &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;a href=&quot;/link/1ad9bdcaa96b4c37925a71c536b5aaec.aspx&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;/link/b1c53a27942b45e78e48af32e032cdec.aspx&quot; width=&quot;1000&quot; height=&quot;257&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</id><updated>2015-11-25T13:12:17.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>5 things to know about Dojo</title><link href="https://world.optimizely.com/blogs/hakon-nordli/dates/2015/11/5-things-to-know-about-dojo/" /><id>&lt;p&gt;This blog post is part 2 of “Learn how to develop your own Dojo widget”. If you haven’t read part 1, I recommend you to read it. You may find it &lt;a href=&quot;/link/9a723b97500542b8ba7ea8048fc0498a.aspx&quot;&gt;here&lt;/a&gt;.&amp;nbsp; &lt;p&gt;In part 1 I promised to write 10 tips, it ended up being 5. I hope you can forgive me.&amp;nbsp; &lt;h2&gt;1. Including modules – define &lt;/h2&gt; &lt;p&gt;When looking at Dojo you will find a lot of definitions at the top. Dojo is separated into several small modules, which means that you only add the parts you are going to use. This is very nice since you only add the once you actually need. On the other hand, it is a bit annoying since you have to keep track of several modules.&amp;nbsp; &lt;p&gt;EPiServer has built some modules of their own. To be honest I do not have a complete overview of all of them, but they are documented here &lt;a href=&quot;/link/b1d8e803c99c4339b6fc912d5332f171.aspx?version=9&amp;amp;product=cms&quot;&gt;http://world.episerver.com/documentation/Javascript-Library/?version=9&amp;amp;product=cms&lt;/a&gt;  &lt;p&gt;After the definitions there is a list of function names which is the name you give the added modules. Through these function names you may use the modules in your javascript code.&lt;/p&gt;&lt;code&gt;define([ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dojo/_base/array&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dojo/on&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dojo/_base/declare&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dojo/_base/lang&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/_CssStateMixin&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/_Widget&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/_TemplatedMixin&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/_WidgetsInTemplateMixin&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/form/Textarea&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;epi/epi&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;epi/shell/widget/_ValueRequiredMixin&quot; &lt;br /&gt;],  &lt;p&gt;function ( &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; on, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lang, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _CssStateMixin, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _Widget, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _TemplatedMixin, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _WidgetsInTemplateMixin, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Textarea, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; epi, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _ValueRequiredMixin &lt;br /&gt;) { &lt;/p&gt;&lt;/code&gt; &lt;h2&gt;2. templateString&lt;/h2&gt; &lt;p&gt;This is the HTML representing your widget. Say, if you want to create an input text field, this is where you put your HTML. The important thing to know is that instead of using IDs or class names to handle your HTML in the JavaScript you should/must use data-dojo-attach-point. This way Dojo will create a reference to it and it will be available through the widget as this.attach-point-name. &lt;/p&gt; &lt;p&gt;Example templateString: &lt;/p&gt;&lt;code&gt;&#39;&amp;lt;div class=&quot;dijitInline&quot;&amp;gt;\&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div data-dojo-attach-point=&quot;textArea&quot; data-dojo-type=&quot;dijit.form.Textarea&quot;&amp;gt;&amp;lt;/div&amp;gt;\ &lt;br /&gt;&amp;lt;/div&amp;gt;&#39;&lt;/code&gt;  &lt;p&gt;Notice the data-dojo-type in the example above. Dojo creates new elements based on the Dojo-type. In our case it will create a textarea since we are using the dijit.form.Textarea. &lt;/p&gt; &lt;h2&gt;3. startup and postCreate&lt;/h2&gt; &lt;p&gt;PostCreate is a built-in Dojo method which runs after all the properties are set up, but it runs before the templateString is added to the DOM. It is a method where you may start/initialize other methods. &lt;/p&gt; &lt;p&gt;Startup is also a built-in Dojo method, but runs after postCreate and after the templateString is added to the DOM. This is where you may add bindings or any other needed setups.&lt;/p&gt; &lt;h2&gt;4. Saving changes &lt;/h2&gt; &lt;p&gt;When the editor is done, you want to save the data that is changed or added. There are mainly two methods you want to run doing that, this.onChange and this. set.&lt;/p&gt; &lt;p&gt;this._set sets the value to the widget and notify any observers. &lt;/p&gt; &lt;p&gt;this.onChange is for letting the widget wrapper updating the UI when the value is changed.&lt;/p&gt; &lt;p&gt;The exampe below is taken from the other blog post, part 1. It uses both this_set and this.onChange when saving changes.&lt;/p&gt;&lt;code&gt; &lt;p&gt;_setValue: function (value, updateTextarea) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //avoids running this if the widget already is started&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (this._started &amp;amp;&amp;amp; epi.areEqual(this.value, value)) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._set(&quot;value&quot;, value); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // set value to textarea&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateTextarea &amp;amp;&amp;amp; this.textArea.set(&quot;value&quot;, value);&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (this._started &amp;amp;&amp;amp; this.validate()) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Trigger change event&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onChange(value); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;},&lt;/p&gt;&lt;/code&gt; &lt;h2&gt;5. Connect vs on&lt;/h2&gt; &lt;p&gt;The built-in methods for binding events, connect and on, is two methods for the same thing. I&#39;ve noticed that connect is used in several EPiServer Dojo examples. According to the Dojo Documentation connect is deprecated. Based on that we should use the dojo/on module to bind events instead.&lt;/p&gt;&lt;code&gt; &lt;p&gt;this.connect(this.textArea, &quot;onChange&quot;, this._onTextAreaChanged); &lt;/p&gt; &lt;p&gt;on(this.textArea, &quot;change&quot;, lang.hitch(this, this._onTextAreaChanged)); &lt;/p&gt;&lt;/code&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</id><updated>2015-11-03T19:56:12.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Learn how to develop your own Dojo widget</title><link href="https://world.optimizely.com/blogs/hakon-nordli/dates/2015/10/learn-how-to-develop-your-own-dojo-widget3/" /><id>&lt;p&gt;“It was like getting a brick in the head, &#187; a developer told me after a dojo seminar a while back.&amp;nbsp;&amp;nbsp; Often when I talk to developers about dojo, I get the same message, they have no idea where to start. They find it a bit too difficult and it takes too much time to understand the basics.&amp;nbsp; &lt;/p&gt; &lt;p&gt;This has led me to write a new blog post on how to build your own Dojo widget. I have decided to split the article in two separate parts, first how and where to start building a widget and second, 10 tips that may come in handy when developing.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Before we start developing, I would like to point out a few things. Dojo is a library much like jQuery, you may do DOM manipulations and other fun things. Together with Dojo, you will also get Dijit, which is Dojo’s UI library. We use Dijit when dealing with widgets in EPiServer.&amp;nbsp; &lt;/p&gt; &lt;h2&gt;Step by step guide&amp;nbsp; &lt;/h2&gt; &lt;p&gt;Here is a list of files that are necessary for you to build your first widget. Depending on what you would like to develop, you might need other files as well. However, these are the ones you must have.&amp;nbsp; &lt;/p&gt; &lt;h3&gt;Step 1 – EditorDescriptor.cs&amp;nbsp; &lt;/h3&gt; &lt;p&gt;First, you need an EditorDescriptor. I suggest putting it in your Business/EditorDescriptors folder.&amp;nbsp; &lt;/p&gt; &lt;p&gt;It defines which editor to use for a specific property for a page or shared content. You may read more about it here. &lt;a href=&quot;/link/0bb46ad404ee48c5a57cdecbb01ab8f8.aspx&quot;&gt;http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/7/Editing/How-To/Registering-a-Custom-Editor/&lt;/a&gt; &lt;/p&gt;&lt;code&gt;using System; &lt;br /&gt;using System.Collections.Generic; &lt;br /&gt;using EPiServer.Shell.ObjectEditing.EditorDescriptors;  &lt;p&gt;namespace Alloy.Business.EditorDescriptors &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [EditorDescriptorRegistration(TargetType = typeof(String), UIHint = &quot;NewTextarea&quot;)] &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public class NewTextareaEditorDescriptor : EditorDescriptor &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public override void ModifyMetadata(EPiServer.Shell.ObjectEditing.ExtendedMetadata metadata, IEnumerable&amp;lt;Attribute&amp;gt; attributes) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ClientEditingClass = &quot;alloy/editors/NewTextarea&quot;; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base.ModifyMetadata(metadata, attributes); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;}&lt;/p&gt;&lt;/code&gt;  &lt;h3&gt;Step 2 – The dojo widget (JavaScript file) &lt;/h3&gt; &lt;p&gt;This is the actual widget where a lot of the magic happens. I suggest putting the file in your ClientResources/Scripts/Editors folder.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Here is an example of a small widget, a textarea. I recommend starting with this when building a widget for the first time. Later you can rewrite it and make it do whatever you need it to be. This way you have an excellent starting point with no errors. &lt;/p&gt; &lt;p&gt;The reason I have built a textarea is because EPiServer already have a textarea. That way no one will actually use this widget, but instead use it as a starting point.&amp;nbsp; &lt;/p&gt; &lt;p&gt;The widget is based on StringList from Alloy, but are rewritten and have several comments that explain several of the methods and modules. &lt;/p&gt;&lt;code&gt; &lt;p&gt;define([ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dojo/_base/array&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dojo/query&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dojo/on&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dojo/_base/declare&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dojo/_base/lang&quot;, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/_CssStateMixin&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/_Widget&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/_TemplatedMixin&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/_WidgetsInTemplateMixin&quot;, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dijit/form/Textarea&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;epi/epi&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;epi/shell/widget/_ValueRequiredMixin&quot; &lt;br /&gt;], &lt;/p&gt; &lt;p&gt;function ( &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; query, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; on, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lang, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _CssStateMixin, //_CssStateMixin is a mixin for widgets that set CSS classes on their nodes depending on hover/active/focused state, and also semantic state (checked, selected, disabled, etc.). &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _Widget, //BaseClass for all dijit widgets &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _TemplatedMixin, //dijit/_TemplatedMixin is a mixin for most widgets in dijit. It takes an HTML template, and creates the widget’s DOM tree according to that template. &lt;/p&gt; &lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _WidgetsInTemplateMixin, //When using this template in a directly extended widget class, you will need to mixin dijit._WidgetsInTemplateMixin in addition to dijit._TemplatedMixin. &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Textarea, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; epi, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _ValueRequiredMixin //Extends dijit/_CssStateMixin: &lt;a href=&quot;/link/b1d8e803c99c4339b6fc912d5332f171.aspx?documentId=episerverframework/7.1/epi/shell/widget/_ValueRequiredMixin&quot;&gt;http://world.episerver.com/Documentation/Javascript-Library/?documentId=episerverframework/7.1/epi/shell/widget/_ValueRequiredMixin&lt;/a&gt; &lt;br /&gt;) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return declare(&quot;alloy.editors.NewTextarea&quot;, [_Widget, _TemplatedMixin, _WidgetsInTemplateMixin, _CssStateMixin, _ValueRequiredMixin], { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; templateString: &quot;&amp;lt;div class=\&quot;dijitInline\&quot;&amp;gt;\ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div data-dojo-attach-point=\&quot;textArea\&quot; data-dojo-type=\&quot;dijit.form.Textarea\&quot;&amp;gt;&amp;lt;/div&amp;gt;\ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&quot;, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intermediateChanges: false, //default false. intermediatechanges is a dijit property which fire the change event when there is an actually change.&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value: null, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onChange: function (value) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Event &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //built-in dijit widget. postCreate is run after all the properties are set up, but before the templateString is added to the DOM &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; postCreate: function () { &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // call base implementation &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.inherited(arguments); &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Init textarea and bind event &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.textArea.set(&quot;intermediateChanges&quot;, this.intermediateChanges); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Notice the lang.hitch. It forces the on method to retain it’s original scope.&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on(this.textArea, &quot;change&quot;, lang.hitch(this, this._onTextAreaChanged)); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //built-in dijit widget. Runs after the templateString is added to the DOM.&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startup: function () { &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // build-in dojo method. Prevents an invalid form from submitting &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isValid: function () { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return !this.required || lang.isArray(this.value) &amp;amp;&amp;amp; this.value.length &amp;gt; 0 &amp;amp;&amp;amp; this.value.join() != &quot;&quot;; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Setter for value property. Runs at startup.&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _setValueAttr: function (value) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._setValue(value, true); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //runs at startup.&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _setReadOnlyAttr: function (value) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._set(&quot;readOnly&quot;, value); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.textArea.set(&quot;readOnly&quot;, value); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //A setter for intermediateChanges &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _setIntermediateChangesAttr: function (value) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.textArea.set(&quot;intermediateChanges&quot;, value); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._set(&quot;intermediateChanges&quot;, value); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Event handler for textarea &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _onTextAreaChanged: function (value) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._setValue(value, false); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _setValue: function (value, updateTextarea) { &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //avoids running this if the widget already is started &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (this._started &amp;amp;&amp;amp; epi.areEqual(this.value, value)) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // set value to this widget (and notify observers). Built-in dijit method. Source: &lt;a href=&quot;https://www.sitepen.com/blog/2013/10/16/dojo-faq-what-is-the-difference-between-set-and-_set/&quot;&gt;https://www.sitepen.com/blog/2013/10/16/dojo-faq-what-is-the-difference-between-set-and-_set/&lt;/a&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._set(&quot;value&quot;, value); &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // set value to textarea &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateTextarea &amp;amp;&amp;amp; this.textArea.set(&quot;value&quot;, value); &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (this._started &amp;amp;&amp;amp; this.validate()) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Trigger change event &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onChange(value); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }); &lt;br /&gt;}); &lt;br /&gt;&lt;/p&gt;&lt;/code&gt; &lt;h3&gt;Step 3 - Module.config &lt;/h3&gt; &lt;p&gt;Module.config should be in your web root folder. It is to add a mapping from alloy to ~/ClientResources/Scripts to the dojo loader configuration. If you do not have this, you will get 404 errors for your widget file.&amp;nbsp; &lt;/p&gt;&lt;code&gt; &lt;p&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt; &lt;br /&gt;&amp;lt;module&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dojo&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- Add a mapping from alloy to ~/ClientResources/Scripts to the dojo loader configuration --&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;paths&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add name=&quot;alloy&quot; path=&quot;Scripts&quot; /&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/paths&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/dojo&amp;gt; &lt;br /&gt;&amp;lt;/module&amp;gt;&lt;/p&gt;&lt;/code&gt; &lt;p&gt;&lt;br /&gt;Here is EPiServer’s documentation about module.config&amp;nbsp; &lt;br /&gt;&lt;a href=&quot;/link/5b5dc2ad61394b848503a77e114c38fd.aspx&quot;&gt;http://world.episerver.com/documentation/items/developers-guide/episerver-framework/7/configuration/configuring-moduleconfig/&lt;/a&gt;&amp;nbsp; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;Step 4 – Use the widget on a page &lt;/h3&gt; &lt;p&gt;To add the widget to a property, use the UIHint showed below: &lt;/p&gt;&lt;code&gt; &lt;p&gt;[UIHint(&quot;NewTextarea&quot;)] &lt;br /&gt;[Display(GroupName = SystemTabNames.Content, Order = 10)] &lt;br /&gt;public virtual string NewTextarea { get; set; } &lt;br /&gt;&lt;/p&gt;&lt;/code&gt; &lt;h2&gt;The End &lt;/h2&gt; &lt;p&gt;These files are only meant as a starting point. You may use them and rewrite them to whatever you want.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Remember to update the namespaces.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Happy coding!&amp;nbsp; &lt;/p&gt;</id><updated>2015-10-20T09:53:14.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Dojo – a color picker widget</title><link href="https://world.optimizely.com/blogs/hakon-nordli/dates/2015/9/dojo--a-color-picker-widget/" /><id>&lt;p&gt;Now and then, a web editor needs to pick a color either in a block or a page. There are several ways to pick colors, for instance you can use the built in dijit widget for picking colors, &lt;a href=&quot;http://dojotoolkit.org/reference-guide/1.10/dijit/ColorPalette.html&quot;&gt;http://dojotoolkit.org/reference-guide/1.10/dijit/ColorPalette.html&lt;/a&gt;, or just add a dropdown.  &lt;p&gt;In my opinion, I think the built-in ColorPalette from Dojo is too difficult and not as extendable. That is why I have created my own color picker. I have refactored the code and shared the property on github.  &lt;p&gt;Here is a screen dump from editmode:  &lt;p&gt;&lt;a href=&quot;/link/e26a4848beca4e8c85418f46ecb09807.aspx&quot;&gt;&lt;img title=&quot;clip_image001&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;clip_image001&quot; src=&quot;/link/aa3f7b66b20944d9aa1913153040e50a.aspx&quot; width=&quot;677&quot; height=&quot;209&quot; /&gt;&lt;/a&gt;  &lt;p&gt;This is a lightweight widget where you as a developer can decide which colors that will be available. In the templateString all the colors are visible through the A-tag.&lt;/p&gt;&lt;code&gt;&amp;lt;div class=\&quot;dijitInline\&quot;&amp;gt;\ &lt;br /&gt;&amp;lt;ul data-dojo-attach-point=\&quot;colorPickerList\&quot; class=\&quot;colorPickerList\&quot;&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#7cb5ec\&quot; style=\&quot;background-color:#7cb5ec;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#434348\&quot; style=\&quot;background-color:#434348;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#90ed7d\&quot; style=\&quot;background-color:#90ed7d;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#f7a35c\&quot; style=\&quot;background-color:#f7a35c;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#8085e9\&quot; style=\&quot;background-color:#8085e9;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#f15c80\&quot; style=\&quot;background-color:#f15c80;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#e4d354\&quot; style=\&quot;background-color:#e4d354;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#8085e8\&quot; style=\&quot;background-color:#8085e8;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#8d4653\&quot; style=\&quot;background-color:#8d4653;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;li&amp;gt;&amp;lt;a href=\&quot;#\&quot; data-color=\&quot;#91e8e1\&quot; style=\&quot;background-color:#91e8e1;\&quot;&amp;gt;&amp;lt;span&amp;gt;Color name 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;\ &lt;br /&gt;&amp;lt;/ul&amp;gt;\ &lt;br /&gt;&amp;lt;/div&amp;gt; &lt;/code&gt; &lt;p&gt;As you can see, the data-color attribute holds the color, and the style attribute is for showing the color. Notice the span-tag which holds the color name. This way it is more accessible.  &lt;p&gt;If you are going to use this in a project, I suggest that you to put the colors in the CSS and SASS/LESS variables, which may be used several places in your project. If you are not using SASS, LESS or other style preprocessors, I recommend you to have a look at it.  &lt;p&gt;To add the color picker to a project just add the descriptor file, css file and the dojo javascript file to the project code. Then you can start using it by adding the UIHint ColorPickerEditor. Also notice that I use string as a property. There is no need for a custom property in this case. &lt;/p&gt;&lt;code&gt;[UIHint(&quot;ColorPickerEditor&quot;)]&lt;br /&gt;[Display(GroupName = SystemTabNames.Content, Order = 25)]&lt;br /&gt;public virtual string ColorPicker { get; set; }&lt;br /&gt;&lt;/code&gt; &lt;p&gt;There is a more detailed description on git on how to add the widget. Please have a look!  &lt;p&gt;The widget is tested for EPiServer 8 and 9.  &lt;p&gt;The property is available on &lt;a href=&quot;https://github.com/knowit/ColorPickerEditor&quot;&gt;Github&lt;/a&gt; and is open for everyone to use. Please give me feedback if you find any bugs.  &lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</id><updated>2015-09-23T20:05:18.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Dojo widget - Multiple images in one property</title><link href="https://world.optimizely.com/blogs/hakon-nordli/dates/2015/8/dojo-widget---multiple-images-in-one-property/" /><id>&lt;p&gt;For some time I’ve had several customers who wanted an easy way to structure multiple images in one property. They needed a way to add images, descriptions and sort the images as easy as possible. This lead me to build the Multiple Images property.  &lt;p&gt;&amp;nbsp; &lt;h3&gt;How did I start&lt;/h3&gt; &lt;p&gt;At the beginning I read several different blog posts about dojo and EPiServer. I’m gonna be honest and say that I used a lot of time to understand how dojo works and work together with EPiServer. However, after a while I came to the conclusion that dojo was the correct thing to do and perfect match for EPiServer. Dojo gives EPiServer a lot of flexibility and it makes it is possible to create pretty much whatever you want.  &lt;p&gt;My best learning resource was the StringList.js from the Alloy solution. Well written code and a lot of comments made it easy to understand the widget. If you want to make you’re own widget I would suggest to take a look at it.  &lt;p&gt;&amp;nbsp; &lt;h3&gt;How does it work&lt;/h3&gt; &lt;p&gt;The Multiple Images property is easy to use. The editor can just drag images from the media archive into the property. The editor can then add a description and sort the images.  &lt;p&gt;&lt;a href=&quot;/link/a9bbfcd1aa514e1aa48292185d1f0e6b.aspx&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;/link/a67c03d6080b4c89ad45b82dd82ff267.aspx&quot; width=&quot;850&quot; height=&quot;534&quot; /&gt;&lt;/a&gt;  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;p&gt;&lt;a href=&quot;/link/7dc1fdb8ea7d4bfeb63f88d01881e391.aspx&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;/link/0972771524d445ab80e11e394cc590f0.aspx&quot; width=&quot;578&quot; height=&quot;299&quot; /&gt;&lt;/a&gt;  &lt;p&gt;When handling images on a website there are often two description fields or areas, the alternative text and the text below the image. The description for this property is not suppose to be the alternative text, but typically the text below the image. It would be possible to add a second text description, but I’ve only added one to avoid too many choices and to keep it simple. My suggestion is to rather put the alternative text in a separate text property on the image itself. However this is up to the developer and customer to decide.  &lt;p&gt;&amp;nbsp; &lt;h3&gt;Handling all the images&lt;/h3&gt; &lt;p&gt;To handle all the images and the attached description, I put everything in a json-object. This made it very easy to work with the image-objects.  &lt;p&gt;When dragging an object in dojo you have to create a target and a source. EPiServer has already created all we need for the source objects. This meant I only had to create a target which could accept the EPiServer source type. When dragging an image to the drop zone (target) I got an object (source object) with all the necessary info about the image.  &lt;p&gt;Here is an example for the object received when dragging an item:  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;code class=&quot;javascript&quot;&gt;{ &lt;br /&gt;&lt;/code&gt;&lt;code&gt;&quot;url&quot;: &quot;/globalassets/events/patrick-jane_keynote.png&quot;,&lt;br /&gt;&lt;/code&gt;&lt;code&gt;&quot;previewUrl&quot;: &quot;/EPiServer/CMS/Content/globalassets/events/patrick-jane_keynote.png,,109?epieditmode=False&quot;,&lt;br /&gt;&quot;permanentUrl&quot;: &quot;/link/1735c52fff064081b4d6251ddff76cd9.aspx&quot;, &quot;text&quot;: &quot;Patrick-Jane_KeyNote.png&quot;,&lt;br /&gt;&quot;typeIdentifier&quot;: &quot;alloyepi8.models.media.imagefile&quot; &lt;br /&gt;} &lt;/code&gt; &lt;p&gt;&amp;nbsp; &lt;p&gt;To handle the description I just added an extra string variable in the json-item.  &lt;p&gt;&amp;nbsp; &lt;h3&gt;EPiServer tip - saving a property&lt;/h3&gt; &lt;p&gt;At first the property was saved as a string, but it didn’t take me long before I realized I had to do something about that since EPiServer wasn’t aware of the images being used. I therefor created a new EPiServer property. This was a lot more hassle then I had anticipated. To create the property itself was well documented, but the saving part of it was not. Luckily other have had the same issue before me. In Alexander Haneng&#39;s &lt;a href=&quot;/link/8f2cbf76bfd8405c81da65828325b6c4.aspx&quot;&gt;blogpost&lt;/a&gt; from 2013, I found that EPiServer didn’t know how to serialize the multiple images object. Based on that I added a converter which inherited from JsonConverter. Have a look at the MultipleImagesConverter class for how it is done.  &lt;p&gt;&amp;nbsp; &lt;h3&gt;Available for everyone&lt;/h3&gt; &lt;p&gt;The Multiple Images property is tested in EPiServer 8. &lt;/p&gt; &lt;p&gt;The property is available on &lt;a href=&quot;https://github.com/knowit/MultipleImages&quot;&gt;Github&lt;/a&gt; and is open for everyone to use. Please give me feedback if you find any bugs. &lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</id><updated>2015-08-26T10:06:56.0000000Z</updated><summary type="html">Blog post</summary></entry></feed>