-
Notifications
You must be signed in to change notification settings - Fork 0
Changed the first javascript function to coffeescript #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
geraldma1998
wants to merge
6
commits into
master
Choose a base branch
from
change-javascript-to-coffeescript
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b175da8
Changed the first javascript function to coffeescript
geraldma1998 084af3f
Deleted javascript functions into comments
geraldma1998 0df50af
Merge branch 'master' of https://github.com/geraldma1998/apprentice_b…
geraldma1998 51e33c4
Fixed issues of ranking for posts
geraldma1998 b11d7e1
Fixed PR issue
geraldma1998 ebc242e
Refactored code of posts controller
geraldma1998 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| jQuery -> | ||
| "use strict" | ||
| # Floating label headings for the contact form | ||
| $( "body" ).on("input propertychange", ".floating-label-form-group", (e) -> | ||
| $(@).toggleClass "floating-label-form-group-with-value", !!$(e.target).val() | ||
| ).on("focus", ".floating-label-form-group", -> | ||
| $(@).addClass "floating-label-form-group-with-focus" | ||
| ).on("blur", ".floating-label-form-group", -> | ||
| $(@).removeClass "floating-label-form-group-with-focus" | ||
| ) | ||
|
|
||
| minimunScreenSize = 992 | ||
|
|
||
| #primary navigation slide-in effect | ||
| if $(window).width() > minimunScreenSize | ||
| headerHeight = $('#mainNav').height() | ||
| $(window).on('scroll', | ||
| previousTop: 0, | ||
| -> | ||
| currentTop = $(window).scrollTop() | ||
| #check if user is scrolling up | ||
| if (currentTop < @.previousTop) | ||
| #if scrolling up... | ||
| if currentTop > 0 && $('#mainNav').hasClass('is-fixed') | ||
| $('#mainNav').addClass('is-visible') | ||
| else | ||
| $('#mainNav').removeClass('is-visible is-fixed') | ||
| else if currentTop > @.previousTop | ||
| #if scrolling down... | ||
| $('#mainNav').removeClass('is-visible') | ||
| $('#mainNav').addClass('is-fixed') if (currentTop > headerHeight && !$('#mainNav').hasClass('is-fixed')) | ||
| @.previousTop = currentTop | ||
| ) | ||
|
|
||
| $('.remove-posts_category:first').hide() | ||
|
|
||
| reorderPostsCategories = -> | ||
| $('#posts_categories-form h4.subsection.new-posts_categories span:visible').each((index) -> | ||
| $(@).html(index + 1) | ||
| ) | ||
|
|
||
| $(document).on('nested:fieldAdded nested:fieldRemoved', (event) -> | ||
| reorderPostsCategories() | ||
| ) | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
|
|
||
| $(document).on "turbolinks:load", -> | ||
| return unless $("body").data("controller") == "posts" && $("body").data("action") == "show" | ||
|
|
||
| $stars = $('.rate-popover') | ||
|
|
||
| new_rank = 0 | ||
| currentElement = $('#current_post') | ||
| postId = currentElement.attr "data-post" | ||
| userId = currentElement.attr "data-user" | ||
|
|
||
| $stars.on('mouseover', -> | ||
| index = $(@).attr('data-index') | ||
| markStarsAsActive(index) | ||
| ) | ||
|
|
||
| markStarsAsActive = (index) -> | ||
| unmarkActive() | ||
| i = 0 | ||
| while i <= index | ||
| $($stars.get(i)).addClass('amber-text') | ||
| i++ | ||
|
|
||
| unmarkActive = -> | ||
| $stars.removeClass('amber-text') | ||
|
|
||
| $stars.on('click', -> | ||
| new_rank = $(@).attr('data-index') | ||
| url_request = "/rankings" | ||
|
|
||
| $.ajax( | ||
| type: 'POST', | ||
| url: url_request, | ||
| data: JSON.stringify ( | ||
| post_id: postId | ||
| user_id: userId | ||
| rank: new_rank, | ||
| commit: "Change Ranking" | ||
| ) | ||
| success: (data) -> | ||
| contentType: "application/json" | ||
| dataType: 'json' | ||
| ) | ||
| ) |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,5 +1,5 @@ | ||
| <tr> | ||
| <td><%= ranking.title %></td> | ||
| <td><%= link_to ranking.title, ranking %></td> | ||
| <td><%= ranking.user.username %></td> | ||
| <td><%= ranking.ranking_value %></td> | ||
| </tr> |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -9,6 +9,6 @@ | |
| </thead> | ||
|
|
||
| <tbody> | ||
| <%= render @posts %> | ||
| <%= render partial: "ranking", collection: @posts %> | ||
| </tbody> | ||
| </table> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.