Skip to content

Commit

Permalink
conflict resolve.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanghapal committed Sep 20, 2013
2 parents 6e86ac9 + 44d0da8 commit 2f9813a
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 10 deletions.
3 changes: 0 additions & 3 deletions app/assets/javascripts/levels.js.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

$("#bonus_round_unlocked").click ->
$("#bonus_round").show()
1 change: 1 addition & 0 deletions app/assets/javascripts/topics.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
e.stopPropagation
$('input[id="' + sid + '"]').focus()

$(document).ready ->
window.nestedFormEvents.insertFields = (content, assoc, link) ->
$(content).insertBefore(link)
if assoc == "contents"
Expand Down
9 changes: 7 additions & 2 deletions app/assets/javascripts/users.js.coffee
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@


errorElements = $(document).find('.help-inline').prev()
ul = $('<ul id="errorlist"></ul>')
errorElements.each (i) ->
span = $(this).next()
labelText = $(this).parent().parent().find('label')
$(' <li> <a href="#' + $(this).attr('id') + '" onclick=" " >' + labelText.text() + ' ' + '(' + span.text() + ')' + '</a></li>').appendTo(ul)
$('#profile').html(ul)
60 changes: 60 additions & 0 deletions app/assets/javascripts/validations.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
$(document).ready ->
#error elements test
#alert("error elements:" + $('.content:first .help-inline').size())
#get the errorElements
errorElements = $(document).find('.help-inline')

#validate only if errors exist
if(errorElements.length > 0)
#test where error container is
#$("#errorcontainer").html("Here I am")

#ul element as container for error summary
errorSummaryContainer = $(document.createElement("ul"))
errorSummaryContainer.attr("id","errorlist")

#append error summary to error container
$("#errorcontainer").append(errorSummaryContainer)

#Iterate through the error elements to create summary
#test individual error elements
#i = 0
errorElements.each ->
#Test results for each individual error element
#alert("this is error number " + ++i)

#individual participents
errorElement = $(this)#Note this singular
inputElement = errorElement.prev()#preventing another call to $(this)
labelElement = errorElement.parent().prev()#again preventing another call to $(this)

#test whether we have all the above three elements
#alert(labelElement.text() + ":" + labelElement.attr("for") + ":" + inputElement.attr("id") + ":" + errorElement.text())
#test to get only label text without the "*" sign
#alert(labelElement.contents().last().text())

#Error string
labelText = labelElement.contents().last().text()#without the "*"
errorString = labelText + "(" + errorElement.text() + ")"#e.g. First Name(Can't be blank)

#anchor element for error string
anchorElement = $(document.createElement("a"))
#Siddhant thinks that focussing input element can work even without the href in action
anchorElement.attr("href","javascript:void(0)")
anchorElement.addClass("errorlink")
anchorElement.text(errorString)

anchorElement.click ->
$("#" + inputElement.attr("id")).focus()

#listElement for anchor element
listElement = $(document.createElement("li"))
errorSummaryContainer.append(listElement)
listElement.append(anchorElement)


#End iteration
$(".errorlink:first").focus()
4 changes: 4 additions & 0 deletions app/views/home/_nominate_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
- content_for :javascript do
= javascript_include_tag 'validations'
= simple_form_for @nominate, url: nominate_path(@nominate), method: :post, html: {:class => 'form-horizontal'} do |f|
= f.error_notification
%p#errorcontainer

.form-inputs
= f.input :name
= f.input :email, required: false
Expand Down
4 changes: 4 additions & 0 deletions app/views/home/feedback.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
- content_for :javascript do
= javascript_include_tag 'validations'
%h1 Feedback form
.content
= simple_form_for @feedback, url: feedback_path, method: :post, html: {:class => 'form-horizontal'} do |f|
= f.error_notification
%p#errorcontainer

.form-inputs
= f.input :name
= f.input :email
Expand Down
5 changes: 4 additions & 1 deletion app/views/levels/_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
- content_for :javascript do
= javascript_include_tag 'validations'
= simple_nested_form_for @level, html: {:class => 'form-horizontal'} do |f|
= f.error_notification

%p#errorcontainer

.form-inputs
= f.input :level_number
= f.input :level_name
Expand Down
3 changes: 3 additions & 0 deletions app/views/topics/_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
- content_for :javascript do
= javascript_include_tag 'validations'
= simple_nested_form_for [@level, @topic], html: {:class => 'form-horizontal'} do |f|
= @topic.errors.full_messages

- if !@topic.errors.empty?
%p#errorcontainer
.form-inputs
Expand Down
2 changes: 2 additions & 0 deletions app/views/topics/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
%h1.delta New topic for #{@level.level_name} level
.content
= render 'form'
- content_for :javascript do
= javascript_include_tag 'nested_form'
6 changes: 3 additions & 3 deletions app/views/users/_frmprofile.html.haml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
- content_for :javascript do
= javascript_include_tag 'global'
= stylesheet_link_tag 'calendar'
= javascript_include_tag 'validations'

= stylesheet_link_tag 'calendar'
= simple_form_for @user, url: profile_path(@user), method: :post, html: {:class => 'form-horizontal'} do |u|
= u.error_notification

= u.simple_fields_for :profile do |p|

%p#errorcontainer
.form-inputs
= p.input :first_name
= p.input :last_name
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/profile.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
%th Correspondence Address
%th Date Of Birth
%th Contact Number
%th= @user.profile.disability if @user.profile.disability if @user.profile.disability.present?
%th= @user.profile.disability if @user.profile.disability.present?
%tr
%td= @user.profile.first_name + " " + @user.profile.last_name
%td= @user.profile.correspondence_address + " " + @user.profile.city + " " + @user.profile.state + " " + @user.profile.country
Expand Down
Binary file not shown.

0 comments on commit 2f9813a

Please sign in to comment.