/**
  * {@inheritdoc}
  */
 public function doGenerate()
 {
     $form = HTML5\html('form');
     $form->setAttributes(array('action' => '', 'onsubmit' => sprintf("var popup = Mibew.Objects.ChatPopups['%s'];" . "popup.open(popup.buildChatUrl() " . "+ '&operator_code=' " . "+ document.getElementById('mibew-operator-code-field').value);" . "return false;", $this->getOption('unique_id')), 'id' => 'mibew-operator-code-form'));
     $form->addChild(HTML5\html('input', array('type' => 'text', 'id' => 'mibew-operator-code-field')));
     $button = HTML5\html('fragment');
     $button->addChild(HTML5\html('comment', 'mibew operator code field'));
     $button->addChild($form);
     $button->addChild($this->getPopup());
     $button->addChild(HTML5\html('comment', '/ mibew operator code field'));
     return $button;
 }
示例#2
0
 /**
  * Generates a markup for link that opens chat popup.
  *
  * @param string|\Canteen\HTML5\Node $caption A string or an HTML node that
  * is used as popup link caption.
  * @return string HTML markup.
  */
 protected function getPopupLink($caption)
 {
     $link = HTML5\html('a', $caption);
     $link->setAttributes(array('id' => 'mibew-agent-button', 'href' => str_replace('&', '&', $this->getChatUrl()), 'target' => '_blank', 'onclick' => "Mibew.Objects.ChatPopups['" . $this->getOption('unique_id') . "'].open();" . "return false;"));
     $title = $this->getOption('title');
     if ($title) {
         $link->setAttribute('title', $title);
     }
     $fragment = HTML5\html('fragment');
     $fragment->addChild($link);
     $fragment->addChild($this->getPopup());
     return $fragment;
 }
示例#3
0
 /**
  * Generates HTML markup for Mibew widget.
  *
  * @return \Canteen\HTML5\Fragment
  */
 protected function getWidgetCode()
 {
     $widget_data = array();
     // Get actual invitation style instance
     $style_name = $this->getOption('invitation_style') ? $this->getOption('invitation_style') : InvitationStyle::getCurrentStyle();
     $style = new InvitationStyle($style_name);
     // URL of file with additional CSS rules for invitation popup
     $widget_data['inviteStyle'] = $this->generateAssetUrl($style->getFilesPath() . '/invite.css');
     // Time between requests to the server in milliseconds
     $widget_data['requestTimeout'] = Settings::get('updatefrequency_tracking') * 1000;
     // URL for requests
     $widget_data['requestURL'] = $this->generateUrl('widget_gateway');
     // Locale for invitation
     $widget_data['locale'] = $this->getOption('locale');
     // Name of the cookie to track user. It is used if third-party cookie
     // blocked
     $widget_data['visitorCookieName'] = VISITOR_COOKIE_NAME;
     $markup = HTML5\html('fragment');
     $markup->addChild(HTML5\html('div#mibew-invitation'));
     $markup->addChild(HTML5\html('script')->setAttributes(array('type' => 'text/javascript', 'src' => $this->generateAssetUrl('js/compiled/widget.js'))));
     $markup->addChild(HTML5\html('script')->setAttribute('type', 'text/javascript')->addChild('Mibew.Widget.init(' . json_encode($widget_data) . ')'));
     return $markup;
 }
示例#4
0
 /**
  * Builds markup with chat popup initialization code.
  *
  * @return \Canteen\HTML5\Fragment
  */
 protected function getPopup()
 {
     $fragment = HTML5\html('fragment');
     $fragment->addChild(HTML5\html('script')->setAttributes(array('type' => 'text/javascript', 'src' => $this->generateAssetUrl('js/compiled/chat_popup.js'))));
     $fragment->addChild(HTML5\html('script')->setAttribute('type', 'text/javascript')->addChild('Mibew.ChatPopup.init(' . json_encode($this->getPopupOptions()) . ');'));
     return $fragment;
 }