Commit Graph

74 Commits

Author SHA1 Message Date
Ben Thomson 5f15ed54f9 Initial unit tests for front-end framework (#4576)
Credit to @bennothommo
2019-09-25 10:23:17 -06:00
Samuel Georges 2962f75221 Include the JSON parser natively in framework.js
We've also included it as a separate framework.parser.js file in case its needed by some external lib, such as Storm UI
2019-09-14 17:56:18 +10:00
Samuel Georges ebcb7ee6fd
Add a small JSON Parser to October framework lib (#4527)
* Add a small JSON Parser to October framework lib
2019-09-14 17:29:31 +10:00
Samuel Georges 3291e07191
Update Deprecated code in October into (event.key) (#4489)
Update Deprecated code in October into (event.key)
2019-09-11 21:35:18 +10:00
Alexander Voronin f4240d7e2c Fix: Disabled global AJAX events (#4282)
Credit to @VoroninWD.
2019-07-14 23:41:35 +03:00
Petr Popov ba0da07c46 Fix FormData initialization (#4391)
Credit to @Air-Petr.
2019-06-19 12:59:13 +03:00
CSNWEB 044ae054f8 Wait until input is finished to fire requests fired by tracking input (#4238)
Fixes #4237. Credit to @CSNWEB
2019-04-19 10:52:50 -06:00
Rike-cz c0e01c0f0d Add support for `data-request-url` in the data attributes AJAX API (#4012)
Credit to @Rike-cz. Documented in https://github.com/octobercms/docs/pull/353
2019-01-25 10:29:49 -06:00
Viamage 667b82e6ce Replace keyup listener with input listener (#3567)
Fixes #1270. Credit to @viamage
2018-05-30 20:26:38 -06:00
SeriousKen 965d91e51c Trailing & in requestData if data is empty (#3262)
This fixes a small issue where the form is submitted an extra unnamed null field is present in the request due to a trailing & symbol in `requestData` when `data` is empty.
2017-11-23 09:54:17 -06:00
Samuel Georges 2092454343 Clean up from #3255
This logic could have been placed in the ValidationException class or the framework.js file. It seems more fitting for it to be in the framework.js file.
2017-11-22 13:47:34 +11:00
Jan c165fc02d7 Fix ajax validation for array syntax (#3255) 2017-11-21 17:05:04 -06:00
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 2be18764d4 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