-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9581a0d
commit 4056f86
Showing
1 changed file
with
12 additions
and
104 deletions.
There are no files selected for viewing
116 changes: 12 additions & 104 deletions
116
Resources/Public/JavaScript/Backend/FormEditor/CaptchaViewModel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,17 @@ | ||
/** | ||
* Module: @blueways/bw-captcha/Backend/FormEditor/CaptchaViewModel.js | ||
*/ | ||
import $ from 'jquery'; | ||
import * as Helper from '@typo3/form/backend/form-editor/helper.js' | ||
import * as Helper from '@typo3/form/backend/form-editor/helper.js'; | ||
|
||
/** | ||
* @private | ||
* | ||
* @var object | ||
*/ | ||
let _formEditorApp = null; | ||
|
||
/** | ||
* @private | ||
* | ||
* @return object | ||
*/ | ||
function getFormEditorApp() { | ||
return _formEditorApp; | ||
}; | ||
|
||
/** | ||
* @private | ||
* | ||
* @return object | ||
*/ | ||
function getPublisherSubscriber() { | ||
return getFormEditorApp().getPublisherSubscriber(); | ||
}; | ||
|
||
/** | ||
* @private | ||
* | ||
* @return object | ||
*/ | ||
function getUtility() { | ||
return getFormEditorApp().getUtility(); | ||
}; | ||
|
||
/** | ||
* @private | ||
* | ||
* @param object | ||
* @return object | ||
*/ | ||
function getHelper() { | ||
return Helper; | ||
}; | ||
|
||
/** | ||
* @private | ||
* | ||
* @return object | ||
*/ | ||
function getCurrentlySelectedFormElement() { | ||
return getFormEditorApp().getCurrentlySelectedFormElement(); | ||
}; | ||
|
||
/** | ||
* @private | ||
* | ||
* @param mixed test | ||
* @param string message | ||
* @param int messageCode | ||
* @return void | ||
*/ | ||
function assert(test, message, messageCode) { | ||
return getFormEditorApp().assert(test, message, messageCode); | ||
}; | ||
|
||
/** | ||
* @private | ||
* | ||
* @return void | ||
* @throws 1491643380 | ||
*/ | ||
function _helperSetup() { | ||
assert('function' === $.type(Helper.bootstrap), | ||
'The view model helper does not implement the method "bootstrap"', | ||
1491643380 | ||
); | ||
Helper.bootstrap(getFormEditorApp()); | ||
}; | ||
|
||
/** | ||
* @private | ||
* | ||
* @return void | ||
*/ | ||
function _subscribeEvents() { | ||
getPublisherSubscriber().subscribe('view/stage/abstract/render/template/perform', function (topic, args) { | ||
if (args[0].get('type') === 'Captcha') { | ||
getFormEditorApp().getViewModel().getStage().renderSimpleTemplateWithValidators(args[0], args[1]); | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* @public | ||
* | ||
* @param object formEditorApp | ||
* @return void | ||
*/ | ||
export function bootstrap(formEditorApp) { | ||
_formEditorApp = formEditorApp; | ||
_helperSetup(); | ||
_subscribeEvents(); | ||
}; | ||
Helper.bootstrap(formEditorApp); | ||
|
||
formEditorApp.getPublisherSubscriber().subscribe( | ||
'view/stage/abstract/render/template/perform', | ||
(topic, args) => { | ||
if (args[0].get('type') === 'Captcha') { | ||
formEditorApp.getViewModel().getStage().renderSimpleTemplateWithValidators(args[0], args[1]); | ||
} | ||
} | ||
); | ||
} |