Implement in-place editor for project descriptions
This commit is contained in:
@@ -46,4 +46,13 @@ class Ajax extends MY_Controller {
|
|||||||
$tpl['messages'] = $this->messages->get();
|
$tpl['messages'] = $this->messages->get();
|
||||||
$this->load->view('global/notifications', $tpl);
|
$this->load->view('global/notifications', $tpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves a projects description.
|
||||||
|
*/
|
||||||
|
public function save_project() {
|
||||||
|
$this->load->model('project');
|
||||||
|
$data['description'] = $this->input->post('content');
|
||||||
|
$this->project->update($this->session->userdata('active_project'), $data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configurations are used to store different variations of the same project.
|
* Configurations are used to store different variations of the same project.
|
||||||
*
|
*
|
||||||
* @author Karsten Heiken <karsten@disposed.de>
|
* @author Karsten Heiken <karsten@disposed.de>
|
||||||
*/
|
*/
|
||||||
class Project extends CI_Model {
|
class Project extends CI_Model {
|
||||||
@@ -35,8 +35,7 @@ class Project extends CI_Model {
|
|||||||
* @return array The user's projects.
|
* @return array The user's projects.
|
||||||
*/
|
*/
|
||||||
public function getOwn() {
|
public function getOwn() {
|
||||||
// TODO: Session: $query = $this->db->where(array('owner' => $this->session->userdata('user_id')))
|
$query = $this->db->where(array('owner' => $this->session->userdata('user_id')))
|
||||||
$query = $this->db->where(array('owner' => '215cd70f310ae6ae'))
|
|
||||||
->order_by('lastaccess', 'desc')
|
->order_by('lastaccess', 'desc')
|
||||||
->get('projects');
|
->get('projects');
|
||||||
return $query->result_array();
|
return $query->result_array();
|
||||||
@@ -65,7 +64,7 @@ class Project extends CI_Model {
|
|||||||
$query = $this->db->where(array('public' => '1'))
|
$query = $this->db->where(array('public' => '1'))
|
||||||
->order_by('name', 'asc')
|
->order_by('name', 'asc')
|
||||||
->get('projects');
|
->get('projects');
|
||||||
|
|
||||||
return $query->result_array();
|
return $query->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,10 +78,10 @@ class Project extends CI_Model {
|
|||||||
$this->db->where('id', $project_id)->update('projects', array(
|
$this->db->where('id', $project_id)->update('projects', array(
|
||||||
'lastaccess' => mysql_now(),
|
'lastaccess' => mysql_now(),
|
||||||
));
|
));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all projects from the database.
|
* Get all projects from the database.
|
||||||
*/
|
*/
|
||||||
@@ -91,8 +90,6 @@ class Project extends CI_Model {
|
|||||||
->join('users', 'users.id = projects.owner', 'left')
|
->join('users', 'users.id = projects.owner', 'left')
|
||||||
->get('projects')->result_array();
|
->get('projects')->result_array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,19 +152,33 @@ class Project extends CI_Model {
|
|||||||
} while ($this->db->where('id', $data['id'])->from('projects')->count_all_results() > 0);
|
} while ($this->db->where('id', $data['id'])->from('projects')->count_all_results() > 0);
|
||||||
|
|
||||||
|
|
||||||
if($this->db->insert('projects', $data))
|
if ($this->db->insert('projects', $data)) {
|
||||||
return $data['id'];
|
return $data['id'];
|
||||||
else
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a project.
|
* Updates a project.
|
||||||
|
*
|
||||||
|
* @param integer $projectId The ID of the project to update
|
||||||
|
* @param array $data Array with data to update
|
||||||
|
*/
|
||||||
|
public function update($projectId, $data) {
|
||||||
|
return $this->db->where('id', $projectId)->update('projects', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a project.
|
||||||
*
|
*
|
||||||
* There is no security check in here to verify if the user has the
|
* There is no security check in here to verify if the user has the
|
||||||
* rights to do so. This needs to be done in the controller!
|
* rights to do so. This needs to be done in the controller!
|
||||||
|
*
|
||||||
|
* @param integer $projectId The ID of the project to delete
|
||||||
*/
|
*/
|
||||||
public function delete($project_id) {
|
public function delete($projectId) {
|
||||||
return $this->db->delete('projects', array('id' => $project_id));
|
return $this->db->delete('projects', array('id' => $projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,87 +2,80 @@
|
|||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<h2>Projektinformationen</h2>
|
<h2>Projektinformationen</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h3>Versuche</h3>
|
<h3>Beschreibung</h3>
|
||||||
<table class="tableList">
|
<div class="editInPlace"><?=nl2br($project['description']);?></div>
|
||||||
<thead>
|
<p></p>
|
||||||
<tr>
|
<h3>Versuche</h3>
|
||||||
<th scope="col">Versuch</th>
|
<table class="tableList">
|
||||||
<th scope="col">Berechnungen</th>
|
<thead>
|
||||||
<th scope="col">Aktionen</th>
|
<tr>
|
||||||
</tr>
|
<th scope="col">Versuch</th>
|
||||||
</thead>
|
<th scope="col">Berechnungen</th>
|
||||||
<tbody>
|
<th scope="col">Aktionen</th>
|
||||||
<?
|
</tr>
|
||||||
if(count($trials) > 0):
|
</thead>
|
||||||
foreach($trials as $trial):
|
<tbody>
|
||||||
?>
|
<?php if (count($trials) > 0):?>
|
||||||
<tr>
|
<?php foreach($trials as $trial):?>
|
||||||
<td><a href="<?=site_url('trials/'.$trial['id'])?>"title="Versuch "<?=$trial['name']?>" anzeigen"><?=$trial['name']?></a></td>
|
<tr>
|
||||||
<td><span class="active">Erfolgreich abgeschlossen</span></td>
|
<td><a href="<?=site_url('trials/'.$trial['id'])?>"title="Versuch "<?=$trial['name']?>" anzeigen"><?=$trial['name']?></a></td>
|
||||||
<td>
|
<td><span class="active">Erfolgreich abgeschlossen</span></td>
|
||||||
<a href="<?=site_url('trials/results/'.$trial['id'])?>" title="Ergebnisse zum Versuch "<?=$trial['name']?>" anzeigen">Ergebnisse anzeigen</a> |
|
<td>
|
||||||
<a href="<?=site_url('trials/edit/'.$trial['id'])?>" title="Versuch "<?=$trial['name']?>" bearbeiten">Bearbeiten</a> |
|
<a href="<?=site_url('trials/results/'.$trial['id'])?>" title="Ergebnisse zum Versuch "<?=$trial['name']?>" anzeigen">Ergebnisse anzeigen</a> |
|
||||||
<a href="<?=site_url('trials/delete/'.$trial['id'])?>" title="Versuch "<?=$trial['name']?>" entfernen">Entfernen</a></td>
|
<a href="<?=site_url('trials/edit/'.$trial['id'])?>" title="Versuch "<?=$trial['name']?>" bearbeiten">Bearbeiten</a> |
|
||||||
</tr>
|
<a href="<?=site_url('trials/delete/'.$trial['id'])?>" title="Versuch "<?=$trial['name']?>" entfernen">Entfernen</a>
|
||||||
<?
|
</td>
|
||||||
endforeach;
|
</tr>
|
||||||
else:
|
<?php endforeach;?>
|
||||||
?>
|
<?php else:?>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">Keine Versuche vorhanden.</td>
|
<td colspan="3">Keine Versuche vorhanden.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?php endif;?>
|
||||||
endif;
|
</tbody>
|
||||||
?>
|
</table>
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<p><a class="button add" href="<?=site_url('trials/create/'.$project['id'])?>">Neuen Versuch erstellen</a>
|
<p><a class="button add" href="<?=site_url('trials/create/'.$project['id'])?>">Neuen Versuch erstellen</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<h2>Letzte Berechnungen</h2>
|
<h2>Letzte Berechnungen</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<table class="tableList">
|
<table class="tableList">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Versuch</th>
|
<th scope="col">Versuch</th>
|
||||||
<th scope="col">Fertiggestellt</th>
|
<th scope="col">Fertiggestellt</th>
|
||||||
<th scope="col">Aktionen</th>
|
<th scope="col">Aktionen</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?
|
<?php if(count($jobsDone) > 0):?>
|
||||||
if(count($jobsDone) > 0):
|
<?php foreach($jobsDone as $job):?>
|
||||||
foreach($jobsDone as $job):
|
<tr>
|
||||||
?>
|
<td>Versuchsname</td>
|
||||||
<tr>
|
<td>Heute, 09:32</td>
|
||||||
<td>Versuchsname</td>
|
<td>
|
||||||
<td>Heute, 09:32</td>
|
<a href="<?=site_url('trials/results/'.$trial['id'])?>" title="Ergebnisse zum Versuch "<?=$trial['name']?>" anzeigen">Ergebnisse anzeigen</a> |
|
||||||
<td>
|
<a href="<?=site_url('trials/edit/'.$trial['id'])?>" title="Versuch "<?=$trial['name']?>" bearbeiten">Bearbeiten</a>
|
||||||
<a href="<?=site_url('trials/results/'.$trial['id'])?>" title="Ergebnisse zum Versuch "<?=$trial['name']?>" anzeigen">Ergebnisse anzeigen</a> |
|
</td>
|
||||||
<a href="<?=site_url('trials/edit/'.$trial['id'])?>" title="Versuch "<?=$trial['name']?>" bearbeiten">Bearbeiten</a></td>
|
</tr>
|
||||||
</tr>
|
<?php endforeach;?>
|
||||||
<?
|
<?php else:?>
|
||||||
endforeach;
|
<tr>
|
||||||
else:
|
<td colspan="3">Es wurden noch keine Berechnungen durchgeführt.</td>
|
||||||
?>
|
</tr>
|
||||||
<tr>
|
<?php endif;?>
|
||||||
<td colspan="3">Es wurden noch keine Berechnungen durchgeführt.</td>
|
</tbody>
|
||||||
</tr>
|
</table>
|
||||||
<?
|
</div>
|
||||||
endif;
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,75 +1,71 @@
|
|||||||
<?php $this->load->view('header'); ?>
|
<?php $this->load->view('header');?>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<h2>Projektübersicht</h2>
|
<h2>Projektübersicht</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h3>Übersicht aller Projekte</h3>
|
<h3>Übersicht aller Projekte</h3>
|
||||||
<table class="tableList paginated">
|
<table class="tableList paginated">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Projekt</th>
|
<th scope="col">Projekt</th>
|
||||||
<th scope="col">Besitzer</th>
|
<th scope="col">Besitzer</th>
|
||||||
<th scope="col">Berechnungen</th>
|
<th scope="col">Berechnungen</th>
|
||||||
<th scope="col">Aktion</th>
|
<th scope="col">Aktion</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?
|
<?php foreach($projects as $project):?>
|
||||||
foreach($projects as $project):
|
<tr>
|
||||||
?>
|
<td><a href="<?=site_url('projects/detail/' . $project['id'])?>"><abbr title="<?=$project['description']?>"><?=$project['name']?></abbr></a></td>
|
||||||
<tr>
|
<td><?=$project['firstname'] . " " . $project['lastname']?></td>
|
||||||
<td><a href="<?=site_url('projects/detail/' . $project['id'])?>"><abbr title="<?=$project['description']?>"><?=$project['name']?></abbr></a></td>
|
<td><span class="active">Erfolgreich abgeschlossen</span></td>
|
||||||
<td><?=$project['firstname'] . " " . $project['lastname']?></td>
|
<td><a href="#">Ergebnisse anzeigen</a> | <?=anchor('projects/delete/' . $project['id'], "Entfernen");?></td>
|
||||||
<td><span class="active">Erfolgreich abgeschlossen</span></td>
|
</tr>
|
||||||
<td><a href="#">Ergebnisse anzeigen</a> | <?=anchor('projects/delete/' . $project['id'], "Entfernen");?></td>
|
<?php endforeach;?>
|
||||||
</tr>
|
<tr>
|
||||||
<?
|
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
||||||
endforeach;
|
<td>Karsten Heiken</td>
|
||||||
?>
|
<td><span class="closed">Fehlgeschlagen</span></td>
|
||||||
<tr>
|
<td><a href="#">Fehlerbericht</a> | <a href="#">Entfernen</a></td>
|
||||||
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
</tr>
|
||||||
<td>Karsten Heiken</td>
|
<tr>
|
||||||
<td><span class="closed">Fehlgeschlagen</span></td>
|
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
||||||
<td><a href="#">Fehlerbericht</a> | <a href="#">Entfernen</a></td>
|
<td>Karsten Heiken</td>
|
||||||
</tr>
|
<td><span class="pending">Berechnung im Gange: 20%</span></td>
|
||||||
<tr>
|
<td><a href="#">Anhalten</a> | <a href="#">Entfernen</a></td>
|
||||||
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
</tr>
|
||||||
<td>Karsten Heiken</td>
|
<tr>
|
||||||
<td><span class="pending">Berechnung im Gange: 20%</span></td>
|
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
||||||
<td><a href="#">Anhalten</a> | <a href="#">Entfernen</a></td>
|
<td>Karsten Heiken</td>
|
||||||
</tr>
|
<td><span class="pending">Berechnung im Gange: 60%</span></td>
|
||||||
<tr>
|
<td><a href="#">Anhalten</a> | <a href="#">Entfernen</a></td>
|
||||||
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
</tr>
|
||||||
<td>Karsten Heiken</td>
|
<tr>
|
||||||
<td><span class="pending">Berechnung im Gange: 60%</span></td>
|
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
||||||
<td><a href="#">Anhalten</a> | <a href="#">Entfernen</a></td>
|
<td>Karsten Heiken</td>
|
||||||
</tr>
|
<td><span class="pending">Berechnung im Gange: 0%</span></td>
|
||||||
<tr>
|
<td><a href="#">Anhalten</a> | <a href="#">Entfernen</a></td>
|
||||||
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
</tr>
|
||||||
<td>Karsten Heiken</td>
|
<tr>
|
||||||
<td><span class="pending">Berechnung im Gange: 0%</span></td>
|
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
||||||
<td><a href="#">Anhalten</a> | <a href="#">Entfernen</a></td>
|
<td>Karsten Heiken</td>
|
||||||
</tr>
|
<td><span class="closed">Fehlgeschlagen</span></td>
|
||||||
<tr>
|
<td><a href="#">Fehlerbericht</a> | <a href="#">Entfernen</a></td>
|
||||||
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
</tr>
|
||||||
<td>Karsten Heiken</td>
|
<tr>
|
||||||
<td><span class="closed">Fehlgeschlagen</span></td>
|
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
||||||
<td><a href="#">Fehlerbericht</a> | <a href="#">Entfernen</a></td>
|
<td>Karsten Heiken</td>
|
||||||
</tr>
|
<td><span class="closed">Fehlgeschlagen</span></td>
|
||||||
<tr>
|
<td><a href="#">Fehlerbericht</a> | <a href="#">Entfernen</a></td>
|
||||||
<td><a href="#"><abbr title="Beschreibung des Projekts">Blutkörperchen</abbr></a></td>
|
</tr>
|
||||||
<td>Karsten Heiken</td>
|
</tbody>
|
||||||
<td><span class="closed">Fehlgeschlagen</span></td>
|
</table>
|
||||||
<td><a href="#">Fehlerbericht</a> | <a href="#">Entfernen</a></td>
|
</div>
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php $this->load->view('footer'); ?>
|
<?php $this->load->view('footer');?>
|
||||||
|
|||||||
@@ -1,17 +1,62 @@
|
|||||||
function get_notifications() {
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function getNotifications() {
|
||||||
$.get(SITE_URL + 'ajax/get_notifications', function(data) {
|
$.get(SITE_URL + 'ajax/get_notifications', function(data) {
|
||||||
if(data.length > 0) {
|
if (data.length > 0) {
|
||||||
$('#notifications').append(data).slideDown();
|
$('#notifications').append(data).slideDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the changes done by in-place edit.
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
* @param cancel
|
||||||
|
*/
|
||||||
|
function saveChanges(obj, cancel) {
|
||||||
|
var a;
|
||||||
|
|
||||||
|
if (!cancel) {
|
||||||
|
a = $(obj).parent().siblings(0).val();
|
||||||
|
$.post(SITE_URL + 'ajax/save_project', { content: a }, function(response) {
|
||||||
|
alert("Die Änderungen wurden gespeichert.");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
a = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(obj).parent().parent().after('<div class="editInPlace">' + a + '</div>').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alternates the table rows.
|
||||||
|
*/
|
||||||
$.fn.alternateRowColors = function() {
|
$.fn.alternateRowColors = function() {
|
||||||
$('tbody tr:odd', this).removeClass('even').addClass('odd');
|
$('tbody tr:odd', this).removeClass('even').addClass('odd');
|
||||||
$('tbody tr:even', this).removeClass('odd').addClass('even');
|
$('tbody tr:even', this).removeClass('odd').addClass('even');
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces html line breaks with newlines.
|
||||||
|
*/
|
||||||
|
$.fn.br2nl = function() {
|
||||||
|
return $(this).html().replace(/(<br>)|(<br \/>)|(<p>)|(<\/p>)/g, "");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to PHP's nl2br function.
|
||||||
|
*/
|
||||||
|
$.fn.nl2br = function() {
|
||||||
|
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
|
||||||
|
return $(this).html().replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tabs
|
||||||
|
*/
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$(".tab_content").hide(); // hide all content
|
$(".tab_content").hide(); // hide all content
|
||||||
$("ul.tabs li:first").addClass("active").show(); // activate first tab
|
$("ul.tabs li:first").addClass("active").show(); // activate first tab
|
||||||
@@ -30,75 +75,100 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#notifications').hide();
|
$('#notifications').hide();
|
||||||
get_notifications();
|
getNotifications();
|
||||||
setInterval('get_notifications()', '5000');
|
setInterval('getNotifications()', '5000');
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Tables
|
* Do some stuff if document is ready.
|
||||||
*/
|
*/
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var settings = {
|
/*
|
||||||
table_class : 'tableList'
|
* Tables
|
||||||
};
|
*/
|
||||||
|
var settings = {
|
||||||
|
table_class : 'tableList'
|
||||||
|
};
|
||||||
|
|
||||||
// add or delete "hover" class on mouseOver event
|
// add or delete "hover" class on mouseOver event
|
||||||
$('.' + settings.table_class + ' tbody tr').hover(function() {
|
$('.' + settings.table_class + ' tbody tr').hover(function() {
|
||||||
$(this).addClass("hover");
|
$(this).addClass("hover");
|
||||||
}, function() {
|
}, function() {
|
||||||
$(this).removeClass("hover");
|
$(this).removeClass("hover");
|
||||||
});
|
});
|
||||||
|
|
||||||
// add or delete "selected" class if a row is selected via checkbox
|
// add or delete "selected" class if a row is selected via checkbox
|
||||||
$('.' + settings.table_class + ' tbody input:checkbox').click(function() {
|
$('.' + settings.table_class + ' tbody input:checkbox').click(function() {
|
||||||
if ($(this).attr('checked') == true) {
|
if ($(this).attr('checked') == true) {
|
||||||
$(this).parent().parent().addClass('selected');
|
$(this).parent().parent().addClass('selected');
|
||||||
} else {
|
} else {
|
||||||
$(this).parent().parent().removeClass('selected');
|
$(this).parent().parent().removeClass('selected');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// alternate table rows
|
// alternate table rows
|
||||||
$('.' + settings.table_class).each(function() {
|
$('.' + settings.table_class).each(function() {
|
||||||
var table = $(this);
|
var table = $(this);
|
||||||
table.alternateRowColors(table);
|
table.alternateRowColors(table);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pagination
|
* Pagination
|
||||||
*/
|
*/
|
||||||
$('.paginated').each(function() {
|
$('.paginated').each(function() {
|
||||||
var currentPage = 0;
|
var currentPage = 0;
|
||||||
var numPerPage = 6;
|
var numPerPage = 6;
|
||||||
var table = $(this);
|
var table = $(this);
|
||||||
|
|
||||||
table.bind('repaginate', function() {
|
table.bind('repaginate', function() {
|
||||||
var start = currentPage * numPerPage;
|
var start = currentPage * numPerPage;
|
||||||
var end = (currentPage + 1) * numPerPage;
|
var end = (currentPage + 1) * numPerPage;
|
||||||
table.find('tbody tr').slice(start, end).show().end().slice(0, start).hide().end().slice(end).hide().end();
|
table.find('tbody tr').slice(start, end).show().end().slice(0, start).hide().end().slice(end).hide().end();
|
||||||
});
|
});
|
||||||
|
|
||||||
var numRows = table.find('tbody tr').length;
|
var numRows = table.find('tbody tr').length;
|
||||||
var numPages = Math.ceil(numRows / numPerPage);
|
var numPages = Math.ceil(numRows / numPerPage);
|
||||||
|
|
||||||
var $pager = $('<div class="pagination"></div>');
|
var $pager = $('<div class="pagination"></div>');
|
||||||
var $pagelist = $('<ul></ul>');
|
var $pagelist = $('<ul></ul>');
|
||||||
|
|
||||||
$pagelist.append('<li class="pages">Seite:</li>');
|
$pagelist.append('<li class="pages">Seite:</li>');
|
||||||
|
|
||||||
for (var page = 0; page < numPages; page++) {
|
for (var page = 0; page < numPages; page++) {
|
||||||
$('<li class="page-number">' + (page + 1) + '</li>').bind('click', {'newPage': page}, function(event) {
|
$('<li class="page-number">' + (page + 1) + '</li>').bind('click', {'newPage': page}, function(event) {
|
||||||
currentPage = event.data['newPage'];
|
currentPage = event.data['newPage'];
|
||||||
table.trigger('repaginate');
|
table.trigger('repaginate');
|
||||||
|
|
||||||
$(this).addClass('active').siblings().removeClass('active');
|
$(this).addClass('active').siblings().removeClass('active');
|
||||||
}).appendTo($pagelist).addClass('clickable');
|
}).appendTo($pagelist).addClass('clickable');
|
||||||
}
|
}
|
||||||
|
|
||||||
$pagelist.find('li.page-number:first').addClass('active');
|
$pagelist.find('li.page-number:first').addClass('active');
|
||||||
$pager.append($pagelist);
|
$pager.append($pagelist);
|
||||||
$pager.insertAfter(table);
|
$pager.insertAfter(table);
|
||||||
|
|
||||||
table.trigger('repaginate');
|
table.trigger('repaginate');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In-place editor
|
||||||
|
*/
|
||||||
|
$('.editInPlace').click(function() {
|
||||||
|
var textarea = '<div><textarea rows="6" cols="60">' + $(this).br2nl() + '</textarea><p></p>';
|
||||||
|
var button = '<p><a class="button save" href="javascript:void(0);">Speichern</a> <a class="button cancel" href="javascript:void(0);">Abbrechen</a></div>';
|
||||||
|
var revert = $(this).html();
|
||||||
|
|
||||||
|
$(this).after(textarea + button).remove();
|
||||||
|
|
||||||
|
$('.save').click(function() {
|
||||||
|
saveChanges(this, false);
|
||||||
|
});
|
||||||
|
$('.cancel').click(function() {
|
||||||
|
saveChanges(this, revert);
|
||||||
|
});
|
||||||
|
}).mouseover(function() {
|
||||||
|
$(this).addClass('editable');
|
||||||
|
}).mouseout(function() {
|
||||||
|
$(this).removeClass('editable');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user