/** * profile - user (jquery) */ 'use strict'; $(function () { // Variable declaration for table var dt_project_table = $('.datatable-project'); // Project datatable // -------------------------------------------------------------------- if (dt_project_table.length) { var dt_project = dt_project_table.DataTable({ ajax: assetsPath + 'json/pages-profile-user.json', // JSON file to add data columns: [ // columns according to JSON { data: 'id' }, { data: 'id' }, { data: 'project_name' }, { data: 'leader' }, { data: 'avatar' }, { data: 'progress' }, { data: ' ' } ], columnDefs: [ { // For Responsive className: 'control', searchable: false, orderable: false, responsivePriority: 2, targets: 0, render: function (data, type, full, meta) { return ''; } }, { // For Checkboxes targets: 1, orderable: false, searchable: false, responsivePriority: 4, checkboxes: true, render: function () { return ''; }, checkboxes: { selectAllRender: '' } }, { // User full name and email targets: 2, responsivePriority: 1, render: function (data, type, full, meta) { var $name = full['project_name'], $framework = full['framework'], $image = full['project_image']; if ($image) { // For Avatar image var $output = 'Project Image'; } else { // For Avatar badge var stateNum = Math.floor(Math.random() * 6) + 1; var states = ['success', 'danger', 'warning', 'info', 'dark', 'primary', 'secondary']; var $state = states[stateNum], $name = full['full_name'], $initials = $name.match(/\b\w/g) || []; $initials = (($initials.shift() || '') + ($initials.pop() || '')).toUpperCase(); $output = '' + $initials + ''; } // Creates full output for row var $row_output = '
' + '
' + '
' + $output + '
' + '
' + '
' + '' + $name + '' + '' + $framework + '' + '
' + '
'; return $row_output; } }, { // Task targets: 3, render: function (data, type, full, meta) { var $task = full['leader']; return '' + $task + ''; } }, { // progress targets: 5, render: function (data, type, full, meta) { var $progress = full['progress']; var $progress_output = '
' + '
' + '
' + '
' + '
' + $progress + '%
' + '
'; return $progress_output; } }, { // avatar targets: 4, render: function (data, type, full, meta) { var $avatar = full['avatar'], $avatar_item = '', $avatar_count = 0; for (var i = 0; i < $avatar.length; i++) { $avatar_item += '
  • ' + 'Avatar' + '
  • '; $avatar_count++; if ($avatar_count > 2) break; } if ($avatar_count > 2) { var $remainingAvatars = $avatar.length - 3; if ($remainingAvatars > 0) { $avatar_item += '
  • ' + '+' + $remainingAvatars + '' + '
  • '; } } var $avatar_output = '
    ' + '' + '
    '; return $avatar_output; } }, { // Actions targets: -1, title: 'Actions', searchable: false, orderable: false, render: function (data, type, full, meta) { return ( '
    ' + '' + '
    ' ); } } ], order: [[2, 'desc']], dom: 't', displayLength: 7, lengthMenu: [7, 10, 25, 50, 75, 100], language: { sLengthMenu: 'Show _MENU_', search: '', searchPlaceholder: 'Search Project' }, // For responsive popup responsive: { details: { display: $.fn.dataTable.Responsive.display.modal({ header: function (row) { var data = row.data(); return 'Details of ' + data['full_name']; } }), type: 'column', renderer: function (api, rowIdx, columns) { var data = $.map(columns, function (col, i) { return col.title !== '' // ? Do not show row in modal popup if title is blank (for check box) ? '' + '' + col.title + ':' + ' ' + '' + col.data + '' + '' : ''; }).join(''); return data ? $('').append(data) : false; } } } }); } });