dialog_obj(别名):

Widget_obj(别名):

调用widget方法

$.widget("ui.dialog",dialog_obj);  //  jquery.ui.dialog.js文件第27行 

	   //widget方法位于 jquery.ui.widget.js 文件第27行 

变量赋值:

prototype=dialog_obj
base=Widget_obj

定义构造函数

	$[ namespace ][ name ] = function( options, element ) {
// allow instantiation without initializing for simple inheritance
if ( arguments.length ) {
this._createWidget( options, element );
}
};//<pre name="code" class="javascript">//以上代码位于 jquery.ui.widget.js 文件第44行

 以上代码作用:

jQuery.ui.dialog=function(){};//定义一个名为dialog类的构造函数

创建Widget_obj类的实例对象

var basePrototype = new base();

设置dialog类的原型对象

$[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
namespace: namespace,
widgetName: name,
widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
widgetBaseClass: fullName
}, prototype );

通过extern方法将basePrototype与prototype两者进行合并,两个对象中出现同名属性,

后者将前者覆盖,并将basePrototype作为返回值赋值给dialog类的原型对象,

如:

Widget_obj中_init,_create,destroy等方法被dialog_obj的_init,_create,destroy覆盖

创建dialog插件

$.widget.bridge( name, $[ namespace ][ name ] );//name="dialog" ,jQuery.ui.dialog
$.fn[ name ] =function(){};//定义dialog插件

调用

/*当我们在页面中js中调用:$("#showDiv").dialog({
width:500px;
heigh:200px;
...
});
调用的是$.fn[ name ] = function( options ) {} 这一堆
重点:
在bridge方法中,有以下一段这段
$.data( this, name, new object( options, this ) );
//this是id为showDiv的div对象,options为页面中传入的json对象,
name="dialog" ,object=jQuery.ui.dialog ,此处使用闭包 new object //创建 jQuery.ui.dialog 类的实例
构造函数:
$[ namespace ][ name ] = function( options, element ) {
// allow instantiation without initializing for simple inheritance
if ( arguments.length ) {
this._createWidget( options, element );
}
};
//调用 this._createWidget,代码例如以下: _createWidget: function( options, element ) {
// $.widget.bridge stores the plugin instance, but we do it anyway
// so that it's stored even before the _create function runs
this.element = $( element ).data( this.widgetName, this );
this.options = $.extend( true, {},
this.options,
$.metadata && $.metadata.get( element )[ this.widgetName ],
options ); var self = this;
this.element.bind( "remove." + this.widgetName, function() {
self.destroy();
}); this._create();
this._init();
}
*/

jquery的widget源代码剖析的更多相关文章

  1. jquery ui widget 源代码分析

    jquery ui 的全部组件都是基于一个简单,可重用的widget. 这个widget是jquery ui的核心部分,有用它能实现一致的API.创建有状态的插件,而无需关心插件的内部转换. $.wi ...

  2. Jquery ui widget开发

    Jquery ui 提供了一些基本的widget,但是他提供了很好的机制来创建widget.在jquery css framework中包含了基本的css样式(视觉和感觉诸如颜色,字体大小,图标等), ...

  3. 使用 jQuery UI Widget Factory 编写有状态的插件(Stateful Plugins)

    使用 jQuery UI Widget Factory 编写有状态的插件(Stateful Plugins) Note 这一章节的内容是基于 Scott Gonzalez 一篇博客 Building ...

  4. 转】从源代码剖析Mahout推荐引擎

    原博文出自于: http://blog.fens.me/mahout-recommend-engine/ 感谢! 从源代码剖析Mahout推荐引擎 Hadoop家族系列文章,主要介绍Hadoop家族产 ...

  5. NGINX源代码剖析 之 CPU绑定(CPU亲和性)

    作者:邹祁峰 邮箱:Qifeng.zou.job@gmail.com 博客:http://blog.csdn.net/qifengzou 日期:2014.06.12 18:44 转载请注明来自&quo ...

  6. JQuery UI Widget Factory官方Demo

    <!doctype html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  7. jQuery UI Widget(1.8.1)工作原理--转载

    先看下代码的相关注释: /*! * jQuery UI Widget 1.8.1 * * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/abo ...

  8. Qt中事件分发源代码剖析(一共8个步骤,顺序非常清楚:全局的事件过滤器,再传递给目标对象的事件过滤器,最终传递给目标对象)

    Qt中事件分发源代码剖析 Qt中事件传递顺序: 在一个应该程序中,会进入一个事件循环,接受系统产生的事件,并且进行分发,这些都是在exec中进行的.下面举例说明: 1)首先看看下面一段示例代码: in ...

  9. STL源代码剖析 读书总结

    <<STL源代码剖析>> 侯捷著 非常早就买了这本书, 一直没看, 如今在实验室师兄代码的时候发现里面使用了大量泛型编程的内容, 让我有了先看看这本书的想法. 看之前我对于泛型 ...

随机推荐

  1. doT.js模板和pagination分页应用

    doT.js模板和pagination分页应用 博客中模拟了数据加载初始化的过程.doT.js渲染每一项内容的数据项.示例如下: <script id="Messtmpl" ...

  2. 在MyEclipse中将Java Project转换成Web Project

    在MyEclipse中将Java Project转换成Web Project 此添加方法是针对MyEclipse中添加的: 编辑工程的.project文件: 添加 <nature>com. ...

  3. Android Studio 编译错误

    同样的代码,在eclipse里面能编译通过,导入到Android Studio里面就报错. illegal character: \65279 终于找到答案: http://bbs.csdn.net/ ...

  4. 使用CollectionViewSource,通过Xaml绑定自动排序

    这个是一个完成分组和排序功能的Datagrid,同样只是简单的绑定到List集合,后台不用额外的代码,所有功能都在Xaml中完成: 首先在UI中定义CollectionViewSource资源,在这里 ...

  5. SpringBoot Logback配置,SpringBoot日志配置

    SpringBoot Logback配置,SpringBoot日志配置  SpringBoot springProfile属性配置 ================================ © ...

  6. android编译错误--/usr/bin/ld: cannot find -lz

    编译时出现/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libz.so when se ...

  7. 技巧:Vim 的纵向编辑模式

    https://www.ibm.com/developerworks/cn/linux/l-cn-vimcolumn/ 开始之前 人类大脑对文字的处理是平面式的,所以我们浏览文章.查找资料或者重构代码 ...

  8. android中volley通信框架简介

    1. 什么是Volley? 在这之前,我们在程序中需要和网络通信的时候,大体使用的东西莫过于AsyncTaskLoader,HttpURLConnection,AsyncTask,HTTPClient ...

  9. Redis集成到Spring做mybatis做二级缓存

    一.原理: 要缓存的 Java 对象必须实现 Serializable 接口,因为 Spring 会将对象先序列化再存入 Redis,比如本文中的 com.defonds.bdp.city.bean. ...

  10. java工具类 获取包下所有类

    extends:http://blog.csdn.net/jdzms23/article/details/17550119 package com.threeti.util; import java. ...