my( $self, $c ) = @_;
my $tradition = delete $c->stash->{'tradition'};
my $collation = $tradition->collation;
-
+
+ # Stash text direction to use in JS.
+ $c->stash->{'direction'} = $collation->direction;
+
# Stash the relationship definitions
$c->stash->{'relationship_scopes'} =
to_json( find_type_constraint( 'RelationshipScope' )->values );
my $name = $c->request->param('name') || 'Uploaded tradition';
my $lang = $c->request->param( 'language' ) || 'Default';
my $public = $c->request->param( 'public' ) ? 1 : undef;
+ my $direction = $c->request->param('direction') || 'LR';
+
my( $ext ) = $upload->filename =~ /\.(\w+)$/;
my %newopts = (
'name' => $name,
'language' => $lang,
'public' => $public,
- 'file' => $upload->tempname
+ 'file' => $upload->tempname,
+ 'direction' => $direction,
);
my $tradition;
$changed = 1 if $ispublic;
}
+ # Handle text direction
+ my $tdval = delete $params->{direction} || 'LR';
+
+ unless( $tradition->collation->direction
+ && $tradition->collation->direction eq $tdval ) {
+ try {
+ $tradition->collation->change_direction( $tdval );
+ $changed = 1;
+ } catch {
+ return _json_error( $c, 500, "Error setting direction to $tdval: $@" );
+ }
+ }
+
+
# Handle ownership change
if( exists $params->{'owner'} ) {
# Only admins can update user / owner
my $textinfo = {
textid => $textid,
name => $tradition->name,
+ direction => $tradition->collation->direction || 'LR',
public => $tradition->public || 0,
owner => $tradition->user ? $tradition->user->email : undef,
witnesses => [ map { $_->sigil } $tradition->witnesses ],
$("#edit_textinfo_status").empty();
// Populate the form fields with the current values
// edit_(name, language, public, owner)
- $.each([ 'name', 'language', 'owner' ], function( idx, k ) {
+ $.each([ 'name', 'language', 'owner', 'direction' ], function( idx, k ) {
var fname = '#edit_' + k;
// Special case: language Default is basically language null
if( k == 'language' && selectedTextInfo[k] == 'Default' ) {
var start_element_height = 0;
var reltypes = {};
var readingdata = {};
+var text_direction = 'LR';
jQuery.removeFromArray = function(value, arr) {
return jQuery.grep(arr, function(elem, index) {
//initialize marquee
marquee = new Marquee();
-
+
+ if (text_direction == 'RL') {
+ scrollToEnd();
+ }
}
function add_relations( callback_fn ) {
return false;
}
+function scrollToEnd() {
+ var stateTf = svg_root_element.getCTM().inverse();
+
+ var vbdim = svg_root.viewBox.baseVal;
+ var width = Math.floor(svg_root_element.getBoundingClientRect().width) - vbdim.width;
+
+ var p = svg_root.createSVGPoint();
+ p.x = width;
+ p.y = 0;
+ p = p.matrixTransform(stateTf);
+
+ var matrix = stateTf.inverse().translate(-p.x, -100);
+ var s = "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
+ svg_root_element.setAttribute("transform", s);
+}
$(document).ready(function () {
});
}
-function loadSVG(svgData) {
+function loadSVG(svgData, direction) {
+ text_direction = direction;
+
var svgElement = $('#svgenlargement');
$(svgElement).svg('destroy');
<input id="edit_language" type="text" size="12" name="language"/>
<label for="edit_public">Publicly viewable: </label>
<input id="edit_public" type="checkbox" name="public"/><br/>
+ <label for="edit_direction">Text direction: </label>
+ <select id="edit_direction" name="direction">
+ <option value="LR" selected>Left-to-right</option>
+ <option value="RL">Right-to-left</option>
+ <option value="BI">Bidirectional</option>
+ </select><br/>
[% IF c.user_exists -%]
[% IF c.user.get_object.is_admin -%]
<label for="edit_owner">Tradition owner: </label>
<input id="new_name" type="text" name="name" size="40"/><br/>
<label for="new_lang">Primary language of the text: </label>
<input id="new_lang" type="text" name="language" size="20"/><br/>
+
+ <label for="direction">Text direction:</label>
+
+ <select name="direction" id="direction">
+ <option value="LR" selected>Left to Right</option>
+ <option value="RL">Right to Left</option>
+ <option value="BI">Bi-directional</option>
+ </select><Br/>
+
<label for="new_public">Allow public display: </label>
<input id="new_public" name="public" type="checkbox"/><br/>
</form>
[% END -%]
$(document).ready(function () {
- loadSVG('[% svg_string %]');
+ loadSVG('[% svg_string %]', '[% direction %]');
});
</script>
[% END %]