lucasefe-multi_helper 0.0.1
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/README.rdoc +11 -0
- data/Rakefile +14 -0
- data/generators/full_layout/full_layout_generator.rb +47 -0
- data/generators/full_layout/templates/_flash_messages.html.haml +6 -0
- data/generators/full_layout/templates/_main_navigation.html.haml +6 -0
- data/generators/full_layout/templates/_secondary_navigation.html.haml +2 -0
- data/generators/full_layout/templates/_sidebar.html.haml +15 -0
- data/generators/full_layout/templates/_theme_switch.html.erb +29 -0
- data/generators/full_layout/templates/_user_navigation.html.erb +10 -0
- data/generators/full_layout/templates/javascripts/jquery-ui.js +273 -0
- data/generators/full_layout/templates/javascripts/jquery.corner.js +178 -0
- data/generators/full_layout/templates/javascripts/jquery.form.js +601 -0
- data/generators/full_layout/templates/javascripts/jquery.js +19 -0
- data/generators/full_layout/templates/javascripts/jquery.livequery.js +250 -0
- data/generators/full_layout/templates/javascripts/jquery.localscroll.js +104 -0
- data/generators/full_layout/templates/javascripts/jquery.scrollTo.js +150 -0
- data/generators/full_layout/templates/javascripts/layout.js +26 -0
- data/generators/full_layout/templates/layout.html.haml +36 -0
- data/generators/full_layout/templates/stylesheets/base.css +282 -0
- data/generators/full_layout/templates/stylesheets/overrides.css +11 -0
- data/generators/full_layout/templates/stylesheets/themes/bec/style.css +279 -0
- data/generators/full_layout/templates/stylesheets/themes/black-grey/style.css +171 -0
- data/generators/full_layout/templates/stylesheets/themes/default/style.css +233 -0
- data/generators/full_scaffold/README +11 -0
- data/generators/full_scaffold/full_scaffold_generator.rb +149 -0
- data/generators/full_scaffold/templates/controller.rb +13 -0
- data/generators/full_scaffold/templates/helper.rb +2 -0
- data/generators/full_scaffold/templates/migration.rb +15 -0
- data/generators/full_scaffold/templates/model.rb +2 -0
- data/generators/full_scaffold/templates/rspec/unit_spec.rb +11 -0
- data/generators/full_scaffold/templates/view__collection.haml +23 -0
- data/generators/full_scaffold/templates/view__form.haml +3 -0
- data/generators/full_scaffold/templates/view__search.haml +11 -0
- data/generators/full_scaffold/templates/view_edit.haml +9 -0
- data/generators/full_scaffold/templates/view_index.haml +8 -0
- data/generators/full_scaffold/templates/view_index.js.haml +1 -0
- data/generators/full_scaffold/templates/view_new.haml +7 -0
- data/generators/full_scaffold/templates/view_show.haml +10 -0
- data/icons/add.png +0 -0
- data/icons/arrow_undo.png +0 -0
- data/icons/cross.png +0 -0
- data/icons/error.png +0 -0
- data/icons/exclamation.png +0 -0
- data/icons/pencil.png +0 -0
- data/icons/tick.png +0 -0
- data/lib/multi_helper.rb +6 -0
- data/lib/multi_helper/form.rb +11 -0
- data/lib/multi_helper/form/README.markdown +119 -0
- data/lib/multi_helper/form/builder.rb +346 -0
- data/lib/multi_helper/form/helper.rb +41 -0
- data/lib/multi_helper/navigation.rb +6 -0
- data/lib/multi_helper/navigation/group.rb +36 -0
- data/lib/multi_helper/navigation/helper.rb +11 -0
- data/lib/multi_helper/navigation/item.rb +27 -0
- data/lib/multi_helper/navigation/renderer.rb +35 -0
- data/lib/multi_helper/vendor/validation_reflection.rb +73 -0
- data/lib/multi_helper/view.rb +49 -0
- data/multi_helper.gemspec +31 -0
- data/rails/init.rb +2 -0
- metadata +129 -0
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rake"
|
3
|
+
require "echoe"
|
4
|
+
|
5
|
+
Echoe.new('multi_helper', '0.0.1') do |p|
|
6
|
+
p.description = "Group of custim helpers for rails."
|
7
|
+
p.url = "http://github.com/lucasefe/multi_helper"
|
8
|
+
p.author = "Lucas Florio"
|
9
|
+
p.email = "lucasefe@gmail.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Basado en el scaffold generator de Resource Controller.
|
2
|
+
class FullLayoutGenerator < Rails::Generator::Base
|
3
|
+
# attr_accessor :layout_name
|
4
|
+
def initialize(*runtime_args)
|
5
|
+
raise "Instalar Haml" unless defined?Haml
|
6
|
+
super(*runtime_args)
|
7
|
+
end
|
8
|
+
|
9
|
+
def manifest
|
10
|
+
record do |m|
|
11
|
+
templates = File.join([File.dirname(__FILE__), "templates"])
|
12
|
+
|
13
|
+
m.file('layout.html.haml', "app/views/layouts/application.html.haml")
|
14
|
+
m.directory("app/views/shared")
|
15
|
+
Dir.glob(File.join([templates, "_*.html.*"])).each do |html|
|
16
|
+
html_basename = File.basename(html)
|
17
|
+
m.file(html_basename, "app/views/shared/#{html_basename}")
|
18
|
+
end
|
19
|
+
# javascripts
|
20
|
+
Dir.glob(File.join([templates, "javascripts", "*.js"])).each do |js|
|
21
|
+
js_basename = File.basename(js)
|
22
|
+
m.file("javascripts/#{js_basename}", "public/javascripts/#{js_basename}")
|
23
|
+
end
|
24
|
+
# stylesheets
|
25
|
+
stylesheets = File.join([templates, "stylesheets"])
|
26
|
+
Dir.glob(File.join([stylesheets, "*.css"])).each do |css|
|
27
|
+
css_basename = File.basename(css)
|
28
|
+
m.file("stylesheets/#{css_basename}", "public/stylesheets/#{css_basename}")
|
29
|
+
end
|
30
|
+
# theme stylesheets
|
31
|
+
themes = File.join([templates, "stylesheets", "themes"])
|
32
|
+
themes_target = File.join([Rails.root, "public", "stylesheets", "themes"])
|
33
|
+
FileUtils.cp_r themes, themes_target
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
# Override with your own usage banner.
|
39
|
+
def banner
|
40
|
+
"Usage: #{$0} full_layout layout_name"
|
41
|
+
end
|
42
|
+
# def add_options!(opt)
|
43
|
+
# opt.separator ''
|
44
|
+
# opt.separator 'Options:'
|
45
|
+
# opt.on("--rspec", "Force rspec mode (checks for RAILS_ROOT/spec by default)") { |v| options[:rspec] = true }
|
46
|
+
# end
|
47
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
var Theme = {
|
2
|
+
activate: function(name) {
|
3
|
+
window.location.hash = 'themes/' + name
|
4
|
+
Theme.loadCurrent();
|
5
|
+
},
|
6
|
+
loadCurrent: function() {
|
7
|
+
var hash = window.location.hash;
|
8
|
+
if (hash.length > 0) {
|
9
|
+
matches = hash.match(/^#themes\/([a-z0-9\-_]+)$/);
|
10
|
+
if (matches && matches.length > 1) {
|
11
|
+
$('#current-theme').attr('href', '/stylesheets/themes/' + matches[1] + '/style.css');
|
12
|
+
} else {
|
13
|
+
alert('theme not valid');
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
$().ready(function() {
|
20
|
+
Theme.loadCurrent();
|
21
|
+
$.localScroll();
|
22
|
+
$('.table :checkbox.toggle').each(function(i, toggle) {
|
23
|
+
$(toggle).change(function(e) {
|
24
|
+
$(toggle).parents('table:first').find(':checkbox:not(.toggle)').each(function(j, checkbox) {
|
25
|
+
checkbox.checked = !checkbox.checked;
|
26
|
+
})
|
27
|
+
});
|
28
|
+
});
|
29
|
+
});
|
@@ -0,0 +1,273 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery UI 1.6rc6
|
3
|
+
*
|
4
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
5
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
6
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
7
|
+
*
|
8
|
+
* http://docs.jquery.com/UI
|
9
|
+
*/
|
10
|
+
* jQuery UI Draggable 1.6rc6
|
11
|
+
*
|
12
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
13
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
14
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
15
|
+
*
|
16
|
+
* http://docs.jquery.com/UI/Draggables
|
17
|
+
*
|
18
|
+
* Depends:
|
19
|
+
* ui.core.js
|
20
|
+
*/
|
21
|
+
* jQuery UI Droppable 1.6rc6
|
22
|
+
*
|
23
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
24
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
25
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
26
|
+
*
|
27
|
+
* http://docs.jquery.com/UI/Droppables
|
28
|
+
*
|
29
|
+
* Depends:
|
30
|
+
* ui.core.js
|
31
|
+
* ui.draggable.js
|
32
|
+
*/
|
33
|
+
* jQuery UI Resizable 1.6rc6
|
34
|
+
*
|
35
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
36
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
37
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
38
|
+
*
|
39
|
+
* http://docs.jquery.com/UI/Resizables
|
40
|
+
*
|
41
|
+
* Depends:
|
42
|
+
* ui.core.js
|
43
|
+
*/
|
44
|
+
* jQuery UI Selectable 1.6rc6
|
45
|
+
*
|
46
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
47
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
48
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
49
|
+
*
|
50
|
+
* http://docs.jquery.com/UI/Selectables
|
51
|
+
*
|
52
|
+
* Depends:
|
53
|
+
* ui.core.js
|
54
|
+
*/
|
55
|
+
* jQuery UI Sortable 1.6rc6
|
56
|
+
*
|
57
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
58
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
59
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
60
|
+
*
|
61
|
+
* http://docs.jquery.com/UI/Sortables
|
62
|
+
*
|
63
|
+
* Depends:
|
64
|
+
* ui.core.js
|
65
|
+
*/
|
66
|
+
* jQuery UI Accordion 1.6rc6
|
67
|
+
*
|
68
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
69
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
70
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
71
|
+
*
|
72
|
+
* http://docs.jquery.com/UI/Accordion
|
73
|
+
*
|
74
|
+
* Depends:
|
75
|
+
* ui.core.js
|
76
|
+
*/
|
77
|
+
* jQuery UI Dialog 1.6rc6
|
78
|
+
*
|
79
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
80
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
81
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
82
|
+
*
|
83
|
+
* http://docs.jquery.com/UI/Dialog
|
84
|
+
*
|
85
|
+
* Depends:
|
86
|
+
* ui.core.js
|
87
|
+
* ui.draggable.js
|
88
|
+
* ui.resizable.js
|
89
|
+
*/
|
90
|
+
* jQuery UI Slider 1.6rc6
|
91
|
+
*
|
92
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
93
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
94
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
95
|
+
*
|
96
|
+
* http://docs.jquery.com/UI/Slider
|
97
|
+
*
|
98
|
+
* Depends:
|
99
|
+
* ui.core.js
|
100
|
+
*/
|
101
|
+
* jQuery UI Tabs 1.6rc6
|
102
|
+
*
|
103
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
104
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
105
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
106
|
+
*
|
107
|
+
* http://docs.jquery.com/UI/Tabs
|
108
|
+
*
|
109
|
+
* Depends:
|
110
|
+
* ui.core.js
|
111
|
+
*/
|
112
|
+
* jQuery UI Datepicker 1.6rc6
|
113
|
+
*
|
114
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
115
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
116
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
117
|
+
*
|
118
|
+
* http://docs.jquery.com/UI/Datepicker
|
119
|
+
*
|
120
|
+
* Depends:
|
121
|
+
* ui.core.js
|
122
|
+
*/
|
123
|
+
* jQuery UI Progressbar 1.6rc6
|
124
|
+
*
|
125
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
126
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
127
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
128
|
+
*
|
129
|
+
* http://docs.jquery.com/UI/Progressbar
|
130
|
+
*
|
131
|
+
* Depends:
|
132
|
+
* ui.core.js
|
133
|
+
*/
|
134
|
+
* jQuery UI Effects 1.6rc6
|
135
|
+
*
|
136
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
137
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
138
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
139
|
+
*
|
140
|
+
* http://docs.jquery.com/UI/Effects/
|
141
|
+
*/
|
142
|
+
* jQuery UI Effects Blind 1.6rc6
|
143
|
+
*
|
144
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
145
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
146
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
147
|
+
*
|
148
|
+
* http://docs.jquery.com/UI/Effects/Blind
|
149
|
+
*
|
150
|
+
* Depends:
|
151
|
+
* effects.core.js
|
152
|
+
*/
|
153
|
+
* jQuery UI Effects Bounce 1.6rc6
|
154
|
+
*
|
155
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
156
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
157
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
158
|
+
*
|
159
|
+
* http://docs.jquery.com/UI/Effects/Bounce
|
160
|
+
*
|
161
|
+
* Depends:
|
162
|
+
* effects.core.js
|
163
|
+
*/
|
164
|
+
* jQuery UI Effects Clip 1.6rc6
|
165
|
+
*
|
166
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
167
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
168
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
169
|
+
*
|
170
|
+
* http://docs.jquery.com/UI/Effects/Clip
|
171
|
+
*
|
172
|
+
* Depends:
|
173
|
+
* effects.core.js
|
174
|
+
*/
|
175
|
+
* jQuery UI Effects Drop 1.6rc6
|
176
|
+
*
|
177
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
178
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
179
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
180
|
+
*
|
181
|
+
* http://docs.jquery.com/UI/Effects/Drop
|
182
|
+
*
|
183
|
+
* Depends:
|
184
|
+
* effects.core.js
|
185
|
+
*/
|
186
|
+
* jQuery UI Effects Explode 1.6rc6
|
187
|
+
*
|
188
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
189
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
190
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
191
|
+
*
|
192
|
+
* http://docs.jquery.com/UI/Effects/Explode
|
193
|
+
*
|
194
|
+
* Depends:
|
195
|
+
* effects.core.js
|
196
|
+
*/
|
197
|
+
* jQuery UI Effects Fold 1.6rc6
|
198
|
+
*
|
199
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
200
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
201
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
202
|
+
*
|
203
|
+
* http://docs.jquery.com/UI/Effects/Fold
|
204
|
+
*
|
205
|
+
* Depends:
|
206
|
+
* effects.core.js
|
207
|
+
*/
|
208
|
+
* jQuery UI Effects Highlight 1.6rc6
|
209
|
+
*
|
210
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
211
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
212
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
213
|
+
*
|
214
|
+
* http://docs.jquery.com/UI/Effects/Highlight
|
215
|
+
*
|
216
|
+
* Depends:
|
217
|
+
* effects.core.js
|
218
|
+
*/
|
219
|
+
* jQuery UI Effects Pulsate 1.6rc6
|
220
|
+
*
|
221
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
222
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
223
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
224
|
+
*
|
225
|
+
* http://docs.jquery.com/UI/Effects/Pulsate
|
226
|
+
*
|
227
|
+
* Depends:
|
228
|
+
* effects.core.js
|
229
|
+
*/
|
230
|
+
* jQuery UI Effects Scale 1.6rc6
|
231
|
+
*
|
232
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
233
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
234
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
235
|
+
*
|
236
|
+
* http://docs.jquery.com/UI/Effects/Scale
|
237
|
+
*
|
238
|
+
* Depends:
|
239
|
+
* effects.core.js
|
240
|
+
*/
|
241
|
+
* jQuery UI Effects Shake 1.6rc6
|
242
|
+
*
|
243
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
244
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
245
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
246
|
+
*
|
247
|
+
* http://docs.jquery.com/UI/Effects/Shake
|
248
|
+
*
|
249
|
+
* Depends:
|
250
|
+
* effects.core.js
|
251
|
+
*/
|
252
|
+
* jQuery UI Effects Slide 1.6rc6
|
253
|
+
*
|
254
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
255
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
256
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
257
|
+
*
|
258
|
+
* http://docs.jquery.com/UI/Effects/Slide
|
259
|
+
*
|
260
|
+
* Depends:
|
261
|
+
* effects.core.js
|
262
|
+
*/
|
263
|
+
* jQuery UI Effects Transfer 1.6rc6
|
264
|
+
*
|
265
|
+
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
266
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
267
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
268
|
+
*
|
269
|
+
* http://docs.jquery.com/UI/Effects/Transfer
|
270
|
+
*
|
271
|
+
* Depends:
|
272
|
+
* effects.core.js
|
273
|
+
*/
|
@@ -0,0 +1,178 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery corner plugin
|
3
|
+
*
|
4
|
+
* version 1.92 (12/18/2007)
|
5
|
+
*
|
6
|
+
* Dual licensed under the MIT and GPL licenses:
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
* http://www.gnu.org/licenses/gpl.html
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* The corner() method provides a simple way of styling DOM elements.
|
13
|
+
*
|
14
|
+
* corner() takes a single string argument: $().corner("effect corners width")
|
15
|
+
*
|
16
|
+
* effect: The name of the effect to apply, such as round or bevel.
|
17
|
+
* If you don't specify an effect, rounding is used.
|
18
|
+
*
|
19
|
+
* corners: The corners can be one or more of top, bottom, tr, tl, br, or bl.
|
20
|
+
* By default, all four corners are adorned.
|
21
|
+
*
|
22
|
+
* width: The width specifies the width of the effect; in the case of rounded corners this
|
23
|
+
* will be the radius of the width.
|
24
|
+
* Specify this value using the px suffix such as 10px, and yes it must be pixels.
|
25
|
+
*
|
26
|
+
* For more details see: http://methvin.com/jquery/jq-corner.html
|
27
|
+
* For a full demo see: http://malsup.com/jquery/corner/
|
28
|
+
*
|
29
|
+
*
|
30
|
+
* @example $('.adorn').corner();
|
31
|
+
* @desc Create round, 10px corners
|
32
|
+
*
|
33
|
+
* @example $('.adorn').corner("25px");
|
34
|
+
* @desc Create round, 25px corners
|
35
|
+
*
|
36
|
+
* @example $('.adorn').corner("notch bottom");
|
37
|
+
* @desc Create notched, 10px corners on bottom only
|
38
|
+
*
|
39
|
+
* @example $('.adorn').corner("tr dog 25px");
|
40
|
+
* @desc Create dogeared, 25px corner on the top-right corner only
|
41
|
+
*
|
42
|
+
* @example $('.adorn').corner("round 8px").parent().css('padding', '4px').corner("round 10px");
|
43
|
+
* @desc Create a rounded border effect by styling both the element and its parent
|
44
|
+
*
|
45
|
+
* @name corner
|
46
|
+
* @type jQuery
|
47
|
+
* @param String options Options which control the corner style
|
48
|
+
* @cat Plugins/Corner
|
49
|
+
* @return jQuery
|
50
|
+
* @author Dave Methvin (dave.methvin@gmail.com)
|
51
|
+
* @author Mike Alsup (malsup@gmail.com)
|
52
|
+
*/
|
53
|
+
(function($) {
|
54
|
+
|
55
|
+
$.fn.corner = function(o) {
|
56
|
+
var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent);
|
57
|
+
function sz(el, p) { return parseInt($.css(el,p))||0; };
|
58
|
+
function hex2(s) {
|
59
|
+
var s = parseInt(s).toString(16);
|
60
|
+
return ( s.length < 2 ) ? '0'+s : s;
|
61
|
+
};
|
62
|
+
function gpc(node) {
|
63
|
+
for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) {
|
64
|
+
var v = $.css(node,'backgroundColor');
|
65
|
+
if ( v.indexOf('rgb') >= 0 ) {
|
66
|
+
if ($.browser.safari && v == 'rgba(0, 0, 0, 0)')
|
67
|
+
continue;
|
68
|
+
var rgb = v.match(/\d+/g);
|
69
|
+
return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
|
70
|
+
}
|
71
|
+
if ( v && v != 'transparent' )
|
72
|
+
return v;
|
73
|
+
}
|
74
|
+
return '#ffffff';
|
75
|
+
};
|
76
|
+
function getW(i) {
|
77
|
+
switch(fx) {
|
78
|
+
case 'round': return Math.round(width*(1-Math.cos(Math.asin(i/width))));
|
79
|
+
case 'cool': return Math.round(width*(1+Math.cos(Math.asin(i/width))));
|
80
|
+
case 'sharp': return Math.round(width*(1-Math.cos(Math.acos(i/width))));
|
81
|
+
case 'bite': return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
|
82
|
+
case 'slide': return Math.round(width*(Math.atan2(i,width/i)));
|
83
|
+
case 'jut': return Math.round(width*(Math.atan2(width,(width-i-1))));
|
84
|
+
case 'curl': return Math.round(width*(Math.atan(i)));
|
85
|
+
case 'tear': return Math.round(width*(Math.cos(i)));
|
86
|
+
case 'wicked': return Math.round(width*(Math.tan(i)));
|
87
|
+
case 'long': return Math.round(width*(Math.sqrt(i)));
|
88
|
+
case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
|
89
|
+
case 'dog': return (i&1) ? (i+1) : width;
|
90
|
+
case 'dog2': return (i&2) ? (i+1) : width;
|
91
|
+
case 'dog3': return (i&3) ? (i+1) : width;
|
92
|
+
case 'fray': return (i%2)*width;
|
93
|
+
case 'notch': return width;
|
94
|
+
case 'bevel': return i+1;
|
95
|
+
}
|
96
|
+
};
|
97
|
+
o = (o||"").toLowerCase();
|
98
|
+
var keep = /keep/.test(o); // keep borders?
|
99
|
+
var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]); // corner color
|
100
|
+
var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]); // strip color
|
101
|
+
var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
|
102
|
+
var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
|
103
|
+
var fx = ((o.match(re)||['round'])[0]);
|
104
|
+
var edges = { T:0, B:1 };
|
105
|
+
var opts = {
|
106
|
+
TL: /top|tl/.test(o), TR: /top|tr/.test(o),
|
107
|
+
BL: /bottom|bl/.test(o), BR: /bottom|br/.test(o)
|
108
|
+
};
|
109
|
+
if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
|
110
|
+
opts = { TL:1, TR:1, BL:1, BR:1 };
|
111
|
+
var strip = document.createElement('div');
|
112
|
+
strip.style.overflow = 'hidden';
|
113
|
+
strip.style.height = '1px';
|
114
|
+
strip.style.backgroundColor = sc || 'transparent';
|
115
|
+
strip.style.borderStyle = 'solid';
|
116
|
+
return this.each(function(index){
|
117
|
+
var pad = {
|
118
|
+
T: parseInt($.css(this,'paddingTop'))||0, R: parseInt($.css(this,'paddingRight'))||0,
|
119
|
+
B: parseInt($.css(this,'paddingBottom'))||0, L: parseInt($.css(this,'paddingLeft'))||0
|
120
|
+
};
|
121
|
+
|
122
|
+
if ($.browser.msie) this.style.zoom = 1; // force 'hasLayout' in IE
|
123
|
+
if (!keep) this.style.border = 'none';
|
124
|
+
strip.style.borderColor = cc || gpc(this.parentNode);
|
125
|
+
var cssHeight = $.curCSS(this, 'height');
|
126
|
+
|
127
|
+
for (var j in edges) {
|
128
|
+
var bot = edges[j];
|
129
|
+
// only add stips if needed
|
130
|
+
if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
|
131
|
+
strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
|
132
|
+
var d = document.createElement('div');
|
133
|
+
$(d).addClass('jquery-corner');
|
134
|
+
var ds = d.style;
|
135
|
+
|
136
|
+
bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);
|
137
|
+
|
138
|
+
if (bot && cssHeight != 'auto') {
|
139
|
+
if ($.css(this,'position') == 'static')
|
140
|
+
this.style.position = 'relative';
|
141
|
+
ds.position = 'absolute';
|
142
|
+
ds.bottom = ds.left = ds.padding = ds.margin = '0';
|
143
|
+
if ($.browser.msie)
|
144
|
+
ds.setExpression('width', 'this.parentNode.offsetWidth');
|
145
|
+
else
|
146
|
+
ds.width = '100%';
|
147
|
+
}
|
148
|
+
else if (!bot && $.browser.msie) {
|
149
|
+
if ($.css(this,'position') == 'static')
|
150
|
+
this.style.position = 'relative';
|
151
|
+
ds.position = 'absolute';
|
152
|
+
ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';
|
153
|
+
|
154
|
+
// fix ie6 problem when blocked element has a border width
|
155
|
+
var bw = 0;
|
156
|
+
if (ie6 || !$.boxModel)
|
157
|
+
bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
|
158
|
+
ie6 ? ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"') : ds.width = '100%';
|
159
|
+
}
|
160
|
+
else {
|
161
|
+
ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' :
|
162
|
+
(pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';
|
163
|
+
}
|
164
|
+
|
165
|
+
for (var i=0; i < width; i++) {
|
166
|
+
var w = Math.max(0,getW(i));
|
167
|
+
var e = strip.cloneNode(false);
|
168
|
+
e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
|
169
|
+
bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
});
|
174
|
+
};
|
175
|
+
|
176
|
+
$.fn.uncorner = function(o) { return $('.jquery-corner', this).remove(); };
|
177
|
+
|
178
|
+
})(jQuery);
|