diff --git a/src/mibew/js/source/chat/model_views/controls/tracked_path.js b/src/mibew/js/source/chat/model_views/controls/tracked_path.js new file mode 100644 index 00000000..42d8bc9a --- /dev/null +++ b/src/mibew/js/source/chat/model_views/controls/tracked_path.js @@ -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, _); \ No newline at end of file diff --git a/src/mibew/js/source/chat/models/controls/tracked_path.js b/src/mibew/js/source/chat/models/controls/tracked_path.js new file mode 100644 index 00000000..1af9bcf9 --- /dev/null +++ b/src/mibew/js/source/chat/models/controls/tracked_path.js @@ -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, _); \ No newline at end of file diff --git a/src/mibew/js/source/chat/modules/chat.js b/src/mibew/js/source/chat/modules/chat.js index 8ec9171d..4574b21b 100644 --- a/src/mibew/js/source/chat/modules/chat.js +++ b/src/mibew/js/source/chat/modules/chat.js @@ -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 diff --git a/src/mibew/libs/chat.php b/src/mibew/libs/chat.php index bfe11dc2..3a2bbf83 100644 --- a/src/mibew/libs/chat.php +++ b/src/mibew/libs/chat.php @@ -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,10 +519,12 @@ function setup_chatview_for_operator( // Set tracking params if (Settings::get('enabletracking')) { $visitor = track_get_visitor_by_thread_id($thread->id); - $data['chat']['links']['tracked'] = $url_generator->generate( - 'history_user_track', - array('visitor' => $visitor['visitorid']) - ); + if ($visitor) { + $data['chat']['links']['tracked'] = $url_generator->generate( + 'history_user_track', + array('visitor' => $visitor['visitorid']) + ); + } } // Check if agent can post messages diff --git a/src/mibew/styles/chats/dark/chat.css b/src/mibew/styles/chats/dark/chat.css index de8fb104..e456e061 100644 --- a/src/mibew/styles/chats/dark/chat.css +++ b/src/mibew/styles/chats/dark/chat.css @@ -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; } diff --git a/src/mibew/styles/chats/dark/images/buttons.gif b/src/mibew/styles/chats/dark/images/buttons.gif index 6c2904f4..c8700d8a 100644 Binary files a/src/mibew/styles/chats/dark/images/buttons.gif and b/src/mibew/styles/chats/dark/images/buttons.gif differ diff --git a/src/mibew/styles/chats/dark/templates_src/client_side/chat/controls/tracked_path.handlebars b/src/mibew/styles/chats/dark/templates_src/client_side/chat/controls/tracked_path.handlebars new file mode 100644 index 00000000..dd5334b7 --- /dev/null +++ b/src/mibew/styles/chats/dark/templates_src/client_side/chat/controls/tracked_path.handlebars @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/src/mibew/styles/chats/default/chat.css b/src/mibew/styles/chats/default/chat.css index 3c0b4ba0..ceadf37a 100644 --- a/src/mibew/styles/chats/default/chat.css +++ b/src/mibew/styles/chats/default/chat.css @@ -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; } diff --git a/src/mibew/styles/chats/default/images/buttons.gif b/src/mibew/styles/chats/default/images/buttons.gif index 5d3a20b9..628d84ab 100644 Binary files a/src/mibew/styles/chats/default/images/buttons.gif and b/src/mibew/styles/chats/default/images/buttons.gif differ diff --git a/src/mibew/styles/chats/default/templates_src/client_side/chat/controls/tracked_path.handlebars b/src/mibew/styles/chats/default/templates_src/client_side/chat/controls/tracked_path.handlebars new file mode 100644 index 00000000..dd5334b7 --- /dev/null +++ b/src/mibew/styles/chats/default/templates_src/client_side/chat/controls/tracked_path.handlebars @@ -0,0 +1 @@ + \ No newline at end of file