muck-engine 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -31,9 +31,15 @@ class Admin::Muck::BaseController < ApplicationController
31
31
 
32
32
  # Output a page update that will display messages in the flash
33
33
  def output_admin_messages(fields = nil, title = '', options = { :class => 'notify-box' }, flash_only = false)
34
- render :update do |page|
35
- page.replace_html 'admin-messages', output_errors(title, options, fields, flash_only)
36
- end
34
+ @fields = fields
35
+ @title = title
36
+ @options = options
37
+ @flash_only = flash_only
38
+ render :template => 'admin/shared/output_admin_messages', :layout => false
37
39
  end
38
40
 
41
+ def output_admin_messages
42
+
43
+ end
44
+
39
45
  end
@@ -10,4 +10,9 @@ module MuckAdminHelper
10
10
  end
11
11
  end
12
12
 
13
+ # Generates a string that will hide admin messages.
14
+ def hide_admin_messages
15
+ "jQuery('#admin-messages').hide();"
16
+ end
17
+
13
18
  end
@@ -113,6 +113,7 @@ class MuckCustomFormBuilder < ActionView::Helpers::FormBuilder
113
113
  end
114
114
  end
115
115
 
116
+ # Call '<%= country_scripts %>' to render javascript that will change the state control based on the current country
116
117
  # creates a select control with us states. Default id is 'us_states'. If 'retain' is passed for the class value the value of this
117
118
  # control will be written into a cookie with the key 'us_states'.
118
119
  def us_state_select(method, options = {}, html_options = {}, additional_state = nil)
@@ -23,6 +23,13 @@ module MuckEngineHelper
23
23
  end
24
24
  end
25
25
 
26
+ # Outputs scripts that manipulate the country and state select controls
27
+ def country_scripts
28
+ return if @@country_scripts_included
29
+ @@country_scripts_included = true
30
+ render :partial => 'scripts/country_scripts'
31
+ end
32
+
26
33
  def custom_form_for(record_or_name_or_array, *args, &proc)
27
34
  options = args.detect { |argument| argument.is_a?(Hash) }
28
35
  if options.nil?
@@ -131,11 +138,11 @@ module MuckEngineHelper
131
138
 
132
139
  # Used inside of format.js to return a message to the client.
133
140
  # If jGrowl is enabled the message will show up as a growl instead of a popup
134
- def page_alert(page, message, title = '')
141
+ def page_alert(message, title = '')
135
142
  if GlobalConfig.growl_enabled
136
- page << "jQuery.jGrowl.error('" + message + "', {header:'" + title + "'});"
143
+ "jQuery.jGrowl.error('" + message + "', {header:'" + title + "'});"
137
144
  else
138
- page.alert(message)
145
+ "alert(#{message});"
139
146
  end
140
147
  end
141
148
 
@@ -0,0 +1,2 @@
1
+ jQuery('#admin-messages').html('<%= escape_javascript(output_errors(@title, @options, @fields, @flash_only))%>');
2
+ jQuery('#admin-messages').show();
@@ -21,7 +21,7 @@
21
21
  jQuery('#colorSelectorDisplay<%=html_id%>').css('backgroundColor', '#' + hex);
22
22
  jQuery('#<%=field_name%>').val(hex);
23
23
  }
24
- });
24
+ });
25
25
  });
26
26
  </script>
27
27
  </div>
@@ -0,0 +1,3 @@
1
+ <% content_for :head do -%>
2
+ <%= javascript_include_tag 'muck-countries' %>
3
+ <% end -%>
@@ -1,5 +1,7 @@
1
1
  <div <%=css_class%> id="errorExplanation">
2
- <h2><%= title %></h2>
2
+ <% if !title.blank? -%>
3
+ <h2><%= title %></h2>
4
+ <% end -%>
3
5
  <%= flash_html %>
4
6
  <%= field_errors %>
5
7
  <%= extra_html %>
@@ -1,24 +1,26 @@
1
1
  class MuckEngine
2
2
  module FlashErrors
3
3
 
4
+ # Output only flash errors
4
5
  def output_flash(options = {})
5
6
  output_errors('', options, nil, true)
6
7
  end
7
8
 
9
+ # Output flash and object errors
8
10
  def output_errors(title, options = {}, fields = nil, flash_only = false)
9
11
  fields = [fields] unless fields.is_a?(Array)
10
12
  flash_html = render(:partial => 'shared/flash_messages')
11
13
  flash.clear
12
- css_class = "class=\"#{options[:class]}\"" unless options[:class].nil?
14
+ css_class = "class=\"#{options[:class] || 'error'}\"" unless options[:class].nil?
13
15
  field_errors = render(:partial => 'shared/field_error', :collection => fields)
14
-
16
+
15
17
  if flash_only || (!flash_html.empty? && field_errors.empty?)
16
18
  # Only flash. Don't render errors for any fields
17
19
  render(:partial => 'shared/flash_error_box', :locals => {:flash_html => flash_html, :css_class => css_class})
18
20
  elsif !field_errors.empty?
19
21
  # Field errors and/or flash
20
- render(:partial => 'shared/error_box', :locals => {:title => title,
21
- :flash_html => flash_html,
22
+ render(:partial => 'shared/error_box', :locals => {:title => title,
23
+ :flash_html => flash_html,
22
24
  :field_errors => field_errors,
23
25
  :css_class => css_class,
24
26
  :extra_html => options[:extra_html]})
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-engine}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball", "Joel Duffin"]
12
- s.date = %q{2010-01-30}
12
+ s.date = %q{2010-02-01}
13
13
  s.description = %q{The base engine for the muck system. Contains common tables, custom for, css and javascript.}
14
14
  s.email = %q{justin@tatemae.com}
15
15
  s.extra_rdoc_files = [
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  "app/models/language.rb",
33
33
  "app/models/state.rb",
34
34
  "app/views/admin/default/index.html.erb",
35
+ "app/views/admin/shared/output_admin_messages.js.erb",
35
36
  "app/views/forms/_base_field.html.erb",
36
37
  "app/views/forms/_color_picker_field.html.erb",
37
38
  "app/views/forms/_default.html.erb",
@@ -51,6 +52,7 @@ Gem::Specification.new do |s|
51
52
  "app/views/layouts/global/_google_analytics.html.erb",
52
53
  "app/views/layouts/global/_head.html.erb",
53
54
  "app/views/layouts/popup.html.erb",
55
+ "app/views/scripts/_country_scripts.html.erb",
54
56
  "app/views/scripts/_parse_uri.html.erb",
55
57
  "app/views/scripts/_time_scripts.html.erb",
56
58
  "app/views/shared/_delete.html.erb",
@@ -541,6 +543,7 @@ Gem::Specification.new do |s|
541
543
  "public/javascripts/jquery/jquery.swapimage.min.js",
542
544
  "public/javascripts/jquery/jquery.tips.js",
543
545
  "public/javascripts/jquery/jrails.js",
546
+ "public/javascripts/muck-countries.js",
544
547
  "public/javascripts/muck.js",
545
548
  "public/javascripts/muck_time/en.js",
546
549
  "public/javascripts/tree.js",
@@ -0,0 +1,50 @@
1
+ function setup_country(force_load){
2
+
3
+ var country_id = jQuery("#countries").val();
4
+ var state_id = jQuery("#states").val();
5
+
6
+ if (country_id == undefined){
7
+ return;
8
+ }
9
+
10
+ if (country_id == '-1'){
11
+ jQuery("#states").val('-1');
12
+ jQuery("#counties").val('-1');
13
+ }
14
+
15
+ if (country_id == '-1' || country_id == ''){
16
+ jQuery("#states-container").hide();
17
+ jQuery("#counties-container").hide();
18
+ return;
19
+ }
20
+
21
+ if(force_load || state_id == '' || state_id == null || state_id == -1) {
22
+ jQuery.getJSON("/helper/load_states_for_country/" + country_id + ".js", function(data){
23
+ var options = '';
24
+ jQuery("#counties-container").hide();
25
+ jQuery('#states-container label').html(data.label);
26
+ states = data.states;
27
+ if(states.length > 0){
28
+ for (var i = 0; i < states.length; i++) {
29
+ var state_id = states[i].state.id;
30
+ if(state_id == undefined) { state_id = ''; }
31
+ options += '<option value="' + state_id + '">' + states[i].state.name + '</option>';
32
+ }
33
+ jQuery("#states-container").show();
34
+ jQuery("select#states").html(options);
35
+ } else {
36
+ jQuery("#states-container").hide();
37
+ }
38
+ });
39
+ }
40
+ }
41
+
42
+ jQuery(document).ready(function() {
43
+ jQuery("#countries-container select").change(function() {
44
+ setup_country(true);
45
+ });
46
+ if(jQuery("#states").val() == '' || jQuery("#states").val() == null) {
47
+ jQuery("#states-container").hide();
48
+ }
49
+ setup_country(false);
50
+ });
@@ -8,88 +8,6 @@ jQuery(document).ajaxSend(function(event, request, settings) {
8
8
  settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
9
9
  });
10
10
 
11
- function setup_submit_delete(){
12
- jQuery(".submit-delete").click(function() {
13
- // if(!confirm("Are you sure?")){
14
- // return false;
15
- // }
16
- jQuery(this).parents('.delete-container').fadeOut();
17
- var form = jQuery(this).parents('form');
18
- jQuery.post(form.attr('action') + '.json', form.serialize(),
19
- function(data){
20
- var json = eval('(' + data + ')');
21
- if(!json.success){
22
- jQuery.jGrowl.info(json.message);
23
- }
24
- });
25
- return false;
26
- });
27
- jQuery(".submit-delete-js").click(function() {
28
- // if(!confirm("Are you sure?")){
29
- // return false;
30
- // }
31
- jQuery(this).parents('.delete-container').fadeOut();
32
- var form = jQuery(this).parents('form');
33
- jQuery.post(form.attr('action') + '.js', form.serialize(),
34
- function(data){
35
- });
36
- return false;
37
- });
38
- }
39
-
40
- function show_hide_obj (ary_objs_to_show, ary_objs_to_hide)
41
- {
42
- for (i=0;i<ary_objs_to_show.length;i++) {
43
- if (obj_to_show = document.getElementById(ary_objs_to_show[i])) obj_to_show.style.display="";
44
- if (tab = document.getElementById('anchor'+ary_objs_to_show[i])) tab.className = 'curTab';
45
- }
46
- for (i=0;i<ary_objs_to_hide.length;i++) {
47
- if (obj_to_hide = document.getElementById(ary_objs_to_hide[i])) obj_to_hide.style.display="none";
48
- if (tab = document.getElementById('anchor'+ary_objs_to_hide[i])) tab.className = '';
49
- }
50
- }
51
-
52
- function setup_country(force_load){
53
-
54
- var country_id = jQuery("#countries").val();
55
- var state_id = jQuery("#states").val();
56
-
57
- if (country_id == undefined){
58
- return;
59
- }
60
-
61
- if (country_id == '-1'){
62
- jQuery("#states").val('-1');
63
- jQuery("#counties").val('-1');
64
- }
65
-
66
- if (country_id == '-1' || country_id == ''){
67
- jQuery("#states-container").hide();
68
- jQuery("#counties-container").hide();
69
- return;
70
- }
71
-
72
- if(force_load || state_id == '' || state_id == null || state_id == -1) {
73
- jQuery.getJSON("/helper/load_states_for_country/" + country_id + ".js", function(data){
74
- var options = '';
75
- jQuery("#counties-container").hide();
76
- jQuery('#states-container label').html(data.label);
77
- states = data.states;
78
- if(states.length > 0){
79
- for (var i = 0; i < states.length; i++) {
80
- var state_id = states[i].state.id;
81
- if(state_id == undefined) { state_id = ''; }
82
- options += '<option value="' + state_id + '">' + states[i].state.name + '</option>';
83
- }
84
- jQuery("#states-container").show();
85
- jQuery("select#states").html(options);
86
- } else {
87
- jQuery("#states-container").hide();
88
- }
89
- });
90
- }
91
- }
92
-
93
11
  function apply_ajax_forms() {
94
12
  jQuery('form.ajax').ajaxForm({
95
13
  dataType: 'script',
@@ -133,21 +51,26 @@ jQuery(document).ready(function() {
133
51
  return false;
134
52
  });
135
53
 
136
- jQuery("#global-login").focus(function() {
137
- jQuery("#global-login").val("");
138
- });
139
- jQuery("#global-password").focus(function() {
140
- jQuery("#global-password").val("");
141
- });
142
- jQuery("#quick-login-submit").click(function() {
143
- jQuery("#quick-login").submit();
144
- });
145
-
146
- jQuery("#countries-container select").change(function() {
147
- setup_country(true);
54
+ jQuery(".submit-delete").live('click', function() {
55
+ jQuery(this).parents('.delete-container').fadeOut();
56
+ var form = jQuery(this).parents('form');
57
+ jQuery.post(form.attr('action') + '.json', form.serialize(),
58
+ function(data){
59
+ var json = eval('(' + data + ')');
60
+ if(!json.success){
61
+ jQuery.jGrowl.info(json.message);
62
+ }
63
+ });
64
+ return false;
65
+ });
66
+
67
+ jQuery(".submit-delete-js").live('click', function() {
68
+ jQuery(this).parents('.delete-container').fadeOut();
69
+ var form = jQuery(this).parents('form');
70
+ jQuery.post(form.attr('action') + '.js', form.serialize(),
71
+ function(data){
72
+ });
73
+ return false;
148
74
  });
149
- if(jQuery("#states").val() == '' || jQuery("#states").val() == null) {
150
- jQuery("#states-container").hide();
151
- }
152
- setup_country(false);
75
+
153
76
  });
@@ -26,7 +26,9 @@ ul.admin-list li a{font-size:1.2em;}
26
26
  /* errors, message */
27
27
  .notify-box{font-size:1.2em;color:#555;width:100%}
28
28
  .error,.notice,.success {margin:0;}
29
- #errorExplanation{margin:0;padding:0;}
29
+ #errorExplanation{margin:0;padding:.8em;width:97%;border:2px solid #ddd;background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;}
30
+ #admin-messages{display:none;}
31
+
30
32
  /* tables */
31
33
  .adminTable{margin:5px 0 0 0;padding:0 0 40px 0px;width:980px;}
32
34
  .adminTable a{color:#000;text-decoration:none;font-weight:bold;}
@@ -8,88 +8,6 @@ jQuery(document).ajaxSend(function(event, request, settings) {
8
8
  settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
9
9
  });
10
10
 
11
- function setup_submit_delete(){
12
- jQuery(".submit-delete").click(function() {
13
- // if(!confirm("Are you sure?")){
14
- // return false;
15
- // }
16
- jQuery(this).parents('.delete-container').fadeOut();
17
- var form = jQuery(this).parents('form');
18
- jQuery.post(form.attr('action') + '.json', form.serialize(),
19
- function(data){
20
- var json = eval('(' + data + ')');
21
- if(!json.success){
22
- jQuery.jGrowl.info(json.message);
23
- }
24
- });
25
- return false;
26
- });
27
- jQuery(".submit-delete-js").click(function() {
28
- // if(!confirm("Are you sure?")){
29
- // return false;
30
- // }
31
- jQuery(this).parents('.delete-container').fadeOut();
32
- var form = jQuery(this).parents('form');
33
- jQuery.post(form.attr('action') + '.js', form.serialize(),
34
- function(data){
35
- });
36
- return false;
37
- });
38
- }
39
-
40
- function show_hide_obj (ary_objs_to_show, ary_objs_to_hide)
41
- {
42
- for (i=0;i<ary_objs_to_show.length;i++) {
43
- if (obj_to_show = document.getElementById(ary_objs_to_show[i])) obj_to_show.style.display="";
44
- if (tab = document.getElementById('anchor'+ary_objs_to_show[i])) tab.className = 'curTab';
45
- }
46
- for (i=0;i<ary_objs_to_hide.length;i++) {
47
- if (obj_to_hide = document.getElementById(ary_objs_to_hide[i])) obj_to_hide.style.display="none";
48
- if (tab = document.getElementById('anchor'+ary_objs_to_hide[i])) tab.className = '';
49
- }
50
- }
51
-
52
- function setup_country(force_load){
53
-
54
- var country_id = jQuery("#countries").val();
55
- var state_id = jQuery("#states").val();
56
-
57
- if (country_id == undefined){
58
- return;
59
- }
60
-
61
- if (country_id == '-1'){
62
- jQuery("#states").val('-1');
63
- jQuery("#counties").val('-1');
64
- }
65
-
66
- if (country_id == '-1' || country_id == ''){
67
- jQuery("#states-container").hide();
68
- jQuery("#counties-container").hide();
69
- return;
70
- }
71
-
72
- if(force_load || state_id == '' || state_id == null || state_id == -1) {
73
- jQuery.getJSON("/helper/load_states_for_country/" + country_id + ".js", function(data){
74
- var options = '';
75
- jQuery("#counties-container").hide();
76
- jQuery('#states-container label').html(data.label);
77
- states = data.states;
78
- if(states.length > 0){
79
- for (var i = 0; i < states.length; i++) {
80
- var state_id = states[i].state.id;
81
- if(state_id == undefined) { state_id = ''; }
82
- options += '<option value="' + state_id + '">' + states[i].state.name + '</option>';
83
- }
84
- jQuery("#states-container").show();
85
- jQuery("select#states").html(options);
86
- } else {
87
- jQuery("#states-container").hide();
88
- }
89
- });
90
- }
91
- }
92
-
93
11
  function apply_ajax_forms() {
94
12
  jQuery('form.ajax').ajaxForm({
95
13
  dataType: 'script',
@@ -133,21 +51,26 @@ jQuery(document).ready(function() {
133
51
  return false;
134
52
  });
135
53
 
136
- jQuery("#global-login").focus(function() {
137
- jQuery("#global-login").val("");
138
- });
139
- jQuery("#global-password").focus(function() {
140
- jQuery("#global-password").val("");
141
- });
142
- jQuery("#quick-login-submit").click(function() {
143
- jQuery("#quick-login").submit();
144
- });
145
-
146
- jQuery("#countries-container select").change(function() {
147
- setup_country(true);
54
+ jQuery(".submit-delete").live('click', function() {
55
+ jQuery(this).parents('.delete-container').fadeOut();
56
+ var form = jQuery(this).parents('form');
57
+ jQuery.post(form.attr('action') + '.json', form.serialize(),
58
+ function(data){
59
+ var json = eval('(' + data + ')');
60
+ if(!json.success){
61
+ jQuery.jGrowl.info(json.message);
62
+ }
63
+ });
64
+ return false;
65
+ });
66
+
67
+ jQuery(".submit-delete-js").live('click', function() {
68
+ jQuery(this).parents('.delete-container').fadeOut();
69
+ var form = jQuery(this).parents('form');
70
+ jQuery.post(form.attr('action') + '.js', form.serialize(),
71
+ function(data){
72
+ });
73
+ return false;
148
74
  });
149
- if(jQuery("#states").val() == '' || jQuery("#states").val() == null) {
150
- jQuery("#states-container").hide();
151
- }
152
- setup_country(false);
75
+
153
76
  });
@@ -26,7 +26,9 @@ ul.admin-list li a{font-size:1.2em;}
26
26
  /* errors, message */
27
27
  .notify-box{font-size:1.2em;color:#555;width:100%}
28
28
  .error,.notice,.success {margin:0;}
29
- #errorExplanation{margin:0;padding:0;}
29
+ #errorExplanation{margin:0;padding:.8em;width:97%;border:2px solid #ddd;background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;}
30
+ #admin-messages{display:none;}
31
+
30
32
  /* tables */
31
33
  .adminTable{margin:5px 0 0 0;padding:0 0 40px 0px;width:980px;}
32
34
  .adminTable a{color:#000;text-decoration:none;font-weight:bold;}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Ball
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-01-30 00:00:00 -07:00
13
+ date: 2010-02-01 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -78,6 +78,7 @@ files:
78
78
  - app/models/language.rb
79
79
  - app/models/state.rb
80
80
  - app/views/admin/default/index.html.erb
81
+ - app/views/admin/shared/output_admin_messages.js.erb
81
82
  - app/views/forms/_base_field.html.erb
82
83
  - app/views/forms/_color_picker_field.html.erb
83
84
  - app/views/forms/_default.html.erb
@@ -97,6 +98,7 @@ files:
97
98
  - app/views/layouts/global/_google_analytics.html.erb
98
99
  - app/views/layouts/global/_head.html.erb
99
100
  - app/views/layouts/popup.html.erb
101
+ - app/views/scripts/_country_scripts.html.erb
100
102
  - app/views/scripts/_parse_uri.html.erb
101
103
  - app/views/scripts/_time_scripts.html.erb
102
104
  - app/views/shared/_delete.html.erb
@@ -587,6 +589,7 @@ files:
587
589
  - public/javascripts/jquery/jquery.swapimage.min.js
588
590
  - public/javascripts/jquery/jquery.tips.js
589
591
  - public/javascripts/jquery/jrails.js
592
+ - public/javascripts/muck-countries.js
590
593
  - public/javascripts/muck.js
591
594
  - public/javascripts/muck_time/en.js
592
595
  - public/javascripts/tree.js