forked from elsewhat/openui5-cards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample3.html
135 lines (118 loc) · 4.66 KB
/
example3.html
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html><head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>openui5-cards Google+</title>
<!--Standard sapui5 init-->
<script id="sap-ui-bootstrap"
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m,sap.ui.commons"></script>
<!--CSS required by open.m.Card
Needs to be after sapui5 init in order to override styles-->
<link href="openui5-cards.css" type="text/css" rel="stylesheet"/>
<script src="openui5-cards.js"></script>
<style>
/*overwriting title size to smaller value*/
h1.cardTitle1 {
font-size:1.5rem;
}
/*Attempting to improve performance*/
.sapMNav{
overflow:visible;
}
.sapMPageScroll{
overflow:visible;
}
</style>
<script>
var googlePlusUrl="https://www.googleapis.com/plus/v1/people/111622544588609267059/activities/public?key=AIzaSyD5ICveYtey_w-L4I7AiF_1MQEDFJHPwDo&maxResults=100";
var oModel = new sap.ui.model.json.JSONModel(googlePlusUrl);
var cardFactory = function(sId, oContext) {
var oCard = new open.m.Card(sId)
.bindProperty("title", oContext.sPath+"/title")
.bindProperty("subtitle", oContext.sPath+"/actor/displayName")
.bindProperty("bodyImage", oContext.sPath+"/object/attachments",function(postAttachments){
//surely there is a better way of handling bindings like this one
if(postAttachments!= null && postAttachments.length>=1){
return postAttachments[0].image.url;
}else {
return null;
}
}
);
var viewLink = oContext.getModel().getProperty(oContext.sPath+"/url");
var fullImageLink = null;
var postAttachments = oContext.getModel().getProperty(oContext.sPath+"/object/attachments");
if(postAttachments!= null && postAttachments.length>=1){
fullImageLink= postAttachments[0].fullImage.url;
}
//Action for navigating to G+ post
oCard.addAction(new open.m.CardAction(sId+"action1",
{actionText:"View post",
press:function(){
jQuery.sap.require("sap.m.MessageToast");
sap.m.MessageToast.show("View link action clicked");
window.location.href = viewLink;
},
icon:"sap-icon://post"}));
//Action for viewing full image
if(fullImageLink!=null){
oCard.addAction(new open.m.CardAction(sId+"action2",
{actionText:"View image",
press:function(){
var imageDialog = new sap.m.Dialog({
title: "Photo",
content: new sap.m.Image({
src: fullImageLink,
width: "22em"
}),
leftButton: new sap.m.Button({
text: "Ok",
press: function () {
imageDialog.close();
}
})
}).addStyleClass("sapUiPopupWithPadding");
imageDialog.open();
},
icon:"sap-icon://post"}));
}
//add menu
oCard.setMenu(new sap.m.ActionSheet(sId+"menu1",{
title: "Options",
showCancelButton: false,
placement: sap.m.PlacementType.Bottom,
buttons: [
new sap.m.Button({
icon: "sap-icon://arrow-top",
text: "+1",
press: function(){
jQuery.sap.require("sap.m.MessageToast");
sap.m.MessageToast.show("Not implemented (ie. Left as an exercise for the user)");
}
}),
]
}));
return oCard;
};
var headerCard = new open.m.Card("initialCard",
{title:"<strong>About</strong>",
subtitle:"Demonstrates binding to a dynamic JSONModel (from Google+)",})
var cardContainer = new open.m.CardContainer("myCardContainer",
{ showSearchField:false,
headerCard:headerCard,
headerImageUrl:"openui5-cards-header-night.png"
});
cardContainer.setModel(oModel);
cardContainer.bindAggregation("cards","/items", cardFactory);
var app = new sap.m.App({initialPage:"openui5-cards"});
app.placeAt("content");
var pageContent = new sap.m.Page("openui5-cards",{title:"Google+ OpenUI5-Cards", showHeader:false, showFooter:false, enableScrolling:false});
pageContent.addContent(cardContainer);
app.addPage(pageContent);
</script>
</head>
<body class="sapUiBody">
<div id="content"></div>
</body>
</html>