guilded 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ = 1.0.13 2010-08-04
2
+
3
+ * Provide option to include script tags in the g_apply_behavior method.
4
+
5
+
1
6
  = 1.0.12 2010-05-11
2
7
 
3
8
  * Fixed a new compatibility issue with Rails 3 templating.
@@ -77,7 +82,7 @@
77
82
 
78
83
  = 0.2.8 2009-06-12
79
84
 
80
- * Removed some code from the InactiveRecord:Base extension for human attrbiute hint that returns unless
85
+ * Removed some code from the InactiveRecord:Base extension for human attrbiute hint that returns unless
81
86
  table_exists? as this does not make any sense for InactiveRecord.
82
87
 
83
88
 
@@ -98,9 +103,9 @@
98
103
 
99
104
  = 0.2.4 2009-05-29
100
105
 
101
- * Added add_data method to the Guilder object allowing named data structures to be passed to the JavaScript
106
+ * Added add_data method to the Guilder object allowing named data structures to be passed to the JavaScript
102
107
  executing environment.
103
- * Added a jQuery event to the body DOM element called guildedInitialized. To execute JavaScript code after all
108
+ * Added a jQuery event to the body DOM element called guildedInitialized. To execute JavaScript code after all
104
109
  Guilded components are intialized, simply bind to this event.
105
110
 
106
111
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.12
1
+ 1.0.13
data/guilded.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{guilded}
8
- s.version = "1.0.12"
8
+ s.version = "1.0.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["C. Jason Harrelson (midas)"]
12
- s.date = %q{2010-05-11}
12
+ s.date = %q{2010-08-04}
13
13
  s.description = %q{Guilded intends to provide a toolset for creating and consuming reusable web components. Currently, this problem domain is filled with JavaScript frameworks. These frameworks are wonderful and work very well. However, they do not degrade gracefully and are not accessible (in most cases). Guilded seeks to provide the same level of "componentization" and ease of use without sacrificing degradability and accessibility. Guilded will achieve these goals by applying each technology at our disposal (HTML, CSS and JavaScript) to do as it was intended.}
14
14
  s.email = %q{jason@lookforwardenterprises.com}
15
15
  s.extra_rdoc_files = [
@@ -7,7 +7,7 @@ GUILDED_CONFIG = {
7
7
  :js_folder => "", # from the js_path
8
8
  :jquery_js => "jquery/jquery-1.3.2.min.js", # from the js_path
9
9
  :use_remote_jquery => true,
10
- :jquery_remote_url => "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",
10
+ :jquery_remote_url => "//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",
11
11
  :mootools_js => "mootools/mootools-1.2.3.min.js", # from the js_path
12
12
  :css_path => "#{Rails.root}/public/stylesheets/",
13
13
  :css_folder => "guilded/", # from the css_path
data/lib/guilded.rb CHANGED
@@ -10,35 +10,35 @@ require 'guilded/rails/view_helpers'
10
10
  require 'guilded/rails/active_record/human_attribute_hint'
11
11
  require 'guilded/rails/inactive_record/human_attribute_hint'
12
12
 
13
- # Guilded is a framework for creating reusable UI components for web applications. Guilded provides the facilities to
13
+ # Guilded is a framework for creating reusable UI components for web applications. Guilded provides the facilities to
14
14
  # easily add components and all of their required assets to a page.
15
- #
15
+ #
16
16
  # A Guilded component is a set of XHTML, CSS and JavaScript that combine to create a rich UI. The Guilded component should be
17
17
  # authored using progressive enhancement to enable users without CSS or JavaScript enabled to utilize the essential functionality
18
18
  # of the component. The easiest way to accomplish this requirement is to write your behavior code as a jQuery plugin. Doing
19
- # so will naturally guide your behavior code to be applied through progrssive enhancement and also allow your behavior code
19
+ # so will naturally guide your behavior code to be applied through progrssive enhancement and also allow your behavior code
20
20
  # to be used without Guilded.
21
21
  #
22
22
  # To create a Guilded component at least four things must occur: writing a view helper, writing a JavaScript initialization
23
- # function, writing a default stylesheet and writing either a rake task or generator to place these assets into a project's
24
- # public directory. It is also probable that a jQuery plugin with the behavior code will need to be authored. If this is the
25
- # case, then the JavaScript initialization function will most likely just call the jQuery plugin on the DOM element(s) that should
23
+ # function, writing a default stylesheet and writing either a rake task or generator to place these assets into a project's
24
+ # public directory. It is also probable that a jQuery plugin with the behavior code will need to be authored. If this is the
25
+ # case, then the JavaScript initialization function will most likely just call the jQuery plugin on the DOM element(s) that should
26
26
  # have the behavior applied.
27
27
  #
28
28
  # The view helper should output the HTML necessary for the component. It must also add the component to a collection so that
29
29
  # Guilded can collect its assets and add them to the page. This is accomplished through a call to the Guilder.add() method.
30
30
  # The Guilder is a singleton, so you must access it like: Guilded::Guilder.instance.add( ... ). The Guilder.add() method adds
31
- # element to a collection with it's options. Guilded automatically looks for CSS assets that obey the naming convention
32
- # {component_name}/default.css. Guilded also automatically looks for a JavaScript asset named: guilded.{component_name}.js.
33
- # This asset should at least include the initComponentName( options ). The Guilded.add() method can also add additional CSS and
34
- # JavaScript assets necessary for a component. An example of an additional JavaScript asset is the jQuery plugin authored to
31
+ # element to a collection with it's options. Guilded automatically looks for CSS assets that obey the naming convention
32
+ # {component_name}/default.css. Guilded also automatically looks for a JavaScript asset named: guilded.{component_name}.js.
33
+ # This asset should at least include the initComponentName( options ). The Guilded.add() method can also add additional CSS and
34
+ # JavaScript assets necessary for a component. An example of an additional JavaScript asset is the jQuery plugin authored to
35
35
  # contain the behavior of a component. The view helper must be called with an :id option as it is used to differentiate different
36
- # instances of the same component on a single page from each other. It will also be used as the DOM element's id. A Guilded view
36
+ # instances of the same component on a single page from each other. It will also be used as the DOM element's id. A Guilded view
37
37
  # helper should have a g_ appended to the beginning of it to help differentiate from normal view helepr sin a project.
38
- #
38
+ #
39
39
  # The JavaScript initialization function should be named init{ComponentName}( options ). The options hash from the view helper
40
40
  # will automatically be passed to this function. The function should handle a before and after init callback to enable the user
41
- # to set up anything necessary for the component and perform additional tasks. This function must also perform any other code
41
+ # to set up anything necessary for the component and perform additional tasks. This function must also perform any other code
42
42
  # necessary to set up the behavior for a compnent. An example fo this would be adding behavior to events or simply calling
43
43
  # a jQuery plugin on element(s) of the component. Remember that any JavaScript relating to Guilded should be placed in the 'g'
44
44
  # namespace that Guilded creates on every page. An example init function for a g_load_alerter would be:
@@ -56,23 +56,23 @@ require 'guilded/rails/inactive_record/human_attribute_hint'
56
56
  #
57
57
  # For a user to implement these callback functions, they should create a JavaScript file with the functions and call it on
58
58
  # any page they need it on utilizing Guilded's JavaScript include helper g_javascript_include_tag. This helper will add the
59
- # JavaScript files after the jQuery and Guilded framework files, but within the component files in the order they were added.
59
+ # JavaScript files after the jQuery and Guilded framework files, but within the component files in the order they were added.
60
60
  # This will make the 'g' namespace available for use. Obviously this file must be included prior to calling the component's helper,
61
- # or the callback functions will not be defined for use.
61
+ # or the callback functions will not be defined for use.
62
62
  #
63
63
  # The default stylesheet for a Guilded component should be the minimum amount of CSS for the component to function. When no :skin
64
64
  # option is passed to the view helper when a component is added, Guilded will look for the default stylesheet. The assets
65
65
  # used within the stylesheet (images) should be placed in a folder named default that is in the same directory as the default.css
66
66
  # file. All asssets used in the stylesheet should use an absolute reference from the public directory: /stylesheets/guilded/{component_name}/default/{asset_name}.
67
67
  #
68
- # In order to create another skin for a component, simply create a {skin_name}.css file and a {skin_name} directory with the style
69
- # assets in it. Be sure to reference the style assets with absolute paths from teh public directory so that the skin will work in
68
+ # In order to create another skin for a component, simply create a {skin_name}.css file and a {skin_name} directory with the style
69
+ # assets in it. Be sure to reference the style assets with absolute paths from teh public directory so that the skin will work in
70
70
  # all cases. Then call the component's view helper and use the :skin option:
71
71
  #
72
72
  # <%= g_load_alerter :skin => 'blueish', :id => 'load_alerter' %>
73
73
  #
74
74
  module Guilded
75
- VERSION = '1.0.12'
75
+ VERSION = '1.0.13'
76
76
  end
77
77
 
78
78
  ActionView::Base.send( :include, Guilded::Rails::ViewHelpers ) if defined?( ActionView )
@@ -3,30 +3,30 @@ require 'singleton'
3
3
  require 'guilded/exceptions'
4
4
 
5
5
  module Guilded
6
-
6
+
7
7
  # Guilder is the worker for the entire Guilded framework. It collects all of the necessary components for a page
8
8
  # through its add() method. When the g_apply_behavior() method is called at the end of a page, the Guilder writes
9
9
  # HTML to include all of the necessary asset files (caching them in production). It also writes a JavaScript initialization
10
- # function and fires the initialization function on page load and a before and after initialization callback allowing for
10
+ # function and fires the initialization function on page load and a before and after initialization callback allowing for
11
11
  # custom initializtion to occur.
12
12
  #
13
- # This initialization function calls the initialization function for each Guilded component that was added to the current
14
- # page. For example, if a Guilded component named 'g_load_alerter' was added to a page, the Guilder would include this line
13
+ # This initialization function calls the initialization function for each Guilded component that was added to the current
14
+ # page. For example, if a Guilded component named 'g_load_alerter' was added to a page, the Guilder would include this line
15
15
  # in the initialization function it writes: g.initLoadAlerter( /* passing options hash here */ ); The g before the function
16
- # is a JavaScript namespace that Guilded automatically creates to facilitate avoiding name collisions with other JavaScript
16
+ # is a JavaScript namespace that Guilded automatically creates to facilitate avoiding name collisions with other JavaScript
17
17
  # libraries and code.
18
18
  #
19
- # Th options hash that is passed to the init functions for each Guilded component is simply the options hash from the
19
+ # Th options hash that is passed to the init functions for each Guilded component is simply the options hash from the
20
20
  # component's view helper. The Guilder calls .to_json() on the options hash. Thus, if there are pairs in the options hash
21
- # that need not go to the JavaScript init method they should be removed within the view helper.
21
+ # that need not go to the JavaScript init method they should be removed within the view helper.
22
22
  #
23
23
  class Guilder
24
24
  include Singleton
25
-
25
+
26
26
  GUILDED_NS = "guilded."
27
-
27
+
28
28
  attr_reader :initialized_at, :jquery_js, :mootools_js
29
-
29
+
30
30
  def initialize #:nodoc:
31
31
  if defined?( GUILDED_CONFIG )
32
32
  @config = GUILDED_CONFIG
@@ -45,7 +45,7 @@ module Guilded
45
45
  # unless the user specified no reset to be included.
46
46
  init_sources
47
47
  end
48
-
48
+
49
49
  # Adds an element with its options to the @g_elements hash to be used later.
50
50
  #
51
51
  def add( element, options={}, libs=[], styles=[] )
@@ -54,18 +54,18 @@ module Guilded
54
54
  @need_mootools = true if options[:mootools]
55
55
  @g_elements[ options[:id].to_sym ] = Guilded::ComponentDef.new( element, options, libs, styles )
56
56
  end
57
-
58
- # Adds a data structure to be passed to the Guilded JavaScript environment for use on the client
57
+
58
+ # Adds a data structure to be passed to the Guilded JavaScript environment for use on the client
59
59
  # side. The data is passed using the ruby to_json method on the data structure provided.
60
60
  #
61
61
  # === Parameters
62
62
  # * +name+ - The desired name of the variable on the client side.
63
- # * +data+ - The data to pass to the Guilded JavaScript environment.
63
+ # * +data+ - The data to pass to the Guilded JavaScript environment.
64
64
  #
65
65
  def add_data( name, data )
66
66
  @g_data_elements.merge!( name.to_sym => data )
67
67
  end
68
-
68
+
69
69
  # Adds JavaScript sources to the libs collection by resolving them to the normal or min version
70
70
  # based on the current running environment, development, production, etc.
71
71
  #
@@ -76,41 +76,41 @@ module Guilded
76
76
  def add_css_source( src, position=:post )
77
77
  @css_temp_hold[position.to_sym] << src unless @css_temp_hold[position.to_sym].include?( src )
78
78
  end
79
-
79
+
80
80
  def count #:nodoc:
81
81
  @g_elements.size
82
82
  end
83
-
83
+
84
84
  # The number of Guilded components to be renderred.
85
85
  #
86
86
  def component_count
87
87
  count
88
88
  end
89
-
90
- # The current number of CSS assets necessary for the Guilded component set.
89
+
90
+ # The current number of CSS assets necessary for the Guilded component set.
91
91
  #
92
92
  def style_count
93
93
  @combined_css_srcs.size
94
94
  end
95
-
96
- # The current number of JavaScript assets necessary for the Guilded component set.
95
+
96
+ # The current number of JavaScript assets necessary for the Guilded component set.
97
97
  #
98
98
  def script_count
99
99
  @combined_js_srcs.size
100
100
  end
101
-
101
+
102
102
  # Returns true if the component type is included, otherwise false.
103
103
  #
104
104
  def include_component?( type )
105
105
  @g_elements.has_key?( type.to_sym )
106
106
  end
107
-
107
+
108
108
  # The collection of JavaScript assets for the current Guilded component set.
109
109
  #
110
110
  def combined_js_srcs
111
111
  @combined_js_srcs
112
112
  end
113
-
113
+
114
114
  # The collection of CSS assets for the current Guilded component set.
115
115
  #
116
116
  def combined_css_srcs
@@ -120,7 +120,7 @@ module Guilded
120
120
  @css_temp_hold[:post].each { |src| @combined_css_srcs << src }
121
121
  @combined_css_srcs
122
122
  end
123
-
123
+
124
124
  # Clears out all but the reset CSS and the base JavaScripts
125
125
  #
126
126
  def reset!
@@ -137,12 +137,12 @@ module Guilded
137
137
  def inject_css( *sources )
138
138
  @combined_css_srcs.insert( @default_css_count, *sources )
139
139
  end
140
-
140
+
141
141
  def inject_js( *sources )
142
142
  @combined_js_srcs.insert( @default_js_count, *sources )
143
143
  end
144
-
145
- # Generates the markup required to include all the assets necessary for the Guilded compoents in
144
+
145
+ # Generates the markup required to include all the assets necessary for the Guilded compoents in
146
146
  # @g_elements collection. Use this if you are not interested in caching asset files.
147
147
  #
148
148
  def apply #:nodoc:
@@ -153,45 +153,58 @@ module Guilded
153
153
  to_init << generate_javascript_init
154
154
  reset!
155
155
  end
156
-
157
- # Writes an initialization method that calls each Guilded components initialization method. This
156
+
157
+ # Writes an initialization method that calls each Guilded components initialization method. This
158
158
  # method will exceute on document load finish.
159
159
  #
160
- def generate_javascript_init #:nodoc:
161
- code = "var initGuildedElements = function(){"
160
+ def generate_javascript_init( options={} ) #:nodoc:
161
+ options[:include_script_tags] = true if options[:include_script_tags].nil?
162
+ code = ""
163
+
164
+ if options[:include_script_tags]
165
+ code << "<script type=\"text/javascript\">\n//<![CDATA[\n"
166
+ end
167
+
168
+ code << "var initGuildedElements = function(){"
162
169
  @g_data_elements.each do |name, data|
163
- code << "g.#{name} = #{data.to_json};"
170
+ code << "g.#{name} = #{data.to_json};"
164
171
  end
165
- @g_elements.each_value do |guilded_def|
172
+ @g_elements.each_value do |guilded_def|
166
173
  code << "g.#{guilded_def.kind.to_s.camelize( :lower )}Init(#{guilded_def.options.to_json});" unless guilded_def.exclude_js?
167
174
  end
168
175
  code << "jQuery('body').trigger('guildedInitialized');};jQuery('document').ready(initGuildedElements);"
176
+
177
+ if options[:include_script_tags]
178
+ code << "\n\n//]]>\n</script>"
179
+ end
180
+
181
+ code
169
182
  end
170
-
183
+
171
184
  # Generates a name to use when caching the current set of Guilded component JavaScript assets. Sorts and concatenates
172
- # the name of each JavaScript asset in @combined_js_srcs. Then hashes this string to generate a reproducible, unique
185
+ # the name of each JavaScript asset in @combined_js_srcs. Then hashes this string to generate a reproducible, unique
173
186
  # and shorter string.
174
187
  #
175
188
  def js_cache_name
176
189
  generate_js_cache_name( @combined_js_srcs )
177
190
  end
178
-
191
+
179
192
  # Generates a name to use when caching the current set of Guilded component CSS assets. Sorts and concatenates
180
- # the name of each JavaScript asset in @combined_js_srcs. Then hashes this string to generate a reproducible, unique
193
+ # the name of each JavaScript asset in @combined_js_srcs. Then hashes this string to generate a reproducible, unique
181
194
  # and shorter string.
182
195
  #
183
196
  def css_cache_name
184
197
  name = generate_css_cache_name( @combined_css_srcs )
185
198
  name
186
199
  end
187
-
188
- def generate_js_cache_name( sources ) #:nodoc:
200
+
201
+ def generate_js_cache_name( sources ) #:nodoc:
189
202
  sorted_srcs = sources.sort
190
203
  stripped_srcs = sorted_srcs.map { |src| src.gsub( /.js/, '' ).gsub( /\//, '_') }
191
204
  joined = stripped_srcs.join( "+" )
192
205
  "#{Digest::MD5.hexdigest( joined )}"
193
206
  end
194
-
207
+
195
208
  def generate_css_cache_name( sources ) #:nodoc:
196
209
  sorted_srcs = sources.sort
197
210
  stripped_srcs = sorted_srcs.map { |src| src.gsub( /.css/, '' ).gsub( /\//, '_') }
@@ -206,48 +219,48 @@ module Guilded
206
219
  @g_elements.each_value do |defi|
207
220
  #TODO get stylesheet (skin) stuff using rails caching
208
221
  combine_css_sources( defi.kind, defi.options[:skin], defi.styles ) unless defi.exclude_css?
209
-
222
+
210
223
  # Combine all JavaScript sources so that the caching option can be used on
211
224
  # the javascript_incldue_tag helper.
212
225
  combine_js_sources( defi.kind, defi.libs ) unless defi.exclude_js?
213
226
  end
214
227
  end
215
-
228
+
216
229
  def jquery_js
217
230
  @config[:jquery_js]
218
231
  end
219
-
232
+
220
233
  def jquery_remote_url
221
234
  @config[:jquery_remote_url]
222
235
  end
223
-
236
+
224
237
  def use_remote_jquery
225
238
  @config[:use_remote_jquery]
226
239
  end
227
-
240
+
228
241
  def app_root
229
242
  @config[:app_root]
230
243
  end
231
-
244
+
232
245
  def environment
233
246
  @config[:environment]
234
247
  end
235
-
236
- def development? #:nodoc:
248
+
249
+ def development? #:nodoc:
237
250
  environment.to_sym == :development
238
251
  end
239
-
240
- def production? #:nodoc:
252
+
253
+ def production? #:nodoc:
241
254
  environment.to_sym == :production
242
255
  end
243
-
244
- def test? #:nodoc:
256
+
257
+ def test? #:nodoc:
245
258
  environment.to_sym == :test
246
259
  end
247
-
260
+
248
261
  protected
249
-
250
- def configure_guilded #:nodoc:
262
+
263
+ def configure_guilded #:nodoc:
251
264
  @js_path = @config[:js_path]
252
265
  @js_folder = @config[:js_folder]
253
266
  @jquery_js = @config[:jquery_js]
@@ -274,17 +287,17 @@ module Guilded
274
287
  @css_folder.freeze
275
288
  @reset_css.freeze
276
289
  @env.freeze
277
- end
278
-
290
+ end
291
+
279
292
  # Adds the Guilded reset CSS file and the guilded.js and jQuery files to the respective sources
280
293
  # collections.
281
294
  #
282
- def init_sources #:nodoc:
295
+ def init_sources #:nodoc:
283
296
  @css_temp_hold[:reset] << "#{@reset_css}" unless @reset_css.nil? || @reset_css.empty?
284
297
  resolve_js_libs( "#{@jquery_js}", "#{@jquery_folder}#{@url_js}", "#{@js_folder}#{@guilded_js}" )
285
298
  #TODO include the jQuery lib from Google server in production
286
299
  end
287
-
300
+
288
301
  # Helper method that takes the libs and component specific js files and puts them
289
302
  # into one array so that the javascript_include_tag can correctly cache them. Automatically
290
303
  # ignores files that have already been inlcuded.
@@ -292,24 +305,24 @@ module Guilded
292
305
  # *parameters*
293
306
  # combined_src (required) An array of the combined sorces for the page being renderred.
294
307
  # component (required) The name of a guilded component.
295
- # libs An array of JavaScript libraries that this component depends on. More than likely
308
+ # libs An array of JavaScript libraries that this component depends on. More than likely
296
309
  # a jQuery plugin, etc.
297
310
  #
298
311
  def combine_js_sources( component, libs=[] ) #:nodoc:
299
312
  libs << @mootools_js if @need_mootools
300
313
  resolve_js_libs( *libs )
301
-
314
+
302
315
  comp_src = add_guilded_js_path( component )
303
316
  @combined_js_srcs.push( comp_src ) unless @combined_js_srcs.include?( comp_src )
304
317
  end
305
-
318
+
306
319
  # Helper method that adds the aditional JavaScript library icludes to the include set.
307
- #
320
+ #
308
321
  # If running development mode, it will try to remove any .pack, .min, or.compressed
309
- # parts fo the name to try and get the debug version of the library. If it cannot
322
+ # parts fo the name to try and get the debug version of the library. If it cannot
310
323
  # find the debug version of the file, it will just remain what was initially provded.
311
324
  #
312
- def resolve_js_libs( *libs ) #:nodoc:
325
+ def resolve_js_libs( *libs ) #:nodoc:
313
326
  if development?
314
327
  # Try to use an unpacked or unminimized version
315
328
  libs.each do |lib|
@@ -325,41 +338,41 @@ module Guilded
325
338
  libs.each { |lib| @combined_js_srcs.push( lib ) unless @combined_js_srcs.include?( lib ) }
326
339
  end
327
340
  end
328
-
341
+
329
342
  # Helper method that takes an array of js sources and adds the correct guilded
330
343
  # path to them. Returns an array with the new path resolved sources.
331
344
  #
332
- def map_guilded_js_paths( *sources ) #:nodoc:
345
+ def map_guilded_js_paths( *sources ) #:nodoc:
333
346
  sources.map { |source| add_guilded_js_path( source ) }
334
347
  end
335
-
348
+
336
349
  # Adds the guilded JS path to the the source name passed in. When not in development mode,
337
- # it looks for a .pack.js, .min.jsm .compressed.js and chooses one of these over the
350
+ # it looks for a .pack.js, .min.jsm .compressed.js and chooses one of these over the
338
351
  # development version.
339
352
  #
340
- def add_guilded_js_path( source ) #:nodoc:
353
+ def add_guilded_js_path( source ) #:nodoc:
341
354
  part = "#{@js_folder}#{GUILDED_NS}#{source.to_s}"
342
355
  ext = 'js'
343
-
356
+
344
357
  return "#{part}.#{ext}" unless production?
345
-
358
+
346
359
  possibles = [ "#{@js_path}#{part}.min.#{ext}", "#{@js_path}#{part}.pack.#{ext}", "#{@js_path}#{part}.compressed.#{ext}",
347
360
  "#{@js_path}#{part}.#{ext}" ]
348
361
  parts = [ "#{part}.min.#{ext}", "{part}.pack.#{ext}", "#{part}.compressed.#{ext}", "#{part}.#{ext}" ]
349
-
362
+
350
363
  possibles.each_with_index do |full_path, i|
351
- return parts[i] if File.exists?( full_path )
364
+ return parts[i] if File.exists?( full_path )
352
365
  end
353
-
366
+
354
367
  "" # Should never reach here
355
368
  end
356
-
357
- def combine_css_sources( component, skin, styles=[] ) #:nodoc:
369
+
370
+ def combine_css_sources( component, skin, styles=[] ) #:nodoc:
358
371
  # Get all of this components defined external styles
359
372
  styles.each do |style|
360
373
  @css_temp_hold[:components].push( style ) unless @css_temp_hold[:components].include?( style )
361
374
  end
362
-
375
+
363
376
  #Get the default or guilded skin styles for this component
364
377
  comp_src = add_guilded_css_path( component, skin )
365
378
  @css_temp_hold[:components].push( comp_src ) unless @css_temp_hold[:components].include?( comp_src ) || comp_src.empty?
@@ -368,8 +381,8 @@ module Guilded
368
381
  skin_user_src = add_guilded_css_path( component, "#{skin || 'default'}_user" )
369
382
  @css_temp_hold[:components].push( skin_user_src ) unless @css_temp_hold[:components].include?( skin_user_src ) || skin_user_src.empty?
370
383
  end
371
-
372
- def add_guilded_css_path( source, skin ) #:nodoc:
384
+
385
+ def add_guilded_css_path( source, skin ) #:nodoc:
373
386
  skin = 'default' if skin.nil? || skin.empty?
374
387
  part = "#{@css_folder}#{source.to_s}/#{skin}.css"
375
388
  path = "#{@css_path}#{part}"
@@ -5,18 +5,18 @@ module Guilded
5
5
  # Generates the initGuildedElements function and includes a call to each GUIlded
6
6
  # element(s) Init method.
7
7
  #
8
- # Must be called once per rendered page. You can include it just before the closing body
9
- # tag of your application layout. If no Guilded elements were called in the template, the
8
+ # Must be called once per rendered page. You can include it just before the closing body
9
+ # tag of your application layout. If no Guilded elements were called in the template, the
10
10
  # call to g_apply_behavior will not output anything.
11
11
  #
12
- def g_apply_behavior
13
- Guilded::Guilder.instance.generate_javascript_init
12
+ def g_apply_behavior( options={} )
13
+ Guilded::Guilder.instance.generate_javascript_init( options )
14
14
  end
15
-
15
+
16
16
  # Generates the JavaScript include(s) for each Guilded element that is used.
17
17
  #
18
- # Must be called once per rendered page. You can include it just before the closing body
19
- # tag of your application layout. If no Guilded elements were called in the template, the
18
+ # Must be called once per rendered page. You can include it just before the closing body
19
+ # tag of your application layout. If no Guilded elements were called in the template, the
20
20
  # call to g_apply_includes will not output anything.
21
21
  #
22
22
  def g_apply_includes
@@ -33,12 +33,12 @@ module Guilded
33
33
  end
34
34
  output
35
35
  end
36
-
36
+
37
37
  def g_apply_style
38
38
  "<!-- guilded.styles -->"
39
39
  end
40
-
41
- # Injects the CSS into the header. Must be called once per rendered page and within a scope that allows access
40
+
41
+ # Injects the CSS into the header. Must be called once per rendered page and within a scope that allows access
42
42
  # to the output buffer of the tempalte system being used.
43
43
  #
44
44
  def g_inject_styles
@@ -47,12 +47,12 @@ module Guilded
47
47
  end
48
48
 
49
49
  # Creates a javascript include tag for a Guilded specific file. The only difference
50
- # being that it adds the file to a sources array to be concatenated and included at the
50
+ # being that it adds the file to a sources array to be concatenated and included at the
51
51
  # end of the page with the dependencies specified for the Guilded components used.
52
52
  #
53
53
  # To explicitly include the jQuery or MooTools libraries you can use :jquery and/or :mootools
54
54
  # respectively. If a component that uses either jQuery or MooTools is used on a page, there is
55
- # no need to explicitly include the library, as it will be resolved as a dependency and only
55
+ # no need to explicitly include the library, as it will be resolved as a dependency and only
56
56
  # included once.
57
57
  #
58
58
  def g_javascript_include_tag( *sources )
@@ -82,19 +82,19 @@ module Guilded
82
82
  ''
83
83
  end
84
84
 
85
- # Replaces the Rails stylesheet_link_tag helper if you wnat Guilded to manage CSS for you.
85
+ # Replaces the Rails stylesheet_link_tag helper if you wnat Guilded to manage CSS for you.
86
86
  # Although the syntax is exactly the same, the method works a little differently.
87
- #
88
- # This helper adds the stylesheet(s) to a collection to be renderred out together
89
- # with all the guilded componenets stylesheets. This allows the stylesheets passed
87
+ #
88
+ # This helper adds the stylesheet(s) to a collection to be renderred out together
89
+ # with all the guilded componenets stylesheets. This allows the stylesheets passed
90
90
  # to this method to be cached with the guilded stylesheests into a single reusable file.
91
- #
91
+ #
92
92
  # The helper will ensure that these stylesheets are included after Guilded's reset
93
- # stylesheet and before guilded's component's stylesheets so that they can override any
93
+ # stylesheet and before guilded's component's stylesheets so that they can override any
94
94
  # resets, etc and not override any guilded components styles.
95
-
95
+
96
96
  # *options*
97
- # :position The place to position the css. pre for before the component's css or post for after.
97
+ # :position The place to position the css. pre for before the component's css or post for after.
98
98
  # Defaults to post.
99
99
  #
100
100
  def g_stylesheet_link_tag( *sources )
@@ -112,7 +112,7 @@ module Guilded
112
112
  ""
113
113
  end
114
114
  end
115
-
115
+
116
116
  end
117
117
  end
118
118
  end
@@ -7,7 +7,7 @@ GUILDED_CONFIG = {
7
7
  :js_folder => "", # from the js_path
8
8
  :jquery_js => "jquery/jquery-1.3.2.min.js", # from the js_path
9
9
  :use_remote_jquery => true,
10
- :jquery_remote_url => "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",
10
+ :jquery_remote_url => "//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",
11
11
  :mootools_js => "mootools/mootools-1.2.3.min.js", # from the js_path
12
12
  :css_path => "#{Rails.root}/public/stylesheets/",
13
13
  :css_folder => "guilded/", # from the css_path
data/spec/spec_helper.rb CHANGED
@@ -25,7 +25,7 @@ GUILDED_CONFIG = {
25
25
  :js_folder => "", # from the js_path
26
26
  :jquery_js => "jquery/jquery-1.3.2.min.js", # from the js_path
27
27
  :use_remote_jquery => true,
28
- :jquery_remote_url => "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",
28
+ :jquery_remote_url => "//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",
29
29
  :mootools_js => "mootools/mootools-1.2.3.min.js", # from the js_path
30
30
  :css_path => "#{Rails.root}/public/stylesheets/",
31
31
  :css_folder => "guilded/", # from the css_path
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 12
9
- version: 1.0.12
8
+ - 13
9
+ version: 1.0.13
10
10
  platform: ruby
11
11
  authors:
12
12
  - C. Jason Harrelson (midas)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-11 00:00:00 -05:00
17
+ date: 2010-08-04 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency