UNPKG

get-translation

Version:
1 lines 18.6 kB
define(['backbone','jquery','contents/home/HomeView','contents/home/Home','contents/search/SearchView','contents/search/Search','contents/locales/LocalesView','contents/locales/Locales','contents/translations/TranslationsView','contents/translations/Translations','contents/translation/TranslationView','contents/translation/Translation'], function(Backbone,$,HomeView,Home,SearchView,Search,LocalesView,Locales,TranslationsView,Translations,TranslationView,Translation) {var Constructor = Backbone.Router.extend({routes : {':locale/translations' : 'compose :locale/translations',':locale/t/:id/:key' : 'compose :locale/t/:id/:key'},'compose :locale/translations': function() {var _this = this, incorrectRegions = 0, n = 0;app.document.trigger('fetchstart', ':locale/translations');this.should = {};if(typeof app.views.home === 'undefined' || app.views.home.should(':locale/translations') === 'update') {if(typeof app.views.home === 'undefined') {if(!document.querySelector('[data-content="home"]')) {this.should['home'] = 'update';}else {this.should['home'] = 'keep';}}else {this.should['home'] = app.views.home.should(':locale/translations');Backbone.Relational.store.unregister(app.models.home);}app.models.home = new Home;app.views.home = new HomeView(app.models.home);incorrectRegions++;setTimeout(function() {try {app.models.home.fetch({success: function() {_this.content['home'] = app.views.home.toHTML();if(typeof app.views.home.bindModel === 'function') {app.views.home.bindModel();}n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/translations');_this['render :locale/translations']();}}});}catch(err) {if(err.message === 'A "url" property or function must be specified') {_this.content['home'] = app.views.home.toHTML();n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/translations');_this['render :locale/translations']();}}else {throw err;}}}, 0);}else if(app.views.home.should(':locale/translations') === 'remove') {app.views.home.hide();}else {app.views.home.show();}if(typeof app.views.search === 'undefined' || app.views.search.should(':locale/translations') === 'update') {if(typeof app.views.search === 'undefined') {if(!document.querySelector('[data-content="search"]')) {this.should['search'] = 'update';}else {this.should['search'] = 'keep';}}else {this.should['search'] = app.views.search.should(':locale/translations');Backbone.Relational.store.unregister(app.models.search);}app.models.search = new Search;app.views.search = new SearchView(app.models.search);incorrectRegions++;setTimeout(function() {try {app.models.search.fetch({success: function() {_this.content['search'] = app.views.search.toHTML();if(typeof app.views.search.bindModel === 'function') {app.views.search.bindModel();}n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/translations');_this['render :locale/translations']();}}});}catch(err) {if(err.message === 'A "url" property or function must be specified') {_this.content['search'] = app.views.search.toHTML();n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/translations');_this['render :locale/translations']();}}else {throw err;}}}, 0);}else if(app.views.search.should(':locale/translations') === 'remove') {app.views.search.hide();}else {app.views.search.show();}if(typeof app.views.locales === 'undefined' || app.views.locales.should(':locale/translations') === 'update') {if(typeof app.views.locales === 'undefined') {if(!document.querySelector('[data-content="locales"]')) {this.should['locales'] = 'update';}else {this.should['locales'] = 'keep';}}else {this.should['locales'] = app.views.locales.should(':locale/translations');Backbone.Relational.store.unregister(app.models.locales);}app.models.locales = new Locales;app.views.locales = new LocalesView(app.models.locales);incorrectRegions++;setTimeout(function() {try {app.models.locales.fetch({success: function() {_this.content['locales'] = app.views.locales.toHTML();if(typeof app.views.locales.bindModel === 'function') {app.views.locales.bindModel();}n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/translations');_this['render :locale/translations']();}}});}catch(err) {if(err.message === 'A "url" property or function must be specified') {_this.content['locales'] = app.views.locales.toHTML();n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/translations');_this['render :locale/translations']();}}else {throw err;}}}, 0);}else if(app.views.locales.should(':locale/translations') === 'remove') {app.views.locales.hide();}else {app.views.locales.show();}if(typeof app.views.translations === 'undefined' || app.views.translations.should(':locale/translations') === 'update') {if(typeof app.views.translations === 'undefined') {if(!document.querySelector('[data-content="translations"]')) {this.should['translations'] = 'update';}else {this.should['translations'] = 'keep';}}else {this.should['translations'] = app.views.translations.should(':locale/translations');Backbone.Relational.store.unregister(app.models.translations);}app.models.translations = new Translations;app.views.translations = new TranslationsView(app.models.translations);incorrectRegions++;setTimeout(function() {try {app.models.translations.fetch({success: function() {_this.content['body'] = app.views.translations.toHTML();if(typeof app.views.translations.bindModel === 'function') {app.views.translations.bindModel();}n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/translations');_this['render :locale/translations']();}}});}catch(err) {if(err.message === 'A "url" property or function must be specified') {_this.content['body'] = app.views.translations.toHTML();n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/translations');_this['render :locale/translations']();}}else {throw err;}}}, 0);}else if(app.views.translations.should(':locale/translations') === 'remove') {app.views.translations.hide();}else {app.views.translations.show();}for(var view in app.views) {if(view !== 'home' && view !== 'search' && view !== 'locales' && view !== 'translations') {app.views[view].remove();delete app.views[view];if(typeof app.models[view] !== 'undefined') {Backbone.Relational.store.unregister(app.models[view]);delete app.models[view];}}}},'compose :locale/t/:id/:key': function() {var _this = this, incorrectRegions = 0, n = 0;app.document.trigger('fetchstart', ':locale/t/:id/:key');this.should = {};if(typeof app.views.home === 'undefined' || app.views.home.should(':locale/t/:id/:key') === 'update') {if(typeof app.views.home === 'undefined') {if(!document.querySelector('[data-content="home"]')) {this.should['home'] = 'update';}else {this.should['home'] = 'keep';}}else {this.should['home'] = app.views.home.should(':locale/t/:id/:key');Backbone.Relational.store.unregister(app.models.home);}app.models.home = new Home;app.views.home = new HomeView(app.models.home);incorrectRegions++;setTimeout(function() {try {app.models.home.fetch({success: function() {_this.content['home'] = app.views.home.toHTML();if(typeof app.views.home.bindModel === 'function') {app.views.home.bindModel();}n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}});}catch(err) {if(err.message === 'A "url" property or function must be specified') {_this.content['home'] = app.views.home.toHTML();n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}else {throw err;}}}, 0);}else if(app.views.home.should(':locale/t/:id/:key') === 'remove') {app.views.home.hide();}else {app.views.home.show();}if(typeof app.views.search === 'undefined' || app.views.search.should(':locale/t/:id/:key') === 'update') {if(typeof app.views.search === 'undefined') {if(!document.querySelector('[data-content="search"]')) {this.should['search'] = 'update';}else {this.should['search'] = 'keep';}}else {this.should['search'] = app.views.search.should(':locale/t/:id/:key');Backbone.Relational.store.unregister(app.models.search);}app.models.search = new Search;app.views.search = new SearchView(app.models.search);incorrectRegions++;setTimeout(function() {try {app.models.search.fetch({success: function() {_this.content['search'] = app.views.search.toHTML();if(typeof app.views.search.bindModel === 'function') {app.views.search.bindModel();}n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}});}catch(err) {if(err.message === 'A "url" property or function must be specified') {_this.content['search'] = app.views.search.toHTML();n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}else {throw err;}}}, 0);}else if(app.views.search.should(':locale/t/:id/:key') === 'remove') {app.views.search.hide();}else {app.views.search.show();}if(typeof app.views.locales === 'undefined' || app.views.locales.should(':locale/t/:id/:key') === 'update') {if(typeof app.views.locales === 'undefined') {if(!document.querySelector('[data-content="locales"]')) {this.should['locales'] = 'update';}else {this.should['locales'] = 'keep';}}else {this.should['locales'] = app.views.locales.should(':locale/t/:id/:key');Backbone.Relational.store.unregister(app.models.locales);}app.models.locales = new Locales;app.views.locales = new LocalesView(app.models.locales);incorrectRegions++;setTimeout(function() {try {app.models.locales.fetch({success: function() {_this.content['locales'] = app.views.locales.toHTML();if(typeof app.views.locales.bindModel === 'function') {app.views.locales.bindModel();}n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}});}catch(err) {if(err.message === 'A "url" property or function must be specified') {_this.content['locales'] = app.views.locales.toHTML();n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}else {throw err;}}}, 0);}else if(app.views.locales.should(':locale/t/:id/:key') === 'remove') {app.views.locales.hide();}else {app.views.locales.show();}if(typeof app.views.translations === 'undefined' || app.views.translations.should(':locale/t/:id/:key') === 'update') {if(typeof app.views.translations === 'undefined') {if(!document.querySelector('[data-content="translations"]')) {this.should['translations'] = 'update';}else {this.should['translations'] = 'keep';}}else {this.should['translations'] = app.views.translations.should(':locale/t/:id/:key');Backbone.Relational.store.unregister(app.models.translations);}app.models.translations = new Translations;app.views.translations = new TranslationsView(app.models.translations);incorrectRegions++;setTimeout(function() {try {app.models.translations.fetch({success: function() {_this.content['body'] = app.views.translations.toHTML();if(typeof app.views.translations.bindModel === 'function') {app.views.translations.bindModel();}n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}});}catch(err) {if(err.message === 'A "url" property or function must be specified') {_this.content['body'] = app.views.translations.toHTML();n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}else {throw err;}}}, 0);}else if(app.views.translations.should(':locale/t/:id/:key') === 'remove') {app.views.translations.hide();}else {app.views.translations.show();}if(typeof app.views.translation === 'undefined' || app.views.translation.should(':locale/t/:id/:key') === 'update') {if(typeof app.views.translation === 'undefined') {if(!document.querySelector('[data-content="translation"]')) {this.should['translation'] = 'update';}else {this.should['translation'] = 'keep';}}else {this.should['translation'] = app.views.translation.should(':locale/t/:id/:key');Backbone.Relational.store.unregister(app.models.translation);}app.models.translation = new Translation;app.views.translation = new TranslationView(app.models.translation);incorrectRegions++;setTimeout(function() {try {app.models.translation.fetch({success: function() {_this.content['translation'] = app.views.translation.toHTML();if(typeof app.views.translation.bindModel === 'function') {app.views.translation.bindModel();}n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}});}catch(err) {if(err.message === 'A "url" property or function must be specified') {_this.content['translation'] = app.views.translation.toHTML();n++;if(n === incorrectRegions) {app.document.trigger('fetchend', ':locale/t/:id/:key');_this['render :locale/t/:id/:key']();}}else {throw err;}}}, 0);}else if(app.views.translation.should(':locale/t/:id/:key') === 'remove') {app.views.translation.hide();}else {app.views.translation.show();}for(var view in app.views) {if(view !== 'home' && view !== 'search' && view !== 'locales' && view !== 'translations' && view !== 'translation') {app.views[view].remove();delete app.views[view];if(typeof app.models[view] !== 'undefined') {Backbone.Relational.store.unregister(app.models[view]);delete app.models[view];}}}},'render :locale/translations': function() {app.document.trigger('renderstart');if(document.querySelectorAll('[data-layout=app]').length) {app.document.trigger('renderhomestart');try {if(this.should['home'] === 'update') {var $region = document.querySelector('[data-region="home"]');$region.innerHTML = this.content['home'];$region.classList.remove('hidden');}if(app.views.el !== '<div></div>') {app.views.home.setElement('[data-content="home"]');}if(!app.views.home.boundDOM) {app.views.home.bindDOM();app.views.home.boundDOM = true;}}catch(err) {throw err;}app.document.trigger('renderhomeend');app.document.trigger('rendersearchstart');try {if(this.should['search'] === 'update') {var $region = document.querySelector('[data-region="search"]');$region.innerHTML = this.content['search'];$region.classList.remove('hidden');}if(app.views.el !== '<div></div>') {app.views.search.setElement('[data-content="search"]');}if(!app.views.search.boundDOM) {app.views.search.bindDOM();app.views.search.boundDOM = true;}}catch(err) {throw err;}app.document.trigger('rendersearchend');app.document.trigger('renderlocalesstart');try {if(this.should['locales'] === 'update') {var $region = document.querySelector('[data-region="locales"]');$region.innerHTML = this.content['locales'];$region.classList.remove('hidden');}if(app.views.el !== '<div></div>') {app.views.locales.setElement('[data-content="locales"]');}if(!app.views.locales.boundDOM) {app.views.locales.bindDOM();app.views.locales.boundDOM = true;}}catch(err) {throw err;}app.document.trigger('renderlocalesend');app.document.trigger('rendertranslationsstart');try {if(this.should['translations'] === 'update') {var $region = document.querySelector('[data-region="body"]');$region.innerHTML = this.content['body'];$region.classList.remove('hidden');}if(app.views.el !== '<div></div>') {app.views.translations.setElement('[data-content="translations"]');}if(!app.views.translations.boundDOM) {app.views.translations.bindDOM();app.views.translations.boundDOM = true;}}catch(err) {throw err;}app.document.trigger('rendertranslationsend');}else {app.$layout.remove();app.$body.append(app.layoutTmpls.app({home : this.content['home'],search : this.content['search'],locales : this.content['locales'],body : this.content['translations']}));}app.document.trigger('renderend');},'render :locale/t/:id/:key': function() {app.document.trigger('renderstart');if(document.querySelectorAll('[data-layout=app]').length) {app.document.trigger('renderhomestart');try {if(this.should['home'] === 'update') {var $region = document.querySelector('[data-region="home"]');$region.innerHTML = this.content['home'];$region.classList.remove('hidden');}if(app.views.el !== '<div></div>') {app.views.home.setElement('[data-content="home"]');}if(!app.views.home.boundDOM) {app.views.home.bindDOM();app.views.home.boundDOM = true;}}catch(err) {throw err;}app.document.trigger('renderhomeend');app.document.trigger('rendersearchstart');try {if(this.should['search'] === 'update') {var $region = document.querySelector('[data-region="search"]');$region.innerHTML = this.content['search'];$region.classList.remove('hidden');}if(app.views.el !== '<div></div>') {app.views.search.setElement('[data-content="search"]');}if(!app.views.search.boundDOM) {app.views.search.bindDOM();app.views.search.boundDOM = true;}}catch(err) {throw err;}app.document.trigger('rendersearchend');app.document.trigger('renderlocalesstart');try {if(this.should['locales'] === 'update') {var $region = document.querySelector('[data-region="locales"]');$region.innerHTML = this.content['locales'];$region.classList.remove('hidden');}if(app.views.el !== '<div></div>') {app.views.locales.setElement('[data-content="locales"]');}if(!app.views.locales.boundDOM) {app.views.locales.bindDOM();app.views.locales.boundDOM = true;}}catch(err) {throw err;}app.document.trigger('renderlocalesend');app.document.trigger('rendertranslationsstart');try {if(this.should['translations'] === 'update') {var $region = document.querySelector('[data-region="body"]');$region.innerHTML = this.content['body'];$region.classList.remove('hidden');}if(app.views.el !== '<div></div>') {app.views.translations.setElement('[data-content="translations"]');}if(!app.views.translations.boundDOM) {app.views.translations.bindDOM();app.views.translations.boundDOM = true;}}catch(err) {throw err;}app.document.trigger('rendertranslationsend');app.document.trigger('rendertranslationstart');try {if(this.should['translation'] === 'update') {var $region = document.querySelector('[data-region="translation"]');$region.innerHTML = this.content['translation'];$region.classList.remove('hidden');}if(app.views.el !== '<div></div>') {app.views.translation.setElement('[data-content="translation"]');}if(!app.views.translation.boundDOM) {app.views.translation.bindDOM();app.views.translation.boundDOM = true;}}catch(err) {throw err;}app.document.trigger('rendertranslationend');}else {app.$layout.remove();app.$body.append(app.layoutTmpls.app({home : this.content['home'],search : this.content['search'],locales : this.content['locales'],body : this.content['translations'],translation : this.content['translation']}));}app.document.trigger('renderend');},});Constructor.prototype.content = {};return Constructor;});