Browse Source

[Issues #46 #131] Repostionner le scrool après marqué comme lu avec le bouton, FIX touches raccourcis
- remodelage de la page d'index avec suppression des onclick sur les boutons
- gestion unique de la zone de sélection d'un article avec une nouvelle fonction js buttonAction

Simounet 7 years ago
parent
commit
ae32fe5a69
3 changed files with 43 additions and 15 deletions
  1. 5 0
      templates/marigolds/css/style.css
  2. 3 3
      templates/marigolds/index.html
  3. 35 12
      templates/marigolds/js/script.js

+ 5 - 0
templates/marigolds/css/style.css

@@ -286,6 +286,11 @@ header a,header a:hover,header a:visited{
 	color:#939393;
 	margin:0px;
 }
+#main article section .articleDetails .readUnreadButton,
+#main article section .articleDetails .readUnreadButton:hover
+{
+	color: #FFF;
+}
 
 #main article div.articleContent .enclosure{
 	color:#F16529;

+ 3 - 3
templates/marigolds/index.html

@@ -123,7 +123,7 @@
 					<!-- CORPS ARTICLE -->
 					 
 					
-					<section id="{$value->getId()}" onclick="targetThisEvent(this);" class="{if="!$value->getUnread()"} eventRead {/if} {$hightlighted%2==0?'eventHightLighted':''}" >
+					<section id="{$value->getId()}" class="{if="!$value->getUnread()"}eventRead{/if} {$hightlighted%2==0?'eventHightLighted':''}" >
 						<a title="Revenir en haut de page" class="goTopButton" href="#pageTopAnvil">ˆ</a>
 						<!-- TITRE -->
 						<h2 class="articleTitle">
@@ -149,7 +149,7 @@
 							 <a class="pointer favorite" onclick="removeFavorite(this,{$value->getId()});" >Défavoriser</a> 
 							 {/if}
 							
-							 <span class="pointer right readUnreadButton" onclick="readThis(this,{$value->getId()}{$action=='unreadEvents' || $action==''?',true':''});">(lu/non lu)</span>
+							 <a class="pointer right readUnreadButton">(lu/non lu)</a>
 							 {function="Plugin::callHook("event_post_top_options", array(&$value))"}
 						</h3>
 
@@ -172,7 +172,7 @@
 							<h3 class="articleDetails">
 								{function="Plugin::callHook("event_pre_bottom_options", array(&$value))"}
 							
-								<span class="pointer right readUnreadButton" onclick="readThis(this,{$value->getId()}{$action=='unreadEvents' || $action==''?',true':''});">(lu/non lu)</span>
+								<a class="pointer right readUnreadButton">(lu/non lu)</a>
 								{if="$value->getFavorite()!=1"}<a class="right pointer favorite"  onclick="addFavorite(this,{$value->getId()});" >Favoriser</a> 
 								{else}
 							 	<a class="right pointer favorite" onclick="removeFavorite(this,{$value->getId()});" >Défavoriser</a>  

+ 35 - 12
templates/marigolds/js/script.js

@@ -42,6 +42,16 @@ $(document).ready(function(){
 
 		targetThisEvent($('article section:first'),true);
 
+		$('article section').click(function(event){
+			var target = event.target;
+			var id = this.id;
+			if($(target).hasClass('readUnreadButton')){
+				buttonAction(target,id);
+			}else{
+				targetThisEvent(this);
+			}
+		});
+
 	}
 
 });
@@ -137,25 +147,22 @@ function openTargetEvent(){
 
 function readTargetEvent(){
 	var buttonElement = $('.eventSelected .readUnreadButton');
-	var id = $('.anchor',target).attr('name');
+	var id = $(target).attr('id');
 	readThis(buttonElement,id,null,function(){
 		targetThisEvent($('.eventSelected').next(),true);
 	});
-	
-	
-
 }
 
 function readAllDisplayedEvents(){
 	$('article section').each(function(i,article){
 		var buttonElement = $('.readUnreadButton',article);
-		var id = $('.anchor',article).attr('name');
+		var id = $('.anchor',article).attr('id');
 		readThis(buttonElement,id);
 	});
 }
 
 function switchFavoriteTargetEvent(){
-	var id = $('.anchor',target).attr('name');
+	var id = $(target).attr('id');
 	if($('.favorite',target).html()=='Favoriser'){
 		addFavorite($('.favorite',target),id);
 	}else{
@@ -261,15 +268,21 @@ function changeFeedFolder(element,id){
 function readThis(element,id,from,callback){
 	var hide = ($('#pageTop').html()==''?true:false);
 	var parent = $(element).parent().parent();
+	var nextEvent = $('#'+id).next();
 	if(!parent.hasClass('eventRead')){
 
 		if(hide){ 
-					  		parent.fadeOut(200,function(){
-					  			if(null!=callback) callback();
-					  		}); 
-					  	}else{ 
-					  		parent.addClass('eventRead');
-					  	}
+			parent.fadeOut(200,function(){
+				if(callback){
+					callback();
+				}else{
+					targetThisEvent(nextEvent,true);
+				}
+			}); 
+		}else{ 
+			parent.addClass('eventRead');
+			targetThisEvent(nextEvent,true);
+		}
 		
 		$.ajax({
 					  url: "./action.php?action=readContent",
@@ -314,3 +327,13 @@ function toggleBlocks(target){
 	target=target.substring(1);
 	$('#main article > section').hide();$('.'+target).fadeToggle(200);
 }
+
+function buttonAction(target,id){
+	// Check unreadEvent
+	if($('#pageTop').html()){
+		var from=true;
+	}else{
+		var from='';
+	}
+	readThis(target,id,from);
+}