edwinhaq/yii2-simple-loading

简单加载

安装量: 23,524

依赖者: 1

建议者: 0

安全性: 0

星标: 3

关注者: 1

分支: 4

开放问题: 0

类型:yii2-extension

1.0.1 2017-10-31 03:23 UTC

This package is auto-updated.

Last update: 2024-09-14 08:15:31 UTC


README

为 Yii 2.0 或更高版本的框架提供的简单加载小部件

描述

edwinhaq\simpleloading\SimpleLoading 小部件是显示加载屏幕的简单方法。

需求

  • Yii 版本 2.0.0 或更高

安装

安装此扩展的首选方式是通过 composer

运行以下命令

php composer.phar require --prefer-dist edwinhaq/yii2-simple-loading "*"

或者在您的 composer.json 文件的 require 部分添加以下内容

"edwinhaq/yii2-simple-loading": "*"

使用方法

扩展安装后,只需在 PHP 代码中使用它即可

	// ...
	use edwinhaq\simpleloading\SimpleLoading;
	// ...
	SimpleLoading::widget();
	// ...

在 JavaScript 中调用 start 和 stop 以控制加载小部件

	/*
	 * start(image type)
	 * Allows to start the loading image and select the image to show
	 * options: [box, clock, default, gears, hourglass, magnify, reload, ring-alt, ring, ripple, rolling]
	 */
	SimpleLoading.start('gears'); 	// Load gears.gif
	SimpleLoading.start('default'); // Load default.gif
	SimpleLoading.start(); 			// Load default.gif

	/*
	 *
	 * Allows to stop the loading image
	 */
	SimpleLoading.stop();


	// Example:

	$.ajax(
		{
			'type':'POST',
			'dataType':'json',
			'url':'index.php?r=controller/action',
			'beforeSend':function(json)
			{
				SimpleLoading.start('gears');
			},
			'success':function(json){/* ... */},
			'error':function(json,status,errorThrown ){/* ... */},
			'complete':function(json)
			{
				SimpleLoading.stop();
			},
			'cache':false,
			'data':jQuery(this).parents("form").serialize()
		}
	);

历史

  • 版本 1.0.0 (2017-05-30)
    • 在 Yii 2.0.6 上测试
  • 版本 1.0.1 (2017-10-30)
    • 在 Yii 2.0.12 上测试