Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e60df0e
commit 6d4a218
Showing
23 changed files
with
1,231 additions
and
1,231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,89 @@ | ||
|
||
// TODO Change to dropping the name property off the input element when in example mode | ||
TextFieldWithExample = Class.create(); | ||
TextFieldWithExample.prototype = { | ||
initialize: function(inputElementId, defaultText, options) { | ||
this.setOptions(options); | ||
|
||
this.input = $(inputElementId); | ||
this.name = this.input.name; | ||
this.defaultText = defaultText; | ||
this.createHiddenInput(); | ||
|
||
this.checkAndShowExample(); | ||
|
||
Event.observe(this.input, "blur", this.onBlur.bindAsEventListener(this)); | ||
Event.observe(this.input, "focus", this.onFocus.bindAsEventListener(this)); | ||
Event.observe(this.input, "select", this.onFocus.bindAsEventListener(this)); | ||
Event.observe(this.input, "keydown", this.onKeyPress.bindAsEventListener(this)); | ||
Event.observe(this.input, "click", this.onClick.bindAsEventListener(this)); | ||
}, | ||
createHiddenInput: function() { | ||
this.hiddenInput = document.createElement("input"); | ||
this.hiddenInput.type = "hidden"; | ||
this.hiddenInput.value = ""; | ||
this.input.parentNode.appendChild(this.hiddenInput); | ||
}, | ||
setOptions: function(options) { | ||
this.options = { exampleClassName: 'example' }; | ||
Object.extend(this.options, options || {}); | ||
}, | ||
onKeyPress: function(event) { | ||
if (!event) var event = window.event; | ||
var code = (event.which) ? event.which : event.keyCode | ||
if (this.isAlphanumeric(code)) { | ||
this.removeExample(); | ||
} | ||
}, | ||
onBlur: function(event) { | ||
this.checkAndShowExample(); | ||
}, | ||
onFocus: function(event) { | ||
if (this.exampleShown()) { | ||
this.removeExample(); | ||
} | ||
}, | ||
onClick: function(event) { | ||
this.removeExample(); | ||
}, | ||
isAlphanumeric: function(keyCode) { | ||
return keyCode >= 40 && keyCode <= 90; | ||
}, | ||
checkAndShowExample: function() { | ||
if (this.input.value == '') { | ||
this.input.value = this.defaultText; | ||
this.input.name = null; | ||
this.hiddenInput.name = this.name; | ||
Element.addClassName(this.input, this.options.exampleClassName); | ||
} | ||
}, | ||
removeExample: function() { | ||
if (this.exampleShown()) { | ||
this.input.value = ''; | ||
this.input.name = this.name; | ||
this.hiddenInput.name = null; | ||
Element.removeClassName(this.input, this.options.exampleClassName); | ||
} | ||
}, | ||
exampleShown: function() { | ||
return Element.hasClassName(this.input, this.options.exampleClassName); | ||
} | ||
} | ||
|
||
Form.disable = function(form) { | ||
var elements = this.getElements(form); | ||
for (var i = 0; i < elements.length; i++) { | ||
var element = elements[i]; | ||
try { element.blur(); } catch (e) {} | ||
element.disabled = 'disabled'; | ||
Element.addClassName(element, 'disabled'); | ||
} | ||
} | ||
Form.enable = function(form) { | ||
var elements = this.getElements(form); | ||
for (var i = 0; i < elements.length; i++) { | ||
var element = elements[i]; | ||
element.disabled = ''; | ||
Element.removeClassName(element, 'disabled'); | ||
} | ||
|
||
// TODO Change to dropping the name property off the input element when in example mode | ||
TextFieldWithExample = Class.create(); | ||
TextFieldWithExample.prototype = { | ||
initialize: function(inputElementId, defaultText, options) { | ||
this.setOptions(options); | ||
|
||
this.input = $(inputElementId); | ||
this.name = this.input.name; | ||
this.defaultText = defaultText; | ||
this.createHiddenInput(); | ||
|
||
this.checkAndShowExample(); | ||
|
||
Event.observe(this.input, "blur", this.onBlur.bindAsEventListener(this)); | ||
Event.observe(this.input, "focus", this.onFocus.bindAsEventListener(this)); | ||
Event.observe(this.input, "select", this.onFocus.bindAsEventListener(this)); | ||
Event.observe(this.input, "keydown", this.onKeyPress.bindAsEventListener(this)); | ||
Event.observe(this.input, "click", this.onClick.bindAsEventListener(this)); | ||
}, | ||
createHiddenInput: function() { | ||
this.hiddenInput = document.createElement("input"); | ||
this.hiddenInput.type = "hidden"; | ||
this.hiddenInput.value = ""; | ||
this.input.parentNode.appendChild(this.hiddenInput); | ||
}, | ||
setOptions: function(options) { | ||
this.options = { exampleClassName: 'example' }; | ||
Object.extend(this.options, options || {}); | ||
}, | ||
onKeyPress: function(event) { | ||
if (!event) var event = window.event; | ||
var code = (event.which) ? event.which : event.keyCode | ||
if (this.isAlphanumeric(code)) { | ||
this.removeExample(); | ||
} | ||
}, | ||
onBlur: function(event) { | ||
this.checkAndShowExample(); | ||
}, | ||
onFocus: function(event) { | ||
if (this.exampleShown()) { | ||
this.removeExample(); | ||
} | ||
}, | ||
onClick: function(event) { | ||
this.removeExample(); | ||
}, | ||
isAlphanumeric: function(keyCode) { | ||
return keyCode >= 40 && keyCode <= 90; | ||
}, | ||
checkAndShowExample: function() { | ||
if (this.input.value == '') { | ||
this.input.value = this.defaultText; | ||
this.input.name = null; | ||
this.hiddenInput.name = this.name; | ||
Element.addClassName(this.input, this.options.exampleClassName); | ||
} | ||
}, | ||
removeExample: function() { | ||
if (this.exampleShown()) { | ||
this.input.value = ''; | ||
this.input.name = this.name; | ||
this.hiddenInput.name = null; | ||
Element.removeClassName(this.input, this.options.exampleClassName); | ||
} | ||
}, | ||
exampleShown: function() { | ||
return Element.hasClassName(this.input, this.options.exampleClassName); | ||
} | ||
} | ||
|
||
Form.disable = function(form) { | ||
var elements = this.getElements(form); | ||
for (var i = 0; i < elements.length; i++) { | ||
var element = elements[i]; | ||
try { element.blur(); } catch (e) {} | ||
element.disabled = 'disabled'; | ||
Element.addClassName(element, 'disabled'); | ||
} | ||
} | ||
Form.enable = function(form) { | ||
var elements = this.getElements(form); | ||
for (var i = 0; i < elements.length; i++) { | ||
var element = elements[i]; | ||
element.disabled = ''; | ||
Element.removeClassName(element, 'disabled'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
/* IE hacks | ||
==================================== */ | ||
|
||
* html .active-scaffold-header, | ||
.active-scaffold li.form-element, | ||
.active-scaffold li.sub-section { | ||
zoom: 1; | ||
} | ||
|
||
* html .active-scaffold td .messages-container { | ||
border-top: solid 1px #DAFFCD; | ||
} | ||
|
||
.active-scaffold-header div.actions a.show_search { | ||
background-image: none; | ||
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/active_scaffold/default/magnifier.png', sizingMethod='crop'); | ||
} | ||
|
||
.active-scaffold .sub-form .association-record a.destroy { | ||
background-image: none; | ||
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/active_scaffold/default/cross.png', sizingMethod='crop'); | ||
} | ||
|
||
.active-scaffold-header div.actions a.disabled { | ||
filter: alpha(opacity=50); | ||
} | ||
|
||
.active-scaffold .show-view dd, | ||
.active-scaffold li.form-element dd { | ||
float: none; | ||
} | ||
|
||
.active-scaffold li.form-element dt { | ||
padding: 4px 0; | ||
/* IE hacks | ||
==================================== */ | ||
|
||
* html .active-scaffold-header, | ||
.active-scaffold li.form-element, | ||
.active-scaffold li.sub-section { | ||
zoom: 1; | ||
} | ||
|
||
* html .active-scaffold td .messages-container { | ||
border-top: solid 1px #DAFFCD; | ||
} | ||
|
||
.active-scaffold-header div.actions a.show_search { | ||
background-image: none; | ||
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/active_scaffold/default/magnifier.png', sizingMethod='crop'); | ||
} | ||
|
||
.active-scaffold .sub-form .association-record a.destroy { | ||
background-image: none; | ||
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/active_scaffold/default/cross.png', sizingMethod='crop'); | ||
} | ||
|
||
.active-scaffold-header div.actions a.disabled { | ||
filter: alpha(opacity=50); | ||
} | ||
|
||
.active-scaffold .show-view dd, | ||
.active-scaffold li.form-element dd { | ||
float: none; | ||
} | ||
|
||
.active-scaffold li.form-element dt { | ||
padding: 4px 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<% | ||
parent_record = @record | ||
associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name) | ||
associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order) | ||
|
||
show_blank_record = (column.plural_association? or (column.singular_association? and associated.empty?)) | ||
show_blank_record = false if column.through_association? | ||
show_blank_record = false unless column.association.klass.authorized_for?(:action => :create) | ||
|
||
associated << column.association.klass.new if show_blank_record | ||
-%> | ||
<h5><%= column.label -%> (<%= link_to_visibility_toggle(:default_visible => !column.collapsed) -%>)</h5> | ||
<div <%= 'style="display: none;"' if column.collapsed -%>> | ||
<%= render :partial => subform_partial_for_column(column), :locals => {:column => column, :scope => column_scope(column), :parent_record => parent_record, :associated => associated} %> | ||
</div> | ||
<% @record = parent_record -%> | ||
<% | ||
parent_record = @record | ||
associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name) | ||
associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order) | ||
|
||
show_blank_record = (column.plural_association? or (column.singular_association? and associated.empty?)) | ||
show_blank_record = false if column.through_association? | ||
show_blank_record = false unless column.association.klass.authorized_for?(:action => :create) | ||
|
||
associated << column.association.klass.new if show_blank_record | ||
-%> | ||
<h5><%= column.label -%> (<%= link_to_visibility_toggle(:default_visible => !column.collapsed) -%>)</h5> | ||
<div <%= 'style="display: none;"' if column.collapsed -%>> | ||
<%= render :partial => subform_partial_for_column(column), :locals => {:column => column, :scope => column_scope(column), :parent_record => parent_record, :associated => associated} %> | ||
</div> | ||
<% @record = parent_record -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<thead> | ||
<tr> | ||
<% | ||
active_scaffold_config_for(@record.class).subform.columns.each :for => @record, :flatten => true do |column| | ||
next unless in_subform?(column, parent_record) and column_renders_as(column) != :hidden | ||
-%> | ||
<th><%= column.label %></th> | ||
<% end -%> | ||
</tr> | ||
<thead> | ||
<tr> | ||
<% | ||
active_scaffold_config_for(@record.class).subform.columns.each :for => @record, :flatten => true do |column| | ||
next unless in_subform?(column, parent_record) and column_renders_as(column) != :hidden | ||
-%> | ||
<th><%= column.label %></th> | ||
<% end -%> | ||
</tr> | ||
</thead> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
<% readonly = (@record.readonly? or not @record.authorized_for?(:action => :update)) -%> | ||
<% active_scaffold_config_for(@record.class).subform.columns.each :for => @record, :flatten => true do |column| %> | ||
<% | ||
next unless in_subform?(column, parent_record) | ||
column = column.clone | ||
column.form_ui ||= :select if column.association | ||
-%> | ||
<td> | ||
<% unless readonly -%> | ||
<%= render :partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope } -%> | ||
<% else -%> | ||
<p><%= h @record.send(column.name) -%></p> | ||
<% end -%> | ||
</td> | ||
<% end -%> | ||
<td class="actions"> | ||
<%= link_to_function as_('Remove'), '$(this).up(".association-record").remove()', { :class => "destroy" } -%> | ||
<% unless @record.new_record? %> | ||
<input type="hidden" name="<%= "record#{scope}[id]" -%>" value="<%= @record.id -%>" /> | ||
<% end -%> | ||
</td> | ||
<% readonly = (@record.readonly? or not @record.authorized_for?(:action => :update)) -%> | ||
<% active_scaffold_config_for(@record.class).subform.columns.each :for => @record, :flatten => true do |column| %> | ||
<% | ||
next unless in_subform?(column, parent_record) | ||
column = column.clone | ||
column.form_ui ||= :select if column.association | ||
-%> | ||
<td> | ||
<% unless readonly -%> | ||
<%= render :partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope } -%> | ||
<% else -%> | ||
<p><%= h @record.send(column.name) -%></p> | ||
<% end -%> | ||
</td> | ||
<% end -%> | ||
<td class="actions"> | ||
<%= link_to_function as_('Remove'), '$(this).up(".association-record").remove()', { :class => "destroy" } -%> | ||
<% unless @record.new_record? %> | ||
<input type="hidden" name="<%= "record#{scope}[id]" -%>" value="<%= @record.id -%>" /> | ||
<% end -%> | ||
</td> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<table cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td class="indicator-container"> | ||
<%= loading_indicator_tag(:action => :record, :id => record.id) %> | ||
</td> | ||
<% active_scaffold_config.action_links.each :record do |link| -%> | ||
<% next if controller.respond_to? link.security_method and !controller.send(link.security_method) -%> | ||
<td> | ||
<%= record.authorized_for?(:action => link.crud_type) ? render_action_link(link, url_options) : "<a class='disabled'>#{link.label}</a>" -%> | ||
</td> | ||
<% end -%> | ||
</tr> | ||
<table cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td class="indicator-container"> | ||
<%= loading_indicator_tag(:action => :record, :id => record.id) %> | ||
</td> | ||
<% active_scaffold_config.action_links.each :record do |link| -%> | ||
<% next if controller.respond_to? link.security_method and !controller.send(link.security_method) -%> | ||
<td> | ||
<%= record.authorized_for?(:action => link.crud_type) ? render_action_link(link, url_options) : "<a class='disabled'>#{link.label}</a>" -%> | ||
</td> | ||
<% end -%> | ||
</tr> | ||
</table> |
Oops, something went wrong.