125 lines
2.8 KiB
PHTML
Raw Normal View History

2012-01-15 17:43:37 +00:00
<style>
div#entete {
width:45%;
float:left;
2012-01-19 08:19:02 +00:00
border:1px solid #bebebe;
2012-01-15 17:43:37 +00:00
height:400px;
overflow:auto;
margin:5px 0;
}
div#entete li {
background-color:#4D90FE;
border-top:2px solid #ffffff;
border-bottom:2px solid #ffffff;
line-height:20px;
font-weight:bold;
color:#000000;
2012-01-19 08:19:02 +00:00
margin-left:30px;
padding-left:10px;
}
div#dico {
width:45%;
height:400px;
float:right;
border:1px solid #bebebe;
overflow:auto;
margin:5px 0;
2012-01-15 17:43:37 +00:00
}
div#dico li {
list-style-type:none;
padding-left:10px;
background-color:#4D90FE;
border-top:2px solid #ffffff;
border-bottom:2px solid #ffffff;
line-height:20px;
font-weight:bold;
color:#000000;
}
</style>
<div id="entete">
<h1 class="ui-widget-header">Entete</h1>
<div class="ui-widget-content">
<ol>
2012-01-19 08:19:02 +00:00
<span class="placeholder">Placer les elements ici</span>
2012-01-15 17:43:37 +00:00
</ol>
2012-01-16 14:19:25 +00:00
</div>
2012-01-15 17:43:37 +00:00
</div>
<div id="dico">
<h1 class="ui-widget-header">Elements disponibles</h1>
<ul>
2012-01-16 14:19:25 +00:00
<?php foreach($this->elements as $key => $element) {?>
<li id="<?=$key?>">
<?php if (isset($element['lib'])) { echo $element['lib']; } else { echo $key; }?>
<?php if (isset($element['values'])) { echo "<input type=\"text\" name=\"".$key."\" value=\"\"/>"; }?>
</li>
2012-01-15 17:43:37 +00:00
<?php }?>
</ul>
</div>
2012-01-16 14:19:25 +00:00
<div style="clear:both;">
Référence <input type="text" name="profil" value="" />
<a id="save" href="<?=$this->url(array('controller'=>'profil', 'action'=>'save'))?>">Sauvegarder</a>
</div>
2012-01-15 17:43:37 +00:00
<script>
$(function() {
2012-01-19 08:19:02 +00:00
$("#dico li").draggable({
2012-01-15 17:43:37 +00:00
appendTo: "body",
helper: "clone"
});
2012-01-19 08:19:02 +00:00
$("#entete ol").droppable({
2012-01-15 17:43:37 +00:00
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: ":not(.ui-sortable-helper)",
drop: function( event, ui ) {
2012-01-16 14:19:25 +00:00
$( this ).find( ".placeholder" ).remove();
var id = ui.draggable.attr('id');
$('<li id="'+id+'"></li>').html( ui.draggable.html() ).appendTo( this );
2012-01-15 17:43:37 +00:00
}
}).sortable({
items: "li:not(.placeholder)",
sort: function() {
$( this ).removeClass( "ui-state-default" );
}
});
2012-01-16 14:19:25 +00:00
2012-01-19 08:19:02 +00:00
$("#entete").delegate("a.delete","click", function(){
$(this).parent().remove();
});
$("#entete ol").delegate("li" , "hover", function(e) {
if (e.type === 'mouseenter') {
var html = $(this).html();
$(this).html(html+'<a href="#" class="delete">Supprimer</a>');
} else {
$( this ).find( ".delete" ).remove();
}
});
2012-01-16 14:19:25 +00:00
$('#save').click(function(e){
e.preventDefault();
var url = $(this).attr('href');
var list = new Array();
$('#entete ol li').each(function(index){
var id = $(this).attr('id');
if($('input[name='+id+']', this).length>0){
id = id + '(' + $('input[name='+id+']', this).val() + ')';
}
list.push(id);
});
var ref = $('input[name=profil]').val();
if (ref!='') {
$.post(url, { reference: ref, criteres: list.join() }, function(data){
2012-01-19 11:23:51 +00:00
if (data!='Erreur'){ window.location.href = '/'; }
2012-01-16 14:19:25 +00:00
}, 'json');
}
});
2012-01-15 17:43:37 +00:00
});
</script>