Add new in-place editor

This commit is contained in:
Eike Foken
2011-09-14 00:09:50 +02:00
parent 0c0b00f4e3
commit 51f3e022fe
8 changed files with 711 additions and 65 deletions

View File

@@ -35,6 +35,11 @@ class Ajax extends CI_Controller {
*/
public function __construct() {
parent::__construct();
// security check
if (!$this->input->is_ajax_request()) {
show_error(_('No AJAX request was made.'));
}
}
/**
@@ -49,12 +54,31 @@ class Ajax extends CI_Controller {
}
/**
* Saves a projects description.
* Saves the projects description.
*
* @param string $projectId
*/
public function save_project() {
public function update_project($projectId) {
$this->load->model('project');
$data['description'] = $this->input->post('content');
$this->project->update($this->session->userdata('active_project'), $data);
$data['description'] = $this->input->post('description');
$this->project->update($data, $projectId);
$this->output->set_output($data['description']);
}
/**
* Saves the experiments description.
*
* @param string $experimentId
*/
public function update_experiment($experimentId) {
$this->load->model('experiment');
$data['description'] = $this->input->post('description');
$this->experiment->update($data, $experimentId);
$this->output->set_output($data['description']);
}
/**
@@ -67,6 +91,8 @@ class Ajax extends CI_Controller {
/**
* Displays the description of parameters.
*
* @param string $parameterId
*/
public function parameter_help($parameterId) {
$this->load->model('parameter');

View File

@@ -213,7 +213,7 @@ class Project extends CI_Model {
* @param integer $projectId The ID of the project to update
* @param array $data Array with data to update
*/
public function update($projectId, $data) {
public function update($data, $projectId) {
return $this->db->where('id', $projectId)->update('projects', $data);
}

View File

@@ -13,7 +13,10 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" language="javascript" type="text/javascript"></script>
<?=js_asset('tablednd.jquery.js');?>
<?=js_asset('jquery.editinplace.js');?>
<?=js_asset('jquery.tablednd.js');?>
<?=js_asset('minmax.js');?>
<?=js_asset('jsc3d.min.js');?>
<?=js_asset('scattport.js');?>
<?=js_asset('jtip.js');?>

View File

@@ -130,4 +130,14 @@
</div>
<script>
$('.editInPlace').editInPlace({
url: BASE_URL + 'ajax/update_project/' + '<?=$project['id']?>',
saving_image: SITE_URL + 'images/ajax-loader.gif',
update_value: 'description',
value_required: true
});
</script>
<?php $this->load->view('footer');?>