Commit 0a2a5d46 by Alexander Makarov

Merge pull request #2595 from thiagotalma/master

Arrows to display the previous and next files.
parents 3cf9e8f8 facb5469
...@@ -13,6 +13,7 @@ Yii Framework 2 gii extension Change Log ...@@ -13,6 +13,7 @@ Yii Framework 2 gii extension Change Log
- Enh #1897: diff markup is now copy paste friendly (samdark) - Enh #1897: diff markup is now copy paste friendly (samdark)
- Enh #2327: better visual representation of changed files, added header and refresh button to diff modal (thiagotalma) - Enh #2327: better visual representation of changed files, added header and refresh button to diff modal (thiagotalma)
- Enh #2491: Added support for using the same base class name of search model and data model in Gii (qiangxue) - Enh #2491: Added support for using the same base class name of search model and data model in Gii (qiangxue)
- Enh #2595: Browse through all generated files using right and left arrows (thiagotalma)
2.0.0 alpha, December 1, 2013 2.0.0 alpha, December 1, 2013
----------------------------- -----------------------------
......
...@@ -35,10 +35,13 @@ yii.gii = (function ($) { ...@@ -35,10 +35,13 @@ yii.gii = (function ($) {
}; };
var initPreviewDiffLinks = function () { var initPreviewDiffLinks = function () {
$('.preview-code, .diff-code, .modal-refresh').on('click', function () { $('.preview-code, .diff-code, .modal-refresh, .modal-previous, .modal-next').on('click', function () {
var $modal = $('#preview-modal'); var $modal = $('#preview-modal');
var $link = $(this); var $link = $(this);
$modal.find('.modal-refresh').attr('href', $link.prop('href')); $modal.find('.modal-refresh').attr('href', $link.attr('href'));
if ($link.hasClass('preview-code') || $link.hasClass('diff-code')) {
$modal.data('action', ($link.hasClass('preview-code') ? 'preview-code' : 'diff-code'))
}
$modal.find('.modal-title').text($link.data('title')); $modal.find('.modal-title').text($link.data('title'));
$modal.find('.modal-body').html('Loading ...'); $modal.find('.modal-body').html('Loading ...');
$modal.modal('show'); $modal.modal('show');
...@@ -48,6 +51,15 @@ yii.gii = (function ($) { ...@@ -48,6 +51,15 @@ yii.gii = (function ($) {
url: $link.prop('href'), url: $link.prop('href'),
data: $('.default-view form').serializeArray(), data: $('.default-view form').serializeArray(),
success: function (data) { success: function (data) {
if (!$link.hasClass('modal-refresh')) {
var filesSelector = 'a.' + $modal.data('action');
var $files = $(filesSelector);
var index = $files.filter('[href="' + $link.attr('href') + '"]').index(filesSelector);
var $prev = $files.eq(index-1);
var $next = $files.eq((index+1 == $files.length ? 0 : index+1));
$modal.find('.modal-previous').attr('href', $prev.attr('href')).data('title', $prev.data('title'));
$modal.find('.modal-next').attr('href', $next.attr('href')).data('title', $next.data('title'));
}
$modal.find('.modal-body').html(data); $modal.find('.modal-body').html(data);
$modal.find('.content').css('max-height', ($(window).height() - 200) + 'px'); $modal.find('.content').css('max-height', ($(window).height() - 200) + 'px');
}, },
......
...@@ -81,7 +81,14 @@ use yii\gii\CodeFile; ...@@ -81,7 +81,14 @@ use yii\gii\CodeFile;
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4><a class="modal-refresh glyphicon glyphicon-refresh" href="#"></a> <span class="modal-title">Modal title</span></h4> <div class="btn-group pull-left">
<a class="modal-previous btn btn-xs btn-default" href="#"><span class="glyphicon glyphicon-arrow-left"></span></a>
<a class="modal-next btn btn-xs btn-default" href="#"><span class="glyphicon glyphicon-arrow-right"></span></a>
<a class="modal-refresh btn btn-xs btn-default" href="#"><span class="glyphicon glyphicon-refresh"></span></a>
&nbsp;
</div>
<strong class="modal-title pull-left">Modal title</strong>
<div class="clearfix"></div>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Please wait ...</p> <p>Please wait ...</p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment