Skip to content

Commit 3041dfa

Browse files
committed
Merge pull request #163 from Muskworker/master
some tweaks for broken things in rc1
2 parents af49e0f + 996ed8e commit 3041dfa

File tree

11 files changed

+55
-65
lines changed

11 files changed

+55
-65
lines changed

app/assets/javascripts/application.js.erb

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ activate_autocompletes = function(element){
152152
}
153153
});
154154
});
155-
}
155+
};
156156

157157
Event.observe(window, 'load', function(){
158158
activate_links($$('body')[0]);
@@ -243,15 +243,15 @@ function update_languages(languages) {
243243
$('lexeme_dictionary_ids').enable();
244244
update_add_links();
245245
$$(".translatable").each(function(content){
246-
oldlangs = content.down('.language-content').childElements().invoke('identify').invoke('gsub', /.*_/, '');
246+
oldlangs = content.down('.language-content').childElements().invoke('readAttribute', 'data-language');
247247
langtype = content.readAttribute("data-languages");
248248
langtabs = content.down('.language-list ul');
249249
// go through each language in the languages for the appropriate language class
250250
languages[langtype].each(function(language){
251251
// if an existing div is in the languages, keep it (moving it to the appropriate position); if it's not, flag it as not to be saved (if content) or remove it (if not)
252-
if (oldlangs.include(language.code)) {
252+
if (oldlangs.include(language.underscore_code)) {
253253
// old field and tab
254-
oldfield = content.down('input[id$=_'+language.code+'],textarea[id$=_'+language.code+']');
254+
oldfield = content.down('[data-language='+language.underscore_code+']');
255255
oldtab_index = oldfield.up().childElements().indexOf(oldfield) + 1;
256256
oldtab = content.down('li', oldtab_index);
257257

@@ -266,33 +266,34 @@ function update_languages(languages) {
266266
// if it's in the languages and doesn't already have a field, duplicate, blanken, re-ID, and add it in its place
267267
oldfield = content.down('input,textarea');
268268
oldtab = content.down('li', 1);
269+
oldlang = oldfield.readAttribute('data-language');
269270

270271
newfield = oldfield.up().appendChild(oldfield.clone(true));
271-
newfield.id = oldfield.identify().replace(/(.+_).+$/, "$1"+language.code);
272-
newfield.name = oldfield.name.replace(/(.+_).*?\]$/, "$1"+language.code+"]");
272+
posindex = oldfield.identify().lastIndexOf(oldlang);
273+
newfield.id = oldfield.identify().substring(0, posindex) + language.underscore_code + oldfield.identify().substring(0, posindex + oldlang.length)
274+
// newfield.id = oldfield.identify().replace(/(.+_).+$/, "$1"+language.underscore_code);
275+
posindex = oldfield.name.lastIndexOf(oldlang);
276+
newfield.name = oldfield.name.substring(0, posindex) + language.underscore_code + oldfield.name.substring(0, posindex + oldlang.length)
277+
// newfield.name = oldfield.name.replace(/(.+_).*?\]$/, "$1"+language.underscore_code+"]");
273278
newfield.clear();
274279
newtab = oldtab.up().appendChild(oldtab.clone(true));
275280
newtab.innerHTML = language.tab;
276281
newtab.removeClassName('warning');
277282
newtab.removeClassName('default');
283+
newfield.writeAttribute('data-language', language.underscore_code);
278284
Effect.Appear(newtab, {duration: 0.25});
279285
}
280286
});
281287

282-
dropped_languages = oldlangs.without.apply(oldlangs, languages[langtype].collect(function(lang){return lang.code}));
288+
dropped_languages = oldlangs.without.apply(oldlangs, languages[langtype].collect(function(lang){return lang.underscore_code}));
283289
dropped_languages.each(function(language){
284-
oldfield = content.down('input[id$=_'+language+'],textarea[id$=_'+language+']');
290+
oldfield = content.down('[data-language='+language+']');
285291
oldtab_index = oldfield.up().childElements().indexOf(oldfield) + 1;
286292
oldtab = content.down('li', oldtab_index);
287293

288-
if ($F(oldfield) == "") {
289-
oldfield.remove();
290-
oldtab.remove();
291-
} else {
292-
293294
// if droppable is DEFAULT then add its content to any blank, then remove.
294-
if (oldtab.hasClassName('default')) {
295-
clean_defaults(content, oldfield, oldtab);
295+
if (oldtab.hasClassName('default')) {
296+
clean_defaults(content, oldfield, oldtab);
296297

297298
// newfields = content.select('input,textarea');
298299
// newfields.each(function(newfield) {
@@ -301,15 +302,14 @@ function update_languages(languages) {
301302
// oldfield.remove();
302303
// oldtab.remove();
303304

304-
} else {
305-
oldfield.enable();
306-
oldtab.addClassName('warning');
305+
}
306+
307+
oldfield.enable();
308+
oldtab.addClassName('warning');
307309

308-
oldfield.up().appendChild(oldfield);
309-
oldtab.up().appendChild(oldtab);
310-
Effect.Appear(oldtab, {duration: 0.25});
311-
}
312-
}
310+
oldfield.up().appendChild(oldfield);
311+
oldtab.up().appendChild(oldtab);
312+
Effect.Appear(oldtab, {duration: 0.25});
313313
});
314314

315315
// deselect all tabs
@@ -335,12 +335,13 @@ function update_add_links(){
335335
});
336336
};
337337

338-
// if a language is DEFAULT (old db style, or new lexeme) then add its content to any blank, then remove.
338+
// if a language is DEFAULT (old db style, or new lexeme) then add its content to any blank.
339339
function clean_defaults(content, oldfield, oldtab){
340340
newfields = content.select('input,textarea');
341341
newfields.each(function(newfield) {
342342
if (newfield.getValue() == "") { newfield.setValue($F(oldfield)); }
343343
});
344-
oldfield.remove();
345-
oldtab.remove();
344+
oldfield.setValue("");
345+
//oldfield.remove();
346+
//oldtab.remove();
346347
}

app/assets/stylesheets/1col_layout.css

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
/*
2-
*= require ../yaml/core/base
3-
*= require ../yaml/navigation/nav_shinybuttons
4-
*= require ../yaml/screen/forms
5-
*= require screen/basemod
6-
*= require screen/content
7-
*= require ../yaml/print/print_draft
8-
*= require_self
9-
*/
10-
111
/**
122
* "Yet Another Multicolumn Layout" - (X)HTML/CSS framework
133
* (en) central stylesheet
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
*= require core/base
3+
*= require navigation/nav_shinybuttons
4+
*= require screen/forms
5+
*= require screen/basemod
6+
*= require screen/content
7+
*= require print/print_draft
8+
*= require 1col_layout
9+
*/

app/controllers/dictionaries_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def index
1515
when "langs"
1616
hsh = Dictionary.langs_hash_for(@dictionaries)
1717
hsh = hsh.collect do |categ, langs|
18-
[categ, langs.collect {|lang| { tab: lang.to_s, code: lang.iso_639_code }}]
18+
[categ, langs.collect {|lang| { tab: lang.to_s, code: lang.iso_639_code, underscore_code: lang.iso_639_code.underscore }}]
1919
end
2020

2121
render json: Hash[hsh]

app/helpers/application_helper.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,10 @@ def translatable_tag form, field, attribute, languages = [], html_options = {}
267267

268268
output << content_tag(:div, class: "language-content") do
269269
languages.each do |lang|
270-
Globalize.with_locale(lang.iso_639_code) do
271-
concat(form.send(field, "#{attribute}_#{lang.iso_639_code.underscore}", html_options))
270+
code = lang.iso_639_code
271+
html_options[:data] = (html_options[:data] || {}).merge(language: code.underscore)
272+
Globalize.with_locale(code) do
273+
concat(form.send(field, "#{attribute}_#{code.underscore}", html_options))
272274
end
273275
end
274276
end

app/models/sense.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Sense < ActiveRecord::Base
1111
globalize_accessors :locales => (Language.all.collect(&:iso_639_code) | [I18n.default_locale])
1212

1313
accepts_nested_attributes_for :parses, :notes, :allow_destroy => true, :reject_if => proc { |attributes| attributes.all? {|k,v| v.blank?} }
14-
accepts_nested_attributes_for :glosses, :allow_destroy => true, :reject_if => proc {|attrs| Gloss.new(attrs).invalid? }
14+
accepts_nested_attributes_for :glosses, :allow_destroy => true, :reject_if => proc {|attrs| Gloss.new(attrs.slice(Gloss.new.attribute_names)).invalid? }
1515

1616
HASH_MAP_TO_PARSE = { :interpretations => Interpretation::HASH_MAP_TO_PARSE }
1717

app/views/layouts/1col_layout.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<head>
66
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
77
<title><%= strip_tags page_title %></title>
8-
<%= stylesheet_link_tag '1col_layout' %>
8+
<%= stylesheet_link_tag 'application' %>
99
<!--[if lte IE 7]>
1010
<link href="css/patches/patch_my_layout.css" rel="stylesheet" type="text/css" />
1111
<![endif]-->

config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ class Application < Rails::Application
4242

4343
config.assets.enabled = true
4444
config.assets.version = '1.0'
45-
config.assets.precompile += ['1col_layout.css']
45+
# config.assets.precompile += ['1col_layout.css']
4646
end
4747
end

db/migrate/20141216001422_translate_etymologies.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class TranslateEtymologies < ActiveRecord::Migration
22
def up
33
Etymology.create_translation_table!({
4-
etymon: :string,
4+
# etymon: :string,
55
gloss: :string
66
}, { migrate_data: true })
77
end
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
class TranslateLoci < ActiveRecord::Migration
2-
def up
3-
Locus.create_translation_table!({
4-
example: :text,
5-
example_translation: :text
6-
}, { migrate_data: true })
7-
end
2+
# Pending UI
3+
# def up
4+
# Locus.create_translation_table!({
5+
# example: :text,
6+
# example_translation: :text
7+
# }, { migrate_data: true })
8+
# end
89

9-
def down
10-
Locus.drop_translation_table! migrate_data: true
11-
end
10+
# def down
11+
# Locus.drop_translation_table! migrate_data: true
12+
# end
1213
end

0 commit comments

Comments
 (0)