Permalink
Browse files

Just require coffee-script

  • Loading branch information...
1 parent 873456a commit 875e74d8db6f5fcdf1da233da52c0a4ae7fbac93 @josh committed Sep 17, 2012
Showing with 0 additions and 318 deletions.
  1. +0 −9 accept.js
  2. +0 −22 beforesend.js
  3. +0 −13 confirm.js
  4. +0 −50 csrf.js
  5. +0 −43 disable.js
  6. +0 −12 ie_utf8.js
  7. +0 −30 method.js
  8. +0 −65 prepare.js
  9. +0 −44 remote.js
  10. +0 −30 remote_submit.js
View
@@ -1,9 +0,0 @@
-(function() {
-
- $(document).on('ajaxBeforeSend', function(event, xhr, settings) {
- if (!settings.dataType) {
- return xhr.setRequestHeader('Accept', '*/*;q=0.5, ' + settings.accepts.script);
- }
- });
-
-}).call(this);
View
@@ -1,22 +0,0 @@
-(function() {
-
- if (typeof Zepto === "undefined" || Zepto === null) {
- $.ajaxSetup({
- beforeSend: function(xhr, settings) {
- var element, event;
- if (!settings.global) {
- return;
- }
- element = settings.context || document;
- event = $.Event('ajaxBeforeSend');
- $(element).trigger(event, [xhr, settings]);
- if (event.isDefaultPrevented()) {
- return false;
- } else {
- return event.result;
- }
- }
- });
- }
-
-}).call(this);
View
@@ -1,13 +0,0 @@
-(function() {
-
- $(document).on('click:prepare', 'a[data-confirm], button[data-confirm]', function(event) {
- var message;
- if (message = $(this).attr('data-confirm')) {
- if (!confirm(message)) {
- event.stopImmediatePropagation();
- event.preventDefault();
- }
- }
- });
-
-}).call(this);
View
50 csrf.js
@@ -1,50 +0,0 @@
-(function() {
- var isSameOrigin;
-
- $(document).on('ajaxBeforeSend', function(event, xhr, settings) {
- var token;
- if (settings.crossDomain) {
- return;
- }
- if (settings.type === 'GET') {
- return;
- }
- if (token = $('meta[name="csrf-token"]').attr('content')) {
- return xhr.setRequestHeader('X-CSRF-Token', token);
- }
- });
-
- $(document).on('submit:prepare', 'form', function() {
- var form, input, param, token;
- form = $(this);
- if (form.is('form[data-remote]')) {
- return;
- }
- if (!this.method || this.method.toUpperCase() === 'GET') {
- return;
- }
- if (!isSameOrigin(form.attr('action'))) {
- return;
- }
- param = $('meta[name="csrf-param"]').attr('content');
- token = $('meta[name="csrf-token"]').attr('content');
- if ((param != null) && (token != null)) {
- if (!form.find("input[name=" + param + "]")[0]) {
- input = document.createElement('input');
- input.setAttribute('type', 'hidden');
- input.setAttribute('name', param);
- input.setAttribute('value', token);
- form.prepend(input);
- }
- }
- });
-
- isSameOrigin = function(url) {
- var a, origin;
- a = document.createElement('a');
- a.href = url;
- origin = a.href.split('/', 3).join("/");
- return location.href.indexOf(origin) === 0;
- };
-
-}).call(this);
View
Oops, something went wrong.
View
@@ -1,12 +0,0 @@
-(function() {
- var m;
-
- if ((m = navigator.userAgent.match(/MSIE ([\w]+)/)) && parseInt(m[1]) <= 8) {
- $(document).on('submit:prepare', 'form', function() {
- if ($(this).find('input[name=utf8]').length === 0) {
- $(this).prepend('<input type=hidden name=utf8 value=✓>');
- }
- });
- }
-
-}).call(this);
View
@@ -1,30 +0,0 @@
-(function() {
-
- $(document).on('click', 'a[data-method]', function(event) {
- var element, form, input, method;
- element = $(this);
- if (element.is('a[data-remote]')) {
- return;
- }
- method = element.attr('data-method').toLowerCase();
- if (method === 'get') {
- return;
- }
- form = document.createElement('form');
- form.method = 'POST';
- form.action = element.attr('href');
- form.style.display = 'none';
- if (method !== 'post') {
- input = document.createElement('input');
- input.setAttribute('type', 'hidden');
- input.setAttribute('name', '_method');
- input.setAttribute('value', method);
- form.appendChild(input);
- }
- document.body.appendChild(form);
- $(form).submit();
- event.preventDefault();
- return false;
- });
-
-}).call(this);
View
@@ -1,65 +0,0 @@
-(function() {
- var dispatchPrepare, lastPreparedTimestamp, preDispatch, setup, teardown;
-
- if (typeof Zepto !== "undefined" && Zepto !== null) {
- dispatchPrepare = function(originalEvent) {
- var combine, event, k, v;
- event = document.createEvent('Events');
- for (k in originalEvent) {
- v = originalEvent[k];
- event[k] = v;
- }
- event.initEvent("" + originalEvent.type + ":prepare", true, true);
- combine = function(f, g) {
- return function() {
- f.apply(originalEvent);
- return g.apply(event);
- };
- };
- event.preventDefault = combine(originalEvent.preventDefault, event.preventDefault);
- event.stopPropagation = combine(originalEvent.stopPropagation, event.stopPropagation);
- event.stopImmediatePropagation = combine(originalEvent.stopImmediatePropagation, event.stopImmediatePropagation);
- originalEvent.target.dispatchEvent(event);
- return event.result;
- };
- window.addEventListener('click', dispatchPrepare, true);
- window.addEventListener('submit', dispatchPrepare, true);
- } else {
- lastPreparedTimestamp = null;
- preDispatch = function(event) {
- var origType;
- if (event.timeStamp !== lastPreparedTimestamp) {
- origType = event.type;
- event.type = "" + origType + ":prepare";
- $.event.trigger(event, [], event.target, false);
- event.type = origType;
- lastPreparedTimestamp = event.timeStamp;
- }
- };
- setup = function(event) {
- return function() {
- $(this).on("" + event + ".prepare", function() {});
- };
- };
- teardown = function(event) {
- return function() {
- $(this).off("" + event + ".prepare", function() {});
- };
- };
- $.event.special.click = {
- preDispatch: preDispatch
- };
- $.event.special.submit = {
- preDispatch: preDispatch
- };
- $.event.special['click:prepare'] = {
- setup: setup('click'),
- teardown: teardown('click')
- };
- $.event.special['submit:prepare'] = {
- setup: setup('submit'),
- teardown: teardown('submit')
- };
- }
-
-}).call(this);
View
@@ -1,44 +0,0 @@
-(function() {
-
- $(document).on('click', 'a[data-remote]', function(event) {
- var dataType, element, settings, type, url;
- element = $(this);
- settings = {};
- settings.context = this;
- if (type = element.attr('data-method')) {
- settings.type = type;
- }
- if (url = this.href) {
- settings.url = url;
- }
- if (dataType = element.attr('data-type')) {
- settings.dataType = dataType;
- }
- $.ajax(settings);
- event.preventDefault();
- return false;
- });
-
- $(document).on('submit', 'form[data-remote]', function(event) {
- var data, dataType, form, settings, type, url;
- form = $(this);
- settings = {};
- settings.context = this;
- if (type = this.method) {
- settings.type = type;
- }
- if (url = this.action) {
- settings.url = url;
- }
- if (data = form.serializeArray()) {
- settings.data = data;
- }
- if (dataType = form.attr('data-type')) {
- settings.dataType = dataType;
- }
- $.ajax(settings);
- event.preventDefault();
- return false;
- });
-
-}).call(this);
View
@@ -1,30 +0,0 @@
-(function() {
- var submitSelectors;
-
- submitSelectors = "form[data-remote] input[type=submit],\nform[data-remote] button[type=submit],\nform[data-remote] button:not([type]),\nform[data-remote-submit] input[type=submit],\nform[data-remote-submit] button[type=submit],\nform[data-remote-submit] button:not([type])";
-
- $(document).on('click', submitSelectors, function() {
- var defaultValue, form, input, name, submit, value;
- submit = $(this);
- form = submit.closest('form');
- input = form.find('.js-submit-button-value');
- if (name = submit.attr('name')) {
- defaultValue = submit.is('input[type=submit]') ? 'Submit' : '';
- value = submit.val() || defaultValue;
- if (!input[0]) {
- input = document.createElement('input');
- input.setAttribute('type', 'hidden');
- input.setAttribute('name', name);
- input.setAttribute('value', value);
- input.setAttribute('class', 'js-submit-button-value');
- form.prepend(input);
- } else {
- input.attr('name', name);
- input.attr('value', value);
- }
- } else {
- input.remove();
- }
- });
-
-}).call(this);

0 comments on commit 875e74d

Please sign in to comment.