http://www.cnblogs.com/mlzs/p/3279162.html中的功能插件化

插件代码:

 /*
*tpl模版加入按钮
*<div class="x-button-normal x-button x-iconalign-center x-layout-box-item x-stretched btn" style="visibility:{visibility}" fire="TasteUp" ><span class="x-button-icon x-shown lower"></span></div>
*fire="tasteUp" 表示添加tasteUp事件和激活dotasteUp方法
*有两个参数cmp:视图本身以及doit
*只要是以上格式的模板都可以被监控到
*其中btn、shareIco为自定义样式,其他都是st自带样式
*/
Ext.define('ux.ConTpl', {
alias: 'plugin.conTpl',
xtype: 'conTpl',
config: {
cmp: null,
//竖向滚动,不显示滚动条
scrollable: {
direction: 'vertical',
directionLock: true,
indicators: false
},
//按下时添加css
pressedCls: 'pressing',
//监控对象选择器
delegate: 'div.x-button'
},
constructor: function (config) {
this.initConfig(config);
this.callParent([config]);
},
//初始化
init: function (cmp) {
this.setCmp(cmp);
},
//更新配置
updateCmp: function (newCmp, oldCmp) {
if (newCmp) {
newCmp.element.on({
tap: 'onTap',
touchstart: 'onPress',
touchend: 'onRelease',
delegate: this.getDelegate(),
scope: this
});
newCmp.setScrollable(this.getScrollable());
}
},
//执行动作
onTap: function (e) {
var cmp = this.getCmp(),
el = e.getTarget(this.getDelegate(), null, true),
fire = el.getAttribute('fire'),
action = 'do' + fire;
cmp.fireAction(fire, [cmp, el], action);
},
//按钮按下时,添加css
onPress: function (e, node) {
var el = e.getTarget(this.getDelegate(), null, true);
el.addCls(this.getPressedCls());
},
//松开按钮时,移除css
onRelease: function (e, node) {
var el = e.getTarget(this.getDelegate(), null, true);
el.removeCls(this.getPressedCls());
}
});

使用代码:

Ext.define('app.view.message.Info', {
alternateClassName: 'messageInfo',
extend: 'Ext.Container',
xtype: 'messageInfo',
requires: ['ux.TplBtn'],
config: {
cls: 'info',
plugins: 'tplBtn',
tpl: new Ext.XTemplate(
'<div class="title tl">{Title}</div>',
'<div class="box sm"><div class="left">时间 {Time}</div><div>发布来源:{Auth}</div></div>',
'<div class="box"><div class="one"></div><div>',
'<div class="x-button btn"><span class="x-button-icon shareIco x-icon-mask" fire="showWeibo"></span></div>',
'<div class="x-button btn"><span class="x-button-icon favorites x-icon-mask"></span></div>',
'<div class="x-button btn"><span class="x-button-icon commentIco x-icon-mask"></span></div>',
'</div></div>',
'<div class="con">{Summary}</div>')
},
//分享到微博
showWeibo: function (cmp, doit) {
myUtil.showWeibo({ url: 'http://www.baidu.com', title: this.getData().Title });
}
});

css略过...

效果图:

点击按钮后执行效果:

2013.9.14

  为控件添加点击事件和点击方法

sencha touch Container tpl 监听组件插件(2013-9-14)的更多相关文章

  1. sencha touch list tpl 监听组件插件(2013-9-15)

    插件代码 /* *list tpl模版加入按钮监控 *<div class="x-button-normal x-button x-iconalign-center x-layout- ...

  2. waypoint+animate元素滚动监听触发插件实现页面动画效果

    最近在做一个官网类型滚动加载动画,使用到waypoint监听事件插件和animate动画样式,两者结合完美实现向下滚动加载动画,但是没有做向上滚动撤消动画,留待以后有空研究 首先来介绍下jquery. ...

  3. Bootstrap滚动监听(Scrollspy)插件

    Bootstrap滚动监听(Scrollspy)插件,即自动更新导航插件,会根据滚动条的位置自动更新对应的导航目标

  4. Vue中如何监听组件的原生事件

    在首页开发中,右下角有一个返回顶部的小箭头,将它单独封装成一个BackTop组件,但是它何时出现需要依赖于首页的滑动,即另外一个Scroll组件.如果直接在BackTop组件里面监听,则需要通过thi ...

  5. sencha touch Container 监听超链接插件

    有时候内容直接从后台获取,有可能包含超链接,打包成应用之后,点击会造成不好的后果,这样做能够用外部浏览器打开.需要Cordova支持 监听插件代码: /* *监听a标签,用外部浏览器打开链接 */ E ...

  6. sencha touch Container

    Container控件是我们在实际开发中最常用的控件,大部分视图控件都是继承于Container控件,了解此控件能帮我们更好的了解sencha touch. layout是一个很重要的属性,能够帮助你 ...

  7. 12.vue属性.监听.组件

    1.计算属性 https://cn.vuejs.org/v2/guide/computed.html new Vue({ computed:{//定义 show(){ } } }) ++计算属性1.h ...

  8. sencha touch 2.2 为list PullRefresh插件添加refreshFn方法

    sencha touch 2.2 list PullRefresh插件没有refreshFn方法 但是我们又需要他,所以需要自行扩展 代码如下 /** * 重写下拉刷新插件,以支持refreshFn事 ...

  9. bootstrap源码之滚动监听组件scrollspy.js详解

    其实滚动监听使用的情况还是很多的,比如导航居于右侧,当主题内容滚动某一块的时候,右侧导航对应的要高亮. 实现功能 1.当滚动区域内设置的hashkey距离顶点到有效位置时,就关联设置其导航上的指定项 ...

随机推荐

  1. Spring Cloud 微服务的那点事

    什么是微服务 微服务的概念源于2014年3月Martin Fowler所写的一篇文章“Microservices”. 微服务架构是一种架构模式,它提倡将单一应用程序划分成一组小的服务,服务之间互相协调 ...

  2. ubuntu下gedit和vim输入中文和中文显示

    安装和配置VIM,参考   http://jingyan.baidu.com/album/046a7b3efd165bf9c27fa915.html?picindex=4 在home/你的用户名 这个 ...

  3. LinuxMint系统下Gate One的安装指南

    1. Gate One简介 前面有两个随笔介绍过开源软件tty.js和wetty在Linux的安装.Tty.js和wetty都是采用Node.js实现的开源Web-based ssh.今天来介绍另一个 ...

  4. sar监控工具详解

    转自http://www.cnblogs.com/Amaranthus/p/3745680.html SAR NAME: SAR报告,收集,保存系统活动信息 语法: sar  [ -A ] [ -b ...

  5. Alpine Linux:如何配置GUI的图形桌面环境:x Desktop Environment

    alpine linux 真是不错.小巧.迅捷! 官方的各个版本的alpine镜像内没有带图形环境的.那我们如何构建自己的桌面图形环境呢? 其实:这个问题,在起官网的wiki内有指南,我们根据那些相关 ...

  6. windows 下为Python安装redis

    最近在看<redis实战>,里面的redis示例都是Python写的,先将环境整好 启动redis redis-server.exe  redis.conf 安装了python2.7 安装 ...

  7. 源码分析五(HashSet的内部实现)

    一:首先来看看Hashset的继承体系 public class HashSet<E> extends AbstractSet<E> implements Set<E&g ...

  8. mysql中,创建包含json数据类型的表?创建json表时候的注意事项?查询json字段中某个key的值?

    需求描述: 在mysql数据库中,创建包含json数据类型的表.记录下,在创建的过程中,需要注意的问题. 操作过程: 1.通过以下的语句,创建包含json数据类型的表 mysql> create ...

  9. git同时提交到两个仓库

    有时候一个项目,希望既提交到oschina又提交到公司内网的gitlab,或者是github什么的. 使用git remote -v 查看当前git的远程仓库. 添加一个远程仓库 git remote ...

  10. 解决Spring Boot中,通过filter打印post请求的 request body 问题

    http://slackspace.de/articles/log-request-body-with-spring-boot/ (filter + RequestWrapper:最优雅的写法) ht ...