<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Many Interests BLOG &#187; javascript</title>
	<atom:link href="http://blog.darsain.net/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.darsain.net</link>
	<description>Too many things, too little time</description>
	<lastBuildDate>Sat, 03 Jul 2010 14:47:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>I hate you!</title>
		<link>http://blog.darsain.net/81/i-hate-you-2/</link>
		<comments>http://blog.darsain.net/81/i-hate-you-2/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 22:01:39 +0000</pubDate>
		<dc:creator>Darsain</dc:creator>
				<category><![CDATA[Interwebz]]></category>
		<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[advertisement]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.darsain.net/?p=81</guid>
		<description><![CDATA[As I&#8217;m browsing through the interwebz, I&#8217;m too often stumbling upon an annoying, or just cheeky things on various websites. Many of them are completely useless, and websites without them would be much more user friendly, and nicer place. So here is some list I&#8217;ve put together. Enjoy, and try to avoid that in future [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;m browsing through the interwebz, I&#8217;m too often stumbling upon an annoying, or just cheeky things on various websites. Many of them are completely useless, and websites without them would be much more user friendly, and nicer place. So here is some list I&#8217;ve put together. Enjoy, and try to avoid that in future :)</p>
<p><span id="more-81"></span></p>
<h1>Valid XHTML/HTML/CSS/LOLCAT/&#8230; badges</h1>
<p>You know what I&#8217;m talking about:<br />
<img src="http://blog.darsain.net/wp-content/uploads/2010/01/validation-badges.jpg" alt="" title="validation-badges" width="443" height="96" class="aligncenter size-full wp-image-82" /></p>
<p>Your visitors either don&#8217;t know what it is, they do not care, or &#8211; in my case &#8211; they are laughing for a first few years, and than it is just silly.<br />
It really was laughable to want a valid web from webdevelopers in time, where the most widely used browser was not supporting the web standards.<br />
And now, there is not much meaning in it either. 100% result in W3C validator does not mean the right usage of web standards. It does not mean, that your website will render exactly how you want, or even that it&#8217;ll render in every browser the same.<br />
For example, I can have a website with nice, clean code, working and looking exactly how I want in every major browser, with error-free JavaScript, but:</p>
<ul>
<li><b>I&#8217;ve used a custom HTML tag attribute for better comfort in JavaScript (as &#8220;data-&#8221; attribute is not supported yet):</b> BAM! Code is not valid.</li>
<li><b>I&#8217;ve declared a CSS opacity value, which is working in almost every browser by now, but it is not officially &#8220;out&#8221; yet:</b> BAM! Code is not valid.</li>
<li>etcetera&#8230;</li>
</ul>
<p>Validation badges are used only for e-penis enlargement, or ripping off the customers for &#8220;additional services&#8221; &#8211; yes, I&#8217;ve seen a webdesigners, that are persuading their clients that they NEEED that badge, so they can charge more.</p>
<p>And of course, they look awful, and they do not fit anywhere :)</p>
<h1>Horizontal scrollbars</h1>
<p>I have a 1920 pixels wide screen resolution. If I see a horizontal scrollbar, I get annoyed.</p>
<ul>
<li>badly coded JavaScript horizontal sliders</li>
<li>designers that think that horizontally based pages are cool (seriously, <a href="http://www.thehorizontalway.com/">this is not what &#8220;accessibility&#8221; means</a>)</li>
<li>bad cascading styles</li>
</ul>
<p>These are just few of the problems that causes this issue.</p>
<h1>Advertisements</h1>
<p>Oh, how much i hate them&#8230; ALL of them. There is not one ad on my personal webpages, and I&#8217;ll do whatever I could to preserve it that way. I hate when I have to scroll through 2 pages of ads to get to the content. I hate when blinking ads are trying to kill me with epileptic seizure. I hate when flash ads are moving, sliding, popping, animating, and stealing my focus from things that I want really read, or watch. I hate when flash ads are removing my cursor from screen.</p>
<p>In spite of my hatred against ads, I understand the business model based on them. So, people, if you like some website, you are grateful for services provided by it, click on the ads there. It doesn&#8217;t cost you anything, website will get some money, and the best part is: those bastards that created that awful blinking ads will pay for it :)</p>
<h1>Flash abbusing</h1>
<p>Already mentioned ads, flash menus, flash buttons, or other unnecessary flash components. Most of what I&#8217;m seeing in flash could be done with few lines of JavaScript. Things in flash are often not much accessible for users (copy&#038;paste of text), and I just hate when I have to click before activating flash controls. Not mentioning overlapping HTML elements, or whole flash blocks disappearing when coder is trying to prevent overlapping.</p>
<p>Yes, I&#8217;m not a huge fan of flash, but I&#8217;m not totally against it. I&#8217;m just marked by webdevelopers, that are doing Flash components on their website only because they know Flash, not because Flash is the good choice, and that is just fundamentally bad behavior. On the other hand, whole interactive websites completely done in flash are often looking really good (checkout <a href="http://www.thefwa.com/">this great list of awesome flash sites</a>), but such approach can not be used for other than purely presentational purposes (like main pages of movies, etc).<br />
Flash video players are another example of the right choice for Flash (even though SilverLight is better, presence of Flash plugin is more common).</p>
<h1>JavaScript abusing</h1>
<p>There are MANY ways how JavaScript is abused. For example:</p>
<ul>
<li>words replaced for advertisement links that pops up advert bubble on hover event</li>
<li>links that will show you the thumbnail of page they are referring to if you will hover them (what is the point of that!?)</li>
<li>share &#8220;supper&#8221; buttons</li>
<li>etcetera&#8230;</li>
</ul>
<p>These things are truly the plague of the websites. </p>
<h1>Java applets</h1>
<p>Seriously, websites are not the place for Java. Nuff said.</p>
<h1>Donate spam</h1>
<p>In every WordPress plugin, under every article post, on every tutorial demo presentation, there is some PayPal icon. Please, choose one place on your website, and leave it there. Make the user interface of your apps clean, and do not spam with that everywhere.</p>
<h1>Web 2.0 bullshit talk</h1>
<p>I can&#8217;t explain it better than <a href="http://www.andybudd.com/">Andy Budd</a> and <a href="http://adactio.com/">Jeremy Keith</a> on their <a href="http://www.viddler.com/explore/sandieman/videos/112/">How to Bluff Your Way In Web 2.0 presentation</a>. Must see!!</p>
<p><a href="http://blog.darsain.net/81/i-hate-you-2/"><em>Click here to view the embedded video.</em></a></p>
<h1>Register or GTFO</h1>
<p>You had to encounter that. Website is offering you some download, presentation, or tutorial, but only if you&#8217;ll register there. No fees, or other requirements, just register&#8230;&#8230;. <strong>WHY?!</strong> Why the holy fuck are you bothering people with registration, if you are offering that for free? Why do you need that useless account?</p>
<p>FireFox users, there is a big helper for you against fuckers like this. It is called the <a href="https://addons.mozilla.org/en-US/firefox/addon/6349">BugMeNot plugin</a>, and it&#8217;ll log you in on every website that is requiring useless registration.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.darsain.net/81/i-hate-you-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple animated toggle with jQuery</title>
		<link>http://blog.darsain.net/38/simple-animated-toggle-with-jquery/</link>
		<comments>http://blog.darsain.net/38/simple-animated-toggle-with-jquery/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 20:11:00 +0000</pubDate>
		<dc:creator>Darsain</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[animated toggle]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.darsain.net/?p=38</guid>
		<description><![CDATA[We all know about jQuery. Powerful and very popular JavaScript framework with many useful and great plugins. But the variety of plugins has created one bad behavior among webdevelopers. When they need to create some effect, or function, they are often looking for solution in plugins, instead of trying to do that on their own. [...]]]></description>
			<content:encoded><![CDATA[<p>We all know about jQuery. Powerful and very popular JavaScript framework with many useful and great plugins. But the variety of plugins has created one bad behavior among webdevelopers. When they need to create some effect, or function, they are often looking for solution in plugins, instead of trying to do that on their own. This simple search for simplified coding is creating mess in code, and forcing you to compromises in your layout, styling, or even website design. In this tutorial, we will create few lines of code, that can replace very popular plugin called Animated Collapsible DIV, or most of the plugins creating tabs.</p>
<p><span id="more-38"></span></p>
<a href="http://blog.darsain.net/?file_id=1" class="download-item">
  <img src="http://blog.darsain.net/wp-content/plugins/downloads-manager/img/icons/external.png" alt="icon">
  <h3>Demo presentation</h3>
  <span></span> <span>474x</span>
</a> <a href="http://blog.darsain.net/?file_id=2" class="download-item">
  <img src="http://blog.darsain.net/wp-content/plugins/downloads-manager/img/icons/archive.png" alt="icon">
  <h3>Tutorial files</h3>
  <span>24.93KB</span> <span>247x</span>
</a>
<p>First, we need to decide, how the animation will be triggered, and by what object. I&#8217;ve choose the solution of creating your own attributes (yeah, now you can&#8217;t masturbate over 100% W3C validation result you hypocritical bastard ;)), so the triggering object can be almost any tag. Animation will start after click on any object with my custom attribute &#8220;toggle&#8221;, and animated will be object with id equals toggle value. The whole HTML will look like this:</p>
<pre class="brush: xml;">
&lt;a href=&quot;#&quot; toggle=&quot;myObject&quot;&gt;Click me&lt;/a&gt;

&lt;div id=&quot;myObject&quot;&gt;
content ...
&lt;/div&gt;
</pre>
<p>Easy, huh? And as I already wrote, you can add this custom attribute to any object, like this:</p>
<pre class="brush: xml;">
&lt;a href=&quot;#&quot; toggle=&quot;myObject&quot;&gt;Click me&lt;/a&gt;
&lt;div toggle=&quot;myObject&quot;&gt;Click me&lt;/div&gt;
&lt;span toggle=&quot;myObject&quot;&gt;Click me&lt;/span&gt;
&lt;h1 toggle=&quot;myObject&quot;&gt;Click me&lt;/h1&gt;

&lt;div id=&quot;myObject&quot;&gt;
content ...
&lt;/div&gt;
</pre>
<p>All objects with attribute &#8220;toggle&#8221;, which is addressing to triggered object ID, are live buttons now.</p>
<p><strong><em>&#8220;But, what if I need to show one object, but close few others with some group, or something?&#8221;</em></strong></p>
<p>Nothing can be easier. We can add to targeted object another custom attribute called &#8220;group&#8221;, and give it the name of group as a value, so all the objects with this group will slide up, when another object is sliding down. Here is the HTML:</p>
<pre class="brush: xml;">
&lt;a href=&quot;#&quot; toggle=&quot;bread1&quot;&gt;I want some bread&lt;/a&gt;

&lt;div id=&quot;bread&quot; group=&quot;breakfast&quot;&gt;
content ...
&lt;/div&gt;

&lt;a href=&quot;#&quot; toggle=&quot;bread2&quot;&gt;What about milk?&lt;/a&gt;

&lt;div id=&quot;milk&quot; group=&quot;breakfast&quot;&gt;
content ...
&lt;/div&gt;
</pre>
<p>So, now, when we know how we want this to work, we can jump to creating our jQuery snippet.<br />
We need to trigger the click() function, when any object with the attribute &#8220;toggle&#8221; is clicked.</p>
<pre class="brush: jscript;">
$(&quot;[toggle]&quot;).click( function() {

});
</pre>
<p>Now, we need to define some variables to work with. Read the descriptions next to them.</p>
<pre class="brush: jscript;">
$(&quot;[toggle]&quot;).click( function() {

  var targetObjId = $(this).attr(&quot;toggle&quot;); // get the ID of targeted object from &quot;toggle&quot; attribute value
  var targetObj = $(&quot;[id=&quot;+targetObjId+&quot;]&quot;); // find and target the needed object into variable
  var targetObjGroup = $(targetObj).attr(&quot;group&quot;); // check, if tehre is any group reference on targeted object

});
</pre>
<p>We have our variables, so lets do some magic and finish the snippet. Again, read the comments in code.</p>
<pre class="brush: jscript;">
$(&quot;[toggle]&quot;).click( function() {

  var targetObjId = $(this).attr(&quot;toggle&quot;);
  var targetObj = $(&quot;[id=&quot;+targetObjId+&quot;]&quot;);
  var targetObjGroup = $(targetObj).attr(&quot;group&quot;);

  if( targetObjGroup ) // if there is some reference to group, run this
  {
      $(&quot;[group=&quot;+targetObjGroup+&quot;]&quot;).not(targetObj).slideUp(); // slide up (hide) all objects with refered group, but not our targetObj
      $(targetObj).slideDown(); // slide down (animated show function) our targetObj
  }
  else // if  there is no reference for group, run this
  {
      if( $(targetObj).is(&quot;:hidden&quot;) ) $(targetObj).slideDown(); // if our targetObj is hidden, slide him down
      else $(targetObj).slideUp(); // in other case, slide him up
  }

  return false; // in case that triggering object is an &lt;a&gt; tag, we don't want to href=&quot;&quot; got executed by browser

});
</pre>
<p>And thats it. This 19 lines of code can simply replace the whole Animated Collapsible DIV plugin. Interesting huh?</p>
<p>But this is not over yet :) In case, that you want to use this snippet as a tabs switcher, you have to do some changes, but you want to leave this snipped like it is, so simply copy paste it, and change the attribute to &#8220;showtab&#8221;. Here is the new snipped, with highlighted lines and explanations.</p>
<pre class="brush: jscript; highlight: [1,3,9,10,14,15];">
$(&quot;[showtab]&quot;).click( function() { // changed attribute

  var targetObjId = $(this).attr(&quot;showtab&quot;); // changed attribute
  var targetObj = $(&quot;[id=&quot;+targetObjId+&quot;]&quot;);
  var targetObjGroup = $(targetObj).attr(&quot;group&quot;);

  if( targetObjGroup )
  {
      $(&quot;[group=&quot;+targetObjGroup+&quot;]&quot;).not(targetObj).hide(); // in case of hiding tab, we don want to animate sliding, so it wouldn't mess with height of surrounding elements
      $(targetObj).fadeIn(); // fadeIn() animation is way better in tabs switching
  }
  else
  {
      if( $(targetObj).is(&quot;:hidden&quot;) ) $(targetObj).fadeIn(); // in case, that there is only one tab, just toggle it
      else $(targetObj).fadeOut();
  }

  return false;

});
</pre>
<p>If you need to change style of triggering button after click, just create a css class called &#8220;active&#8221; with needed changes, and toggle this class to button after if().</p>
<pre class="brush: jscript;">
$(&quot;[toggle]&quot;).click( function() {

  var targetObjId = $(this).attr(&quot;toggle&quot;);
  var targetObj = $(&quot;[id=&quot;+targetObjId+&quot;]&quot;);
  var targetObjGroup = $(targetObj).attr(&quot;group&quot;);

  if( targetObjGroup )
  { ... }
  else
  { ... }

  $(this).toggleclass('active'); // &lt;- thats what I'm talking about

  return false;

});
</pre>
<p>Or add this class with addclass(), and remove with removeclass() whenever in code you need.</p>
<p>I hope, that this tutorial will be useful for someone, and remember: Try to create some functions &#038; features yourself before finding the solution among plugins. That way, you will gain more experience, and know-hows.</p>
<p>As bonus, here are 2 simple snippets for &#8220;show&#8221; and &#8220;hide&#8221; attributes, for better understanding.</p>
<pre class="brush: jscript;">
$(&quot;[show]&quot;).click( function() {

  var targetObjId = $(this).attr(&quot;show&quot;);
  var targetObj = $(&quot;[id=&quot;+targetObjId+&quot;]&quot;);

  $(targetObj).slideDown();

});

$(&quot;[hide]&quot;).click( function() {

  var targetObjId = $(this).attr(&quot;hide&quot;);
  var targetObj = $(&quot;[id=&quot;+targetObjId+&quot;]&quot;);

  $(targetObj).slideUp();

});
</pre>
<p>If you have any questions, do not hesitate to ask. Comments are always welcome.</p>
<a href="http://blog.darsain.net/?file_id=1" class="download-item">
  <img src="http://blog.darsain.net/wp-content/plugins/downloads-manager/img/icons/external.png" alt="icon">
  <h3>Demo presentation</h3>
  <span></span> <span>474x</span>
</a> <a href="http://blog.darsain.net/?file_id=2" class="download-item">
  <img src="http://blog.darsain.net/wp-content/plugins/downloads-manager/img/icons/archive.png" alt="icon">
  <h3>Tutorial files</h3>
  <span>24.93KB</span> <span>247x</span>
</a>
]]></content:encoded>
			<wfw:commentRss>http://blog.darsain.net/38/simple-animated-toggle-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
