mirror of
https://github.com/Mibew/mibew.git
synced 2024-11-15 08:34:11 +03:00
Add button to show tracked path of a visitor into operator's chat window
This commit is contained in:
parent
3148db54b5
commit
691bcfa061
@ -0,0 +1,68 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
/**
|
||||
* @class Represents Tracked path control view
|
||||
*/
|
||||
Mibew.Views.TrackedPathControl = Mibew.Views.Control.extend(
|
||||
/** @lends Mibew.Views.TrackedPathControl.prototype */
|
||||
{
|
||||
/**
|
||||
* Template function
|
||||
* @type Function
|
||||
*/
|
||||
template: Handlebars.templates['chat/controls/tracked_path'],
|
||||
|
||||
/**
|
||||
* Map ui events to view methods
|
||||
* The view inherits events from
|
||||
* {@link Mibew.Views.Control.prototype.events}.
|
||||
* @type Object
|
||||
*/
|
||||
events: _.extend(
|
||||
{},
|
||||
Mibew.Views.Control.prototype.events,
|
||||
{
|
||||
'click': 'showTrackedPath'
|
||||
}
|
||||
),
|
||||
|
||||
/**
|
||||
* Display tracked path window
|
||||
*/
|
||||
showTrackedPath: function() {
|
||||
var user = Mibew.Objects.Models.user;
|
||||
var link = this.model.get('link');
|
||||
if (user.get('isAgent') && link) {
|
||||
var winParams = Mibew.Utils.buildWindowParams(this.model.get('windowParams'));
|
||||
|
||||
// TODO: Kill & at the server side
|
||||
link = link.replace('&', '&', 'g');
|
||||
|
||||
var newWindow = window.open(link, 'UserTrackedPath', winParams);
|
||||
if (newWindow !== null) {
|
||||
newWindow.focus();
|
||||
newWindow.opener=window;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
})(Mibew, Handlebars, _);
|
63
src/mibew/js/source/chat/models/controls/tracked_path.js
Normal file
63
src/mibew/js/source/chat/models/controls/tracked_path.js
Normal file
@ -0,0 +1,63 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
|
||||
/**
|
||||
* @class Tracked path control model
|
||||
*/
|
||||
Mibew.Models.TrackedPathControl = Mibew.Models.Control.extend(
|
||||
/** @lends Mibew.Models.TrackedPathControl.prototype */
|
||||
{
|
||||
/**
|
||||
* A list of default model values.
|
||||
*
|
||||
* The model inherits defaults from
|
||||
* {@link Mibew.Models.Control.prototype.defaults}.
|
||||
* @type Object
|
||||
*/
|
||||
defaults: _.extend(
|
||||
{},
|
||||
Mibew.Models.Control.prototype.defaults,
|
||||
{
|
||||
/**
|
||||
* An URL of the tracked path page or false by default.
|
||||
* @type String|Boolean
|
||||
*/
|
||||
link: false,
|
||||
|
||||
/**
|
||||
* Params string for tracked path popup window
|
||||
* @type String
|
||||
*/
|
||||
windowParams: ''
|
||||
}
|
||||
),
|
||||
|
||||
/**
|
||||
* Returns model type
|
||||
* @returns {String} Model type
|
||||
*/
|
||||
getModelType: function() {
|
||||
return 'TrackedPathControl';
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
})(Mibew, _);
|
@ -101,6 +101,15 @@
|
||||
windowParams: options.windowsParams.history
|
||||
});
|
||||
ctrlsCollection.add(controls.history);
|
||||
|
||||
if (options.links.tracked) {
|
||||
controls.tracked_path = new Mibew.Models.TrackedPathControl({
|
||||
weight: 170,
|
||||
link: options.links.tracked,
|
||||
windowParams: options.windowsParams.trackedPath
|
||||
});
|
||||
ctrlsCollection.add(controls.tracked_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Create toggle sound button
|
||||
|
@ -380,6 +380,8 @@ function setup_chatview(Thread $thread)
|
||||
$style_config = $page_style->getConfigurations();
|
||||
$data['chat']['windowsParams']['history']
|
||||
= $style_config['history']['window'];
|
||||
$data['chat']['windowsParams']['trackedPath']
|
||||
= $style_config['tracked']['visitor_window'];
|
||||
|
||||
$data['startFrom'] = 'chat';
|
||||
|
||||
@ -517,11 +519,13 @@ function setup_chatview_for_operator(
|
||||
// Set tracking params
|
||||
if (Settings::get('enabletracking')) {
|
||||
$visitor = track_get_visitor_by_thread_id($thread->id);
|
||||
if ($visitor) {
|
||||
$data['chat']['links']['tracked'] = $url_generator->generate(
|
||||
'history_user_track',
|
||||
array('visitor' => $visitor['visitorid'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if agent can post messages
|
||||
if ($thread->agentId == $operator['operatorid']) {
|
||||
|
@ -170,6 +170,12 @@ a:hover .image-close-window {
|
||||
.active-history-control .tpl-image {
|
||||
background-position: -112px 0;
|
||||
}
|
||||
.tracked-path-control .tpl-image {
|
||||
background-position: -192px -16px;
|
||||
}
|
||||
.active-tracked-path-control .tpl-image {
|
||||
background-position: -192px 0;
|
||||
}
|
||||
.sound-control .sound-control-on {
|
||||
background-position: -48px -16px;
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.5 KiB |
@ -0,0 +1 @@
|
||||
<div class="tpl-image" title="{{l10n "Tracked path of visitor"}}"></div>
|
@ -167,6 +167,12 @@ a:hover .image-close-window {
|
||||
.active-history-control .tpl-image {
|
||||
background-position: -112px 0;
|
||||
}
|
||||
.tracked-path-control .tpl-image {
|
||||
background-position: -192px -16px;
|
||||
}
|
||||
.active-tracked-path-control .tpl-image {
|
||||
background-position: -192px 0;
|
||||
}
|
||||
.sound-control .sound-control-on {
|
||||
background-position: -48px -16px;
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.5 KiB |
@ -0,0 +1 @@
|
||||
<div class="tpl-image" title="{{l10n "Tracked path of visitor"}}"></div>
|
Loading…
Reference in New Issue
Block a user