]>
git.proxmox.com Git - sencha-touch.git/blob - src/examples/pullrefresh/app.js
7 // This utility function takes a date and returns a representation in words.
8 var timeAgoInWords = function(date
) {
10 var now
= Math
.ceil(Number(new Date()) / 1000),
11 dateTime
= Math
.ceil(Number(new Date(date
)) / 1000),
12 diff
= now
- dateTime
,
16 return String(diff
) + ' seconds ago';
17 } else if (diff
< 3600) {
18 str
= String(Math
.ceil(diff
/ (60)));
19 return str
+ (str
== "1" ? ' minute' : ' minutes') + ' ago';
20 } else if (diff
< 86400) {
21 str
= String(Math
.ceil(diff
/ (3600)));
22 return str
+ (str
== "1" ? ' hour' : ' hours') + ' ago';
23 } else if (diff
< 60 * 60 * 24 * 365) {
24 str
= String(Math
.ceil(diff
/ (60 * 60 * 24)));
25 return str
+ (str
== "1" ? ' day' : ' days') + ' ago';
27 return Ext
.Date
.format(new Date(date
), 'jS M \'y');
35 * This examples illustrates the 'List Paging' and 'Pull Refresh' plugins
41 'Ext.data.proxy.Rest',
42 'Ext.plugin.ListPaging',
43 'Ext.plugin.PullRefresh'
47 '320x460': 'resources/startup/Default.jpg', // Non-retina iPhone, iPod touch, and all Android devices
48 '640x920': 'resources/startup/640x920.png', // Retina iPhone and iPod touch
49 '640x1096': 'resources/startup/640x1096.png', // iPhone 5 and iPod touch (fifth generation)
50 '768x1004': 'resources/startup/768x1004.png', // Non-retina iPad (first and second generation) in portrait orientation
51 '748x1024': 'resources/startup/748x1024.png', // Non-retina iPad (first and second generation) in landscape orientation
52 '1536x2008': 'resources/startup/1536x2008.png', // : Retina iPad (third generation) in portrait orientation
53 '1496x2048': 'resources/startup/1496x2048.png' // : Retina iPad (third generation) in landscape orientation
56 isIconPrecomposed
: false,
58 57: 'resources/icons/icon.png',
59 72: 'resources/icons/icon@72.png',
60 114: 'resources/icons/icon@2x.png',
61 144: 'resources/icons/icon@144.png'
65 Ext
.override(Ext
.data
.proxy
.Rest
, {
66 getMethod: function(){
71 Ext
.define('TweetStore', {
72 extend
: 'Ext.data.Store',
75 fields
: ['from_user', 'profile_image_url', 'text', 'created_at'],
81 url
: 'http://schematic-ipsum.herokuapp.com/?n=15',
85 "properties[id][type]":"string",
86 "properties[id][ipsum]":"id",
87 "properties[from_user][type]":"string",
88 "properties[from_user][ipsum]":"first name",
89 "properties[profile_image_url][type]":"string",
90 "properties[profile_image_url][ipsum]":"small image",
91 "properties[text][type]":"string",
92 "properties[text][ipsum]":"sentence",
93 "properties[created_at][type]":"string",
94 "properties[created_at][format]":"date-time"
100 Ext
.define('TweetList', {
104 useSimpleItems
: false,
105 variableHeights
: true,
107 disableSelection
: true,
108 allowDeselect
: false,
109 scrollToTopOnRefresh
: false,
110 store
: Ext
.create('TweetStore'),
113 { xclass
: 'Ext.plugin.ListPaging' },
114 { xclass
: 'Ext.plugin.PullRefresh' }
116 emptyText
: '<p class="no-searches">No tweets found matching that search</p>',
118 itemTpl
: Ext
.create('Ext.XTemplate',
119 '<div class="twitter-post">',
120 '<img src="{profile_image_url}" />',
121 '<div class="tweet">',
122 '<span class="posted">{[this.posted(values.created_at)]}</span>',
123 '<h2>@{from_user}</h2>',
127 posted
: timeAgoInWords
133 if (Ext
.os
.is
.Phone
) {
134 Ext
.create('TweetList', {