Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove data-remote support because it's not being used

  • Loading branch information...
commit 512f745056e2a59006b64a8f2c56c89f55d84055 1 parent 0cd3d0b
@jhollinger authored
Showing with 6 additions and 49 deletions.
  1. +6 −49 public/javascripts/admin.js
View
55 public/javascripts/admin.js
@@ -26,12 +26,6 @@ function bind_textile_preview(button) {
})
}
-// Ask user to confirm link
-function allow_action(link) {
- var msg = link.attr('data-confirm')
- return !msg || (confirm(msg))
-}
-
// Convert a link to a form and submit it
function handle_method(link) {
var url = link.attr('href'),
@@ -42,53 +36,16 @@ function handle_method(link) {
form.submit()
}
-// Submits remote links with ajax
-function handle_remote(element) {
- var dataType = element.attr('data-type') || ($.ajaxSettings && $.ajaxSettings.dataType);
- var method = element.attr('data-method') || 'GET';
- var url = element.attr('href');
- var data = null;
-
- $.ajax({
- url: url, type: method, 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]);
- }
- });
-}
-
-// 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;
-}
-
$(function() {
// Convert data-method links into forms and submit
- $('a[data-confirm], a[data-method], a[data-remote]').live('click', function() {
- var link = $(this)
+ $('a[data-confirm],a[data-method]').live('click', function() {
+ var msg, link = $(this)
// Make sure user wants to do this
- if ( !allow_action(link) ) return false
- // Submit remote link
- if ( link.attr('data-remote') ) {
- handle_remote(link)
- return false
+ if ( msg = link.attr('data-confirm') ) {
+ if ( !confirm(msg) ) return false
+ }
// Submit link as a form
- } else if ( link.attr('data-method') ) {
+ if ( link.attr('data-method') ) {
handle_method(link)
return false
}
Please sign in to comment.
Something went wrong with that request. Please try again.