bhf 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/bhf/application_controller.rb +50 -29
- data/app/controllers/bhf/entries_controller.rb +7 -7
- data/app/controllers/bhf/pages_controller.rb +19 -15
- data/app/helpers/bhf/entries_helper.rb +1 -1
- data/app/helpers/bhf/pages_helper.rb +4 -4
- data/app/views/bhf/_footer.haml +11 -1
- data/app/views/bhf/application/index.haml +1 -1
- data/app/views/bhf/entries/_form.haml +4 -2
- data/app/views/bhf/entries/form/belongs_to/_account_scope.haml +2 -0
- data/app/views/bhf/entries/form/belongs_to/_radio.haml +2 -1
- data/app/views/bhf/entries/form/belongs_to/_select.haml +2 -1
- data/app/views/bhf/entries/form/belongs_to/_static.haml +1 -1
- data/app/views/bhf/entries/form/column/_password.haml +2 -0
- data/app/views/bhf/entries/form/column/_static.haml +2 -2
- data/app/views/bhf/entries/form/has_and_belongs_to_many/_account_scope.haml +2 -0
- data/app/views/bhf/entries/form/has_and_belongs_to_many/_check_box.haml +2 -1
- data/app/views/bhf/entries/form/has_and_belongs_to_many/_static.haml +1 -1
- data/app/views/bhf/entries/form/has_many/_static.haml +1 -1
- data/app/views/bhf/entries/form/has_one/_account_scope.haml +3 -0
- data/app/views/bhf/entries/form/has_one/_static.haml +1 -1
- data/app/views/bhf/pages/_platform.haml +10 -10
- data/app/views/layouts/bhf/{default.haml → application.haml} +8 -6
- data/config/locales/en.yml +1 -0
- data/lib/bhf/active_record.rb +30 -9
- data/lib/bhf/data.rb +27 -10
- data/lib/bhf/pagination.rb +10 -11
- data/lib/bhf/platform.rb +62 -41
- data/lib/bhf/settings.rb +8 -9
- data/lib/bhf.rb +2 -1
- data/lib/engine.rb +3 -1
- data/lib/rails/generators/bhf/templates/initializer.rb +4 -3
- data/public/javascripts/bhf.js +1 -1
- data/public/stylesheets/bhf.css +1 -1
- metadata +24 -14
data/lib/bhf/pagination.rb
CHANGED
@@ -6,7 +6,7 @@ module Bhf
|
|
6
6
|
attr_reader :offset_per_page, :offset_to_add
|
7
7
|
|
8
8
|
def initialize(offset_per_page = 10, offset_to_add = 5)
|
9
|
-
@offset_per_page = offset_per_page
|
9
|
+
@offset_per_page = offset_per_page || 10
|
10
10
|
@offset_to_add = offset_to_add
|
11
11
|
end
|
12
12
|
|
@@ -31,10 +31,10 @@ module Bhf
|
|
31
31
|
|
32
32
|
def info(platform, options = {})
|
33
33
|
collection = platform.paginated_objects
|
34
|
-
|
34
|
+
|
35
35
|
entry_name = options[:entry_name] ||
|
36
36
|
(collection.empty?? I18n.t('bhf.pagination.entry') : collection.first.class.model_name.human)
|
37
|
-
|
37
|
+
|
38
38
|
info = if collection.total_pages < 2
|
39
39
|
case collection.size
|
40
40
|
when 0
|
@@ -52,7 +52,7 @@ module Bhf
|
|
52
52
|
:offset_end => collection.offset + collection.length
|
53
53
|
})
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
info.html_safe
|
57
57
|
end
|
58
58
|
|
@@ -69,7 +69,7 @@ module Bhf
|
|
69
69
|
platform_params.delete(:page)
|
70
70
|
platform_params[:per_page] = load_offset
|
71
71
|
|
72
|
-
direction =
|
72
|
+
direction = plus ? 'more' : 'less'
|
73
73
|
template.link_to(
|
74
74
|
I18n.t("bhf.pagination.load_#{direction}"),
|
75
75
|
template.bhf_page_path(
|
@@ -78,20 +78,20 @@ module Bhf
|
|
78
78
|
), attributes.merge(:class => "load_#{direction}")
|
79
79
|
)
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def load_less(platform, attributes = {})
|
83
83
|
load_more(platform, attributes, false)
|
84
84
|
end
|
85
85
|
|
86
86
|
|
87
|
-
class LinkRenderer < WillPaginate::LinkRenderer
|
88
|
-
|
87
|
+
class LinkRenderer < WillPaginate::ViewHelpers::LinkRenderer
|
88
|
+
|
89
89
|
def initialize(bhf_pagination, platform)
|
90
90
|
@b_p = bhf_pagination
|
91
91
|
@platform = platform
|
92
92
|
end
|
93
93
|
|
94
|
-
def
|
94
|
+
def link(text, page, attributes = {})
|
95
95
|
platform_params = @b_p.template.params[@platform.name] || {}
|
96
96
|
platform_params[:page] = page
|
97
97
|
|
@@ -105,7 +105,6 @@ module Bhf
|
|
105
105
|
end
|
106
106
|
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
end
|
110
|
-
|
111
110
|
end
|
data/lib/bhf/platform.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Bhf
|
2
2
|
class Platform
|
3
3
|
|
4
|
-
attr_accessor :paginated_objects
|
4
|
+
attr_accessor :paginated_objects, :pagination
|
5
5
|
attr_reader :name, :title, :page_name
|
6
6
|
|
7
|
-
def initialize(options, page_name)
|
7
|
+
def initialize(options, page_name, user = nil)
|
8
8
|
@paginated_objects = []
|
9
9
|
|
10
10
|
if options.is_a?(String)
|
@@ -14,7 +14,7 @@ module Bhf
|
|
14
14
|
@data = options.values[0] || {}
|
15
15
|
@collection = get_collection
|
16
16
|
|
17
|
-
human_title = if model.to_s
|
17
|
+
human_title = if model.to_s == @name.singularize.camelize
|
18
18
|
model.model_name.human
|
19
19
|
else
|
20
20
|
@name.humanize
|
@@ -22,6 +22,7 @@ module Bhf
|
|
22
22
|
|
23
23
|
@title = I18n.t("bhf.platforms.#{@name}.title", :platform_title => human_title, :default => human_title).pluralize
|
24
24
|
@page_name = page_name
|
25
|
+
@user = user
|
25
26
|
end
|
26
27
|
|
27
28
|
def search?
|
@@ -31,36 +32,50 @@ module Bhf
|
|
31
32
|
def custom_columns?
|
32
33
|
table_options(:columns).is_a?(Array)
|
33
34
|
end
|
35
|
+
|
36
|
+
def user_scope?
|
37
|
+
@user && table_options(:user_scope)
|
38
|
+
end
|
34
39
|
|
35
|
-
def
|
40
|
+
def search_source
|
36
41
|
table_options(:search) || :where
|
37
42
|
end
|
38
43
|
|
39
|
-
def prepare_objects(options)
|
40
|
-
|
44
|
+
def prepare_objects(options, paginate_options = nil)
|
45
|
+
if user_scope?
|
46
|
+
chain = @user.send(table_options(:user_scope).to_sym)
|
47
|
+
else
|
48
|
+
chain = model
|
49
|
+
chain = chain.unscoped if options[:order]
|
50
|
+
chain = chain.send(data_source) if data_source
|
51
|
+
end
|
41
52
|
|
42
53
|
if options[:order]
|
43
|
-
chain = chain.
|
54
|
+
chain = chain.order("#{options[:order]} #{options[:direction]}")
|
44
55
|
end
|
45
56
|
|
46
57
|
if search? && options[:search].present?
|
47
58
|
chain = do_search(chain, options[:search])
|
48
59
|
end
|
49
60
|
|
50
|
-
|
61
|
+
if paginate_options
|
62
|
+
chain = chain.paginate(paginate_options)
|
63
|
+
end
|
64
|
+
|
65
|
+
@objects = chain
|
51
66
|
end
|
52
|
-
|
67
|
+
|
53
68
|
def model
|
54
69
|
return @data['model'].constantize if @data['model']
|
55
70
|
@name.singularize.camelize.constantize
|
56
71
|
end
|
57
|
-
|
72
|
+
|
58
73
|
def model_name
|
59
74
|
ActiveModel::Naming.singular(model)
|
60
75
|
end
|
61
76
|
|
62
77
|
def fields
|
63
|
-
default_attrs(form_options(:display), @collection)
|
78
|
+
default_attrs(form_options(:display), @collection, false)
|
64
79
|
end
|
65
80
|
|
66
81
|
def columns
|
@@ -70,11 +85,15 @@ module Bhf
|
|
70
85
|
end
|
71
86
|
end
|
72
87
|
|
88
|
+
def entries_per_page
|
89
|
+
table_options(:per_page)
|
90
|
+
end
|
91
|
+
|
73
92
|
def has_file_upload?
|
74
93
|
@collection.each do |field|
|
75
|
-
return true if field.form_type
|
94
|
+
return true if field.form_type == :file
|
76
95
|
end
|
77
|
-
|
96
|
+
false
|
78
97
|
end
|
79
98
|
|
80
99
|
def table
|
@@ -86,44 +105,40 @@ module Bhf
|
|
86
105
|
end
|
87
106
|
|
88
107
|
def hooks(method)
|
89
|
-
@data['hooks']
|
108
|
+
if @data['hooks'] && @data['hooks'][method.to_s]
|
109
|
+
@data['hooks'][method.to_s].to_sym
|
110
|
+
end
|
90
111
|
end
|
91
|
-
|
112
|
+
|
92
113
|
private
|
93
114
|
|
94
115
|
def do_search(chain, search_term)
|
95
116
|
search_condition = if table_options(:search)
|
96
117
|
search_term
|
97
118
|
else
|
98
|
-
|
99
|
-
model.columns_hash.each_pair do |name, props|
|
100
|
-
is_number = search_term.to_i.to_s === search_term || search_term.to_f.to_s === search_term
|
101
|
-
|
102
|
-
if props.type === :string || props.type === :text
|
103
|
-
where_statement << "#{name} LIKE '%#{search_term}%'"
|
104
|
-
elsif props.type === :integer && is_number
|
105
|
-
where_statement << "#{name} = #{search_term.to_i}"
|
106
|
-
elsif props.type === :float && is_number
|
107
|
-
where_statement << "#{name} = #{search_term.to_f}"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
where_statement.join(' OR ')
|
119
|
+
model.bhf_default_search(search_term)
|
112
120
|
end
|
113
121
|
|
114
|
-
chain.send
|
122
|
+
chain.send search_source, search_condition
|
115
123
|
end
|
116
124
|
|
117
125
|
def data_source
|
118
|
-
table_options(:source)
|
126
|
+
table_options(:source)
|
119
127
|
end
|
120
128
|
|
121
|
-
def default_attrs(attrs,
|
122
|
-
return
|
123
|
-
|
124
|
-
model_respond_to?(attrs)
|
129
|
+
def default_attrs(attrs, d_attrs, warning = true)
|
130
|
+
return d_attrs unless attrs
|
131
|
+
|
132
|
+
model_respond_to?(attrs) if warning
|
125
133
|
attrs.each_with_object([]) do |attr_name, obj|
|
126
|
-
obj <<
|
134
|
+
obj << (
|
135
|
+
@collection.select{ |field| attr_name == field.name }[0] ||
|
136
|
+
Bhf::Data::AbstractField.new({
|
137
|
+
:name => attr_name,
|
138
|
+
:type => form_options(:types, attr_name) || attr_name,
|
139
|
+
:info => I18n.t("bhf.platforms.#{@name}.infos.#{attr_name}", :default => '')
|
140
|
+
})
|
141
|
+
)
|
127
142
|
end
|
128
143
|
end
|
129
144
|
|
@@ -133,6 +148,7 @@ module Bhf
|
|
133
148
|
model.columns_hash.each_pair do |name, props|
|
134
149
|
all[name] = Bhf::Data::Field.new(props, {
|
135
150
|
:overwrite_type => form_options(:types, name),
|
151
|
+
:overwrite_display_type => table_options(:types, name),
|
136
152
|
:info => I18n.t("bhf.platforms.#{@name}.infos.#{name}", :default => '')
|
137
153
|
}, model.primary_key)
|
138
154
|
end
|
@@ -140,6 +156,7 @@ module Bhf
|
|
140
156
|
model.reflections.each_pair do |name, props|
|
141
157
|
all[name.to_s] = Bhf::Data::Reflection.new(props, {
|
142
158
|
:overwrite_type => form_options(:types, name),
|
159
|
+
:overwrite_display_type => table_options(:types, name),
|
143
160
|
:info => I18n.t("bhf.platforms.#{@name}.infos.#{name}", :default => ''),
|
144
161
|
:link => form_options(:links, name)
|
145
162
|
})
|
@@ -159,9 +176,9 @@ module Bhf
|
|
159
176
|
output = []
|
160
177
|
|
161
178
|
attrs.each_pair do |key, value|
|
162
|
-
if key
|
179
|
+
if key == model.primary_key
|
163
180
|
id << value
|
164
|
-
elsif key
|
181
|
+
elsif key == 'created_at' || key == 'updated_at'
|
165
182
|
static_dates << value
|
166
183
|
else
|
167
184
|
output << value
|
@@ -184,7 +201,7 @@ module Bhf
|
|
184
201
|
|
185
202
|
def form_options(key, attribute = nil)
|
186
203
|
if form
|
187
|
-
if attribute
|
204
|
+
if attribute == nil
|
188
205
|
form[key.to_s]
|
189
206
|
elsif form[key.to_s]
|
190
207
|
form[key.to_s][attribute.to_s]
|
@@ -192,9 +209,13 @@ module Bhf
|
|
192
209
|
end
|
193
210
|
end
|
194
211
|
|
195
|
-
def table_options(key)
|
212
|
+
def table_options(key, attribute = nil)
|
196
213
|
if table
|
197
|
-
|
214
|
+
if attribute == nil
|
215
|
+
table[key.to_s]
|
216
|
+
elsif table[key.to_s]
|
217
|
+
table[key.to_s][attribute.to_s]
|
218
|
+
end
|
198
219
|
end
|
199
220
|
end
|
200
221
|
|
data/lib/bhf/settings.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Bhf
|
2
|
-
|
2
|
+
|
3
3
|
class Settings
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(options)
|
6
6
|
@options = options
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def pages
|
10
10
|
@options['pages'].each_with_object([]) do |page, obj|
|
11
11
|
if page.is_a?(String)
|
@@ -14,12 +14,11 @@ module Bhf
|
|
14
14
|
obj << page.keys[0]
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def content_for_page(selected_page)
|
19
19
|
@options['pages'].each do |page|
|
20
|
-
if page.is_a?(String)
|
21
|
-
|
22
|
-
end
|
20
|
+
page = {page => nil} if page.is_a?(String)
|
21
|
+
|
23
22
|
if selected_page == page.keys[0]
|
24
23
|
return page.values.flatten
|
25
24
|
end
|
@@ -27,10 +26,10 @@ module Bhf
|
|
27
26
|
nil
|
28
27
|
end
|
29
28
|
|
30
|
-
def find_platform(platform_name)
|
29
|
+
def find_platform(platform_name, current_account = nil)
|
31
30
|
pages.each do |page|
|
32
31
|
content_for_page(page).each do |platform|
|
33
|
-
bhf_platform = Bhf::Platform.new(platform, page)
|
32
|
+
bhf_platform = Bhf::Platform.new(platform, page, current_account)
|
34
33
|
return bhf_platform if bhf_platform.name == platform_name
|
35
34
|
end
|
36
35
|
end
|
data/lib/bhf.rb
CHANGED
data/lib/engine.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'haml'
|
2
2
|
require 'will_paginate'
|
3
|
+
require 'will_paginate/view_helpers/action_view'
|
3
4
|
|
4
5
|
module Bhf
|
5
6
|
class Engine < Rails::Engine
|
@@ -7,7 +8,8 @@ module Bhf
|
|
7
8
|
# Config defaults
|
8
9
|
config.page_title = nil
|
9
10
|
config.mount_at = 'bhf'
|
10
|
-
config.
|
11
|
+
config.session_auth_name = :is_admin
|
12
|
+
config.current_admin_account = nil
|
11
13
|
config.css = []
|
12
14
|
|
13
15
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Bhf
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
|
4
|
-
config.page_title = '
|
4
|
+
config.page_title = 'Bahnhof Admin'
|
5
5
|
config.mount_at = '/bhf'
|
6
|
-
# config.
|
7
|
-
config.
|
6
|
+
# config.current_admin_account = :current_user
|
7
|
+
# config.session_auth_name = :admin
|
8
|
+
# config.css = ['bhf_extend']
|
8
9
|
end
|
9
10
|
end
|
data/public/javascripts/bhf.js
CHANGED
@@ -1146,4 +1146,4 @@ e[i+"2"]=true;}}this.fireEvent("bound",e);this.tip.setStyles(h);},fill:function(
|
|
1146
1146
|
}if(!this.tip.parentNode){this.tip.inject(document.body);}this.fireEvent("show",[this.tip,b]);},hide:function(b){if(!this.tip){document.id(this);}this.fireEvent("hide",[this.tip,b]);
|
1147
1147
|
}});})();Locale.define("de-DE","Date",{months:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],months_abbr:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],days:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],days_abbr:["So.","Mo.","Di.","Mi.","Do.","Fr.","Sa."],dateOrder:["date","month","year"],shortDate:"%d.%m.%Y",shortTime:"%H:%M",AM:"vormittags",PM:"nachmittags",ordinal:".",lessThanMinuteAgo:"vor weniger als einer Minute",minuteAgo:"vor einer Minute",minutesAgo:"vor {delta} Minuten",hourAgo:"vor einer Stunde",hoursAgo:"vor {delta} Stunden",dayAgo:"vor einem Tag",daysAgo:"vor {delta} Tagen",weekAgo:"vor einer Woche",weeksAgo:"vor {delta} Wochen",monthAgo:"vor einem Monat",monthsAgo:"vor {delta} Monaten",yearAgo:"vor einem Jahr",yearsAgo:"vor {delta} Jahren",lessThanMinuteUntil:"in weniger als einer Minute",minuteUntil:"in einer Minute",minutesUntil:"in {delta} Minuten",hourUntil:"in ca. einer Stunde",hoursUntil:"in ca. {delta} Stunden",dayUntil:"in einem Tag",daysUntil:"in {delta} Tagen",weekUntil:"in einer Woche",weeksUntil:"in {delta} Wochen",monthUntil:"in einem Monat",monthsUntil:"in {delta} Monaten",yearUntil:"in einem Jahr",yearsUntil:"in {delta} Jahren"});
|
1148
1148
|
Locale.define("de-DE","FormValidator",{required:"Dieses Eingabefeld muss ausgefüllt werden.",minLength:"Geben Sie bitte mindestens {minLength} Zeichen ein (Sie haben nur {length} Zeichen eingegeben).",maxLength:"Geben Sie bitte nicht mehr als {maxLength} Zeichen ein (Sie haben {length} Zeichen eingegeben).",integer:"Geben Sie in diesem Eingabefeld bitte eine ganze Zahl ein. Dezimalzahlen (z.B. "1.25") sind nicht erlaubt.",numeric:"Geben Sie in diesem Eingabefeld bitte nur Zahlenwerte (z.B. "1", "1.1", "-1" oder "-1.1") ein.",digits:"Geben Sie in diesem Eingabefeld bitte nur Zahlen und Satzzeichen ein (z.B. eine Telefonnummer mit Bindestrichen und Punkten ist erlaubt).",alpha:"Geben Sie in diesem Eingabefeld bitte nur Buchstaben (a-z) ein. Leerzeichen und andere Zeichen sind nicht erlaubt.",alphanum:"Geben Sie in diesem Eingabefeld bitte nur Buchstaben (a-z) und Zahlen (0-9) ein. Leerzeichen oder andere Zeichen sind nicht erlaubt.",dateSuchAs:"Geben Sie bitte ein gültiges Datum ein (z.B. "{date}").",dateInFormatMDY:"Geben Sie bitte ein gültiges Datum im Format TT.MM.JJJJ ein (z.B. "31.12.1999").",email:"Geben Sie bitte eine gültige E-Mail-Adresse ein (z.B. "max@mustermann.de").",url:"Geben Sie bitte eine gültige URL ein (z.B. "http://www.google.de").",currencyDollar:"Geben Sie bitte einen gültigen Betrag in EURO ein (z.B. 100.00€).",oneRequired:"Bitte füllen Sie mindestens ein Eingabefeld aus.",errorPrefix:"Fehler: ",warningPrefix:"Warnung: ",noSpace:"Es darf kein Leerzeichen in diesem Eingabefeld sein.",reqChkByNode:"Es wurden keine Elemente gewählt.",requiredChk:"Dieses Feld muss ausgefüllt werden.",reqChkByName:"Bitte wählen Sie ein {label}.",match:"Dieses Eingabefeld muss mit dem {matchName} Eingabefeld übereinstimmen.",startDate:"Das Anfangsdatum",endDate:"Das Enddatum",currendDate:"Das aktuelle Datum",afterDate:"Das Datum sollte zur gleichen Zeit oder später sein als {label}.",beforeDate:"Das Datum sollte zur gleichen Zeit oder früher sein als {label}.",startMonth:"Wählen Sie bitte einen Anfangsmonat",sameMonth:"Diese zwei Datumsangaben müssen im selben Monat sein - Sie müssen eines von beiden verändern.",creditcard:"Die eingegebene Kreditkartennummer ist ungültig. Bitte überprüfen Sie diese und versuchen Sie es erneut. {length} Zahlen eingegeben."});
|
1149
|
-
Locale.define("EU","Number",{decimal:",",group:".",currency:{prefix:"€ "}});Locale.define("de-DE").inherit("EU","Number");(function($){window.rails={applyEvents:function(el){el=$(el||document.body);var apply=function(selector,action,callback){el.getElements(selector).addEvent(action,callback)};apply('form[data-remote="true"]',"submit",rails.handleRemote);apply('a[data-remote="true"], input[data-remote="true"]',"click",rails.handleRemote);apply("a[data-method][data-remote!=true]","click",function(e){e.preventDefault();if(rails.confirmed(this)){var form=new Element("form",{method:"post",action:this.get("href"),styles:{display:"none"}}).inject(this,"after");var methodInput=new Element("input",{type:"hidden",name:"_method",value:this.get("data-method")});var csrfInput=new Element("input",{type:"hidden",name:rails.csrf.param,value:rails.csrf.token});form.adopt(methodInput,csrfInput).submit()}});var noMethodNorRemoteConfirm=":not([data-method]):not([data-remote=true])[data-confirm]";apply("a"+noMethodNorRemoteConfirm+",input"+noMethodNorRemoteConfirm,"click",function(){return rails.confirmed(this)})},getCsrf:function(name){var meta=document.getElement("meta[name=csrf-"+name+"]");return(meta?meta.get("content"):null)},confirmed:function(el){var confirmMessage=el.get("data-confirm");if(confirmMessage&&!confirm(confirmMessage)){return false}return true},disable:function(el){var button=el.get("data-disable-with")?el:el.getElement("[data-disable-with]");if(button){var enableWith=button.get("value");el.addEvent("ajax:complete",function(){button.set({value:enableWith,disabled:false})});button.set({value:button.get("data-disable-with"),disabled:true})}},handleRemote:function(e){e.preventDefault();if(rails.confirmed(this)){this.request=new Request.Rails(this);rails.disable(this);this.request.send()}}};Request.Rails=new Class({Extends:Request,initialize:function(element,options){this.el=element;this.parent(Object.merge({},{method:this.el.get("method")||this.el.get("data-method")||"get",url:this.el.get("action")||this.el.get("href")},options));this.headers.Accept="*/*";this.addRailsEvents()},send:function(options){this.el.fireEvent("ajax:before");if(this.el.get("tag")=="form"){this.options.data=this.el}this.parent(options);this.el.fireEvent("ajax:after",this.xhr)},addRailsEvents:function(){this.addEvent("request",function(){this.el.fireEvent("ajax:loading",this.xhr)});this.addEvent("success",function(){this.el.fireEvent("ajax:success",this.xhr)});this.addEvent("complete",function(){this.el.fireEvent("ajax:complete",this.xhr);this.el.fireEvent("ajax:loaded",this.xhr)});this.addEvent("failure",function(){this.el.fireEvent("ajax:failure",this.xhr)})}})})(document.id);window.addEvent("domready",function(){rails.csrf={token:rails.getCsrf("token"),param:rails.getCsrf("param")};rails.applyEvents()});var BrowserUpdate=new Class({initialize:function(op,test){var b,jsv=5,n=window.navigator;this.op=op||{};this.op.l=op.l||n.language||n.userLanguage||document.documentElement.getAttribute("lang")||"en";this.op.vsakt={i:8,f:3.6,o:10.6,s:5,n:10};this.op.vsdefault={i:6,f:2,o:9.64,s:3,n:10};this.op.vs=op.vs||this.op.vsdefault;for(b in this.op.vsakt){if(this.op.vs[b]>=this.op.vsakt[b]){this.op.vs[b]=this.op.vsdefault[b]}}if(!op.reminder||op.reminder<0.1){this.op.reminder=0}else{this.op.reminder=op.reminder||24}this.op.onshow=op.onshow||function(o){};this.op.url=op.url||"http://browser-update.org/update.html";this.op.pageurl=op.pageurl||window.location.hostname||"unknown";this.op.newwindow=op.newwindow||false;this.op.test=test||op.test||false;if(window.location.hash=="#test-bu"){this.op.test=true}function getBrowser(){var n,v,t,ua=navigator.userAgent,names={i:"Internet Explorer",f:"Firefox",o:"Opera",s:"Apple Safari",n:"Netscape Navigator",c:"Chrome",x:"Other"};if(/like firefox|chromeframe|seamonkey|opera mini|meego|netfront|moblin|maemo|arora|camino|flot|k-meleon|fennec|kazehakase|galeon|android|mobile|iphone|ipod|ipad|symbian|webos/i.test(ua)){n="x"}else{if(/MSIE (\d+\.\d+);/.test(ua)){n="i"}else{if(/Chrome.(\d+\.\d+)/i.test(ua)){n="c"}else{if(/Firefox.(\d+\.\d+)/i.test(ua)){n="f"}else{if(/Version.(\d+.\d+).{0,10}Safari/i.test(ua)){n="s"}else{if(/Safari.(\d+)/i.test(ua)){n="so"}else{if(/Opera.*Version.(\d+\.\d+)/i.test(ua)){n="o"}else{if(/Opera.(\d+\.\d+)/i.test(ua)){n="o"}else{if(/Netscape.(\d+)/i.test(ua)){n="n"}else{return{n:"x",v:0,t:names[n]}}}}}}}}}}if(n=="x"){return{n:"x",v:0,t:names[n]}}v=new Number(RegExp.$1);if(n=="so"){v=((v<100)&&1)||((v<130)&&1.2)||((v<320)&&1.3)||((v<520)&&2)||((v<524)&&3)||((v<526)&&3.2)||4;n="s"}if(n=="i"&&v==7&&window.XDomainRequest){v=8}return{n:n,v:v,t:names[n]+" "+v}}this.op.browser=getBrowser();if(!this.op.test&&(!this.op.browser||!this.op.browser.n||this.op.browser.n=="x"||this.op.browser.n=="c"||document.cookie.indexOf("browserupdateorg=pause")>-1||this.op.browser.v>this.op.vs[this.op.browser.n])){return}if(this.op.reminder>0){var d=new Date(new Date().getTime()+1000*3600*this.op.reminder);document.cookie="browserupdateorg=pause; expires="+d.toGMTString()+"; path=/"}var ll=this.op.l.substr(0,2);var languages="de,en";if(languages.indexOf(ll)!==false){this.op.url="http://browser-update.org/"+ll+"/update.html#"+jsv}var tar="";if(this.op.newwindow){tar=' target="_blank"'}function busprintf(){var args=arguments;var data=args[0];for(var k=1;k<args.length;++k){data=data.replace(/%s/,args[k])}return data}ll=(window.Locale)?Locale.getCurrent().name:"en-US";var t="Your browser (%s) is <b>out of date</b>. It has known <b>security flaws</b> and may <b>not display all features</b> of this and other websites. <a%s>Learn how to update your browser</a>";if(ll=="de-DE"){t="Sie verwenden einen <b>veralteten Browser</b> (%s) mit <b>Sicherheitsschwachstellen</b> und <b>können nicht alle Funktionen dieser Webseite nutzen</b>. <a%s>Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können</a>."}if(op.text){t=op.text}this.op.text=busprintf(t,this.op.browser.t,' href="'+this.op.url+'"'+tar);var div=document.createElement("div");this.op.div=div;div.id="buorg";div.className="buorg";div.innerHTML="<div>"+this.op.text+'<div id="buorgclose">X</div></div>';var sheet=document.createElement("style");var style=".buorg {position:absolute;z-index:111111; width:100%; top:0px; left:0px; border-bottom:1px solid #A29330; background:#FDF2AB no-repeat 10px center url(http://browser-update.org/img/dialog-warning.gif); text-align:left; cursor:pointer; font-family: Arial,Helvetica,sans-serif; color:#000; font-size: 12px;} .buorg div { padding:5px 36px 5px 40px; } .buorg a,.buorg a:visited {color:#E25600; text-decoration: underline;} #buorgclose { position: absolute; right: .5em; top:.2em; height: 20px; width: 12px; font-weight: bold;font-size:14px; padding:0; }";document.body.insertBefore(div,document.body.firstChild);document.getElementsByTagName("head")[0].appendChild(sheet);try{sheet.innerText=style;sheet.innerHTML=style}catch(e){try{sheet.styleSheet.cssText=style}catch(e){return}}var me=this;div.onclick=function(){if(me.op.newwindow){window.open(me.op.url,"_blank")}else{window.location.href=me.op.url}return false};div.getElementsByTagName("a")[0].onclick=function(e){var e=e||window.event;if(e.stopPropagation){e.stopPropagation()}else{e.cancelBubble=true}return true};this.op.bodymt=document.body.style.paddingTop;document.body.style.paddingTop=(div.clientHeight)+"px";document.getElementById("buorgclose").onclick=function(e){var e=e||window.event;if(e.stopPropagation){e.stopPropagation()}else{e.cancelBubble=true}me.op.div.style.display="none";document.body.style.paddingTop=me.op.bodymt;return true};op.onshow(this.op)}});var Ajaxify=new Class({version:0.2,Implements:[Options,Events],options:{events:{loading:{name:"ajax:loading",text:"Loading…"},success:{name:"ajax:success",text:"Changes successfully saved!"},failure:{name:"ajax:failure",text:"Oops, something went wrong…"}},holder:new Element("div#ajax_holder"),fadeOutDuration:2000},initialize:function(_options){this.setOptions(_options);this.holder=this.options.holder},applyEvents:function(el){el=document.id(el||document.body);var apply=function(action,callback){el.getElements('[data-remote="true"]').addEvent(action,callback)};apply(this.options.events.loading.name,this.loading.bind(this));apply(this.options.events.success.name,this.success.bind(this));apply(this.options.events.failure.name,this.failure.bind(this))},loading:function(xhr){this.setMessage("loading",false)},success:function(xhr){this.setMessage("success",true)},failure:function(xhr){this.setMessage("failure",true)},setMessage:function(status,fadeOut){this.holder.set("class",status).set("text",this.options.events[status].text).inject(document.body);if(fadeOut){this.holder.addClass("fadeout");setTimeout(function(){this.holder.dispose()}.bind(this),this.options.fadeOutDuration)}}});var AjaxEdit=new Class({version:0.2,options:{holderParent:document.body},Implements:[Options,Events],holder:new Element("div.quick_edit_holder"),initialize:function(_options){this.setOptions(_options);this.holder.addEvents({"click:relay(.open)":function(e){e.preventDefault();location.href=this.wrapElement.getElement("a").get("href")}.bind(this),"click:relay(.cancel)":function(e){e.preventDefault();this.close()}.bind(this),"click:relay(.save_and_next)":function(e){e.preventDefault();this.submit(["successAndChange","successAndNext"])}.bind(this),"click:relay(.save)":function(e){e.preventDefault();this.submit(["successAndChange"])}.bind(this),"submit:relay(form)":function(e){e.preventDefault();this.submit(["successAndChange"])}.bind(this)})},startEdit:function(element,wrapElement){this.clean();this.wrapElement=wrapElement?wrapElement:element;this.wrapElement.addClass("live_edit");new Request({method:"get",url:element.get("href"),onSuccess:function(html){this.injectForm(html)}.bind(this)}).send()},submit:function(eventNames){var form=this.holder.getElement("form");wysiwyg.each(function(elem){elem.saveContent()});new Request.JSON({method:form.get("method"),url:form.get("action"),onRequest:function(){this.disableButtons()}.bind(this),onFailure:function(invalidForm){this.injectForm(invalidForm.response)}.bind(this),onSuccess:function(json){if(!eventNames.contains("successAndNext")){this.close()}eventNames.each(function(eventName){this.fireEvent(eventName,[json])}.bind(this))}.bind(this)}).send({data:form})},disableButtons:function(){this.holder.getElements(".open, .cancel, .save_and_next, .save").set("disabled","disabled")},clean:function(){document.body.getElements(".live_edit").removeClass("live_edit")},close:function(){this.clean();this.holder.dispose()},injectForm:function(form){this.holder.innerHTML=form;this.holder.inject(this.options.holderParent);this.holder.getElements(".wysiwyg").each(function(elem){wysiwyg.push(elem.mooEditable())})}});(function(){var blockEls=/^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|SCRIPT|NOSCRIPT|STYLE)$/i;var urlRegex=/^(https?|ftp|rmtp|mms):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i;var protectRegex=/<(script|noscript|style)[\u0000-\uFFFF]*?<\/(script|noscript|style)>/g;this.MooEditable=new Class({Implements:[Events,Options],options:{toolbar:true,cleanup:true,paragraphise:true,xhtml:true,semantics:true,actions:"bold italic underline strikethrough | insertunorderedlist insertorderedlist indent outdent | undo redo | createlink unlink | urlimage | toggleview",handleSubmit:true,handleLabel:true,disabled:false,baseCSS:"html{ height: 100%; cursor: text; } body{ font-family: sans-serif; }",extraCSS:"",externalCSS:"",html:'<!DOCTYPE html><html><head><meta charset="UTF-8">{BASEHREF}<style>{BASECSS} {EXTRACSS}</style>{EXTERNALCSS}</head><body></body></html>',rootElement:"p",baseURL:"",dimensions:null},initialize:function(el,options){this.setOptions(options);this.textarea=document.id(el);this.textarea.store("MooEditable",this);this.actions=this.options.actions.clean().split(" ");this.keys={};this.dialogs={};this.protectedElements=[];this.actions.each(function(action){var act=MooEditable.Actions[action];if(!act){return}if(act.options){var key=act.options.shortcut;if(key){this.keys[key]=action}}if(act.dialogs){Object.each(act.dialogs,function(dialog,name){dialog=dialog.attempt(this);dialog.name=action+":"+name;if(typeOf(this.dialogs[action])!="object"){this.dialogs[action]={}}this.dialogs[action][name]=dialog},this)}if(act.events){Object.each(act.events,function(fn,event){this.addEvent(event,fn)},this)}}.bind(this));this.render()},toElement:function(){return this.textarea},render:function(){var self=this;var dimensions=this.options.dimensions||this.textarea.getSize();this.container=new Element("div",{id:(this.textarea.id)?this.textarea.id+"-mooeditable-container":null,"class":"mooeditable-container",styles:{width:dimensions.x}});this.textarea.addClass("mooeditable-textarea").setStyle("height",dimensions.y);this.iframe=new IFrame({"class":"mooeditable-iframe",frameBorder:0,src:'javascript:""',styles:{height:dimensions.y}});this.toolbar=new MooEditable.UI.Toolbar({onItemAction:function(){var args=Array.from(arguments);var item=args[0];self.action(item.name,args)}});this.attach.delay(1,this);if(this.options.handleLabel&&this.textarea.id){$$('label[for="'+this.textarea.id+'"]').addEvent("click",function(e){if(self.mode!="iframe"){return}e.preventDefault();self.focus()})}if(this.options.handleSubmit){this.form=this.textarea.getParent("form");if(!this.form){return}this.form.addEvent("submit",function(){if(self.mode=="iframe"){self.saveContent()}})}this.fireEvent("render",this)},attach:function(){var self=this;this.mode="iframe";this.editorDisabled=false;this.container.wraps(this.textarea);this.textarea.setStyle("display","none");this.iframe.setStyle("display","").inject(this.textarea,"before");Object.each(this.dialogs,function(action,name){Object.each(action,function(dialog){document.id(dialog).inject(self.iframe,"before");var range;dialog.addEvents({open:function(){range=self.selection.getRange();self.editorDisabled=true;self.toolbar.disable(name);self.fireEvent("dialogOpen",this)},close:function(){self.toolbar.enable();self.editorDisabled=false;self.focus();if(range){self.selection.setRange(range)}self.fireEvent("dialogClose",this)}})})});this.win=this.iframe.contentWindow;this.doc=this.win.document;if(Browser.firefox){this.doc.designMode="On"}var docHTML=this.options.html.substitute({BASECSS:this.options.baseCSS,EXTRACSS:this.options.extraCSS,EXTERNALCSS:(this.options.externalCSS)?'<link rel="stylesheet" href="'+this.options.externalCSS+'">':"",BASEHREF:(this.options.baseURL)?'<base href="'+this.options.baseURL+'" />':""});this.doc.open();this.doc.write(docHTML);this.doc.close();(Browser.ie)?this.doc.body.contentEditable=true:this.doc.designMode="On";Object.append(this.win,new Window);Object.append(this.doc,new Document);if(Browser.Element){var winElement=this.win.Element.prototype;for(var method in Element){if(!method.test(/^[A-Z]|\$|prototype|mooEditable/)){winElement[method]=Element.prototype[method]}}}else{document.id(this.doc.body)}this.setContent(this.textarea.get("value"));this.doc.addEvents({mouseup:this.editorMouseUp.bind(this),mousedown:this.editorMouseDown.bind(this),mouseover:this.editorMouseOver.bind(this),mouseout:this.editorMouseOut.bind(this),mouseenter:this.editorMouseEnter.bind(this),mouseleave:this.editorMouseLeave.bind(this),contextmenu:this.editorContextMenu.bind(this),click:this.editorClick.bind(this),dblclick:this.editorDoubleClick.bind(this),keypress:this.editorKeyPress.bind(this),keyup:this.editorKeyUp.bind(this),keydown:this.editorKeyDown.bind(this),focus:this.editorFocus.bind(this),blur:this.editorBlur.bind(this)});this.win.addEvents({focus:this.editorFocus.bind(this),blur:this.editorBlur.bind(this)});["cut","copy","paste"].each(function(event){self.doc.body.addListener(event,self["editor"+event.capitalize()].bind(self))});this.textarea.addEvent("keypress",this.textarea.retrieve("mooeditable:textareaKeyListener",this.keyListener.bind(this)));if(Browser.firefox2){this.doc.addEvent("focus",function(){self.win.fireEvent("focus").focus()})}if(this.doc.addEventListener){this.doc.addEventListener("focus",function(){self.win.fireEvent("focus")},true)}if(!Browser.ie&&!Browser.opera){var styleCSS=function(){self.execute("styleWithCSS",false,false);self.doc.removeEvent("focus",styleCSS)};this.win.addEvent("focus",styleCSS)}if(this.options.toolbar){document.id(this.toolbar).inject(this.container,"top");this.toolbar.render(this.actions)}if(this.options.disabled){this.disable()}this.selection=new MooEditable.Selection(this.win);this.oldContent=this.getContent();this.fireEvent("attach",this);return this},detach:function(){this.saveContent();this.textarea.setStyle("display","").removeClass("mooeditable-textarea").inject(this.container,"before");this.textarea.removeEvent("keypress",this.textarea.retrieve("mooeditable:textareaKeyListener"));this.container.dispose();this.fireEvent("detach",this);return this},enable:function(){this.editorDisabled=false;this.toolbar.enable();return this},disable:function(){this.editorDisabled=true;this.toolbar.disable();return this},editorFocus:function(e){this.oldContent="";this.fireEvent("editorFocus",[e,this])},editorBlur:function(e){this.oldContent=this.saveContent().getContent();this.fireEvent("editorBlur",[e,this])},editorMouseUp:function(e){if(this.editorDisabled){e.stop();return}if(this.options.toolbar){this.checkStates()}this.fireEvent("editorMouseUp",[e,this])},editorMouseDown:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseDown",[e,this])},editorMouseOver:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseOver",[e,this])},editorMouseOut:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseOut",[e,this])},editorMouseEnter:function(e){if(this.editorDisabled){e.stop();return}if(this.oldContent&&this.getContent()!=this.oldContent){this.focus();this.fireEvent("editorPaste",[e,this])}this.fireEvent("editorMouseEnter",[e,this])},editorMouseLeave:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseLeave",[e,this])},editorContextMenu:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorContextMenu",[e,this])},editorClick:function(e){if(Browser.safari||Browser.chrome){var el=e.target;if(Element.get(el,"tag")=="img"){if(this.options.baseURL){if(el.getProperty("src").indexOf("http://")==-1){el.setProperty("src",this.options.baseURL+el.getProperty("src"))}}this.selection.selectNode(el);this.checkStates()}}this.fireEvent("editorClick",[e,this])},editorDoubleClick:function(e){this.fireEvent("editorDoubleClick",[e,this])},editorKeyPress:function(e){if(this.editorDisabled){e.stop();return}this.keyListener(e);this.fireEvent("editorKeyPress",[e,this])},editorKeyUp:function(e){if(this.editorDisabled){e.stop();return}var c=e.code;if(this.options.toolbar&&(/^enter|left|up|right|down|delete|backspace$/i.test(e.key)||(c>=33&&c<=36)||c==45||e.meta||e.control)){if(Browser.ie6){clearTimeout(this.checkStatesDelay);this.checkStatesDelay=this.checkStates.delay(500,this)}else{this.checkStates()}}this.fireEvent("editorKeyUp",[e,this])},editorKeyDown:function(e){if(this.editorDisabled){e.stop();return}if(e.key=="enter"){if(this.options.paragraphise){if(e.shift&&(Browser.safari||Browser.chrome)){var s=this.selection;var r=s.getRange();var br=this.doc.createElement("br");r.insertNode(br);r.setStartAfter(br);r.setEndAfter(br);s.setRange(r);if(s.getSelection().focusNode==br.previousSibling){var nbsp=this.doc.createTextNode("\u00a0");var p=br.parentNode;var ns=br.nextSibling;(ns)?p.insertBefore(nbsp,ns):p.appendChild(nbsp);s.selectNode(nbsp);s.collapse(1)}this.win.scrollTo(0,Element.getOffsets(s.getRange().startContainer).y);e.preventDefault()}else{if(Browser.firefox||Browser.safari||Browser.chrome){var node=this.selection.getNode();var isBlock=Element.getParents(node).include(node).some(function(el){return el.nodeName.test(blockEls)});if(!isBlock){this.execute("insertparagraph")}}}}else{if(Browser.ie){var r=this.selection.getRange();var node=this.selection.getNode();if(r&&node.get("tag")!="li"){this.selection.insertContent("<br>");this.selection.collapse(false)}e.preventDefault()}}}if(Browser.opera){var ctrlmeta=e.control||e.meta;if(ctrlmeta&&e.key=="x"){this.fireEvent("editorCut",[e,this])}else{if(ctrlmeta&&e.key=="c"){this.fireEvent("editorCopy",[e,this])}else{if((ctrlmeta&&e.key=="v")||(e.shift&&e.code==45)){this.fireEvent("editorPaste",[e,this])}}}}this.fireEvent("editorKeyDown",[e,this])},editorCut:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorCut",[e,this])},editorCopy:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorCopy",[e,this])},editorPaste:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorPaste",[e,this])},keyListener:function(e){var key=(Browser.Platform.mac)?e.meta:e.control;if(!key||!this.keys[e.key]){return}e.preventDefault();var item=this.toolbar.getItem(this.keys[e.key]);item.action(e)},focus:function(){(this.mode=="iframe"?this.win:this.textarea).focus();this.fireEvent("focus",this);return this},action:function(command,args){var action=MooEditable.Actions[command];if(action.command&&typeOf(action.command)=="function"){action.command.apply(this,args)}else{this.focus();this.execute(command,false,args);if(this.mode=="iframe"){this.checkStates()}}},execute:function(command,param1,param2){if(this.busy){return}this.busy=true;this.doc.execCommand(command,param1,param2);this.saveContent();this.busy=false;return false},toggleView:function(){this.fireEvent("beforeToggleView",this);if(this.mode=="textarea"){this.mode="iframe";this.iframe.setStyle("display","");this.setContent(this.textarea.value);this.textarea.setStyle("display","none")}else{this.saveContent();this.mode="textarea";this.textarea.setStyle("display","");this.iframe.setStyle("display","none")}this.fireEvent("toggleView",this);this.focus.delay(10,this);return this},getContent:function(){var protect=this.protectedElements;var html=this.doc.body.get("html").replace(/<!-- mooeditable:protect:([0-9]+) -->/g,function(a,b){return protect[b.toInt()]});return this.cleanup(this.ensureRootElement(html))},setContent:function(content){var protect=this.protectedElements;content=content.replace(protectRegex,function(a){protect.push(a);return"<!-- mooeditable:protect:"+(protect.length-1)+" -->"});this.doc.body.set("html",this.ensureRootElement(content));return this},saveContent:function(){if(this.mode=="iframe"){this.textarea.set("value",this.getContent())}return this},ensureRootElement:function(val){if(this.options.rootElement){var el=new Element("div",{html:val.trim()});var start=-1;var create=false;var html="";var length=el.childNodes.length;for(var i=0;i<length;i++){var childNode=el.childNodes[i];var nodeName=childNode.nodeName;if(!nodeName.test(blockEls)&&nodeName!=="#comment"){if(nodeName==="#text"){if(childNode.nodeValue.trim()){if(start<0){start=i}html+=childNode.nodeValue}}else{if(start<0){start=i}html+=new Element("div").adopt($(childNode).clone()).get("html")}}else{create=true}if(i==(length-1)){create=true}if(start>=0&&create){var newel=new Element(this.options.rootElement,{html:html});el.replaceChild(newel,el.childNodes[start]);for(var k=start+1;k<i;k++){el.removeChild(el.childNodes[k]);length--;i--;k--}start=-1;create=false;html=""}}val=el.get("html").replace(/\n\n/g,"")}return val},checkStates:function(){var element=this.selection.getNode();if(!element){return}if(typeOf(element)!="element"){return}this.actions.each(function(action){var item=this.toolbar.getItem(action);if(!item){return}item.deactivate();var states=MooEditable.Actions[action]["states"];if(!states){return}if(typeOf(states)=="function"){states.attempt([document.id(element),item],this);return}try{if(this.doc.queryCommandState(action)){item.activate();return}}catch(e){}if(states.tags){var el=element;do{var tag=el.tagName.toLowerCase();if(states.tags.contains(tag)){item.activate(tag);break}}while((el=Element.getParent(el))!=null)}if(states.css){var el=element;do{var found=false;for(var prop in states.css){var css=states.css[prop];if(el.style[prop.camelCase()].contains(css)){item.activate(css);found=true}}if(found||el.tagName.test(blockEls)){break}}while((el=Element.getParent(el))!=null)}}.bind(this))},cleanup:function(source){if(!this.options.cleanup){return source.trim()}do{var oSource=source;if(this.options.baseURL){source=source.replace('="'+this.options.baseURL,'="')}source=source.replace(/<br class\="webkit-block-placeholder">/gi,"<br />");source=source.replace(/<span class="Apple-style-span">(.*)<\/span>/gi,"$1");source=source.replace(/ class="Apple-style-span"/gi,"");source=source.replace(/<span style="">/gi,"");source=source.replace(/<p>\s*<br ?\/?>\s*<\/p>/gi,"<p>\u00a0</p>");source=source.replace(/<p>( |\s)*<\/p>/gi,"<p>\u00a0</p>");if(!this.options.semantics){source=source.replace(/\s*<br ?\/?>\s*<\/p>/gi,"</p>")}if(this.options.xhtml){source=source.replace(/<br>/gi,"<br />")}if(this.options.semantics){if(Browser.ie){source=source.replace(/<li>\s*<div>(.+?)<\/div><\/li>/g,"<li>$1</li>")}if(Browser.safari||Browser.chrome){source=source.replace(/^([\w\s]+.*?)<div>/i,"<p>$1</p><div>");source=source.replace(/<div>(.+?)<\/div>/ig,"<p>$1</p>")}if(!Browser.ie){source=source.replace(/<p>[\s\n]*(<(?:ul|ol)>.*?<\/(?:ul|ol)>)(.*?)<\/p>/ig,"$1<p>$2</p>");source=source.replace(/<\/(ol|ul)>\s*(?!<(?:p|ol|ul|img).*?>)((?:<[^>]*>)?\w.*)$/g,"</$1><p>$2</p>")}source=source.replace(/<br[^>]*><\/p>/g,"</p>");source=source.replace(/<p>\s*(<img[^>]+>)\s*<\/p>/ig,"$1\n");source=source.replace(/<p([^>]*)>(.*?)<\/p>(?!\n)/g,"<p$1>$2</p>\n");source=source.replace(/<\/(ul|ol|p)>(?!\n)/g,"</$1>\n");source=source.replace(/><li>/g,">\n\t<li>");source=source.replace(/([^\n])<\/(ol|ul)>/g,"$1\n</$2>");source=source.replace(/([^\n])<img/ig,"$1\n<img");source=source.replace(/^\s*$/g,"")}source=source.replace(/<br ?\/?>$/gi,"");source=source.replace(/^<br ?\/?>/gi,"");if(this.options.paragraphise){source=source.replace(/(h[1-6]|p|div|address|pre|li|ol|ul|blockquote|center|dl|dt|dd)><br ?\/?>/gi,"$1>")}source=source.replace(/<br ?\/?>\s*<\/(h1|h2|h3|h4|h5|h6|li|p)/gi,"</$1");source=source.replace(/<span style="font-weight: bold;">(.*)<\/span>/gi,"<strong>$1</strong>");source=source.replace(/<span style="font-style: italic;">(.*)<\/span>/gi,"<em>$1</em>");source=source.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>");source=source.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,"<em>$1</em>");source=source.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration: underline;">$1</span>');source=source.replace(/<strong><span style="font-weight: normal;">(.*)<\/span><\/strong>/gi,"$1");source=source.replace(/<em><span style="font-weight: normal;">(.*)<\/span><\/em>/gi,"$1");source=source.replace(/<span style="text-decoration: underline;"><span style="font-weight: normal;">(.*)<\/span><\/span>/gi,"$1");source=source.replace(/<strong style="font-weight: normal;">(.*)<\/strong>/gi,"$1");source=source.replace(/<em style="font-weight: normal;">(.*)<\/em>/gi,"$1");source=source.replace(/<[^> ]*/g,function(match){return match.toLowerCase()});source=source.replace(/<[^>]*>/g,function(match){match=match.replace(/ [^=]+=/g,function(match2){return match2.toLowerCase()});return match});source=source.replace(/<[^!][^>]*>/g,function(match){match=match.replace(/( [^=]+=)([^"][^ >]*)/g,'$1"$2"');return match});if(this.options.xhtml){source=source.replace(/<img([^>]+)(\s*[^\/])>(<\/img>)*/gi,"<img$1$2 />")}source=source.replace(/<p>(?:\s*)<p>/g,"<p>");source=source.replace(/<\/p>\s*<\/p>/g,"</p>");source=source.replace(/<pre[^>]*>.*?<\/pre>/gi,function(match){return match.replace(/<br ?\/?>/gi,"\n")});source=source.trim()}while(source!=oSource);return source}});MooEditable.Selection=new Class({initialize:function(win){this.win=win},getSelection:function(){this.win.focus();return(this.win.getSelection)?this.win.getSelection():this.win.document.selection},getRange:function(){var s=this.getSelection();if(!s){return null}try{return s.rangeCount>0?s.getRangeAt(0):(s.createRange?s.createRange():null)}catch(e){return this.doc.body.createTextRange()}},setRange:function(range){if(range.select){Function.attempt(function(){range.select()})}else{var s=this.getSelection();if(s.addRange){s.removeAllRanges();s.addRange(range)}}},selectNode:function(node,collapse){var r=this.getRange();var s=this.getSelection();if(r.moveToElementText){Function.attempt(function(){r.moveToElementText(node);r.select()})}else{if(s.addRange){collapse?r.selectNodeContents(node):r.selectNode(node);s.removeAllRanges();s.addRange(r)}else{s.setBaseAndExtent(node,0,node,1)}}return node},isCollapsed:function(){var r=this.getRange();if(r.item){return false}return r.boundingWidth==0||this.getSelection().isCollapsed},collapse:function(toStart){var r=this.getRange();var s=this.getSelection();if(r.select){r.collapse(toStart);r.select()}else{toStart?s.collapseToStart():s.collapseToEnd()}},getContent:function(){var r=this.getRange();var body=new Element("body");if(this.isCollapsed()){return""}if(r.cloneContents){body.appendChild(r.cloneContents())}else{if(r.item!=undefined||r.htmlText!=undefined){body.set("html",r.item?r.item(0).outerHTML:r.htmlText)}else{body.set("html",r.toString())}}var content=body.get("html");return content},getText:function(){var r=this.getRange();var s=this.getSelection();return this.isCollapsed()?"":r.text||(s.toString?s.toString():"")},getNode:function(){var r=this.getRange();if(!Browser.ie||Browser.version>=9){var el=null;if(r){el=r.commonAncestorContainer;if(!r.collapsed){if(r.startContainer==r.endContainer){if(r.startOffset-r.endOffset<2){if(r.startContainer.hasChildNodes()){el=r.startContainer.childNodes[r.startOffset]}}}}while(typeOf(el)!="element"){el=el.parentNode}}return document.id(el)}return document.id(r.item?r.item(0):r.parentElement())},insertContent:function(content){if(Browser.ie){var r=this.getRange();if(r.pasteHTML){r.pasteHTML(content);r.collapse(false);r.select()}else{if(r.insertNode){r.deleteContents();if(r.createContextualFragment){r.insertNode(r.createContextualFragment(content))}else{var doc=this.win.document;var fragment=doc.createDocumentFragment();var temp=doc.createElement("div");fragment.appendChild(temp);temp.outerHTML=content;r.insertNode(fragment)}}}}else{this.win.document.execCommand("insertHTML",false,content)}}});var phrases={};MooEditable.Locale={define:function(key,value){if(typeOf(window.Locale)!="null"){return Locale.define("en-US","MooEditable",key,value)}if(typeOf(key)=="object"){Object.merge(phrases,key)}else{phrases[key]=value}},get:function(key){if(typeOf(window.Locale)!="null"){return Locale.get("MooEditable."+key)}return key?phrases[key]:""}};MooEditable.Locale.define({ok:"OK",cancel:"Cancel",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",unorderedList:"Unordered List",orderedList:"Ordered List",indent:"Indent",outdent:"Outdent",undo:"Undo",redo:"Redo",removeHyperlink:"Remove Hyperlink",addHyperlink:"Add Hyperlink",selectTextHyperlink:"Please select the text you wish to hyperlink.",enterURL:"Enter URL",enterImageURL:"Enter image URL",addImage:"Add Image",toggleView:"Toggle View"});MooEditable.UI={};MooEditable.UI.Toolbar=new Class({Implements:[Events,Options],options:{"class":""},initialize:function(options){this.setOptions(options);this.el=new Element("div",{"class":"mooeditable-ui-toolbar "+this.options["class"]});this.items={};this.content=null},toElement:function(){return this.el},render:function(actions){if(this.content){this.el.adopt(this.content)}else{this.content=actions.map(function(action){return(action=="|")?this.addSeparator():this.addItem(action)}.bind(this))}return this},addItem:function(action){var self=this;var act=MooEditable.Actions[action];if(!act){return}var type=act.type||"button";var options=act.options||{};var item=new MooEditable.UI[type.camelCase().capitalize()](Object.append(options,{name:action,"class":action+"-item toolbar-item",title:act.title,onAction:self.itemAction.bind(self)}));this.items[action]=item;document.id(item).inject(this.el);return item},getItem:function(action){return this.items[action]},addSeparator:function(){return new Element("span",{"class":"toolbar-separator"}).inject(this.el)},itemAction:function(){this.fireEvent("itemAction",arguments)},disable:function(except){Object.each(this.items,function(item){(item.name==except)?item.activate():item.deactivate().disable()});return this},enable:function(){Object.each(this.items,function(item){item.enable()});return this},show:function(){this.el.setStyle("display","");return this},hide:function(){this.el.setStyle("display","none");return this}});MooEditable.UI.Button=new Class({Implements:[Events,Options],options:{title:"",name:"",text:"Button","class":"",shortcut:"",mode:"icon"},initialize:function(options){this.setOptions(options);this.name=this.options.name;this.render()},toElement:function(){return this.el},render:function(){var self=this;var key=(Browser.Platform.mac)?"Cmd":"Ctrl";var shortcut=(this.options.shortcut)?" ( "+key+"+"+this.options.shortcut.toUpperCase()+" )":"";var text=this.options.title||name;var title=text+shortcut;this.el=new Element("button",{"class":"mooeditable-ui-button "+self.options["class"],title:title,html:'<span class="button-icon"></span><span class="button-text">'+text+"</span>",events:{click:self.click.bind(self),mousedown:function(e){e.preventDefault()}}});if(this.options.mode!="icon"){this.el.addClass("mooeditable-ui-button-"+this.options.mode)}this.active=false;this.disabled=false;if(Browser.ie){this.el.addEvents({mouseenter:function(e){this.addClass("hover")},mouseleave:function(e){this.removeClass("hover")}})}return this},click:function(e){e.preventDefault();if(this.disabled){return}this.action(e)},action:function(){this.fireEvent("action",[this].concat(Array.from(arguments)))},enable:function(){if(this.active){this.el.removeClass("onActive")}if(!this.disabled){return}this.disabled=false;this.el.removeClass("disabled").set({disabled:false,opacity:1});return this},disable:function(){if(this.disabled){return}this.disabled=true;this.el.addClass("disabled").set({disabled:true,opacity:0.4});return this},activate:function(){if(this.disabled){return}this.active=true;this.el.addClass("onActive");return this},deactivate:function(){this.active=false;this.el.removeClass("onActive");return this}});MooEditable.UI.Dialog=new Class({Implements:[Events,Options],options:{"class":"",contentClass:""},initialize:function(html,options){this.setOptions(options);this.html=html;var self=this;this.el=new Element("div",{"class":"mooeditable-ui-dialog "+self.options["class"],html:'<div class="dialog-content '+self.options.contentClass+'">'+html+"</div>",styles:{display:"none"},events:{click:self.click.bind(self)}})},toElement:function(){return this.el},click:function(){this.fireEvent("click",arguments);return this},open:function(){this.el.setStyle("display","");this.fireEvent("open",this);return this},close:function(){this.el.setStyle("display","none");this.fireEvent("close",this);return this}});MooEditable.UI.AlertDialog=function(alertText){if(!alertText){return}var html=alertText+' <button class="dialog-ok-button">'+MooEditable.Locale.get("ok")+"</button>";return new MooEditable.UI.Dialog(html,{"class":"mooeditable-alert-dialog",onOpen:function(){var button=this.el.getElement(".dialog-ok-button");(function(){button.focus()}).delay(10)},onClick:function(e){e.preventDefault();if(e.target.tagName.toLowerCase()!="button"){return}if(document.id(e.target).hasClass("dialog-ok-button")){this.close()}}})};MooEditable.UI.PromptDialog=function(questionText,answerText,fn){if(!questionText){return}var html='<label class="dialog-label">'+questionText+' <input type="text" class="text dialog-input" value="'+answerText+'"></label> <button class="dialog-button dialog-ok-button">'+MooEditable.Locale.get("ok")+'</button><button class="dialog-button dialog-cancel-button">'+MooEditable.Locale.get("cancel")+"</button>";return new MooEditable.UI.Dialog(html,{"class":"mooeditable-prompt-dialog",onOpen:function(){var input=this.el.getElement(".dialog-input");(function(){input.focus();input.select()}).delay(10)},onClick:function(e){e.preventDefault();if(e.target.tagName.toLowerCase()!="button"){return}var button=document.id(e.target);var input=this.el.getElement(".dialog-input");if(button.hasClass("dialog-cancel-button")){input.set("value",answerText);this.close()}else{if(button.hasClass("dialog-ok-button")){var answer=input.get("value");input.set("value",answerText);this.close();if(fn){fn.attempt(answer,this)}}}}})};MooEditable.Actions={bold:{title:MooEditable.Locale.get("bold"),options:{shortcut:"b"},states:{tags:["b","strong"],css:{"font-weight":"bold"}},events:{beforeToggleView:function(){if(Browser.firefox){var value=this.textarea.get("value");var newValue=value.replace(/<strong([^>]*)>/gi,"<b$1>").replace(/<\/strong>/gi,"</b>");if(value!=newValue){this.textarea.set("value",newValue)}}},attach:function(){if(Browser.firefox){var value=this.textarea.get("value");var newValue=value.replace(/<strong([^>]*)>/gi,"<b$1>").replace(/<\/strong>/gi,"</b>");if(value!=newValue){this.textarea.set("value",newValue);this.setContent(newValue)}}}}},italic:{title:MooEditable.Locale.get("italic"),options:{shortcut:"i"},states:{tags:["i","em"],css:{"font-style":"italic"}},events:{beforeToggleView:function(){if(Browser.firefox){var value=this.textarea.get("value");var newValue=value.replace(/<embed([^>]*)>/gi,"<tmpembed$1>").replace(/<em([^>]*)>/gi,"<i$1>").replace(/<tmpembed([^>]*)>/gi,"<embed$1>").replace(/<\/em>/gi,"</i>");if(value!=newValue){this.textarea.set("value",newValue)}}},attach:function(){if(Browser.firefox){var value=this.textarea.get("value");var newValue=value.replace(/<embed([^>]*)>/gi,"<tmpembed$1>").replace(/<em([^>]*)>/gi,"<i$1>").replace(/<tmpembed([^>]*)>/gi,"<embed$1>").replace(/<\/em>/gi,"</i>");if(value!=newValue){this.textarea.set("value",newValue);this.setContent(newValue)}}}}},underline:{title:MooEditable.Locale.get("underline"),options:{shortcut:"u"},states:{tags:["u"],css:{"text-decoration":"underline"}}},strikethrough:{title:MooEditable.Locale.get("strikethrough"),options:{shortcut:"s"},states:{tags:["s","strike"],css:{"text-decoration":"line-through"}}},insertunorderedlist:{title:MooEditable.Locale.get("unorderedList"),states:{tags:["ul"]}},insertorderedlist:{title:MooEditable.Locale.get("orderedList"),states:{tags:["ol"]}},indent:{title:MooEditable.Locale.get("indent"),states:{tags:["blockquote"]}},outdent:{title:MooEditable.Locale.get("outdent")},undo:{title:MooEditable.Locale.get("undo"),options:{shortcut:"z"}},redo:{title:MooEditable.Locale.get("redo"),options:{shortcut:"y"}},unlink:{title:MooEditable.Locale.get("removeHyperlink")},createlink:{title:MooEditable.Locale.get("addHyperlink"),options:{shortcut:"l"},states:{tags:["a"]},dialogs:{alert:MooEditable.UI.AlertDialog.pass(MooEditable.Locale.get("selectTextHyperlink")),prompt:function(editor){return MooEditable.UI.PromptDialog(MooEditable.Locale.get("enterURL"),"http://",function(url){editor.execute("createlink",false,url.trim())})}},command:function(){var selection=this.selection;var dialogs=this.dialogs.createlink;if(selection.isCollapsed()){var node=selection.getNode();if(node.get("tag")=="a"&&node.get("href")){selection.selectNode(node);var prompt=dialogs.prompt;prompt.el.getElement(".dialog-input").set("value",node.get("href"));prompt.open()}else{dialogs.alert.open()}}else{var text=selection.getText();var prompt=dialogs.prompt;if(urlRegex.test(text)){prompt.el.getElement(".dialog-input").set("value",text)}prompt.open()}}},urlimage:{title:MooEditable.Locale.get("addImage"),options:{shortcut:"m"},dialogs:{prompt:function(editor){return MooEditable.UI.PromptDialog(MooEditable.Locale.get("enterImageURL"),"http://",function(url){editor.execute("insertimage",false,url.trim())})}},command:function(){this.dialogs.urlimage.prompt.open()}},toggleview:{title:MooEditable.Locale.get("toggleView"),command:function(){(this.mode=="textarea")?this.toolbar.enable():this.toolbar.disable("toggleview");this.toggleView()}}};MooEditable.Actions.Settings={};Element.Properties.mooeditable={get:function(){return this.retrieve("MooEditable")}};Element.implement({mooEditable:function(options){var mooeditable=this.get("mooeditable");if(!mooeditable){mooeditable=new MooEditable(this,options)}return mooeditable}})})();var ajaxNote=new Ajaxify();var wysiwyg=[];window.addEvent("domready",function(){var quickEdit=new AjaxEdit({holderParent:$("content")});ajaxNote.applyEvents();var platforms=document.body.getElements(".platform");var main_form=document.id("main_form");if(platforms.length){var updatePlatform=function(href,platform,callback){new Request({method:"get",url:href,onSuccess:function(html){platform.innerHTML=html;if(callback){callback.call()}}}).send()};platforms.addEvents({"click:relay(.pagination a, thead a)":function(e){e.preventDefault();updatePlatform(this.get("href"),this.getParent(".platform"))},"submit:relay(.search)":function(e){e.preventDefault();var parent=this.getParent(".platform");new Request({method:"get",url:this.get("action"),onSuccess:function(html){parent.innerHTML=html}}).send({data:this})},"click:relay(.quick_edit)":function(e){e.preventDefault();quickEdit.startEdit(this,this.getParent("tr"))}});quickEdit.addEvents({successAndChange:function(json){var tr=this.wrapElement;tr.getElements("td").each(function(td){var name=td.get("data-column-name");if(!name){return}var a=td.getElement("a");(a?a:td).innerHTML=json[name]||""})},successAndNext:function(json){var tr=this.wrapElement;var nextTr=tr.getNext("tr");if(nextTr){quickEdit.startEdit(nextTr.getElement("a"),nextTr)}else{var platform=tr.getParent(".platform");var loadMore=platform.getElement(".load_more");if(loadMore){trIndex=tr.getParent("tbody").getElements("tr").indexOf(tr);updatePlatform(loadMore.get("href"),platform,function(){platform.getElements("tbody tr").each(function(newTr,index){if(trIndex===index){nextTr=newTr.getNext("tr");quickEdit.startEdit(nextTr.getElement("a"),nextTr)}})})}else{nextTr=platform.getElements("tbody tr")[0];quickEdit.startEdit(nextTr.getElement("a"),nextTr)}}}})}else{if(main_form){$$(".wysiwyg").each(function(elem){wysiwyg.push(elem.mooEditable())});main_form.addEvents({"click:relay(.quick_edit)":function(e){e.preventDefault();quickEdit.startEdit(this,this)}});quickEdit.addEvents({successAndChange:function(json){this.wrapElement.set("text",json.to_bhf_s||"")},successAndNext:function(json){var a=this.wrapElement;var li=a.getParent("li");if(!li){this.close();return}var holder=li.getNext("li");if(!holder){holder=li.getParent("ul")}quickEdit.startEdit(holder.getElement("a"))}})}}setTimeout(function(){var fm=$("flash_massages");if(fm){fm.fade("out")}},4000);new BrowserUpdate({vs:{i:8,f:3,o:10.01,s:2,n:9}})});
|
1149
|
+
Locale.define("EU","Number",{decimal:",",group:".",currency:{prefix:"€ "}});Locale.define("de-DE").inherit("EU","Number");(function($){window.rails={applyEvents:function(el){el=$(el||document.body);var apply=function(selector,action,callback){el.getElements(selector).addEvent(action,callback)};apply('form[data-remote="true"]',"submit",rails.handleRemote);apply('a[data-remote="true"], input[data-remote="true"]',"click",rails.handleRemote);apply("a[data-method][data-remote!=true]","click",function(e){e.preventDefault();if(rails.confirmed(this)){var form=new Element("form",{method:"post",action:this.get("href"),styles:{display:"none"}}).inject(this,"after");var methodInput=new Element("input",{type:"hidden",name:"_method",value:this.get("data-method")});var csrfInput=new Element("input",{type:"hidden",name:rails.csrf.param,value:rails.csrf.token});form.adopt(methodInput,csrfInput).submit()}});var noMethodNorRemoteConfirm=":not([data-method]):not([data-remote=true])[data-confirm]";apply("a"+noMethodNorRemoteConfirm+",input"+noMethodNorRemoteConfirm,"click",function(){return rails.confirmed(this)})},getCsrf:function(name){var meta=document.getElement("meta[name=csrf-"+name+"]");return(meta?meta.get("content"):null)},confirmed:function(el){var confirmMessage=el.get("data-confirm");if(confirmMessage&&!confirm(confirmMessage)){return false}return true},disable:function(el){var button=el.get("data-disable-with")?el:el.getElement("[data-disable-with]");if(button){var enableWith=button.get("value");el.addEvent("ajax:complete",function(){button.set({value:enableWith,disabled:false})});button.set({value:button.get("data-disable-with"),disabled:true})}},handleRemote:function(e){e.preventDefault();if(rails.confirmed(this)){this.request=new Request.Rails(this);rails.disable(this);this.request.send()}}};Request.Rails=new Class({Extends:Request,initialize:function(element,options){this.el=element;this.parent(Object.merge({},{method:this.el.get("method")||this.el.get("data-method")||"get",url:this.el.get("action")||this.el.get("href")},options));this.headers.Accept="*/*";this.addRailsEvents()},send:function(options){this.el.fireEvent("ajax:before");if(this.el.get("tag")=="form"){this.options.data=this.el}this.parent(options);this.el.fireEvent("ajax:after",this.xhr)},addRailsEvents:function(){this.addEvent("request",function(){this.el.fireEvent("ajax:loading",this.xhr)});this.addEvent("success",function(){this.el.fireEvent("ajax:success",this.xhr)});this.addEvent("complete",function(){this.el.fireEvent("ajax:complete",this.xhr);this.el.fireEvent("ajax:loaded",this.xhr)});this.addEvent("failure",function(){this.el.fireEvent("ajax:failure",this.xhr)})}})})(document.id);window.addEvent("domready",function(){rails.csrf={token:rails.getCsrf("token"),param:rails.getCsrf("param")};rails.applyEvents()});var BrowserUpdate=new Class({initialize:function(op,test){var b,jsv=5,n=window.navigator;this.op=op||{};this.op.l=op.l||n.language||n.userLanguage||document.documentElement.getAttribute("lang")||"en";this.op.vsakt={i:8,f:3.6,o:10.6,s:5,n:10};this.op.vsdefault={i:6,f:2,o:9.64,s:3,n:10};this.op.vs=op.vs||this.op.vsdefault;for(b in this.op.vsakt){if(this.op.vs[b]>=this.op.vsakt[b]){this.op.vs[b]=this.op.vsdefault[b]}}if(!op.reminder||op.reminder<0.1){this.op.reminder=0}else{this.op.reminder=op.reminder||24}this.op.onshow=op.onshow||function(o){};this.op.url=op.url||"http://browser-update.org/update.html";this.op.pageurl=op.pageurl||window.location.hostname||"unknown";this.op.newwindow=op.newwindow||false;this.op.test=test||op.test||false;if(window.location.hash=="#test-bu"){this.op.test=true}function getBrowser(){var n,v,t,ua=navigator.userAgent,names={i:"Internet Explorer",f:"Firefox",o:"Opera",s:"Apple Safari",n:"Netscape Navigator",c:"Chrome",x:"Other"};if(/like firefox|chromeframe|seamonkey|opera mini|meego|netfront|moblin|maemo|arora|camino|flot|k-meleon|fennec|kazehakase|galeon|android|mobile|iphone|ipod|ipad|symbian|webos/i.test(ua)){n="x"}else{if(/MSIE (\d+\.\d+);/.test(ua)){n="i"}else{if(/Chrome.(\d+\.\d+)/i.test(ua)){n="c"}else{if(/Firefox.(\d+\.\d+)/i.test(ua)){n="f"}else{if(/Version.(\d+.\d+).{0,10}Safari/i.test(ua)){n="s"}else{if(/Safari.(\d+)/i.test(ua)){n="so"}else{if(/Opera.*Version.(\d+\.\d+)/i.test(ua)){n="o"}else{if(/Opera.(\d+\.\d+)/i.test(ua)){n="o"}else{if(/Netscape.(\d+)/i.test(ua)){n="n"}else{return{n:"x",v:0,t:names[n]}}}}}}}}}}if(n=="x"){return{n:"x",v:0,t:names[n]}}v=new Number(RegExp.$1);if(n=="so"){v=((v<100)&&1)||((v<130)&&1.2)||((v<320)&&1.3)||((v<520)&&2)||((v<524)&&3)||((v<526)&&3.2)||4;n="s"}if(n=="i"&&v==7&&window.XDomainRequest){v=8}return{n:n,v:v,t:names[n]+" "+v}}this.op.browser=getBrowser();if(!this.op.test&&(!this.op.browser||!this.op.browser.n||this.op.browser.n=="x"||this.op.browser.n=="c"||document.cookie.indexOf("browserupdateorg=pause")>-1||this.op.browser.v>this.op.vs[this.op.browser.n])){return}if(this.op.reminder>0){var d=new Date(new Date().getTime()+1000*3600*this.op.reminder);document.cookie="browserupdateorg=pause; expires="+d.toGMTString()+"; path=/"}var ll=this.op.l.substr(0,2);var languages="de,en";if(languages.indexOf(ll)!==false){this.op.url="http://browser-update.org/"+ll+"/update.html#"+jsv}var tar="";if(this.op.newwindow){tar=' target="_blank"'}function busprintf(){var args=arguments;var data=args[0];for(var k=1;k<args.length;++k){data=data.replace(/%s/,args[k])}return data}ll=(window.Locale)?Locale.getCurrent().name:"en-US";var t="Your browser (%s) is <b>out of date</b>. It has known <b>security flaws</b> and may <b>not display all features</b> of this and other websites. <a%s>Learn how to update your browser</a>";if(ll=="de-DE"){t="Sie verwenden einen <b>veralteten Browser</b> (%s) mit <b>Sicherheitsschwachstellen</b> und <b>können nicht alle Funktionen dieser Webseite nutzen</b>. <a%s>Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können</a>."}if(op.text){t=op.text}this.op.text=busprintf(t,this.op.browser.t,' href="'+this.op.url+'"'+tar);var div=document.createElement("div");this.op.div=div;div.id="buorg";div.className="buorg";div.innerHTML="<div>"+this.op.text+'<div id="buorgclose">X</div></div>';var sheet=document.createElement("style");var style=".buorg {position:absolute;z-index:111111; width:100%; top:0px; left:0px; border-bottom:1px solid #A29330; background:#FDF2AB no-repeat 10px center url(http://browser-update.org/img/dialog-warning.gif); text-align:left; cursor:pointer; font-family: Arial,Helvetica,sans-serif; color:#000; font-size: 12px;} .buorg div { padding:5px 36px 5px 40px; } .buorg a,.buorg a:visited {color:#E25600; text-decoration: underline;} #buorgclose { position: absolute; right: .5em; top:.2em; height: 20px; width: 12px; font-weight: bold;font-size:14px; padding:0; }";document.body.insertBefore(div,document.body.firstChild);document.getElementsByTagName("head")[0].appendChild(sheet);try{sheet.innerText=style;sheet.innerHTML=style}catch(e){try{sheet.styleSheet.cssText=style}catch(e){return}}var me=this;div.onclick=function(){if(me.op.newwindow){window.open(me.op.url,"_blank")}else{window.location.href=me.op.url}return false};div.getElementsByTagName("a")[0].onclick=function(e){var e=e||window.event;if(e.stopPropagation){e.stopPropagation()}else{e.cancelBubble=true}return true};this.op.bodymt=document.body.style.paddingTop;document.body.style.paddingTop=(div.clientHeight)+"px";document.getElementById("buorgclose").onclick=function(e){var e=e||window.event;if(e.stopPropagation){e.stopPropagation()}else{e.cancelBubble=true}me.op.div.style.display="none";document.body.style.paddingTop=me.op.bodymt;return true};op.onshow(this.op)}});var Ajaxify=new Class({version:0.2,Implements:[Options,Events],options:{events:{loading:{name:"ajax:loading",text:"Loading…"},success:{name:"ajax:success",text:"Changes successfully saved!"},failure:{name:"ajax:failure",text:"Oops, something went wrong…"}},holder:new Element("div#ajax_holder"),fadeOutDuration:2000},initialize:function(_options){this.setOptions(_options);this.holder=this.options.holder},applyEvents:function(el){el=document.id(el||document.body);var apply=function(action,callback){el.getElements('[data-remote="true"]').addEvent(action,callback)};apply(this.options.events.loading.name,this.loading.bind(this));apply(this.options.events.success.name,this.success.bind(this));apply(this.options.events.failure.name,this.failure.bind(this))},loading:function(xhr){this.setMessage("loading",false)},success:function(xhr){this.setMessage("success",true)},failure:function(xhr){this.setMessage("failure",true)},setMessage:function(status,fadeOut){this.holder.set("class",status).set("text",this.options.events[status].text).inject(document.body);if(fadeOut){this.holder.addClass("fadeout");setTimeout(function(){this.holder.dispose()}.bind(this),this.options.fadeOutDuration)}}});var AjaxEdit=new Class({version:0.2,options:{holderParent:document.body},Implements:[Options,Events],holder:new Element("div.quick_edit_holder"),initialize:function(_options){this.setOptions(_options);this.holder.addEvents({"click:relay(.open)":function(e){e.preventDefault();location.href=this.wrapElement.getElement("a").get("href")}.bind(this),"click:relay(.cancel)":function(e){e.preventDefault();this.close()}.bind(this),"click:relay(.save_and_next)":function(e){e.preventDefault();this.submit(["successAndChange","successAndNext"])}.bind(this),"click:relay(.save)":function(e){e.preventDefault();this.submit(["successAndChange"])}.bind(this),"submit:relay(form)":function(e){e.preventDefault();this.submit(["successAndChange"])}.bind(this)})},startEdit:function(element,wrapElement){this.clean();this.wrapElement=wrapElement?wrapElement:element;this.wrapElement.addClass("live_edit");new Request({method:"get",url:element.get("href"),onSuccess:function(html){this.injectForm(html)}.bind(this)}).send()},submit:function(eventNames){var form=this.holder.getElement("form");wysiwyg.each(function(elem){elem.saveContent()});new Request.JSON({method:form.get("method"),url:form.get("action"),onRequest:function(){this.disableButtons()}.bind(this),onFailure:function(invalidForm){this.injectForm(invalidForm.response)}.bind(this),onSuccess:function(json){if(!eventNames.contains("successAndNext")){this.close()}eventNames.each(function(eventName){this.fireEvent(eventName,[json])}.bind(this))}.bind(this)}).send({data:form})},disableButtons:function(){this.holder.getElements(".open, .cancel, .save_and_next, .save").set("disabled","disabled")},clean:function(){document.body.getElements(".live_edit").removeClass("live_edit")},close:function(){this.clean();this.holder.dispose()},injectForm:function(form){this.holder.innerHTML=form;this.holder.inject(this.options.holderParent);this.holder.getElements(".wysiwyg").each(function(elem){wysiwyg.push(elem.mooEditable())})}});(function(){var blockEls=/^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|SCRIPT|NOSCRIPT|STYLE)$/i;var urlRegex=/^(https?|ftp|rmtp|mms):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i;var protectRegex=/<(script|noscript|style)[\u0000-\uFFFF]*?<\/(script|noscript|style)>/g;this.MooEditable=new Class({Implements:[Events,Options],options:{toolbar:true,cleanup:true,paragraphise:true,xhtml:true,semantics:true,actions:"bold italic underline strikethrough | insertunorderedlist insertorderedlist indent outdent | undo redo | createlink unlink | urlimage | toggleview",handleSubmit:true,handleLabel:true,disabled:false,baseCSS:"html{ height: 100%; cursor: text; } body{ font-family: sans-serif; }",extraCSS:"",externalCSS:"",html:'<!DOCTYPE html><html><head><meta charset="UTF-8">{BASEHREF}<style>{BASECSS} {EXTRACSS}</style>{EXTERNALCSS}</head><body></body></html>',rootElement:"p",baseURL:"",dimensions:null},initialize:function(el,options){this.setOptions(options);this.textarea=document.id(el);this.textarea.store("MooEditable",this);this.actions=this.options.actions.clean().split(" ");this.keys={};this.dialogs={};this.protectedElements=[];this.actions.each(function(action){var act=MooEditable.Actions[action];if(!act){return}if(act.options){var key=act.options.shortcut;if(key){this.keys[key]=action}}if(act.dialogs){Object.each(act.dialogs,function(dialog,name){dialog=dialog.attempt(this);dialog.name=action+":"+name;if(typeOf(this.dialogs[action])!="object"){this.dialogs[action]={}}this.dialogs[action][name]=dialog},this)}if(act.events){Object.each(act.events,function(fn,event){this.addEvent(event,fn)},this)}}.bind(this));this.render()},toElement:function(){return this.textarea},render:function(){var self=this;var dimensions=this.options.dimensions||this.textarea.getSize();this.container=new Element("div",{id:(this.textarea.id)?this.textarea.id+"-mooeditable-container":null,"class":"mooeditable-container",styles:{width:dimensions.x}});this.textarea.addClass("mooeditable-textarea").setStyle("height",dimensions.y);this.iframe=new IFrame({"class":"mooeditable-iframe",frameBorder:0,src:'javascript:""',styles:{height:dimensions.y}});this.toolbar=new MooEditable.UI.Toolbar({onItemAction:function(){var args=Array.from(arguments);var item=args[0];self.action(item.name,args)}});this.attach.delay(1,this);if(this.options.handleLabel&&this.textarea.id){$$('label[for="'+this.textarea.id+'"]').addEvent("click",function(e){if(self.mode!="iframe"){return}e.preventDefault();self.focus()})}if(this.options.handleSubmit){this.form=this.textarea.getParent("form");if(!this.form){return}this.form.addEvent("submit",function(){if(self.mode=="iframe"){self.saveContent()}})}this.fireEvent("render",this)},attach:function(){var self=this;this.mode="iframe";this.editorDisabled=false;this.container.wraps(this.textarea);this.textarea.setStyle("display","none");this.iframe.setStyle("display","").inject(this.textarea,"before");Object.each(this.dialogs,function(action,name){Object.each(action,function(dialog){document.id(dialog).inject(self.iframe,"before");var range;dialog.addEvents({open:function(){range=self.selection.getRange();self.editorDisabled=true;self.toolbar.disable(name);self.fireEvent("dialogOpen",this)},close:function(){self.toolbar.enable();self.editorDisabled=false;self.focus();if(range){self.selection.setRange(range)}self.fireEvent("dialogClose",this)}})})});this.win=this.iframe.contentWindow;this.doc=this.win.document;if(Browser.firefox){this.doc.designMode="On"}var docHTML=this.options.html.substitute({BASECSS:this.options.baseCSS,EXTRACSS:this.options.extraCSS,EXTERNALCSS:(this.options.externalCSS)?'<link rel="stylesheet" href="'+this.options.externalCSS+'">':"",BASEHREF:(this.options.baseURL)?'<base href="'+this.options.baseURL+'" />':""});this.doc.open();this.doc.write(docHTML);this.doc.close();(Browser.ie)?this.doc.body.contentEditable=true:this.doc.designMode="On";Object.append(this.win,new Window);Object.append(this.doc,new Document);if(Browser.Element){var winElement=this.win.Element.prototype;for(var method in Element){if(!method.test(/^[A-Z]|\$|prototype|mooEditable/)){winElement[method]=Element.prototype[method]}}}else{document.id(this.doc.body)}this.setContent(this.textarea.get("value"));this.doc.addEvents({mouseup:this.editorMouseUp.bind(this),mousedown:this.editorMouseDown.bind(this),mouseover:this.editorMouseOver.bind(this),mouseout:this.editorMouseOut.bind(this),mouseenter:this.editorMouseEnter.bind(this),mouseleave:this.editorMouseLeave.bind(this),contextmenu:this.editorContextMenu.bind(this),click:this.editorClick.bind(this),dblclick:this.editorDoubleClick.bind(this),keypress:this.editorKeyPress.bind(this),keyup:this.editorKeyUp.bind(this),keydown:this.editorKeyDown.bind(this),focus:this.editorFocus.bind(this),blur:this.editorBlur.bind(this)});this.win.addEvents({focus:this.editorFocus.bind(this),blur:this.editorBlur.bind(this)});["cut","copy","paste"].each(function(event){self.doc.body.addListener(event,self["editor"+event.capitalize()].bind(self))});this.textarea.addEvent("keypress",this.textarea.retrieve("mooeditable:textareaKeyListener",this.keyListener.bind(this)));if(Browser.firefox2){this.doc.addEvent("focus",function(){self.win.fireEvent("focus").focus()})}if(this.doc.addEventListener){this.doc.addEventListener("focus",function(){self.win.fireEvent("focus")},true)}if(!Browser.ie&&!Browser.opera){var styleCSS=function(){self.execute("styleWithCSS",false,false);self.doc.removeEvent("focus",styleCSS)};this.win.addEvent("focus",styleCSS)}if(this.options.toolbar){document.id(this.toolbar).inject(this.container,"top");this.toolbar.render(this.actions)}if(this.options.disabled){this.disable()}this.selection=new MooEditable.Selection(this.win);this.oldContent=this.getContent();this.fireEvent("attach",this);return this},detach:function(){this.saveContent();this.textarea.setStyle("display","").removeClass("mooeditable-textarea").inject(this.container,"before");this.textarea.removeEvent("keypress",this.textarea.retrieve("mooeditable:textareaKeyListener"));this.container.dispose();this.fireEvent("detach",this);return this},enable:function(){this.editorDisabled=false;this.toolbar.enable();return this},disable:function(){this.editorDisabled=true;this.toolbar.disable();return this},editorFocus:function(e){this.oldContent="";this.fireEvent("editorFocus",[e,this])},editorBlur:function(e){this.oldContent=this.saveContent().getContent();this.fireEvent("editorBlur",[e,this])},editorMouseUp:function(e){if(this.editorDisabled){e.stop();return}if(this.options.toolbar){this.checkStates()}this.fireEvent("editorMouseUp",[e,this])},editorMouseDown:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseDown",[e,this])},editorMouseOver:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseOver",[e,this])},editorMouseOut:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseOut",[e,this])},editorMouseEnter:function(e){if(this.editorDisabled){e.stop();return}if(this.oldContent&&this.getContent()!=this.oldContent){this.focus();this.fireEvent("editorPaste",[e,this])}this.fireEvent("editorMouseEnter",[e,this])},editorMouseLeave:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseLeave",[e,this])},editorContextMenu:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorContextMenu",[e,this])},editorClick:function(e){if(Browser.safari||Browser.chrome){var el=e.target;if(Element.get(el,"tag")=="img"){if(this.options.baseURL){if(el.getProperty("src").indexOf("http://")==-1){el.setProperty("src",this.options.baseURL+el.getProperty("src"))}}this.selection.selectNode(el);this.checkStates()}}this.fireEvent("editorClick",[e,this])},editorDoubleClick:function(e){this.fireEvent("editorDoubleClick",[e,this])},editorKeyPress:function(e){if(this.editorDisabled){e.stop();return}this.keyListener(e);this.fireEvent("editorKeyPress",[e,this])},editorKeyUp:function(e){if(this.editorDisabled){e.stop();return}var c=e.code;if(this.options.toolbar&&(/^enter|left|up|right|down|delete|backspace$/i.test(e.key)||(c>=33&&c<=36)||c==45||e.meta||e.control)){if(Browser.ie6){clearTimeout(this.checkStatesDelay);this.checkStatesDelay=this.checkStates.delay(500,this)}else{this.checkStates()}}this.fireEvent("editorKeyUp",[e,this])},editorKeyDown:function(e){if(this.editorDisabled){e.stop();return}if(e.key=="enter"){if(this.options.paragraphise){if(e.shift&&(Browser.safari||Browser.chrome)){var s=this.selection;var r=s.getRange();var br=this.doc.createElement("br");r.insertNode(br);r.setStartAfter(br);r.setEndAfter(br);s.setRange(r);if(s.getSelection().focusNode==br.previousSibling){var nbsp=this.doc.createTextNode("\u00a0");var p=br.parentNode;var ns=br.nextSibling;(ns)?p.insertBefore(nbsp,ns):p.appendChild(nbsp);s.selectNode(nbsp);s.collapse(1)}this.win.scrollTo(0,Element.getOffsets(s.getRange().startContainer).y);e.preventDefault()}else{if(Browser.firefox||Browser.safari||Browser.chrome){var node=this.selection.getNode();var isBlock=Element.getParents(node).include(node).some(function(el){return el.nodeName.test(blockEls)});if(!isBlock){this.execute("insertparagraph")}}}}else{if(Browser.ie){var r=this.selection.getRange();var node=this.selection.getNode();if(r&&node.get("tag")!="li"){this.selection.insertContent("<br>");this.selection.collapse(false)}e.preventDefault()}}}if(Browser.opera){var ctrlmeta=e.control||e.meta;if(ctrlmeta&&e.key=="x"){this.fireEvent("editorCut",[e,this])}else{if(ctrlmeta&&e.key=="c"){this.fireEvent("editorCopy",[e,this])}else{if((ctrlmeta&&e.key=="v")||(e.shift&&e.code==45)){this.fireEvent("editorPaste",[e,this])}}}}this.fireEvent("editorKeyDown",[e,this])},editorCut:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorCut",[e,this])},editorCopy:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorCopy",[e,this])},editorPaste:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorPaste",[e,this])},keyListener:function(e){var key=(Browser.Platform.mac)?e.meta:e.control;if(!key||!this.keys[e.key]){return}e.preventDefault();var item=this.toolbar.getItem(this.keys[e.key]);item.action(e)},focus:function(){(this.mode=="iframe"?this.win:this.textarea).focus();this.fireEvent("focus",this);return this},action:function(command,args){var action=MooEditable.Actions[command];if(action.command&&typeOf(action.command)=="function"){action.command.apply(this,args)}else{this.focus();this.execute(command,false,args);if(this.mode=="iframe"){this.checkStates()}}},execute:function(command,param1,param2){if(this.busy){return}this.busy=true;this.doc.execCommand(command,param1,param2);this.saveContent();this.busy=false;return false},toggleView:function(){this.fireEvent("beforeToggleView",this);if(this.mode=="textarea"){this.mode="iframe";this.iframe.setStyle("display","");this.setContent(this.textarea.value);this.textarea.setStyle("display","none")}else{this.saveContent();this.mode="textarea";this.textarea.setStyle("display","");this.iframe.setStyle("display","none")}this.fireEvent("toggleView",this);this.focus.delay(10,this);return this},getContent:function(){var protect=this.protectedElements;var html=this.doc.body.get("html").replace(/<!-- mooeditable:protect:([0-9]+) -->/g,function(a,b){return protect[b.toInt()]});return this.cleanup(this.ensureRootElement(html))},setContent:function(content){var protect=this.protectedElements;content=content.replace(protectRegex,function(a){protect.push(a);return"<!-- mooeditable:protect:"+(protect.length-1)+" -->"});this.doc.body.set("html",this.ensureRootElement(content));return this},saveContent:function(){if(this.mode=="iframe"){this.textarea.set("value",this.getContent())}return this},ensureRootElement:function(val){if(this.options.rootElement){var el=new Element("div",{html:val.trim()});var start=-1;var create=false;var html="";var length=el.childNodes.length;for(var i=0;i<length;i++){var childNode=el.childNodes[i];var nodeName=childNode.nodeName;if(!nodeName.test(blockEls)&&nodeName!=="#comment"){if(nodeName==="#text"){if(childNode.nodeValue.trim()){if(start<0){start=i}html+=childNode.nodeValue}}else{if(start<0){start=i}html+=new Element("div").adopt($(childNode).clone()).get("html")}}else{create=true}if(i==(length-1)){create=true}if(start>=0&&create){var newel=new Element(this.options.rootElement,{html:html});el.replaceChild(newel,el.childNodes[start]);for(var k=start+1;k<i;k++){el.removeChild(el.childNodes[k]);length--;i--;k--}start=-1;create=false;html=""}}val=el.get("html").replace(/\n\n/g,"")}return val},checkStates:function(){var element=this.selection.getNode();if(!element){return}if(typeOf(element)!="element"){return}this.actions.each(function(action){var item=this.toolbar.getItem(action);if(!item){return}item.deactivate();var states=MooEditable.Actions[action]["states"];if(!states){return}if(typeOf(states)=="function"){states.attempt([document.id(element),item],this);return}try{if(this.doc.queryCommandState(action)){item.activate();return}}catch(e){}if(states.tags){var el=element;do{var tag=el.tagName.toLowerCase();if(states.tags.contains(tag)){item.activate(tag);break}}while((el=Element.getParent(el))!=null)}if(states.css){var el=element;do{var found=false;for(var prop in states.css){var css=states.css[prop];if(el.style[prop.camelCase()].contains(css)){item.activate(css);found=true}}if(found||el.tagName.test(blockEls)){break}}while((el=Element.getParent(el))!=null)}}.bind(this))},cleanup:function(source){if(!this.options.cleanup){return source.trim()}do{var oSource=source;if(this.options.baseURL){source=source.replace('="'+this.options.baseURL,'="')}source=source.replace(/<br class\="webkit-block-placeholder">/gi,"<br />");source=source.replace(/<span class="Apple-style-span">(.*)<\/span>/gi,"$1");source=source.replace(/ class="Apple-style-span"/gi,"");source=source.replace(/<span style="">/gi,"");source=source.replace(/<p>\s*<br ?\/?>\s*<\/p>/gi,"<p>\u00a0</p>");source=source.replace(/<p>( |\s)*<\/p>/gi,"<p>\u00a0</p>");if(!this.options.semantics){source=source.replace(/\s*<br ?\/?>\s*<\/p>/gi,"</p>")}if(this.options.xhtml){source=source.replace(/<br>/gi,"<br />")}if(this.options.semantics){if(Browser.ie){source=source.replace(/<li>\s*<div>(.+?)<\/div><\/li>/g,"<li>$1</li>")}if(Browser.safari||Browser.chrome){source=source.replace(/^([\w\s]+.*?)<div>/i,"<p>$1</p><div>");source=source.replace(/<div>(.+?)<\/div>/ig,"<p>$1</p>")}if(!Browser.ie){source=source.replace(/<p>[\s\n]*(<(?:ul|ol)>.*?<\/(?:ul|ol)>)(.*?)<\/p>/ig,"$1<p>$2</p>");source=source.replace(/<\/(ol|ul)>\s*(?!<(?:p|ol|ul|img).*?>)((?:<[^>]*>)?\w.*)$/g,"</$1><p>$2</p>")}source=source.replace(/<br[^>]*><\/p>/g,"</p>");source=source.replace(/<p>\s*(<img[^>]+>)\s*<\/p>/ig,"$1\n");source=source.replace(/<p([^>]*)>(.*?)<\/p>(?!\n)/g,"<p$1>$2</p>\n");source=source.replace(/<\/(ul|ol|p)>(?!\n)/g,"</$1>\n");source=source.replace(/><li>/g,">\n\t<li>");source=source.replace(/([^\n])<\/(ol|ul)>/g,"$1\n</$2>");source=source.replace(/([^\n])<img/ig,"$1\n<img");source=source.replace(/^\s*$/g,"")}source=source.replace(/<br ?\/?>$/gi,"");source=source.replace(/^<br ?\/?>/gi,"");if(this.options.paragraphise){source=source.replace(/(h[1-6]|p|div|address|pre|li|ol|ul|blockquote|center|dl|dt|dd)><br ?\/?>/gi,"$1>")}source=source.replace(/<br ?\/?>\s*<\/(h1|h2|h3|h4|h5|h6|li|p)/gi,"</$1");source=source.replace(/<span style="font-weight: bold;">(.*)<\/span>/gi,"<strong>$1</strong>");source=source.replace(/<span style="font-style: italic;">(.*)<\/span>/gi,"<em>$1</em>");source=source.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>");source=source.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,"<em>$1</em>");source=source.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration: underline;">$1</span>');source=source.replace(/<strong><span style="font-weight: normal;">(.*)<\/span><\/strong>/gi,"$1");source=source.replace(/<em><span style="font-weight: normal;">(.*)<\/span><\/em>/gi,"$1");source=source.replace(/<span style="text-decoration: underline;"><span style="font-weight: normal;">(.*)<\/span><\/span>/gi,"$1");source=source.replace(/<strong style="font-weight: normal;">(.*)<\/strong>/gi,"$1");source=source.replace(/<em style="font-weight: normal;">(.*)<\/em>/gi,"$1");source=source.replace(/<[^> ]*/g,function(match){return match.toLowerCase()});source=source.replace(/<[^>]*>/g,function(match){match=match.replace(/ [^=]+=/g,function(match2){return match2.toLowerCase()});return match});source=source.replace(/<[^!][^>]*>/g,function(match){match=match.replace(/( [^=]+=)([^"][^ >]*)/g,'$1"$2"');return match});if(this.options.xhtml){source=source.replace(/<img([^>]+)(\s*[^\/])>(<\/img>)*/gi,"<img$1$2 />")}source=source.replace(/<p>(?:\s*)<p>/g,"<p>");source=source.replace(/<\/p>\s*<\/p>/g,"</p>");source=source.replace(/<pre[^>]*>.*?<\/pre>/gi,function(match){return match.replace(/<br ?\/?>/gi,"\n")});source=source.trim()}while(source!=oSource);return source}});MooEditable.Selection=new Class({initialize:function(win){this.win=win},getSelection:function(){this.win.focus();return(this.win.getSelection)?this.win.getSelection():this.win.document.selection},getRange:function(){var s=this.getSelection();if(!s){return null}try{return s.rangeCount>0?s.getRangeAt(0):(s.createRange?s.createRange():null)}catch(e){return this.doc.body.createTextRange()}},setRange:function(range){if(range.select){Function.attempt(function(){range.select()})}else{var s=this.getSelection();if(s.addRange){s.removeAllRanges();s.addRange(range)}}},selectNode:function(node,collapse){var r=this.getRange();var s=this.getSelection();if(r.moveToElementText){Function.attempt(function(){r.moveToElementText(node);r.select()})}else{if(s.addRange){collapse?r.selectNodeContents(node):r.selectNode(node);s.removeAllRanges();s.addRange(r)}else{s.setBaseAndExtent(node,0,node,1)}}return node},isCollapsed:function(){var r=this.getRange();if(r.item){return false}return r.boundingWidth==0||this.getSelection().isCollapsed},collapse:function(toStart){var r=this.getRange();var s=this.getSelection();if(r.select){r.collapse(toStart);r.select()}else{toStart?s.collapseToStart():s.collapseToEnd()}},getContent:function(){var r=this.getRange();var body=new Element("body");if(this.isCollapsed()){return""}if(r.cloneContents){body.appendChild(r.cloneContents())}else{if(r.item!=undefined||r.htmlText!=undefined){body.set("html",r.item?r.item(0).outerHTML:r.htmlText)}else{body.set("html",r.toString())}}var content=body.get("html");return content},getText:function(){var r=this.getRange();var s=this.getSelection();return this.isCollapsed()?"":r.text||(s.toString?s.toString():"")},getNode:function(){var r=this.getRange();if(!Browser.ie||Browser.version>=9){var el=null;if(r){el=r.commonAncestorContainer;if(!r.collapsed){if(r.startContainer==r.endContainer){if(r.startOffset-r.endOffset<2){if(r.startContainer.hasChildNodes()){el=r.startContainer.childNodes[r.startOffset]}}}}while(typeOf(el)!="element"){el=el.parentNode}}return document.id(el)}return document.id(r.item?r.item(0):r.parentElement())},insertContent:function(content){if(Browser.ie){var r=this.getRange();if(r.pasteHTML){r.pasteHTML(content);r.collapse(false);r.select()}else{if(r.insertNode){r.deleteContents();if(r.createContextualFragment){r.insertNode(r.createContextualFragment(content))}else{var doc=this.win.document;var fragment=doc.createDocumentFragment();var temp=doc.createElement("div");fragment.appendChild(temp);temp.outerHTML=content;r.insertNode(fragment)}}}}else{this.win.document.execCommand("insertHTML",false,content)}}});var phrases={};MooEditable.Locale={define:function(key,value){if(typeOf(window.Locale)!="null"){return Locale.define("en-US","MooEditable",key,value)}if(typeOf(key)=="object"){Object.merge(phrases,key)}else{phrases[key]=value}},get:function(key){if(typeOf(window.Locale)!="null"){return Locale.get("MooEditable."+key)}return key?phrases[key]:""}};MooEditable.Locale.define({ok:"OK",cancel:"Cancel",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",unorderedList:"Unordered List",orderedList:"Ordered List",indent:"Indent",outdent:"Outdent",undo:"Undo",redo:"Redo",removeHyperlink:"Remove Hyperlink",addHyperlink:"Add Hyperlink",selectTextHyperlink:"Please select the text you wish to hyperlink.",enterURL:"Enter URL",enterImageURL:"Enter image URL",addImage:"Add Image",toggleView:"Toggle View"});MooEditable.UI={};MooEditable.UI.Toolbar=new Class({Implements:[Events,Options],options:{"class":""},initialize:function(options){this.setOptions(options);this.el=new Element("div",{"class":"mooeditable-ui-toolbar "+this.options["class"]});this.items={};this.content=null},toElement:function(){return this.el},render:function(actions){if(this.content){this.el.adopt(this.content)}else{this.content=actions.map(function(action){return(action=="|")?this.addSeparator():this.addItem(action)}.bind(this))}return this},addItem:function(action){var self=this;var act=MooEditable.Actions[action];if(!act){return}var type=act.type||"button";var options=act.options||{};var item=new MooEditable.UI[type.camelCase().capitalize()](Object.append(options,{name:action,"class":action+"-item toolbar-item",title:act.title,onAction:self.itemAction.bind(self)}));this.items[action]=item;document.id(item).inject(this.el);return item},getItem:function(action){return this.items[action]},addSeparator:function(){return new Element("span",{"class":"toolbar-separator"}).inject(this.el)},itemAction:function(){this.fireEvent("itemAction",arguments)},disable:function(except){Object.each(this.items,function(item){(item.name==except)?item.activate():item.deactivate().disable()});return this},enable:function(){Object.each(this.items,function(item){item.enable()});return this},show:function(){this.el.setStyle("display","");return this},hide:function(){this.el.setStyle("display","none");return this}});MooEditable.UI.Button=new Class({Implements:[Events,Options],options:{title:"",name:"",text:"Button","class":"",shortcut:"",mode:"icon"},initialize:function(options){this.setOptions(options);this.name=this.options.name;this.render()},toElement:function(){return this.el},render:function(){var self=this;var key=(Browser.Platform.mac)?"Cmd":"Ctrl";var shortcut=(this.options.shortcut)?" ( "+key+"+"+this.options.shortcut.toUpperCase()+" )":"";var text=this.options.title||name;var title=text+shortcut;this.el=new Element("button",{"class":"mooeditable-ui-button "+self.options["class"],title:title,html:'<span class="button-icon"></span><span class="button-text">'+text+"</span>",events:{click:self.click.bind(self),mousedown:function(e){e.preventDefault()}}});if(this.options.mode!="icon"){this.el.addClass("mooeditable-ui-button-"+this.options.mode)}this.active=false;this.disabled=false;if(Browser.ie){this.el.addEvents({mouseenter:function(e){this.addClass("hover")},mouseleave:function(e){this.removeClass("hover")}})}return this},click:function(e){e.preventDefault();if(this.disabled){return}this.action(e)},action:function(){this.fireEvent("action",[this].concat(Array.from(arguments)))},enable:function(){if(this.active){this.el.removeClass("onActive")}if(!this.disabled){return}this.disabled=false;this.el.removeClass("disabled").set({disabled:false,opacity:1});return this},disable:function(){if(this.disabled){return}this.disabled=true;this.el.addClass("disabled").set({disabled:true,opacity:0.4});return this},activate:function(){if(this.disabled){return}this.active=true;this.el.addClass("onActive");return this},deactivate:function(){this.active=false;this.el.removeClass("onActive");return this}});MooEditable.UI.Dialog=new Class({Implements:[Events,Options],options:{"class":"",contentClass:""},initialize:function(html,options){this.setOptions(options);this.html=html;var self=this;this.el=new Element("div",{"class":"mooeditable-ui-dialog "+self.options["class"],html:'<div class="dialog-content '+self.options.contentClass+'">'+html+"</div>",styles:{display:"none"},events:{click:self.click.bind(self)}})},toElement:function(){return this.el},click:function(){this.fireEvent("click",arguments);return this},open:function(){this.el.setStyle("display","");this.fireEvent("open",this);return this},close:function(){this.el.setStyle("display","none");this.fireEvent("close",this);return this}});MooEditable.UI.AlertDialog=function(alertText){if(!alertText){return}var html=alertText+' <button class="dialog-ok-button">'+MooEditable.Locale.get("ok")+"</button>";return new MooEditable.UI.Dialog(html,{"class":"mooeditable-alert-dialog",onOpen:function(){var button=this.el.getElement(".dialog-ok-button");(function(){button.focus()}).delay(10)},onClick:function(e){e.preventDefault();if(e.target.tagName.toLowerCase()!="button"){return}if(document.id(e.target).hasClass("dialog-ok-button")){this.close()}}})};MooEditable.UI.PromptDialog=function(questionText,answerText,fn){if(!questionText){return}var html='<label class="dialog-label">'+questionText+' <input type="text" class="text dialog-input" value="'+answerText+'"></label> <button class="dialog-button dialog-ok-button">'+MooEditable.Locale.get("ok")+'</button><button class="dialog-button dialog-cancel-button">'+MooEditable.Locale.get("cancel")+"</button>";return new MooEditable.UI.Dialog(html,{"class":"mooeditable-prompt-dialog",onOpen:function(){var input=this.el.getElement(".dialog-input");(function(){input.focus();input.select()}).delay(10)},onClick:function(e){e.preventDefault();if(e.target.tagName.toLowerCase()!="button"){return}var button=document.id(e.target);var input=this.el.getElement(".dialog-input");if(button.hasClass("dialog-cancel-button")){input.set("value",answerText);this.close()}else{if(button.hasClass("dialog-ok-button")){var answer=input.get("value");input.set("value",answerText);this.close();if(fn){fn.attempt(answer,this)}}}}})};MooEditable.Actions={bold:{title:MooEditable.Locale.get("bold"),options:{shortcut:"b"},states:{tags:["b","strong"],css:{"font-weight":"bold"}},events:{beforeToggleView:function(){if(Browser.firefox){var value=this.textarea.get("value");var newValue=value.replace(/<strong([^>]*)>/gi,"<b$1>").replace(/<\/strong>/gi,"</b>");if(value!=newValue){this.textarea.set("value",newValue)}}},attach:function(){if(Browser.firefox){var value=this.textarea.get("value");var newValue=value.replace(/<strong([^>]*)>/gi,"<b$1>").replace(/<\/strong>/gi,"</b>");if(value!=newValue){this.textarea.set("value",newValue);this.setContent(newValue)}}}}},italic:{title:MooEditable.Locale.get("italic"),options:{shortcut:"i"},states:{tags:["i","em"],css:{"font-style":"italic"}},events:{beforeToggleView:function(){if(Browser.firefox){var value=this.textarea.get("value");var newValue=value.replace(/<embed([^>]*)>/gi,"<tmpembed$1>").replace(/<em([^>]*)>/gi,"<i$1>").replace(/<tmpembed([^>]*)>/gi,"<embed$1>").replace(/<\/em>/gi,"</i>");if(value!=newValue){this.textarea.set("value",newValue)}}},attach:function(){if(Browser.firefox){var value=this.textarea.get("value");var newValue=value.replace(/<embed([^>]*)>/gi,"<tmpembed$1>").replace(/<em([^>]*)>/gi,"<i$1>").replace(/<tmpembed([^>]*)>/gi,"<embed$1>").replace(/<\/em>/gi,"</i>");if(value!=newValue){this.textarea.set("value",newValue);this.setContent(newValue)}}}}},underline:{title:MooEditable.Locale.get("underline"),options:{shortcut:"u"},states:{tags:["u"],css:{"text-decoration":"underline"}}},strikethrough:{title:MooEditable.Locale.get("strikethrough"),options:{shortcut:"s"},states:{tags:["s","strike"],css:{"text-decoration":"line-through"}}},insertunorderedlist:{title:MooEditable.Locale.get("unorderedList"),states:{tags:["ul"]}},insertorderedlist:{title:MooEditable.Locale.get("orderedList"),states:{tags:["ol"]}},indent:{title:MooEditable.Locale.get("indent"),states:{tags:["blockquote"]}},outdent:{title:MooEditable.Locale.get("outdent")},undo:{title:MooEditable.Locale.get("undo"),options:{shortcut:"z"}},redo:{title:MooEditable.Locale.get("redo"),options:{shortcut:"y"}},unlink:{title:MooEditable.Locale.get("removeHyperlink")},createlink:{title:MooEditable.Locale.get("addHyperlink"),options:{shortcut:"l"},states:{tags:["a"]},dialogs:{alert:MooEditable.UI.AlertDialog.pass(MooEditable.Locale.get("selectTextHyperlink")),prompt:function(editor){return MooEditable.UI.PromptDialog(MooEditable.Locale.get("enterURL"),"http://",function(url){editor.execute("createlink",false,url.trim())})}},command:function(){var selection=this.selection;var dialogs=this.dialogs.createlink;if(selection.isCollapsed()){var node=selection.getNode();if(node.get("tag")=="a"&&node.get("href")){selection.selectNode(node);var prompt=dialogs.prompt;prompt.el.getElement(".dialog-input").set("value",node.get("href"));prompt.open()}else{dialogs.alert.open()}}else{var text=selection.getText();var prompt=dialogs.prompt;if(urlRegex.test(text)){prompt.el.getElement(".dialog-input").set("value",text)}prompt.open()}}},urlimage:{title:MooEditable.Locale.get("addImage"),options:{shortcut:"m"},dialogs:{prompt:function(editor){return MooEditable.UI.PromptDialog(MooEditable.Locale.get("enterImageURL"),"http://",function(url){editor.execute("insertimage",false,url.trim())})}},command:function(){this.dialogs.urlimage.prompt.open()}},toggleview:{title:MooEditable.Locale.get("toggleView"),command:function(){(this.mode=="textarea")?this.toolbar.enable():this.toolbar.disable("toggleview");this.toggleView()}}};MooEditable.Actions.Settings={};Element.Properties.mooeditable={get:function(){return this.retrieve("MooEditable")}};Element.implement({mooEditable:function(options){var mooeditable=this.get("mooeditable");if(!mooeditable){mooeditable=new MooEditable(this,options)}return mooeditable}})})();var wysiwyg=[];window.addEvent("domready",function(){var quickEdit=new AjaxEdit({holderParent:$("content")});var platforms=document.body.getElements(".platform");var main_form=document.id("main_form");if(platforms.length){var updatePlatform=function(href,platform,callback){new Request({method:"get",url:href,onSuccess:function(html){platform.innerHTML=html;if(callback){callback.call()}}}).send()};platforms.addEvents({"click:relay(.pagination a, thead a)":function(e){e.preventDefault();updatePlatform(this.get("href"),this.getParent(".platform"))},"submit:relay(.search)":function(e){e.preventDefault();var parent=this.getParent(".platform");new Request({method:"get",url:this.get("action"),onSuccess:function(html){parent.innerHTML=html}}).send({data:this})},"click:relay(.quick_edit)":function(e){e.preventDefault();quickEdit.startEdit(this,this.getParent("tr"))},"ajax:complete:relay(a[data-method=delete][data-remote])":function(e){e.preventDefault();this.getParent("tr").dispose()}});quickEdit.addEvents({successAndChange:function(json){var tr=this.wrapElement;tr.getElements("td").each(function(td){var name=td.get("data-column-name");if(!name){return}var a=td.getElement("a");(a?a:td).innerHTML=json[name]||""})},successAndNext:function(json){var tr=this.wrapElement;var nextTr=tr.getNext("tr");if(nextTr){quickEdit.startEdit(nextTr.getElement("a"),nextTr)}else{var platform=tr.getParent(".platform");var loadMore=platform.getElement(".load_more");if(loadMore){trIndex=tr.getParent("tbody").getElements("tr").indexOf(tr);updatePlatform(loadMore.get("href"),platform,function(){platform.getElements("tbody tr").each(function(newTr,index){if(trIndex===index){nextTr=newTr.getNext("tr");quickEdit.startEdit(nextTr.getElement("a"),nextTr)}})})}else{nextTr=platform.getElements("tbody tr")[0];quickEdit.startEdit(nextTr.getElement("a"),nextTr)}}}})}else{if(main_form){$$(".wysiwyg").each(function(elem){wysiwyg.push(elem.mooEditable())});main_form.addEvents({"click:relay(.quick_edit)":function(e){e.preventDefault();quickEdit.startEdit(this,this)}});quickEdit.addEvents({successAndChange:function(json){this.wrapElement.set("text",json.to_bhf_s||"")},successAndNext:function(json){var a=this.wrapElement;var li=a.getParent("li");if(!li){this.close();return}var holder=li.getNext("li");if(!holder){holder=li.getParent("ul")}quickEdit.startEdit(holder.getElement("a"))}})}}setTimeout(function(){var fm=$("flash_massages");if(fm){fm.fade("out")}},4000);new BrowserUpdate({vs:{i:8,f:3,o:10.01,s:2,n:9}})});
|