{"id":273,"date":"2013-07-19T09:20:47","date_gmt":"2013-07-19T09:20:47","guid":{"rendered":"http:\/\/www.w3.org\/community\/rww\/?p=273"},"modified":"2013-07-19T09:20:47","modified_gmt":"2013-07-19T09:20:47","slug":"tabulator-creating-a-new-pane-part-1","status":"publish","type":"post","link":"https:\/\/www.w3.org\/community\/rww\/2013\/07\/19\/tabulator-creating-a-new-pane-part-1\/","title":{"rendered":"Tabulator &#8212; Creating a New Pane &#8212; Part 1"},"content":{"rendered":"<p>Last time, we looked at <a href=\"http:\/\/www.w3.org\/community\/rww\/2013\/06\/25\/installing-the-tabulator\/\">how to install The Tabulator<\/a> as a Firefox extension.\u00a0 Although tabulator can also run as a chrome extension or a JavaScript shim, one advantage of the approach outlined is that you can dive in to the code and make changes.<\/p>\n<p>We&#8217;re going to look at how to create a new &#8216;Pane&#8217; and expand slightly on the <a href=\"http:\/\/dig.csail.mit.edu\/2005\/ajar\/ajaw\/Developer.html\" target=\"_blank\" rel=\"nofollow\">developer notes.<\/a>\u00a0 For this tutorial you&#8217;ll need a text editor and basic JavaScript knowledge.<\/p>\n<h2><span style=\"color: #0000ff\">What is a Tabulator Pane?<\/span><\/h2>\n<p>Panes are views for displaying different types of data, and creating apps that are data driven.\u00a0 Although tabulator has many generic data panes, for viewing, querying and <a href=\"http:\/\/dig.csail.mit.edu\/2007\/tab\/tutorial\/editing.mov\" target=\"_blank\" rel=\"nofollow\">editing data<\/a>, it can be handy to have vertical specific panes, too.<\/p>\n<p>For example for a Person entity you may want a social style pane that allows updates to your timeline, for a publication you may want a special reader, or for your photos you may wish to develop a gallery pane.\u00a0 In this two part tutorial I&#8217;ll show how to display a microblog post in a pane.<\/p>\n<h2><span style=\"color: #0000ff\">Step 1: Find an Icon<\/span><\/h2>\n<p><a href=\"http:\/\/www.w3.org\/community\/rww\/files\/2013\/07\/microblog_large.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-274\" src=\"http:\/\/www.w3.org\/community\/rww\/files\/2013\/07\/microblog_large.png\" alt=\"\" width=\"128\" height=\"128\" \/><\/a><\/p>\n<p>Each pane will normally require an icon.\u00a0 There are many icon repositories on the web, for this I used, <a href=\"http:\/\/openiconlibrary.sourceforge.net\/gallery2\/?.\/Icons\/apps\/accessories-text-editor-6.png\" target=\"_blank\" rel=\"nofollow\">openiconlib<\/a> which has conveniently sized 22&#215;22 sized icons under LGPG.<\/p>\n<p>The icons are stored in content\/icons from the main source tree.\u00a0 In our case we will save the <a href=\"http:\/\/openiconlibrary.sourceforge.net\/gallery2\/open_icon_library-full\/icons\/png\/22x22\/apps\/accessories-text-editor-6.png\" target=\"_blank\" rel=\"nofollow\">22&#215;22 PNG<\/a> under <strong>\/content\/icons\/microblog\/microblogPost.png<\/strong><\/p>\n<h2><span style=\"color: #0000ff\">Step 2: Add the Icon to Tabulator<\/span><\/h2>\n<p>Next we need to add the icon to tabulator and this is done in the file located at <strong>\/content\/js\/init\/icons.js<\/strong>.\u00a0 Add the following line:<\/p>\n<pre>tabulator.Icon.src.icon_mbpost = iconPrefix + 'icons\/microblog\/microblogpost.png';<\/pre>\n<h2><span style=\"color: #0000ff\">Step 3: Add the Pane<\/span><\/h2>\n<p>To add the pane we need to create a new JavaScript file located at <strong>\/content\/js\/panes\/microblog\/<\/strong><\/p>\n<pre>tabulator<span style=\"color: #808030\">.<\/span>panes<span style=\"color: #808030\">.<\/span>register<span style=\"color: #808030\">(<\/span> <span style=\"color: #800080\">{<\/span>\r\n\r\n  icon<span style=\"color: #800080\">:<\/span> tabulator<span style=\"color: #808030\">.<\/span>Icon<span style=\"color: #808030\">.<\/span>src<span style=\"color: #808030\">.<\/span>icon_mbpost<span style=\"color: #808030\">,<\/span><span style=\"color: #696969\">\/\/This icon should be defined in icons.js<\/span>\r\n  label<span style=\"color: #800080\">:<\/span> <span style=\"color: #800000;font-weight: bold\">function<\/span><span style=\"color: #808030\">(<\/span>subject<span style=\"color: #808030\">)<\/span> <span style=\"color: #800080\">{<\/span> <span style=\"color: #696969\">\/\/'subject' is the source of the document<\/span>\r\n    <span style=\"color: #800000;font-weight: bold\">if<\/span> <span style=\"color: #808030\">(<\/span><span style=\"color: #0f4d75\">true<\/span><span style=\"color: #808030\">)<\/span> <span style=\"color: #800080\">{<\/span>\r\n      <span style=\"color: #800000;font-weight: bold\">return<\/span> <span style=\"color: #800000\">\"<\/span><span style=\"color: #0000e6\">MicroblogPost<\/span><span style=\"color: #800000\">\"<\/span><span style=\"color: #800080\">;<\/span> <span style=\"color: #696969\">\/\/The icon text<\/span>\r\n    <span style=\"color: #800080\">}<\/span> <span style=\"color: #800000;font-weight: bold\">else<\/span> <span style=\"color: #800080\">{<\/span>\r\n      <span style=\"color: #800000;font-weight: bold\">return<\/span> <span style=\"color: #0f4d75\">null<\/span><span style=\"color: #800080\">;<\/span>\r\n    <span style=\"color: #800080\">}<\/span>\r\n  <span style=\"color: #800080\">}<\/span><span style=\"color: #808030\">,<\/span>\r\n\r\n  render<span style=\"color: #800080\">:<\/span> <span style=\"color: #800000;font-weight: bold\">function<\/span><span style=\"color: #808030\">(<\/span>subject<span style=\"color: #808030\">,<\/span> document<span style=\"color: #808030\">)<\/span> <span style=\"color: #800080\">{<\/span>\r\n    <span style=\"color: #800000;font-weight: bold\">var<\/span> newDiv <span style=\"color: #808030\">=<\/span> document<span style=\"color: #808030\">.<\/span>createElement<span style=\"color: #808030\">(<\/span><span style=\"color: #800000\">\"<\/span><span style=\"color: #0000e6\">h2<\/span><span style=\"color: #800000\">\"<\/span><span style=\"color: #808030\">)<\/span><span style=\"color: #800080\">;<\/span>\r\n    <span style=\"color: #800000;font-weight: bold\">var<\/span> newContent <span style=\"color: #808030\">=<\/span> document<span style=\"color: #808030\">.<\/span>createTextNode<span style=\"color: #808030\">(<\/span><span style=\"color: #800000\">\"<\/span><span style=\"color: #0000e6\">Microblog will appear here!<\/span><span style=\"color: #800000\">\"<\/span><span style=\"color: #808030\">)<\/span><span style=\"color: #800080\">;<\/span>\r\n    newDiv<span style=\"color: #808030\">.<\/span>appendChild<span style=\"color: #808030\">(<\/span>newContent<span style=\"color: #808030\">)<\/span><span style=\"color: #800080\">;<\/span>\r\n    <span style=\"color: #800000;font-weight: bold\">return<\/span> newDiv<span style=\"color: #800080\">;<\/span>\r\n  <span style=\"color: #800080\">}<\/span>\r\n\r\n<span style=\"color: #800080\">}<\/span> <span style=\"color: #808030\">,<\/span> <span style=\"color: #0f4d75\">true<\/span><span style=\"color: #808030\">)<\/span><span style=\"color: #800080\">;<\/span><\/pre>\n<p>The (true) condition means that this icon will always appear (more on this in part 2).\u00a0 The render function will simply display a generic heading for testing purposes.\u00a0 Later we will show how to query an actual microblog and display the fields.<\/p>\n<h2><span style=\"color: #0000ff\">Step 4 &#8212; Load the Pane and Test<br \/>\n<\/span><\/h2>\n<p><a href=\"http:\/\/www.w3.org\/community\/rww\/files\/2013\/07\/microblogpost.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-279\" src=\"http:\/\/www.w3.org\/community\/rww\/files\/2013\/07\/microblogpost.png\" alt=\"\" width=\"263\" height=\"96\" \/><\/a><\/p>\n<p><em>Image: New pane Icon added to Tabulator<\/em><\/p>\n<p>We&#8217;re now ready for the final step.\u00a0 Add the line below to <strong>\/content\/js\/init\/init.js<\/strong> and once done you should see the icon on any data that the tabulator imports.<\/p>\n<pre>\u00a0tabulator.loadScript(\"js\/panes\/microblogPane\/microblogPostPane.js\");<\/pre>\n<p>If all has gone well you should see the new icon appear in tabulator, after restarting.\u00a0 Try clicking the following test <a href=\"http:\/\/foaf.cc\/demo\/microblogpost.ttl#post101\" target=\"_blank\" rel=\"nofollow\">link<\/a> to see if you have been successful!<\/p>\n<h2><span style=\"color: #0000ff\">What&#8217;s Next?<\/span><\/h2>\n<p>We&#8217;ve seen how to add a simple pane to The Tabulator.\u00a0 In the next part we will look at how to get data items from a real microblog post, how display the icon conditionally and how to style the page.\u00a0 The ultimate goal here is to be able to both read and write microblog posts, and share them with your social graph, using web standards.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last time, we looked at how to install The Tabulator as a Firefox extension.\u00a0 Although tabulator can also run as a chrome extension or a JavaScript shim, one advantage of the approach outlined is that you can dive in to &hellip; <a href=\"https:\/\/www.w3.org\/community\/rww\/2013\/07\/19\/tabulator-creating-a-new-pane-part-1\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":26,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"yes","footnotes":""},"categories":[19],"tags":[16,15,13,21],"class_list":["post-273","post","type-post","status-publish","format-standard","hentry","category-rww-2","tag-linkeddata","tag-rww","tag-readwriteweb","tag-tabulator"],"_links":{"self":[{"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/comments?post=273"}],"version-history":[{"count":6,"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/posts\/273\/revisions"}],"predecessor-version":[{"id":281,"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/posts\/273\/revisions\/281"}],"wp:attachment":[{"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/media?parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/categories?post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.w3.org\/community\/rww\/wp-json\/wp\/v2\/tags?post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}