Wednesday, February 01, 2006
by Nik Kalyani
Wednesday, February 01, 2006 7:53:24 PM (Pacific Standard Time, UTC-08:00)

The IE7 toolbar has an RSS icon that is ordinarily grayed-out, but lights up when visiting certain web pages.

Clicking the icon displays a list of feeds available on the page. When you select a feed you see a formatted version of the feed along with options to subscribe to the feed and change the sort order of items. Once you subscribe to the feed, it gets added to the “Favorites Center” which you can open to organize your feeds or view them.

If you are a web developer and have made RSS feeds available on your web pages, you can make discovery and subscription of these feeds easier for IE7 users by adding a few elements to your page that announce the presence of the feeds. Adding a <LINK> tag to the page Head with the correct attributes will do the trick. For example, my blog has the following:

<link rel="alternate" type="application/rss+xml" title="My RSS Feed" ref="http://blogs.speerio.net/peerio/SyndicationService.asmx/GetRss" /> 

As you can see, this is quite simple; you just have to add the attributes “rel,” type,” “title,” and “ref”. This is a simple addition that will instantly make your RSS feeds easier to consume. 

by Nik Kalyani
Wednesday, February 01, 2006 11:25:26 AM (Pacific Standard Time, UTC-08:00)

Sometimes, it is necessary to override stylesheets defined on a page or to add additional stylesheets, perhaps for different media. The script below defines a JS object that allows you to define stylesheets for screen/print for IE/Other browsers. It then adds them to the page dynamically.

In the code below, you can ignore the portion from //BEGIN to //END. The snippet at the end is all that needs to be changed. Se the desired values for “picker.ieScreen,” “picker.iePrint,” “picker.otherScreen,” and “picker.otherPrint” and the code will take care of the rest.

<script language="javascript">

// BEGIN: styleSheetPicker object definition
function styleSheetPicker()
{
   this.ieScreen = this.iePrint = this.otherScreen = this.otherPrint = "";
}

styleSheetPicker.prototype.render = function()
{
   if (document.createStyleSheet)
   {
    if (this.ieScreen)
     document.createStyleSheet(this.ieScreen);

    if (this.iePrint)
        {
     var ieP = document.createStyleSheet(this.iePrint);
            ieP.media = "print";
        }
   }
   else
   {
        var head = document.getElementsByTagName("head")[0];
    if (this.otherScreen != "")
            head.innerHTML += "<link rel=\"stylesheet\" href=\"" + this.otherScreen + "\">";

    if (this.otherPrint != "")
            head.innerHTML += "<link rel=\"stylesheet\" media=\"print\" href=\"" + this.otherPrint + "\">";

   }
}
// END: styleSheetPicker object definition


var picker = new styleSheetPicker();

// IE stylesheets
picker.ieScreen = "ie.css";
picker.iePrint = "other.css";

// Other browser stylesheets
picker.otherScreen = "default.css";
picker.otherPrint = "other.css";

picker.render();

</script>

 

#    Comments [1] - Trackback    

CSS | Javascript

 Wednesday, April 20, 2005
by Nik Kalyani
Wednesday, April 20, 2005 7:31:38 PM (Pacific Standard Time, UTC-08:00)

There are many different solutions for creating tabbed content in HTML pages. For a number of my apps, I needed a simple, lightweight solution that was easy to use and to integrate with my apps. I came up with a simple solution and am sharing it here. Hopefully someone will find it useful.

The solution consists of a table containing the tabs and DIV’s representing the content for each tab. The tabs table has one cell for each tab with ID of “Tab_n” where n starts with 0 and increases by 1 for each tab. Add an onClick handler for each cell that calls tabClickHandler(n). Finally, create a DIV for each tab’s content and set its ID to be “Panel_n” where n starts with 0 and increases by 1 for each tab. Add a style attribute of “display: none” for all DIVs representing the tab content except for the first, which should be set to “display:block”.

<script language="javascript">
function tabClickHandler(tab)
  {
    i = -1;
    while (true)
    {
        i++;
        objTab = eval(document.getElementById("Tab_" + i));

        if (objTab)
        {
            objTab.className = (i == tab) ? "Speerio-SelectedTab" : ((i > tab) 
                                          ?
"Speerio-RightTab" : "Speerio-LeftTab");
            document.getElementById("Panel_" + i).style.display = (i == tab ? "block" : "none");
        }
        else break;
     }
  }
</script>

<style>
    .Speerio-Tabs { width:100%; color: black; font-family: Verdana,Arial,Helvetica,Sans Serif}
    .Speerio-TabLeftSpacer {width:10%;  BORDER-BOTTOM: 1px solid black}
    .Speerio-TabRightSpacer {width:10%; BORDER-BOTTOM: 1px solid black}
    .Speerio-SelectedTab { width:20%; BORDER-RIGHT: 1px solid black; BORDER-TOP: 1px solid black; BORDER-LEFT: 1px solid black}
    .Speerio-LeftTab {cursor: hand; width:20%;  BORDER-TOP: 1px solid #cccccc; BORDER-LEFT: 1px solid #cccccc; CURSOR: hand; BORDER-BOTTOM: 1px solid black; background-color: #eeeeee}
    .Speerio-RightTab {cursor: hand; width:20%;  BORDER-RIGHT: 1px solid #cccccc; BORDER-TOP: 1px solid #cccccc; BORDER-LEFT: medium none; CURSOR: hand; BORDER-BOTTOM: 1px solid black; background-color: #eeeeee}
    .Speerio-TabLabel { font-size: 8pt; font-weight: bold; color: black; font-family: Verdana,Arial,Helvetica,Sans Serif}
</style>

<table cellspacing="0" cellpadding="2" border="0" align="center" class="Speerio-Tabs">
 <tr>
  <td class="Speerio-TabLeftSpacer">&nbsp;</td>
  <td id="Tab_0" class="Speerio-SelectedTab" nowrap align="Center" valign="Middle" onClick="tabClickHandler(0)">
   <span class="Speerio-TabLabel">ABC</span></td>
  <td id="Tab_1" class="Speerio-RightTab" nowrap align="Center" valign="Middle" onClick="tabClickHandler(1)">
   <span class="Speerio-TabLabel">DEF</span></td>
  <td id="Tab_2" class="Speerio-RightTab" nowrap align="Center" valign="Middle" onClick="tabClickHandler(2)">
   <span class="Speerio-TabLabel">GHI</span></td>
  <td id="Tab_3" class="Speerio-RightTab" nowrap align="Center" valign="Middle" onClick="tabClickHandler(3)">
   <span class="Speerio-TabLabel">JKL</span></td>

  <!-- Add as many additional cells corresponding to tabs here -->
  <td class="Speerio-TabRightSpacer" align="right">&nbsp;</td>
 </tr>
</table>
  <!-– Add a DIV for each tab’s content here -->

<div id="Panel_0" style="display:block" width="100%">Contents of the first tab</div>
<div id="Panel_1" style="display:none" width="100%">
Contents of the second tab
</div>
<div id="Panel_2" style="display:none" width="100%">
Contents of the third tab
</div>
<div id="Panel_3" style="display:none" width="100%">
Contents of the fourth tab</div>


 

 

 Sunday, March 20, 2005
by Nik Kalyani
Sunday, March 20, 2005 12:49:43 PM (Pacific Standard Time, UTC-08:00)

The DotNetNuke Control Panel is generally positioned at the top of a page (although it can be positioned anywhere). It is displayed if a user has administrative rights to a page. After the initial layout of a page, the Control Panel is not often needed, but it continues to take up valuable screen real-estate. I saw a recent discussion on this issue in the ASP.net forums, and decided that it presents an interesting U.I. challenge. (Turns out it really isn’t much of a challenge.)

At Bryan Andrews’ suggestion, I had actually developed a script modeled after the Windows Terminal Services Client collapsible admin bar some months back. The bar is visible at the top, but rolls up after a few seconds. I posted the script to the Core Team forum, but unfortunately, there was no interest.

Anyway, getting back to the Control Panel solution. I like the Terminal Services client concept and modeled my solution after it. One of my design goals was to keep things really simple and not require any external images or the like.

My solution works as follows:

1) My script block needs to be inserted into any DNN skin, replacing the existing element with id=”ControlPanel”

2) It renders the Control Panel at the top of the page (coordinates 0,0). The Control Panel is initially hidden and is represented by a 5px tall red bar.

3) Move your mouse over the bar and the Control Panel is displayed over page content. This is an important difference from the standard Control Panel as the page content remains in place and does not scroll down.

4) When the mouse cursors is moved over the red bar one more time, the Control Panel smoothly rolls up.

Here is the code. Just paste it into a DNN skin ascx file, taking care to replace the element with id=”ControlPanel” that should already be present in the file.

<!-- Begin collapsible Control panel code -->

<script language="Javascript">

var rollUp = false;
function collapseElement(objId)
{
   o = document.getElementById(objId);
   h = parseInt(o.style.height);
   if (h > 6)
       {
           h--;
           o.style.height= h + "px";
           window.setTimeout("collapseElement('" + objId + "')",5);
       }
   else
       rollUp = false;
}


function displayElement(height)
{
    obj = document.getElementById("<%= ControlPanel.ClientID %>");

    if (rollUp)
       collapseElement("<%= ControlPanel.ClientID %>");
    else
    {
       rollUp = true;   
         obj.style.height = height;
    }
}
</script>

<style>

.ControlPanelHeader
{
        height:5px;
        width:100%;
        background-color:#cc0000;
        padding-top:5px;
        overflow:hidden
}

.RollUpControlPanel
{
         position:absolute;
        top:0px;
        left:0px;
        z-Index:1000;
        height:5px;
        width:100%;

        overflow: hidden;
}

</style>

<div class="RollUpControlPanel" id="ControlPanel" runat="server">
<div class="ControlPanelHeader" onmouseover="displayElement('110px')">&nbsp;</div>
</div>

<!-- End collapsible control panel code -->

 

 Tuesday, March 08, 2005
by Nik Kalyani
Tuesday, March 08, 2005 10:36:49 PM (Pacific Standard Time, UTC-08:00)

I am working on a web app that consists of a treeview on the left and content on the right. The basic layout is a table with the height of the content determining the overall height of the table.

This basically means the treeview has to be scrollable, since it's possible that the table height is less than the tree height. Simple enough...put the treeview inside a DIV and change its "height" style attribute to 100%.

Works in IE6 but does not in FireFox. After Googling for hours and not finding a good solution, I devised a function to make this work. In my function, the params are the ID's of the main table and the DIV containing the treeview. The code first sets the height of the scrollable DIV to 0. This allows the main table to adjust to its normal height. Then the DIV's height is set to the same as the table height.

Works in IE6 and FireFox.

function setScrollerHeight(mainTableId, explorerScrollerId)

         var mainTable = document.getElementById(mainTableId); 
         var scroller = document.getElementById(explorerScrollerId); 
         if (!scroller) return; 
         if (mainTable.clientHeight > 0) 
         { 
                  scroller.style.height = "0px"; 
                  scroller.style.height = mainTable.clientHeight; 
         }
         else 
                  scroller.style.height = "500px"; }

 Tuesday, March 01, 2005
by Nik Kalyani
Tuesday, March 01, 2005 12:20:18 AM (Pacific Standard Time, UTC-08:00)

Microsoft Word creates awful HTML code. If you need to use it on a web page (especially in an HTML editor), you will want to clean it up a bit. Here’s a Javascript function that will take a string of text copied from Microsoft Word, and return it minus all the extraneous formatting that Word adds:


function cleanWordContent(wordContent)
{

        wordDiv = document.createElement("DIV");
 wordDiv.innerHTML = wordContent;

 for (var i=0;i<wordDiv.all.length;i++)
 {
  wordDiv.all[i].removeAttribute("className","",0);
  wordDiv.all[i].removeAttribute("style","",0);
 }
 wordContent = wordDiv.innerHTML;
 wordContent = String(wordContent).replace(/<\\?\?xml[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?o:p[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?v:[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?o:[^>]*>/g,"");
 wordContent = String(wordContent).replace(/&nbsp;/g,"");//<p>&nbsp;</p>
 wordContent = String(wordContent).replace(/<\/?SPAN[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?FONT[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?STRONG[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?P[^>]*><\/P>/g,"");
 wordContent = String(wordContent).replace(/<\/?H1[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H2[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H3[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H4[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H5[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H6[^>]*>/g,"");

 return(wordContent);

}

 

RSS feed
Search and Links
Bling

View Nik Kalyani's profile on LinkedIn

TechBubble
www.flickr.com
This is a Flickr badge showing public photos from techbubble. Make your own badge here.
Statistics
Total Posts: 216
This Year: 19
This Month: 0
This Week: 0
Comments: 226
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008
Nik Kalyani
Sign In
All Content © 2008, Nik Kalyani