diff options
| author | 2012-10-22 22:11:23 +0200 | |
|---|---|---|
| committer | 2012-10-22 22:11:23 +0200 | |
| commit | a928ebf1d010433d81d3afe5a6981f7ca391b9c7 (patch) | |
| tree | 94cbb70710abf65c1e993b272bade0958e5b4e01 /app/views | |
| parent | 0426541acbeb44d240e6dbf7a93f3a104bea61b4 (diff) | |
ajout des touches de raccourcis et de tout le javascript
Diffstat (limited to 'app/views')
| -rw-r--r-- | app/views/configure/display.phtml | 6 | ||||
| -rw-r--r-- | app/views/index/index.phtml | 18 | ||||
| -rw-r--r-- | app/views/javascript/main.phtml | 130 |
3 files changed, 143 insertions, 11 deletions
diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 228957b6a..5b25a51fc 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -22,11 +22,11 @@ <label>Afficher les articles dépliés par défaut</label> <div class="radio_group"> - <input type="radio" name="display_posts" id="radio_yes" value="yes"<?php echo $this->conf->displayPosts () ? ' checked="checked"' : ''; ?> /> + <input type="radio" name="display_posts" id="radio_yes" value="yes"<?php echo $this->conf->displayPosts () == 'yes' ? ' checked="checked"' : ''; ?> /> <label for="radio_yes">Oui</label> <br /> - <input type="radio" name="display_posts" id="radio_no" value="no"<?php echo !$this->conf->displayPosts () ? ' checked="checked"' : ''; ?> /> - <label for="radio_no">Non</label> + <input type="radio" name="display_posts" id="radio_no" value="no"<?php echo $this->conf->displayPosts () == 'no' ? ' checked="checked"' : ''; ?> /> + <label for="radio_no">Non<noscript> - <strong>nécessite que javascript soit activé</strong></noscript></label> </div> <input type="submit" value="Valider" /> diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 8863d08a2..af01f3fd2 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -1,3 +1,5 @@ +<?php $items = $this->entryPaginator->items (); ?> +<?php if (!empty ($items)) { ?> <div id="top"> <a class="read_all" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('is_read' => 1))); ?>">Tout marquer comme lu</a><!-- <?php if (Session::param ('mode', 'all') == 'not_read') { ?> @@ -8,8 +10,6 @@ </div> <div id="stream"> -<?php $items = $this->entryPaginator->items (); ?> -<?php if (!empty ($items)) { ?> <?php $this->entryPaginator->render ('pagination.phtml', 'page'); ?> <?php foreach ($items as $item) { ?> @@ -27,23 +27,25 @@ <div class="after"> <?php if (!$item->isRead ()) { ?> - <a href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('id' => $item->id (), 'is_read' => 1))); ?>">J'ai fini de lire l'article</a><!-- + <a class="read" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('id' => $item->id (), 'is_read' => 1))); ?>">J'ai fini de lire l'article</a><!-- <?php } else { ?> - <a href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('id' => $item->id (), 'is_read' => 0))); ?>">Marquer comme non lu</a><!-- + <a class="read" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('id' => $item->id (), 'is_read' => 0))); ?>">Marquer comme non lu</a><!-- <?php } ?> <?php if (!$item->isFavorite ()) { ?> - --><a href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'bookmark', 'params' => array ('id' => $item->id (), 'is_favorite' => 1))); ?>">Ajouter l'article à mes favoris</a> + --><a class="bookmark" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'bookmark', 'params' => array ('id' => $item->id (), 'is_favorite' => 1))); ?>">Ajouter l'article à mes favoris</a> <?php } else { ?> - --><a href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'bookmark', 'params' => array ('id' => $item->id (), 'is_favorite' => 0))); ?>">Retirer l'article de mes favoris</a> + --><a class="bookmark" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'bookmark', 'params' => array ('id' => $item->id (), 'is_favorite' => 0))); ?>">Retirer l'article de mes favoris</a> <?php } ?> </div> </div> <?php } ?> <?php $this->entryPaginator->render ('pagination.phtml', 'page'); ?> +</div> <?php } else { ?> - <div class="post flux"> +<div class="table"> + <div class="nothing"> <p> Il n'y a aucun flux à afficher. <?php if (Session::param ('mode', 'all') == 'not_read') { ?> @@ -51,5 +53,5 @@ <?php } ?> </p> </div> -<?php } ?> </div> +<?php } ?> diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml new file mode 100644 index 000000000..87b53ca9a --- /dev/null +++ b/app/views/javascript/main.phtml @@ -0,0 +1,130 @@ +<?php if ($this->conf->displayPosts () == 'no') { ?> +var hide_posts = true; +<?php } else { ?> +var hide_posts = false; +<?php } ?> + +function redirect (url) { + if (url) { + location.href = url; + } +} + +function slide (new_active, old_active) { + old_active.removeClass ("active"); + new_active.addClass ("active"); + + if (hide_posts) { + old_active.children (".content").slideUp (200); + new_active.children (".content").slideDown (200, function () { + $.smoothScroll({ + offset: new_active.position ().top + 25 + }); + }); + } else { + $.smoothScroll({ + offset: new_active.position ().top + 25 + }); + } +} + +$(document).ready (function () { + if (hide_posts) { + $(".post.flux .content").slideToggle (); + } + + // Touches de manipulation + shortcut.add("m", function () { + // on marque comme lu ou non lu + active = $(".post.flux.active"); + url = active.find ("a.read").attr ("href"); + + $.ajax ({ + type: 'POST', + url: url, + data : { ajax: true } + }).done (function () { + if (active.hasClass ("not_read")) { + active.removeClass ("not_read"); + } else { + active.addClass ("not_read"); + } + }); + }); + shortcut.add("f", function () { + // on marque comme favori ou non favori + active = $(".post.flux.active"); + url = active.find ("a.bookmark").attr ("href"); + + $.ajax ({ + type: 'POST', + url: url, + data : { ajax: true } + }).done (function () { + if (active.hasClass ("favorite")) { + active.removeClass ("favorite"); + } else { + active.addClass ("favorite"); + } + }); + }); + shortcut.add("space", function () { + // On plie / déplie l'article + active = $(".post.flux.active"); + active.children (".content").slideToggle (200, function () { + $.smoothScroll({ + offset: active.position ().top + 25 + }); + }); + }); + + // Touches de navigation + shortcut.add("up", function () { + old_active = $(".post.flux.active"); + last_active = $(".post.flux:last"); + new_active = old_active.prev (); + + if (new_active[0] instanceof HTMLDivElement) { + slide (new_active, old_active); + } else { + slide (last_active, old_active); + } + }); + shortcut.add("down", function () { + old_active = $(".post.flux.active"); + first_active = $(".post.flux:first"); + new_active = old_active.next (); + + if (new_active[0] instanceof HTMLDivElement) { + slide (new_active, old_active); + } else { + slide (first_active, old_active); + } + }); + shortcut.add("right", function () { + url = $(".pager-next a").attr ("href"); + if (url === undefined) { + url = $(".pager-first a").attr ("href"); + } + + redirect (url); + }); + shortcut.add("left", function () { + url = $(".pager-previous a").attr ("href"); + if (url === undefined) { + url = $(".pager-last a").attr ("href"); + } + + redirect (url); + }); + + + $(".post.flux").click (function () { + old_active = $(".post.flux.active"); + new_active = $(this); + + if (old_active[0] != new_active[0]) { + slide (new_active, old_active); + } + }); +}); |
