טאבים לחלופת עמודים מבוססת jquery
במהלך פיתוח האתר שלנו נוצר צורך בין השאר ליצור מנגנון מבוסס טאבים עבור עמוד האודות.
הדבר הראשון שעשינו היה לבדוק את היצע התוספים והספריות הקיימים היום עבור jquery. מהר מאד הגענו לפרוייקט jqueryui שכולל גם את הטיפול בממשק טאבים.
קבצי הג'אווהסקריפט הנדרשים הם:
קוד ה-HTML נראה כך:
<div id="tabs"> <ul> <li> <a href="#tabs-1">tab 1</a> </li> <li> <a href="#tabs-2">tab 2</a></li> <li> <a href="#tabs-3">tab 3</a></li> </ul> <div id="tabs-1"> <p> Text for tab 1.</p> </div> <div id="tabs-2"> <p> text for tab 2.</p> </div> <div id="tabs-3"> <p> text for tab 3.</p> </div> </div>
וקוד הפונקציה נראה בצורתו הבסיסית כך:
<script type="text/javascript">
$(function() {
$("#tabs").tabs();
});
</script>
אנחנו רצינו להוסיף גם אפקטים של פייד
ולכן השתמשנו בקוד הבא
<script type="text/javascript">
$(function() {
$("#tabs").tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
});
</script>
ניתן לראות כאן את האפשרויות השונות של ממשק הטאבים.
כלומר קוד ה-HTML שאנחנו צריכים הוא:
<html>
<head>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?ver=1.3.2'></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
});
</script>
</head>
<body>
<div id="tabs">
<ul>
<li>
<a href="#tabs-1">tab 1</a>
</li>
<li>
<a href="#tabs-2">tab 2</a></li>
<li>
<a href="#tabs-3">tab 3</a></li>
</ul>
<div id="tabs-1">
<p>
Text for tab 1.</p>
</div>
<div id="tabs-2">
<p>
text for tab 2.</p>
</div>
<div id="tabs-3">
<p>
text for tab 3.</p>
</div>
</div>
</body>
</html>
עכשיו רק צריך לשלב את העסק הזה עם מערכת הוורדפרס שלנו.
כאמור אנחנו למעשה רצינו ממשק שמחליף תוכן בין עמודים שונים, השלב הראשון היה לייצר תבנית ייחודית עבור עמוד האודות
לאחר מכן הוספנו לקובץ function.php את הקריאה ל-jquery
if( !is_admin()){
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2');
wp_enqueue_script('jquery');
}
ולקובץ header את הקריאה ל-jqueryui ולסקריפט שלנו
<?php wp_head(); ?>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
});
</script>
חשוב לשים לב לקרוא להן אחרי הקריאה לפונקציה wp_head כדי שיטענו רק אחרי הקריאה ל-jquery עצמו.
הדברה האחרון שנותר הוא לייצר את הטאבים, יצרנו מבנה עמודים כך שכל הטאבים הם תתי עמודים של עמוד אודות ואז ניתן להשתמש בקוד הבא:
<div id="tabs">
<!-- tabs navigation menu -->
<ul>
<?
query_posts("post_parent=$post->ID&orderby=order&post_type=page&order=ASC");
while(have_posts()) {
the_post();
echo "<li><a href='#".get_the_ID()."'>".get_the_title()."</a></li>";
}
?>
</ul>
<div class="main">
<?
reset($posts);
/* The tabs loop, each div is a different tab */
while(have_posts()) { the_post();
?>
<div id="<? the_ID(); ?>" class="tabdiv">
<h2><? the_title();?></h2>
<?
the_content();
?>
</div>
<?
}
?>
</div>
</div>
אחלה קוד, פשוט ויפה. רק שימי לב שלא מומלץ לטעון את קוד הג'אווהסקריפט של jQuery בהדר, אלא בפוטר. זה מאט את פעילות הדפדפן כי הוא עוצר להוריד ולהריץ את הקוד הזה לפני שהוא ממשיך הלאה, ובינתיים המשתמש מחכה שהעמוד יטען.
הטיפ הזה ועוד רבים וטובים פה:
http://developer.yahoo.com/performance/rules.html
שים לב שכשעובדים בוורדפרס אני לא טוענת את הקוד ב-header אלא בעזרת wp_enqueue_script
הדרך הנכונה להשתמש בו היא:
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2', true);
ואז הוא נטען בפוטר.
כמובן שהשלב הבא הוא להעביר את כל פונקציות ה-js לפוטר
תודה רבה על הקוד,
מה שלא הבנתי..
מה ששמת בקובץ ה function.php
לאיזה פונקציה להוסיף אותו?
או שזה אמור לשבת מחוץ לפונקציה מסויימת?
I admit, I have not seen this web page for a long time, however, it was another pleasure to see such an fantastic topic and overpass it. Thanks for helping making people more aware of wonderful points.
This is usually a remarkable post by the best way. I am going to don't wait and bookmark this post for my sis to try in a while tomorrow. Keep up the great quality work.
Greetings your website seems to be great .I agree you are working your straight knowledge.I would love to know many more features of your website
I am speechless. It is a fantastic blog and really engaging too. Great work! That is not likely a lot coming from an amateur blogger like me, nevertheless it's all I may assume after enjoying your posts. Nice grammar and vocabulary. Unlike other blogs. You actually know what you're speaking about too. A lot that you just made me need to read more. Your weblog has change into a stepping stone for me, my fellow blogger. Thanks for the detailed journey. I really enjoyed the 6 posts that I've read so far.
You made some decent points there. I looked on the web for the issue and identified most people will go in addition to together with your web site.
Clarity, when you reply to a persons cenmomt . how should I word this, okay, the reply option beneath your video, does the person your replying to even know that you replied to them! Do you understand what I'm saying? When I reply to a person I send a personal message directly to them. Just a question, I saw you were replying to (salman1sa) and the question entered my mind, do we want to draw that person back in to view our vids or is this just for future viewers?
You completed certain fine points there. I did a search on the topic and found mainly people will go along with with your blog.
There are certainly a great deal of details like that to take into consideration. That's a fantastic point to bring up. I give the thoughts above as common inspiration but clearly you will discover questions like the one you bring up where one of the most critical factor will be working in honest fantastic faith. I don?t know if greatest practices have emerged around things like that, but I am certain that your job is clearly identified as a fair game. Each boys and girls feel the impact of just a moment?ˉs pleasure, for the rest of their lives.
I conceive this website holds some rattling excellent information for everyone
. "The ground that a good man treads is hallowed." by Johann von Goethe.
Hands down, Apple's app store wins by a mile. It's a huge selection of all sorts of apps vs a rather sad selection of a handful for Zune. Microsoft has plans, especially in the realm of games, but I'm not sure I'd want to bet on the future if this aspect is important to you. The iPod is a much better choice in that case.
I admit, I have not seen this web site for a long time, however, it was another joy to see such a best items and ignore it. Thank you for helping making people realize that excellent ideas.
I'm a teenager and I heard that you can actually get paid for things like this. I'm experienced with computers and have good literature skills and I'm sure I can write successful blogs/articles.. . On a different (sort of) topic, would I be able to join affiliate programs?.
Zune and iPod: Most people compare the Zune to the Touch, but after seeing how slim and surprisingly small and light it is, I consider it to be a rather unique hybrid that combines qualities of both the Touch and the Nano. It's very colorful and lovely OLED screen is slightly smaller than the touch screen, but the player itself feels quite a bit smaller and lighter. It weighs about 2/3 as much, and is noticeably smaller in width and height, while being just a hair thicker.
Sorry for the huge review, but I'm really loving the new Zune, and hope this, as well as the excellent reviews some other people have written, will help you decide if it's the right choice for you.
Apple now has Rhapsody as an app, which is a great start, but it is currently hampered by the inability to store locally on your iPod, and has a dismal 64kbps bit rate. If this changes, then it will somewhat negate this advantage for the Zune, but the 10 songs per month will still be a big plus in Zune Pass' favor.
A nation's culture resides in the hearts and in the soul of its people. | A policy is a temporary creed liable to be changed, but while it holds good it has got to be pursued with apostolic zeal. | A principle is the expression of perfection, and as imperfect beings like us cannot practise perfection, we devise every moment limits of its compromise in practice. | A religion that takes no account of practical affairs and does not help to solve them is no religion. | A small body of determined spirits fired by an unquenchable faith in their mission can alter the course of history. | A vow is a purely religious act which cannot be taken in a fit of passion. It can be taken only with a mind purified and composed and with God as witness. | A weak man is just by accident. A strong but non-violent man is unjust by accident. | Action expresses priorities. | Action is no less necessary than thought to the instinctive tendencies of the human frame. | All compromise is based on give and take, but there can be no give and take on fundamentals. Any compromise on mere fundamentals is a surrender. For it is all give and no take. | All the religions of the world, while they may differ in other respects, unitedly proclaim that nothing lives in this world but Truth. | Always aim at complete harmony of thought and word and deed. Always aim at purifying your thoughts and everything will be well. |
It may be too sophisticated and very broad for me. I am expecting for your other posting, and I will try to get the hang of it! Really the posting is spreading its wings quickly, searching for it...
I leave a comment each time I like a article on a site or I have something to add to the discussion. Usually it is triggered by the sincerness displayed in the post I looked at. And after this article ט××‘×™× ×œ×—×œ×•×¤×ª ×¢×ž×•×“×™× ×ž×‘×•×¡×¡×ª jquery | קוד-×רט. I was excited enough to drop a thought
I actually do have 2 questions for you if it's okay. Could it be simply me or do some of the remarks look as if they are coming from brain dead visitors?
And, if you are posting on other sites, I'd like to keep up with anything new you have to post. Could you make a list all of all your public pages like your Facebook page, twitter feed, or linkedin profile?
Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You clearly know what youre talking about, why throw away your intelligence on just posting videos to your blog when you could be giving us something enlightening to read?
Wow, what a video it is! Really nice quality video, the lesson given in this video is truly informative.
visit us.
Many thanks for helping to study this opinion, I feel intensive about issues and I am willing to learn much things on this point. Probably, as you acquire knowledge, would you notice updating your web site with loads of more info? It’s very useful for me.
Unquestionably believe that which you stated. Your favourite justification seemed to be at the web the simplest factor to take note of. I say to you, I definitely get annoyed even as folks consider concerns that they just do not recognise about. You controlled to hit the nail upon the highest and also defined out the entire thing with no need side effect , other people could take a signal. Will probably be again to get more. Thanks
I could not show too much not the same information on this clot of detail, so it was great to locate his one. I will get back again to look at next essays that you have another time.
The Zune concentrates on being a Portable Media Player. Not a web browser. Not a game machine. Maybe in the future it'll do even better in those areas, but for now it's a fantastic way to organize and listen to your music and videos, and is without peer in that regard. The iPod's strengths are its web browsing and apps. If those sound more compelling, perhaps it is your best choice.
Glorious read, I just passed this onto a colleague who was doing a little analysis on that. And he actually purchased me lunch because I found it for him smile So let me rephrase that: Thanks for lunch! Anyway, in my language, there usually are not much good source like this.
I found this is a helpful and interesting post, so I think it is very helpful and knowledgeable. Appreciate for the efforts you have made in writing this publication. I am hoping the different great work from you in the future as well. Really your creative writing ability has urged me.
I couldn't locate too much unequal information on this clot of contents, so it was easy to show his one. I will be back again to overlook another write-ups that you have next time.
Because the admin of this website is working, no doubt very quickly it will be well-known, due to its feature contents.
Actually, the points is practically the sweetest on this useful posting. I coordinate with your summary and will hopefully await your approaching updates. Saying thanks will not just be ample, for the great clarity in your writing.
It looks like too complicated and very comprehensive for me. I am awaiting for your the other essay, and I plan to try to get the hang of it! Actually the essay is spreading its wings promptly, searching for it...
...Click here for or more Information...
[...]you make blogging glance[...]...
Thank you for another informative web site. Where else could I get that type of info written in such a perfect way? I've a project that I am just now working on, and I've been on the look out for such information.
Between me and my husband we've owned more MP3 players over the years than I can count, including Sansas, iRivers, iPods (classic & touch), the Ibiza Rhapsody, etc. But, the last few years I've settled down to one line of players. Why? Because I was happy to discover how well-designed and fun to use the underappreciated (and widely mocked) Zunes are.
I learned something new today, thanks for sharing.
Oh my goodness! an awesome write-up dude. Thank you Having said that I'm experiencing issue with ur rss . Don?ˉt know why Unable to subscribe to it. Is there anyone acquiring identical rss issue? Any person who knows kindly respond. Thanks.
I have a lot of respect for a writer that can take informational content and make it interesting. You did this. Readers like to be entertained when reading straight information.
I couldn't discover too much different information on this clot of contents, so it was great to locate his one. I will return again to overlook some other essays that you have another time.
I couldn't find too much different information on this piece of contents, so it was easy to locate his one. I will get back again to look through another submissions that you have next time.
I leave a leave a response each time I appreciate a post on a website or I have something to contribute to the conversation. It's a result of the sincerness communicated in the article I browsed. And on this article ט××‘×™× ×œ×—×œ×•×¤×ª ×¢×ž×•×“×™× ×ž×‘×•×¡×¡×ª jquery | קוד-×רט. I was moved enough to drop a commenta response
I actually do have a few questions for you if you don't mind. Could it be only me or does it look like like a few of these remarks appear like coming from brain dead individuals?
And, if you are posting at additional places, I'd like to follow you. Would you make a list every one of your social pages like your Facebook page, twitter feed, or linkedin profile?
I am extremely inspired with your writing skills and also with the layout to your weblog. Is this a paid theme or did you modify it yourself? Anyway stay up the nice high quality writing, it’s rare to see a nice weblog like this one today..
You are my breathing in, I possess few web logs and occasionally run out from to brand.
Hi there, all the time i used to check blog posts here early in the break of day, because i enjoy to learn more and more.
This is getting a bit more subjective, but I much prefer the Zune Marketplace. The interface is colorful, has more flair, and some cool features like 'Mixview' that let you quickly see related albums, songs, or other users related to what you're listening to. Clicking on one of those will center on that item, and another set of "neighbors" will come into view, allowing you to navigate around exploring by similar artists, songs, or users. Speaking of users, the Zune "Social" is also great fun, letting you find others with shared tastes and becoming friends with them. You then can listen to a playlist created based on an amalgamation of what all your friends are listening to, which is also enjoyable. Those concerned with privacy will be relieved to know you can prevent the public from seeing your personal listening habits if you so choose.
http://sdfdsjfhsiu887.hostei.com
Thanks you pretty considerably for this fantastic and really insightful publish. Any individual may get incredibly good information from this publish.really good receive the occupation performed protect it up. I'm likely to bookmark this online site for arrived again in foreseeable foreseeable future.
Would you think it's better to put social bookmark?
Hey there are using WordPress for your site platform? I'm new to the blog world but I'm trying to get started and create my own. Do you need any coding knowledge to make your own blog? Any help would be greatly appreciated!
Thanks so much for giving everyone an extremely splendid chance to discover important secrets from this blog. It's usually very sweet and also stuffed with a lot of fun for me and my office peers to visit your web site on the least three times per week to find out the fresh secrets you have got. And lastly, I am also at all times pleased with all the tremendous techniques you give. Selected two areas in this article are surely the finest we've ever had.