can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[livejournal] r17658: LJSUP-7052: Landing page

Committer: dpetrov
LJSUP-7052: Landing page
A   trunk/htdocs/js/widgets/search.js
U   trunk/templates/Browse/recent_posts.tmpl
Added: trunk/htdocs/js/widgets/search.js
===================================================================
--- trunk/htdocs/js/widgets/search.js	                        (rev 0)
+++ trunk/htdocs/js/widgets/search.js	2010-11-10 08:34:35 UTC (rev 17658)
@@ -0,0 +1,85 @@
+jQuery(function($) {
+	var label = $( '#search_text_label' ),
+		search = $( '#search_text' );
+
+	if( search.size() === 0 ){
+		return;
+	}
+
+	search
+		.focus( function(){
+			label.hide();
+		} )
+		.blur( function(){
+			if( search.val().length === 0 ){
+				label.show();
+			}
+		} );
+
+	if( search.val().length > 0 ){
+		label.hide();
+	}
+
+	search.parents( 'form' ).submit( function( ev ){
+		var val = $.trim( search.val() );
+		if( val.length === 0 ){
+			ev.preventDefault();
+			return;
+		}
+
+		search.val ( val );
+	} );
+
+	//should feed tags array there
+	tagAutocomplete( search, [] );
+
+	function tagAutocomplete(node, tags)
+	{
+		jQuery(node).autocomplete({
+			minLength: 1,
+			source: function(request, response) {
+				var tag = this.element.context.value;
+
+				// delegate back to autocomplete, but extract term
+				if (!tag) {
+					response([]);
+					return;
+				}
+				var resp_ary = [], i = -1;
+				while (tags[++i]) {
+					if (tags[i].indexOf(tag) === 0) {
+						resp_ary.push(tags[i]);
+						if (resp_ary.length === 10) {
+							break;
+						}
+					}
+				}
+				
+				response(resp_ary);
+			},
+			focus: function() {
+				// prevent value inserted on focus
+				return false;
+			},
+			select: function(e, ui) {
+				this.value = ui.item.value;
+				this.form.submit();
+			},
+			
+			open: function()
+			{
+				var widget = jQuery(this).autocomplete('widget')
+				// fix left pos in FF 3.6
+				if (jQuery.browser.mozilla) {
+					var offset = widget.offset();
+					offset.left++;
+					
+					widget.offset(offset);
+					widget.width(widget.width()+3);
+				} else {
+					widget.width(widget.width()+4);
+				}
+			}
+		});
+	}
+} );

Modified: trunk/templates/Browse/recent_posts.tmpl
===================================================================
--- trunk/templates/Browse/recent_posts.tmpl	2010-11-10 08:17:10 UTC (rev 17657)
+++ trunk/templates/Browse/recent_posts.tmpl	2010-11-10 08:34:35 UTC (rev 17658)
@@ -24,6 +24,24 @@
 			<tmpl_var post_text>
 			<tmpl_if is_need_more>(<a href="<tmpl_var url_to_post>">Read more in original post</a>)</tmpl_if>
 		</div>
+		<ul class="b-share">
+			<li class="b-share-fb"><a href="javascript:void(0);">facebook</a></li>
+			<li class="b-share-twitter"><a href="javascript:void(0);">twitter</a></li>
+			<li class="b-share-sharethis"><a href="javascript:void(0);">sharethis</a></li>
+			<li class="b-share-email"><a href="javascript:void(0);">mail</a></li>
+			<li class="b-share-fb-like"><iframe src="http://www.facebook.com/plugins/like.php?href=<tmpl_var expr="eurl(url_to_post)">&amp;layout=button_count&amp;show_faces=true&amp;width=150&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" allowTransparency="true"></iframe></li>
+		</ul>
+		<script type="text/javascript">
+		(function() {
+			var s = SHARETHIS.addEntry({url:'<tmpl_var url_to_post>', title: '<tmpl_var subject>'}, {button: false});
+			var ul = jQuery('ul:last');
+
+			s.attachButton( ul.find('.b-share-sharethis a')[0]);
+			s.attachChicklet("email", ul.find('.b-share-email a')[0]);
+			s.attachChicklet("facebook", ul.find('.b-share-fb a')[0]);
+			s.attachChicklet("twitter", ul.find('.b-share-twitter a')[0]);
+		}());
+		</script>
 		<p class="b-catalogue-item-comments"><span class="b-catalogue-comments-count"><a href="<tmpl_var url_to_post>#comments"><tmpl_var comments_count> comments</a> |</span> <a href="<tmpl_var url_to_post>?mode=reply">Leave comment</a></p>
 	</li>
 </tmpl_loop>

Tags: can3p, js, livejournal, tmpl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments