antw-kin 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +21 -0
- data/LICENSE +19 -0
- data/Rakefile +64 -0
- data/VERSION.yml +4 -0
- data/lib/kin.rb +41 -0
- data/lib/kin/assets/javascripts/kin.js +260 -0
- data/lib/kin/assets/stylesheets/_forms.sass +255 -0
- data/lib/kin/assets/stylesheets/_modal.sass +67 -0
- data/lib/kin/configurable.rb +40 -0
- data/lib/kin/core_ext/date.rb +24 -0
- data/lib/kin/core_ext/string.rb +24 -0
- data/lib/kin/core_ext/time.rb +17 -0
- data/lib/kin/form_builder.rb +215 -0
- data/lib/kin/masthead.rb +223 -0
- data/lib/kin/merbtasks.rb +0 -0
- data/lib/kin/nav.rb +337 -0
- data/lib/kin/nav/builder.rb +172 -0
- data/lib/kin/nav/formatters.rb +116 -0
- data/lib/kin/nav/helper_mixin.rb +54 -0
- data/lib/kin/tasks/sync_assets.rb +48 -0
- data/spec/configurable_spec.rb +47 -0
- data/spec/core_ext/date_spec.rb +29 -0
- data/spec/core_ext/string_spec.rb +43 -0
- data/spec/core_ext/time_spec.rb +75 -0
- data/spec/fixture/app/controllers/application.rb +2 -0
- data/spec/fixture/app/controllers/exceptions.rb +13 -0
- data/spec/fixture/app/controllers/form_builder_specs.rb +3 -0
- data/spec/fixture/app/controllers/masthead_specs.rb +3 -0
- data/spec/fixture/app/controllers/nav_specs.rb +2 -0
- data/spec/fixture/app/controllers/spec_controller.rb +12 -0
- data/spec/fixture/app/helpers/global_helpers.rb +7 -0
- data/spec/fixture/app/models/fake_model.rb +19 -0
- data/spec/fixture/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/spec/fixture/app/views/exceptions/not_found.html.erb +47 -0
- data/spec/fixture/app/views/form_builder_specs/bound_date_field.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_date_field_disabled.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_date_field_with_error.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_date_field_with_label.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_date_field_with_value.html.haml +5 -0
- data/spec/fixture/app/views/form_builder_specs/bound_datetime_field.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_datetime_field_disabled.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_datetime_field_with_error.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_datetime_field_with_label.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_datetime_field_with_value.html.haml +5 -0
- data/spec/fixture/app/views/form_builder_specs/bound_time_field.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_time_field_disabled.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_time_field_with_error.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_time_field_with_label.html.haml +2 -0
- data/spec/fixture/app/views/form_builder_specs/bound_time_field_with_value.html.haml +5 -0
- data/spec/fixture/app/views/form_builder_specs/date_field.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/date_field_with_label.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/datetime_field.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/datetime_field_disabled.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/datetime_field_with_classes.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/datetime_field_with_date_value.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/datetime_field_with_datetime_value.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/datetime_field_with_label.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/datetime_field_with_time_value.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/label.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/label_with_note.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/label_with_note_in_parens.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/label_with_requirement.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/time_field.html.haml +1 -0
- data/spec/fixture/app/views/form_builder_specs/time_field_with_label.html.haml +1 -0
- data/spec/fixture/app/views/layout/application.html.erb +12 -0
- data/spec/fixture/app/views/layout/masthead.html.haml +1 -0
- data/spec/fixture/app/views/masthead_specs/all.html.haml +5 -0
- data/spec/fixture/app/views/masthead_specs/border.html.haml +2 -0
- data/spec/fixture/app/views/masthead_specs/escaping.html.haml +5 -0
- data/spec/fixture/app/views/masthead_specs/no_border.html.haml +2 -0
- data/spec/fixture/app/views/masthead_specs/no_extras.html.haml +3 -0
- data/spec/fixture/app/views/masthead_specs/no_subtitles.html.haml +3 -0
- data/spec/fixture/app/views/masthead_specs/right_subtitle.html.haml +2 -0
- data/spec/fixture/app/views/masthead_specs/right_title.html.haml +2 -0
- data/spec/fixture/app/views/masthead_specs/subtitle.html.haml +2 -0
- data/spec/fixture/app/views/masthead_specs/with_css_classes.html.haml +5 -0
- data/spec/fixture/app/views/masthead_specs/with_links.html.haml +5 -0
- data/spec/fixture/app/views/masthead_specs/with_no_escape.html.haml +4 -0
- data/spec/fixture/app/views/nav_specs/_guarded.html.haml +11 -0
- data/spec/fixture/app/views/nav_specs/active.html.haml +19 -0
- data/spec/fixture/app/views/nav_specs/content_injection.html.haml +6 -0
- data/spec/fixture/app/views/nav_specs/escaped_content_injection.html.haml +6 -0
- data/spec/fixture/app/views/nav_specs/generic_nav.html.haml +7 -0
- data/spec/fixture/app/views/nav_specs/guard_with_all_params.html.haml +2 -0
- data/spec/fixture/app/views/nav_specs/guard_with_single_param.html.haml +2 -0
- data/spec/fixture/app/views/nav_specs/guard_without_param.html.haml +2 -0
- data/spec/fixture/app/views/nav_specs/item_with_title.html.haml +8 -0
- data/spec/fixture/app/views/nav_specs/item_without_title.html.haml +6 -0
- data/spec/fixture/app/views/nav_specs/multiple_injection.html.haml +6 -0
- data/spec/fixture/app/views/nav_specs/resource_url.html.haml +7 -0
- data/spec/fixture/app/views/nav_specs/resource_url_without_resource.html.haml +7 -0
- data/spec/fixture/app/views/nav_specs/show_resource_url.html.haml +7 -0
- data/spec/fixture/app/views/nav_specs/with_custom_formatter.html.haml +7 -0
- data/spec/fixture/config/environments/development.rb +15 -0
- data/spec/fixture/config/environments/production.rb +10 -0
- data/spec/fixture/config/environments/rake.rb +11 -0
- data/spec/fixture/config/environments/staging.rb +10 -0
- data/spec/fixture/config/environments/test.rb +12 -0
- data/spec/fixture/config/init.rb +19 -0
- data/spec/fixture/config/rack.rb +11 -0
- data/spec/fixture/config/router.rb +41 -0
- data/spec/fixture/public/images/merb.jpg +0 -0
- data/spec/fixture/public/stylesheets/master.css +119 -0
- data/spec/form_builder_spec.rb +507 -0
- data/spec/masthead_spec.rb +228 -0
- data/spec/nav_spec.rb +358 -0
- data/spec/spec_helper.rb +37 -0
- metadata +183 -0
data/CHANGELOG
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
== 0.3.1 2009-08-26
|
|
2
|
+
|
|
3
|
+
* When setting on which controller and actions a nav item can be active, you
|
|
4
|
+
may use a glob for the action: 'home/{dashboard,accounts,users}'.
|
|
5
|
+
|
|
6
|
+
== 0.3.0 2009-08-25
|
|
7
|
+
|
|
8
|
+
* Kin::Nav now figures out which tab is active depending on the current
|
|
9
|
+
controller and action (see fixture/active.html.haml).
|
|
10
|
+
|
|
11
|
+
== 0.2.0 2009-08-22
|
|
12
|
+
|
|
13
|
+
* Renamed gem from Potion to Kin.
|
|
14
|
+
* Added kin.js from Torque project.
|
|
15
|
+
* SASS stylesheets will no longer be added to the SASS load path, rather you
|
|
16
|
+
should use `rake kin:copy_assets` to copy Kin's SASS and javascripts to your
|
|
17
|
+
application.
|
|
18
|
+
* Navigation configuration will be autoloaded from navigation.rb in your
|
|
19
|
+
application's config directory (Merb.dir_for(:config)).
|
|
20
|
+
* Added Kin::Configurable which replaces application-specific #config and
|
|
21
|
+
#configure methods.
|
data/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2009 Anthony Williams
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'spec/rake/spectask'
|
|
3
|
+
|
|
4
|
+
require 'merb-core'
|
|
5
|
+
require 'merb-core/tasks/merb'
|
|
6
|
+
|
|
7
|
+
begin
|
|
8
|
+
require 'jeweler'
|
|
9
|
+
Jeweler::Tasks.new do |s|
|
|
10
|
+
s.name = 'kin'
|
|
11
|
+
s.platform = Gem::Platform::RUBY
|
|
12
|
+
s.has_rdoc = false
|
|
13
|
+
s.summary = 'Components commonly used in Showcase which can be ' +
|
|
14
|
+
'applied to other projects.'
|
|
15
|
+
s.description = s.summary
|
|
16
|
+
s.author = 'Anthony Williams'
|
|
17
|
+
s.email = 'anthony@ninecraft.com'
|
|
18
|
+
|
|
19
|
+
s.extra_rdoc_files = ['README', 'CHANGELOG', 'LICENSE']
|
|
20
|
+
|
|
21
|
+
s.files = %w(LICENSE README CHANGELOG Rakefile VERSION.yml) +
|
|
22
|
+
Dir.glob("{lib,spec}/**/*") - %w(spec/merb_test.log)
|
|
23
|
+
end
|
|
24
|
+
rescue LoadError
|
|
25
|
+
puts 'Jeweler not available. Install it with: gem install ' +
|
|
26
|
+
'technicalpickles-jeweler -s http://gems.github.com'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
##############################################################################
|
|
30
|
+
# rSpec & rcov
|
|
31
|
+
##############################################################################
|
|
32
|
+
|
|
33
|
+
desc "Run all examples (or a specific spec with TASK=xxxx)"
|
|
34
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
|
35
|
+
t.spec_opts = ["-c -f s"]
|
|
36
|
+
t.spec_files = begin
|
|
37
|
+
if ENV["TASK"]
|
|
38
|
+
ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
|
|
39
|
+
else
|
|
40
|
+
FileList['spec/**/*_spec.rb']
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
desc "Run all examples with RCov"
|
|
46
|
+
Spec::Rake::SpecTask.new('spec:rcov') do |t|
|
|
47
|
+
t.spec_files = FileList['spec/**/*.rb']
|
|
48
|
+
t.spec_opts = ['-c -f s']
|
|
49
|
+
t.rcov = true
|
|
50
|
+
t.rcov_opts = ['--exclude', 'spec']
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
##############################################################################
|
|
54
|
+
# YARD Documentation
|
|
55
|
+
##############################################################################
|
|
56
|
+
|
|
57
|
+
begin
|
|
58
|
+
require 'yard'
|
|
59
|
+
YARD::Rake::YardocTask.new do |t|
|
|
60
|
+
t.files = %w( CHANGELOG LICENSE lib/**/*.rb )
|
|
61
|
+
end
|
|
62
|
+
rescue LoadError
|
|
63
|
+
puts 'Yardoc not available. Install it with: gem install yardoc'
|
|
64
|
+
end
|
data/VERSION.yml
ADDED
data/lib/kin.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'merb-helpers'
|
|
2
|
+
|
|
3
|
+
# Make sure we're running inside Merb.
|
|
4
|
+
if defined?(Merb::Plugins)
|
|
5
|
+
kin = File.expand_path(File.join(File.dirname(__FILE__), 'kin'))
|
|
6
|
+
|
|
7
|
+
require File.join(kin, 'core_ext', 'date')
|
|
8
|
+
require File.join(kin, 'core_ext', 'string')
|
|
9
|
+
require File.join(kin, 'core_ext', 'time')
|
|
10
|
+
|
|
11
|
+
require File.join(kin, 'configurable')
|
|
12
|
+
require File.join(kin, 'form_builder')
|
|
13
|
+
require File.join(kin, 'masthead')
|
|
14
|
+
require File.join(kin, 'nav')
|
|
15
|
+
|
|
16
|
+
Merb::Plugins.add_rakefiles(File.join(kin, 'tasks', 'sync_assets'))
|
|
17
|
+
|
|
18
|
+
# Default nav formatter. Can be overridden in an after_app_loads block, or
|
|
19
|
+
# on a case-by-case basis in +display_navigation+.
|
|
20
|
+
Merb::Plugins.config[:kin] = { :nav_formatter => Kin::Nav::BasicFormatter }
|
|
21
|
+
|
|
22
|
+
Merb::BootLoader.after_app_loads do
|
|
23
|
+
# Add default time formats.
|
|
24
|
+
unless Time.formats.include?(:full)
|
|
25
|
+
Time.add_format(:full, '%A %d %B, %H:%M')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
unless Time.formats.include?(:date_only)
|
|
29
|
+
Time.add_format(:date_only, '%A %d %B')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
unless Time.formats.include?(:date_with_year)
|
|
33
|
+
Time.add_format(:date_with_year, '%d %B %Y')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# After the application loads, see if there is a config/navigation.rb file
|
|
37
|
+
# to initialize the nav instances.
|
|
38
|
+
nav_rb = File.join(Merb.dir_for(:config), 'navigation.rb')
|
|
39
|
+
load(nav_rb) if File.exists?(nav_rb)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// Copyright (c) 2009 Anthony Williams, Torque
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
+
// copy of this software and associated documentation files (the "Software"),
|
|
5
|
+
// to deal in the Software without restriction, including without limitation
|
|
6
|
+
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
7
|
+
// and/or sell copies of the Software, and to permit persons to whom the
|
|
8
|
+
// Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
19
|
+
// DEALINGS IN THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
// This file is placed here by the kin:copy_assets rake task and will be
|
|
22
|
+
// overwritten whenever that task is run. Do not edit this file directly.
|
|
23
|
+
|
|
24
|
+
(function() {
|
|
25
|
+
|
|
26
|
+
var R_ISO_8601 = new RegExp(
|
|
27
|
+
"(\\d\\d\\d\\d)(-)?" + // YYYY capture:1-2
|
|
28
|
+
"(\\d\\d)(-)?" + // MM capture:3-4
|
|
29
|
+
"(\\d\\d)" + // DD capture:5
|
|
30
|
+
"(T)?(\\d\\d)(:)?" + // HH capture:6-8
|
|
31
|
+
"(\\d\\d)(:)?" + // MM capture:9-10
|
|
32
|
+
"(\\d\\d)(\.\\d+)?" + // SS capture:11-12
|
|
33
|
+
"(Z|([+-])" + // Zulu or Timezone capture:13-14
|
|
34
|
+
"(\\d\\d)(:)?(\\d\\d))" // HH::MM capture:15-17
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
Date.fromISO8601 = function (isoString) {
|
|
38
|
+
var match = isoString.match(R_ISO_8601),
|
|
39
|
+
date = new Date(),
|
|
40
|
+
offset = 0;
|
|
41
|
+
|
|
42
|
+
if (! match)
|
|
43
|
+
return NaN;
|
|
44
|
+
|
|
45
|
+
date.setUTCDate(1);
|
|
46
|
+
date.setUTCFullYear(match[1].toInt());
|
|
47
|
+
date.setUTCMonth(match[3].toInt() - 1);
|
|
48
|
+
date.setUTCDate(match[5].toInt());
|
|
49
|
+
date.setUTCHours(match[7].toInt());
|
|
50
|
+
date.setUTCMinutes(match[9].toInt());
|
|
51
|
+
date.setUTCSeconds(match[11].toInt());
|
|
52
|
+
|
|
53
|
+
if(match[12]) {
|
|
54
|
+
date.setUTCMilliseconds(match[12].toFloat() * 100);
|
|
55
|
+
} else {
|
|
56
|
+
date.setUTCMilliseconds(0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (match[13] != 'Z') {
|
|
60
|
+
offset = (match[15].toInt() * 60) + match[17].toInt();
|
|
61
|
+
offset *= ((match[14] == '-') ? -1 : 1);
|
|
62
|
+
date.setTime(date.getTime() - offset * 60 * 1000);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return date;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
})();
|
|
69
|
+
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
var Kin = {};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a button.
|
|
76
|
+
*/
|
|
77
|
+
Kin.Button = new Class({
|
|
78
|
+
Implements: [Options, Element.ToElement],
|
|
79
|
+
|
|
80
|
+
options: {
|
|
81
|
+
// Main buttons are shown in blue.
|
|
82
|
+
main: false,
|
|
83
|
+
// An optional icon name to be added (as a CSS class).
|
|
84
|
+
icon: false,
|
|
85
|
+
// Right-align the button?
|
|
86
|
+
right: false,
|
|
87
|
+
// Additional CSS classes to add.
|
|
88
|
+
css: ''
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
initialize: function(text, options) {
|
|
92
|
+
this.setOptions(options);
|
|
93
|
+
this.text = text;
|
|
94
|
+
this.tag = 'button';
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
build: function() {
|
|
98
|
+
this.element = new Element(this.tag).addClass('button');
|
|
99
|
+
|
|
100
|
+
if(this.options.css)
|
|
101
|
+
this.element.addClass(this.options.css);
|
|
102
|
+
|
|
103
|
+
if(this.options.main)
|
|
104
|
+
this.element.addClass('blue');
|
|
105
|
+
|
|
106
|
+
if(this.options.right)
|
|
107
|
+
this.element.addClass('right');
|
|
108
|
+
|
|
109
|
+
// If the button has an icon, the text gets wrapped in an 'icon' span,
|
|
110
|
+
// otherwise, the text is added straight to the button itself.
|
|
111
|
+
if(this.options.icon) {
|
|
112
|
+
this.element.adopt(
|
|
113
|
+
new Element('span').set('text', this.text).
|
|
114
|
+
addClass('icon').addClass(this.options.icon)
|
|
115
|
+
);
|
|
116
|
+
} else {
|
|
117
|
+
this.element.set('text', this.text);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return this.element;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Creates a link which looks like a button.
|
|
126
|
+
*/
|
|
127
|
+
Kin.Button.Link = new Class({
|
|
128
|
+
Extends: Kin.Button,
|
|
129
|
+
|
|
130
|
+
initialize: function(text, url, options) {
|
|
131
|
+
this.parent(text, options);
|
|
132
|
+
this.tag = 'a';
|
|
133
|
+
this.url = url;
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
build: function() {
|
|
137
|
+
return this.parent().set('href', this.url);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Creates a modal dialog.
|
|
145
|
+
*/
|
|
146
|
+
Kin.Dialog = new Class({
|
|
147
|
+
Extends: StickyWin.Modal.Ajax,
|
|
148
|
+
|
|
149
|
+
options: {
|
|
150
|
+
requestOptions: {
|
|
151
|
+
method: 'get',
|
|
152
|
+
evalScripts: false
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
handleResponse: function(data) {
|
|
156
|
+
this.Request.response.text.stripScripts();
|
|
157
|
+
|
|
158
|
+
this.content = this.transform(data);
|
|
159
|
+
this.setContent(new Kin.Dialog.UI(this).build());
|
|
160
|
+
this.show();
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
closeOnEsc: true
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
initialize: function(options) {
|
|
167
|
+
options = $merge(options || {}, {
|
|
168
|
+
modalOptions: {
|
|
169
|
+
modalStyle: {
|
|
170
|
+
'background-color': '#000',
|
|
171
|
+
'opacity': 0.7
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
this.parent(options);
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
createRequest: function(){
|
|
180
|
+
this.Request = new Request.JSON(this.options.requestOptions)
|
|
181
|
+
this.Request.addEvent('onSuccess', this.options.handleResponse.bind(this));
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
// Provides a hook so that subclasses can transform the returned response
|
|
185
|
+
// data (which is typically JSON) into HTML.
|
|
186
|
+
transform: function(data) {
|
|
187
|
+
return data;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* UI wrapper for Kin dialogs.
|
|
193
|
+
*/
|
|
194
|
+
Kin.Dialog.UI = new Class({
|
|
195
|
+
initialize: function(dialog) {
|
|
196
|
+
this.dialog = dialog;
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
build: function() {
|
|
200
|
+
var hide = function(event) {
|
|
201
|
+
event.stop();
|
|
202
|
+
this.dialog.hide();
|
|
203
|
+
}.bind(this);
|
|
204
|
+
|
|
205
|
+
var wrapper = new Element('div').addClass('modal_shadow');
|
|
206
|
+
this.element = wrapper;
|
|
207
|
+
|
|
208
|
+
var dialog = new Element('div').addClass('dialog');
|
|
209
|
+
wrapper.adopt(dialog);
|
|
210
|
+
|
|
211
|
+
// Create header.
|
|
212
|
+
var top = new Element('div').addClass('top');
|
|
213
|
+
var header = this.buildHeader()
|
|
214
|
+
|
|
215
|
+
// Add close button.
|
|
216
|
+
top.adopt(
|
|
217
|
+
new Element('a').set('href', window.location.href).
|
|
218
|
+
addClass('close').addEvent('click', hide)
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
dialog.adopt(top.adopt(header));
|
|
222
|
+
|
|
223
|
+
// Create main content.
|
|
224
|
+
var content = new Element('div').addClass('content');
|
|
225
|
+
content.adopt(this.buildContent());
|
|
226
|
+
dialog.adopt(content);
|
|
227
|
+
|
|
228
|
+
// Create footer.
|
|
229
|
+
dialog.adopt(new Element('div').addClass('footer'));
|
|
230
|
+
|
|
231
|
+
// Close the dialog if the user clicks on the shadow.
|
|
232
|
+
wrapper.addEvent('click', hide);
|
|
233
|
+
// But not when clicking elsewhere in the dialog.
|
|
234
|
+
dialog.addEvent('click', function(event) {
|
|
235
|
+
event.stopPropagation();
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
return wrapper;
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
buildHeader: function() {
|
|
242
|
+
var title = new Element('span').set('text', this.dialog.title);
|
|
243
|
+
|
|
244
|
+
if(this.dialog.type) {
|
|
245
|
+
title.adopt(new Element('span').addClass('note').
|
|
246
|
+
set('text', ' ' + this.dialog.type));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if(this.dialog.icon) {
|
|
250
|
+
title = new Element('span').addClass('icon').
|
|
251
|
+
addClass(this.dialog.icon).adopt(title);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return new Element('div').addClass('title').adopt(title);
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
buildContent: function() {
|
|
258
|
+
return new Element('div').adopt(this.dialog.content);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// This file is placed here by the kin:copy_assets rake task and will be
|
|
2
|
+
// overwritten whenever that task is run. Do not edit this file directly.
|
|
3
|
+
|
|
4
|
+
// Expects your own stylsheets to define:
|
|
5
|
+
// !width - width of the content area.
|
|
6
|
+
// !link_color - colour of your hyperlinks.
|
|
7
|
+
|
|
8
|
+
// Buttons
|
|
9
|
+
!btn_link_line_height ||= 18px
|
|
10
|
+
!btn_line_height ||= !btn_link_line_height
|
|
11
|
+
!btn_link_padding ||= 3px 11px 3px 12px
|
|
12
|
+
!btn_ie6_padding ||= 2px 11px 1px 12px
|
|
13
|
+
!btn_ie7_padding ||= 2px 11px 1px 12px
|
|
14
|
+
!btn_fx_padding ||= 3px 11px 3px 12px
|
|
15
|
+
|
|
16
|
+
// Tiny Buttons
|
|
17
|
+
!btn_tiny_line_height ||= 15px
|
|
18
|
+
!btn_tiny_link_padding ||= 3px 8px 2px 9px
|
|
19
|
+
!btn_tiny_ie6_padding ||= 2px 8px 0px 9px
|
|
20
|
+
!btn_tiny_ie7_padding ||= 2px 8px 1px 9px
|
|
21
|
+
!btn_tiny_fx_padding ||= 3px 8px 2px 9px
|
|
22
|
+
|
|
23
|
+
!btn_font ||= "\"Lucida Grande\", Arial, sans-serif"
|
|
24
|
+
|
|
25
|
+
!quiet ||= #777
|
|
26
|
+
|
|
27
|
+
form
|
|
28
|
+
label, span.pseudo_label
|
|
29
|
+
:cursor pointer
|
|
30
|
+
:display block
|
|
31
|
+
:font-weight bold
|
|
32
|
+
:line-height 1
|
|
33
|
+
:padding 0 0 8px
|
|
34
|
+
span.req
|
|
35
|
+
:color #c00
|
|
36
|
+
span.note
|
|
37
|
+
+quiet
|
|
38
|
+
+ismall
|
|
39
|
+
:font-weight normal
|
|
40
|
+
:padding-left 5px
|
|
41
|
+
span.pseudo_label
|
|
42
|
+
:cursor default
|
|
43
|
+
ul.form
|
|
44
|
+
:list-style none
|
|
45
|
+
:margin 0
|
|
46
|
+
li
|
|
47
|
+
:padding-bottom 20px
|
|
48
|
+
.description
|
|
49
|
+
+small
|
|
50
|
+
+quiet
|
|
51
|
+
:display block
|
|
52
|
+
:font-weight normal
|
|
53
|
+
:margin 0
|
|
54
|
+
:padding 5px 0 0
|
|
55
|
+
.multiple span.field
|
|
56
|
+
:display block
|
|
57
|
+
:float left
|
|
58
|
+
:padding-right 6px
|
|
59
|
+
|
|
60
|
+
// Fields.
|
|
61
|
+
|
|
62
|
+
input.text, input.password, input.title, textarea
|
|
63
|
+
:background #fff url(../images/form_field.png) top left repeat-x
|
|
64
|
+
:border = !border
|
|
65
|
+
:border-bottom-color #ddd
|
|
66
|
+
:border-top-color #999
|
|
67
|
+
:font-size 1em
|
|
68
|
+
:line-height 1em
|
|
69
|
+
:padding 5px 4px
|
|
70
|
+
&:focus
|
|
71
|
+
:border-color #999
|
|
72
|
+
:border-bottom-color #aaa
|
|
73
|
+
:border-top-color #666
|
|
74
|
+
// :background-color #fffff0
|
|
75
|
+
// Safari focus.
|
|
76
|
+
:outline 0
|
|
77
|
+
&[disabled=disabled]
|
|
78
|
+
:background-color #f9f9f9
|
|
79
|
+
.title input, .title .overTxtDiv
|
|
80
|
+
:font-size 1.25em
|
|
81
|
+
input.wide, input.title, textarea
|
|
82
|
+
:width = !width - 10px
|
|
83
|
+
&.error
|
|
84
|
+
:background-color #fef3f3
|
|
85
|
+
textarea
|
|
86
|
+
:height 6em
|
|
87
|
+
:line-height 1.5
|
|
88
|
+
:margin 0
|
|
89
|
+
.overTxtDiv
|
|
90
|
+
+quiet
|
|
91
|
+
:padding 4px 0 0 2px
|
|
92
|
+
|
|
93
|
+
// Radios.
|
|
94
|
+
|
|
95
|
+
.radios
|
|
96
|
+
label
|
|
97
|
+
:float left
|
|
98
|
+
:font-weight normal
|
|
99
|
+
:padding 3px 0 8px 5px
|
|
100
|
+
:width 628px
|
|
101
|
+
input
|
|
102
|
+
:float left
|
|
103
|
+
:margin 2px
|
|
104
|
+
|
|
105
|
+
// Date fields.
|
|
106
|
+
|
|
107
|
+
li.date
|
|
108
|
+
.at, .timesep
|
|
109
|
+
+quiet
|
|
110
|
+
:padding-top 4px
|
|
111
|
+
.hour, .timesep
|
|
112
|
+
:padding-right 2px
|
|
113
|
+
.datepicker a
|
|
114
|
+
+ismall
|
|
115
|
+
:background url(../images/icons/datepicker.png) 6px 4px no-repeat
|
|
116
|
+
:display block
|
|
117
|
+
:padding 3px 5px 4px 26px
|
|
118
|
+
.datepicker.disabled a
|
|
119
|
+
+quiet
|
|
120
|
+
:background-position 6px -26px
|
|
121
|
+
&:hover
|
|
122
|
+
:cursor default
|
|
123
|
+
:text-decoration none
|
|
124
|
+
|
|
125
|
+
// Buttons.
|
|
126
|
+
form ul.form li.buttons
|
|
127
|
+
:padding-bottom 0
|
|
128
|
+
|
|
129
|
+
.buttons
|
|
130
|
+
:margin 0
|
|
131
|
+
:padding-bottom 0
|
|
132
|
+
button, a
|
|
133
|
+
:background #ecf4f6 url(../images/button.png) repeat-x
|
|
134
|
+
:-moz-border-radius 3px
|
|
135
|
+
:-webkit-border-radius 3px
|
|
136
|
+
:border-radius 3px
|
|
137
|
+
:border 1px solid #999
|
|
138
|
+
:color #222
|
|
139
|
+
:cursor pointer
|
|
140
|
+
:display block
|
|
141
|
+
:float left
|
|
142
|
+
:font-family = !btn_font
|
|
143
|
+
:font-size 1em
|
|
144
|
+
:line-height = !btn_link_line_height
|
|
145
|
+
:margin 0 8px 0 0
|
|
146
|
+
// Links.
|
|
147
|
+
:padding = !btn_link_padding
|
|
148
|
+
:text-decoration none
|
|
149
|
+
&.right
|
|
150
|
+
:float right
|
|
151
|
+
:margin 0 0 0 8px
|
|
152
|
+
&:active
|
|
153
|
+
:background-position 0 -40px
|
|
154
|
+
&:focus
|
|
155
|
+
:border-color #444
|
|
156
|
+
// Safari
|
|
157
|
+
:outline none
|
|
158
|
+
&.blue
|
|
159
|
+
:background-position 0 -80px
|
|
160
|
+
:border-color #2c5b8c
|
|
161
|
+
:color #fff
|
|
162
|
+
:text-shadow 0 -1px 0px #2c5b8c
|
|
163
|
+
&:active
|
|
164
|
+
:background-position 0 -120px
|
|
165
|
+
.icon
|
|
166
|
+
:background-position = 2px (!btn_line_height - 16px)
|
|
167
|
+
:background-repeat no-repeat
|
|
168
|
+
:padding 2px 2px 2px 26px
|
|
169
|
+
button
|
|
170
|
+
:overflow visible
|
|
171
|
+
// IE6.
|
|
172
|
+
:padding = !btn_ie6_padding
|
|
173
|
+
:width auto
|
|
174
|
+
&[class]
|
|
175
|
+
// Firefox.
|
|
176
|
+
:padding = !btn_fx_padding
|
|
177
|
+
// Webkit
|
|
178
|
+
:line-height = !btn_line_height
|
|
179
|
+
*:first-child+html &
|
|
180
|
+
// IE7.
|
|
181
|
+
:padding = !btn_ie7_padding
|
|
182
|
+
&.tiny
|
|
183
|
+
a, button
|
|
184
|
+
+itiny
|
|
185
|
+
:line-height = !btn_tiny_line_height
|
|
186
|
+
:margin-right 6px
|
|
187
|
+
:padding = !btn_tiny_link_padding
|
|
188
|
+
button
|
|
189
|
+
// IE6.
|
|
190
|
+
:padding = !btn_tiny_ie6_padding
|
|
191
|
+
&[class]
|
|
192
|
+
// Firefox.
|
|
193
|
+
:padding = !btn_tiny_fx_padding
|
|
194
|
+
*:first-child+html &
|
|
195
|
+
// IE7.
|
|
196
|
+
:padding = !btn_tiny_ie7_padding
|
|
197
|
+
&, &.tiny
|
|
198
|
+
button
|
|
199
|
+
&[disabled=disabled]
|
|
200
|
+
:cursor default
|
|
201
|
+
:opacity 0.5
|
|
202
|
+
:text-shadow none
|
|
203
|
+
&:active
|
|
204
|
+
:background-position 0 0
|
|
205
|
+
&.blue
|
|
206
|
+
&:active
|
|
207
|
+
:background-position 0 -80px
|
|
208
|
+
&.faux_link
|
|
209
|
+
:background none
|
|
210
|
+
:border-color transparent
|
|
211
|
+
:-moz-box-shadow none
|
|
212
|
+
:-webkit-box-shadow none
|
|
213
|
+
:box-shadow none
|
|
214
|
+
:color = !link_color
|
|
215
|
+
:font-weight normal
|
|
216
|
+
:padding-left 0
|
|
217
|
+
:padding-right 0
|
|
218
|
+
:text-shadow none
|
|
219
|
+
&:hover
|
|
220
|
+
:text-decoration underline
|
|
221
|
+
|
|
222
|
+
// Error messages
|
|
223
|
+
// ---------------------------------------------------------------------------
|
|
224
|
+
|
|
225
|
+
div.wide_notice, #gordon div.notice, div.error
|
|
226
|
+
:background #ecfaff url(../images/icons/information.png) 25px 8px no-repeat
|
|
227
|
+
:border-top 1px solid #d0e4ec
|
|
228
|
+
:border-bottom 1px solid #d0e4ec
|
|
229
|
+
:padding 10px 25px 10px 47px
|
|
230
|
+
:line-height 1
|
|
231
|
+
:margin 0 -25px 25px
|
|
232
|
+
.main
|
|
233
|
+
:display block
|
|
234
|
+
:font-weight bold
|
|
235
|
+
.note
|
|
236
|
+
+small
|
|
237
|
+
:color #626d74
|
|
238
|
+
:display block
|
|
239
|
+
:margin 6px 0 0
|
|
240
|
+
|
|
241
|
+
#gordon
|
|
242
|
+
div.notice
|
|
243
|
+
:background-color #f5fff0
|
|
244
|
+
:background-image url(../images/icons/tick.png)
|
|
245
|
+
:border-color #d7ecd2
|
|
246
|
+
div.error
|
|
247
|
+
:background-color #fff0f0
|
|
248
|
+
:background-image url(../images/icons/cross.png)
|
|
249
|
+
:border-color #ecd2d2
|
|
250
|
+
|
|
251
|
+
div.error
|
|
252
|
+
:background #fffde9 url(/images/icons/exclamation.png) 25px 10px no-repeat
|
|
253
|
+
:border-color #e3e0c4
|
|
254
|
+
ul
|
|
255
|
+
:margin 0
|