linkbutton.js
jquery.linkbutton.js
/**
* linkbutton - jQuery EasyUI
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*/
(function($){ function createButton(target) {
var opts = $.data(target, 'linkbutton').options; $(target).empty();
$(target).addClass('l-btn');
if (opts.id){
$(target).attr('id', opts.id);
} else {
$(target).removeAttr('id');
}
if (opts.plain){
$(target).addClass('l-btn-plain');
} else {
$(target).removeClass('l-btn-plain');
} if (opts.text){
$(target).html(opts.text).wrapInner(
'<span class="l-btn-left">' +
'<span class="l-btn-text">' +
'</span>' +
'</span>'
);
if (opts.iconCls){
$(target).find('.l-btn-text').addClass(opts.iconCls).css('padding-left', '20px');
}
} else {
$(target).html(' ').wrapInner(
'<span class="l-btn-left">' +
'<span class="l-btn-text">' +
'<span class="l-btn-empty"></span>' +
'</span>' +
'</span>'
);
if (opts.iconCls){
$(target).find('.l-btn-empty').addClass(opts.iconCls);
}
} setDisabled(target, opts.disabled);
} function setDisabled(target, disabled){
var state = $.data(target, 'linkbutton');
if (disabled){
state.options.disabled = true;
var href = $(target).attr('href');
if (href){
state.href = href;
$(target).attr('href', 'javascript:void(0)');
}
var onclick = $(target).attr('onclick');
if (onclick) {
state.onclick = onclick;
$(target).attr('onclick', null);
}
$(target).addClass('l-btn-disabled');
} else {
state.options.disabled = false;
if (state.href) {
$(target).attr('href', state.href);
}
if (state.onclick) {
target.onclick = state.onclick;
}
$(target).removeClass('l-btn-disabled');
}
}
/**
* 扩展jQuery对象的属性方法
*/
$.fn.linkbutton = function(options){
if (typeof options == 'string'){
switch(options){
case 'options':
return $.data(this[0], 'linkbutton').options;
case 'enable':
return this.each(function(){
setDisabled(this, false);
});
case 'disable':
return this.each(function(){
setDisabled(this, true);
});
}
} options = options || {};
return this.each(function(){
var state = $.data(this, 'linkbutton');
if (state){
$.extend(state.options, options);
} else {
var t = $(this);
$.data(this, 'linkbutton', {
options: $.extend({}, $.fn.linkbutton.defaults, {
id: t.attr('id'),
disabled: (t.attr('disabled') ? true : undefined),
plain: (t.attr('plain') ? t.attr('plain') == 'true' : undefined),
text: $.trim(t.html()),
iconCls: t.attr('icon')
}, options)
});
t.removeAttr('disabled');
} createButton(this);
});
}; $.fn.linkbutton.defaults = {
id: null,
disabled: false,
plain: false,
text: '',
iconCls: null
}; })(jQuery);
linkbutton.js的更多相关文章
- easyloader.js源代码分析
http://www.cnblogs.com/jasonoiu/p/easyloader_source_code_analysis.html Jquery easyui是一个javascript UI ...
- 3.EasyUI学习总结(三)——easyloader源码分析
easyloader模块是用来加载jquery easyui的js和css文件的,即easyloader可以在调用的时候自动加载当前页面所需的文件,不用再自己引用, 而且它可以分析模块的依赖关系,先加 ...
- easyloader源码
/** * easyloader - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * ...
- 使用Jquery+EasyUI 进行框架项目开发案例讲解之二---用户管理源码分享
使用Jquery+EasyUI 进行框架项目开发案例讲解之二 用户管理源码分享 在上一篇文章<使用Jquery+EasyUI进行框架项目开发案例讲解之一---员工管理源码分享>我们分享 ...
- easyui源码翻译1.32--datagrid(数据表格)
前言 此前网上有easyui1.25的源码 应该算是比较老的版本 之后又经历了1.26 . 1.3. 1.31. 1.32 .1.33.1.34 1.33开始支持css3 算是又一个转折 但是 ...
- easyui源码翻译1.32--EasyLoader(简单加载)
前言 扩展自$.fn.datebox.defaults,使用$.fn.datetimebox.defaults重写默认值对象.下载该插件翻译源码 源码 /** * jQuery EasyUI 1.3. ...
- easyui源码翻译1.32--Pagination(分页)
前言 使用$.fn.pagination.defaults重写默认值对象下载该插件翻译源码 该分页控件允许用户导航页面的数据.它支持页面导航和页面长度选择的选项设置.用户可以在分页控件上添加自定义按钮 ...
- easyui源码翻译1.32--SearchBox(搜索框)
前言 使用$.fn.searchbox.defaults重写默认值对象.下载该插件翻译源码 搜索框提示用户需要输入搜索的值.它可以结合一个菜单,允许用户选择不同的搜索类别.在用户按下回车键或点击组件右 ...
- easyui源码翻译1.32--Tabs(选项卡)
前言 使用$.fn.tabs.defaults重写默认值对象.下载该插件翻译源码 选项卡显示一批面板.但在同一个时间只会显示一个面板.每个选项卡面板都有头标题和一些小的按钮工具菜单,包括关闭按钮和其他 ...
随机推荐
- c++ - fcgio.cpp:50: error: 'EOF' was not declared in this scope - Stack Overflow
c++ - fcgio.cpp:50: error: 'EOF' was not declared in this scope - Stack Overflow fcgio.cpp:50: error ...
- uva-12657 - Boxes in a Line(双向链表)
12657 - Boxes in a Line You have n boxes in a line on the table numbered 1 . . . n from left to righ ...
- cuda核函数再调用核函数,多层并行
#include <stdio.h> __global__ void childKernel(int i) { int tid = blockIdx.x*blockDim.x+thread ...
- ios7 UIScrollView 尺寸问题
假设在UINavigationController内设置一个UIViewControlller,而UIViewController的第一个子视图是UIScrollView的话,UIScrollview ...
- BootStrap 智能表单系列 三 分块表单配置的介绍
相信广大博友肯定碰到过一个编辑页面分了很多块的情况,智能表单插件已经为您支持了这种情况, 代码如下(链接地址:https://github.com/xiexingen/Bootstrap-SmartF ...
- 判断联网wifi
UIApplication *app = [UIApplication sharedApplication]; NSArray *children = [[[app valueForKeyPath:@ ...
- ExtJS002Window创建
Ext.onReady(function () { Ext.create('Ext.window.Window', { title: 'window', width: 400, height: 300 ...
- c#计算文件的MD5值
代码: /// <summary> /// 计算文件的 MD5 值 /// </summary> /// <param name="fileName" ...
- React使用笔记(3)-React Event Listener
Date: 2015-11-28 12:18 Category: Web Tags: JavaScript Author: 刘理想 [toc] 1. 构造基本结构 首先,我们先创建一个按钮,一个输入框 ...
- 帝国cms7.2灵动标签万能教程
学完本文,就完全能掌握帝国模板开发制作啦!这里只介绍sql语句调用方法(方便,快捷!) 灵动标签语法: [e:loop={,24,0}] 模板内容 [/e:loop] 详细解释:黄色部分:条件语句,即 ...