Browse Source

fixed TableAjax js

Piotr Labudda 6 years ago
parent
commit
ba5ddca074

+ 18 - 16
SE/se-lib/TableAjax.php.TableAjax.js

@@ -940,16 +940,18 @@ var TableAjax = function() {
 
 		// TODO: priv.options.router.init();
 		// priv.options.router.getLinkOnclickFunction(task, args);
-		if (location.hash) {
-			priv.options.router()
-		} else {
-			priv.update(priv.options.router)
-		}
-
 		if (typeof priv.options.router == "function") {
+			if (location.hash) {
+				priv.options.router()
+			} else {
+				priv.update(priv.options.router)
+			}
+
 			$(window).bind('hashchange', function() {
 				priv.options.router();
 			});
+		} else {
+			priv.update()
 		}
 	};
 
@@ -1631,13 +1633,13 @@ var TableAjax = function() {
 	};
 
 	priv.renderCellRowFunctions = function(rowFunctions, rowPK, rowProps) {
-		var cellNode = $('<td></td>'),
-				keys = Object.keys(rowFunctions),
-				total = keys.length,
-				moreFuncBtnNode,
-				moreFunctions = [],
-				idx
-		;
+		var cellNode = $('<td></td>');
+		var keys = Object.keys(rowFunctions);
+		var total = keys.length;
+		var moreFuncBtnNode;
+		var moreFunctions = [];
+		var idx;
+
 		if (priv.options.debug || DBG) console.log('TableAjax::renderCellRowFunctions: rowFunctions', rowFunctions);
 		idx = keys.indexOf('hist');
 		if (idx !== -1) {
@@ -1653,9 +1655,9 @@ var TableAjax = function() {
 			// if (funObj['ui-function'] && global[funObj['ui-function']]) {
 			// 	funcNode.on('click', function (event) { event.preventDefault(); global[funObj['ui-function']](rowPK); });
 			// }
-			var funObj = rowFunctions[key],
-					funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: false})
-			;
+			var funObj = rowFunctions[key];
+			var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: false});
+
 			funcNode.appendTo(cellNode);
 		});
 		moreFuncBtnNode = $('<a href="#" style="margin:0 2px;text-decoration:none" title="Więcej funkcji dla rekordu nr '+rowPK+'" class="glyphicon glyphicon-menu-hamburger"> </a>');

+ 6 - 6
SE/se-lib/TableAjax.php.generateFunctionNode.js

@@ -5,12 +5,12 @@
 
 var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 	var defaultsProps = {
-				ico: true,
-				label: false
-			},
-			props = jQuery.extend({}, defaultsProps, props);
-			funcNode = $('<a href="#" style="margin:0 2px;"></a>')
-	;
+		ico: true,
+		label: false
+	};
+	var props = jQuery.extend({}, defaultsProps, props);
+	var funcNode = $('<a href="#" style="margin:0 2px;"></a>');
+
 	if ('href' in funObj) funcNode.attr('href', p5Utils__format(funObj.href, [rowPK]));
 	if (props.ico) {
 		if ('ico' in funObj) funcNode.append('<span class="' + funObj.ico + '"></span>');

+ 3 - 3
SE/se-lib/TableAjax.php.init.js

@@ -28,13 +28,13 @@ jQuery(document).ready(function(){
 		pageSize: PAGE_SIZE,
 		pageSizes: PAGE_SIZES,
 		tblFunctions: TABLE_FUNCTIONS,
-		rowFunctions: ROW_FUNCTIONS,
 		exportFields: EXPORT_FIELDS,
 		specialFilterFunctions: SPECIAL_FILTER_FUNCTIONS,
 		selectedFunctions: SELECTED_FUNCTIONS,
-		router: tableAjaxRouter,
 		filtersClean: true,
-		longDesc: true
+		longDesc: true,
+		router: tableAjaxRouter,
+		rowFunctions: ROW_FUNCTIONS,
 	});
 });