lolita-i18n 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -0
- data/.rspec +1 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +165 -0
- data/LICENSE.txt +20 -0
- data/README.md +27 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/app/assets/images/lolita/i18n/google_translate_icon.png +0 -0
- data/app/assets/javascripts/lolita/i18n/application.js +2 -0
- data/app/assets/javascripts/lolita/i18n/i18n.js.coffee +135 -0
- data/app/assets/javascripts/lolita/i18n/spin.min.js +2 -0
- data/app/assets/stylesheets/lolita/i18n/application.scss +102 -0
- data/app/controllers/lolita/i18n_controller.rb +39 -0
- data/app/helpers/lolita/i18n_helper.rb +25 -0
- data/app/views/lolita/i18n/index.html.haml +34 -0
- data/config/locales/en.yml +5 -0
- data/config/locales/lv.yml +4 -0
- data/config/routes.rb +11 -0
- data/lib/lolita-i18n.rb +81 -0
- data/lib/lolita-i18n/backend.rb +69 -0
- data/lib/lolita-i18n/google_translate.rb +76 -0
- data/lib/lolita-i18n/module.rb +1 -0
- data/lib/lolita-i18n/rails.rb +6 -0
- data/lolita-i18n.gemspec +110 -0
- data/spec/controllers/lolita/i18n_controller_spec.rb +39 -0
- data/spec/lolita-i18n/backend_spec.rb +21 -0
- data/spec/lolita-i18n/google_translate_spec.rb +31 -0
- data/spec/rails_app/app/controllers/application_controller.rb +3 -0
- data/spec/rails_app/config/application.rb +18 -0
- data/spec/rails_app/config/enviroment.rb +5 -0
- data/spec/rails_app/config/initializers/lolita_i18n.rb +15 -0
- data/spec/rails_app/config/locales/en.yml +9 -0
- data/spec/rails_app/config/locales/lv.yml +2 -0
- data/spec/rails_app/config/routes.rb +3 -0
- data/spec/spec_helper.rb +33 -0
- metadata +197 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "lolita", '~>3.2.0.rc.3'
|
4
|
+
gem "hiredis", "~> 0.3.1"
|
5
|
+
gem "redis", "~> 2.2.2", :require => ["redis/connection/hiredis", "redis"]
|
6
|
+
gem "yajl-ruby", "~> 1.0.0"
|
7
|
+
gem "easy_translate", "~> 0.2.1"
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem "shoulda", ">= 0"
|
11
|
+
gem "bundler", "~> 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.5.2"
|
13
|
+
gem "rcov", ">= 0"
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem "rspec","~>2.6.0"
|
18
|
+
gem "rspec-rails", "~>2.6.0"
|
19
|
+
gem "webmock", "~> 1.7.6"
|
20
|
+
# gem "mongo", "~> 1.3.0"
|
21
|
+
# gem "mongoid", "~> 2.0.0"
|
22
|
+
# gem "bson_ext", "~> 1.4.0"
|
23
|
+
gem 'ruby-debug19', :require => 'ruby-debug'
|
24
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.1.0)
|
6
|
+
actionpack (= 3.1.0)
|
7
|
+
mail (~> 2.3.0)
|
8
|
+
actionpack (3.1.0)
|
9
|
+
activemodel (= 3.1.0)
|
10
|
+
activesupport (= 3.1.0)
|
11
|
+
builder (~> 3.0.0)
|
12
|
+
erubis (~> 2.7.0)
|
13
|
+
i18n (~> 0.6)
|
14
|
+
rack (~> 1.3.2)
|
15
|
+
rack-cache (~> 1.0.3)
|
16
|
+
rack-mount (~> 0.8.2)
|
17
|
+
rack-test (~> 0.6.1)
|
18
|
+
sprockets (~> 2.0.0)
|
19
|
+
activemodel (3.1.0)
|
20
|
+
activesupport (= 3.1.0)
|
21
|
+
bcrypt-ruby (~> 3.0.0)
|
22
|
+
builder (~> 3.0.0)
|
23
|
+
i18n (~> 0.6)
|
24
|
+
activerecord (3.1.0)
|
25
|
+
activemodel (= 3.1.0)
|
26
|
+
activesupport (= 3.1.0)
|
27
|
+
arel (~> 2.2.1)
|
28
|
+
tzinfo (~> 0.3.29)
|
29
|
+
activeresource (3.1.0)
|
30
|
+
activemodel (= 3.1.0)
|
31
|
+
activesupport (= 3.1.0)
|
32
|
+
activesupport (3.1.0)
|
33
|
+
multi_json (~> 1.0)
|
34
|
+
addressable (2.2.6)
|
35
|
+
archive-tar-minitar (0.5.2)
|
36
|
+
arel (2.2.1)
|
37
|
+
bcrypt-ruby (3.0.1)
|
38
|
+
builder (3.0.0)
|
39
|
+
columnize (0.3.4)
|
40
|
+
crack (0.3.1)
|
41
|
+
diff-lcs (1.1.3)
|
42
|
+
digestion (1.2.1)
|
43
|
+
actionpack (~> 3.1.0)
|
44
|
+
easy_translate (0.2.1)
|
45
|
+
json
|
46
|
+
erubis (2.7.0)
|
47
|
+
git (1.2.5)
|
48
|
+
haml (3.1.3)
|
49
|
+
hike (1.2.1)
|
50
|
+
hiredis (0.3.2)
|
51
|
+
i18n (0.6.0)
|
52
|
+
jeweler (1.5.2)
|
53
|
+
bundler (~> 1.0.0)
|
54
|
+
git (>= 1.2.5)
|
55
|
+
rake
|
56
|
+
jquery-rails (1.0.14)
|
57
|
+
railties (~> 3.0)
|
58
|
+
thor (~> 0.14)
|
59
|
+
json (1.6.1)
|
60
|
+
kaminari (0.12.4)
|
61
|
+
rails (>= 3.0.0)
|
62
|
+
linecache19 (0.5.12)
|
63
|
+
ruby_core_source (>= 0.1.4)
|
64
|
+
lolita (3.2.0.rc.3)
|
65
|
+
abstract
|
66
|
+
builder (~> 3.0)
|
67
|
+
haml (~> 3.1.2)
|
68
|
+
jquery-rails
|
69
|
+
kaminari (~> 0.12.4)
|
70
|
+
rails (~> 3.1.0)
|
71
|
+
tinymce-rails
|
72
|
+
mail (2.3.0)
|
73
|
+
i18n (>= 0.4.0)
|
74
|
+
mime-types (~> 1.16)
|
75
|
+
treetop (~> 1.4.8)
|
76
|
+
mime-types (1.16)
|
77
|
+
multi_json (1.0.3)
|
78
|
+
polyglot (0.3.2)
|
79
|
+
rack (1.3.3)
|
80
|
+
rack-cache (1.0.3)
|
81
|
+
rack (>= 0.4)
|
82
|
+
rack-mount (0.8.3)
|
83
|
+
rack (>= 1.0.0)
|
84
|
+
rack-ssl (1.3.2)
|
85
|
+
rack
|
86
|
+
rack-test (0.6.1)
|
87
|
+
rack (>= 1.0)
|
88
|
+
rails (3.1.0)
|
89
|
+
actionmailer (= 3.1.0)
|
90
|
+
actionpack (= 3.1.0)
|
91
|
+
activerecord (= 3.1.0)
|
92
|
+
activeresource (= 3.1.0)
|
93
|
+
activesupport (= 3.1.0)
|
94
|
+
bundler (~> 1.0)
|
95
|
+
railties (= 3.1.0)
|
96
|
+
railties (3.1.0)
|
97
|
+
actionpack (= 3.1.0)
|
98
|
+
activesupport (= 3.1.0)
|
99
|
+
rack-ssl (~> 1.3.2)
|
100
|
+
rake (>= 0.8.7)
|
101
|
+
rdoc (~> 3.4)
|
102
|
+
thor (~> 0.14.6)
|
103
|
+
rake (0.9.2)
|
104
|
+
rcov (0.9.10)
|
105
|
+
rdoc (3.9.4)
|
106
|
+
redis (2.2.2)
|
107
|
+
rspec (2.6.0)
|
108
|
+
rspec-core (~> 2.6.0)
|
109
|
+
rspec-expectations (~> 2.6.0)
|
110
|
+
rspec-mocks (~> 2.6.0)
|
111
|
+
rspec-core (2.6.4)
|
112
|
+
rspec-expectations (2.6.0)
|
113
|
+
diff-lcs (~> 1.1.2)
|
114
|
+
rspec-mocks (2.6.0)
|
115
|
+
rspec-rails (2.6.1)
|
116
|
+
actionpack (~> 3.0)
|
117
|
+
activesupport (~> 3.0)
|
118
|
+
railties (~> 3.0)
|
119
|
+
rspec (~> 2.6.0)
|
120
|
+
ruby-debug-base19 (0.11.25)
|
121
|
+
columnize (>= 0.3.1)
|
122
|
+
linecache19 (>= 0.5.11)
|
123
|
+
ruby_core_source (>= 0.1.4)
|
124
|
+
ruby-debug19 (0.11.6)
|
125
|
+
columnize (>= 0.3.1)
|
126
|
+
linecache19 (>= 0.5.11)
|
127
|
+
ruby-debug-base19 (>= 0.11.19)
|
128
|
+
ruby_core_source (0.1.5)
|
129
|
+
archive-tar-minitar (>= 0.5.2)
|
130
|
+
shoulda (2.11.3)
|
131
|
+
sprockets (2.0.0)
|
132
|
+
hike (~> 1.2)
|
133
|
+
rack (~> 1.0)
|
134
|
+
tilt (!= 1.3.0, ~> 1.1)
|
135
|
+
thor (0.14.6)
|
136
|
+
tilt (1.3.3)
|
137
|
+
tinymce-rails (3.4.5)
|
138
|
+
digestion (~> 1.0)
|
139
|
+
railties (~> 3.1.0)
|
140
|
+
treetop (1.4.10)
|
141
|
+
polyglot
|
142
|
+
polyglot (>= 0.3.1)
|
143
|
+
tzinfo (0.3.29)
|
144
|
+
webmock (1.7.6)
|
145
|
+
addressable (> 2.2.5, ~> 2.2)
|
146
|
+
crack (>= 0.1.7)
|
147
|
+
yajl-ruby (1.0.0)
|
148
|
+
|
149
|
+
PLATFORMS
|
150
|
+
ruby
|
151
|
+
|
152
|
+
DEPENDENCIES
|
153
|
+
bundler (~> 1.0.0)
|
154
|
+
easy_translate (~> 0.2.1)
|
155
|
+
hiredis (~> 0.3.1)
|
156
|
+
jeweler (~> 1.5.2)
|
157
|
+
lolita (~> 3.2.0.rc.3)
|
158
|
+
rcov
|
159
|
+
redis (~> 2.2.2)
|
160
|
+
rspec (~> 2.6.0)
|
161
|
+
rspec-rails (~> 2.6.0)
|
162
|
+
ruby-debug19
|
163
|
+
shoulda
|
164
|
+
webmock (~> 1.7.6)
|
165
|
+
yajl-ruby (~> 1.0.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 ITHouse (Latvia) and Arturs Meisters
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# About
|
2
|
+
|
3
|
+
Lolita I18n is Lolita[https://github.com/ithouse/lolita] plugin, that enables .yml file translation from WEB interface.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
* setup rails 3.1 project with ["Lolita"](https://github.com/ithouse/lolita)
|
8
|
+
* setup [Redis DB](http://redis.io) on your server
|
9
|
+
* add `gem 'lolita-i18n'` into Gemfile
|
10
|
+
* add `I18n.backend = Lolita::I18n.load Redis.new(:db => REDIS_DB)` into your `config/initializers/lolita.rb`
|
11
|
+
* add `REDIS_DB = 10` in your production/staging environment file.
|
12
|
+
* open `/lolita/i18n` and start translating
|
13
|
+
|
14
|
+
## Contributing to lolita-i18n
|
15
|
+
|
16
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
17
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
18
|
+
* Fork the project
|
19
|
+
* Start a feature/bugfix branch
|
20
|
+
* Commit and push until you are happy with your contribution
|
21
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
22
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
23
|
+
|
24
|
+
== Copyright
|
25
|
+
|
26
|
+
Copyright (c) 2011 ITHouse (Latvia). See LICENSE.txt for
|
27
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "lolita-i18n"
|
16
|
+
gem.homepage = "http://github.com/ithouse/lolita-i18n"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Lolita plugin, that enables .yml management}
|
19
|
+
gem.description = %Q{Lolita plugin, that enables .yml files management from administrative interface. Also faster access to translations, that DB store}
|
20
|
+
gem.email = "support@ithouse.lv"
|
21
|
+
gem.authors = ["ITHouse (Latvia)","Arturs Meisters", "Gatis Tomsons"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :test
|
37
|
+
|
38
|
+
require 'rdoc/task'
|
39
|
+
RDoc::Task.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "lolita-i18n #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.3
|
Binary file
|
@@ -0,0 +1,135 @@
|
|
1
|
+
class LolitaI18nCell
|
2
|
+
|
3
|
+
constructor: (@td) ->
|
4
|
+
@p = @td.find('p:first')
|
5
|
+
|
6
|
+
edit: ->
|
7
|
+
if @td.find('input').size() == 0
|
8
|
+
@key = @td.attr('data-key')
|
9
|
+
@locale = @td.attr('data-locale')
|
10
|
+
input = $('<textarea name="'+@key+'" />').html(@fix_quotes(@p.text().trim()))
|
11
|
+
input.css('width',@p.width()+'px').css('height', @p.height()+'px')
|
12
|
+
@p.html("")
|
13
|
+
@p.hide()
|
14
|
+
@td.append(input)
|
15
|
+
input.focus()
|
16
|
+
that = this
|
17
|
+
|
18
|
+
input.blur ->
|
19
|
+
that.value = input.val().trim()
|
20
|
+
input.remove()
|
21
|
+
that.add_spinner()
|
22
|
+
that.save()
|
23
|
+
|
24
|
+
input.keyup (e) ->
|
25
|
+
if e.keyCode == 27
|
26
|
+
input.trigger('blur')
|
27
|
+
|
28
|
+
save: ->
|
29
|
+
that = this
|
30
|
+
$.ajax
|
31
|
+
type: 'PUT'
|
32
|
+
url: '/lolita/i18n/' + @locale + '.' + that.key
|
33
|
+
data: {translation: that.value}
|
34
|
+
dataType: 'json'
|
35
|
+
success: (data) ->
|
36
|
+
if data.error
|
37
|
+
alert "Error saving translation " + that.key
|
38
|
+
that.remove_spinner()
|
39
|
+
|
40
|
+
add_spinner: ->
|
41
|
+
opts =
|
42
|
+
lines: 10
|
43
|
+
length: 3
|
44
|
+
width: 2
|
45
|
+
radius: 5,
|
46
|
+
color: '#000'
|
47
|
+
speed: 1
|
48
|
+
trail: 20
|
49
|
+
shadow: false
|
50
|
+
|
51
|
+
@spinner = Spinner(opts).spin()
|
52
|
+
@td.prepend(@spinner.el)
|
53
|
+
$(@spinner.el).css('top',($(@spinner.el).parent().height() / 2)+ 'px').css('left','5px').css('clear','both')
|
54
|
+
|
55
|
+
remove_spinner: ->
|
56
|
+
@spinner.stop()
|
57
|
+
@p.text(@value)
|
58
|
+
@p.show()
|
59
|
+
|
60
|
+
fix_quotes: (value) ->
|
61
|
+
value.replace(/\'/g, "'").replace(/\"/g, """)
|
62
|
+
|
63
|
+
class LolitaTranslate
|
64
|
+
|
65
|
+
constructor: (@button)->
|
66
|
+
@url = @button.attr('data-url')
|
67
|
+
@locale = @button.attr('data-locale')
|
68
|
+
@add_spinner()
|
69
|
+
@translate()
|
70
|
+
|
71
|
+
translate: ->
|
72
|
+
that = this
|
73
|
+
|
74
|
+
$.ajax
|
75
|
+
type: 'PUT'
|
76
|
+
url: @url
|
77
|
+
data: {active_locale: @locale}
|
78
|
+
dataType: 'json'
|
79
|
+
success: (data) ->
|
80
|
+
if data.errors.length > 0
|
81
|
+
alert("Errors\n\n" + data.errors.join("\n"))
|
82
|
+
that.remove_spinner()
|
83
|
+
if data.translated > 0
|
84
|
+
window.location.reload()
|
85
|
+
else
|
86
|
+
that.remove_spinner()
|
87
|
+
error: (request,error) ->
|
88
|
+
alert "Error 500"
|
89
|
+
that.remove_spinner()
|
90
|
+
|
91
|
+
add_spinner: ->
|
92
|
+
opts =
|
93
|
+
lines: 10
|
94
|
+
length: 3
|
95
|
+
width: 2
|
96
|
+
radius: 5
|
97
|
+
color: '#000'
|
98
|
+
speed: 1
|
99
|
+
trail: 5
|
100
|
+
shadow: false
|
101
|
+
|
102
|
+
@spinner = Spinner(opts).spin()
|
103
|
+
@button.append(@spinner.el)
|
104
|
+
@button.addClass('loading')
|
105
|
+
@button.attr('disabled',true)
|
106
|
+
$(@spinner.el).css('position', 'absolute').css('top','17px').css('left','16px')
|
107
|
+
|
108
|
+
remove_spinner: ->
|
109
|
+
@spinner.stop()
|
110
|
+
@button.removeClass('loading')
|
111
|
+
@button.attr('disabled',false)
|
112
|
+
|
113
|
+
params = (name) ->
|
114
|
+
decodeURI((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[1,null])[1])
|
115
|
+
|
116
|
+
$ ->
|
117
|
+
$('.list td p').click ->
|
118
|
+
cell = new LolitaI18nCell $(this).parent()
|
119
|
+
cell.edit()
|
120
|
+
$('.list td span.hint').click ->
|
121
|
+
cell = new LolitaI18nCell $(this).parent()
|
122
|
+
cell.edit()
|
123
|
+
$('#active_locale').change ->
|
124
|
+
show_untranslated = if params('show_untranslated') == "null" then "" else "&show_untranslated=true"
|
125
|
+
window.location.href = "?active_locale=" + $(this).val() + show_untranslated
|
126
|
+
$('button.translate:first').click ->
|
127
|
+
if confirm('Are you shure?')
|
128
|
+
new LolitaTranslate $(this)
|
129
|
+
$('#show_untranslated').change ->
|
130
|
+
active_locale = if params('active_locale') == "null" then "" else "active_locale=" + params('active_locale')
|
131
|
+
if $(this).attr('checked')
|
132
|
+
window.location.href = "?show_untranslated=true&" + active_locale
|
133
|
+
else
|
134
|
+
window.location.href = "?" + active_locale
|
135
|
+
|
@@ -0,0 +1,2 @@
|
|
1
|
+
//fgnass.github.com/spin.js#v1.2
|
2
|
+
(function(a,b,c){function n(a){var b={x:a.offsetLeft,y:a.offsetTop};while(a=a.offsetParent)b.x+=a.offsetLeft,b.y+=a.offsetTop;return b}function m(a,b){for(var d in b)a[d]===c&&(a[d]=b[d]);return a}function l(a,b){for(var c in b)a.style[k(a,c)||c]=b[c];return a}function k(a,b){var e=a.style,f,g;if(e[b]!==c)return b;b=b.charAt(0).toUpperCase()+b.slice(1);for(g=0;g<d.length;g++){f=d[g]+b;if(e[f]!==c)return f}}function j(a,b,c,d){var g=["opacity",b,~~(a*100),c,d].join("-"),h=.01+c/d*100,j=Math.max(1-(1-a)/b*(100-h),a),k=f.substring(0,f.indexOf("Animation")).toLowerCase(),l=k&&"-"+k+"-"||"";e[g]||(i.insertRule("@"+l+"keyframes "+g+"{"+"0%{opacity:"+j+"}"+h+"%{opacity:"+a+"}"+(h+.01)+"%{opacity:1}"+(h+b)%100+"%{opacity:"+a+"}"+"100%{opacity:"+j+"}"+"}",0),e[g]=1);return g}function h(a,b,c){c&&!c.parentNode&&h(a,c),a.insertBefore(b,c||null);return a}function g(a,c){var d=b.createElement(a||"div"),e;for(e in c)d[e]=c[e];return d}var d=["webkit","Moz","ms","O"],e={},f;h(b.getElementsByTagName("head")[0],g("style"));var i=b.styleSheets[b.styleSheets.length-1],o=function q(a){if(!this.spin)return new q(a);this.opts=m(a||{},{lines:12,length:7,width:5,radius:10,color:"#000",speed:1,trail:100,opacity:.25,fps:20})},p=o.prototype={spin:function(a){this.stop();var b=this,c=b.el=l(g(),{position:"relative"}),d,e;a&&(e=n(h(a,c,a.firstChild)),d=n(c),l(c,{left:(a.offsetWidth>>1)-d.x+e.x+"px",top:(a.offsetHeight>>1)-d.y+e.y+"px"})),c.setAttribute("aria-role","progressbar"),b.lines(c,b.opts);if(!f){var i=b.opts,j=0,k=i.fps,m=k/i.speed,o=(1-i.opacity)/(m*i.trail/100),p=m/i.lines;(function q(){j++;for(var a=i.lines;a;a--){var d=Math.max(1-(j+a*p)%m*o,i.opacity);b.opacity(c,i.lines-a,d,i)}b.timeout=b.el&&setTimeout(q,~~(1e3/k))})()}return b},stop:function(){var a=this.el;a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=c);return this}};p.lines=function(a,b){function e(a,d){return l(g(),{position:"absolute",width:b.length+b.width+"px",height:b.width+"px",background:a,boxShadow:d,transformOrigin:"left",transform:"rotate("+~~(360/b.lines*c)+"deg) translate("+b.radius+"px"+",0)",borderRadius:(b.width>>1)+"px"})}var c=0,d;for(;c<b.lines;c++)d=l(g(),{position:"absolute",top:1+~(b.width/2)+"px",transform:"translate3d(0,0,0)",opacity:b.opacity,animation:f&&j(b.opacity,b.trail,c,b.lines)+" "+1/b.speed+"s linear infinite"}),b.shadow&&h(d,l(e("#000","0 0 4px #000"),{top:"2px"})),h(a,h(d,e(b.color,"0 0 1px rgba(0,0,0,.1)")));return a},p.opacity=function(a,b,c){a.childNodes[b].style.opacity=c},function(){var a=l(g("group"),{behavior:"url(#default#VML)"}),b;if(!k(a,"transform")&&a.adj){for(b=4;b--;)i.addRule(["group","roundrect","fill","stroke"][b],"behavior:url(#default#VML)");p.lines=function(a,b){function k(a,d,i){h(f,h(l(e(),{rotation:360/b.lines*a+"deg",left:~~d}),h(l(g("roundrect",{arcsize:1}),{width:c,height:b.width,left:b.radius,top:-b.width>>1,filter:i}),g("fill",{color:b.color,opacity:b.opacity}),g("stroke",{opacity:0}))))}function e(){return l(g("group",{coordsize:d+" "+d,coordorigin:-c+" "+ -c}),{width:d,height:d})}var c=b.length+b.width,d=2*c,f=e(),i=~(b.length+b.radius+b.width)+"px",j;if(b.shadow)for(j=1;j<=b.lines;j++)k(j,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(j=1;j<=b.lines;j++)k(j);return h(l(a,{margin:i+" 0 0 "+i,zoom:1}),f)},p.opacity=function(a,b,c,d){d=d.shadow&&d.lines||0,a.firstChild.childNodes[b+d].firstChild.firstChild.opacity=c}}else f=k(a,"animation")}(),a.Spinner=o})(window,document)
|