sencha touch Container tpl 监听组件插件(2013-9-14)
将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)的更多相关文章
- sencha touch list tpl 监听组件插件(2013-9-15)
插件代码 /* *list tpl模版加入按钮监控 *<div class="x-button-normal x-button x-iconalign-center x-layout- ...
- waypoint+animate元素滚动监听触发插件实现页面动画效果
最近在做一个官网类型滚动加载动画,使用到waypoint监听事件插件和animate动画样式,两者结合完美实现向下滚动加载动画,但是没有做向上滚动撤消动画,留待以后有空研究 首先来介绍下jquery. ...
- Bootstrap滚动监听(Scrollspy)插件
Bootstrap滚动监听(Scrollspy)插件,即自动更新导航插件,会根据滚动条的位置自动更新对应的导航目标
- Vue中如何监听组件的原生事件
在首页开发中,右下角有一个返回顶部的小箭头,将它单独封装成一个BackTop组件,但是它何时出现需要依赖于首页的滑动,即另外一个Scroll组件.如果直接在BackTop组件里面监听,则需要通过thi ...
- sencha touch Container 监听超链接插件
有时候内容直接从后台获取,有可能包含超链接,打包成应用之后,点击会造成不好的后果,这样做能够用外部浏览器打开.需要Cordova支持 监听插件代码: /* *监听a标签,用外部浏览器打开链接 */ E ...
- sencha touch Container
Container控件是我们在实际开发中最常用的控件,大部分视图控件都是继承于Container控件,了解此控件能帮我们更好的了解sencha touch. layout是一个很重要的属性,能够帮助你 ...
- 12.vue属性.监听.组件
1.计算属性 https://cn.vuejs.org/v2/guide/computed.html new Vue({ computed:{//定义 show(){ } } }) ++计算属性1.h ...
- sencha touch 2.2 为list PullRefresh插件添加refreshFn方法
sencha touch 2.2 list PullRefresh插件没有refreshFn方法 但是我们又需要他,所以需要自行扩展 代码如下 /** * 重写下拉刷新插件,以支持refreshFn事 ...
- bootstrap源码之滚动监听组件scrollspy.js详解
其实滚动监听使用的情况还是很多的,比如导航居于右侧,当主题内容滚动某一块的时候,右侧导航对应的要高亮. 实现功能 1.当滚动区域内设置的hashkey距离顶点到有效位置时,就关联设置其导航上的指定项 ...
随机推荐
- com.panie 项目开发随笔_数据字典(2017.2.24)
(一) 做一个网站,第一步需要考虑的是从哪个地方开始下手.首先,每一个功能肯定有最基本的增删改查功能,而此功能一般都分为两个页面. 1) 列表显示页面.用列表来展示数据库中的数据,多用于分页显示.该页 ...
- Window.Open()方法详细的参数说明及技巧。
Window.Open()方法详细的参数说明及技巧. 一.window.open()支持环境: JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+ 二.基本语法 ...
- 怎么安装ABBYY FineReader
ABBYY FineReader是市场领先的文字识别(OCR)软件,可快速方便地将扫描纸质文档.PDF文件和数码相机的图像转换成可编辑.可搜索信息,ABBYY FineReader 12是目前最新版本 ...
- MysqlHelper使用反射机制智能推算数据类型以及属性名称
public class MySqlHelper { private string ConnString; public MySqlHelper(string connectionString) { ...
- Java 多线程编程知识详解
Java 给多线程编程提供了内置的支持.一个多线程程序包含两个或多个能并发运行的部分.程序的每一部分都称作一个线程,并且每个线程定义了一个独立的执行路径. 多线程是多任务的一种特别的形式,但多线程使用 ...
- Unity3D的按钮添加事件有三种方式
为Unity3D的按钮添加事件有三种方式,假设我们场景中有一个Canvas对象,Canvas对象中有一个Button对象. 方式一: 创建脚本ClickObject.cs,然后将脚本添加到Canvas ...
- Android刮刮卡效果
不多说,直接上代码: package com.example.test; import android.app.Activity; import androi ...
- SpringBoot------注解把配置文件自动映射到属性和实体类
1.映射到属性 package top.ytheng.demo.controller; import org.springframework.beans.factory.annotation.Valu ...
- 8 -- 深入使用Spring -- 7... Spring 整合 Struts 2
8.7 Spring 整合 Struts2 8.7.1 启动Spring 容器 8.7.2 MVC框架与Spring整合的思考 8.7.3 让Spring管理控制器 8.7.4 使用自动装配
- 善用 CSS 中的 table-layout 屬性加快 Table 的顯示速度
在很久以前我們都是用 Table 在排版的,我相信現在還是有不少人還是在用 Table 進行排版而非現在較為流行的 CSS 排版,使用 Table 排版最大的好處就是版面在各瀏覽器中顯示比較不會亂掉. ...