you are in: codestackercodes [RSS] → tag: html [RSS]

back to top Delicious Email

show/hide lines
   1  <a href="#top" onclick="$('html, body').animate({scrollTop:0}, 'slow'); return false;">top</a>
created by leozera — 22 August 2009 — get a short url — tags: html javascript jquery embed

jquery twitter Delicious Email

http://ralphwhitbeck.com/content/binary/twitter-json-jquery.html

show/hide lines
   1  <html>
   2  <head>
   3  <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
   4  <script>
   5  	$(document).ready( function() {
   6  	
   7  		var url = "http://twitter.com/status/user_timeline/RedWolves.json?count=3&callback=?";
   8  		$.getJSON(url,
   9          function(data){
  10  			$.each(data, function(i, item) {
  11  				$("img#profile").attr("src", item.user["profile_image_url"]); 
  12  				$("#tweets ul").append("<li>" + item.text.linkify() + " <span class='created_at'>" + relative_time(item.created_at) + " via " + item.source + "</span></li>");
  13  			});
  14          });
  15  	});
  16  	
  17  	String.prototype.linkify = function() {
  18  		return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
  19      return m.link(m);
  20    });
  21   }; 
  22    function relative_time(time_value) {
  23  	  var values = time_value.split(" ");
  24  	  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
  25  	  var parsed_date = Date.parse(time_value);
  26  	  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
  27  	  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
  28  	  delta = delta + (relative_to.getTimezoneOffset() * 60);
  29  	  
  30  	  var r = '';
  31  	  if (delta < 60) {
  32  	    r = 'a minute ago';
  33  	  } else if(delta < 120) {
  34  	    r = 'couple of minutes ago';
  35  	  } else if(delta < (45*60)) {
  36  	    r = (parseInt(delta / 60)).toString() + ' minutes ago';
  37  	  } else if(delta < (90*60)) {
  38  	    r = 'an hour ago';
  39  	  } else if(delta < (24*60*60)) {
  40  	    r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
  41  	  } else if(delta < (48*60*60)) {
  42  	    r = '1 day ago';
  43  	  } else {
  44  	    r = (parseInt(delta / 86400)).toString() + ' days ago';
  45  	  }
  46  	  
  47  	  return r;
  48  }
  49  function twitter_callback ()
  50  {
  51  	return true;
  52  }
  53  
  54  </script>	
  55  </head>
  56  <body>
  57  	<div id="tweets">
  58  		<img id="profile">
  59  		<ul></ul>
  60  	</div>
  61  </body>
  62  </html>
created by leozera — 10 May 2009 — get a short url — tags: javascript jquery twitter embed

cool newsticker using jquery Delicious Email

from http://benjaminsterling.com/blog-news-ticker/

show/hide lines
   1  <html>
   2  	<head>
   3          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   4          <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
   5          <script type="text/javascript">
   6  			var height = 0;
   7  			var to = null;
   8  			var theAnimation;
   9  			var newsScroller;
  10  			$(document)
  11  			.ready(function(){
  12  				newsScroller = $('#newsScroller');
  13  				
  14  				var curSet = newsScroller
  15  				.prev()
  16  					.addClass('ns')
  17  				.end()
  18  				.wrap('<div>')
  19  				.parent()
  20  					.addClass('ns')
  21  				.end()
  22  				.wrap('<div>')
  23  				.children()
  24  				.slice(0,4)
  25  				.each(function(){
  26  					height += $(this).outerHeight(true);
  27  				});
  28  				
  29  				theAnimation = function(){
  30  					if( !newsScroller.is(':animated') ){
  31  						newsScroller.animate({top:-height},1000,function(){
  32  							height = 0;
  33  							curSet = newsScroller
  34  							.append(curSet)
  35  							.css('top',0)
  36  							.children()
  37  							.slice(0,4)
  38  							.each(function(){
  39  								height += $(this).outerHeight(true);
  40  							});
  41  						});
  42  					}
  43  				};
  44  				
  45  				to = setInterval(theAnimation,4000);
  46  				
  47  				newsScroller.bind('mouseenter',function(){
  48  					clearInterval(to);
  49  				})
  50  				.bind('mouseleave',function(){
  51  					theAnimation();
  52  					to = setInterval(theAnimation,4000);
  53  				});
  54  			});
  55  		</script>
  56          <style media="screen, projector">
  57  			h3#newsScrollerTitle{
  58  				margin:0;
  59  				padding:0;
  60  				font:bold 14px/1.2 Georgia, "Times New Roman", Times, serif;
  61  			}
  62  			dl#newsScroller{
  63  				font:normal 11px/1.4 Arial, Helvetica, sans-serif;
  64  				padding:0;
  65  				margin:0;
  66  			}
  67  			dl#newsScroller dt{
  68  				font-weight:bold;
  69  			}
  70  			dl#newsScroller dd{
  71  				padding:0 0 0 11px;
  72  				margin:0;
  73  			}
  74  			dl#newsScroller dd p{
  75  				padding:0;
  76  				margin:0 0 11px 0;
  77  			}
  78  			dl#newsScroller dd + dd{
  79  				padding:0 0 0 22px;
  80  			}
  81  			
  82  			h3#newsScrollerTitle.ns{
  83  				padding:5px 11px;
  84  				border:1px solid #B18C58;
  85  				border-bottom:none;
  86  				background:#beb677;
  87  				width:278px;
  88  			}
  89  			div.ns{
  90  				padding:11px;
  91  				border:1px solid #B18C58;
  92  				border-top:none;
  93  				background:#E8E4B4;
  94  				width:278px;
  95  				height:300px;
  96  				position:relative;
  97  				overflow:hidden;
  98  			}
  99  			div.ns div{
 100  				height:300px;
 101  				overflow:hidden;
 102  			}
 103  			div.ns dl{
 104  				position:relative;
 105  				top:0;
 106  			}
 107  			div.ns dl dt,
 108  			div.ns dl dd{
 109  				position:relative;
 110  			}
 111  		</style>
 112      </head>
 113      
 114      <body>
 115      	<h3 id="newsScrollerTitle">Our News</h3>
 116      	<dl id="newsScroller">
 117          	<dt>Web Tech November Meetup Presentation</dt>
 118              <dd>
 119                  <p>Last night I had the opportunity to speak at the Web Tech 
 120                  November Meetup in Baltimore about jQuery.  I focused mainly 
 121                  on traversing since I believe once you fully grasp some of 
 122                  the built in jQuery traversing methods you can do just about 
 123                  anything using jQuery and do it easily.</p>
 124                  <p>Preparations<br/>
 125                  I spent about three weeks getting [...]</p>
 126  			</dd>
 127              <dd>Tuesday, November 25th, 2008</dd>
 128              <dd>Posted in Presentations, Web Development, jQuery | Edit | No Comments »</dd>
 129              
 130          	<dt>Slide in tab window using jQuery</dt>
 131              <dd>
 132                  <p>Say you want to wanted to put little tabs - you know, the 
 133                  ones like what you get from a lawyer or a realestate again to
 134                  point out important things - off the side of your page so that
 135                  your users can click, bring that tab into view to see what 
 136                  important information you want [...]</p>
 137              </dd>
 138              <dd>Thursday, November 20th, 2008</dd>
 139              <dd>Posted in Tips, Tutorials, Web Development, jQuery | Edit | 5 Comments »</dd>
 140              
 141          	<dt>Better jQuery Code #2</dt>
 142              <dd>
 143                  <p>In a follow up to my Better jQuery Code #1 post I will be
 144                  writing about some other small items that I have found to make
 145                  my code better and more readable.</p>
 146                  <p>Chaining<br/>
 147                  Chaining is one of the most beautiful and time save pieces of 
 148                  code structure that jQuery brought to the game, the problem is
 149                  is [...]   </p>         
 150              </dd>
 151              <dd>Sunday, November 16th, 2008</dd>
 152              <dd>Posted in Tips, Web Development, jQuery | Edit | 2 Comments »</dd>
 153              
 154          	<dt>Better jQuery Code #1</dt>
 155              <dd>
 156                  <p>I've been wanting to write some jQuery tips for a while now 
 157                  and just never know what to really say until I saw Marc 
 158                  Grabanski's 5 Tips for Better jQuery Code.  Although I have 
 159                  tips, I don't think I have any that are Earth shattering or ones
 160                  that I can rank higher then the other, [...]</p>            
 161              </dd>
 162              <dd>Saturday, November 15th, 2008</dd>
 163              <dd>Posted in Tips, Web Development, jQuery | Edit | 8 Comments »</dd>
 164              
 165          	<dt>Release of jQuery UI v1.5</dt>
 166              <dd>
 167                  <p>Well ladies and gents, it is finally here! Mark June 9th, 2008
 168                  as the day the web got better, jQuery's long awaited release of 
 169                  it's UI library update is here. Flushed with many bug fixes, a bunch
 170                  of really good examples, many new features and a theme builder.</p>
 171                  When jQuery UI first came out [...]            
 172              </dd>
 173              <dd>Monday, June 9th, 2008</dd>
 174              <dd>Posted in jQuery | Edit | 2 Comments »</dd>
 175          </dl>
 176      </body>
 177  </html>
created by leozera — 20 April 2009 — get a short url — tags: jquery embed

jquery mouseover/mouseout effect in link Delicious Email

show/hide lines
   1  <script src="http://code.jquery.com/jquery-latest.js"></script>
   2  <script src="http://ui.jquery.com/latest/ui/effects.core.js"></script>
   3  <script type="text/javascript">
   4  $(document).ready( function() {		
   5  	$(".link").mouseover(function() {
   6  		$(this).animate({ color: "#022d3f" }, 1000);
   7  	}).mouseout(function() {
   8  		$(this).animate({ color: "#ccc" }, 1000);
   9  	}) 
  10  </script>
created by leozera — 17 April 2009 — get a short url — tags: jquery javascript embed

CSS Horizontal And Vertical Align JQuery Plugin Delicious Email

from: http://www.nealgrosskopf.com/tech/thread.asp?pid=37

show/hide lines
   1  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
   2  <html>
   3  <head>
   4  <title>Demo</title>
   5  
   6  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   7  
   8  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
   9  
  10  <script type="text/javascript">
  11  (function ($) {
  12  $.fn.vAlign = function() {
  13  	return this.each(function(i){
  14  	var h = $(this).height();
  15  	var oh = $(this).outerHeight();
  16  	var mt = (h + (oh - h)) / 2;	
  17  	$(this).css("margin-top", "-" + mt + "px");	
  18  	$(this).css("top", "50%");
  19  	$(this).css("position", "absolute");	
  20  	});	
  21  };
  22  })(jQuery);
  23  
  24  (function ($) {
  25  $.fn.hAlign = function() {
  26  	return this.each(function(i){
  27  	var w = $(this).width();
  28  	var ow = $(this).outerWidth();	
  29  	var ml = (w + (ow - w)) / 2;	
  30  	$(this).css("margin-left", "-" + ml + "px");
  31  	$(this).css("left", "50%");
  32  	$(this).css("position", "absolute");
  33  	});
  34  };
  35  })(jQuery);
  36  
  37  $(document).ready(function() {
  38  	$("#content").vAlign();
  39  	$("#content").hAlign();
  40  });
  41  </script>
  42  
  43  <style type="text/css">
  44  html { background: #fafafa; }
  45  
  46  #content
  47  {
  48  background: #fff;
  49  border: 10px solid #eee;
  50  padding: 20px;
  51  color: #666;
  52  font-family: Arial, Helvetica, sans-serif;
  53  font-size: 12px;
  54  line-height: 25px;
  55  text-align: justify;
  56  }
  57  
  58  #content { width: 400px; }
  59  </style>
  60  
  61  </head>
  62  
  63  <body>
  64  
  65  <div id="content">
  66  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu dui eget nulla condimentum gravida. Vivamus erat leo, ultricies quis, gravida a, fringilla eu, urna. Pellentesque a mauris ac nisl semper egestas. Pellentesque ut elit in pede mattis gravida. Donec ac lectus a nisi suscipit placerat. Maecenas quis ipsum. Pellentesque mattis tellus. Suspendisse sollicitudin accumsan tortor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed metus. Quisque et leo at erat rutrum lobortis. In tempus lectus eget ligula convallis tristique. 
  67  </div>
  68  
  69  </body>
  70  </html>
created by leozera — 25 February 2009 — get a short url — tags: css javascript jquery vertical embed

jquery twitter plugin Delicious Email

from: http://www.tidbits.com.br/download/exemplos/jquery.twitter/jquery.twitter_original.zip

show/hide lines
   1  <script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
   2  <script type="text/javascript" src="jquery.twitter.js"></script>
   3  
   4  <script type="text/javascript">
   5  <!--//--><![CDATA[//><!--
   6  	$(document).ready(function() {
   7  		$("#twitter").getTwitter({
   8  			userName: "leozera",
   9  			numTweets: 5,
  10  			loaderText: "Loading tweets...",
  11  			slideIn: true,
  12  			showHeading: true,
  13  			headingText: "Latest Tweets",
  14  			showProfileLink: true
  15  		});
  16  	});
  17  //--><!]]>
  18  </script>
  19  
  20  <div id="twitter"></div>
  21  
created by leozera — 05 January 2009 — get a short url — tags: javascript jquery twitter embed

validation client-side with form_tag and form_remote_tag Delicious Email

create your javascript validate function and call in your form

show/hide lines
   1  <% form_tag "/login", :onsubmit => 'return validate(this)' do %>
   2      <!-- your form -->
   3  <% end %>
   4  
   5  <!-- or -->
   6  
   7  <% form_remote_tag :url => "/login", :update => 'temp', :before => 'if( !validate(this) ) return false' do %>
   8      <!-- your form -->
   9  <% end %>
created by leozera — 30 November 2008 — get a short url — tags: form_remote rails validation embed

ie6 notice Delicious Email

used here!

show/hide lines
   1  <!--[if IE 6]>
   2  IE 6 is a junkie!
   3  <![endif]-->
created by leozera — 08 November 2008 — get a short url embed

vertical align with javascript Delicious Email

source: http://snipplr.com/view/9321/vertically-align-within-browser-window/

show/hide lines
   1  <div id="verticalContainer">
   2  	This text will always be vertically centered inside the browser window
   3  </div>
   4  
   5  <script type="text/javascript">
   6  	function getWindowHeight() {
   7  		var windowHeight = 0;
   8  		if (typeof(window.innerHeight) == 'number') {
   9  			windowHeight = window.innerHeight;
  10  		}
  11  		else {
  12  			if (document.documentElement && document.documentElement.clientHeight) {
  13  				windowHeight = document.documentElement.clientHeight;
  14  			}
  15  			else {
  16  				if (document.body && document.body.clientHeight) {
  17  					windowHeight = document.body.clientHeight;
  18  				}
  19  			}
  20  		}
  21  		return windowHeight;
  22  	}
  23  
  24  	function setContent() {
  25  		if (document.getElementById) {
  26  			var windowHeight = getWindowHeight();
  27  			if (windowHeight > 0) {
  28  				var contentElement = document.getElementById('verticalContainer');	// Be sure to specify the correct ID
  29  				var contentHeight = contentElement.offsetHeight;
  30  				if (windowHeight - contentHeight > 0) {
  31  					contentElement.style.position = 'relative';
  32  					contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
  33  				}
  34  				else {
  35  					contentElement.style.position = 'static';
  36  				}
  37  			}
  38  		}
  39  	}
  40  
  41  	window.onresize = function() {
  42  		setContent();
  43  	}
  44  
  45  	window.onload = function() {
  46  		setContent();
  47  	}
  48  </script>
created by leozera — 01 November 2008 — get a short url — tags: align javascript embed

search box onclick clear/unclear Delicious Email

this’s used here!

show/hide lines
   1  <script type="text/javascript">
   2      function clickclear(thisfield, defaulttext) {
   3          if (thisfield.value == defaulttext) {
   4              thisfield.value = "";
   5          }
   6      }
   7      
   8      function clickrecall(thisfield, defaulttext) {
   9          if (thisfield.value == "") {
  10              thisfield.value = defaulttext;
  11          }
  12      }
  13  </script>
  14  
  15  <input id="search" type="text" name="q" value="search" onclick="clickclear(this, 'search')" onblur="clickrecall(this,'search')"/>
created by leozera — 01 November 2008 — get a short url — tags: input javascript embed
Displaying records 1 - 10 of 12