Skip to content
Snippets Groups Projects
Commit 477c0ca1 authored by Jared Hancock's avatar Jared Hancock
Browse files

i18n: Add vertical tabs to the content management dialog

parent 7bfc50cf
Branches
Tags
No related merge requests found
...@@ -141,3 +141,7 @@ ...@@ -141,3 +141,7 @@
padding-left: 8px; padding-left: 8px;
padding-right: initial; padding-right: initial;
} }
.rtl .left-tabs {
margin-left: auto;
margin-right: 45px;
}
...@@ -137,8 +137,9 @@ class ContentAjaxAPI extends AjaxController { ...@@ -137,8 +137,9 @@ class ContentAjaxAPI extends AjaxController {
$content = Page::lookup($id, $lang); $content = Page::lookup($id, $lang);
$langs = $cfg->getSecondaryLanguages(); $langs = Internationalization::getConfiguredSystemLanguages();
$translations = $content->getAllTranslations(); $translations = $content->getAllTranslations();
$info = array();
foreach ($translations as $t) { foreach ($translations as $t) {
if (!($data = $t->getComplex())) if (!($data = $t->getComplex()))
continue; continue;
......
...@@ -168,16 +168,19 @@ $manage_content = function($title, $content) use ($contents) { ...@@ -168,16 +168,19 @@ $manage_content = function($title, $content) use ($contents) {
$notes = explode('. ', $notes); $notes = explode('. ', $notes);
$notes = $notes[0]; $notes = $notes[0];
?><tr><td colspan="2"> ?><tr><td colspan="2">
<div style="display:inline-block;margin:0 36px">
<i class="icon-file-text pull-left icon-2x" style="color:#bbb;margin:0 -36px"></i>
<a href="#ajax.php/content/<?php echo $id; ?>/manage" <a href="#ajax.php/content/<?php echo $id; ?>/manage"
onclick="javascript: onclick="javascript:
$.dialog($(this).attr('href').substr(1), 200); $.dialog($(this).attr('href').substr(1), 200);
return false;"><i class="icon-file-text pull-left icon-2x" return false;">
style="color:#bbb;"></i> <?php <?php
echo Format::htmlchars($title); ?></a><br/> echo Format::htmlchars($title); ?></a><br/>
<span class="faded" style="display:inline-block;width:90%"><?php <span class="faded"><?php
echo Format::display($notes); ?> echo Format::display($notes); ?>
<em>(<?php echo sprintf(__('Last Updated %s'), Format::datetime($upd)); <em>(<?php echo sprintf(__('Last Updated %s'), Format::datetime($upd));
?>)</em></span></td></tr><?php ?>)</em></span>
</div></td></tr><?php
}; ?> }; ?>
<tr> <tr>
<th colspan="2"> <th colspan="2">
......
<h3><?php echo __('Manage Content'); ?> &mdash; <?php echo Format::htmlchars($content->getName()); ?></h3> <h3><?php echo __('Manage Content'); ?> &mdash; <?php echo Format::htmlchars($content->getName()); ?></h3>
<a class="close" href=""><i class="icon-remove-circle"></i></a> <a class="close" href=""><i class="icon-remove-circle"></i></a>
<hr/> <hr/>
<?php if ($langs) { ?>
<div class="banner">&nbsp; <form method="post" action="#content/<?php echo $content->getId(); ?>"
<span class="pull-left"> style="clear:none">
<i class="icon-globe icon-large"></i> <?php
<?php echo __('This content is translatable'); ?> if (count($langs) > 1) { ?>
</span> <ul class="vertical left tabs">
<span class="pull-right"> <li class="empty"><i class="icon-globe" title="This content is translatable"></i></li>
<select onchange="javascript: <?php foreach ($langs as $tag=>$nfo) { ?>
$('option', this).each(function(){$($(this).val()).hide()}); <li class="<?php if ($tag == $cfg->getPrimaryLanguage()) echo "active";
$($('option:selected', this).val()).show(); "> ?>"><a href="#translation-<?php echo $tag; ?>" title="<?php
<option value="#reference-text"><?php echo echo Internationalization::getLanguageDescription($tag);
Internationalization::getLanguageDescription($cfg->getPrimaryLanguage()); ?>"><span class="flag flag-<?php echo strtolower($nfo['flag']); ?>"></span>
?><?php echo __('Primary'); ?></option> </a></li>
<?php foreach ($langs as $tag) { ?>
<option value="#translation-<?php echo $tag; ?>"><?php echo
Internationalization::getLanguageDescription($tag);
?></option>
<?php } ?>
</select>
</span>
</div>
<?php } ?> <?php } ?>
<form method="post" action="#content/<?php echo $content->getId(); ?>"> </ul>
<div id="reference-text" lang="<?php echo $cfg->getPrimaryLanguage(); ?>"> <?php
} ?>
<div id="translation-<?php echo $cfg->getPrimaryLanguage(); ?>"
class="tab_content left-tabs" style="padding:0" lang="<?php echo $cfg->getPrimaryLanguage(); ?>">
<input type="text" style="width: 100%; font-size: 14pt" name="name" value="<?php <input type="text" style="width: 100%; font-size: 14pt" name="name" value="<?php
echo Format::htmlchars($content->getName()); ?>" /> echo Format::htmlchars($content->getName()); ?>" />
<div style="margin-top: 5px"> <div style="margin-top: 5px">
...@@ -34,21 +29,29 @@ ...@@ -34,21 +29,29 @@
</div> </div>
</div> </div>
<?php foreach ($langs as $tag) { ?> <?php foreach ($langs as $tag=>$nfo) {
<div id="translation-<?php echo $tag; ?>" style="display:none" lang="<?php echo $tag; ?>"> if ($tag == $cfg->getPrimaryLanguage())
<input type="text" style="width: 100%; font-size: 14pt" name="trans[<?php echo $tag; ?>][title]" value="<?php continue; ?>
echo Format::htmlchars($info['title'][$tag]); ?>" /> <div id="translation-<?php echo $tag; ?>" class="tab_content left-tabs"
style="display:none;padding:0" dir="<?php echo $nfo['direction']; ?>" lang="<?php echo $tag; ?>">
<input type="text" style="width: 100%; font-size: 14pt"
name="trans[<?php echo $tag; ?>][title]" value="<?php
echo Format::htmlchars($info['title'][$tag]); ?>"
placeholder="<?php echo __('Title'); ?>" />
<div style="margin-top: 5px"> <div style="margin-top: 5px">
<textarea class="richtext no-bar" name="trans[<?php echo $tag; ?>][body]"><?php <textarea class="richtext no-bar" data-direction=<?php echo $nfo['direction']; ?>
placeholder="<?php echo __('Message content'); ?>"
name="trans[<?php echo $tag; ?>][body]"><?php
echo Format::htmlchars(Format::viewableImages($info['body'][$tag])); echo Format::htmlchars(Format::viewableImages($info['body'][$tag]));
?></textarea> ?></textarea>
</div> </div>
</div> </div>
<?php } ?> <?php } ?>
<div id="msg_info" style="margin-top:7px"><?php <div class="info-banner left-tabs" style="margin-top:7px"><?php
echo $content->getNotes(); ?></div> echo $content->getNotes(); ?></div>
<hr/>
<hr class="clear"/>
<p class="full-width"> <p class="full-width">
<span class="buttons pull-left"> <span class="buttons pull-left">
<input type="reset" value="<?php echo __('Reset'); ?>"> <input type="reset" value="<?php echo __('Reset'); ?>">
...@@ -59,6 +62,6 @@ echo $content->getNotes(); ?></div> ...@@ -59,6 +62,6 @@ echo $content->getNotes(); ?></div>
<input type="submit" value="<?php echo __('Save Changes'); ?>"> <input type="submit" value="<?php echo __('Save Changes'); ?>">
</span> </span>
</p> </p>
</form>
</div> </div>
</form>
<div class="clear"></div> <div class="clear"></div>
...@@ -1949,6 +1949,9 @@ tr.disabled th { ...@@ -1949,6 +1949,9 @@ tr.disabled th {
position: relative; position: relative;
padding: 10px; padding: 10px;
} }
.left-tabs {
margin-left: 48px;
}
.floating-options { .floating-options {
display: inline-block; display: inline-block;
position: absolute; position: absolute;
......
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
.prepend($('<span>').addClass('flag flag-'+info.flag)) .prepend($('<span>').addClass('flag flag-'+info.flag))
.append($('<input type="text" data-lang="'+lang+'">') .append($('<input type="text" data-lang="'+lang+'">')
.attr('dir', info.direction || 'ltr') .attr('dir', info.direction || 'ltr')
.on('change blur keydown', $.proxy(this.showCommit, this)) .on('change keydown', $.proxy(this.showCommit, this))
.val(text) .val(text)
) )
) )
...@@ -145,7 +145,10 @@ ...@@ -145,7 +145,10 @@
commit: function(e) { commit: function(e) {
var changes = {}, self = this; var changes = {}, self = this;
$('input[type=text]', this.$translations).each(function() { $('input[type=text]', this.$translations).each(function() {
changes[$(this).data('lang')] = $(this).val(); var trans = $(this).val();
if (!trans)
$(this).closest('li').slideUp();
changes[$(this).data('lang')] = trans;
}); });
this.$commit.prop('disabled', true); this.$commit.prop('disabled', true);
this.$commit.find('button').empty().text(' Saving') this.$commit.find('button').empty().text(' Saving')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment