Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘quot quot’

TODO Comments in Visual Studio

Using TODO

imageTODO comments allow you to tell Visual Studio to maintain a central list of tasks, which it reads from many different places in your code. The Task List is a panel or floating window in Visual Studio that will display all the TODO comments in your project. To open the list, go to View menu -> Task List.

Some example TODO comments

You probably have a lot of code that needs a lot of work. If you don’t, then you need to write code that needs a lot of work. Here are some examples of TODO lines that Visual Studio 2008 will notice and put into its special Task Pane.

//todo: your task 1
//TODO: your task 2
// Todo your task 3

Description of example. This will appear in your tasks pane as a separate task. Note that you have some flexibility with these tokens. The strings "todo", "TODO", and "TODO" all work equally well—Visual Studio’s parser gives you a little bit of freedom.

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

jQuery hoverImage plugin

   1: (function($) {

   2:     $.fn.extend({

   3:         hoverImage: function(options) {

   4:             var defaults = { src: "-hover", preload: true, replaceEnd: "" };

   5:             options = $.extend(defaults, options);

   6:  

   7:             var append = options.src.indexOf(".") == -1;

   8:  

   9:             var splitter;

  10:             if (append) {

  11:                 splitter = options.replaceEnd + ".";

  12:             }

  13:  

  14:             return this.each(function() {

  15:                 var obj = $(this);

  16:                 var img = obj.is("[src]") ? obj : obj.children("[src]:first").eq(0);

  17:  

  18:                 if (!img.is("[src]")) {

  19:                     return true;

  20:                 }

  21:  

  22:                 var oSrc = img.attr("src");

  23:                 img.data("oSrc", oSrc);

  24:  

  25:                 var hSrc = options.src;

  26:                 if (append) {

  27:                     hSrc = oSrc.split(splitter).join(hSrc + ".");

  28:                 }

  29:                 

  30:                 img.data("hSrc", hSrc);

  31:  

  32:                 if (options.preload) {

  33:                     new Image().src = hSrc;

  34:                 }

  35:  

  36:                 obj.hover(function() { img.attr("src", img.data("hSrc")); },

  37:                           function() { img.attr("src", img.data("oSrc")); });

  38:             });

  39:         }

  40:     });

  41: })(jQuery);

Here’s a sample of html in which the plug-in is used.

   1: <html xmlns="http://www.w3.org/1999/xhtml">

   2: <head runat="server">

   3:     <title>hoverImage test page</title>

   4:     <script src="/ClientScript/jquery-1.3.2.min.js" type="text/javascript"></script>
   1:  

   2:     <script src="/ClientScript/jquery.hoverImage.js" type="text/javascript">

   1: </script>

   2:  

   3:     <script type="text/javascript">

   4:         $(function() {

   5:             $(".standardImage").hoverImage({replaceEnd: "-standard"});

   6:             $(".hoverImage").hoverImage();

   7:         });

   8:     

</script>

   5: </head>

   6: <body>

   7:     <form id="form1" runat="server">

   8:     <div>

   9:         <img class="standardImage" src="Imgs/button-standard.gif" />

  10:         <img class="hoverImage" src="Imgs/button.gif" />

  11:         <a class="hoverImage" href="#" style="display:block; width:100%;border:solid 1px black;">

  12:             <img src="Imgs/button.gif" />

  13:         </a>

  14:     </div>

  15:     </form>

  16: </body>

  17: </html>

Happy 2010~~

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark