Blame view
app/scripts/services/illustration.js
3.9 KB
6f105dbd5
|
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
define(['app'], function (app) { 'use strict'; app.factory('$illustration', function ($http, $rootScope) { // data format: {'id_cate1': {name: '', list: [item1,item2]}, ...} // item format: {name: '', path: ''} var DATA = { 'cate1': { name: 'category #1', list: [ { name: 'item 1', path: 'images/illustrations/item1.svg' }, { name: 'item 2', path: 'images/illustrations/item2.svg' }, { name: 'item 3', path: 'images/illustrations/item3.svg' }, { name: 'item 4', path: 'images/illustrations/item4.svg' }, { name: 'item 1', path: 'images/illustrations/item3.svg' }, { name: 'item 2', path: 'images/illustrations/item1.svg' }, { name: 'item 3', path: 'images/illustrations/item4.svg' }, { name: 'item 4', path: 'images/illustrations/item2.svg' } ] }, 'cate2': { name: 'category #2', list: [ { name: 'item 1', path: 'images/illustrations/item3.svg' }, { name: 'item 2', path: 'images/illustrations/item1.svg' }, { name: 'item 3', path: 'images/illustrations/item4.svg' }, { name: 'item 4', path: 'images/illustrations/item2.svg' }, { name: 'item 1', path: 'images/illustrations/item1.svg' }, { name: 'item 2', path: 'images/illustrations/item2.svg' }, { name: 'item 3', path: 'images/illustrations/item3.svg' }, { name: 'item 4', path: 'images/illustrations/item4.svg' } ] } }; return { loadFromRemote: function (params,successHandle,errorHandle) { // return format: { status:0|1 , data:{} } var httpObj = $http({ url: $rootScope+'/apiv1/illustration', method: 'GET', params: params || [] }); if (typeof successHandle == 'undefined'){ successHandle = function(response){ if (response.status==1){ DATA = response.data; } } } httpObj.success(successHandle); if (typeof errorHandle != 'undefined'){ httpObj.error(errorHandle); } }, getAll: function(){ return DATA; }, getList: function(category){ if (typeof DATA[category] == 'undefined'){ return []; } return DATA[category]; } }; }); }); |