Update :: Jquery Toolpik Revision 1 - Dewa Blogger

Halaman

    Social Items

Buy Now
 because I realize that there are some fatal mistakes about HTML manipulation when mouseou UPDATE :: jQuery Toolpik Revision 1

I decided to update this Toolpik because I realize that there are some fatal mistakes about HTML manipulation when mouseout and things that I think still can be shortened. In addition, a duduk kasus which in my opinion (and all of us) the most annoying is that Toolpik not have the ability to keep itself stay on the visible area:

 because I realize that there are some fatal mistakes about HTML manipulation when mouseou UPDATE :: jQuery Toolpik Revision 1
ARRGGHHH!!!

And moreover, the acronym tag is already deprecated and was replaced by abbr (Read: Avoid the Deprecated <acronym> Tag in HTML 5). But, if you want to continue include Toolpik for the acronym tag, just add it beside the abbr with separate comma:

var ttTarget = "abbr, acronym";

I don't know who is the author on this discussion, but gratitude to him for all of his knowledge. This is how I keep Toolpik stay on the visible area:

// Get the toolpik width and height var toolpikWidth  = $("#toolpik").outerWidth(),     toolpikHeight = $("#toolpik").outerHeight(),      // Get the window width and height     winWidth      = $(window).width(),     winHeight     = $(window).height(),      top           = e.clientY - toolpikHeight/2, // Set top and bottom position of the toolpik     left          = e.clientX - toolpikWidth/2;  // Set the left and right position of the toolpik  if (top + toolpikHeight > winHeight) {     // Flip the toolpik position to the top of the object     // so it won't go out of the current window height     // and show up in the correct place     top = winHeight - toolpikHeight - 50; } else if (top <= 0) {     top = 10; } else {     top = top; }  if (left + toolpikWidth > winWidth) {     // Shift the toolpik position to the left of the object     // so it won't go out of width of current window width     // and show up in the correct place     left = winWidth - toolpikWidth - 50; } else if (left <= 0) {     left = 10; } else {     left = left; }

Complete Code

$(function() {      $(ttTarget).css('cursor', 'help').hover(function(e) {          $(this).append('<div id="toolpik"><div id="nurrohman"></div><div style="clear:both;"></div><img class="absol" src="' + ttImg + '" alt=" because I realize that there are some fatal mistakes about HTML manipulation when mouseou UPDATE :: jQuery Toolpik Revision 1" /></div>');         $('#nurrohman', '#toolpik').html($(this).attr('title'));         $(this).removeAttr('title');          // Get the toolpik width and height         var toolpikWidth  = $("#toolpik").outerWidth(),             toolpikHeight = $("#toolpik").outerHeight(),              // Get the window width and height             winWidth      = $(window).width(),             winHeight     = $(window).height(),              top           = e.clientY - toolpikHeight/2, // Set top and bottom position of the toolpik             left          = e.clientX - toolpikWidth/2;  // Set the left and right position of the toolpik          if (top + toolpikHeight > winHeight) {             // Flip the toolpik position to the top of the object             // so it won't go out of the current window height             // and show up in the correct place             top = winHeight - toolpikHeight - 50;         } else if (top <= 0) {             top = 10;         } else {             top = top;         }          if (left + toolpikWidth > winWidth) {             // Shift the toolpik position to the left of the object             // so it won't go out of width of current window width             // and show up in the correct place              left = winWidth - toolpikWidth - 50;         } else if (left <= 0) {             left = 10;         } else {             left = left;         }          // Last: Show and set the position of the toolpik with animation         $('#toolpik')             .delay(600)             .fadeIn(1000, movement);              function movement() {                 $(this)                 .delay(600)                 .animate({                     top:top-70,                     left:left                 }, {                     duration:2000,                     easing:"easeOutBack"                 })                 .animate({top:top}, 400);             };      }, function() {         // Put back the title attribute's value         $(this).attr('title', $('#nurrohman', '#toolpik').html());         // Remove the appended toolpik         $('#nurrohman').parent().remove();     });   });

View Demo Download Files

Usage

Install the toolpik-styler.css, jQuery library and jQuery Easing 1.3, then add the Toolpik scripts above the </head>:

<link rel='stylesheet' href='css/toolpik-styler.css'></link> <script src='js/jquery-1.7.1.min.js'></script> <script src='js/jquery-easing-1.3.pack.js'></script> <script src='js/toolpik.js'></script> <script>     var ttImg    = "ikon1.png"; // REPLACE THIS ICON WITH YOUR OWN     var ttTarget = "abbr, acronym"; </script>

Activation

Toolpik will find the value of title attribute and convert it to text or HTML element inside Toolpik. Simply wrap the text that you want with <abbr> tag and add the title attribute with the specified value and it will be a description in Toolpik:

Lorem ipsum <abbr title="UPDATE :: jQuery Toolpik Revision 1">I have a Toolpik</abbr>. Dolor sit amet-amet jabang bayi oek-oek.

However, if you are not familiar using <abbr> as a marker, you can use another tags such as <a>. To enable <a> as Toolpik, replace the variable var ttTarget = "abbr, acronym"; to var ttTarget = "a[title]";

You can also insert HTML code into the title attribute to get various content. For safety reasons, just make sure that if you use double quotation symbol on the title attribute, you must use single quotes in tag attributes inside. And for more secure, parse all the code < with &lt; and > with &gt;

Lorem ipsum <abbr title="UPDATE :: jQuery Toolpik Revision 1">I have a Toolpik</abbr>. Dolor sit amet-amet jabang bayi oek-oek.

Or...

Lorem ipsum <abbr title="UPDATE :: jQuery Toolpik Revision 1">I have a Toolpik</abbr>. Dolor sit amet-amet jabang bayi oek-oek.

Sumber https://www.dte.web.id/

Update :: Jquery Toolpik Revision 1

 because I realize that there are some fatal mistakes about HTML manipulation when mouseou UPDATE :: jQuery Toolpik Revision 1

I decided to update this Toolpik because I realize that there are some fatal mistakes about HTML manipulation when mouseout and things that I think still can be shortened. In addition, a duduk kasus which in my opinion (and all of us) the most annoying is that Toolpik not have the ability to keep itself stay on the visible area:

 because I realize that there are some fatal mistakes about HTML manipulation when mouseou UPDATE :: jQuery Toolpik Revision 1
ARRGGHHH!!!

And moreover, the acronym tag is already deprecated and was replaced by abbr (Read: Avoid the Deprecated <acronym> Tag in HTML 5). But, if you want to continue include Toolpik for the acronym tag, just add it beside the abbr with separate comma:

var ttTarget = "abbr, acronym";

I don't know who is the author on this discussion, but gratitude to him for all of his knowledge. This is how I keep Toolpik stay on the visible area:

// Get the toolpik width and height var toolpikWidth  = $("#toolpik").outerWidth(),     toolpikHeight = $("#toolpik").outerHeight(),      // Get the window width and height     winWidth      = $(window).width(),     winHeight     = $(window).height(),      top           = e.clientY - toolpikHeight/2, // Set top and bottom position of the toolpik     left          = e.clientX - toolpikWidth/2;  // Set the left and right position of the toolpik  if (top + toolpikHeight > winHeight) {     // Flip the toolpik position to the top of the object     // so it won't go out of the current window height     // and show up in the correct place     top = winHeight - toolpikHeight - 50; } else if (top <= 0) {     top = 10; } else {     top = top; }  if (left + toolpikWidth > winWidth) {     // Shift the toolpik position to the left of the object     // so it won't go out of width of current window width     // and show up in the correct place     left = winWidth - toolpikWidth - 50; } else if (left <= 0) {     left = 10; } else {     left = left; }

Complete Code

$(function() {      $(ttTarget).css('cursor', 'help').hover(function(e) {          $(this).append('<div id="toolpik"><div id="nurrohman"></div><div style="clear:both;"></div><img class="absol" src="' + ttImg + '" alt=" because I realize that there are some fatal mistakes about HTML manipulation when mouseou UPDATE :: jQuery Toolpik Revision 1" /></div>');         $('#nurrohman', '#toolpik').html($(this).attr('title'));         $(this).removeAttr('title');          // Get the toolpik width and height         var toolpikWidth  = $("#toolpik").outerWidth(),             toolpikHeight = $("#toolpik").outerHeight(),              // Get the window width and height             winWidth      = $(window).width(),             winHeight     = $(window).height(),              top           = e.clientY - toolpikHeight/2, // Set top and bottom position of the toolpik             left          = e.clientX - toolpikWidth/2;  // Set the left and right position of the toolpik          if (top + toolpikHeight > winHeight) {             // Flip the toolpik position to the top of the object             // so it won't go out of the current window height             // and show up in the correct place             top = winHeight - toolpikHeight - 50;         } else if (top <= 0) {             top = 10;         } else {             top = top;         }          if (left + toolpikWidth > winWidth) {             // Shift the toolpik position to the left of the object             // so it won't go out of width of current window width             // and show up in the correct place              left = winWidth - toolpikWidth - 50;         } else if (left <= 0) {             left = 10;         } else {             left = left;         }          // Last: Show and set the position of the toolpik with animation         $('#toolpik')             .delay(600)             .fadeIn(1000, movement);              function movement() {                 $(this)                 .delay(600)                 .animate({                     top:top-70,                     left:left                 }, {                     duration:2000,                     easing:"easeOutBack"                 })                 .animate({top:top}, 400);             };      }, function() {         // Put back the title attribute's value         $(this).attr('title', $('#nurrohman', '#toolpik').html());         // Remove the appended toolpik         $('#nurrohman').parent().remove();     });   });

View Demo Download Files

Usage

Install the toolpik-styler.css, jQuery library and jQuery Easing 1.3, then add the Toolpik scripts above the </head>:

<link rel='stylesheet' href='css/toolpik-styler.css'></link> <script src='js/jquery-1.7.1.min.js'></script> <script src='js/jquery-easing-1.3.pack.js'></script> <script src='js/toolpik.js'></script> <script>     var ttImg    = "ikon1.png"; // REPLACE THIS ICON WITH YOUR OWN     var ttTarget = "abbr, acronym"; </script>

Activation

Toolpik will find the value of title attribute and convert it to text or HTML element inside Toolpik. Simply wrap the text that you want with <abbr> tag and add the title attribute with the specified value and it will be a description in Toolpik:

Lorem ipsum <abbr title="UPDATE :: jQuery Toolpik Revision 1">I have a Toolpik</abbr>. Dolor sit amet-amet jabang bayi oek-oek.

However, if you are not familiar using <abbr> as a marker, you can use another tags such as <a>. To enable <a> as Toolpik, replace the variable var ttTarget = "abbr, acronym"; to var ttTarget = "a[title]";

You can also insert HTML code into the title attribute to get various content. For safety reasons, just make sure that if you use double quotation symbol on the title attribute, you must use single quotes in tag attributes inside. And for more secure, parse all the code < with &lt; and > with &gt;

Lorem ipsum <abbr title="UPDATE :: jQuery Toolpik Revision 1">I have a Toolpik</abbr>. Dolor sit amet-amet jabang bayi oek-oek.

Or...

Lorem ipsum <abbr title="UPDATE :: jQuery Toolpik Revision 1">I have a Toolpik</abbr>. Dolor sit amet-amet jabang bayi oek-oek.

Sumber https://www.dte.web.id/