<?xml version="1.0" encoding="UTF-8"?>
<rss version='2.0' xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Prasad Hewage</title>
    <description>I am a software engineer interested in javascript , game development and tool making</description>
    <link>https://prasad19sara.silvrback.com/feed</link>
    <atom:link href="https://prasad19sara.silvrback.com/feed" rel="self" type="application/rss+xml"/>
    <category domain="prasad19sara.silvrback.com">Content Management/Blog</category>
    <language>en-us</language>
      <pubDate>Thu, 08 May 2014 19:21:34 +0100</pubDate>
    <managingEditor>prasad19sara@gmail.com (Prasad Hewage)</managingEditor>
      <item>
        <guid>https://prasad19sara.silvrback.com/bootstrap-responsive-layout-designer#3681</guid>
          <pubDate>Thu, 08 May 2014 19:21:34 +0100</pubDate>
        <link>https://prasad19sara.silvrback.com/bootstrap-responsive-layout-designer</link>
        <title>Bootstrap - responsive layout designing with gridit</title>
        <description>A drag n drop html5 editor</description>
        <content:encoded><![CDATA[<p><a href="http://gridit.meteor.com/"><strong>Gridit</strong></a> : An <a href="https://github.com/prasadKodeInCloud/gridit">open source</a>  bootstrap layout designing tool.</p>

<h2 id="introduction">Introduction</h2>

<p>A few weeks ago i saw <a href="https://nadeesha.silvrback.com/gridster-boostroap-0-1">a post by Nadeeka</a> on creating a twitter <a href="http://getbootstrap.com/">bootstrap</a> layout generation plugin for <a href="http://gridster.net/">gridster</a>. I tested the plugin and the layout generation part was fine for the selected use case. But I realized that gridster is not the best tool to support layout generation since,</p>

<ul>
<li>Have to create initial gridster layout manually.</li>
<li>Current version of gridster does not allow adding inner elements.</li>
<li>Drag and drool feature of gridster prevents placing elements as wish in some scenarios.</li>
</ul>

<p>So I started to create a better editor as a substitute for gridster in this use case.</p>

<h2 id="get-started">Get Started</h2>

<p>I developed the drag and drop editor using <a href="http://kineticjs.com/">kineticjs</a>, canvas drawing library for Html5. The application was developed as a <a href="https://www.meteor.com/">meteor</a> app since it is easy to develop, test and publish javascript apps using meteor.</p>

<p><img alt="gridit editor" src="https://silvrback.s3.amazonaws.com/uploads/85105f0a-d525-4217-99a5-6b712ee751b0/gridit-1_large.png" /></p>

<p>The grid layout in editor represents html container  with 12 columns grid system. You can simply drag n drop divs to the container with exact column sizes using the elements in <strong>toolbox</strong>. For an example <strong>col-07</strong> represents a div with 7 columns and 1 row. You can resize a selected div using the pointers. </p>

<p>Once clicked on the <strong>Grid-It</strong> button you will be able to see actual responsive bootstrap layout, drew in the editor. </p>

<p><img alt="gridit layout" src="https://silvrback.s3.amazonaws.com/uploads/46815a23-347f-4a2a-a43f-21744b7073ab/gridit-2_large.png" /></p>

<p>Resize the screen to check responsive features of the grid system.</p>

<p><img alt="gridit" src="https://silvrback.s3.amazonaws.com/uploads/0575f39d-45af-4ad6-a1e6-7a546d8f2947/gridit-3_large.png" /></p>

<p>The best part is, after all you can download the html file of the layout by clicking <strong>Download</strong> button.</p>

<p>Note: <em>Please change the **bootstrap.css</em>* file path defined in downloaded <strong>layout.html</strong> to match with the relative file path of bootstrap.css file in your app. By default it is*</p>

<p><code>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;bootstrap.css&quot;&gt;</code></p>

<h2 id="dig-in">Dig In</h2>

<p>The ultimate goal of the drag n drop editor is to provide the layout as a json array of divs once click on <strong>Grid-It</strong> button. A div element contains following properties.</p>

<ul>
<li>  xIndex (column)</li>
<li>  yIndex (row)</li>
<li>  width</li>
<li>  height</li>
</ul>

<p><img alt="gridit layout-examle" src="https://silvrback.s3.amazonaws.com/uploads/b292ab62-024b-4c29-b804-4259af638c0a/gridit-4_large.png" /></p>

<p>For example the json array for above layout is</p>
<div class="highlight"><pre><span></span>[{&quot;xIndex&quot;:0,&quot;yIndex&quot;:0,&quot;width&quot;:6,&quot;height&quot;:1},{&quot;xIndex&quot;:6,&quot;yIndex&quot;:0,&quot;width&quot;:6,&quot;height&quot;:1},{&quot;xIndex&quot;:0,&quot;yIndex&quot;:1,&quot;width&quot;:8,&quot;height&quot;:1},{&quot;xIndex&quot;:8,&quot;yIndex&quot;:1,&quot;width&quot;:4,&quot;height&quot;:1},{&quot;xIndex&quot;:0,&quot;yIndex&quot;:2,&quot;width&quot;:4,&quot;height&quot;:2},{&quot;xIndex&quot;:4,&quot;yIndex&quot;:2,&quot;width&quot;:8,&quot;height&quot;:1},{&quot;xIndex&quot;:4,&quot;yIndex&quot;:3,&quot;width&quot;:8,&quot;height&quot;:1}] 
</pre></div>
<p>This array is used to generate actual bootstrap layout.</p>

<h2 id="improvements">Improvements</h2>

<p>As I experienced drag n drop code generating editors rarely completely solve an addressed problem. This is applicable to the <strong>gridit</strong> as well. Currently the tool only allows generating layouts for medium devices <strong>(col-md)</strong>. For now, this tool is helpful to the ui designers at least to some extent as I believe.</p>

<p>I am not a ui designer and I mostly consider about the functionality and accuracy of drag n drop editor. I am planning to support adding <a href="http://getbootstrap.com/css/#grid-nesting">nesting columns</a> as described in bootstrap site in near future.</p>

<h2 id="contribution">Contribution</h2>

<p>Grid-It is an open source project under Apache license. Source code in available in <a href="https://github.com/prasadKodeInCloud/gridit">https://github.com/prasadKodeInCloud/gridit</a></p>

<p>The github project consists of a branch called gridster-bootstrap which supports <a href="https://github.com/ncthis/gridster-bootstrap">gridster-bootstrap</a> library integration.</p>

<p>Please report bugs and suggest features in github project. You are welcome to improve the tool as well providing better algorithm to generate layout. </p>

<p>Thanks !!!</p>
]]></content:encoded>
      </item>
  </channel>
</rss>