Showing posts with label Web Development. Show all posts
Showing posts with label Web Development. Show all posts

Thursday, July 21, 2011

5 sliders content for jQuery


Sliders are powerful tools to highlight content on a website. This article gives you five options jQuery plugins to implement this functionality.

Nivo Slider - Site | Demo


The strong Nivo Slider is a clean HTML for the initial structure of the slider. Only a div element with pictures and links is necessary. The main focus of this slider are images, but the HTML caption feature just enabling the display of any content.

Among the options offered are the speed and direction of the transition and callbakcs to perform actions after the start and loading of the slides. The plugin still has no more and no less than 16 choices of transition from one slide to another. Its compressed version has 15kb.

Coda Slider  - Site | Demo


This plugin has emerged based on the application site Slider Coda . Each element of the slide should be a div element with class "panel".

Coda Slider leaves something to be desired flexibility, offering few options but to display different types of content is most appropriate plugin.

Orbit  - Demo


Originally developed to be a slider images, Orbit also incorporating HTML content just as long as the content div element contains a background set.

Its compressed version is very light, and another differential 3.2kb cool Orbit is the application of a loader marking the transition time between slides.

Anything Slider  - Site | Demo


As the name suggests, the AnythingSlider accepts all and any type of content. In the words of the author, "the plugin is an attempt to gather all of the features found in other plugins of this type."

It is the most adptável plugin and integrates better with the rest of your application oferencendo own hashtags for each slide and the possibility of creating a direct link to a slide.

Moodular  - Demo


The neat thing is Moodular, as well as the name suggests, is modular, core, control and effects. So if you need a simple slider is not necessary to load the control module, for example.

The effects of Moodular module includes the popular "reflection" (the one from Apple) and the control has built in support for touchscreen applications, and keyboard navigation.

5 sliders content for jQuery


Sliders are powerful tools to highlight content on a website. This article gives you five options jQuery plugins to implement this functionality.

Nivo Slider - Site | Demo


The strong Nivo Slider is a clean HTML for the initial structure of the slider. Only a div element with pictures and links is necessary. The main focus of this slider are images, but the HTML caption feature just enabling the display of any content.

Among the options offered are the speed and direction of the transition and callbakcs to perform actions after the start and loading of the slides. The plugin still has no more and no less than 16 choices of transition from one slide to another. Its compressed version has 15kb.

Coda Slider  - Site | Demo


This plugin has emerged based on the application site Slider Coda . Each element of the slide should be a div element with class "panel".

Coda Slider leaves something to be desired flexibility, offering few options but to display different types of content is most appropriate plugin.

Orbit  - Demo


Originally developed to be a slider images, Orbit also incorporating HTML content just as long as the content div element contains a background set.

Its compressed version is very light, and another differential 3.2kb cool Orbit is the application of a loader marking the transition time between slides.

Anything Slider  - Site | Demo


As the name suggests, the AnythingSlider accepts all and any type of content. In the words of the author, "the plugin is an attempt to gather all of the features found in other plugins of this type."

It is the most adptável plugin and integrates better with the rest of your application oferencendo own hashtags for each slide and the possibility of creating a direct link to a slide.

Moodular  - Demo


The neat thing is Moodular, as well as the name suggests, is modular, core, control and effects. So if you need a simple slider is not necessary to load the control module, for example.

The effects of Moodular module includes the popular "reflection" (the one from Apple) and the control has built in support for touchscreen applications, and keyboard navigation.

Wednesday, July 20, 2011

Top Reasons to Firefox even better than Chrome for web development

Some time ago, some of us, web developers, we changed the Firefox Google Chrome because of the important features such as speed.

With the release of Firefox 4, it solved some of the problems we had in past versions, leaving it better, at least when it comes to web development.

This article, divided into two parts, explains some of the reasons why the Firefox browser is still a better than Google Chrome for your web development work.

Evolution of the market share of browsers

About a year ago, I talked about something most of us already knew, that PHP developers are switching to Google Chrome as its web browser access.

As you can see in the table below, this trend continues to be true this year. These numbers were taken from statistics developers PHP Classes logged in to the site .

Browser
May 2009
May 2010
May 2011
Change
Mozilla Firefox
68.0%
63.5%
57.3%
-6.2%
Microsoft IE
18.5%
13.6%
8.9%
-4.7%
Google Chrome
6.0%
15.7%
28.1%
+12.4%

As you can see, Chrome almost doubled its share in a year, while Internet Explorer has lost a little more than half. Firefox also fell slightly.

The gain of Chrome is greater than the loss of the Firefox and Internet Explorer. This means that Chrome also gained share lost to other browsers.

Reasons to Firefox even better than Chrome for web development

Given the fact that the participation of Google Chrome continues to grow enough, you may wonder why on this article. The fact that Chrome will continue to become increasingly popular for web browsing does not mean that web developers are also working with him in his projects. For me, this is not the case. Often when I'm doing development work, I feel I need to switch to Firefox, for reasons which I will list below.

I wish they had in mind that this article is not a rant against Google, which gave us web developers a lot to be grateful to him, but when we speak of Chrome, there is still much to be improved.

I decided to write this article now in the hope that maybe someone at Google to read, and do something to resolve these issues, most of the time, really bother most of us, since we do not keep changing all the time browsers .

1. View HTML

When the code of our sites have bugs, it usually generates an HTML code that is incorrect or invalid. So we need to analyze the HTML code to understand what's wrong. Firefox has an amazing feature that allows you to select a portion of the page and it shows the exact HTML that corresponds to that portion of the selected page. This feature does not exist in Chrome.

The best you have is the Inspect Element feature, which allows you to find the HTML code for the page element below the cursor of your mouse. Not the same thing. If I select a region of the page, I want to see the full HTML of that region, not a single element.

Another annoying thing is that Chrome tries to make the HTML pretty. This means that if you have a malformed HTML, you will not see where he is malformed because Chrome will show an embellished version of the HTML code after it has been repaired. I wish they had an option to disable.

2. Validation of HTML

Another great feature of Firefox is the ability to display any validation errors of HTML that you may have. In fact, this feature is provided by the extension HTML Validator .

I tested several extensions with the same goal in Chrome, but nothing that was really good. Some just used the W3C validation service through the page's URL, which is not good, because when you are developing a page that is not public service W3C can not access it, and any user logged into the site you is developing can not access it.

Other extensions have tried to copy the currently loaded page and pass it to the validation service, but none showed any invalid HTML code that the Firefox extension HTML Validator shows.

It also does not rely on an external validation service. That means you can validate pages even if you do not have internet access. So for all these reasons, an equivalent version of the HTML Validator extension is sorely needed for Chrome.

3. Disable JavaScript

Sometimes you need to test your site with JavaScript disabled. The only way to disable it in Chrome is going to preferences and disable. This is truly annoying. In Firefox, you can use the extension Web Developer by Chris Pederick to add a button to the browser to quickly disable and re-enable JavaScript when you want.

In Chrome, there is also the extension Web Developer the same developer, but it provides no means to disable JavaScript. The problem is due to the limitation of the API exposed to Chrome extensions. It does not allow a way to disable JavaScript from extensions.

There is a request for funding for the project Chromium to implement the necessary support to disable JavaScript. Implementing this feature was actually given a year ago, but it never happened. Oddly, users have been banned from posting future comments on the application of this feature.

4. Empty the browser cache

Sometimes you need to force the cleanup of the browser cache, so that new content can be recovered from the site server you are developing.

It is the same limitation to disable JavaScript. You can not do this through an extension. You need to go in the preferences of Chrome.

There is also a feature request to enable support for clearing the cache from an extension. It was made more than two years, but only a few months ago was released for implementation.

5. Changing the agent identifier of the browser

Sometimes you need to access your site pretending to be developing using another browser, so you can see if it fits to that browser the way you expect.

For example, if you are serving an RSS feed to be handled by Feedburner, all you need to redirect browsers to the URL of the Feedburner feed, unless the current agent is checking if your Feedburner feed has been updated. Therefore, it would be helpful if you could cause the browser to pretend to be the Feedburner, so you could check if he was working as it should.

In Firefox, you can use the extension User Agent Switcher also Chris Pederick. In Chrome, there is also an extension called User Agent Switcher . The problem is that it does not work. Good works, but not the way you want. The extension can only change the browser identification exposed to JavaScript. This means that HTTP requests sent to the server will not use the string identifying the agent that you need to be sent.

I suspect that an application for resource to be implemented in Chromium, but not found. Until this feature is implemented, we will always have to go back to Firefox, which works well with the User Agent Switcher extension.

Top Reasons to Firefox even better than Chrome for web development

Some time ago, some of us, web developers, we changed the Firefox Google Chrome because of the important features such as speed.

With the release of Firefox 4, it solved some of the problems we had in past versions, leaving it better, at least when it comes to web development.

This article, divided into two parts, explains some of the reasons why the Firefox browser is still a better than Google Chrome for your web development work.

Evolution of the market share of browsers

About a year ago, I talked about something most of us already knew, that PHP developers are switching to Google Chrome as its web browser access.

As you can see in the table below, this trend continues to be true this year. These numbers were taken from statistics developers PHP Classes logged in to the site .

Browser
May 2009
May 2010
May 2011
Change
Mozilla Firefox
68.0%
63.5%
57.3%
-6.2%
Microsoft IE
18.5%
13.6%
8.9%
-4.7%
Google Chrome
6.0%
15.7%
28.1%
+12.4%

As you can see, Chrome almost doubled its share in a year, while Internet Explorer has lost a little more than half. Firefox also fell slightly.

The gain of Chrome is greater than the loss of the Firefox and Internet Explorer. This means that Chrome also gained share lost to other browsers.

Reasons to Firefox even better than Chrome for web development

Given the fact that the participation of Google Chrome continues to grow enough, you may wonder why on this article. The fact that Chrome will continue to become increasingly popular for web browsing does not mean that web developers are also working with him in his projects. For me, this is not the case. Often when I'm doing development work, I feel I need to switch to Firefox, for reasons which I will list below.

I wish they had in mind that this article is not a rant against Google, which gave us web developers a lot to be grateful to him, but when we speak of Chrome, there is still much to be improved.

I decided to write this article now in the hope that maybe someone at Google to read, and do something to resolve these issues, most of the time, really bother most of us, since we do not keep changing all the time browsers .

1. View HTML

When the code of our sites have bugs, it usually generates an HTML code that is incorrect or invalid. So we need to analyze the HTML code to understand what's wrong. Firefox has an amazing feature that allows you to select a portion of the page and it shows the exact HTML that corresponds to that portion of the selected page. This feature does not exist in Chrome.

The best you have is the Inspect Element feature, which allows you to find the HTML code for the page element below the cursor of your mouse. Not the same thing. If I select a region of the page, I want to see the full HTML of that region, not a single element.

Another annoying thing is that Chrome tries to make the HTML pretty. This means that if you have a malformed HTML, you will not see where he is malformed because Chrome will show an embellished version of the HTML code after it has been repaired. I wish they had an option to disable.

2. Validation of HTML

Another great feature of Firefox is the ability to display any validation errors of HTML that you may have. In fact, this feature is provided by the extension HTML Validator .

I tested several extensions with the same goal in Chrome, but nothing that was really good. Some just used the W3C validation service through the page's URL, which is not good, because when you are developing a page that is not public service W3C can not access it, and any user logged into the site you is developing can not access it.

Other extensions have tried to copy the currently loaded page and pass it to the validation service, but none showed any invalid HTML code that the Firefox extension HTML Validator shows.

It also does not rely on an external validation service. That means you can validate pages even if you do not have internet access. So for all these reasons, an equivalent version of the HTML Validator extension is sorely needed for Chrome.

3. Disable JavaScript

Sometimes you need to test your site with JavaScript disabled. The only way to disable it in Chrome is going to preferences and disable. This is truly annoying. In Firefox, you can use the extension Web Developer by Chris Pederick to add a button to the browser to quickly disable and re-enable JavaScript when you want.

In Chrome, there is also the extension Web Developer the same developer, but it provides no means to disable JavaScript. The problem is due to the limitation of the API exposed to Chrome extensions. It does not allow a way to disable JavaScript from extensions.

There is a request for funding for the project Chromium to implement the necessary support to disable JavaScript. Implementing this feature was actually given a year ago, but it never happened. Oddly, users have been banned from posting future comments on the application of this feature.

4. Empty the browser cache

Sometimes you need to force the cleanup of the browser cache, so that new content can be recovered from the site server you are developing.

It is the same limitation to disable JavaScript. You can not do this through an extension. You need to go in the preferences of Chrome.

There is also a feature request to enable support for clearing the cache from an extension. It was made more than two years, but only a few months ago was released for implementation.

5. Changing the agent identifier of the browser

Sometimes you need to access your site pretending to be developing using another browser, so you can see if it fits to that browser the way you expect.

For example, if you are serving an RSS feed to be handled by Feedburner, all you need to redirect browsers to the URL of the Feedburner feed, unless the current agent is checking if your Feedburner feed has been updated. Therefore, it would be helpful if you could cause the browser to pretend to be the Feedburner, so you could check if he was working as it should.

In Firefox, you can use the extension User Agent Switcher also Chris Pederick. In Chrome, there is also an extension called User Agent Switcher . The problem is that it does not work. Good works, but not the way you want. The extension can only change the browser identification exposed to JavaScript. This means that HTTP requests sent to the server will not use the string identifying the agent that you need to be sent.

I suspect that an application for resource to be implemented in Chromium, but not found. Until this feature is implemented, we will always have to go back to Firefox, which works well with the User Agent Switcher extension.

Monday, July 18, 2011

How to link items to a UserControl - WPF

In this article we will see how to perform the binding controls within a UserControl to a WPF application.

And accomplish this task using:
  • The DataContext property of the user control.
Reviewing concepts

A UserControl is a control created from existing controls, adding these controls into a single control in order to optimize your code. It is indicated when you realize that there is a loop in the structure of which involved controls so that if you create a composite control, these controls with the data manipulation is facilitated.

Note: Do not confuse a User Control with a Custom Control in WPF. A Custom Control is a control derived from other control and is used when you create a control from the existing one to include a feature that has no existing control.

After the user control is created to use it just do the following:
  • Include a reference to the namespace of the user control, (and if the user control assembly is not in the same assembly);
  • Include the XAML control in the window where we want to use it.
We will see how to perform data binding to a ListBox control used on a UserControl.

Creating a WPF application

Open Visual Basic 2010 Express Edition and create a new application type WPF Application with the name UserControl_Binding.


On the Project menu, click Add New Item and select the template User Control (WPF), then enter the name macLista.xaml.


Note that the model exists Custom Control (WPF) which is different from User Control (WPF).

Then set the following XAML code for this user control that we create:

Download code now (notepad 4kb)

We define a user control with two first ListBox where the Listbox has the property ItemsSource linked to the current DataContext. Specifying Path =. is used to link to the source of current. Specify the Path =. is not required, can also be written like this: ItemsSource = "{Binding}".

The second ListBox gets ItemsSource MeuItemsSource dependency property. ItemsSource Since this property is linked to user control, you must specify the element whose property is linked to the listbox, then we have this way: ElementName = meuUserControl.

The layout of the ListBox control displays two and can be seen below: (Below is the XAML code).



Linking items to the UserControl in our application

Let us now use the UserControl macListBox we create in our application.

Open the file and the XAML code MainWindow.xaml will include the following statements:

Download your code now (notepad 1kb)

As shown below, we see the result of the inclusion of two lines of XAML code above:


Let us now define the file MainWindow.xaml code to use the user control and perform linking of items in the ListBox control.

Change the code MainWindow.xaml XAML file as shown below:


 Now all we have to do and set the data source file MainWindow.xaml.vb as the code below:

Imports System.Collections 
Imports System.Windows
Public Class MainWindow

Private _testaLista The List (Of String)

Public ReadOnly Property TestaLista () As List (Of String)
Get
If _testaLista Is Nothing Then
start ()
End If
Return _testaLista
End Get
End Property

Private Sub start ()
_testaLista = New List (Of String) ()
_testaLista.Add ("Jose Carlos Macoratti")
_testaLista.Add ("Ana Maria Fonseca.")
_testaLista.Add ("Miriam Estela Ribeiro.")
_testaLista.Add ("Jefferson-Day Andre")
_testaLista.Add ("Janice Rachel Smith.")
_testaLista.Add ("Mario Santos")
_testaLista.Add ("Jessica Lang Lima Bueno")
End Sub

End Class 

When we run the project the following happens:

The first user control in the first TabItem binds to TestaLista DataContext of the window.

After the first listbox in the user control is linked to the DataContext that will show the contents of TestaLista.

The result is shown below:


Although the dependency property defined in MeuItemsSource user control, not used in the example. To do so would have to set the user in control for the dependency property as follows:

Imports System.Collections 
Imports System.Windows
Imports System.Windows.Controls

Partial Public Class macLista
Inherits UserControl

Public Shared ReadOnly MeuItemsSourceProperty The DependencyProperty

Shared Sub New ()
macLista.MeuItemsSourceProperty DependencyProperty.Register =
("MeuItemsSource", GetType (IEnumerable), GetType (macLista))
End Sub

Public Property MeuItemsSource () As IEnumerable
Get
Return DirectCast (GetValue (macLista.MeuItemsSourceProperty), IEnumerable)
End Get
Set (ByVal value As IEnumerable)
SetValue (macLista.MeuItemsSourceProperty, value)
End Set
End Property
Sub New ()
End Sub
End Class

Then just set the file MainWindow.xaml another TabItem defined as follows:

Download your code now (notepad 132bytes)

Thus we show how to perform the binding in controls created by the user.
Get the complete project here: UserControl_Binding.zip

How to link items to a UserControl - WPF

In this article we will see how to perform the binding controls within a UserControl to a WPF application.

And accomplish this task using:
  • The DataContext property of the user control.
Reviewing concepts

A UserControl is a control created from existing controls, adding these controls into a single control in order to optimize your code. It is indicated when you realize that there is a loop in the structure of which involved controls so that if you create a composite control, these controls with the data manipulation is facilitated.

Note: Do not confuse a User Control with a Custom Control in WPF. A Custom Control is a control derived from other control and is used when you create a control from the existing one to include a feature that has no existing control.

After the user control is created to use it just do the following:
  • Include a reference to the namespace of the user control, (and if the user control assembly is not in the same assembly);
  • Include the XAML control in the window where we want to use it.
We will see how to perform data binding to a ListBox control used on a UserControl.

Creating a WPF application

Open Visual Basic 2010 Express Edition and create a new application type WPF Application with the name UserControl_Binding.


On the Project menu, click Add New Item and select the template User Control (WPF), then enter the name macLista.xaml.


Note that the model exists Custom Control (WPF) which is different from User Control (WPF).

Then set the following XAML code for this user control that we create:

Download code now (notepad 4kb)

We define a user control with two first ListBox where the Listbox has the property ItemsSource linked to the current DataContext. Specifying Path =. is used to link to the source of current. Specify the Path =. is not required, can also be written like this: ItemsSource = "{Binding}".

The second ListBox gets ItemsSource MeuItemsSource dependency property. ItemsSource Since this property is linked to user control, you must specify the element whose property is linked to the listbox, then we have this way: ElementName = meuUserControl.

The layout of the ListBox control displays two and can be seen below: (Below is the XAML code).



Linking items to the UserControl in our application

Let us now use the UserControl macListBox we create in our application.

Open the file and the XAML code MainWindow.xaml will include the following statements:

Download your code now (notepad 1kb)

As shown below, we see the result of the inclusion of two lines of XAML code above:


Let us now define the file MainWindow.xaml code to use the user control and perform linking of items in the ListBox control.

Change the code MainWindow.xaml XAML file as shown below:


 Now all we have to do and set the data source file MainWindow.xaml.vb as the code below:

Imports System.Collections 
Imports System.Windows
Public Class MainWindow

Private _testaLista The List (Of String)

Public ReadOnly Property TestaLista () As List (Of String)
Get
If _testaLista Is Nothing Then
start ()
End If
Return _testaLista
End Get
End Property

Private Sub start ()
_testaLista = New List (Of String) ()
_testaLista.Add ("Jose Carlos Macoratti")
_testaLista.Add ("Ana Maria Fonseca.")
_testaLista.Add ("Miriam Estela Ribeiro.")
_testaLista.Add ("Jefferson-Day Andre")
_testaLista.Add ("Janice Rachel Smith.")
_testaLista.Add ("Mario Santos")
_testaLista.Add ("Jessica Lang Lima Bueno")
End Sub

End Class 

When we run the project the following happens:

The first user control in the first TabItem binds to TestaLista DataContext of the window.

After the first listbox in the user control is linked to the DataContext that will show the contents of TestaLista.

The result is shown below:


Although the dependency property defined in MeuItemsSource user control, not used in the example. To do so would have to set the user in control for the dependency property as follows:

Imports System.Collections 
Imports System.Windows
Imports System.Windows.Controls

Partial Public Class macLista
Inherits UserControl

Public Shared ReadOnly MeuItemsSourceProperty The DependencyProperty

Shared Sub New ()
macLista.MeuItemsSourceProperty DependencyProperty.Register =
("MeuItemsSource", GetType (IEnumerable), GetType (macLista))
End Sub

Public Property MeuItemsSource () As IEnumerable
Get
Return DirectCast (GetValue (macLista.MeuItemsSourceProperty), IEnumerable)
End Get
Set (ByVal value As IEnumerable)
SetValue (macLista.MeuItemsSourceProperty, value)
End Set
End Property
Sub New ()
End Sub
End Class

Then just set the file MainWindow.xaml another TabItem defined as follows:

Download your code now (notepad 132bytes)

Thus we show how to perform the binding in controls created by the user.
Get the complete project here: UserControl_Binding.zip

Friday, July 15, 2011

Creating a plugin for jQuery


Learn how to create a plug-in for jQuery from scratch - the basics, options, compatibility and examples.

The Basics
A plugin is written as a method or function.

Creating a jQuery function

Syntax
The function must return this.each (..) to maintain the ability to "chaining" - so that the function can be used with one or several objects jQuery.

jQuery.fn.myFunction = function () {
this.each return (function () {
/ / Element-specific code here
});
};


Example

jQuery.fn.makeTextRed = function () {
this.each return (function () {
$ (This). Css ('color', 'red');
});
};
/ / Example usage

$ ('# My-div'). MakeTextRed () / / make text in "my-div" red

$ ('P'). MakeTextRed () / / make all red Paragraphs

Creating a jQuery method

Syntax
jQuery.myMethod = function () {
/ / Code here
};
Example
jQuery.sayHelloWorld = function () {

alert ('Hello World');

};
/ / Example usage

$. SayHelloWorld () / / alerts "Hello World"

Options


Let your plugin more flexible and user friendly as possible, using options. The method $. Extend () takes two or more objects as arguments and combines their contents within the first object.

Example
A function that sets the text color (red by default).

jQuery.fn.makeTextColored = function (settings) {
var config = {
'Color': 'red'
};
if (settings) {$. extend (config, settings);}
this.each return (function () {

$ (This). Css ('color', config.color);

});

};

Now we can choose to use this function passing the parameter settings or not.

$ ('# My-div'). MakeTextColored () / / make red text (default)
$ ('# My-div'). MakeTextColored ('blue') / / make text blue

Compatibility

Because the variable $ can be used by other plugins, use a technique "disguised" to make your plugin compatible future.

(Function ($) {
$. Fn.myFunction = function () {
this.each return (function () {
/ / Element-specific code here
});
};
}) (JQuery);

We went to the jQuery function, and we can now use jQuery for any outfit you want. So, instead of the $, you could use any valid JavaScript variable name.

A checklist of the jQuery plugin
  • This is a list of important points to remember when developing a jQuery plugin ( the jQuery.com ).
  • Name your file jquery. [Insert the plugin name]. Js, eg. jquery.debug.js.
  • All new methods are attached to the object jQuery.fn object, and all functions to the jQuery object.
  • For internal methods, this is a reference to the current jQuery object.
  • Any methods or functions that you attach must have a semicolon (;) at the end - otherwise the code will break when compressed.
  • Your method must return the jQuery object, unless it was explicitly noted otherwise.
  • Use this.each to iterate over the current set of matching elements.
  • Always attach the plugin to jQuery instead of $, so that users can use a custom outfit via noConflict ().
Templates jQuery plugin

These are good code templates to begin developing a jQuery plugin.
Template Function

(Function ($) {
$. Fn.myPlugin = function (settings) {
var config = {
'Foo': 'bar'
};
if (settings) {$. extend (config, settings);}
this.each return (function () {

/ / Element-specific code here

});

};

}) (JQuery);

Template Method

(Function ($) {
$. MyPlugin = function (settings) {
var config = {
'Foo': 'bar'
};
if (settings) {$. extend (config, settings);}
/ / Code here
return this;

};

}) (JQuery);

Example: jQuery Slideshow Plugin

I decided to use very simple examples so far that you might be familiar. The following example is a little more complex and can help you find your inspiration.

He uses the setInterval () together with the effects fadeOut () and fadeIn () jQuery to generate the cycle of any images within a HTML element.

Configuration

HTML


CSS

# Slideshow img {
display: none;
position: absolute;
}

JavaScript

(Function ($) {
$. SimpleSlideShow = function (selector, settings) {
/ / Settings
var config = {
'Delay': 2000,
'FadeSpeed': 500
};
if (settings) {$. extend (config, settings);}
/ / Variables

var obj = $ (selector);

var img = obj.children ('img');

var count = img.length;

var i = 0;
/ / Show first image

img.eq (0). show ();
/ / Run slideshow

setInterval (function () {

img.eq (i). fadeOut (config.fadeSpeed);

i = (i +1 == count)? 0: i +1;

img.eq (i). fadeIn (config.fadeSpeed);

}, Config.delay);
return this;

};

}) (JQuery);


Use

To activate the slideshow div # slideshow, we simply call it using the following JavaScript code:

Blog Archive

Rank