page Settgins ready

This commit is contained in:
Martin Müller 2014-03-26 09:15:43 +01:00
parent 4e3371d251
commit c26d0e1ddf
15 changed files with 210 additions and 93 deletions

3
.gitignore vendored
View File

@ -1,6 +1,9 @@
# User specific & automatically generated files # # User specific & automatically generated files #
################################################# #################################################
/app/Config/database.php /app/Config/database.php
/app/webroot/uploads/
/app/webroot/avatar/
/app/webroot/dreamjob/
/app/tmp /app/tmp
/lib/Cake/Console/Templates/skel/tmp/ /lib/Cake/Console/Templates/skel/tmp/
/plugins /plugins

View File

@ -216,10 +216,11 @@ Configure::write('Routing.prefixes', array('admin'));
* the cake shell command: cake schema create Sessions * the cake shell command: cake schema create Sessions
* *
*/ */
Configure::write('Session', array( Configure::write('Session', array(
'defaults' => 'php' 'defaults' => 'php',
)); 'cookie' => 'PHPSESSID'
)
);
/** /**
* A random string used in security hashing methods. * A random string used in security hashing methods.
*/ */
@ -384,10 +385,3 @@ Cache::config('_cake_model_', array(
'serialize' => ($engine === 'File'), 'serialize' => ($engine === 'File'),
'duration' => $duration 'duration' => $duration
)); ));
Configure::write('Session', array(
'defaults' => 'php',
'cookie' => 'DreamJOBSession'
)
);

View File

@ -34,8 +34,8 @@
Router::connect('/profil', array('controller' => 'user', 'action' => 'profil')); Router::connect('/profil', array('controller' => 'user', 'action' => 'profil'));
Router::connect('/profil/page/:page', array('controller' => 'user', 'action' => 'profil'),array("page" => "[0-9]+")); Router::connect('/profil/page/:page', array('controller' => 'user', 'action' => 'profil'),array("page" => "[0-9]+"));
Router::connect('/settings', array('controller' => 'user', 'action' => 'settings_account')); Router::connect('/settings', array('controller' => 'user', 'action' => 'settings_account'));
Router::connect('/settings/pages', array('controller' => 'user', 'action' => 'settings_pages')); Router::connect('/settings/pages', array('controller' => 'user', 'action' => 'settings_pageInh'));
Router::connect('/settings/pages/:page', array('controller' => 'user', 'action' => 'settings_pages'),array("page" => "[0-9]+")); Router::connect('/settings/pages/:page', array('controller' => 'user', 'action' => 'settings_pageInh'),array("page" => "[0-9]+"));
Router::connect('/settings/isearch', array('controller' => 'user', 'action' => 'settings_isearch')); Router::connect('/settings/isearch', array('controller' => 'user', 'action' => 'settings_isearch'));

View File

@ -19,7 +19,7 @@ class MiconwareSessionComponent extends Component {
$controller->set("COMPANY",($this->self_company_obj)?$this->self_company_obj:false); $controller->set("COMPANY",($this->self_company_obj)?$this->self_company_obj:false);
} }
$controller->set("isStaff",$this->isStaff()); $controller->set("isStaff",$this->isStaff());
$controller->set("MEDIA_URL","http://dev.dreamjob.cc/media/"); $controller->set("MEDIA_URL","/");
$controller->set('default_sForm',array( $controller->set('default_sForm',array(
'inputDefaults' => array( 'inputDefaults' => array(
'div' => array('class' => 'control-group'), 'div' => array('class' => 'control-group'),

View File

@ -91,7 +91,7 @@ class HomeController extends AppController {
} }
public function iagb() { public function agb() {
$this->MiconwareSession->init($this); $this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this); $this->MiconwareSession->initWeb($this);
$this->set('title', 'dreamjob.agb'); $this->set('title', 'dreamjob.agb');

View File

@ -21,6 +21,7 @@ class UserController extends AppController {
* @throws NotFoundException When the view file could not be found * @throws NotFoundException When the view file could not be found
* or MissingViewException in debug mode. * or MissingViewException in debug mode.
*/ */
public function profil() { public function profil() {
$this->MiconwareSession->init($this); $this->MiconwareSession->init($this);
@ -267,7 +268,8 @@ class UserController extends AppController {
$this->render('/User/settings_account'); $this->render('/User/settings_account');
} }
} }
public function settings_pages() { public function settings_pageInh() {
$this->MiconwareSession->init($this); $this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this); $this->MiconwareSession->initWeb($this);
@ -275,7 +277,7 @@ class UserController extends AppController {
$this->layout = 'default'; $this->layout = 'default';
$this->RequestHandler->setContent('html', 'application/html' ); $this->RequestHandler->setContent('html', 'application/html' );
$result = false;
$profil = $this->MiconwareSession->getWorker(); $profil = $this->MiconwareSession->getWorker();
if(empty($profil) or count($profil) <= 0) if(empty($profil) or count($profil) <= 0)
@ -286,24 +288,63 @@ class UserController extends AppController {
$this->set('error', 'dreamjob.error.noPermision'); $this->set('error', 'dreamjob.error.noPermision');
$this->render('/Home/error'); $this->render('/Home/error');
}else{ }else{
var_dump($this->request->data);
if(!empty($this->request->params['page'])){ if(!empty($this->request->params['page'])){
$image = false;
$page = $this->DreamjobPageText->find('first', $page = $this->DreamjobPageText->find('first',
array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id'])) array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
); );
if(!is_array($page) or count($page)<= 0) if(!is_array($page) or count($page)<= 0){
$page = $this->DreamjobPageImage->find('first', $page = $this->DreamjobPageImage->find('first',
array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id'])) array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
); );
if($this->request->is('post')){ $image = true;
$this->MiconwareSession->setFlash(__('dreamjob.page.save'),'flash',array('alert'=>'success'));
} }
if(!empty($page) and count($page)> 0){
if($this->request->is('post')){
$this->request->data['DreamjobPageInh']['user_id']=$profil['AppUser']['id'];
if($image){
$this->request->data['DreamjobPageInh']['id']=$page['DreamjobPageInh']['id'];
$this->request->data['DreamjobPageImage']['page_ptr_id']=$page['DreamjobPageInh']['id'];
$result = $this->DreamjobPageImage->saveAndUpload($this->request->data);
}else{
$this->request->data['DreamjobPageInh']['id']=$page['DreamjobPageInh']['id'];
$this->request->data['DreamjobPageText']['page_ptr_id']=$page['DreamjobPageInh']['id'];
$result = $this->DreamjobPageText->saveAssociated($this->request->data);
}
if(!$result)
$this->MiconwareSession->setFlash(__('dreamjob.page.save.error'),'flash',array('alert'=>'danger'));
}else
$this->request->data=$page; $this->request->data=$page;
$this->set('page',$page); $this->set('page',$page);
}else
$this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
}else{ }else{
if($this->request->is('post')){ if($this->request->is('post')){
$this->MiconwareSession->setFlash(__('dreamjob.page.save'),'flash',array('alert'=>'success')); if(!empty($this->request->data['DreamjobPageText']['text']) and $this->request->data['DreamjobPageImage']['image']['error']==0){
$this->MiconwareSession->setFlash(__('dreamjob.page.oneType'),'flash',array('alert'=>'danger'));
}else{
$this->request->data['DreamjobPageInh']['user_id']=$profil['AppUser']['id'];
if($this->request->data['DreamjobPageImage']['image']['error']==0){
unset($this->request->data['DreamjobPageText']);
$this->DreamjobPageImage->create();
$result = $this->DreamjobPageImage->saveAndUpload($this->request->data);
}else{
unset($this->request->data['DreamjobPageImage']);
$this->DreamjobPageText->create();
$result = $this->DreamjobPageText->saveAssociated($this->request->data);
} }
if(!$result)
$this->MiconwareSession->setFlash(__('dreamjob.page.save.error'),'flash',array('alert'=>'danger'));
}
}
}
if($result){
$this->MiconwareSession->refreshCache();
$this->MiconwareSession->setFlash(__('dreamjob.page.save'),'flash',array('alert'=>'success'));
$profil = $this->MiconwareSession->getWorker();
if(empty($profil) or count($profil) <= 0)
$profil = $this->MiconwareSession->getCompany();
} }
$this->set('profil',$profil); $this->set('profil',$profil);
$this->render('/User/settings_pages'); $this->render('/User/settings_pages');

View File

@ -10,7 +10,7 @@ class DreamjobJobFavority extends AppModel {
public $useDbConfig = 'dreamjobMain'; public $useDbConfig = 'dreamjobMain';
public $useTable = 'mic_dj_job_opening_worker'; public $useTable = 'mic_dj_jobs_opening_worker';
public $validate = array( public $validate = array(
'worker_id' => array( 'worker_id' => array(

View File

@ -35,6 +35,8 @@ class DreamjobPageImage extends AppModel {
*/ */
public $displayField = 'page_ptr_id'; public $displayField = 'page_ptr_id';
/** /**
* Validation rules * Validation rules
* *
@ -59,28 +61,93 @@ class DreamjobPageImage extends AppModel {
//'on' => 'create', // Limit validation to 'create' or 'update' operations //'on' => 'create', // Limit validation to 'create' or 'update' operations
), ),
), ),
/* 'image' => array( 'image' => array(
'notEmpty' => array( // http://book.cakephp.org/2.0/en/models/data-validation.html#Validation::uploadError
'rule' => array('notEmpty'), 'uploadError' => array(
//'message' => 'Your custom message here', 'rule' => 'uploadError',
//'allowEmpty' => false, 'message' => 'Something went wrong with the file upload',
//'required' => false, 'required' => FALSE,
//'last' => false, // Stop validation after this rule 'allowEmpty' => TRUE,
//'on' => 'create', // Limit validation to 'create' or 'update' operations
), ),
'alphaNumeric' => array( // http://book.cakephp.org/2.0/en/models/data-validation.html#Validation::mimeType
'rule' => array('alphaNumeric'), 'mimeType' => array(
//'message' => 'Your custom message here', 'rule' => array('mimeType', array('image/gif','image/png','image/jpg','image/jpeg')),
//'allowEmpty' => false, 'message' => 'Invalid file, only images allowed',
//'required' => false, 'required' => FALSE,
//'last' => false, // Stop validation after this rule 'allowEmpty' => TRUE,
//'on' => 'create', // Limit validation to 'create' or 'update' operations
), ),
),*/ 'processUpload' => array(
'rule' => 'processUpload',
'message' => 'Something went wrong with the file upload',
'required' => FALSE,
'allowEmpty' => TRUE,
'last' => TRUE,
)
)
); );
//The Associations below have been created with all possible keys, those that are not needed can be removed //The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* Upload Directory relative to WWW_ROOT
* @param string
*/
public $uploadDir = 'uploads';
/**
* Before Validation Callback
* @param array $options
* @return boolean
*/
public function beforeValidate($options = array()) {
// ignore empty file - causes issues with form validation when file is empty and optional
if (!empty($this->data[$this->alias]['image']['error']) && $this->data[$this->alias]['image']['error']==4 && $this->data[$this->alias]['image']['size']==0) {
unset($this->data[$this->alias]['image']);
}
return parent::beforeValidate($options);
}
/**
* Process the Upload
* @param array $check
* @return boolean
*/
public function processUpload($check=array()) {
// deal with uploaded file
if (!empty($check['image']['tmp_name'])) {
// check file is uploaded
if (!is_uploaded_file($check['image']['tmp_name'])) {
return FALSE;
}
$this->data[$this->alias]['image'] = "onUpload";
}
return TRUE;
}
public function saveAndUpload($data){
$dataSource = $this->getDataSource();
$dataSource->begin();
$result = $this->saveAssociated($data);
if($result){
$filename = $data["DreamjobPageInh"]['user_id'] . "_-_p" . $this->id .".". pathinfo($data[$this->alias]['image']['name'], PATHINFO_EXTENSION);
$filename = WWW_ROOT . $this->uploadDir . DS . $filename;
if (!move_uploaded_file($data[$this->alias]['image']['tmp_name'], $filename)) {
$result = false;
} else {
$this->saveField('image', str_replace(DS, "/", str_replace(WWW_ROOT, "", $filename) ));
}
}
if ($result) {
$dataSource->commit();
return true;
} else {
$dataSource->rollback();
}
return false;
}
/** /**
* belongsTo associations * belongsTo associations
* *

View File

@ -32,7 +32,7 @@
<?=$this->Form->checkbox('agb').__("dreamjob.agb.accept");?> <?=$this->Form->checkbox('agb').__("dreamjob.agb.accept");?>
</div> </div>
<br/> <br/>
<?=$this->Form->button(__('dreamjob.application.send'),array('div' => false,'class'=>"btn btn-default ",'type' => 'submit'));?> <?=$this->Form->button(__('dreamjob.application.send'),array('div' => false,'class'=>"btn btn-primary ",'type' => 'submit'));?>
</div> </div>
</fieldset> </fieldset>
<?php echo $this->Form->end(); ?> <?php echo $this->Form->end(); ?>

View File

@ -46,7 +46,7 @@ echo $this->Form->create('DreamjobJobOpening',$default_Form);
<legend><?=__("dreamjob.text");?></legend> <legend><?=__("dreamjob.text");?></legend>
<?php echo $this->Form->textarea('DreamjobJobOpening.text',array("class"=>'form-control',"rows"=>10)); ?> <?php echo $this->Form->textarea('DreamjobJobOpening.text',array("class"=>'form-control',"rows"=>10)); ?>
<div class="buttonrow"> <div class="buttonrow">
<?=$this->Form->button(__('dreamjob.save'),array('div' => false,'class'=>"btn btn-default",'type' => 'submit'));?> <?=$this->Form->button(__('dreamjob.save'),array('div' => false,'class'=>"btn btn-primary",'type' => 'submit'));?>
</div> </div>
</fieldset> </fieldset>
<?php echo $this->Form->end(); ?> <?php echo $this->Form->end(); ?>

View File

@ -16,7 +16,7 @@ if($profil['AppUser']['take_systemwide']){
<div class="tabs-below"> <div class="tabs-below">
<ul class="nav nav-tabs pull-right"> <ul class="nav nav-tabs pull-right">
<li class="active"><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings_account'));?></li> <li class="active"><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings_account'));?></li>
<li><?=$this->Html->link(__("dreamjob.settings.pages"),array('controller'=>'user','action'=>'settings_pages'));?></li> <li><?=$this->Html->link(__("dreamjob.settings.pages"),array('controller'=>'user','action'=>'settings_pageInh'));?></li>
<?php <?php
if(!empty($WORKER) and count($WORKER)>0){ if(!empty($WORKER) and count($WORKER)>0){
?> ?>
@ -42,7 +42,7 @@ if($profil['AppUser']['take_systemwide']){
?> ?>
<legend><?=__("dreamjob.worker");?></legend> <legend><?=__("dreamjob.worker");?></legend>
<?php <?php
echo $this->Form->input('AppUser.mannerofaddress_id',array('label'=>array('text'=>__("dreamjob.mannerofaddress_id"),"class"=>$default_Form['inputDefaults']['label']['class']))); echo $this->Form->input('AppUser.mannerofaddress_id',array('label'=>array('text'=>__("dreamjob.mannerofaddress"),"class"=>$default_Form['inputDefaults']['label']['class'])));
echo $this->Form->input('AppUser.first_name',array('label'=>array('text'=>__("dreamjob.first_name"),"class"=>$default_Form['inputDefaults']['label']['class']))); echo $this->Form->input('AppUser.first_name',array('label'=>array('text'=>__("dreamjob.first_name"),"class"=>$default_Form['inputDefaults']['label']['class'])));
echo $this->Form->input('AppUser.last_name',array('label'=>array('text'=>__("dreamjob.last_name"),"class"=>$default_Form['inputDefaults']['label']['class']))); echo $this->Form->input('AppUser.last_name',array('label'=>array('text'=>__("dreamjob.last_name"),"class"=>$default_Form['inputDefaults']['label']['class'])));
echo $this->Form->input('AppUser.bday',array('label'=>array('text'=>__("dreamjob.bday"),"class"=>$default_Form['inputDefaults']['label']['class']),"style"=>'width:20%;display:inline-block;')); echo $this->Form->input('AppUser.bday',array('label'=>array('text'=>__("dreamjob.bday"),"class"=>$default_Form['inputDefaults']['label']['class']),"style"=>'width:20%;display:inline-block;'));
@ -79,7 +79,7 @@ if($profil['AppUser']['take_systemwide']){
echo $this->Form->input('DreamjobWorker.country',array('label'=>array('text'=>__("dreamjob.country"),"class"=>$default_Form['inputDefaults']['label']['class']))); echo $this->Form->input('DreamjobWorker.country',array('label'=>array('text'=>__("dreamjob.country"),"class"=>$default_Form['inputDefaults']['label']['class'])));
?> ?>
<div class="buttonrow"> <div class="buttonrow">
<?=$this->Form->button(__('dreamjob.settings.save'),array('div' => false,'class'=>"btn btn-default ",'type' => 'submit'));?> <?=$this->Form->button(__('dreamjob.settings.save'),array('div' => false,'class'=>"btn btn-primary ",'type' => 'submit'));?>
</div> </div>
</fieldset> </fieldset>
<?php echo $this->Form->end(); ?> <?php echo $this->Form->end(); ?>

View File

@ -15,7 +15,7 @@ if($profil['AppUser']['take_systemwide']){
<div class="tabs-below"> <div class="tabs-below">
<ul class="nav nav-tabs pull-right"> <ul class="nav nav-tabs pull-right">
<li><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings_account'));?></li> <li><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings_account'));?></li>
<li><?=$this->Html->link(__("dreamjob.settings.pages"),array('controller'=>'user','action'=>'settings_pages'));?></li> <li><?=$this->Html->link(__("dreamjob.settings.pages"),array('controller'=>'user','action'=>'settings_pageInh'));?></li>
<li class="active"><?=$this->Html->link(__("dreamjob.settings.isearch"),array('controller'=>'user','action'=>'settings_isearch'));?></li> <li class="active"><?=$this->Html->link(__("dreamjob.settings.isearch"),array('controller'=>'user','action'=>'settings_isearch'));?></li>
</ul> </ul>
</div> </div>

View File

@ -33,7 +33,7 @@ if($profil['AppUser']['take_systemwide']){
<div class="tabs-below"> <div class="tabs-below">
<ul class="nav nav-tabs pull-right"> <ul class="nav nav-tabs pull-right">
<li><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings_account'));?></li> <li><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings_account'));?></li>
<li class="active"><?=$this->Html->link(__("dreamjob.settings.pages"),array('controller'=>'user','action'=>'settings_pages'));?></li> <li class="active"><?=$this->Html->link(__("dreamjob.settings.pages"),array('controller'=>'user','action'=>'settings_pageInh'));?></li>
<?php <?php
if(!empty($WORKER) and count($WORKER)>0){ if(!empty($WORKER) and count($WORKER)>0){
?> ?>
@ -48,18 +48,20 @@ if($profil['AppUser']['take_systemwide']){
<?php foreach($profil['DreamjobPageInh'] as $pag){ ?> <?php foreach($profil['DreamjobPageInh'] as $pag){ ?>
<li<?php if(isset($page['DreamjobPageInh']['id'])) if ($page['DreamjobPageInh']['id'] == $pag['id']){?> class="active"<?php } ?> page="<?=$pag['id'];?>"> <li<?php if(isset($page['DreamjobPageInh']['id'])) if ($page['DreamjobPageInh']['id'] == $pag['id']){?> class="active"<?php } ?> page="<?=$pag['id'];?>">
<?php <?php
echo $this->Html->link('<span class="glyphicon glyphicon-move"></span> '.$pag['title'],array('controller'=>'user','action'=>'settings_pages','page'=> $pag['id'] ),array('escape'=>false)); echo $this->Html->link('<span class="glyphicon glyphicon-move"></span> '.$pag['title'],array('controller'=>'user','action'=>'settings_pageInh','page'=> $pag['id'] ),array('escape'=>false));
?> ?>
</li> </li>
<?php } ?> <?php } ?>
<li<?php if(empty($page)){?> class="active"<?php } ?>> <li<?php if(empty($page)){?> class="active"<?php } ?>>
<?php echo $this->Html->link('<span class="glyphicon glyphicon-plus"></span> '.__('dreamjob.page.new'),array('controller'=>'user','action'=>'settings_pages'),array('escape'=>false)); <?php echo $this->Html->link('<span class="glyphicon glyphicon-plus"></span> '.__('dreamjob.page.new'),array('controller'=>'user','action'=>'settings_pageInh'),array('escape'=>false));
?></li> ?></li>
</ul> </ul>
<legend></legend> <legend></legend>
<?php <?php
if(empty($page) or !isset($page['DreamjobPageText']))
$default_Form['type']='file';
echo $this->Form->create(false,$default_Form); echo $this->Form->create(false,$default_Form);
?> ?>
<fieldset> <fieldset>
@ -70,24 +72,26 @@ if($profil['AppUser']['take_systemwide']){
<legend><?=__('dreamjob.pages.types');?></legend> <legend><?=__('dreamjob.pages.types');?></legend>
<fieldset> <fieldset>
<?php <?php
$extra = array('type'=>'file'); if(empty($page) or isset($page['DreamjobPageImage']))
if(!empty($page) and !isset($page['DreamjobPageImage'])) echo $this->Form->input('DreamjobPageImage.image',array('type'=>'file'));
$extra['disabled'] = 'disabled';
echo $this->Form->input('DreamjobPageImage.image',$extra); if(empty($page)){
$extra = array();
if(!empty($page) and !isset($page['DreamjobPageText']))
$extra['disabled'] = 'disabled';
?> ?>
<div>Oder:</div> <div>Oder:</div>
<?=$this->Form->input('DreamjobPageText.text',$extra);?> <?php
}
if(empty($page) or isset($page['DreamjobPageText']))
echo $this->Form->input('DreamjobPageText.text');
?>
</fieldset> </fieldset>
<div class="buttonrow"> <div class="buttonrow">
<?php <?php
if(!empty($page)){ if(!empty($page)){
echo $this->Html->link('<span class="glyphicon glyphicon-trash"></span> '.__('dreamjob.page.del'),array('controller'=>'user','action'=>'settings_pages','?'=>array('del'=> $pag['id'])),array('escape'=>false,'class'=>'btn btn-default')); echo $this->Html->link('<span class="glyphicon glyphicon-trash"></span> '.__('dreamjob.page.del'),array('controller'=>'user','action'=>'settings_pageInh','?'=>array('del'=> $pag['id'])),array('escape'=>false,'class'=>'btn btn-default'));
} }
?> ?>
<?=$this->Form->button('<span class="glyphicon glyphicon-floppy-disk"></span> '.__('dreamjob.settings.save'),array('div' => false,'class'=>"btn btn-default ",'type' => 'submit'));?> <?=$this->Form->button('<span class="glyphicon glyphicon-floppy-disk"></span> '.__('dreamjob.settings.save'),array('div' => false,'class'=>"btn btn-primary ",'type' => 'submit'));?>
</div> </div>
<?php <?php
echo $this->Form->end(); echo $this->Form->end();

View File

@ -402,8 +402,4 @@ body.loading #container{
.infofield{ .infofield{
color:black; color:black;
} }
.btn.btn-primary{
background-color:red;
border-color:orange;
}

View File

@ -23,11 +23,10 @@
}); });
$(where+" form:not(.hide-form)").submit(function(e){ $(where+" form").submit(function(e){
if(!$(this).hasClass("hide-form") && $(this).attr('enctype')!='multipart/form-data' ){
e.stopPropagation(); e.stopPropagation();
//e.preventDefault(); //e.preventDefault();
if(!$(this).hasClass("hide-form")){
if($(this).attr("back")) if($(this).attr("back"))
back=window.location.href; back=window.location.href;
else else
@ -37,7 +36,18 @@
} }
}); });
$("form[ enctype *= 'multipart/form-data' ]").each(function(evt){
if (!$('#fileUpload').length)
$('body').append('<iframe id="fileUpload" name="fileUpload" style="display:none" />');
$(this).attr('target','fileUpload');
$(this).submit(function(){
frame = $('#fileUpload').load(function(){
setContent(frame.contents().find('body').html());
frame.unbind('load');
setTimeout(function (){frame.html('');}, 1);
});
});
});
$(where+" form.hide-form").each(function(evt){ $(where+" form.hide-form").each(function(evt){
that = this; that = this;
$('span.edit.label',this).click(function(evt){ $('span.edit.label',this).click(function(evt){
@ -74,22 +84,7 @@
//$(where+" form label.has-error").parent(".form-group").addClass("has-error") //$(where+" form label.has-error").parent(".form-group").addClass("has-error")
} }
function load(pageurl,conf,tab){ function setContent(data,back,tab){
data = {};
typemethode = "GET";
back = false;
if(conf['data'])
data = conf['data'];
if(conf['type'])
typemethode = conf['type'];
if(conf['back'] && conf['back'].indexOf("logout")== -1 && conf['back'].indexOf("login")== -1 )
back = conf['back'];
//e.preventDefault();
/*
if uncomment the above line, html5 nonsupported browers won't change the url but will display the ajax content;
if commented, html5 nonsupported browers will reload the page to the specified link.
*/
$.ajax({url:pageurl,data:data,type:typemethode,success: function(data){
alert = data.split('<!-- alert -->')[1].split('<!-- /alert -->')[0]; alert = data.split('<!-- alert -->')[1].split('<!-- /alert -->')[0];
if( alert.trim().length > 0){ if( alert.trim().length > 0){
$('#alert').html(alert); $('#alert').html(alert);
@ -122,7 +117,8 @@
navbar = data.split('<!-- extraScript -->')[1].split('<!-- /extraScript -->')[0]; navbar = data.split('<!-- extraScript -->')[1].split('<!-- /extraScript -->')[0];
eval($(navbar).html()); eval($(navbar).html());
} }
},error:function(data){ }
function setContentError(data,back,tab){
alert = "<div class=\"alert alert-danger\">"+data.statusText+ alert = "<div class=\"alert alert-danger\">"+data.statusText+
"<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>"
+ "</div>"; + "</div>";
@ -130,7 +126,23 @@
event("#alert"); event("#alert");
$('#container').html(data.responseText); $('#container').html(data.responseText);
event("#container"); event("#container");
}}); }
function load(pageurl,conf,tab){
data = {};
typemethode = "GET";
back = false;
if(conf['data'])
data = conf['data'];
if(conf['type'])
typemethode = conf['type'];
if(conf['back'] && conf['back'].indexOf("logout")== -1 && conf['back'].indexOf("login")== -1 )
back = conf['back'];
//e.preventDefault();
/*
if uncomment the above line, html5 nonsupported browers won't change the url but will display the ajax content;
if commented, html5 nonsupported browers will reload the page to the specified link.
*/
$.ajax({url:pageurl,data:data,type:typemethode,success:function(data){setContent(data,back,tab);} ,error:function(data){setContentError(data,back,tab);}});
if(pageurl!=window.location){ if(pageurl!=window.location){
window.history.pushState({path:pageurl},'',pageurl); window.history.pushState({path:pageurl},'',pageurl);
} }