进度条最近变得很受欢迎,并且有大量的插件可以帮助你添加一个到您的网站。在本教程中,我们将代码不同的东西——建在进度条的按钮。 他们将适合显示进展而通过AJAX提交表单或加载内容。他们还将使用CSS3风格和转换使其容易定制。assets/js/script.js$(document).ready(function(){ // Convert all the links with the progress-button class to // actual buttons with progress meters. // You need to call this function once the page is loaded. // If you add buttons later, you will need to call the function only for them. $('.progress-button').progressInitialize(); // Listen for clicks on the first three buttons, and start // the progress animations $('#submitButton').click(function(e){ e.preventDefault(); // This function will show a progress meter for // the specified amount of time $(this).progressTimed(2); }); $('#actionButton').click(function(e){ e.preventDefault(); $(this).progressTimed(2); }); $('#generateButton').one('click', function(e){ e.preventDefault(); // It can take a callback var button = $(this); button.progressTimed(3, function(){ // In this callback, you can set the href attribute of the button // to the URL of the generated file. For the demo, we will only // set up a new event listener that alerts a message. button.click(function(){ alert('Showing how a callback works!'); }); }); }); // Custom progress handling var controlButton = $('#controlButton'); controlButton.click(function(e){ e.preventDefault(); // You can optionally call the progressStart function. // It will simulate activity every 2 seconds if the // progress meter has not been incremented. controlButton.progressStart(); }); $('.command.increment').click(function(){ // Increment the progress bar with 10%. Pass a number // as an argument to increment with a different amount. controlButton.progressIncrement(); }); $('.command.set-to-1').click(function(){ // Set the progress meter to the specified percentage controlButton.progressSet(1); }); $('.command.set-to-50').click(function(){ controlButton.progressSet(50); }); $('.command.finish').click(function(){ // Set the progress meter to 100% and show the done text. controlButton.progressFinish(); });});// The progress meter functionality is available as a series of plugins.// You can put this code in a separate file if you wish to keep things tidy.(function($){ // Creating a number of jQuery plugins that you can use to // initialize and control the progress meters. $.fn.progressInitialize = function(){ // This function s the necessary markup for the progress meter // and sets up a few event listeners. // Loop through all the buttons: return this.each(function(){ var button = $(this), progress = 0; // Extract the data attributes into the options object. // If they are missing, they will receive default values. var options = $.extend({ type:'background-horizontal', loading: 'Loading..', finished: 'Done!' }, button.data()); // Add the data attributes if they are missing from the element. // They are used by our CSS code to show the messages button.attr({'data-loading': options.loading, 'data-finished': options.finished}); // Add the needed markup for the progress bar to the button var bar = $('
文件目录······
暂无数据
猜你喜欢
更多»
项目推荐
更多»
PDF电子书
更多»
Java多线程编程核心技术
(2)
Linux命令详解词典.pdf
(5)
深入Python3中文版
(0)
百度SEO一本通.pdf
(0)
mysql必知必会.pdf
(2)
疯狂JAVA讲义 pdf电子书
(3)
C# 图解教程pdf电子书
(3)
研磨设计模式 pdf电子书
(0)