前端分流页功能
This commit is contained in:
@@ -37,8 +37,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
field: 'auto_reply_text',
|
||||
title: __('Reply statements column'),
|
||||
operate: false,
|
||||
class: 'autocontent',
|
||||
hover: true,
|
||||
formatter: Controller.api.formatter.autoReplyText
|
||||
},
|
||||
{field: 'ip_protect', title: __('Ip_protect'), searchList: Config.ipProtectList, formatter: Table.api.formatter.status},
|
||||
@@ -58,6 +56,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
icon: 'fa fa-commenting-o',
|
||||
classname: 'btn btn-warning btn-xs btn-split-autoreply',
|
||||
url: 'javascript:;'
|
||||
},
|
||||
{
|
||||
name: 'pixel',
|
||||
text: __('Pixel config'),
|
||||
title: __('Pixel config'),
|
||||
icon: 'fa fa-bullseye',
|
||||
classname: 'btn btn-info btn-xs btn-split-pixel',
|
||||
url: 'javascript:;'
|
||||
}
|
||||
],
|
||||
formatter: Table.api.formatter.operate
|
||||
@@ -97,6 +103,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
Controller.api.openAutoReplyModal(row);
|
||||
});
|
||||
|
||||
table.on('click', '.btn-split-pixel', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
var rowIndex = $(this).data('row-index');
|
||||
var row = Table.api.getrowbyindex(table, rowIndex);
|
||||
if (!row || !row.id) {
|
||||
return false;
|
||||
}
|
||||
Controller.api.openPixelModal(row);
|
||||
});
|
||||
|
||||
Controller.api.bindAutoReplyPreviewTips(table);
|
||||
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
@@ -107,8 +127,45 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
/**
|
||||
* 规范化后台跨模块跳转 URL,避免在 split.link 页面内相对解析成 split.link/domain
|
||||
*
|
||||
* @param {string} url API 返回的地址
|
||||
* @param {string} fallback 相对 admin 模块根路径,如 domain / domain/add
|
||||
* @return {string}
|
||||
*/
|
||||
normalizeAdminRouteUrl: function (url, fallback) {
|
||||
fallback = fallback || 'domain';
|
||||
url = $.trim(url || '');
|
||||
if (url === '' || /split\.link\/domain/i.test(url)) {
|
||||
return fallback;
|
||||
}
|
||||
var modulePrefix = (Config.moduleurl || '').replace(/\/+$/, '');
|
||||
if (url.indexOf('://') !== -1) {
|
||||
try {
|
||||
var parsed = new URL(url, window.location.origin);
|
||||
var path = (parsed.pathname || '').replace(/\/+$/, '');
|
||||
if (modulePrefix && path.indexOf(modulePrefix) === 0) {
|
||||
path = path.slice(modulePrefix.length);
|
||||
}
|
||||
path = path.replace(/^\/+/, '');
|
||||
return /^split\.link\/domain/i.test(path) ? fallback : (path || fallback);
|
||||
} catch (e) {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
if (url.charAt(0) === '/') {
|
||||
url = url.replace(/^\/+/, '');
|
||||
var moduleKey = modulePrefix.replace(/^\/+/, '');
|
||||
if (moduleKey && url.indexOf(moduleKey + '/') === 0) {
|
||||
url = url.slice(moduleKey.length + 1);
|
||||
}
|
||||
}
|
||||
return /^split\.link\/domain/i.test(url) ? fallback : url;
|
||||
},
|
||||
/** 弹窗样式(仅注入一次) */
|
||||
modalStyleInjected: false,
|
||||
pixelModalStyleInjected: false,
|
||||
injectModalStyles: function () {
|
||||
if (Controller.api.modalStyleInjected) {
|
||||
return;
|
||||
@@ -140,18 +197,63 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
].join('');
|
||||
$('<style id="split-link-copy-modal-style" type="text/css"></style>').text(css).appendTo('head');
|
||||
},
|
||||
injectPixelModalStyles: function () {
|
||||
if (Controller.api.pixelModalStyleInjected) {
|
||||
return;
|
||||
}
|
||||
Controller.api.pixelModalStyleInjected = true;
|
||||
var css = [
|
||||
'.split-pixel-layer .layui-layer-content{padding:0;overflow:hidden;max-height:calc(86vh - 108px);}',
|
||||
'.split-pixel-layer .layui-layer-btn{border-top:1px solid #e8e8e8;background:#fafafa;}',
|
||||
'.split-pixel-modal{padding:18px 22px 14px;box-sizing:border-box;display:flex;flex-direction:column;min-height:480px;height:calc(86vh - 108px);max-height:720px;}',
|
||||
'.split-pixel-modal .split-pixel-tip{margin:0 0 14px;padding:10px 14px;background:#f0f7ff;border-left:3px solid #337ab7;border-radius:0 4px 4px 0;color:#555;font-size:13px;line-height:1.65;}',
|
||||
'.split-pixel-modal .split-pixel-tabs{margin-bottom:0;border-bottom:1px solid #ddd;}',
|
||||
'.split-pixel-modal .split-pixel-tabs>li>a{padding:9px 18px;font-weight:600;color:#666;}',
|
||||
'.split-pixel-modal .split-pixel-tabs>li.active>a{color:#337ab7;border-bottom-color:#fff;}',
|
||||
'.split-pixel-modal .split-pixel-tab-content{flex:1;display:flex;flex-direction:column;min-height:0;padding-top:14px;}',
|
||||
'.split-pixel-modal .split-pixel-tab-content>.tab-pane{display:none;flex:1;flex-direction:column;min-height:0;}',
|
||||
'.split-pixel-modal .split-pixel-tab-content>.tab-pane.active{display:flex;}',
|
||||
'.split-pixel-modal .split-pixel-list{flex:1;display:flex;flex-direction:column;min-height:0;}',
|
||||
'.split-pixel-modal .split-pixel-toolbar{margin-bottom:12px;display:flex;align-items:center;justify-content:space-between;flex-shrink:0;}',
|
||||
'.split-pixel-modal .split-pixel-toolbar .btn-add-pixel-row{font-weight:600;padding:6px 14px;}',
|
||||
'.split-pixel-modal .split-pixel-table-wrap{flex:1;min-height:320px;overflow:auto;border:1px solid #dce3eb;border-radius:6px;background:#fff;box-shadow:inset 0 1px 2px rgba(0,0,0,.03);}',
|
||||
'.split-pixel-modal .split-pixel-table{margin-bottom:0;font-size:13px;table-layout:auto;width:100%;}',
|
||||
'.split-pixel-modal .split-pixel-table thead th{background:linear-gradient(180deg,#f8fafc 0%,#eef2f6 100%);white-space:nowrap;vertical-align:middle;text-align:center;font-weight:600;color:#444;border-bottom:2px solid #dce3eb;padding:10px 8px;position:sticky;top:0;z-index:3;box-shadow:0 1px 0 #dce3eb;}',
|
||||
'.split-pixel-modal .split-pixel-table tbody td{vertical-align:middle;padding:10px 8px;border-color:#edf1f5;}',
|
||||
'.split-pixel-modal .split-pixel-table tbody tr.split-pixel-row:hover{background:#f7fbff;}',
|
||||
'.split-pixel-modal .split-pixel-table tbody tr.split-pixel-row:nth-child(even){background:#fbfcfd;}',
|
||||
'.split-pixel-modal .split-pixel-table tbody tr.split-pixel-row:nth-child(even):hover{background:#f7fbff;}',
|
||||
'.split-pixel-modal .split-pixel-table .form-control{min-width:0;height:32px;line-height:1.42857143;padding:6px 10px;border-radius:4px;}',
|
||||
'.split-pixel-modal .split-pixel-table .pixel-id{min-width:130px;}',
|
||||
'.split-pixel-modal .split-pixel-table .pixel-access-token{min-width:150px;}',
|
||||
'.split-pixel-modal .split-pixel-table .pixel-test-code{min-width:100px;}',
|
||||
'.split-pixel-modal .split-pixel-table th.pixel-event-col,.split-pixel-modal .split-pixel-table td.pixel-event-cell{min-width:148px;width:148px;}',
|
||||
'.split-pixel-modal .split-pixel-table .pixel-event{width:100%;min-width:132px;max-width:none;padding-right:28px;text-overflow:clip;overflow:visible;white-space:nowrap;cursor:pointer;}',
|
||||
'.split-pixel-modal .split-pixel-empty-row td{padding:48px 16px;color:#999;text-align:center;font-size:13px;background:#fafbfc;}',
|
||||
'.split-pixel-modal .split-pixel-sort-group{width:118px;margin:0 auto;}',
|
||||
'.split-pixel-modal .split-pixel-sort-group .form-control{text-align:center;padding-left:4px;padding-right:4px;}',
|
||||
'.split-pixel-modal .pixel-switch-wrap{text-align:center;}',
|
||||
'.split-pixel-modal .pixel-switch-wrap input[type=checkbox]{width:17px;height:17px;margin:0;cursor:pointer;vertical-align:middle;}',
|
||||
'.split-pixel-modal .pixel-row-index{display:inline-block;min-width:26px;height:26px;line-height:26px;border-radius:13px;background:#e8eef5;color:#4a6785;font-weight:600;font-size:12px;}',
|
||||
'.split-pixel-modal .btn-pixel-row-remove{padding:4px 8px;border-radius:4px;}',
|
||||
'.split-pixel-modal .col-token{min-width:160px;}'
|
||||
].join('');
|
||||
$('<style id="split-pixel-modal-style" type="text/css"></style>').text(css).appendTo('head');
|
||||
},
|
||||
formatter: {
|
||||
/**
|
||||
* 回复语:单元格内省略,悬停显示完整内容
|
||||
* 回复语:列表最多 50 字 + ...,悬停保留换行显示全文
|
||||
*/
|
||||
autoReplyText: function (value, row, index) {
|
||||
value = value == null ? '' : value.toString();
|
||||
if (value === '') {
|
||||
var full = (row.auto_reply != null && row.auto_reply !== '') ? String(row.auto_reply) : '';
|
||||
if (full === '') {
|
||||
return '<span class="text-muted">-</span>';
|
||||
}
|
||||
var safe = Fast.api.escape(value);
|
||||
return "<div class='autocontent-item autocontent-hover' style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:100%;display:block;' title='"
|
||||
+ safe + "'>" + safe + "</div>";
|
||||
var preview = value != null && value !== '' ? String(value) : full;
|
||||
var safePreview = Fast.api.escape(preview);
|
||||
var encFull = encodeURIComponent(full);
|
||||
return '<span class="split-auto-reply-preview" data-full="' + encFull + '" style="display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:middle;cursor:default;">'
|
||||
+ safePreview + '</span>';
|
||||
},
|
||||
/**
|
||||
* 分流链接列:链接样式 + COPY 图标,点击链接打开弹窗
|
||||
@@ -173,6 +275,39 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
Controller.api.renderCopyModal(linkCode, data);
|
||||
});
|
||||
},
|
||||
/** 回复语列悬停提示(保留换行) */
|
||||
autoReplyTipIndex: null,
|
||||
bindAutoReplyPreviewTips: function (table) {
|
||||
table.off('mouseenter.splitAutoReply mouseleave.splitAutoReply')
|
||||
.on('mouseenter.splitAutoReply', '.split-auto-reply-preview', function () {
|
||||
var enc = $(this).attr('data-full');
|
||||
if (!enc) {
|
||||
return;
|
||||
}
|
||||
var full = '';
|
||||
try {
|
||||
full = decodeURIComponent(enc);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
var html = '<div style="white-space:pre-wrap;word-break:break-word;padding:10px 12px;line-height:1.6;max-width:420px;font-size:13px;text-align:left;">'
|
||||
+ Controller.api.escapeHtmlWithNewlines(full) + '</div>';
|
||||
Controller.api.autoReplyTipIndex = Layer.tips(html, this, {
|
||||
tips: [1, ''],
|
||||
time: 0,
|
||||
maxWidth: 450
|
||||
});
|
||||
})
|
||||
.on('mouseleave.splitAutoReply', '.split-auto-reply-preview', function () {
|
||||
if (Controller.api.autoReplyTipIndex != null) {
|
||||
Layer.close(Controller.api.autoReplyTipIndex);
|
||||
Controller.api.autoReplyTipIndex = null;
|
||||
}
|
||||
});
|
||||
},
|
||||
escapeHtmlWithNewlines: function (text) {
|
||||
return $('<div/>').text(text).html().replace(/\n/g, '<br>');
|
||||
},
|
||||
/**
|
||||
* 打开自动回复弹窗
|
||||
*
|
||||
@@ -226,6 +361,233 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
}
|
||||
});
|
||||
},
|
||||
pixelRowUid: function (prefix) {
|
||||
return prefix + '_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 8);
|
||||
},
|
||||
openPixelModal: function (row) {
|
||||
Fast.api.ajax({
|
||||
url: 'split.link/pixel/ids/' + row.id,
|
||||
type: 'get'
|
||||
}, function (data, ret) {
|
||||
var info = ret.data || data || {};
|
||||
Controller.api.renderPixelModal(row.id, info);
|
||||
return false;
|
||||
});
|
||||
},
|
||||
renderPixelModal: function (linkId, info) {
|
||||
Controller.api.injectPixelModalStyles();
|
||||
var eventOptions = $.isArray(info.event_options) ? info.event_options : [
|
||||
'PageView', 'Lead', 'Contact', 'AddToCart', 'Purchase', 'Subscribe'
|
||||
];
|
||||
var fbRows = $.isArray(info.facebook) ? info.facebook : [];
|
||||
var tkRows = $.isArray(info.tiktok) ? info.tiktok : [];
|
||||
|
||||
var html = [
|
||||
'<div class="split-pixel-modal">',
|
||||
' <div class="split-pixel-tip">' + __('Pixel config tip') + '</div>',
|
||||
' <ul class="nav nav-tabs split-pixel-tabs" role="tablist">',
|
||||
' <li role="presentation" class="active"><a href="#split-pixel-fb" role="tab" data-toggle="tab"><i class="fa fa-facebook-square"></i> ' + __('Facebook Pixel') + '</a></li>',
|
||||
' <li role="presentation"><a href="#split-pixel-tk" role="tab" data-toggle="tab"><i class="fa fa-music"></i> ' + __('TikTok Pixel') + '</a></li>',
|
||||
' </ul>',
|
||||
' <div class="tab-content split-pixel-tab-content">',
|
||||
' <div role="tabpanel" class="tab-pane active" id="split-pixel-fb">',
|
||||
Controller.api.buildPixelListShell('facebook', __('Add FB Pixel')),
|
||||
' </div>',
|
||||
' <div role="tabpanel" class="tab-pane" id="split-pixel-tk">',
|
||||
Controller.api.buildPixelListShell('tiktok', __('Add TK Pixel')),
|
||||
' </div>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('');
|
||||
|
||||
Layer.open({
|
||||
type: 1,
|
||||
title: __('Pixel config') + ' - ' + Fast.api.escape(info.link_code || ''),
|
||||
area: ['1140px', '86vh'],
|
||||
maxmin: true,
|
||||
shadeClose: false,
|
||||
content: html,
|
||||
btn: [__('OK'), __('Close')],
|
||||
success: function (layero) {
|
||||
layero.addClass('split-pixel-layer');
|
||||
var $box = layero.find('.split-pixel-modal');
|
||||
var fillRows = function (platform, rows) {
|
||||
var $list = $box.find('.split-pixel-list[data-platform="' + platform + '"]');
|
||||
var $body = $list.find('tbody.split-pixel-list-body');
|
||||
$body.find('tr.split-pixel-row').remove();
|
||||
$.each(rows, function (_, rowData) {
|
||||
$body.append(Controller.api.buildPixelRowHtml(platform, rowData, eventOptions));
|
||||
});
|
||||
Controller.api.syncPixelListEmpty($list);
|
||||
};
|
||||
fillRows('facebook', fbRows);
|
||||
fillRows('tiktok', tkRows);
|
||||
|
||||
$box.on('click', '.btn-add-pixel-row', function () {
|
||||
var platform = $(this).data('platform');
|
||||
var $list = $box.find('.split-pixel-list[data-platform="' + platform + '"]');
|
||||
var $body = $list.find('tbody.split-pixel-list-body');
|
||||
var sortVal = $body.find('tr.split-pixel-row').length;
|
||||
$body.append(Controller.api.buildPixelRowHtml(platform, {
|
||||
id: Controller.api.pixelRowUid(platform === 'facebook' ? 'fb' : 'tk'),
|
||||
enabled: 1,
|
||||
server_postback: 0,
|
||||
pixel_id: '',
|
||||
access_token: '',
|
||||
test_code: '',
|
||||
event: 'PageView',
|
||||
sort: sortVal
|
||||
}, eventOptions));
|
||||
Controller.api.syncPixelListEmpty($list);
|
||||
var $wrap = $list.find('.split-pixel-table-wrap');
|
||||
if ($wrap.length) {
|
||||
$wrap.scrollTop($wrap[0].scrollHeight);
|
||||
}
|
||||
});
|
||||
|
||||
$box.on('click', '.btn-pixel-sort-up', function () {
|
||||
var $row = $(this).closest('tr.split-pixel-row');
|
||||
var $input = $row.find('.pixel-sort-input');
|
||||
$input.val(Math.max(0, (parseInt($input.val(), 10) || 0) + 1));
|
||||
});
|
||||
$box.on('click', '.btn-pixel-sort-down', function () {
|
||||
var $row = $(this).closest('tr.split-pixel-row');
|
||||
var $input = $row.find('.pixel-sort-input');
|
||||
$input.val(Math.max(0, (parseInt($input.val(), 10) || 0) - 1));
|
||||
});
|
||||
$box.on('click', '.btn-pixel-row-remove', function () {
|
||||
var $row = $(this).closest('tr.split-pixel-row');
|
||||
var $list = $row.closest('.split-pixel-list');
|
||||
$row.remove();
|
||||
Controller.api.syncPixelListEmpty($list);
|
||||
});
|
||||
$box.on('change', '.pixel-event', function () {
|
||||
var val = $(this).val() || '';
|
||||
$(this).attr('title', val);
|
||||
});
|
||||
},
|
||||
yes: function (index, layero) {
|
||||
var payload = Controller.api.collectPixelPayload(layero.find('.split-pixel-modal'));
|
||||
var invalid = false;
|
||||
$.each(payload.facebook.concat(payload.tiktok), function (_, item) {
|
||||
if (!$.trim(item.pixel_id)) {
|
||||
invalid = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (invalid) {
|
||||
Toastr.error(__('Pixel ID required'));
|
||||
return false;
|
||||
}
|
||||
Fast.api.ajax({
|
||||
url: 'split.link/pixel/ids/' + linkId,
|
||||
type: 'post',
|
||||
data: {pixel_config: payload}
|
||||
}, function () {
|
||||
Layer.close(index);
|
||||
Toastr.success(__('Pixel config saved'));
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
buildPixelListShell: function (platform, addBtnText) {
|
||||
return [
|
||||
'<div class="split-pixel-list" data-platform="' + platform + '">',
|
||||
' <div class="split-pixel-toolbar">',
|
||||
' <button type="button" class="btn btn-success btn-sm btn-add-pixel-row" data-platform="' + platform + '">',
|
||||
' <i class="fa fa-plus"></i> ' + addBtnText,
|
||||
' </button>',
|
||||
' </div>',
|
||||
' <div class="table-responsive split-pixel-table-wrap">',
|
||||
' <table class="table table-bordered table-hover split-pixel-table">',
|
||||
' <thead>',
|
||||
' <tr>',
|
||||
' <th width="52">' + __('Pixel row index') + '</th>',
|
||||
' <th width="58" title="' + __('Pixel enabled') + '">' + __('Pixel enabled') + '</th>',
|
||||
' <th width="78" title="' + __('Server postback') + '">' + __('Server postback') + '</th>',
|
||||
' <th width="140">' + __('Pixel ID') + ' <span class="text-danger">*</span></th>',
|
||||
' <th class="pixel-event-col">' + __('Pixel event') + '</th>',
|
||||
' <th class="col-token">' + __('Access Token') + '</th>',
|
||||
' <th width="108">' + __('Test code') + '</th>',
|
||||
' <th width="124">' + __('Pixel sort') + '</th>',
|
||||
' <th width="58">' + __('Operate') + '</th>',
|
||||
' </tr>',
|
||||
' </thead>',
|
||||
' <tbody class="split-pixel-list-body">',
|
||||
' <tr class="split-pixel-empty-row"><td colspan="9"><i class="fa fa-inbox" style="margin-right:6px;opacity:.5;"></i>' + __('Pixel list empty') + '</td></tr>',
|
||||
' </tbody>',
|
||||
' </table>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('');
|
||||
},
|
||||
syncPixelListEmpty: function ($list) {
|
||||
var $body = $list.find('tbody.split-pixel-list-body');
|
||||
var $rows = $body.find('tr.split-pixel-row');
|
||||
$body.find('tr.split-pixel-empty-row').toggle($rows.length === 0);
|
||||
$rows.each(function (idx) {
|
||||
$(this).find('.pixel-row-index').text(String(idx + 1));
|
||||
});
|
||||
},
|
||||
buildPixelRowHtml: function (platform, row, eventOptions) {
|
||||
row = row || {};
|
||||
var id = row.id || Controller.api.pixelRowUid(platform === 'facebook' ? 'fb' : 'tk');
|
||||
var enabled = parseInt(row.enabled, 10) === 1;
|
||||
var serverPostback = parseInt(row.server_postback, 10) === 1;
|
||||
var eventOpts = '';
|
||||
$.each(eventOptions, function (_, ev) {
|
||||
eventOpts += '<option value="' + ev + '"' + (row.event === ev ? ' selected' : '') + '>' + ev + '</option>';
|
||||
});
|
||||
var tokenPlaceholder = __('Optional');
|
||||
var tokenHint = row.has_access_token ? ' placeholder="' + tokenPlaceholder + ' (' + __('Optional') + ')"' : ' placeholder="' + tokenPlaceholder + '"';
|
||||
var selectedEvent = row.event || 'PageView';
|
||||
|
||||
return [
|
||||
'<tr class="split-pixel-row" data-row-id="' + Fast.api.escape(id) + '">',
|
||||
' <td class="text-center"><span class="pixel-row-index">-</span></td>',
|
||||
' <td class="pixel-switch-wrap"><input type="checkbox" class="pixel-enabled" title="' + __('Pixel enabled') + '" ' + (enabled ? 'checked' : '') + '></td>',
|
||||
' <td class="pixel-switch-wrap"><input type="checkbox" class="pixel-server-postback" title="' + __('Server postback') + '" ' + (serverPostback ? 'checked' : '') + '></td>',
|
||||
' <td><input type="text" class="form-control input-sm pixel-id" value="' + Fast.api.escape(row.pixel_id || '') + '" placeholder="' + __('Pixel ID') + '"></td>',
|
||||
' <td class="pixel-event-cell"><select class="form-control input-sm pixel-event" title="' + Fast.api.escape(selectedEvent) + '">' + eventOpts + '</select></td>',
|
||||
' <td class="col-token"><input type="text" class="form-control input-sm pixel-access-token" value=""' + tokenHint + '></td>',
|
||||
' <td><input type="text" class="form-control input-sm pixel-test-code" value="' + Fast.api.escape(row.test_code || '') + '" placeholder="' + tokenPlaceholder + '"></td>',
|
||||
' <td>',
|
||||
' <div class="input-group input-group-sm split-pixel-sort-group">',
|
||||
' <span class="input-group-btn"><button type="button" class="btn btn-default btn-pixel-sort-down" title="-1"><i class="fa fa-minus"></i></button></span>',
|
||||
' <input type="number" min="0" class="form-control pixel-sort-input" value="' + (parseInt(row.sort, 10) || 0) + '" title="' + __('Pixel sort') + '">',
|
||||
' <span class="input-group-btn"><button type="button" class="btn btn-default btn-pixel-sort-up" title="+1"><i class="fa fa-plus"></i></button></span>',
|
||||
' </div>',
|
||||
' </td>',
|
||||
' <td class="text-center">',
|
||||
' <button type="button" class="btn btn-danger btn-xs btn-pixel-row-remove" title="' + __('Remove row') + '"><i class="fa fa-trash"></i></button>',
|
||||
' </td>',
|
||||
'</tr>'
|
||||
].join('');
|
||||
},
|
||||
collectPixelPayload: function ($box) {
|
||||
var readList = function (platform) {
|
||||
var rows = [];
|
||||
$box.find('.split-pixel-list[data-platform="' + platform + '"] tbody .split-pixel-row').each(function () {
|
||||
var $row = $(this);
|
||||
rows.push({
|
||||
id: $row.attr('data-row-id') || Controller.api.pixelRowUid(platform === 'facebook' ? 'fb' : 'tk'),
|
||||
enabled: $row.find('.pixel-enabled').prop('checked') ? 1 : 0,
|
||||
server_postback: $row.find('.pixel-server-postback').prop('checked') ? 1 : 0,
|
||||
pixel_id: $.trim($row.find('.pixel-id').val()),
|
||||
access_token: $.trim($row.find('.pixel-access-token').val()),
|
||||
test_code: $.trim($row.find('.pixel-test-code').val()),
|
||||
event: $row.find('.pixel-event').val() || 'PageView',
|
||||
sort: Math.max(0, parseInt($row.find('.pixel-sort-input').val(), 10) || 0)
|
||||
});
|
||||
});
|
||||
return rows;
|
||||
};
|
||||
return {
|
||||
facebook: readList('facebook'),
|
||||
tiktok: readList('tiktok')
|
||||
};
|
||||
},
|
||||
loadCopyModalData: function (callback) {
|
||||
Fast.api.ajax({
|
||||
url: 'split.link/copyinfo',
|
||||
@@ -248,7 +610,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
});
|
||||
}
|
||||
var myDomains = $.isArray(data.my_domains) ? data.my_domains : [];
|
||||
var domainIndexUrl = data.domain_index_url || 'domain/index';
|
||||
var domainIndexUrl = Controller.api.normalizeAdminRouteUrl(data.domain_index_url, 'domain');
|
||||
var domainAddUrl = Controller.api.normalizeAdminRouteUrl(data.domain_add_url, 'domain/add');
|
||||
var configIndexUrl = data.config_index_url || 'general/config/index';
|
||||
var defaultType = platformDomains.length ? 'platform' : 'my';
|
||||
var defaultDomain = platformDomains.length ? platformDomains[0] : (myDomains.length ? myDomains[0].domain : '');
|
||||
@@ -383,10 +746,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
Controller.api.copyText(linkCode);
|
||||
});
|
||||
|
||||
$box.on('click', '.btn-manage-domain, .btn-go-add-domain', function (e) {
|
||||
$box.on('click', '.btn-manage-domain', function (e) {
|
||||
e.preventDefault();
|
||||
Layer.close(index);
|
||||
Backend.api.addtabs(Fast.api.fixurl(domainIndexUrl), __('Manage my domains'), 'fa fa-globe');
|
||||
Backend.api.addtabs(Fast.api.fixurl(domainIndexUrl), __('Domain management'), 'fa fa-globe');
|
||||
});
|
||||
|
||||
$box.on('click', '.btn-go-add-domain', function (e) {
|
||||
e.preventDefault();
|
||||
Layer.close(index);
|
||||
Backend.api.addtabs(Fast.api.fixurl(domainAddUrl), __('Domain management'), 'fa fa-plus');
|
||||
});
|
||||
|
||||
$box.on('click', '.btn-goto-config', function (e) {
|
||||
@@ -431,8 +800,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
var statusHtml = '';
|
||||
if (options.showStatus) {
|
||||
statusHtml = '<span class="split-domain-status">'
|
||||
+ '<span class="label ' + Controller.api.statusLabelClass(options.nsStatus) + '">NS:' + Fast.api.escape(options.nsText || '-') + '</span>'
|
||||
+ '<span class="label ' + Controller.api.statusLabelClass(options.dnsStatus, true) + '">DNS:' + Fast.api.escape(options.dnsText || '-') + '</span>'
|
||||
+ '<span class="label ' + Controller.api.statusLabelClass(options.nsStatus) + '">' + __('NS') + ':' + Fast.api.escape(options.nsText || '-') + '</span>'
|
||||
+ '<span class="label ' + Controller.api.statusLabelClass(options.dnsStatus, true) + '">' + __('DNS') + ':' + Fast.api.escape(options.dnsText || '-') + '</span>'
|
||||
+ '</span>';
|
||||
}
|
||||
return '<div class="split-domain-item' + checkedClass + '">'
|
||||
|
||||
Reference in New Issue
Block a user