Commit Graph

54 Commits

Author SHA1 Message Date
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
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
Sam Georges 7ea65608a0 As per documentation, option-based redirect should only occur on successful AJAX requests (pushing a redirect from the server still works) 2014-09-10 17:03:36 +10:00
Sam Georges 33922f2180 If the target element is an input (textarea, select, etc) include its value when not used in a form 2014-09-06 13:58:10 +10:00
Sam Georges 2a5afaf9c7 Update oc- icons to match font autumn
Minor tidy up to framework.js
2014-07-27 16:08:08 +10:00
alekseybobkov 5488429fe4 Fixed the unknown component caching problem. Added the unknown component handling to the back-end. AJAX request can now be stopped with preventing default action in the oc.beforeRequest event. Fixes #46. 2014-06-26 17:09:25 +11:00
Sam Georges 12a7e7776b Minor 2014-06-10 08:16:33 +10:00
john-mark-wilkinson 35defa381b Update framework.js
Added prepend option '^' for AJAX framework "data-request-update" parameter
2014-06-09 13:47:00 -07:00
Sam Georges 1728295f3f Fixes an issue where success is still called when AJAX validation fails 2014-06-02 18:16:39 +10:00
Sam Georges fc0bf77ffe Add an event for overriding the default error message 2014-05-19 18:17:59 +10:00