forked from YahooArchive/mojito
/
model.server.mocked.js
51 lines (49 loc) · 1.77 KB
/
model.server.mocked.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright (c) 2011-2013, Yahoo! Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
/*jslint anon:true, sloppy:true, nomen:true*/
YUI.add('iphonePagerMojitModel', function (Y, NAME) {
var photos = [];
Y.namespace('mojito.models')[NAME] = {
init: function(config) {
this.config = config;
},
getData: function (search, start, count, callback) {
var id, title,
url = [
'/static/PagerMojit/assets/pic.com/1234/1001_banffpark.jpg',
'/static/PagerMojit/assets/pic.com/1234/1002_calgary.jpg',
'/static/PagerMojit/assets/pic.com/1234/1003_jasperpark.jpg',
'/static/PagerMojit/assets/pic.com/1234/1004_rockmountain.jpg'
];
photos.length = 0;
for (i = 0; i < url.length; i += 1) {
id = url[i].match(/com\/(\d+)\/(\d+)_([0-9a-z]+)\.jpg$/);
title = url[i].split("/");
photos.push({
id: id[2],
title: title[6],
location: url[i]
});
}
callback(photos);
},
getContent: function (imageId, callback) {
for (i = 0; i < photos.length; i += 1) {
id = photos[i].id;
if(imageId === id) {
var raw = {
query: {
results: {
photo: photos[i]
}
}
}
callback(raw);
}
}
}
};
}, '0.0.1', { requires: ['mojito', 'yql']});