Skip to content

Commit

Permalink
Merge pull request #56 from s-nakajima/master
Browse files Browse the repository at this point in the history
言語の切り替えタブを左位置にセットできるように修正
  • Loading branch information
s-nakajima committed Sep 25, 2017
2 parents 4b17795 + 8563e6e commit d7a5587
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
7 changes: 6 additions & 1 deletion View/Elements/switch_language.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* - $languages: Languages data
* - $prefix: It is id attribute prefix
* - $activeLangCode: active language
* - $position: 配置場所
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
Expand All @@ -14,10 +15,14 @@

App::uses('L10n', 'I18n');
$L10n = new L10n();

if (! isset($position)) {
$position = ' pull-right';
}
?>

<div ng-init="activeLangId = '<?php echo h($activeLangId); ?>'" class="clearfix m17n-language-switch">
<ul class="nav nav-pills pull-right small" role="tablist">
<ul class="nav nav-pills<?php echo $position; ?> small" role="tablist">
<?php foreach ($languages as $langId => $langCode) : ?>
<li class="<?php echo ($activeLangId === (string)$langId ? 'active' : ''); ?>">
<a class="nc-switch-language" href="#<?php echo $prefix . $langId ?>" role="tab" data-toggle="tab"
Expand Down
17 changes: 10 additions & 7 deletions View/Helper/SwitchLanguageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ class SwitchLanguageHelper extends AppHelper {
/**
* 言語切り替えタブ
*
* @param string $prefix It is id attribute prefix
* @param string $prefix タブIDのプレフィックス
* @param array $options elementに渡すオプション
* @return string
*/
public function tablist($prefix = null) {
public function tablist($prefix = null, $options = []) {
$this->NetCommonsHtml->css('/m17n/css/style.css');

return $this->_View->element('M17n.switch_language', array(
'prefix' => $prefix,
'languages' => $this->_View->viewVars['languages'],
'activeLangId' => $this->_View->viewVars['activeLangId'],
));
return $this->_View->element('M17n.switch_language',
array_merge(array(
'prefix' => $prefix,
'languages' => $this->_View->viewVars['languages'],
'activeLangId' => $this->_View->viewVars['activeLangId'],
), $options)
);
}

/**
Expand Down

0 comments on commit d7a5587

Please sign in to comment.