Переглянути джерело

exported TableAjax init from TableAjax

Piotr Labudda 8 роки тому
батько
коміт
0382cb6d76
3 змінених файлів з 253 додано та 264 видалено
  1. 38 262
      SE/se-lib/TableAjax.php
  2. 2 2
      SE/se-lib/TableAjax.php.create.js
  3. 213 0
      SE/se-lib/TableAjax.php.init.js

+ 38 - 262
SE/se-lib/TableAjax.php

@@ -536,7 +536,7 @@ class TableAjax extends ViewAjax {
 		'TABLE_AJAX_NODE_ID' => $this->_htmlID,
 		'TABLE_AJAX_LABEL' => $this->getLabelHtml(),
 		'NAMESPACE' => $acl->getNamespace(),
-		'FIRCE_FILER_INIT' => $forceFilterInit,
+		'FIRCE_FILTER_INIT' => $forceFilterInit,
 		'FUNCTION_CREATE_ROUTE' => "TableAjax__CREATE_Route",
 		'URL_CREATE_FORM_AJAX' => "{$this->syncUrl}&_hash={$this->_htmlID}&_task=createFormJson",
 	]);
@@ -549,268 +549,44 @@ class TableAjax extends ViewAjax {
 	]);
 	UI::inlineJS(__FILE__ . '.openRef.js', []); // p5UI__tableAjaxOpenRefCell
 
-	$fltrs = (method_exists($acl, 'getSpecialFilters')) ? $acl->getSpecialFilters() : null;
-	$jsonSpecialFilters = (!empty($fltrs)) ? json_encode($fltrs) : 'false';
+	$specialFilters = (method_exists($acl, 'getSpecialFilters')) ? $acl->getSpecialFilters() : null;
 	$className = __CLASS__;
-?>
-		<script>
-var TABLE_AJAX_NODE_ID = '<?= $this->_htmlID; ?>';
-var NAMESPACE = '<?= $acl->getNamespace(); ?>';
-var FUNCTION_HIST_ROUTE = window['TableAjax__HIST_Route'];
-var FUNCTION_EDIT_ROUTE = window['TableAjax__EDIT_Route'];
-var URL_LOAD_AJAX_BASE = '<?= $this->syncUrl; ?>&_hash=<?= $this->_htmlID; ?>&_task=loadDataAjax';
-var URL_USER_TABLE_FILTER = '<?= ($this->useUserTableFilter) ? $this->useUserTableFilter : ''; ?>';
-var FILER_INIT = <?= json_encode($filterInit); ?>;
-var FIRCE_FILER_INIT = <?= json_encode($forceFilterInit); ?>;
-var PAGE_SIZE = '<?= $pageSize; ?>';
-var PAGE_SIZES = <?= json_encode($pageSizes); ?>;
-var URL_REMOVE_THE_GEOM_AJAX = '<?= "{$this->syncUrl}&_hash={$this->_htmlID}&_task=removeTheGeomAjax"; ?>';
-var URL_MORE_FUNCTIONS_CELL_AJAX = '<?= "{$this->syncUrl}&_hash={$this->_htmlID}&_task=moreFunctionsCellAjax"; ?>';
-var URL_EDIT_INLINE_SAVE = '<?= "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=EDIT_INLINE_SAVE"; ?>';
-var URL_THE_GEOM_SAVE = '<?= "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=THE_GEOM_SAVE"; ?>';
-var URL_PAGE_SIZE_SAVE = '<?= "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=PAGE_SIZE_SAVE"; ?>';
-var URL_HIDDEN_COLS_SAVE = '<?= "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=HIDDEN_COLS_SAVE"; ?>';
-var URL_EDIT_INLINE = '<?= "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=EDIT_INLINE"; ?>';
-var HAS_ADDITIONAL_LAYERS = <?= $this->hasAdditionalLayers() ? 1 : 0; ?>;
-var URL_ADD_USER_TABLE_FILTER_AJAX = '<?= Request::getPathUri() . "index.php?_route=ViewTableAjax&_task=addUserTableFilterAjax"; ?>';
-var URL_RM_USER_TABLE_FILTER_AJAX = '<?= Request::getPathUri() . "index.php?_route=ViewTableAjax&_task=rmUserTableFilterAjax"; ?>';
-var LABEL_HTML = '<?= $this->getLabelHtml(); ?>';
-
-jQuery(document).ready(function(){
-	jQuery('#' + TABLE_AJAX_NODE_ID).TableAjax({
-		namespace: NAMESPACE,
-		url: URL_LOAD_AJAX_BASE,
-		removeTheGeomAjaxUrl: URL_REMOVE_THE_GEOM_AJAX,
-		moreFunctionsCellAjaxUrl: URL_MORE_FUNCTIONS_CELL_AJAX,
-		editInlineSaveUrl: URL_EDIT_INLINE_SAVE,
-		theGeomSaveUrl: URL_THE_GEOM_SAVE,
-		pageSizeSave: URL_PAGE_SIZE_SAVE,
-		hiddenColsSaveUrl: URL_HIDDEN_COLS_SAVE,
-		editInlineUrl: URL_EDIT_INLINE,
-		addUserTableFilterAjaxUrl: URL_ADD_USER_TABLE_FILTER_AJAX,
-		rmUserTableFilterAjaxUrl: URL_RM_USER_TABLE_FILTER_AJAX,
-		hasAdditionalLayers: HAS_ADDITIONAL_LAYERS,
-		labelHtml: LABEL_HTML,
-		userTableFilterUrl: URL_USER_TABLE_FILTER,
-		columnPicker: true,
-		filter: true,
-		filterInit: FILER_INIT,
-		forceFilterInit: FIRCE_FILER_INIT,
-		debug: false,
-		height: 400,
-		sorting: true,
-		paging: true,
-		pageSize: PAGE_SIZE,
-		pageSizes: PAGE_SIZES,
-		tblFunctions: {
-			shortdesc: {
-				icon: 'align-left',
-				title: 'Long desc',
-				method: 'longTextChanged'
-			},
-			<?php if ($hasGeomFlds) : ?>
-				mapeditor: {
-					icon: 'map-marker',
-					title: 'Mapa',
-					method: 'mapEditorChanged'
-				},
-			<?php endif; ?>
-			create: {
-				href: '#CREATE',
-				icon: 'plus',
-				title: 'Dodaj nowy rekord'
-			},
-			refresh: {
-				icon: 'refresh',
-				title: 'Odśwież dane',
-				method: 'refresh'
-			}
-		},
-		rowFunctions: <?php echo json_encode($rowFunctions); ?>,
-		exportFields: <?php echo json_encode($exportFields); ?>,
-		specialFilterFunctions: <?= $jsonSpecialFilters; ?>,
-		router: function() {
-			var routes = {
-				EDIT: FUNCTION_EDIT_ROUTE,
-				HIST: FUNCTION_HIST_ROUTE,
-				FILES: function tableAjaxFiles(args) {
-					var recordID = args;
-					if (typeof args == 'object') {
-						recordID = args.shift();
-						recordID = parseInt(recordID);
-					}
-					if (typeof recordID !== 'number' || recordID <= 0) {
-						// TODO: msg
-						return false;
-					}
-					var cont = jQuery('#<?php echo $this->_htmlID; ?>').parent();
-					cont.hide();
-
-					// remove previous task content
-					var taskCnt = jQuery('#<?php echo $this->_htmlID; ?>_task');
-					taskCnt.parent().remove();
-					taskCnt.remove();
-
-					var taskCont = jQuery('<div class="AjaxTableCont"></div>').insertBefore(cont);
-					jQuery('<ul class="breadcrumb">' +
-						'<li><a href="#" onclick="return tableAjaxBackToTable();"><?php echo $this->getLabelHtml(); ?></a></li>' +
-						'<li class="active">Pliki</li>' +
-					'</ul>').appendTo(taskCont);
-					var taskCnt = jQuery('<div id="<?php echo $this->_htmlID . '_task'; ?>" class="AjaxTable-loading"></div>').appendTo(taskCont);
-					jQuery('<span class="loading-info"> loading ...</span>').appendTo(taskCnt);
-
-					jQuery.ajax({
-						url: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=FILES&ID=' + recordID,
-						type: 'GET',
-						dataType: 'text',
-						data: '',
-						async: true,
-						success: function(data) {
-							taskCnt.removeClass('AjaxTable-loading');
-							//console.log('request finished L.<?php echo __LINE__; ?>', data);
-							jQuery(data).appendTo(taskCnt);
-						},
-						error: function(jqXHR, textStatus, errorThrown) {
-							//console.log('request error:', jqXHR.status, 'txt:', jqXHR.responseText, 'err:', jqXHR);
-							taskCnt.removeClass('AjaxTable-loading');
-							var txt = jqXHR.responseText || 'Error';
-							if (jqXHR.status == 404) {
-								jQuery('<div class="container"><div class="alert alert-danger">' + txt + '</div></div>').appendTo(taskCnt);
-							} else {
-								jQuery('<div class="container"><div class="alert alert-danger">' + txt + '</div></div>').appendTo(taskCnt);
-							}
-						}
-					});
-					//return false;
-				},
-				CREATE: TableAjax__CREATE_Route,
-			};
-			var routePath = location.hash;
-			//console.log('location.hash: ' + routePath);
-			if (location.hash == '' || location.hash == '#') {
-				return false;
-			}
-			if (routePath.charAt(0) == '#') {
-				routePath = routePath.substr(1);
-			}
-			//console.log('routePath: ' + routePath);
-			var parts = routePath.split('/');
-			var task = parts.shift();
-			//console.log('task(' + task + ') parts:');
-			//console.log(parts);
-			if (task in routes && typeof routes[task] == 'function') {
-				var con = jQuery('#<?php echo $this->_htmlID; ?>');
-				if (con) {
-					var tblAjax = con.data('TableAjax');
-					if (tblAjax) {
-						tblAjax.popoverCellRemove();
-					}
-				}
-				routes[task](parts);
-			} else {
-				return false;
-			}
-		},
-		filtersClean: true,
-		longDesc: true
-	});
-});
-
-function tableAjaxBackToTable() {
-	var cont = jQuery('#<?php echo $this->_htmlID; ?>').parent();
-	cont.show();
-	var taskCont = jQuery('#<?php echo $this->_htmlID . '_task'; ?>').parent();
-	taskCont.remove();
-
-	// reload first page
-	var con = jQuery('#<?php echo $this->_htmlID; ?>');
-	con.TableAjaxLoadPage();// TODO: load current page
-}
-
-function tableAjaxCopy(args) {
-	var recordID = args;
-	if (typeof args == 'object') {
-		recordID = args.shift();
-		recordID = parseInt(recordID);
-	}
-	if (typeof recordID !== 'number' || recordID <= 0) {
-		// TODO: msg
-		return false;
-	}
-
-	if (!confirm('Czy na pewno chcesz utworzyc nowy rekord na podstawie danych z rekordu ID = ' + recordID + '?')) {
-		return false;
-	}
-
-	var cont = jQuery('#<?php echo $this->_htmlID; ?>').parent();
-
-	function notifyAjaxCallback(data) {
-		var notify = {};
-		notify.type = (data && data.type)? data.type : '';
-		notify.msg = (data && data.msg)? data.msg : '';
-		switch (notify.type) {
-			case 'success':
-				if (!notify.msg) notify.msg = 'OK';
-				break;
-			case 'info':
-				if (!notify.msg) notify.msg = '';
-				break;
-			case 'error':
-				if (!notify.msg) notify.msg = 'Wystąpiły błędy';
-				break;
-			case 'warning':
-				notify.type = 'warn';
-				if (!notify.msg) notify.msg = 'Wystąpiły błędy';
-				break;
-			default:
-				notify.msg = 'Nieznany błąd';
-				if (data && data.errorCode) notify.msg += ' ' + data.errorCode;
-				notify.type = '';
-		}
-		jQuery.notify(notify.msg, notify.type);
-	}
-
-	var reqData = {};
-	jQuery.ajax({
-		data: reqData,
-		dataType: 'json',
-		type: "GET",
-		url: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=COPY&ID=' + recordID,
-	})
-	.done(function(data, textStatus, jqXHR){
-		var con = jQuery('#<?php echo $this->_htmlID; ?>');
-		con.TableAjaxRefresh();
-		notifyAjaxCallback(data);
-	})
-	.fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
-		if (jqXHR.responseJSON) {
-			notifyAjaxCallback(jqXHR.responseJSON);
-		}
-		else {
-			var txt = jqXHR.responseText || 'Wystąpiły błędy';
-			if (jqXHR.status == 404) {
-				jQuery.notify(jqXHR.responseText, 'error');
-			} else {
-				jQuery.notify(jqXHR.responseText, 'warn');
-			}
-		}
-	});
-
-	return false;
-}
-
-function hidePopover() {
-	var con = jQuery('#<?php echo $this->_htmlID; ?>');
-	if (con) {
-		var tblAjax = con.data('TableAjax');
-		if (tblAjax) {
-			tblAjax.popoverCellRemove();
-		}
-	}
-	return false;
-}
-		</script>
-		<?php
+		UI::inlineJS(__FILE__ . '.init.js', [
+			'TABLE_AJAX_NODE_ID' => $this->_htmlID,
+			'NAMESPACE' => $acl->getNamespace(),
+			'FUNCTION_HIST_ROUTE' => 'TableAjax__HIST_Route',
+			'FUNCTION_EDIT_ROUTE' => 'TableAjax__EDIT_Route',
+			'URL_LOAD_AJAX_BASE' => $this->syncUrl . '&_hash=' . $this->_htmlID . '&_task=loadDataAjax',
+			'URL_USER_TABLE_FILTER' => ($this->useUserTableFilter) ? $this->useUserTableFilter : '',
+			'FILTER_INIT' => $filterInit,
+			'FIRCE_FILTER_INIT' => $forceFilterInit,
+			'PAGE_SIZE' => $pageSize,
+			'PAGE_SIZES' => $pageSizes,
+			'URL_REMOVE_THE_GEOM_AJAX' => "{$this->syncUrl}&_hash={$this->_htmlID}&_task=removeTheGeomAjax",
+			'URL_MORE_FUNCTIONS_CELL_AJAX' => "{$this->syncUrl}&_hash={$this->_htmlID}&_task=moreFunctionsCellAjax",
+			'URL_EDIT_INLINE_SAVE' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=EDIT_INLINE_SAVE",
+			'URL_THE_GEOM_SAVE' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=THE_GEOM_SAVE",
+			'URL_PAGE_SIZE_SAVE' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=PAGE_SIZE_SAVE",
+			'URL_HIDDEN_COLS_SAVE' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=HIDDEN_COLS_SAVE",
+			'URL_EDIT_INLINE' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=EDIT_INLINE",
+			'URL_RECORD_COPY' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=COPY",
+			'URL_RECORD_FILES' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$className}&_hash={$this->_htmlID}&_task=FILES",
+			'HAS_ADDITIONAL_LAYERS' => $this->hasAdditionalLayers() ? 1 : 0,
+			'URL_ADD_USER_TABLE_FILTER_AJAX' => Request::getPathUri() . "index.php?_route=ViewTableAjax&_task=addUserTableFilterAjax",
+			'URL_RM_USER_TABLE_FILTER_AJAX' => Request::getPathUri() . "index.php?_route=ViewTableAjax&_task=rmUserTableFilterAjax",
+			'LABEL_HTML' => $this->getLabelHtml(),
+			'SPECIAL_FILTER_FUNCTIONS' => (!empty($specialFilters)) ? $specialFilters : 'false',
+			'ROW_FUNCTIONS' => $rowFunctions,
+			'TABLE_FUNCTIONS' => array_merge(
+				[ 'shortdesc' => [ 'icon' => "align-left", 'title' => "Long desc", 'method' => "longTextChanged" ] ],
+				($hasGeomFlds)
+					? [ 'mapeditor' => [ 'icon' => "map-marker", 'title' => "Mapa", 'method' => 'mapEditorChanged' ] ]
+					: [],
+				[ 'create' =>  [ 'href' => '#CREATE', 'icon' => 'plus', 'title' => "Dodaj nowy rekord" ] ],
+				[ 'refresh' => [ 'icon' => 'refresh', 'title' => "Odśwież dane", 'method' => "refresh" ] ]
+			),
+			'EXPORT_FIELDS' => $exportFields,
+		]);
 		UI::inlineJS(__FILE__ . '.upload.js', [
 			'URL_UPLOAD_FILES_AJAX' => "index.php?_route=ViewTableAjax&_task=uploadFilesAjax",
 		]);

+ 2 - 2
SE/se-lib/TableAjax.php.create.js

@@ -2,7 +2,7 @@
 if ('undefined' === typeof TABLE_AJAX_NODE_ID) throw "Missing TABLE_AJAX_NODE_ID"; // $this->_htmlID,
 if ('undefined' === typeof TABLE_AJAX_LABEL) throw "Missing TABLE_AJAX_LABEL"; // this->getLabelHtml()
 if ('undefined' === typeof NAMESPACE) throw "Missing NAMESPACE";
-if ('undefined' === typeof FIRCE_FILER_INIT) throw "Missing FIRCE_FILER_INIT";
+if ('undefined' === typeof FIRCE_FILTER_INIT) throw "Missing FIRCE_FILTER_INIT";
 if ('undefined' === typeof FUNCTION_CREATE_ROUTE) throw "Missing FUNCTION_CREATE_ROUTE";
 if ('undefined' === typeof URL_CREATE_FORM_AJAX) throw "Missing URL_CREATE_FORM_AJAX";
 
@@ -24,7 +24,7 @@ function TableAjax__CREATE_Route() {
 	jQuery('<span class="loading-info"> loading ...</span>').appendTo(taskCnt);
 
 	var reqData = [];
-	var forceFilterInit = FIRCE_FILER_INIT; // TODO: read from TableAjax
+	var forceFilterInit = FIRCE_FILTER_INIT; // TODO: read from TableAjax
 	if (forceFilterInit) {
 		$.map(forceFilterInit, function(fltrProps, fltr) {
 			reqData.push('ff_' + fltr + '=' + fltrProps);

+ 213 - 0
SE/se-lib/TableAjax.php.init.js

@@ -0,0 +1,213 @@
+jQuery(document).ready(function(){
+	jQuery('#' + TABLE_AJAX_NODE_ID).TableAjax({
+		namespace: NAMESPACE,
+		url: URL_LOAD_AJAX_BASE,
+		removeTheGeomAjaxUrl: URL_REMOVE_THE_GEOM_AJAX,
+		moreFunctionsCellAjaxUrl: URL_MORE_FUNCTIONS_CELL_AJAX,
+		editInlineSaveUrl: URL_EDIT_INLINE_SAVE,
+		theGeomSaveUrl: URL_THE_GEOM_SAVE,
+		pageSizeSave: URL_PAGE_SIZE_SAVE,
+		hiddenColsSaveUrl: URL_HIDDEN_COLS_SAVE,
+		editInlineUrl: URL_EDIT_INLINE,
+		addUserTableFilterAjaxUrl: URL_ADD_USER_TABLE_FILTER_AJAX,
+		rmUserTableFilterAjaxUrl: URL_RM_USER_TABLE_FILTER_AJAX,
+		hasAdditionalLayers: HAS_ADDITIONAL_LAYERS,
+		labelHtml: LABEL_HTML,
+		userTableFilterUrl: URL_USER_TABLE_FILTER,
+		columnPicker: true,
+		filter: true,
+		filterInit: FILTER_INIT,
+		forceFilterInit: FIRCE_FILTER_INIT,
+		debug: false,
+		height: 400,
+		sorting: true,
+		paging: true,
+		pageSize: PAGE_SIZE,
+		pageSizes: PAGE_SIZES,
+		tblFunctions: TABLE_FUNCTIONS,
+		rowFunctions: ROW_FUNCTIONS,
+		exportFields: EXPORT_FIELDS,
+		specialFilterFunctions: SPECIAL_FILTER_FUNCTIONS,
+		router: function() {
+			var routes = {
+				EDIT: global[FUNCTION_EDIT_ROUTE],
+				HIST: global[FUNCTION_HIST_ROUTE],
+				FILES: function tableAjaxFiles(args) {
+					var recordID = args;
+					if (typeof args == 'object') {
+						recordID = args.shift();
+						recordID = parseInt(recordID);
+					}
+					if (typeof recordID !== 'number' || recordID <= 0) {
+						// TODO: msg
+						return false;
+					}
+					var cont = jQuery('#' + TABLE_AJAX_NODE_ID).parent();
+					cont.hide();
+
+					// remove previous task content
+					var taskCnt = jQuery('#' + TABLE_AJAX_NODE_ID + '_task');
+					taskCnt.parent().remove();
+					taskCnt.remove();
+
+					var taskCont = jQuery('<div class="AjaxTableCont"></div>').insertBefore(cont);
+					jQuery('<ul class="breadcrumb">' +
+						'<li><a href="#" onclick="return tableAjaxBackToTable();">' + LABEL_HTML + '</a></li>' +
+						'<li class="active">Pliki</li>' +
+					'</ul>').appendTo(taskCont);
+					var taskCnt = jQuery('<div id="' + TABLE_AJAX_NODE_ID + '_task" class="AjaxTable-loading"></div>').appendTo(taskCont);
+					jQuery('<span class="loading-info"> loading ...</span>').appendTo(taskCnt);
+
+					jQuery.ajax({
+						url: URL_RECORD_FILES + '&ID=' + recordID,
+						type: 'GET',
+						dataType: 'text',
+						data: '',
+						async: true,
+						success: function(data) {
+							taskCnt.removeClass('AjaxTable-loading');
+							jQuery(data).appendTo(taskCnt);
+						},
+						error: function(jqXHR, textStatus, errorThrown) {
+							//console.log('request error:', jqXHR.status, 'txt:', jqXHR.responseText, 'err:', jqXHR);
+							taskCnt.removeClass('AjaxTable-loading');
+							var txt = jqXHR.responseText || 'Error';
+							if (jqXHR.status == 404) {
+								jQuery('<div class="container"><div class="alert alert-danger">' + txt + '</div></div>').appendTo(taskCnt);
+							} else {
+								jQuery('<div class="container"><div class="alert alert-danger">' + txt + '</div></div>').appendTo(taskCnt);
+							}
+						}
+					});
+					//return false;
+				},
+				CREATE: TableAjax__CREATE_Route,
+			};
+			var routePath = location.hash;
+			//console.log('location.hash: ' + routePath);
+			if (location.hash == '' || location.hash == '#') {
+				return false;
+			}
+			if (routePath.charAt(0) == '#') {
+				routePath = routePath.substr(1);
+			}
+			//console.log('routePath: ' + routePath);
+			var parts = routePath.split('/');
+			var task = parts.shift();
+			//console.log('task(' + task + ') parts:');
+			//console.log(parts);
+			if (task in routes && typeof routes[task] == 'function') {
+				var con = jQuery('#' + TABLE_AJAX_NODE_ID);
+				if (con) {
+					var tblAjax = con.data('TableAjax');
+					if (tblAjax) {
+						tblAjax.popoverCellRemove();
+					}
+				}
+				routes[task](parts);
+			} else {
+				return false;
+			}
+		},
+		filtersClean: true,
+		longDesc: true
+	});
+});
+
+function tableAjaxBackToTable() {
+	var cont = jQuery('#' + TABLE_AJAX_NODE_ID).parent();
+	cont.show();
+	var taskCont = jQuery('#' + TABLE_AJAX_NODE_ID + '_task').parent();
+	taskCont.remove();
+
+	// reload first page
+	var con = jQuery('#' + TABLE_AJAX_NODE_ID);
+	con.TableAjaxLoadPage();// TODO: load current page
+}
+
+function tableAjaxCopy(args) {
+	var recordID = args;
+	if (typeof args == 'object') {
+		recordID = args.shift();
+		recordID = parseInt(recordID);
+	}
+	if (typeof recordID !== 'number' || recordID <= 0) {
+		// TODO: msg
+		return false;
+	}
+
+	if (!confirm('Czy na pewno chcesz utworzyc nowy rekord na podstawie danych z rekordu ID = ' + recordID + '?')) {
+		return false;
+	}
+
+	var cont = jQuery('#' + TABLE_AJAX_NODE_ID).parent();
+
+	function notifyAjaxCallback(data) {
+		var notify = {};
+		notify.type = (data && data.type)? data.type : '';
+		notify.msg = (data && data.msg)? data.msg : '';
+		switch (notify.type) {
+			case 'success':
+				if (!notify.msg) notify.msg = 'OK';
+				break;
+			case 'info':
+				if (!notify.msg) notify.msg = '';
+				break;
+			case 'error':
+				if (!notify.msg) notify.msg = 'Wystąpiły błędy';
+				break;
+			case 'warning':
+				notify.type = 'warn';
+				if (!notify.msg) notify.msg = 'Wystąpiły błędy';
+				break;
+			default:
+				notify.msg = 'Nieznany błąd';
+				if (data && data.errorCode) notify.msg += ' ' + data.errorCode;
+				notify.type = '';
+		}
+		jQuery.notify(notify.msg, notify.type);
+	}
+
+	var reqData = {};
+	jQuery.ajax({
+		data: reqData,
+		dataType: 'json',
+		type: "GET",
+		url: URL_RECORD_COPY + '&ID=' + recordID,
+	})
+	.done(function(data, textStatus, jqXHR){
+		var con = jQuery('#' + TABLE_AJAX_NODE_ID);
+		con.TableAjaxRefresh();
+		notifyAjaxCallback(data);
+	})
+	.fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
+		if (jqXHR.responseJSON) {
+			notifyAjaxCallback(jqXHR.responseJSON);
+		}
+		else {
+			var txt = jqXHR.responseText || 'Wystąpiły błędy';
+			if (jqXHR.status == 404) {
+				jQuery.notify(jqXHR.responseText, 'error');
+			} else {
+				jQuery.notify(jqXHR.responseText, 'warn');
+			}
+		}
+	});
+
+	return false;
+}
+
+function hidePopover() {
+	var con = jQuery('#' + TABLE_AJAX_NODE_ID);
+	if (con) {
+		var tblAjax = con.data('TableAjax');
+		if (tblAjax) {
+			tblAjax.popoverCellRemove();
+		}
+	}
+	return false;
+}
+
+global.tableAjaxBackToTable = tableAjaxBackToTable;
+global.tableAjaxCopy = tableAjaxCopy;
+global.hidePopover = hidePopover;