Forum established

Hi and thanks for all that in previous posts Nzrshvnv forward. With your positive comments, it was decided that this Forum will be established. This forum is now loaded with the address forum.monavarian. ir is available. and but a few points:

  • This forum was created with a limited number that can be spread to welcome you and make Pyshnhadattvn.
  • In addition to my own questions and problems in the forums, try to also answer your questions so that problems and thus have a friendly atmosphere and useful.
  • Try Friends-related materials to any forum where discussion.
  • I do have director Forums Forums management time and attention to the activities of Friends of the Members will be selected.
  • No compliment to say that growth depends Karbrhash forum.

However, I hope this forum could help me and you to get some of our demands.





And polls suggest about a forum site

Hi all.

Send me to a number of friends Mtalbshvnv of where my blog and I'm so busy that, but somehow I was unfaithful and I'm embarrassed about it, I decided to create a forum discussion on this website to friends and written content Btvnn Hashvnv body was there. I founded your friends about this forum and also whether Pyshnhadtvn or even if we set up this forum and I think you will get and when a member of the Spirits.

I'm glad you know this?





Book jQuery: Download full text in Persian as pdf

The full text of my training jquery library that I wrote myself. This training consists of nine chapters are as follows:

  • Chapter I: jquery is Download and install aptana studio
  • Chapter II: The general structure of commands
  • Chapter III: Effects of jquery
  • Chapter Four: jquery and change the contents of the html tags
  • Chapter Five: Change the style element in jquery
  • Chapter Six: Ayjaks in jquery
  • Chapter VII: jquery navigation elements
  • Chapter Eight: The extension or plugin in jquery (installing plug - a plug-in)
  • Chapter Nine: Introduction to a few other useful functions
  • Attachments: (selectors, Events, triger Functions)

Links Download pdf: jquery learning Farsi (learning_jquery_farsi.pdf) File size: 508 KB. Help me with comments on improving this ebook.





Download a few tracks from Becker and Miri Hussein (Shirazi country singer)

First of all say that this is a music blog. But sometimes a pleasure to hear music that makes me go for it on my blog readers to share it between.

Hussein recently go with your blog hoseinmiri.com been opened and several of her songs with explanations and with high quality for download. I doubt they're here to play any artist I work with sound and powerful Iran is not familiar No. I hear and take pleasure.

It was explained that most of the songs from the album Age's first album of his professors and professional musicians Hussein that the giants of Iranian music and adjust ourselves to quote M. Morshed work for anyone else who is working on music Iran a familiar name.

If you download this song and I finally came to rest, to support the reader to check my blog comment.





Learning jQuery - Chapter VII: Elements of scrolling html (Tree Traversal (.

Chapter VII:

: ( Tree Traversal ) : Traversal of the html: (Tree Traversal):

از تعدادی تگهای تو در تو تشکیل شده است . As you know any html page is composed of a number of nested tags. Each child tag and outer tag is the father of her inner tags. It also tags the next level in a neighborhood also called tags.

In addition to access page elements selecting a common feature of these definitions can be used to navigate the tree.

For example the following code:

<html>

<head>

<title> test page </ title>

</ Head>

<body>

<div>

<ul>

<li> one </ li>

<li> two </ li>

<li> three </ li>

</ Ul>

</ Div>

</ Body>

</ Html>

In the above example:

· هستند All html tags are child tags

· پدر تگ title و در نتیجه تگ title فرزند تگ head می باشد . Father head tag and title tag title tag in the head tag is a child.

· همسایه یا هم نژاد (برادر یا خواهر ) یکدیگر هستند و همگی فرزند ul هستند و همچنین در سطح بالاتر فرزند تگ div و body و html . Tags li neighbor or sibling (brother or sister) are together and all children are ul and also higher levels of child div tags and the body and html.

· نیز فرزند div و body و html است . Div and ul tags, the child's body and html.

· همسایه تگ head و فرزند html است . Neighbor's head tag and body tag is html.

Given the above definitions. برای پیمایش درختی عناصر html ایجاد شده که در این فصل آنها را شرح خواهیم داد : JQuery functions for tree traversal html elements generated in this chapter we will explain them:

$ (Selector). Children ([selector]):

$ (Selector). Parent ([selector]);

فرزندهای عنصر انتخابی را بر میگرداند . Function children () Returns the element Frzndhay. For example:

$ ('Ul'). Children (). Css ('background', 'Red');

(فرزند های ul یا همان تگهای li ) قرمز شود . The above statement causes the background color of all tags within tags ul (son of the tags ul li) is red.

استفاده نمایید تا فرزند های خاصی از تگها را انتخاب نمایید . You can also use the argument selector to choose the child specific tags.

Note the following example:

<div>

<span> Hello </ span>

<p class="selected"> Hello Again </ p>

<div class="selected"> And Again </ div>

<p> And One Last Time </ p>

</ Div>

If we run this example, the following code:

$ ("Div"). Children (". Selected"). Css ("color", "blue");

انتخاب میکند که دارای کلاس selected باشد بنابر این نتیجه دستور فوق : In this example, div tags Frzndhayy select a class that is selected so the above command:

Hello
Hello Again

And Again

At One Last Time

پدر عناصر انتخابی را بر میگرداند (اولین پدر ) . Function parent () Returns the parent element of choice (first parent).

$ ('Li'). Parent (). AddClass ('listExpander');

در صفحه کلاس listExpander را اعمال میکند . In this example, the first parent li element in this class will apply listExpander.

این تابع نیز میتواند مقدار selector را قبول کند : The function children () This function will also accept a selector:

<div class="one">

<div class="two">

<span class="text"> click </ span>

</ Div>

<div>

In the example above:

$ ('Span'). Parent ():

با کلاس two اشاره میکند . Div with class to two points. If the

$ ('Span'). Parent ('. One'):

با کلاس one اشاره میکند . One refers to the div with the class.

فقط یک عنصر را به عنوان پدر بر میگرداند . Tip: Consider the function parent () only returns one element as the father. استفاده کنید : If you want all male parents can return an element of the parents (), use:

$ ('Span'). Parents ():

(یعنی هم div با کلاس two و هم div با کلاس one ) را بر میگرداند . In this example, all the parent span (ie the div div class two and class one) and returns.

: Function: parentsUntil ():

$ (Selector). ParentsUntil ([parent_selector]);

به معنی “تا اینکه ” می باشد و همانطور که از معنی این عبارت مشخص است تابع فوق تمامی والدهای عنصر selector را تا رسیدن به عنصر parent_selector بر میگرداند . (Until the word means "until" is the meaning of this phrase is clear from the above function selector element to all male parents parent_selector returns the element.

For example, if in the first instance to write this chapter, the following code:

$ ('Li'). ParentsUntil ('body'). AddClass ('test');

تا تگ body (تگهای ul و div ) کلاس test را اضافه میکند . Parent to all li tags to the tag body (ul tags and div) adds class to the test.

و pv() : Function next () and pv ():

$ (Selector). Next ([selector]);

$ (Selector). Pv ([selector]);

) و عنصر قبلی ( pv ) استفاده میشوند : As the name suggests, these two functions together to get the next element (next) and the previous element (pv) are used:

<ul>

<li> list item 1 </ li>

<li> list item 2 </ li>

<li class="third-item"> list item 3 </ li>

<li> list item 4 </ li>

<li class="test"> list item 5 </ li>

</ Ul>

In the above example with the code:

$ ('Li.third-item'). Next (). Css ('color', 'red');

به رنگ قرمز نمایش داده شود . The above code makes the list item 4 to be displayed in red.

$ ('Li.third-item'). Next (). Css ('color', 'blue');

را به رنگ آبی نمایش میدهد . This code will display the list item 2 to blue.

$ ('Li.third-item'). Next ('. Test'). Css ('background-color', 'blue');

را با پیش زمینه آبی نمایش میدهد . This code will display the list item 5 with a blue background.

$ ('Li.third-item'). Next ('. Test'). Pv (). Css ('background-color', 'Red');

را با پیش زمینه قرمز نمایش میدهد . This code will display the list item 4 with a red background.

ایجاد شده اند : Note: The following functions to navigate than the previous and next elements are created in jquery:

$ (Selector). NextAll ([nextselector])

$ (Selector). PvAll ([pvselector])

و قبل pv از selector را بر میگرداند (مطابق با nextselector یا pvselector ) All elements of the selector to the next and previous pv returns (according to nextselector or pvselector)

$ (Selector). NextUntil ([nextselector])

$ (Selector). PvUntil ([pvselector])

و قبل pv از selector را تا عنصر nextselector و pvselector بر میگرداند . All elements of the selector to the next and previous pv nextselector element and returns pvselector.

: The siblings ():

$ (Selector). Siblings ([sibling_selector])

را بر میگرداند . This function returns the same breed selector. مشخص شده باشد مقادیری که با این عناصر مطابق باشند بر می گرداند . Sibling_selector is specified and if the values ​​are consistent with these returns.

<! DOCTYPE html>

<html>

<head>

<script src="http://code.jquery.com/jquery-latest.js"> </ script>

</ Head>

<body>

<ul>

<li> one </ li>

<li class="test"> two </ li>

<li class="test2"> three </ li>

</ Ul>

<script>

$ ("Li.test"). Siblings (). Css ("background", "yellow");

</ Script>

</ Body>

</ Html>

با کلاس test ، رنگ پیش زمینه زرد به سایر li ها اضافه میشود . Apart from the above example with Class li test, a yellow background color is added to other li.

هایی انتخاب میشوند که دارای کلاس test۲ باشند : If the above code to change the form below to select only those which have li test2 class are:

$ ('Li.test'). Siblings ('. Test2'). Css ('background', 'yellow');

: Function find ():

$ (Selector). Find (find_selector)

در فرزندهای selector به دنبال find_selector میگردد و آن عنصر را بر میگرداند . Frzndhay selector to find the pan is find_selector and it returns the element.

عمل میکند و تنها تفاوت آن این است که تابع children فقط یک سطح فرزند را جستجو میکند . This function is similar in function children () works and the only difference is that the children will only search for a child. پارامتر selector الزامی است (میتوان برای انتخاب همه از عبارت '*' استفاده کرد ) : The function find (selector) selector is mandatory parameter (you can select all of the words '*' can be used):

$ (Selector). Find ('*')

Example:

<ul class="level-1">

<li class="item-i"> I </ li>

<li class="item-ii"> II

<ul class="level-2">

<li class="item-a"> A </ li>

<li class="item-b"> B

<ul class="level-3">

<li class="item-1"> 1 </ li>

<li class="item-2"> 2 </ li>

<li class="item-3"> 3 </ li>

</ Ul>

</ Li>

<li class="item-c"> C </ li>

</ Ul>

</ Li>

<li class="item-iii"> III </ li>

</ Ul>

If you write in the above example the following code:

$ ('Li.item-ii'). Find ('li'). Css ('background-color', 'red');

را قرمز میکند . The background color code phrases A, B, 1, 2,3, C is red. تنها بر روی عبارات A,B,C اعمال میشود . But the same act with the children only on the terms A, B, C is applied.

: The closest ():

$ (Selector). Closest (closest_selector)

عمل میکند . This function, like the parents () works. But there are some differences between these two functions:

· از خود عنصر انتخابی پیمایش را شروع میکند . Element of his closest pan scrolling starts. از اولین والد شروع به پیمایش میکند . If the parents of the first parent will start scrolling.

· عملیات پیمایش را تا رسیدن به عنصر انتخابی ( closest_selector ) انجام میدهد در صورتی که در تابع parents ابتدا عملیات تا انتها ( root ) انجام میشود . Closest to reaching the scrolling operation element (closest_selector) performs the first operation of parents in the end (root) is done. ریخته شده و سپس آنهایی که مطابق با شرط (عنصر selector ) می باشد را از بین آنها انتخاب میکند . Then all the selected elements in a temp variable and then cast in accordance with those conditions (the selector) is chosen from among them. بیشتر است . So speed is the closest.

· میتواند صفر یا یک عنصر بر گرداند در صورتی که تابع parents صفر یا یک یا چند عنصر بر میگرداند . Closest function can return zero or one element, if the parents function returns zero or one or more elements.

In the above example:

$ ('Li.item-a'). Closest ('ul'). Css ('background-color', 'red')

با کلاس level-۲ قرمز شود . Ul with class level-2 causes the background color is red.

Reference Section: http://api.jquery.com/category/traversing/tree-traversal





Learning jQuery - Chapter Six: Ajax in jQuery (Ayjaks in jQuery)

Chapter Six:

jQuery and Ayjaks:

Jquery library is very efficient for working with Ajax technology in itself that it will introduce in this chapter.

Before you know what is Ajax?

The following is a brief Ajax Asynchronous JavaScript and XML. The technology for the first time using Xml data was created in JavaScript.

Ajax is a programming language. But the technology to communicate with the server via JavaScript and Dynamic pages are created.

Ayjaks core object called XMLHttpRequest Are.

Briefly: Ayjaks indirect communication and exchange of information with a web server in the background making things happen and the result is only part of the screen so the entire page needs to reload (refresh) is not.

Ayjaks in jquery:

Functions for working with the jquery work with this technology Ayjaks There is very easy. It can exchange data with the server functions as TXT, HTML, XML and JASON done using two methods: GET and POST.

And the resulting information can be obtained from the server in the selected element (selector) to get screened.

We will continue to review these functions:

Function of load:

$ (Selector). Load (url, data, callback)

This file is in the url address and read the result after the full implementation of the selected element (Selector) display.

A simple example:

Suppose you have a file server files and folders loadtxt.txt want by clicking a button to get it on the page:


<html>

<head>

<script type="text/javascript" src="jquery.js"> </ script>

<script type="text/javascript">

$ (Document). Ready (function () {

$ ("Button"). Click (function () {

$ ('# Result'). Load ('files / loadtxt.txt');

});

});

</ Script>

</ Head>

<body>

<button> Click to Load Data </ ​​button>

<div id="result"> </ div>

</ Body>

</ Html>

After running this program on the contents of text files will display in the div tag.

Another load is a function of two arguments. Argument data: When you want a server script language (php or asp or aspx files, etc.) and should be read from the server for processing Dytayy to send the script to do it by this argument.

Callback function argument also is that when fully loaded operation was to be implemented.

Example:

Suppose you have a folder of files on the file server name loadname.php its content is as follows:

<? Php

$ Name = $ _REQUEST ['name'];

echo 'Welcome'. $ name;

>

This program is rated as the data it receives and displays the welcome message.

Write a program that we want the user to enter a name and then click the Text Box button. Be sent to the above file name and the display and display a message after the completion of work:


<html>

<head>

<script type="text/javascript" src="jquery.js"> </ script>

<script type="text/javascript">

$ (Document). Ready (function () {

$ ("Button"). Click (function () {

var inputname = $ ('input # name'). val ();

$ ('# Result'). Load ('files / loadname.php', {name: inputname}, finish_load);

});

});

function finish_load ()

{

alert ('load finish');

}

</ Script>

</ Head>

<body>

Please Enter Your Name:

<input type="text" id="name" />

<button> Click to Load Data </ ​​button>

<dir id="result"> </ dir>

</ Body>

</ Html>

As you see in the above code on the button after the first read by the function val the value in textbox and in the presence of variable inputnum. Then using this value to load the file and send loadname.php end was the response from the server welcome message finish_load display function is executed and the "load finish" will be displayed on the screen.

Note 1: The function val (): This function returns the value of a form element if the value is and the value of the property value Nsbt element selector.

$ (Selector). Val (content);

Note 2: If you want more data to send data to the server and put them into any data} and {comma "," separated from the next data length:

{Var1: value1, var2: value2, var3: value3}

Function $. Ajax (option):

The lowest level is the work function with Ayjaks in jQuery ajax function. To use this function to send all the parameters required by the argument option to the server.

A simple example:

$. Ajax ({

url: 'ajax / test.html',

success: function (data) {

$ ('. Result'). Html (data);

alert ('Load was performed.');

}

});

In this example the file test.html ajax function call from the server and displays the result in the element class.

With this function is more difficult than most other functions that will be introduced. Therefore recommended to use this function only when needed and can be used instead of simple functions.

Function: $. Get and $. Post:

$. Post (url, data, callback, type);

$. Get (url, data, callback, type);

As the names suggest, these two functions of two different methods and a post script to get the url of the server and the result by Tay callback return call.

  • url: the address of the server-side script should be run
  • Data: data that is sent to the server: {name: value, name: value, ...}
  • Callback: The function that the data is called the server was completely loaded.
  • Type: type of data from the server, and can specify the value (html, xml, json, jasonp, script, text) is

The only difference between these two functions is the type of data to the server first and second method uses the post method to get. So if you can only read files from the server and send data to the server, you better get use of the function. (Or the load).

(If you do not know about these two methods of teaching programming languages ​​like php or asp server, please).

Example:

The above was written for an ajax function with the function can get below wrote:

$. Get ('ajax / test.html', function (data) {

$ ('. Result'). Html (data);

alert ('Load was performed.');

});

Or another example: In this example, the example that we wrote at the beginning of the season for the load function write the post. In this case, the code will change as follows:

$ (Document). Ready (function () {

$ ("Button"). Click (function () {

var inputname = $ ('input # name'). val ();

$. Post ('files / loadname.php', {name: inputname}, function (Data) {

$ ('# Result'). Html (Data);

finish_load ();

});

});

});

As you can see in the example. Callback function is called with the data after the call is complete loadname.php and the data that functions much the same result by executing the command script is loadname.php html (data) in the element with ID display will result.

Function getScript:

$. GetScript (url, callback)

Function getScript, to invoke and execute a JavaScript file (js) is used.

Ajax function, this function has the following format:

$. Ajax ({

url: url,

dataType: 'script',

success: success

});

Example:

$.getScript("test.js");

This example makes the call and the file is test.js.

$.getScript("http://blog.monavarian.ir/test.js", function(){

alert("Script loaded and executed.");

});

In the above example file called test.js blog.monavarian.ir address and if the call is successful, a message will display.

Tip: You can use this function when you want global variables put in a separate file and then use it in programs.

Function getJSON:

$. GetJSON (url, data, callback);

This function calls the server's file format is Jason.

My braces (briefly about Jason):

Files, Jason, are data files that are stored in a special data format. Jason also has a specific format for such files, xml files are stored.

ساختار هر شی jason به صورت روبرو می باشد :

{string : value , string:value , … }

Value ها میتوانند شامل مقادیر string , object , number , array , true , false , null باشند .

ساختار Array در jason نیز به فرم زیر می باشد :

[item۱,item۲,item۳,…]

هر item نیز خود میتواند شامل مقادیر معرفی شده در بالا باشد .

برای کسب اطلاعات بیشتر به سایت مرجع Jason به آدرس http://www.json.org مراجعه نمایید .

یک مثال کلی با post : در این مثال قصد داریم فرمی را توسط توابع jquery بررسی کرده و سپس توسط تابع post به سرور فرستاده و نتیجه را نمایش دهیم :

برای مثال میخواهیم یک فرم ساده ورود ایجاد نماییم . فایل اسکریپت forms.php بررسی میکند که نام کاربری و کلمه عبور داده شده در لیست کاربران موجود است . در صورتی که موجود باشد مقدار ۱ و در صورتی که موجود نباشد مقدار صفر را بر میگرداند . محتوی این فایل به صورت زیر است :

<?php

//user defind :

$users = array (

'admin' => 'demo',

'test' => 'test',

'user' => 'pass',

);

$username = trim($_POST['username']);

$pass = trim($_POST['password']);

if ( array_search($pass,$users) == $username )

echo '۱′;

else

echo '۰′;

?>

این فایل را در پوشه files ذخیره میکنیم .

در فایل اصلی html :


<!DOCTYPE html PUBLIC "-//W۳C//DTD XHTML ۱.۰ Transitional//EN" "http://www.w۳.org/TR/xhtml۱/DTD/xhtml۱-transitional.dtd">

<html xmlns=”http://www.w۳.org/۱۹۹۹/xhtml”>

<head>

<script src=”jquery.js” type=”text/javascript” ></script>

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-۸″ />

<script type=”text/javascript”>

$(document).ready( function (){

$('input').focus( function (){

$('input').removeClass('select');

$( this ).addClass('select');

});

$('form').submit( function (event){

event.preventDefault();

var user = $('input#username').val();

var pass = $('input#pass').val();

if (!user)

{

$('.result').html('please Enter username');

$('input#username').focus();

}

else if (!pass)

{

$('.result').html('please Enter password');

$('input#pass').focus();

}

else

{

$.post('files/forms.php',{username:user,password:pass}, function (data){

if (data == '۱′)

{

$('.result').html('Login Success <br/> welcome '+user);

$('form').hide();

}

else if (data == '۰′)

$('.result').html('username or password is not correct')

else

$('.result').html('can not connect to server')

})

}

return false;

})

})

</script>

<title>Form Validation</title>

<style>

.result {

color : #FF۰۰۰۰ ;

}

.select {

background : #fff ;

border : ۲px solid #۰۰۰۰ff ;

}

</style>

</head>

<body>

<div class=”result” > </div>

<form action=”#” >

<input type=”text” name=”username” id=”username” />

<input type=”password” name=”pass” id=”pass” />

<input type=”submit” value=”Login”/>

</form>

</body>
</html>

همان طور که در کد بالا مشاهده می کنید . در ابتدا هنگام submit فرم بررسی میکند و در صورت خالی بودن فیلدهای username و یا pass پیغام مناسب درج میکند و سپس نشانگر را به فیلد خالی هدایت می کند (focus ) .

در صورتی که username و pass وارد شده باشد . این مقادیر را به فایل forms.php میفرستد و در نتیجه بررسی میکند : در صورتی که نتیجه فرستاده شده از سرور ۱ باشد پیغام خوش آمد نمایش میدهد و فرم را مخفی (hide ) می نماید در غیر این صورت پیغام مناسب را درج می نماید.





آموزش jQuery - فصل پنجم : تغییر استایل در جی کوئری

فصل پنجم :

تغییر استایل در جی کوئری :

توسط jquery میتوانید مستقیما استایل یک شی را در صفحه تغییر دهید . برای تغییر استایل چند تابع مهم وجود دارد :

  • $(selector).css(name,value)
  • $(selector).css({properties})
  • $(selector).css(name)
  • $(selector).height(value)
  • $(selector).width(value)

توسط تابع css به سه روش فوق میتوان مقدار استایل عناصر را تغییر داد .

$(selector).css(name,value)

در این دستور مقدار value را برای خصوصیت name در تمام عناصر html مطابق با selector تنظیم میکند.

$(”p”).css(”background-color”,”yellow”);

عبارت بالا رنگ پیش زمینه همه پاراگراف های موجود در صفحه را به زرد تبدیل میکند.

$(selector).css({properties}) :

این دستور برای تنظیم چندین خصوصیت css برای عناصر انتخابی می باشد . به عنوان مثال :

$(”p”).css({”background-color”:”yellow”,”font-size”:”۲۰۰%”});

عبارت فوق رنگ پیش زمینه پاراگرافها را زرد و اندازه نوشته آنها را دوبرابر میکند. همانطور که میبینید هر خوصوصیت با یک کاما “,” از خصوصیت بعدی جدا میشود و همه خصوصیت ها بین { و } قرار گرفته اند.

$(selector).css(name) :

این دستور مقدار خصوصیت name از عنصر selector را برمیگرداند . For example:

$(this).css(”color”);

عبارت فوق مقدار رنگ نوشته عنصر جاری را برمیگرداند .

$(selector).height(value)

$(selector).width(value)

دو تابع width و height به ترتیب برای تغییر اندازه عرض و ارتفاع selector ها استفاده میشود :

$(”#boxinfo”).height(”۲۰۰px”);

عبارت فوق مقدار ارتفاق عنصری با آیدی boxinfo در صفحه را ۲۰۰ پیکسل میکند.

$(this).width(”۲۰۰px”).height(”۲۰۰px”);

عبارت فوق اندازه عرض و ارتفاع عنصر جاری را برابر ۲۰۰پیکسل میکند.

نکته : دو تابع width و height در صورتی که بدون پارامتر استفاده شوند به ترتیب مقدار عرض و ارتفاع عنصر انتخابی را بر میگردانند.

افزودن و حذف کلاس :

$(selector).addClass(classname);

$(selector).removeClass(classname);

توسط دو دستور فوق میتوان یک کلاس css را به عناصر انتخابی اضافه نمود و یا اگر عناصری دارای کلاسی هستند آن کلاس را حذف کرد .

مثال :

<html>

<head>

<script src=”jquery.js” type=”text/javascript” ></script>

<script type=”text/javascript”>

$(document).ready(function(){

$('button').mouseover(function(){

$('p').addClass('info');

})

$('button').mouseout(function(){

$('p').removeClass('info');

})

})

</script>

<title>Example ۱</title>

<style>

.info {

background:#۰۰۰;

color:#FFF;

}

</style>

</head>

<body>

<button>move mouse to add or remove </button>

<p>paragraph ۱</p>

<p class=”info”> paragraph ۲ whit class info</p>

</body></html>

در کد فوق پس از اجرا با بردن موس روی دکمه کلاس info به پاراگراف ها اعمال میشود و با برن موس به خارج از دکمه کلاس info حذف میشود.

نکته : توسط دستور (selector).toggleClass(content)$ میتوان به عنصری کلاسی را اضافه کرد و در صورتی که عنصر از این کلاس استفاده میکند آن را حذف کرد . (تغییر وضعیت بین اضافه و حذف کلاس content برای عنصر selector ) .

hasClass(classname):

مشخص میکند که آیا عنصر دارای کلاس classname هست یا خیر .

if ( $('#mydiv').hasClass('info') )
alert('mydiv has class info');

position() :

$(selector).position()

این تابع فاصله selector را از بالا و چپ صفحه مشخص میکند . برای دسترسی به فاصله بالا از .top و برای دسترسی به فاصله چپ از .left استفاده میشود :

var pos = $('#mydiv').position();
var left = pos.left;
var top = pos.top;





آموزش jQuery - فصل چهارم : تغییر محتوای عناصر در جی کوئری

فصل چهارم :

Jquery و تغییر محتوای عناصر :

در jquery شما میتوانید به راحتی محتوای تگ ها و عناصر موجود در صفحه را تغییر نمایید .

برای اینکار چندین تابع در jquery وجود دارد :

$(selector).html(content);

با این دستور محتوی content را داخل عناصر Selectors قرار میدهد .

به عنوان مثال :

$(”p#head”).html(” Welcome “);

این قطعه کد در تگ p با آیدی head عبارت Welcome را مینویسد .

نکته : content میتوان متن ساده یا html باشد :

$('p').html(”<h۱> hello </h۱>”);

توابع دیگری نیز برای تغییر محتوا عناصر وجود دارند :

$(selector).append(content)

این تابع عبارت content را به انتهای محتوای Selector اضافه میکند .

$(selector).prepend(content)

این تابع عبارت content را به ابتدای محتوای Selector اضافه میکند .

$(selector).after(content)

این تابع عبارت content را بعد از تمام عناصر نظیر Selector درج میکند .

$(selector).before(content)

این تابع عبارت content را قبل از تمام عناصر نظیر Selector درج میکند .

نکته : دستور html() به تنهای محتوی عنصر را برمیگرداند :

alert($('#box').html());

تابع دیگری هم برای خواندن محتوی وجود دارد به نام text() که همانند تابع html() عمل میکند با این تفاوت که این تابع تگ های html را حذف میکند و فقط نوشته را برمیگرداند در حالی که html() تمام محتوی را با تگهایش برمیگرداند .

به مثال زیر توجه نمایید :

< html >

< head >

< script type =” text/javascript src =” jquery.js ></ script >

< script type =” text/javascript >

$ ( document ). ready ( function (){

$ ( “button” ). click ( function (){

alert ( $ ( '#test' ). text ());

alert ( $ ( '#test' ). html ());

});

</ script >

</ head >

< body >

< p id =” test > < b > paragraph </ b > </ p >

< button > Click me </ button >

</ body >

</ html >

پس از اجرای دستور فوق و کلیک رو دکمه اولین پنجره مقدار “ paragraph ” را نمایش میدهد و دومین پنجره عبارت “ <b> paragraph </b> ” نمایش داده میشود .

تغییر خصوصیات ( Attribute ) شی :

توسط تابع attr() میتوان به خصوصیات یک تگ html دسترسی پیدا کرد .

$(selector).attr(attribute);

خصوصیت attribute از عنصر انتخابی را بر میگرداند .

$(selector).attr(attribute,value);

به خصوصیت attribute از عناصر انتخابی مقدار value را نسبت میدهد .

For example:

$('a').attr('href');

مقدار خصوصیت href از اولین تگ a موجود در صفحه را بر میگرداند .

$(this).attr('id','newName');

مقدار id عنصر جاری را به newName تغییر نام میدهد.

دسترسی به value عناصر فرم ها :

$(selector).val();

$(selector).val(newValue);

توسط تابع val() میتوانیم به محتوا ( value ) عناصر موجود در فرم ها دسترسی و مقدارش را تغییر دهیم .

به مثال های زیر توجه نمایید :

$('input#name').val();

مقدار value عنصر input با آیدی name را بر میگرداند .

$('select.foo option:selected').val();

هنگامی که پنجره dropdown باز است مقدار انتخابی را برمیگرداند .

$('select.foo').val('two');

مقدار انتخاب شده عنصر select با کلاس foo را روی مقدار two تنظیم میکند.

$('input:checkbox:checked').val();

مقدار چک باکس انتخاب شده را بر میگرداند .

$('input:radio[name=bar]:checked').val();

مقدار انتخاب شده از دکمه های رادیویی در گروه با نام bar را بر میگرداند.

Example:

< html >

< head >

< script src =” jquery.js ></ script >

< script >

$ ( document ). ready ( function (){

$ ( “input:button” ). click ( function () {

var text = $ ( this ). val ();

$ ( “input:text” ). val ( text );

});

})

</ script >

</ head >

< body >

< div >

< input type =” button value =” First />

< input type =” button value =” Secont />

< input type =” button value =” third />

</ div >

< input type =” text value =” click a button />

</ body >

</ html >

پس از اجرا با کلیک روی هر دکمه مقدار value آن دکمه ها در تکست باکس نمایش می یابد .





آموزش jquery : فصل سوم : افکتهای jquery

فصل سوم :

jQuery Effects :

افکت ها توابعی هستند که بر روی نمایش عناصر صفحه عملیاتی انجام میدهند .

افکت های موجود : Hide, Show, Toggle, Slide, Fade , Animate

Hide & Show :

توسط دو تابع hide() و show() میتوانید عناصر صفحه را پنهان یا آشکار نمایید :

$(”#btnhide”).click(function(){
$(”p”).hide();
});
$(”#btnshow”).click(function(){
$(”p”).show();
});

در کد فوق هنگامی که روی عنصری در صفحه با آیدی btnhide کلیک شود پاراگرافهای درون صفحه (تگهای p ) پنهای میشوند و با کلیک روی عنصر با آیدی btnshow کلیک شود پاراگرافها نمایش میبابند .

این دو تابع دو پارامتر speed و callback نیز می پذیرند :

$(selector).hide(speed,callback)

$(selector).show(speed,callback)

پارامتر speed میتوانید مقدارهای 'slow' , 'fast' , 'normal' و همچنین مقداری به میلی ثانیه بپذیرد .

پارامتر callback تابعی است که هنگامی که عمل show یا hide به طور کامل انجام شد صدا زده میشود .

$(”button”).click(function(){
$(”p”).hide(۱۰۰۰);
});

در مثال فوق با کلیک روی button پاراگراف p ظرف مدت ۱۰۰۰ میلی ثانیه پنهان میشود .

$(”button”).click(function(){
$(”p”).hide('slow',function(){ alert('hide is finished'); } );
});

در مثال فوق با کلیک روی button پاراگرافهای p بصورت آهسته پنهان میشوند و پس از پنهان شدن پیغام 'hide is finished' بر روی صفحه نمایش می یابد .

Toggle :

این افکت وضعیت عنصر مربوطه را از hide به show و بلعکس تبدیل میکند . یعنی اگر عنصر پنهان باشد با اجرای این افکت عنصر پیدا میشود و اگر پیدا باشد پنهان میشود .

$(”#line”).click(function(){
$(”#lineinfo”).toggle();
});

در کد فوق با کلیک روی عنصری با آیدی line مشخصات آن عنصر که در عنصر دیگری با آیدی lineinfo قرار دارد نمایش می یابد و با کلیک مجدد پنهان میشود .

این افکت هم همانند دو افکت قبلی دارای دو پارامتر speed و Callback می باشد .

Slide :

$(selector).slideDown(speed,callback)

این دستور selector را با سرعت speed به سمت پایین باز میکند .

$(selector).slideUp(speed,callback)

این دستور selector را با سرعت speed به سمت بالا جمع میکند ( hide )

$(selector).slideToggle(speed,callback)

این دستور نیز selector را بین دو وضعیت باز و بسته تعویض مینماید .

پارامتر های این توابع هم مانند افکت های قبلی تنظیم میشوند .

Fade :

این افکت ها نیز برای نمایش و پنهان کردن عنصر استفاده میشود با این تفاوت که نوع پنهان کردن و نمایش دادن عناصر در این دستوران متفاوت است و با تغییر شفافیت ) opacity ) انجام میشود.

$(selector).fadeIn(speed,callback)

این تابع عنصر selector را در صفحه نمایان میکند .

$(selector).fadeOut(speed,callback)

این تابع عنصر selector را در صفحه مخفی میکند .

$(selector).fadeTo(speed,opacity,callback)

این تابع پارامتری به عنوان opacity میپذیرد که میزان شفافیت را بین دو عدد ۰ و ۱ تعیین میکند که عدد ۱ یعنی کاملا آشکار و عدد ۰ یعنی پنهان و عنصر را بع اندازه عدد شفافیت ، شفاف میکند .

For example:

$(”button”).click(function(){

$(”div”).fadeTo(”slow”,۰.۲۵);

});

در کد فوق با کلیک روی button عنصر div درون صفحه به آرامی شفاف میشود تا به ۲۵ درصد شفافیت برسد .

Custom Animation :

$(selector).animate({params},[duration],[easing],[callback])

پارامتر params پارامترهایی را میپذیرد که قرار است همزمان با هم بر روی selector اعمال شوند .

For example:

animate({width:”۷۰%”,opacity:۰.۴,marginLeft:”۰.۶in”,fontSize:”۳em”});

تمام پارامتر ها درون {} نوشته میشوند و با کاما ',' از هم جدا میشوند . هر پارامتر با عنوان و سپس “:” و بعد مقدار آن مشخص میشود .

پارامتر duration مانند پارامتر speed در افکت های قبلی عملی میکند که میتواند مقادیر 'slow' , 'fast' , normal و یا عددی به میلی ثانیه را در بر بگیرد .

<script type=”text/javascript”>
$(document).ready(function(){
$(”#start”).click(function(){
$(”#box”).animate({left:”۱۰۰px”},”slow”);
$(”#box”).animate({fontSize:”۳em”},”slow”);
});
});
</script>

در قطعه کد فوق وقتی روی عنصر با آیدی start کلیک میشود عنصر #box در صفحه اول ۱۰۰ پیکسل به سمت چپ رفته و سپس نوشته های داخلش به اندازه ۳em خواهد شد .

میتوان خطهای ۴ و ۵ را در یک خط نوشت :

$(”#box”).animate({left:”۱۰۰px”, fontSize:”۳em”},”slow”);

که البته در این حالت هر دو مقدار همزمان با هم به #box اعمال خواهد شد.

نکته : تابع stop() هم برای متوقف کردن افکت در حال اجرا استفاده میشود :

$(selector).stop();

نکته مهم : میتوان توابع را بجای نوشتن در خطهای جداگانه ، پشت سر هم به یک عنصر اعمال کرد مثلا :

$('#box').fadeIn(۱۰۰۰);

$('#box').animate({left:”۱۰۰px”},'slow');

$('#box').fadeOut(۱۰۰۰);

بجای کدهای فوق که همه بر روی یک عنصر اعمال میشوند میتوان نوشت :

$('#box').fadeIn(۱۰۰۰).animate({left:”۱۰۰px”},'slow').fadeOut(۱۰۰۰);

سوال : چرا تابع Callback باید استفاده شود ؟

گاهی اوقات ما نیاز داریم عملی را دقیقا بعد از اعمال کامل یک افکت اجرا کنیم .

به مثال زیر توجه نمایید :

$(”button”).click(function(){
$(”p”).hide(۱۰۰۰);
alert(”The paragraph is now hidden”);
});

در این مثال ما میخواهید هنگامی که پاراگراف به طور کامل پنهان شد عبارت “ the paragraph is now hidden ” نمایش یابد . اما در عمل این اتفاق نمی افتد زیرا در حین انجام عمل hide خط بعدی فرمان صدا زده خواهد شد و این امر باعث تداخل خواهد شد .

اما به این مثال دقت نمایید :

$(”button”).click(function(){
$(”p”).hide(۱۰۰۰,my_alert);
});

function my_alert()
{
alert(”The paragraph is now hidden”);
}

در این مثال از تابع my_alert به عنوان تابع Callback استفاده شده . در این حالت دقیقا بعد از اتمام افکت hide تابع my_alert صدا زده میشود .

مثال : در مثال زیر قصد داریم تعدادی لینک در صفحه قرار دهیم که با رفتن موس روی آنها توضیح مختصر با افکت مناسب نمایش یابد :

< html >

< head >

< script type =” text/javascript src =” jquery.js ></ script >

< script type =” text/javascript >

$ ( document ). ready ( function (){

$ ( 'a' ). mouseover ( function (){

$ ( this ). next ( 'div.info' ). slideDown ( 'slow' );

})

$ ( 'a' ). mouseout ( function (){

$ ( this ). next ( 'div.info' ). slideUp ( 'slow' );

});

});

</ script >

< style >

ul {

list-style : none ;

margin : ۰ ;

padding : ۰ ;

}

ul li {

padding : ۳px ;

background : #EEE ;

border : ۱px solid #۰۰۰۰۰۰ ;

width : ۲۰۰px ;

margin : ۲px ;

}

.info {

padding : ۵px ;

background : #FFF ;

color : #۰۰۰ ;

display : none ;

}

</ style >

</ head >

< body >

< ul >

< li >

< a href =” http://blog.monavarian.ir > Blog.Monavarian.ir </ a >

< div class =” info > mohsen monavarian Weblog </ div >

</ li >

< li >

< a href =” http://share.wanted.ir > wanted.ir </ a >

< div class =” info > The First shared TextBoxes in Iran </ div >

</ li >

< li >

< a href =” http://www.res۲ran.com > Res۲Ran.com </ a >

< div class =” info > Shiraz restuarants And FastFoods Guide , Food instructions </ div >

</ li >

</ ul >

</ body >

</ html >

همانطور که در کد بالا مشاهده میکنید در قسمت کد jquery دو تابع برای رویدادهای mouseover و mouseout تگهای a (لینکهای صفحه ) نوشته شده که تابع اولی باعث نمایش تگ div.info با افکت slideDown میشود و تابع دومی نیز با افکت slideUp تگ را مخفی می کند .

شما میتوانید به جای slideDown و slideUp از افکت های دیگری که در این فصل بیان شد استفاده نمایید .

نکته : تابع next :

$(selector۱).next(selector۲);

این تابع به دنبال عناصر انتخابی مطابق با selecotr۲ میگردد که پس از عنصر selector۱ در صفحه موجود باشد . مثلا در کد بالا دنبال اولین عنصر div با کلاس info بعد از عنصر جاری (که همان تگ a انتخاب شده است ) می گردد .





فیلمنامه کوتاه “آنچه فرشته گفت…” نوشته محمدرضا احمدزاده

متن زیر فیلمنامه کوتاهی است تحت عنوان “آنچه فرشته گفت ” که آقای محمد رضا احمد زاده برامون ارسال کرده اند .

فيلمنامه «آنچه فرشته گفت…»

نويسنده: محمدرضا احمدزاده

خانه- جلوي در ورودي- روز

تصوير قسمت زيرين درِ خانه ديده مي شود. پس از چند لحظه در باز مي شود و پاي مردي كه وارد خانه شده در كادر قرار مي گيرد.

برش به:

دستشويي- چند دقيقه بعد

تصوير قدم هاي همان مرد ديده مي شود كه وارد دستشويي مي شود. دوربين گام هاي آهسته مرد را دنبال مي كند تا اينكه به سينك صورتشويي مي رسد. دوربين بالا مي رود و تصوير مرد را در آينه نشان مي دهد كه به خود مي نگرد. صداي مرد از بيرون قاب تصوير شنيده مي شود.

مرد(بيرون قاب) از آخرين نوشته اي كه روانه دنياي زيباي كاغذهاي

كاهي كرده بودم ماه ها مي گذشت.

مرد شير آب را باز كرده و شروع به شستن صورتش مي كند.

مرد (بيرون قاب) جمعه بود و مثل همه جمعه ها … دلگير… خسته

كننده و كسالت آور…

مرد شير آب را مي بندد و با صورت خيس به تصوير خود در آينه مي نگرد.

برش به:

اتاق- شب – داخلي

مرد در كنار پنجره اتاقش ايستاده و به چراغ هاي روشني كه در تاريكي شهر نمايانند نگاه مي كند، اما هيچ حسي در چشمانش نيست.

مرد (بيرون قاب) مدت ها بود كه ديگه مثل سالهاي نوجواني كه

دست از قلم و كاغذ برنمي داشتم عاشق نبودم…

فكرم خشك و خشن شده بود…

من هيچوقت براي شعر گفتن فكر نميكردم… شعر خودش

قلم رو در دستم ميگذاشت ؛ انگشتهام رو به قلم مي فشرد

و كلمات رو بر كاغذ جاري مي كرد… اما اون شب اولين باري

بود كه آگاهانه انتظار شعري رو ميكشيدم ؛ اما شعري نيومد!

ميخواستم به كسي زنگ بزنم تا كمي باهاش حرف بزنم… اما

نميدونستم … نميدونستم دقيقا با چه كسي چه كاري دارم…

كسي هم به من زنگ نمي زد.

مرد از پنجره فاصله مي گيرد و با گامهاي آهسته از كادر خارج مي شود.

دوربين به سمت پنجره كه نمايي نسبتا زيبا از شهر را به ما مي نماياند نزديك ميشود.

مرد (بيرون قاب) انگار همان شب تمام شلوغي هاي دنيا

خاموش شده بود.

برش به:

سمتي ديگر از اتاق- چند دقيقه بعد

تمام چراغ هاي اتاق روشن است. مرد برروي تخت خواب دراز كشيده و چشم هايش را بسته است.

مرد (بيرون قاب) ميخواستم گريه كنم اما اشكهام بيرون نمي آمدند

و در عوض از درون ذره ذره منو ميخوردند.

از قبل همه برقهاي اتاقم رو روشن گداشتم تا وقتي

چشمهام رو مي بندم فقط سياهي نبينم…

تا شايد كمي نور تو اونهمه سياهي از ديواره پلكهام

به مردمك تيره چشمام نفوذ كنه … اما اون شب نور

تو هيچ معبري نمي گنجيد.

مرد از جايش بر مي خيزد و به سمت كليد برق مي رود و آن را مي زند. تعدادي از چراغها خاموش مي شوند. او به سمتي ديگر رفته و كليد ديگري را مي زند.

اتاق كاملا تاريك است. از نمايي بسته تصوير صورت مرد در تاريكي ديده ميشود.

به كمك نورضعيفي كه از بيرون وارد اتاق مي شود ميز تحرير او در حاليكه يك چراغ مطالعه روي آن وجود دارد ديده ميشود. ناگهان چراغ مطالعه روشن ميگردد. مرد باسرعت و به گونه اي كه وحشت در چشمهايش موج مي زند به سمت ميز و چراغ برميگردد. به سمت ميز ميرود و به آن مي رسد. از ديد مرد تصوير چراغ روشن و چند برگ كاغذ و خودكاري برروي آنها ديده ميشود. مرد به سيم برق چراغ نگاه ميكند. آن را مي گيرد و تا انتهاي آن دنبال مي كند. تا اينكه به دوشاخه آزاد چراغ مي رسد كه بر روي زمين افتاده است. او با ترس از ميز دور مي شود. نگاهي دوباره به چراغ مي كند و سپس از هوش مي رود و برروي تخت مي افتد.

برش به:

اتاق- چندي بعد

براي چند لحظه تنها سياهي ديده مي شود.

مرد (بيرون قاب) شبيه فرشته هايي بود كه مادربزرگها

نشاني اونا رو به بچه ها ميدن… اما من هرگز

مادربزرگم رو نديده بودم كه برام تعريف كرده باشه

تا بفهمم كه اون فرشته بود… يا نه…

از ديد مرد: پلكهاي او به آرامي باز ميشود و تصوير روشن مي گردد. اتاق بسيار روشن است. اولين چيزي كه ديده مي شود دختري است با صورتي نوراني و لباس سراسر سفيد كه در مقابل او ايستاده است.

دختر بلند شو…

دختر دست مرد را گرفته و به او كمك مي كند تا برخيزد. سپس او را به سمت ميز تحريرش مي آورد. مرد روي ميز تحرير مي نشيند.

مرد(بيرون قاب) چيزي تو گوشم گفت كه بعد از اون شب هرچه

سعي كردم نتونستم به ياد بيارم…

دختر چيزي درگوش مرد مي گويد. سپس قلم را بر ميدارد و در دستان او ميگذارد

و دستهايش را بر قلم مي فشارد.

دختر (باصدايي طنين انداز) بنويس… هرچه بايد بنويسي بنويس!

مرد هنوز چشم از صورت او برنداشته است.

دختر بنويس…

مرد از او روي برميگرداند و شروع به نوشتن مي كند.

تصوير دست مرد و نوشته هايش ديده مي شود. درحاليكه صداي مرد شنيده ميشود كه آنچه مينويسد در ذهن تكرار ميكند.

مرد(بيرون قاب) به صداي قدم هاي منتظرانه كوچه گوش مي كنم.

او هم عزم خوابيدن نكرده…

او هم در انتظار است. گويي كسي قرار است در

واپسين ساعات تاريكي بغض صدا را بشكند…

كوچه به فكر گريه ايست كه كسي برايش صدا ميشود

كسي برايش اشك مي شود. ميگويند او هرشب به

كوچه سر ميزند… من كه هنوز نخوابيدم… ولي چرا

وقتي صداي پاهايش را مي شنوم ديگر بيدار نيستم…

ديگر بيدار نيستم.

ديزالو به:

همانجا- چند ثانيه بعد

مرد درحاليكه قلم در دست دارد به خوابي عميق فرو رفته است.

دوربين از بالاي سر او ارتفاع ميگيرد و محيط اتاق را نشان مي دهد. درحاليكه مرد خوابيده و هيچ جزئي حركت نمي كند و اثري هم از فرشته نيست.

ارسال شده در ۱۶ اسفند ۱۳۸۸