Advertisement
Avatarr

pattern

Jul 24th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*--------- BUTTON EVENT ------------*/
  2.  
  3. var dial_button = ['.icon-mute', '.i-acw', '.i-pause', '.i-hold', '.i-trans', '.i-hangup', '.i-hangout'];
  4.  
  5. var txtInput = $('#i-dial-number');
  6. // click on digit number
  7. $('.i-btn-digit').click(function() {
  8.  
  9.     //!-- prevent add number whene use ENTER , after numpad opened
  10.     $(document.body).keydown(function(e) {
  11.         if (e.keyCode == 13) {
  12.             return false;
  13.         }
  14.     });
  15.     txtInput.val((txtInput.val()) + "" + $(this).text());
  16. });
  17. //-------------------------------------------
  18.  
  19. /**
  20.  * A Call handle function
  21.  * @className i-hangout: start to call
  22.  * @className i-hangup: stop ti call
  23.  */
  24.  
  25. $('.i-hangout').click(function() {
  26.     ActiveCall = Zoiper.Dial($('#i-dial-number').val());
  27. });
  28.  
  29. $('.i-hangup').click(function() {
  30.  
  31.     if (ActiveCall.IsHold == "true") {
  32.         ActiveCall.UnHold();
  33.         $('.i-hold').removeClass('i-btn_active');
  34.     }
  35.  
  36.     if (Zoiper.MuteMicrophone == "true") {
  37.         Zoiper.MuteMicrophone = "false";
  38.         $('.icon-mute').removeClass('i-btn_active');
  39.     }
  40.  
  41.     Zoiper.Hang();
  42.     ActiveCall = null;
  43.     txtInput.val("");
  44. });
  45.  
  46. //!-- Use ENTER key to call
  47. $(document.body).keydown(function(e) {
  48.     if (e.keyCode == 13) {
  49.         ActiveCall = Zoiper.Dial($('#i-dial-number').val());
  50.  
  51.     }
  52. });
  53. //-------------------------------------------
  54.  
  55. /**
  56.  * A Incomming call handle function
  57.  * @className i-accept: accept incomming call
  58.  * @className i-denied: reject incomming call
  59.  */
  60.  
  61. $('.i-accept').click(function() {
  62.     ActiveCall.Accept();
  63.     popup.close();
  64.     $('.i-popup-content p').remove();
  65.  
  66. });
  67.  
  68. $('.i-denied ').click(function() {
  69.     ActiveCall.Reject();
  70.     popup.close();
  71.     $('.i-popup-content p').remove();
  72. });
  73. //-------------------------------------------
  74.  
  75. /**
  76.  * A Hold handle function
  77.  * @className i-hold: to hold call
  78.  */
  79.  
  80. $('.i-hold').click(function() {
  81.     hold_btn($(this));
  82. });
  83. //-------------------------------------------
  84.  
  85. /**
  86.  * A Mute
  87.  * @className icon-mute: to mute microphone
  88.  */
  89.  
  90. $('.icon-mute').click(function() {
  91.     if (Zoiper.MuteMicrophone == "true") {
  92.         Zoiper.MuteMicrophone = "false";
  93.         $(this).removeClass('i-btn_active');
  94.     } else {
  95.         Zoiper.MuteMicrophone = "true";
  96.         $(this).addClass('i-btn_active');
  97.     }
  98. });
  99. //-------------------------------------------
  100.  
  101. /**
  102.  * A Transfer
  103.  * @className i-trans: to transfer call
  104.  */
  105.  
  106. $('.i-trans').click(function() {
  107.     ActiveCall.Transfer(1001998);
  108.     console.log(ActiveCall.IsTransferring);
  109. });
  110. //-------------------------------------------
  111.  
  112. /**
  113.  * A Keyborad
  114.  * Ues to open numpad windows
  115.  */
  116.  
  117. $('span.i-keyboard').click(function() {
  118.     numpad.center().open();
  119. });
  120.  
  121. $('.i-cog-setting').click(function() {
  122.     open_setting();
  123. });
  124. //-------------------------------------------
  125.  
  126. /**
  127.  * A disable/enable button
  128.  * @param {booble} b is true/false
  129.  */
  130.  
  131. function diable_enable_btn(b) {
  132.     $(".icon-mute, .i-acw, .i-pause, .i-hold, .i-trans , .i-hangup").kendoButton().data("kendoButton");
  133.  
  134.     //!-- disable
  135.     if (b === false) {
  136.  
  137.         $(dial_button[6]).kendoButton().data("kendoButton").enable(false);
  138.  
  139.         $('.i-dial-pad button').each(function(index) {
  140.             if (index === 6) {
  141.                 return false;
  142.             }
  143.  
  144.             $(dial_button[index]).kendoButton().data("kendoButton").enable(true);
  145.         });
  146.  
  147.         //!-- enable
  148.     } else {
  149.         $(dial_button[6]).kendoButton().data("kendoButton").enable(true);
  150.  
  151.         $('.i-dial-pad button').each(function(index) {
  152.             if (index === 6) {
  153.                 return false;
  154.             }
  155.  
  156.             $(dial_button[index]).kendoButton().data("kendoButton").enable(false);
  157.         });
  158.     }
  159. }
  160.  
  161. /**
  162.  * A Open tab
  163.  * Use to open new tab on call incomming
  164.  * @param {Actviecall} call
  165.  * @param {String} seachParam use to store phone number
  166.  * @param {Date} today
  167.  */
  168.  
  169. function open_new_tab(call, seachParam, today) {
  170.     tabStrip.append({
  171.         text: call.Phone + ' - Time: ' + today.toLocaleTimeString(),
  172.         content: '<iframe class ="i-sugar-crm" scrolling="auto" src=\"' + seachParam + '\" onload=\'javascript:resizeIframe(this);\'></iframe>'
  173.     });
  174.  
  175.     var li = $('#i-tab ul li .k-link').last();
  176.     li.append('<span role="presentation" class="k-icon k-i-close close-tab-icon" onclick=\'tabStrip.remove($(this).closest(\"li\"))\'>close</span>');
  177. }
  178.  
  179.  
  180. /**
  181.  * A Popup windows
  182.  * Here is popup windows when call incomming
  183.  *
  184.  * @param {Zoiper} call: zoiper object ActiveCall
  185.  * @param {time} today: data time today
  186.  */
  187. var popup;
  188. var setting;
  189.  
  190. function open_popup(call, today) {
  191.     popup = $(".i-popup").kendoWindow({
  192.         width: "400px",
  193.         height: "150px",
  194.         modal: true,
  195.         title: 'Incomming form: ' + call + ' - Time: ' + today,
  196.         visible: false,
  197.         resizable: false,
  198.         actions: [
  199.  
  200.         ],
  201.         animation: {
  202.             close: {
  203.                 effects: "fade:out"
  204.             }
  205.         }
  206.     }).data("kendoWindow");
  207.  
  208.     // open popup and center position on screen
  209.     $('.i-popup-content').append('<p>Incomming call form: ' + call + '</p>');
  210.     popup.center().open();
  211.  
  212. }
  213.  
  214. function open_setting() {
  215.     setting = $(".i-setting").kendoWindow({
  216.         width: "800px",
  217.         height: "550px",
  218.         modal: true,
  219.         title: '',
  220.         visible: true,
  221.         resizable: false,
  222.         actions: [
  223.             'Close'
  224.         ],
  225.         animation: {
  226.              open: {
  227.                 effects: "fade:in"
  228.             },
  229.             close: {
  230.                 effects: "fade:out"
  231.             }
  232.         }
  233.     }).data("kendoWindow");
  234.     $('.k-window-title').html('<i class="fa fa-wrench"></i> Setting');
  235.  
  236.     setting.center().open();
  237. }
  238.  
  239. function hold_btn(obj) {
  240.     if (ActiveCall.IsHold == "true") {
  241.         ActiveCall.UnHold();
  242.         $(obj).removeClass('i-btn_active');
  243.     } else {
  244.         ActiveCall.Hold();
  245.         $(obj).addClass('i-btn_active');
  246.     }
  247.  
  248. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement