forked from External/greenlight
Merge pull request #5 from jfederico/master
Encapsulated javascript for landingController
This commit is contained in:
commit
14ad57d4d1
|
@ -1,3 +0,0 @@
|
||||||
# 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://coffeescript.org/
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
(function() {
|
||||||
|
var initIndex = function() {
|
||||||
|
$('#join_form_button').click (function (event) {
|
||||||
|
$.ajax({
|
||||||
|
url : $(this).data ('url') + "?name=" + $('#join_form_name').val(),
|
||||||
|
dataType : "json",
|
||||||
|
async : true,
|
||||||
|
type : 'GET',
|
||||||
|
success : function(data) {
|
||||||
|
$(location).attr("href", data.response.join_url);
|
||||||
|
},
|
||||||
|
error : function(xhr, status, error) {
|
||||||
|
},
|
||||||
|
complete : function(xhr, status) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).on("turbolinks:load", function() {
|
||||||
|
if ($("body[data-controller=landing]").get(0)) {
|
||||||
|
if ($("body[data-action=index]").get(0)) {
|
||||||
|
initIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).call(this);
|
|
@ -45,26 +45,6 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
$(document).ready(function($) {
|
|
||||||
$('#join_form_button').click (function (event) {
|
|
||||||
$.ajax({
|
|
||||||
url : $(this).data ('url') + "?name=" + $('#join_form_name').val(),
|
|
||||||
dataType : "json",
|
|
||||||
async : true,
|
|
||||||
type : 'GET',
|
|
||||||
success : function(data) {
|
|
||||||
$(location).attr("href", data.response.join_url);
|
|
||||||
},
|
|
||||||
error : function(xhr, status, error) {
|
|
||||||
},
|
|
||||||
complete : function(xhr, status) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<% if current_user.nil? %>
|
<% if current_user.nil? %>
|
||||||
<ul>
|
<ul>
|
||||||
<li><%= link_to 'Twitter', '/auth/twitter' %></li>
|
<li><%= link_to 'Twitter', '/auth/twitter' %></li>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>">
|
||||||
<!-- Messages -->
|
<!-- Messages -->
|
||||||
<div id='messages' class='hidden'>
|
<div id='messages' class='hidden'>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue