1 /* global launchApplication, getAppByID, acceptCall*/
6 var IncomingCall = function() {
9 * Class provides accept/deny for incoming call dialog in every widget. This component is usually initialized by {{#crossLink "Bootstrap"}}{{/crossLink}} class
10 * and can be later accessed using {{#crossLink "Bootstrap/incomingCall:property"}}{{/crossLink}} property.
12 * Component uses [tizen.phone API]() to perform phone operations and
13 * [Tizen Application API](https://developer.tizen.org/dev-guide/2.2.0/org.tizen.web.device.apireference/tizen/application.html) to launch external application.
15 * This class requires following components:
17 * * {{#crossLink "BoxCaption"}}{{/crossLink}} component
23 if (!$("#incomingCall").length) {
24 var appendHtml = '<div id="incomingCall" class="incomingCall incomingCallHide ">';
25 var background = '<div class = "pageBgColorNormalTransparent" style ="width:100%; height: 100%"></div>';
26 var tabs = '<div id = "incomingCallTopPanel" class="tabsTopPanel"></div>';
27 tabs += '<div id = "incomingCallTabs" class="tabsTab"></div>';
28 tabs += '<div id ="incomingCallTitle" class="TopPanelTitle"></div>';
29 var callbox = '<div class = "callInfoBox">';
30 callbox += '<div class = "callPhotoBox noContactPhoto">';
31 callbox += '<img id = "incomingCallPhoto" class="callPhoto"></div>';
33 callbox += '<div id = "incomingCallName" class="callName fontSizeXLarge fontWeightBold fontColorNormal">unknown</div>';
34 callbox += '<div id = "incomingCallNumber" class="callNumber fontSizeXLarge fontWeightBold fontColorTheme">unknown</div>';
35 // callbox += '</div>';
37 var buttons = '<div id="incomingCallAccept" class="incomingCallAccept button callButton callingFalse boxShadow4Active" onClick = "bootstrap.incomingCall.acceptIncommingCall()"></div>';
38 buttons += '<div id="incomingCallDeny" class="incomingCallDeny button callButton callingTrue boxShadow4Active" onClick = "bootstrap.incomingCall.denyCall()"></div>';
40 appendHtml += background + tabs + callbox + buttons;
41 appendHtml += '</div></div>';
42 $(appendHtml).appendTo("body");
43 $("#incomingCall .TopPanelTitle").boxCaptionPlugin('init', "Incoming Call");
47 * Method shows incoming call dialog.
49 * @param contact {contact} Contact data from phone.
51 IncomingCall.prototype.show = function(contact) {
55 var name = contact.name.firstName || "";
56 name += contact.name.lastName ? " " + contact.name.lastName : "";
57 $("#incomingCallName").html(name);
60 if (contact.phoneNumbers) {
61 $("#incomingCallNumber").html(contact.phoneNumbers[0] && contact.phoneNumbers[0].number ? contact.phoneNumbers[0].number : "");
64 if (contact.photoURI) {
65 $("#incomingCallPhoto").attr("src", contact.photoURI);
68 if ($("#incomingCall").hasClass('incomingCallHide')) {
69 $("#incomingCall").removeClass('incomingCallHide');
70 $("#incomingCall").addClass("incomingCallShow");
74 * Method hides incoming call dialog.
77 IncomingCall.prototype.hide = function() {
79 if ($("#incomingCall").hasClass('incomingCallShow')) {
80 $("#incomingCall").removeClass('incomingCallShow');
81 $("#incomingCall").addClass("incomingCallHide");
85 * Method accepts incoming call. If application where call is accepted isn't Phone application (`Modello009.Phone`), then launches Phone application.
86 * If apllication where call is accepted is Phone application (`Modello009.Phone`), call {{#crossLink "Phone/acceptCall:method"}}{{/crossLink}} method.
87 * @method acceptIncommingCall
89 IncomingCall.prototype.acceptIncommingCall = function() {
91 /* todo add call to phone application */
93 var appId = getAppByID('Modello009.Phone');
94 /* if app isn't phone */
96 launchApplication('Modello009.Phone');
99 if (typeof(tizen) !== 'undefined' && tizen.phone) {
100 var activeCall = tizen.phone.activeCall();
101 acceptCall(activeCall.contact);
106 * Method denies incoming call. This method use api fucntion [tizen.phone.hangupCall]().
109 IncomingCall.prototype.denyCall = function() {
113 if (typeof(tizen) !== 'undefined' && tizen.phone) {
114 tizen.phone.hangupCall(function(result) {
115 console.log(result.message);