Add generate link modal
This commit is contained in:
parent
499b604cc3
commit
2238a52c40
@ -469,6 +469,43 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="generate-link-modal" tabindex="-1" role="dialog" style="overflow: hidden">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="cursor: move">
|
||||
<button type="button" class="close cancel-callback" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title"><?php echo $hesklang['genl']; ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p><?php echo $hesklang['genl2']; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 form-group">
|
||||
<div class="input-group">
|
||||
<input type="text" id="link" class="form-control white-readonly"
|
||||
title="<?php echo $hesklang['genl']; ?>" readonly>
|
||||
<div class="input-group-addon button" data-toggle="tooltip" title="Copy to clipboard"
|
||||
style="padding:0; border: none">
|
||||
<button class="btn btn-primary">
|
||||
<i class="fa fa-files-o"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default cancel-button cancel-callback" data-dismiss="modal">
|
||||
<i class="fa fa-times-circle"></i>
|
||||
<span><?php echo $hesklang['close_modal']; ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/html" id="category-row-template">
|
||||
<tr>
|
||||
<td><span data-property="id" data-value="x"></span></td>
|
||||
@ -498,12 +535,10 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
<i class="fa fa-fw fa-calendar icon-link" data-toggle="tooltip" title="<?php echo $hesklang['events']; ?>"></i>
|
||||
</td>
|
||||
<td>
|
||||
<span class="generate-link-group">
|
||||
<a data-property="generate-link" href="#">
|
||||
<i class="fa fa-fw icon-link" data-toggle="tooltip"
|
||||
data-placement="top"></i>
|
||||
</a>
|
||||
</span>
|
||||
<span class="sort-arrows">
|
||||
<a href="#" data-action="sort"
|
||||
data-direction="up">
|
||||
@ -550,102 +585,6 @@ echo mfh_get_hidden_fields_for_language(array(
|
||||
require_once(HESK_PATH . 'inc/footer.inc.php');
|
||||
exit();
|
||||
|
||||
|
||||
/*** START FUNCTIONS ***/
|
||||
|
||||
|
||||
function change_priority()
|
||||
{
|
||||
global $hesk_settings, $hesklang, $priorities;
|
||||
|
||||
/* A security check */
|
||||
hesk_token_check('POST');
|
||||
|
||||
$_SERVER['PHP_SELF'] = 'manage_categories.php?catid=' . intval(hesk_POST('catid'));
|
||||
|
||||
$catid = hesk_isNumber(hesk_POST('catid'), $hesklang['choose_cat_ren'], $_SERVER['PHP_SELF']);
|
||||
$_SESSION['selcat'] = $catid;
|
||||
$_SESSION['selcat2'] = $catid;
|
||||
|
||||
$priority = intval(hesk_POST('priority', 3));
|
||||
if (!array_key_exists($priority, $priorities)) {
|
||||
$priority = 3;
|
||||
}
|
||||
|
||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` SET `priority`='{$priority}' WHERE `id`='" . intval($catid) . "'");
|
||||
|
||||
hesk_cleanSessionVars('cat_ch_priority');
|
||||
|
||||
hesk_process_messages($hesklang['cat_pri_ch'] . ' ' . $priorities[$priority]['formatted'], $_SERVER['PHP_SELF'], 'SUCCESS');
|
||||
} // END change_priority()
|
||||
|
||||
|
||||
function generate_link_code() {
|
||||
global $hesk_settings, $hesklang;
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML; 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
<head>
|
||||
<title><?php echo $hesklang['genl']; ?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=<?php echo $hesklang['ENCODING']; ?>" />
|
||||
<style type="text/css">
|
||||
body
|
||||
{
|
||||
margin:5px 5px;
|
||||
padding:0;
|
||||
background:#fff;
|
||||
color: black;
|
||||
font : 68.8%/1.5 Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
p
|
||||
{
|
||||
color : black;
|
||||
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 1.0em;
|
||||
}
|
||||
h3
|
||||
{
|
||||
color : #AF0000;
|
||||
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-weight: bold;
|
||||
font-size: 1.0em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="text-center">
|
||||
|
||||
<h3><?php echo $hesklang['genl']; ?></h3>
|
||||
|
||||
<?php
|
||||
if ( ! empty($_GET['p']) )
|
||||
{
|
||||
echo '<p> <br />' . $hesklang['cpric'] . '<br /> </p>';
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<p><i><?php echo $hesklang['genl2']; ?></i></p>
|
||||
|
||||
<textarea rows="3" cols="50" onfocus="this.select()"><?php echo $hesk_settings['hesk_url'].'/index.php?a=add&catid='.intval( hesk_GET('catid') ); ?></textarea>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<p align="center"><a href="#" onclick="Javascript:window.close()"><?php echo $hesklang['cwin']; ?></a></p>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
function new_cat()
|
||||
{
|
||||
global $hesk_settings, $hesklang;
|
||||
|
@ -325,3 +325,12 @@ div.ticket-info {
|
||||
#toast-container > div {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.input-group-addon {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.input-group-addon.button > button {
|
||||
border-radius: 0;
|
||||
}
|
@ -75,6 +75,7 @@ header('X-UA-Compatible: IE=edge');
|
||||
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/jquery.magnific-popup.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
||||
<script type="text/javascript" src="<?php echo HESK_PATH; ?>internal-api/js/alerts.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
||||
<script type="text/javascript" src="<?php echo HESK_PATH; ?>internal-api/js/lang.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
||||
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/clipboard.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
||||
<?php
|
||||
if (defined('EXTRA_JS')) {
|
||||
echo EXTRA_JS;
|
||||
@ -306,6 +307,7 @@ if (defined('MFH_PAGE_LAYOUT') && MFH_PAGE_LAYOUT == 'TOP_ONLY') {
|
||||
unset($onload); ?>" class="<?php echo $layout_tag ?> fixed js">
|
||||
|
||||
<?php // GLOBAL JAVASCRIPT IDs ?>
|
||||
<p style="display: none" id="hesk-url"><?php echo $hesk_settings['hesk_url']; ?></p>
|
||||
<p style="display: none" id="hesk-path"><?php echo HESK_PATH; ?></p>
|
||||
<p style="display: none" id="admin-dir"><?php echo $hesk_settings['admin_dir']; ?></p>
|
||||
<p style="display: none" id="lang_alert_success"><?php echo $hesklang['alert_success']; ?></p>
|
||||
|
@ -7,6 +7,7 @@ $(document).ready(function() {
|
||||
bindFormSubmit();
|
||||
bindDeleteButton();
|
||||
bindCreateModal();
|
||||
bindGenerateLinkModal();
|
||||
});
|
||||
|
||||
|
||||
@ -73,7 +74,9 @@ function loadTable() {
|
||||
$template.find('div.progress').attr('title', percentText.replace('%s', percentage + '%'));
|
||||
$template.find('div.progress-bar').attr('aria-value-now', percentage).css('width', percentage + '%');
|
||||
|
||||
$template.find('[data-property="generate-link"]').find('i').attr('title', mfhLang.text('geco'));
|
||||
$template.find('[data-property="generate-link"]')
|
||||
.attr('data-category-id', this.id)
|
||||
.find('i').attr('title', mfhLang.text('geco'));
|
||||
|
||||
if (this.usage === 1) {
|
||||
// Tickets only
|
||||
@ -319,3 +322,21 @@ function bindDeleteButton() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function bindGenerateLinkModal() {
|
||||
$(document).on('click', '[data-property="generate-link"] i.fa-code', function () {
|
||||
|
||||
var $modal = $('#generate-link-modal');
|
||||
|
||||
var heskUrl = $('p#hesk-url').text();
|
||||
|
||||
var url = heskUrl + '/index.php?a=add&catid=' + $(this).parent().data('category-id');
|
||||
|
||||
$modal.find('input[type="text"]').val(url).end()
|
||||
.find('.input-group-addon').click(function() {
|
||||
clipboard.copy($modal.find('input[type="text"]').val());
|
||||
mfhAlert.success('Copied to clipboard', 'Success');
|
||||
}).end()
|
||||
.modal('show');
|
||||
});
|
||||
}
|
9
js/clipboard.min.js
vendored
Normal file
9
js/clipboard.min.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
(function(e,c){"undefined"!==typeof module?module.exports=c():"function"===typeof define&&"object"===typeof define.amd?define(c):this[e]=c()})("clipboard",function(){if("undefined"===typeof document||!document.addEventListener)return null;var e={};e.copy=function(){function c(){d=!1;b=null;g&&window.getSelection().removeAllRanges();g=!1}var d=!1,b=null,g=!1;document.addEventListener("copy",function(c){if(d){for(var g in b)c.clipboardData.setData(g,b[g]);c.preventDefault()}});return function(f){return new Promise(function(m,
|
||||
e){function k(b){try{if(document.execCommand("copy"))c(),m();else{if(b)throw c(),Error("Unable to copy. Perhaps it's not available in your browser?");var d=document.getSelection();if(!document.queryCommandEnabled("copy")&&d.isCollapsed){var f=document.createRange();f.selectNodeContents(document.body);d.removeAllRanges();d.addRange(f);g=!0}k(!0)}}catch(a){c(),e(a)}}d=!0;"string"===typeof f?b={"text/plain":f}:f instanceof Node?b={"text/html":(new XMLSerializer).serializeToString(f)}:f instanceof Object?
|
||||
b=f:e("Invalid data type. Must be string, DOM node, or an object mapping MIME types to strings.");k(!1)})}}();e.paste=function(){var c=!1,d,b;document.addEventListener("paste",function(g){if(c){c=!1;g.preventDefault();var f=d;d=null;f(g.clipboardData.getData(b))}});return function(g){return new Promise(function(f,e){c=!0;d=f;b=g||"text/plain";try{document.execCommand("paste")||(c=!1,e(Error("Unable to paste. Pasting only works in Internet Explorer at the moment.")))}catch(h){c=!1,e(Error(h))}})}}();
|
||||
"undefined"===typeof ClipboardEvent&&"undefined"!==typeof window.clipboardData&&"undefined"!==typeof window.clipboardData.setData&&(function(c){function d(a,b){return function(){a.apply(b,arguments)}}function b(a){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof a)throw new TypeError("not a function");this._value=this._state=null;this._deferreds=[];l(a,d(f,this),d(e,this))}function g(a){var b=this;return null===this._state?void this._deferreds.push(a):
|
||||
void n(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(e){return void a.reject(e)}a.resolve(d)})}function f(a){try{if(a===this)throw new TypeError("A promise cannot be resolved with itself.");if(a&&("object"==typeof a||"function"==typeof a)){var b=a.then;if("function"==typeof b)return void l(d(b,a),d(f,this),d(e,this))}this._state=!0;this._value=a;h.call(this)}catch(c){e.call(this,c)}}function e(a){this._state=
|
||||
!1;this._value=a;h.call(this)}function h(){for(var a=0,b=this._deferreds.length;b>a;a++)g.call(this,this._deferreds[a]);this._deferreds=null}function k(a,b,c,d){this.onFulfilled="function"==typeof a?a:null;this.onRejected="function"==typeof b?b:null;this.resolve=c;this.reject=d}function l(a,b,c){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,c(a))})}catch(e){d||(d=!0,c(e))}}var n=b.immediateFn||"function"==typeof setImmediate&&setImmediate||function(a){setTimeout(a,1)},p=Array.isArray||
|
||||
function(a){return"[object Array]"===Object.prototype.toString.call(a)};b.prototype["catch"]=function(a){return this.then(null,a)};b.prototype.then=function(a,c){var d=this;return new b(function(b,e){g.call(d,new k(a,c,b,e))})};b.all=function(){var a=Array.prototype.slice.call(1===arguments.length&&p(arguments[0])?arguments[0]:arguments);return new b(function(b,c){function d(f,g){try{if(g&&("object"==typeof g||"function"==typeof g)){var h=g.then;if("function"==typeof h)return void h.call(g,function(a){d(f,
|
||||
a)},c)}a[f]=g;0===--e&&b(a)}catch(k){c(k)}}if(0===a.length)return b([]);for(var e=a.length,f=0;f<a.length;f++)d(f,a[f])})};b.resolve=function(a){return a&&"object"==typeof a&&a.constructor===b?a:new b(function(b){b(a)})};b.reject=function(a){return new b(function(b,c){c(a)})};b.race=function(a){return new b(function(b,c){for(var d=0,e=a.length;e>d;d++)a[d].then(b,c)})};"undefined"!=typeof module&&module.exports?module.exports=b:c.Promise||(c.Promise=b)}(this),e.copy=function(c){return new Promise(function(d,
|
||||
b){if("string"!==typeof c&&!("text/plain"in c))throw Error("You must provide a text/plain type.");window.clipboardData.setData("Text","string"===typeof c?c:c["text/plain"])?d():b(Error("Copying was rejected."))})},e.paste=function(){return new Promise(function(c,d){var b=window.clipboardData.getData("Text");b?c(b):d(Error("Pasting was rejected."))})});return e});
|
Loading…
x
Reference in New Issue
Block a user