Automatisation de l'ajax "visibility"

Ajout de la méthode setVisibility à 3 Modèles
Bug Chrome sur les liens éliminé
This commit is contained in:
Chouchen 2010-09-22 14:02:40 +00:00
parent 81bf7cb785
commit 73e97a31be
9 changed files with 91 additions and 53 deletions

View File

@ -1,29 +1,9 @@
<?// Escaping the input data:
//TODO automatisation ! Je veux plus de "$config_xml[x]"
$clock = $_POST['clock'];
$weather = $_POST['weather'];
$notes = $_POST['notes'];
$search = $_POST['search'];
$links = $_POST['links'];
$blogs = $_POST['blogs'];
$todo = $_POST['todo'];
$clockAdvanced = $_POST['clockAdvanced'];
$rssblogs = $_POST['rssblogs'];
$news = $_POST['news'];
$xmla = simplexml_load_file('../db/config.xml');
$config_xml = $xmla->item;
$config_xml[0]->visibility = $clock;
$config_xml[1]->visibility = $weather;
$config_xml[2]->visibility = $notes;
$config_xml[3]->visibility = $search;
$config_xml[4]->visibility = $links;
$config_xml[5]->visibility = $blogs;
$config_xml[6]->visibility = $todo;
$config_xml[7]->visibility = $clockAdvanced;
$config_xml[8]->visibility = $rssblogs;
$config_xml[9]->visibility = $news;
$xmla->asXML('../db/config.xml');
<?
$options = array();
$module ='';
include '../class/AccueilModules.php';
foreach($_POST as $module => $valeur){
AccueilModules::updateModule($module, array('visibility'=>$valeur));
}
echo "1";
?>

View File

@ -65,14 +65,14 @@ class AccueilModules {
$(\'#config-submit\').live(\'click\',function(e){
$(this).replaceWith(\'<img src="images/interface/ajax_load.gif" style="margin:30px auto;display:block" />\');
var data3 = {';
$temp = '';
foreach($this->modules as $module=>$moduleConf){
echo '\''.$module.'\' : $(\'input[type=radio][name='.$module.'_group]:checked\').attr(\'value\'),';
$temp .= '\''.$module.'\' : $(\'input[type=radio][name='.$module.'_group]:checked\').attr(\'value\'),';
}
echo substr($temp, 0, -1);
echo '};
$.post(\'ajax/post-config.php\',data3,function(msg3){
if(msg3=="1"){
location.reload();
}
});
e.preventDefault();
});

View File

@ -19,7 +19,7 @@ class links {
echo '<span class="label">'.$label['id'].'</span>
<ul class="iconlist" id="'.$label['id'].'">';
foreach($label->link as $link){
echo '<li class="item" id="'.$link->title.'"><a href="'.$link->url.'" onclick="'.$link->onclick.'"><img src="images/links/'.$link->img.'" /><br>'.$link->title.'</a></li>';
echo '<li class="item" id="'.$link->title.'"><a href="'.$link->url.'" class="'.$link->onclick.'"><img src="images/links/'.$link->img.'" /><br>'.$link->title.'</a></li>';
}
echo '</ul>
<hr>';
@ -50,6 +50,18 @@ class links {
echo "ok";
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='links']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){

View File

@ -23,6 +23,18 @@ class notes extends Module {
$notes = new notes($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='notes']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){

View File

@ -23,6 +23,18 @@ class ouifm extends Module {
$ouifm = new ouifm($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='ouifm']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){

View File

@ -42,7 +42,7 @@ class rssblogs extends Module {
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path = $xmla->xpath("//item[@id='rssblogs']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
@ -54,7 +54,7 @@ class rssblogs extends Module {
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path = $xmla->xpath("//item[@id='rssblogs']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
@ -66,7 +66,7 @@ class rssblogs extends Module {
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path = $xmla->xpath("//item[@id='rssblogs']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);

View File

@ -2,37 +2,37 @@
<label id="Google Apps">
<link>
<url>http://mail.google.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>gmail_128.png</img>
<title>Gmail</title>
</link>
<link>
<url>http://mail.live.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>mail-msn.png</img>
<title>Hotmail</title>
</link>
<link>
<url>http://mail1.voila.fr/webmail/fr_FR/login.html</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>voila.png</img>
<title>Voila.fr mail</title>
</link>
<link>
<url>http://calendar.google.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>calendar_128.png</img>
<title>GoogleCalendar</title>
</link>
<link>
<url>http://reader.google.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>reader_128.png</img>
<title>Google Reader</title>
</link>
<link>
<url>http://docs.google.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>docs_128.png</img>
<title>Google Docs</title>
</link>
@ -40,37 +40,37 @@
<label id="Media">
<link>
<url>http://youtube.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>youtube_128.png</img>
<title>YouTube</title>
</link>
<link>
<url>http://picasaweb.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>picasaweb_128.png</img>
<title>PicasaWeb</title>
</link>
<link>
<url>http://www.netvibes.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>netvibes.png</img>
<title>Netvibes</title>
</link>
<link>
<url>http://www.deviantart.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>deviantART128.png</img>
<title>DeviantArt</title>
</link>
<link>
<url>https://www.labanquepostale.fr/index.html</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>banquepostale.png</img>
<title>Banque 1</title>
</link>
<link>
<url>http://www.societegenerale.fr/</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>societegenerale.png</img>
<title>Banque 2</title>
</link>
@ -110,25 +110,25 @@
<label id="Entertainment">
<link>
<url>http://facebook.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>facebook.png</img>
<title>Facebook</title>
</link>
<link>
<url>http://twitter.com</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>twitter.png</img>
<title>Twitter</title>
</link>
<link>
<url>http://fr.vente-privee.com/</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>vp128.png</img>
<title>Ventes Privées</title>
</link>
<link>
<url>http://www.google.fr/movies</url>
<onclick>spawnLink(this);return false;</onclick>
<onclick>popup</onclick>
<img>Gmovie.png</img>
<title>Horaires Ciné</title>
</link>

View File

@ -25,16 +25,32 @@ $(document).ready(function(){
// Mouvement des liens avec enregistrement
$(".iconlist").sortable(
{
//distance: 45,
connectWith: '.iconlist',
update: function(event,ui){
var linkOrder = $(this).sortable('toArray').toString();
var label = $(ui.item).parent()[0].id;
var itemMoved = $(ui.item)[0].id;
$.post("ajax/update-links-order.php", {order: linkOrder, label : label, itemMoved: itemMoved});
},
start: function(e) {
// have to remvoe click handler off item so drop doesn't click
$("a.popup").unbind("click");
},
stop: function(e) {
//$("a.popup").bind("click", function(e){ itemClickHandler(e, $(this)); });
//$("a.popup").click(itemClickHandler);
}
}
).disableSelection().mouseout(function(){
// reattach the item click handler
$('a.popup').unbind("click").bind("click", function(e){
e.preventDefault();
var url = $(this).attr('href');
spawnURL(url);
});
});
}
}
).disableSelection();
});

View File

@ -56,7 +56,13 @@ function make_draggable(elements)
}
});
}
$(document).ready(function(){
$('a.popup').bind("click", function(e){
e.preventDefault();
var url = $(this).attr('href');
spawnURL(url);
});
$('body').prepend('<div id="menu-bar"></div>');
$('#menu-bar').prepend($('#config-menu'));