-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #565 - consolidates translation code.
- Loading branch information
1 parent
03ebb2b
commit d677bc8
Showing
10 changed files
with
122 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
// Manages the application initialization for most pages. | ||
// This script is called by the homepage, search result | ||
// and search details pages. It is not called by | ||
// the about page, because that page does not have popups to manage. | ||
// the about page. | ||
require([ | ||
'util/translation/google-translate-manager', | ||
'app/popup-manager', | ||
'app/alert-manager' | ||
], | ||
function (pm, alert) { | ||
function (googleTranslate, popups, alert) { | ||
'use strict'; | ||
|
||
// If box-shadow CSS is supported, initialize the popups. | ||
if (Modernizr.boxshadow) | ||
pm.init(); | ||
// If page is not translated, initialize the header popups. | ||
if (!googleTranslate.isTranslated()) | ||
popups.init(); | ||
|
||
alert.init(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Cookie CRUD functions, from http://www.quirksmode.org/js/cookies.html | ||
// ERB needed to retrieve domain name that the cookie is saved under. | ||
define( | ||
function () { | ||
'use strict'; | ||
|
||
// @param name [String] The cookie's name. | ||
// @param value [String] The cookie's value. | ||
// @param useDomain [Boolean] Whether set under subdomains or not. | ||
// @param days [Number] Number of days till the cookie expires. | ||
// Can be negative. | ||
function create(name, value, useDomain, days) { | ||
if (days) { | ||
var date = new Date(); | ||
date.setTime(date.getTime() + (days*24*60*60*1000)); | ||
var expires = '; expires=' + date.toGMTString(); | ||
} | ||
else var expires = ''; | ||
|
||
var setting = name + '=' + value + expires + '; path=/'; | ||
|
||
// Sets the cookie under domain and subdomains (if useDomain parameter is present). | ||
document.cookie = setting; | ||
if (useDomain) | ||
document.cookie = setting + "; domain=.<%= ENV['DOMAIN_NAME'] %>"; | ||
} | ||
|
||
// @param name [String] The cookie's name to read. | ||
// @return [String] The named cookie's value, or null. | ||
function read(name) { | ||
var nameEQ = name + "="; | ||
var ca = document.cookie.split(';'); | ||
for(var i=0;i < ca.length;i++) { | ||
var c = ca[i]; | ||
while (c.charAt(0)==' ') c = c.substring(1,c.length); | ||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); | ||
} | ||
return null; | ||
} | ||
|
||
// @param name [String] The cookie's name to remove. | ||
// @param usedDomain [Boolean] Whether to clear subdomains also. | ||
function erase(name, useDomain) { | ||
create(name, '', !!useDomain, -1); | ||
} | ||
|
||
return { | ||
create:create, | ||
read:read, | ||
erase:erase | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
class AboutController < ApplicationController | ||
include GoogleTranslator | ||
respond_to :html, :json | ||
|
||
def index | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
class HomeController < ApplicationController | ||
include GoogleTranslator | ||
include CurrentLanguage | ||
|
||
def index | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters