因项目 需要  老项目需要用到  时分  的插件  而本身sencha  touch  自己木有这个功能,因此在网上找到了 一个可以扩展的插件.

相关目录复制如下代码:

/**
* The picker with hours and minutes slots
*/
Ext.define('Ext.ux.picker.Time', {
extend:'Ext.picker.Picker',
xtype:'timepicker', config:{
/**
* @cfg {Number} increment The number of minutes between each minute value in the list.
* Defaults to: 5
*/
increment:5, /**
* @cfg {Number} start value of hours
*/
minHours:0, /**
* @cfg {Number} end value of hours.
*/
maxHours:23, /**
* @cfg {String} title to show above hour slot
* Note: for titles to show set the {useTitle} config to true.
*/
hoursTitle:'Hours', /**
* @cfg {String} title to show above hour slot
* Note: for this to show set the {useTitle} config to true.
*/
minutesTitle:'Minutes', /**
* @cfg {boolean} show/hide title headers.
* Note: defaults to false (framework default 'Ext.picker.Picker')
*/ slots: []
}, /**
*
* @param value
* @param animated
*/
setValue:function (value, animated) {
var increment = this.getInitialConfig().increment,
modulo; if (Ext.isDate(value)) {
value = {
hours:value.getHours(),
minutes:value.getMinutes()
};
} //Round minutes
modulo = value.minutes % increment;
if (modulo > 0) {
value.minutes = Math.round(value.minutes / increment) * increment;
}
this.callParent([value, animated]);
}, /**
* @override
* @returns {Date} A date object containing the selected hours and minutes. Year, month, day default to the current date..
*/
getValue:function () {
var value = this.callParent(arguments),
date = new Date();
value = new Date(date.getFullYear(), date.getMonth(), date.getDate(), value.hours, value.minutes);
return value;
}, applySlots:function (slots) {
var me = this,
hours = me.createHoursSlot(),
minutes = me.createMinutesSlot(); return [hours, minutes];
}, createHoursSlot:function () {
var me = this,
initialConfig = me.getInitialConfig(),
title = initialConfig.hoursTitle ,
minHours = initialConfig.minHours,
maxHours = initialConfig.maxHours,
hours = [],
slot; for (var i = minHours; i <= maxHours; i++) {
var text = (i < 10) ? ('0' + i) : i; //Add leading zero
hours.push({text:text, value:i});
} slot = {
name:'hours',
align:'center',
title:title,
data:hours,
flex:1
}; return slot;
}, createMinutesSlot:function () {
var me = this,
initialConfig = me.getInitialConfig(),
title = initialConfig.minutesTitle ,
increment = initialConfig.increment,
minutes = [],
slot; for (var j = 0; j < 60; j += increment) {
var text;
text = (j < 10) ? ('0' + j) : j; //Add leading zero
minutes.push({text:text, value:j});
} slot = {
name:'minutes',
align:'center',
title:title,
data:minutes,
flex:1
};
return slot;
}
});

  

/**
* TimePickerfield. Extends from datepickerfield
*/
Ext.define('Ext.ux.field.TimePicker', {
extend:'Ext.field.DatePicker',
xtype:'timepickerfield', requires:['Ext.ux.picker.Time'], config:{
dateFormat:'H:i', //Default format show time only
picker:true
}, /**
* @override
* @param value
* Source copied, small modification
*/
applyValue:function (value) {
if (!Ext.isDate(value) && !Ext.isObject(value)) {
value = null;
} // Begin modified section
if (Ext.isObject(value)) {
var date = new Date(),
year = value.year || date.getFullYear(), // Defaults to current year if year was not supplied etc..
month = value.month || date.getMonth(),
day = value.day || date.getDate(); value = new Date(year, month, day, value.hours, value.minutes); //Added hour and minutes
}
// End modfied section!
return value;
}, applyPicker:function (picker) {
picker = Ext.factory(picker, 'Ext.ux.picker.Time');
picker.setHidden(true); // Do not show picker on creeation
Ext.Viewport.add(picker);
return picker;
}, updatePicker:function (picker) {
picker.on({
scope:this,
change:'onPickerChange',
hide:'onPickerHide'
});
picker.setValue(this.getValue());
return picker;
}
});

  使用方法  如下:

{
xtype: 'timepickerfield',
label: 'time',
value: new Date(), // object also possible {hours:12, minutes:25},
name: 'time',
picker:{
height:300
minHours:9, //(optional)Selectable hours will be between 9-18
maxHours:18 // (optional) These values default to 0-24
}
}

  时间获取方法:

//* Notes:
getValue() // will return a {Date} object
getFormattedValue() //will return H:i (example16:40)

  效果如下:

sench touch 时间插件 扩展的更多相关文章

  1. Yii笔记:打印sql、Form表单、时间插件、Mysql的 FIND_IN_SET函数使用、是否是post/ajax请求

    语句部分: yii1版本打印最后一条执行的SQL: $this->getDbConnection()->createCommand()->select()->from()-&g ...

  2. 【eclipse插件开发实战】 Eclipse插件开发5——时间插件Timer开发实例详解

    Eclipse插件开发5--时间插件Timer开发实例详解 这里做的TimeHelper插件设定为在菜单栏.工具栏提供快捷方式,需要在相应地方设置扩展点,最后弹出窗体显示时间. 在上一篇文章里创建好了 ...

  3. Chrome插件(扩展)

    [干货]Chrome插件(扩展)开发全攻略   写在前面 我花了将近一个多月的时间断断续续写下这篇博文,并精心写下完整demo,写博客的辛苦大家懂的,所以转载务必保留出处.本文所有涉及到的大部分代码均 ...

  4. angularjs封装bootstrap官网的时间插件datetimepicker

    背景:angular与jquery类库的协作 第三方类库中,不得不提的是大名鼎鼎的jquery,现在基本上已经是国内web开发的必修工具了.它灵活的dom操作,让很多web开发人员欲罢不能.再加上已经 ...

  5. bootstrap时间插件 火狐不显示 完美解决方法

    原文链接:http://www.phpbiji.cn/article/index/id/141/cid/4.html bootstrap时间插件火狐 bootstrap-datetimepicker火 ...

  6. 原生js日期时间插件鼠标点击文本框弹出日期时间表格选择日期时间

    原文出处 (这是我从互联网上搜来的,感觉能满足各方面的需求.个人感觉挺不错的,所以后期修改了一下向大家推荐!) 效果图: html代码: <!DOCTYPE html PUBLIC " ...

  7. QML插件扩展2(基于C++的插件扩展)

    上一节介绍了纯QML的插件扩展方式,这种扩展方式基本满足大部分的扩展需求,下面开始介绍比较小众的基于C++的扩展 (一)更新插件工程 1.更新MyPlugin工程下的qmldir文件,加入plugin ...

  8. QML插件扩展(一)

    准备分两节来介绍QML扩展插件,分别为 (一)基于QML文件的扩展方式 (二)基于C++的插件扩展 这篇先介绍基于QML的插件扩展. 先介绍几个基本概念: qmldir: 用于组织自定义的QML插件, ...

  9. bootstrap-datetimepicker bootstrap-datepicker bootstrap-timepicker 时间插件

    <!DOCTYPE html><head> <title>时间插件测试</title><style type="text/css&quo ...

随机推荐

  1. 深入理解jQuery中的each方法

    写在前面 我们先回顾一下数组中的forEach方法吧.在数组的实例上有个forEach方法供所有实例使用,forEach里面接收一个回调函数,而且回调函数默认接收三个参数:当前项,索引,数组 .for ...

  2. js 关键字 in 的使用方法

    参考地址:http://www.cnblogs.com/qiantuwuliang/archive/2011/01/08/1930643.html in 操作符用于确定某个元素是否在数组中,判断某个属 ...

  3. .Net Core 配置文件appsettings

    1.配置文件为appsettings 在appsettings添加ConnectionStrings: { "Logging": { "IncludeScopes&quo ...

  4. 特性Attribute

    1.简介 特性(attribute)是被指定给某一声明的一则附加的声明性信息. 在C#中,有一个小的预定义特性集合.在学习如何建立我们自己的定制特性(custom attributes)之前,我们先来 ...

  5. laravel 关闭 csrf 验证 TokenMismatchException

    csrf验证失败 注释掉kernel.php 的 csrf 行代码

  6. Android 正则表达式验证手机号码

    方案一:比较精准的判断手机段位,但是随着手机号段的增多要不断的修改正则 public boolean isPhoneNumber1(String phone) { String regExp = &q ...

  7. 20145215《网络对抗》Exp4 恶意代码分析

    20145215<网络对抗>Exp4 恶意代码分析 基础问题回答 如果在工作中怀疑一台主机上有恶意代码,但只是猜想,所有想监控下系统一天天的到底在干些什么.请设计下你想监控的操作有哪些,用 ...

  8. 移植busybox构建最小根文件系统

    Busybox:瑞士军刀,里面装有很多小命令. STEP 1:构建目录结构  创建根文件系统目录,主要包括以下目录/dev  /etc /lib  /usr  /var /proc /tmp /hom ...

  9. React的Element的创建和render

    React的Element是React应用程序的最小构建块,它是用来描述我们在屏幕上看到的浏览器页面上的内容. 在React中构建 Element 有两种方式: 1.JSX的方式,JSX不是React ...

  10. python下载夏目友人帳

    python下载夏目友人帐 一般情况下我们使用爬虫更多的应该是爬数据或者图片吧,今天在这里和大家分享一下关于使用爬虫技术来进行视频下载的方法,不仅可以方便的下载一些体积小的视频,针对大容量的视频下载同 ...