62 Commits

Author SHA1 Message Date
Alexander Guth
93a2898379 Do not change behavior: pass request data back to the options object (#3012)
Current changes to the ``framework.js`` led to a breaking change due to the fact, that ``options.data`` was no longer populated with the request data. The ``options`` object is part of the ``context`` object, which is later beeing passed to ``ajaxBeforeSend``
The two relevant versions of the file show the change of behavior:
b6fedfb688/modules/system/assets/js/framework.js (L56) => https://github.com/octobercms/october/blob/develop/modules/system/assets/js/framework.js#L88
The change is required to remain consistent with the old behavior. This code is tested and appears to be working as it did formerly.
2017-09-19 15:34:48 -06:00
Samuel Georges
b732f70c59 Adds support for single file uploads
...when used without a form tag
Refs #2857
2017-07-29 09:21:49 +10:00
Samuel Georges
bc46520e3f This prevents &foo=bar on empty forms 2017-07-28 09:38:39 +10:00
Samuel Georges
97508c3953 Rem code sample 2017-07-28 01:50:37 +10:00
Samuel Georges
72eb48cf2e Add support for AJAX file uploads
Refs #2857
2017-07-28 01:45:26 +10:00
Luke Towers
f819aa607d Hide the loading indicator after AJAX request
Fixes #2780
2017-05-25 11:58:52 -06:00
Samuel Georges
b6fedfb688 Specify explicit form element
This allows request elements external to the form to serialize a target form for use. An example might be a search form at the top of a page, list of results in the middle, then the pagination at the bottom. The pagination would need to target the search form with data-request-form to persist the search query value.

This should work with the JS API too, passed as an object, because $($()) is acceptable in jQuery
2017-03-19 13:54:21 +11:00
Luke Towers
cdc8b23fd4 Fixing same-origin AJAX requests
jQuery sends multiple values for the `X-REQUESTED-WITH` header if it has already been set, even when the value is the same. This means that same-origin requests would send `X-REQUESTED-WITH: XMLHttpRequest, XMLHttpRequest` which isn't detected as AJAX by Laravel/Symphony.

To fix this issue while retaining the crossDomain usage of framework.js, I've used `crossDomain: false` to trick jQuery into sending the header anyways on cross-origin requests. This is still changeable by the user in the `ajaxSetup` event.
2017-02-15 09:56:43 -06:00
Luke Towers
c4031de6d6 X-Requested-With to uppercase
Style change because headers are case insensitive
2017-02-14 17:53:43 -06:00
Luke Towers
88d53ec0d5 Support CORS requests via framework.js
Adds support for Cross-Origin requests made via framework.js by manually adding the `X-Requested-With: XMLHttpRequest` header required for server-side detection of AJAX requests that is sent on normal Same-Origin AJAX requests but stripped by default by jQuery when making Cross-Origin requests. Note: Request target server still needs to have `Access-Control` headers configured correctly to return a request.
2017-02-14 17:46:56 -06:00
Luke Towers
37a735c8ed Process JS API requests through the document
Process JS API requests ($.request(handler, options)) through the document object instead of a non-existent form element. The form element was originally added because the framework only supported requests made from within a form
```
[22:08:12] spunky:	The $triggerEl was implemented because previously it was just $form
[22:08:24] spunky: For data-requests without a form, these events were being ignored
[22:08:31] spunky:	So as a workaround I implemented $triggerEl
```
As this is no longer the case, any JS API requests will now be made through the document element instead to support listening to events (such as ajaxSetup) even when there is no real attached element to trigger them on.
2017-02-06 10:36:57 -06:00
Samuel Georges
d2082e0ea0 Throw an error when framework loads twice
Fixes #2379
2017-02-05 06:49:11 +11:00
Samuel Georges
562f60730f Fix bug in handleConfirmMessage override 2017-02-04 20:15:13 +11:00
Samuel Georges
6cd76e9c6d Add handleValidationMessage override function 2017-02-04 20:03:45 +11:00
Samuel Georges
88ed5c2c64 Dedicated ajaxSetup event for modifying option
Allow overriding confirm message with handleConfirmMessage function
2017-02-04 19:44:53 +11:00
Samuel Georges
7bcc31eef8 Add handleRedirectResponse override function 2017-02-04 19:14:26 +11:00
Samuel Georges
e323a1b98a Added handleFlashMessage function to framework.js
- Used for handling flash messages via JS API

Request options are now passed to ajaxBeforeSend & ajaxPromise events

Improved framework extras
- Fixes data-request-flash when used within a plain form, this code would fail because $triggerEl is set to a plain form:
`<form><button data-request="..." data-request-flash>...</button></form>`
2017-02-04 15:42:43 +11:00
Samuel Georges
08c5a27e50 Peer review 2be18764d47f78820d7f4a02ce3c0995358a16d1 2017-02-04 09:21:45 +11:00
Luke Towers
2be18764d4 Support passing objects as the loading indicator
Adds support for passing objects to be used as the loading indicator. Note: Objects must support `.show()` and `.hide()` methods.
Example:
```js
$.request('onHandler', {
    loading: $.oc.stripeLoadIndicator
});
```
2017-02-03 15:54:59 -06:00
Samuel Georges
10326c2d63 Framework supports passing a "flash" option
This will request the Flash contents, if they are available. It also clears the flash bag contents, which is why this is an optional feature.
Introduced "ajaxValidation" event for capturing all invalid fields at once
2016-11-18 07:39:54 +11:00
Samuel Georges
d788b7e03f Use select2 on touch devices
This is a relic from when select2 v3 had no mobile support, we use select2 v4 now that has been tested with mobile/touch devices.
Refs #108
Clean up some white spaces
2016-10-17 08:38:01 +11:00
Jaap Wesdorp
972cad3f6f Add current url to ajax requests in requestOptions 2016-10-11 17:33:04 +02:00
Samuel Georges
f4b1c586bb Clicking a non-submit type link should allow event propagation
This is useful when an AJAX request link appears inside something like a dropdown. When the link is clicked, the dropdown should close like normal, however this is not the case since the value `false` is returned; so the expected behavior doesn't occur. As a solution, `false` is no longer returned, the default behavior on the event is prevented instead, allowing the propagation to proceed as normal.
2016-05-28 13:02:54 +10:00
Szabó Gergő
6d86e44279 Add missing translation and update the Hungarian translate (#2017)
* Add missing translation

* Update the Hungarian translate

* Open the author's website in a new window

* Minor typo

* Minor change
2016-05-24 06:04:57 +10:00
Samuel Georges
17717e94ec Do not send "undefined" data in ajax
Thanx @BOOMER74
2016-02-13 13:33:20 +11:00
Samuel Georges
a30fc006bb Update copyright and helper function names 2016-01-06 18:50:24 +11:00
Samuel Georges
7b187fc188 Fixes orphaned form events when there is no form container 2016-01-06 18:48:26 +11:00
Samuel Georges
ab432c0ee1 We shouldn't be returning jQuery objects as part of event parameters 2015-06-20 23:18:47 +10:00
Scott Bedard
db999cf179 Adds "search" & "email" types to data-track-input 2015-05-18 21:22:35 -04:00
alekseybobkov
20fb98d9a8 Refactoring and improvements in the back-end client-side memory management. 2015-04-28 20:13:04 -07:00
alekseybobkov
06e5dce96a Fixed a conflict in framework.js. Closures in the script are named now, for the memory profiling needs.
Conflicts:
	modules/system/assets/js/framework.js
2015-04-11 18:58:24 -07:00
Samuel Georges
f143c0e2ce Merge pull request #1051 from scottbedard/patch-4
Adds input type to data-track-input
2015-04-10 22:34:35 +10:00
Samuel Georges
0f630c80d9 Improve framework code to support $(this) in data attributes 2015-04-08 07:44:26 +10:00
Scott Bedard
51c868e693 Adds input types to data-track-input options
I need this input type, and it would be handy if I could use it with data-track-input. I promise this will be the last time I ask you to touch your priceless faberge egg ;)
2015-04-07 09:37:02 -04:00
Scott Bedard
7546174b35 Adds "request-complete" to the data-attributes api
... I hope.
2015-04-06 19:14:17 -04:00
alekseybobkov
9ed3d03484 jQuery in the back-end updated to v.2.1.3. Fixed several memory management issues in select2 (an event attached to the mask element is never unbound), framework.js (onunload event attached to window is never unbound and holds references to the Request instances). Added popup adaptive size option. Started media manager popup API. 2015-03-29 18:56:06 -07:00
alekseybobkov
18e058ad59 Added the Media tab, minor update in .htaccess to allow temporary public directory to be accessible; implemented the basic UI components and navigation; implemented grid, list and tiles view modes; implemented drag-select interface; implemented Media Library cache refreshing; implemented thumbnail generating for local and remote media files; fixed memory leak in third-party Flot Resize library; minor update in the AJAX framework - AJAX request cancelling is not considered as an error anymore; added back-end UI components for creating panels. 2015-03-15 12:52:03 -07:00
Samuel Georges
569fe2e468 These events should pass the context, to be aligned with the others 2015-01-29 20:06:06 +11:00
Samuel Georges
bc016adad7 Rollback performance change to framework.js because it's broken
(Submitting an invalid form in the backend will result in a page refresh, flash messaegs are suppressed)
K.I.S.S > Performance + premature optimization is the root of all evil
2014-12-28 13:03:52 +11:00
alekseybobkov
3ac21e3c89 Merge branch 'develop' into table-widget 2014-12-17 22:15:23 -08:00
Samuel Georges
986b3a95a8 Add the ability to override the confirm function 2014-12-15 17:48:59 +11:00
alekseybobkov
4e921aab7a Minor performance changes in the core JS and CSS. Table widget, in progress. 2014-11-16 18:00:15 -08:00
Sam Georges
c83797231d Subsequent expressions are on a new line (see developer guide > PSR exceptions) 2014-11-01 12:00:45 +11:00
Sam Georges
beab3c3ded A defined loader should not hide when there is a redirect taking place 2014-09-28 12:23:18 +10:00
Sam Georges
2b63282658 We have a form object already, use that instead 2014-09-26 19:54:30 +10:00
Sam Georges
b7e969083f Only when there is no <form /> parental element 2014-09-26 19:52:02 +10:00
Sam Georges
69fb8e0918 Fixes issue where load indicator hangs around on errors when a redirect is used 2014-09-13 17:47:38 +10:00
Sam Georges
c2a71e88bb Clean up some sloppy work 2014-09-12 20:20:52 +10:00
Sam Georges
73200606bc Pass isFirstField attrib, allow prevent of default focus() 2014-09-10 19:29:02 +10:00
Sam Georges
3d36e65a55 Trigger invalid on all fields, but only focus the first one. Also pass the messages across. 2014-09-10 19:11:21 +10:00