mirror of
https://github.com/Mibew/mibew.git
synced 2025-04-10 09:50:12 +03:00
Use CanteenHTML5 for buttons generation
This commit is contained in:
parent
d446b9a78f
commit
c43fccf297
@ -24,7 +24,8 @@
|
|||||||
"symfony/config": "2.5.*",
|
"symfony/config": "2.5.*",
|
||||||
"symfony/yaml": "2.5.*",
|
"symfony/yaml": "2.5.*",
|
||||||
"symfony/translation": "2.5.*",
|
"symfony/translation": "2.5.*",
|
||||||
"tedivm/stash": "0.12.*"
|
"tedivm/stash": "0.12.*",
|
||||||
|
"canteen/html5": "1.1.*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"squizlabs/php_codesniffer": "1.*"
|
"squizlabs/php_codesniffer": "1.*"
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
namespace Mibew\Button\Generator;
|
namespace Mibew\Button\Generator;
|
||||||
|
|
||||||
|
use Canteen\HTML5;
|
||||||
use Mibew\Asset\Generator\UrlGeneratorInterface as AssetUrlGeneratorInterface;
|
use Mibew\Asset\Generator\UrlGeneratorInterface as AssetUrlGeneratorInterface;
|
||||||
use Mibew\Routing\Generator\SecureUrlGeneratorInterface as RouteUrlGeneratorInterface;
|
use Mibew\Routing\Generator\SecureUrlGeneratorInterface as RouteUrlGeneratorInterface;
|
||||||
use Mibew\Settings;
|
use Mibew\Settings;
|
||||||
@ -74,14 +75,20 @@ class ImageGenerator extends TextGenerator
|
|||||||
'&',
|
'&',
|
||||||
$this->generateUrl('button', $image_link_args)
|
$this->generateUrl('button', $image_link_args)
|
||||||
);
|
);
|
||||||
$message = "<img src=\"{$image_url}\" border=\"0\" alt=\"\"/>";
|
$image = HTML5\html('img');
|
||||||
|
$image->setAttributes(array(
|
||||||
|
'src' => $image_url,
|
||||||
|
'border' => 0,
|
||||||
|
'alt' => '',
|
||||||
|
));
|
||||||
|
|
||||||
$button = "<!-- mibew button -->"
|
$button = HTML5\html('fragment');
|
||||||
. $this->getPopup($message)
|
$button->addChild(HTML5\html('comment', 'mibew button'));
|
||||||
. $this->getWidgetCode()
|
$button->addChild($this->getPopup($image));
|
||||||
. "<!-- / mibew button -->";
|
$button->addChild($this->getWidgetCode());
|
||||||
|
$button->addChild(HTML5\html('comment', '/ mibew button'));
|
||||||
|
|
||||||
return $button;
|
return (string)$button;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,13 +147,20 @@ class ImageGenerator extends TextGenerator
|
|||||||
// blocked
|
// blocked
|
||||||
$widget_data['visitorCookieName'] = VISITOR_COOKIE_NAME;
|
$widget_data['visitorCookieName'] = VISITOR_COOKIE_NAME;
|
||||||
|
|
||||||
// Build additional button code
|
$markup = HTML5\html('fragment');
|
||||||
return '<div id="mibewinvitation"></div>'
|
$markup->addChild(HTML5\html('div#mibewinvitation'));
|
||||||
. '<script type="text/javascript" src="'
|
$markup->addChild(
|
||||||
. $this->generateAssetUrl('js/compiled/widget.js')
|
HTML5\html('script')->setAttributes(array(
|
||||||
. '"></script>'
|
'type' => 'text/javascript',
|
||||||
. '<script type="text/javascript">'
|
'src' => $this->generateAssetUrl('js/compiled/widget.js'),
|
||||||
. 'Mibew.Widget.init(' . json_encode($widget_data) . ')'
|
))
|
||||||
. '</script>';
|
);
|
||||||
|
$markup->addChild(
|
||||||
|
HTML5\html('script')
|
||||||
|
->setAttribute('type', 'text/javascript')
|
||||||
|
->addChild('Mibew.Widget.init(' . json_encode($widget_data) . ')')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $markup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
namespace Mibew\Button\Generator;
|
namespace Mibew\Button\Generator;
|
||||||
|
|
||||||
|
use Canteen\HTML5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates an Operator's Code field.
|
* Generates an Operator's Code field.
|
||||||
*/
|
*/
|
||||||
@ -29,19 +31,35 @@ class OperatorCodeGenerator extends AbstractGenerator implements GeneratorInterf
|
|||||||
*/
|
*/
|
||||||
public function generate()
|
public function generate()
|
||||||
{
|
{
|
||||||
$js_link = $this->getChatUrlForJs();
|
$form = HTML5\html('form');
|
||||||
$popup_options = $this->getPopupOptions();
|
$form->setAttributes(array(
|
||||||
|
'action' => '',
|
||||||
|
'onsubmit' => sprintf(
|
||||||
|
("if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 "
|
||||||
|
. "&& window.event.preventDefault) window.event.preventDefault();"
|
||||||
|
. "this.newWindow = window.open(%s + '&operator_code=' "
|
||||||
|
. "+ document.getElementById('mibewOperatorCodeField').value, 'mibew', '%s');"
|
||||||
|
. "this.newWindow.focus();"
|
||||||
|
. "this.newWindow.opener=window;"
|
||||||
|
. "return false;"),
|
||||||
|
$this->getChatUrlForJs(),
|
||||||
|
$this->getPopupOptions()
|
||||||
|
),
|
||||||
|
'id' => 'mibewOperatorCodeForm',
|
||||||
|
));
|
||||||
|
$form->addChild(HTML5\html(
|
||||||
|
'input',
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'id' => 'mibewOperatorCodeField',
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
$form_on_submit = "if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 "
|
$button = HTML5\html('fragment');
|
||||||
. "&& window.event.preventDefault) window.event.preventDefault();"
|
$button->addChild(HTML5\html('comment', 'mibew operator code field'));
|
||||||
. "this.newWindow = window.open({$js_link} + '&operator_code=' "
|
$button->addChild($form);
|
||||||
. "+ document.getElementById('mibewOperatorCodeField').value, 'mibew', '{$popup_options}');"
|
$button->addChild(HTML5\html('comment', '/ mibew operator code field'));
|
||||||
. "this.newWindow.focus();this.newWindow.opener=window;return false;";
|
|
||||||
|
|
||||||
$temp = '<form action="" onsubmit="' . $form_on_submit . '" id="mibewOperatorCodeForm">'
|
return (string)$button;
|
||||||
. '<input type="text" id="mibewOperatorCodeField" />'
|
|
||||||
. '</form>';
|
|
||||||
|
|
||||||
return "<!-- mibew operator code field -->" . $temp . "<!-- / mibew operator code field -->";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
namespace Mibew\Button\Generator;
|
namespace Mibew\Button\Generator;
|
||||||
|
|
||||||
|
use Canteen\HTML5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a Text button.
|
* Generates a Text button.
|
||||||
*/
|
*/
|
||||||
@ -29,9 +31,12 @@ class TextGenerator extends AbstractGenerator implements GeneratorInterface
|
|||||||
*/
|
*/
|
||||||
public function generate()
|
public function generate()
|
||||||
{
|
{
|
||||||
return "<!-- mibew text link -->"
|
$button = HTML5\html('fragment');
|
||||||
. $this->getPopup($this->getOption('caption'))
|
$button->addChild(HTML5\html('comment', 'mibew text link'));
|
||||||
. "<!-- / mibew text link -->";
|
$button->addChild($this->getPopup($this->getOption('caption')));
|
||||||
|
$button->addChild(HTML5\html('comment', '/ mibew text link'));
|
||||||
|
|
||||||
|
return (string)$button;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,16 +46,29 @@ class TextGenerator extends AbstractGenerator implements GeneratorInterface
|
|||||||
*/
|
*/
|
||||||
protected function getPopup($message)
|
protected function getPopup($message)
|
||||||
{
|
{
|
||||||
$url = str_replace('&', '&', $this->getChatUrl());
|
$link = HTML5\html('a', $message);
|
||||||
$js_url = $this->getChatUrlForJs();
|
|
||||||
$options = $this->getPopupOptions();
|
|
||||||
$title = $this->getOption('title');
|
|
||||||
|
|
||||||
return "<a id=\"mibewAgentButton\" href=\"$url\" target=\"_blank\" "
|
$link->setAttributes(array(
|
||||||
. ($title ? "title=\"$title\" " : "")
|
'id' => 'mibewAgentButton',
|
||||||
. "onclick=\"if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 "
|
'href' => str_replace('&', '&', $this->getChatUrl()),
|
||||||
. "&& window.event.preventDefault) window.event.preventDefault();"
|
'target' => '_blank',
|
||||||
. "this.newWindow = window.open($js_url, 'mibew', '$options');"
|
'onclick' =>sprintf(
|
||||||
. "this.newWindow.focus();this.newWindow.opener=window;return false;\">$message</a>";
|
("if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 "
|
||||||
|
. "&& window.event.preventDefault) window.event.preventDefault();"
|
||||||
|
. "this.newWindow = window.open(%s, 'mibew', '%s');"
|
||||||
|
. "this.newWindow.focus();"
|
||||||
|
. "this.newWindow.opener=window;"
|
||||||
|
. "return false;"),
|
||||||
|
$this->getChatUrlForJs(),
|
||||||
|
$this->getPopupOptions()
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
$title = $this->getOption('title');
|
||||||
|
if ($title) {
|
||||||
|
$link->setAttribute('title', $title);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user