Plugin

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-15 12:41:31

软件介绍

A jQuery plugin to lazy load other plugins. Small and easy to use.

To register a plugin:

var plugin = $.plugin.register( url_of_the_file, names_to_register, settings );
or
var plugin = new $.plugin( url_of_the_file, names_to_register, settings );

names_to_register is a hash in this form:
{
$:'foo',
fn:['foo','bar']
}

That means the plugin will register(once loaded): $.foo, $.fn.foo and $.fn.bar.
For now, you can only register to those 2 namespaces. You can use 1 string or an array of names.

settings is an optional hash with these options:
{
cache:boolean, //default is true, use false to avoid caching
id:'some_name', //an id for the script, only necessary if another requires it
require:[ 'some_name', 'some_other_name' ], //ids of the plugins required
sync:boolean //must be loaded sync ? false by default, use it if the call modifies the 'this'
}

Once a call to the plugin is done, the plugin will be loaded, that call will be taken into account and you can even use chaining with this fake call. so $('a').foo().bar() will work perfectly.

The plugin objects have methods( queue, add, check, load, preload, etc ) will explain them soon(sorry).
One useful data stored in the object is plugin.url, which contains the src of the plugin.

You can use bind/unbind/trigger on the plugin objects, and $.plugin itself for global calls.
When a plugin starts loading, the event 'loading' is triggered, it receives the plugin object as 2nd argument.
When finally loaded, the event 'loaded' is triggered.

Example

//registers $.scrollTo and $.fn.scrollTo
$.plugin.register('scrollTo.js',{$:'scrollTo', fn:'scrollTo'},{ id:'ST'});
//registers $.localScroll and $.fn.localScroll, needs ScrollTo first
$.plugin.register('localScroll.js', {$:'localScroll', fn:'localScroll'},{require:'ST'});

And that's it, you can safely call scrollTo or LocalScroll whenever you want, and then, and only then, the plugin will be requested.

Known issues:
-Remote scripts cannot be sync (jQuery limitation).
-Mixing remote and local plugins in a chain seems to cause problems sometimes.

本文地址:https://codercto.com/soft/d/23431.html

参与的胜利

参与的胜利

亨利·詹金斯 / 高芳芳 / 浙江大学出版社 / 2017-9-30 / CNY 42.00

《参与的胜利:网络时代的参与文化》是一场学者之间的对话,三位学者(亨利·詹金斯、伊藤瑞子和丹娜·博伊德)虽然来自不同的代际、不同的学科背景,但他们在相同的参与文化项目中展开合作,并试图解决相似的问题。 希望《参与的胜利:网络时代的参与文化》能够进一步激发团体内部及团体之间的对话,这些团体包括教育者、政策制定者、学者、关注参与文化的公民、业内人士、粉丝及其他任何关心我们文化的未来的人。理想的参......一起来看看 《参与的胜利》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具