Permalink
Browse files

Changed secrets templates to .haml, added missing autofinger partial,…

… removed exptra .js file
  • Loading branch information...
1 parent 0038cea commit 6f038fd87350fdba92f3dd63f37000e5ee196671 @annaswims annaswims committed Jun 13, 2011
@@ -0,0 +1,6 @@
+Level1
+=show_autofinger(1)
+Level2
+=show_autofinger(2)
+Level3
+=show_autofinger(3)
@@ -1,17 +0,0 @@
-<%= form_for(@secret) do |f| %>
- <% if @secret.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@secret.errors.count, "error") %> prohibited this secret from being saved:</h2>
-
- <ul>
- <% @secret.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <div class="actions">
- <%= f.submit %>
- </div>
-<% end %>
@@ -0,0 +1,14 @@
+= form_for(@secret) do |f|
+ -if @secret.errors.any?
+ .error_explanation
+ %h2
+ = pluralize(@secret.errors.count, "error")
+ prohibited this secret from being saved:
+ %ul
+ -@secret.errors.full_messages.each do |msg|
+ %li
+ = msg
+ =f.label :secret_text, "Secret"
+ =f.text_area :secret_text
+ #actions
+ = f.submit
@@ -1,21 +0,0 @@
-<h1>Listing secrets</h1>
-
-<table>
- <tr>
- <th></th>
- <th></th>
- <th></th>
- </tr>
-
-<% @secrets.each do |secret| %>
- <tr>
- <td><%= link_to 'Show', secret %></td>
- <td><%= link_to 'Edit', edit_secret_path(secret) %></td>
- <td><%= link_to 'Destroy', secret, :confirm => 'Are you sure?', :method => :delete %></td>
- </tr>
-<% end %>
-</table>
-
-<br />
-
-<%= link_to 'New Secret', new_secret_path %>
@@ -0,0 +1,13 @@
+%h1 Listing secrets
+= will_paginate @secrets
+
+-@secrets.each do |secret|
+ = secret.secret_id
+ %b
+ = secret.date
+ %br
+ = secret.secret_text
+ %br
+%br
+= link_to 'New Secret', new_secret_path
+%br
@@ -1,5 +0,0 @@
-<h1>New secret</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Back', secrets_path %>
@@ -0,0 +1,3 @@
+%h1 New secret
+= render 'form'
+= link_to 'Back', secrets_path
@@ -1,5 +0,0 @@
-<p id="notice"><%= notice %></p>
-
-
-<%= link_to 'Edit', edit_secret_path(@secret) %> |
-<%= link_to 'Back', secrets_path %>
View
@@ -1,157 +0,0 @@
-/**
- * Unobtrusive scripting adapter for jQuery
- *
- * Requires jQuery 1.4.3 or later.
- * https://github.com/rails/jquery-ujs
- */
-
-(function($) {
- // Make sure that every Ajax request sends the CSRF token
- function CSRFProtection(xhr) {
- var token = $('meta[name="csrf-token"]').attr('content');
- if (token) xhr.setRequestHeader('X-CSRF-Token', token);
- }
- if ('ajaxPrefilter' in $) $.ajaxPrefilter(function(options, originalOptions, xhr){ CSRFProtection(xhr) });
- else $(document).ajaxSend(function(e, xhr){ CSRFProtection(xhr) });
-
- // Triggers an event on an element and returns the event result
- function fire(obj, name, data) {
- var event = new $.Event(name);
- obj.trigger(event, data);
- return event.result !== false;
- }
-
- // Submits "remote" forms and links with ajax
- function handleRemote(element) {
- var method, url, data,
- dataType = element.attr('data-type') || ($.ajaxSettings && $.ajaxSettings.dataType);
-
- if (element.is('form')) {
- method = element.attr('method');
- url = element.attr('action');
- data = element.serializeArray();
- // memoized value from clicked submit button
- var button = element.data('ujs:submit-button');
- if (button) {
- data.push(button);
- element.data('ujs:submit-button', null);
- }
- } else {
- method = element.attr('data-method');
- url = element.attr('href');
- data = null;
- }
-
- $.ajax({
- url: url, type: method || 'GET', data: data, dataType: dataType,
- // stopping the "ajax:beforeSend" event will cancel the ajax request
- beforeSend: function(xhr, settings) {
- if (settings.dataType === undefined) {
- xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
- }
- return fire(element, 'ajax:beforeSend', [xhr, settings]);
- },
- success: function(data, status, xhr) {
- element.trigger('ajax:success', [data, status, xhr]);
- },
- complete: function(xhr, status) {
- element.trigger('ajax:complete', [xhr, status]);
- },
- error: function(xhr, status, error) {
- element.trigger('ajax:error', [xhr, status, error]);
- }
- });
- }
-
- // Handles "data-method" on links such as:
- // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
- function handleMethod(link) {
- var href = link.attr('href'),
- method = link.attr('data-method'),
- csrf_token = $('meta[name=csrf-token]').attr('content'),
- csrf_param = $('meta[name=csrf-param]').attr('content'),
- form = $('<form method="post" action="' + href + '"></form>'),
- metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
-
- if (csrf_param !== undefined && csrf_token !== undefined) {
- metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
- }
-
- form.hide().append(metadata_input).appendTo('body');
- form.submit();
- }
-
- function disableFormElements(form) {
- form.find('input[data-disable-with]').each(function() {
- var input = $(this);
- input.data('ujs:enable-with', input.val())
- .val(input.attr('data-disable-with'))
- .attr('disabled', 'disabled');
- });
- }
-
- function enableFormElements(form) {
- form.find('input[data-disable-with]').each(function() {
- var input = $(this);
- input.val(input.data('ujs:enable-with')).removeAttr('disabled');
- });
- }
-
- function allowAction(element) {
- var message = element.attr('data-confirm');
- return !message || (fire(element, 'confirm') && confirm(message));
- }
-
- function requiredValuesMissing(form) {
- var missing = false;
- form.find('input[name][required]').each(function() {
- if (!$(this).val()) missing = true;
- });
- return missing;
- }
-
- $('a[data-confirm], a[data-method], a[data-remote]').live('click.rails', function(e) {
- var link = $(this);
- if (!allowAction(link)) return false;
-
- if (link.attr('data-remote') != undefined) {
- handleRemote(link);
- return false;
- } else if (link.attr('data-method')) {
- handleMethod(link);
- return false;
- }
- });
-
- $('form').live('submit.rails', function(e) {
- var form = $(this), remote = form.attr('data-remote') != undefined;
- if (!allowAction(form)) return false;
-
- // skip other logic when required values are missing
- if (requiredValuesMissing(form)) return !remote;
-
- if (remote) {
- handleRemote(form);
- return false;
- } else {
- // slight timeout so that the submit button gets properly serialized
- setTimeout(function(){ disableFormElements(form) }, 13);
- }
- });
-
- $('form input[type=submit], form button[type=submit], form button:not([type])').live('click.rails', function() {
- var button = $(this);
- if (!allowAction(button)) return false;
- // register the pressed submit button
- var name = button.attr('name'), data = name ? {name:name, value:button.val()} : null;
- button.closest('form').data('ujs:submit-button', data);
- });
-
- $('form').live('ajax:beforeSend.rails', function(event) {
- if (this == event.target) disableFormElements($(this));
- });
-
- $('form').live('ajax:complete.rails', function(event) {
- if (this == event.target) enableFormElements($(this));
- });
-})( jQuery );

0 comments on commit 6f038fd

Please sign in to comment.