Permalink
Browse files

changed: all element js files are now wrapped inside requirejs define…

…s, each thus loading its own js AMD requirements. Autocomplete and Encoder files are now also AMD modules
  • Loading branch information...
1 parent 2dcc469 commit 77d175489f28f542db8f58b08687ff7fd8f00ede @pollen8 pollen8 committed Mar 18, 2016
Showing with 11,534 additions and 11,437 deletions.
  1. +7 −3 .jshintrc
  2. +14 −12 components/com_fabrik/helpers/html.php
  3. +0 −9 components/com_fabrik/models/element.php
  4. +0 −1 components/com_fabrik/views/form/view.base.php
  5. +2 −0 media/com_fabrik/js/autocomplete-bootstrap-cdd-min.js
  6. +71 −0 media/com_fabrik/js/autocomplete-bootstrap-cdd.js
  7. +1 −1 media/com_fabrik/js/autocomplete-bootstrap-min.js
  8. +359 −411 media/com_fabrik/js/autocomplete-bootstrap.js
  9. +1 −1 media/com_fabrik/js/element-min.js
  10. +795 −904 media/com_fabrik/js/element.js
  11. +1 −1 media/com_fabrik/js/elementlist-min.js
  12. +186 −181 media/com_fabrik/js/elementlist.js
  13. +1 −1 media/com_fabrik/js/encoder-min.js
  14. +181 −175 media/com_fabrik/js/encoder.js
  15. +1 −1 media/com_fabrik/js/fabrik-min.js
  16. +23 −21 media/com_fabrik/js/fabrik.js
  17. +2 −0 media/com_fabrik/js/fileelement-min.js
  18. +117 −0 media/com_fabrik/js/fileelement.js
  19. +2 −2 media/com_fabrik/js/form-min.js
  20. +2,169 −2,164 media/com_fabrik/js/form.js
  21. +197 −197 media/com_fabrik/js/lib/debounce/jquery.ba-throttle-debounce.js
  22. +1 −1 plugins/fabrik_element/access/access-min.js
  23. +10 −6 plugins/fabrik_element/access/access.js
  24. +1 −1 plugins/fabrik_element/attending/attending-min.js
  25. +67 −62 plugins/fabrik_element/attending/attending.js
  26. +0 −20 plugins/fabrik_element/attending/attending.php
  27. +1 −1 plugins/fabrik_element/birthday/birthday-min.js
  28. +33 −28 plugins/fabrik_element/birthday/birthday.js
  29. +1 −1 plugins/fabrik_element/button/button-min.js
  30. +20 −16 plugins/fabrik_element/button/button.js
  31. +1 −1 plugins/fabrik_element/calc/calc-min.js
  32. +149 −143 plugins/fabrik_element/calc/calc.js
  33. +1 −1 plugins/fabrik_element/captcha/captcha-min.js
  34. +9 −5 plugins/fabrik_element/captcha/captcha.js
  35. +1 −1 plugins/fabrik_element/cascadingdropdown/cascadingdropdown-min.js
  36. +296 −282 plugins/fabrik_element/cascadingdropdown/cascadingdropdown.js
  37. +0 −18 plugins/fabrik_element/cascadingdropdown/cascadingdropdown.php
  38. +1 −1 plugins/fabrik_element/checkbox/checkbox-min.js
  39. +88 −84 plugins/fabrik_element/checkbox/checkbox.js
  40. +0 −18 plugins/fabrik_element/checkbox/checkbox.php
  41. +1 −1 plugins/fabrik_element/colourpicker/colourpicker-min.js
  42. +559 −553 plugins/fabrik_element/colourpicker/colourpicker.js
  43. +1 −1 plugins/fabrik_element/count/count-min.js
  44. +9 −6 plugins/fabrik_element/count/count.js
  45. +1 −1 plugins/fabrik_element/databasejoin/databasejoin-min.js
  46. +962 −948 plugins/fabrik_element/databasejoin/databasejoin.js
  47. +0 −3 plugins/fabrik_element/databasejoin/databasejoin.php
  48. +1 −1 plugins/fabrik_element/date/date-min.js
  49. +873 −869 plugins/fabrik_element/date/date.js
  50. +1 −1 plugins/fabrik_element/date/date.php
  51. +1 −1 plugins/fabrik_element/digsig/digsig-min.js
  52. +43 −39 plugins/fabrik_element/digsig/digsig.js
  53. +1 −1 plugins/fabrik_element/digsig/digsig.php
  54. +1 −1 plugins/fabrik_element/display/display-min.js
  55. +15 −11 plugins/fabrik_element/display/display.js
  56. +1 −1 plugins/fabrik_element/dropdown/dropdown-min.js
  57. +153 −149 plugins/fabrik_element/dropdown/dropdown.js
  58. +1 −1 plugins/fabrik_element/fbcomment/fbcomment-min.js
  59. +10 −6 plugins/fabrik_element/fbcomment/fbcomment.js
  60. +1 −1 plugins/fabrik_element/fblike/fblike-min.js
  61. +39 −34 plugins/fabrik_element/fblike/fblike.js
  62. +1 −1 plugins/fabrik_element/field/field-min.js
  63. +80 −75 plugins/fabrik_element/field/field.js
  64. +5 −2 plugins/fabrik_element/field/field.php
  65. +1 −1 plugins/fabrik_element/fileupload/fileupload-min.js
  66. +1,209 −1,200 plugins/fabrik_element/fileupload/fileupload.js
  67. +1 −1 plugins/fabrik_element/fileupload/fileupload.php
  68. +1 −1 plugins/fabrik_element/folder/folder-min.js
  69. +10 −6 plugins/fabrik_element/folder/folder.js
  70. +1 −1 plugins/fabrik_element/googlemap/googlemap-min.js
  71. +773 −767 plugins/fabrik_element/googlemap/googlemap.js
  72. +1 −1 plugins/fabrik_element/googleometer/googleometer-min.js
  73. +11 −5 plugins/fabrik_element/googleometer/googleometer.js
  74. +1 −1 plugins/fabrik_element/image/image-min.js
  75. +119 −115 plugins/fabrik_element/image/image.js
  76. +1 −1 plugins/fabrik_element/internalid/internalid-min.js
  77. +10 −6 plugins/fabrik_element/internalid/internalid.js
  78. +1 −1 plugins/fabrik_element/ip/ip-min.js
  79. +10 −6 plugins/fabrik_element/ip/ip.js
  80. +1 −1 plugins/fabrik_element/jsperiodical/jsperiodical-min.js
  81. +20 −16 plugins/fabrik_element/jsperiodical/jsperiodical.js
  82. +1 −1 plugins/fabrik_element/link/link-min.js
  83. +31 −27 plugins/fabrik_element/link/link.js
  84. +0 −21 plugins/fabrik_element/link/link.php
  85. +1 −1 plugins/fabrik_element/notes/notes-min.js
  86. +81 −77 plugins/fabrik_element/notes/notes.js
  87. +1 −1 plugins/fabrik_element/password/password-min.js
  88. +92 −88 plugins/fabrik_element/password/password.js
  89. +1 −1 plugins/fabrik_element/picklist/picklist-min.js
  90. +187 −184 plugins/fabrik_element/picklist/picklist.js
  91. +1 −1 plugins/fabrik_element/radiobutton/radiobutton-min.js
  92. +190 −186 plugins/fabrik_element/radiobutton/radiobutton.js
  93. +0 −19 plugins/fabrik_element/radiobutton/radiobutton.php
  94. +1 −1 plugins/fabrik_element/rating/rating-min.js
  95. +176 −172 plugins/fabrik_element/rating/rating.js
  96. +0 −17 plugins/fabrik_element/rating/rating.php
  97. +1 −1 plugins/fabrik_element/slider/slider-min.js
  98. +91 −87 plugins/fabrik_element/slider/slider.js
  99. +1 −1 plugins/fabrik_element/spotify/spotify-min.js
  100. +10 −6 plugins/fabrik_element/spotify/spotify.js
  101. +1 −1 plugins/fabrik_element/tags/tags-min.js
  102. +110 −110 plugins/fabrik_element/tags/tags.js
  103. +1 −1 plugins/fabrik_element/textarea/textarea-min.js
  104. +393 −396 plugins/fabrik_element/textarea/textarea.js
  105. +1 −1 plugins/fabrik_element/thumbs/thumbs-min.js
  106. +178 −171 plugins/fabrik_element/thumbs/thumbs.js
  107. +1 −1 plugins/fabrik_element/time/time-min.js
  108. +28 −24 plugins/fabrik_element/time/time.js
  109. +1 −1 plugins/fabrik_element/timer/timer-min.js
  110. +123 −116 plugins/fabrik_element/timer/timer.js
  111. +1 −1 plugins/fabrik_element/timestamp/timestamp-min.js
  112. +10 −6 plugins/fabrik_element/timestamp/timestamp.js
  113. +1 −1 plugins/fabrik_element/user/user-min.js
  114. +6 −3 plugins/fabrik_element/user/user.js
  115. +0 −21 plugins/fabrik_element/user/user.php
  116. +1 −1 plugins/fabrik_element/usergroup/usergroup-min.js
  117. +10 −6 plugins/fabrik_element/usergroup/usergroup.js
  118. +1 −1 plugins/fabrik_element/viewlevel/viewlevel-min.js
  119. +10 −6 plugins/fabrik_element/viewlevel/viewlevel.js
  120. +1 −1 plugins/fabrik_element/yesno/yesno-min.js
  121. +38 −34 plugins/fabrik_element/yesno/yesno.js
  122. +0 −23 plugins/fabrik_element/yesno/yesno.php
  123. +1 −1 plugins/fabrik_element/youtube/youtube-min.js
  124. +10 −6 plugins/fabrik_element/youtube/youtube.js
View
@@ -39,18 +39,22 @@
"tinymce": true,
"Calendar": true,
"WFEditor": true,
+ "Color": true,
+ "Drag": true,
"google": true,
+ "CanvasItem": true,
+ "define": true,
"FB": true,
+ "Layer": true,
"Encoder": true,
"Class": true,
"typeOf": true,
"$H": true,
"AdvancedSearch": true,
"Options": true,
"Events": true,
+ "Spinner": true,
"Request": true,
- "FbElement": true,
- "FbAutocomplete": true,
- "FbRadio": true
+ "requirejs": true
}
}
@@ -828,9 +828,9 @@ public static function framework()
$app = JFactory::getApplication();
$version = new JVersion;
FabrikHelperHTML::modalJLayouts();
- $liveSiteSrc = array();
- $liveSiteReq = array();
- $fbConfig = JComponentHelper::getParams('com_fabrik');
+ $liveSiteSrc = array();
+ $liveSiteReq = array();
+ $fbConfig = JComponentHelper::getParams('com_fabrik');
// Only use template test for testing in 2.5 with my temp J bootstrap template.
$bootstrapped = in_array($app->getTemplate(), array('bootstrap', 'fabrik4')) || $version->RELEASE > 2.5;
@@ -888,7 +888,7 @@ public static function framework()
if ($fbConfig->get('advanced_behavior', '0') == '1')
{
- $liveSiteSrc[] = "var chosenInterval = window.setInterval(function () {
+ $liveSiteSrc[] = "var chosenInterval = window.setInterval(function () {
if (Fabrik.buildChosen) {
window.clearInterval(chosenInterval);
Fabrik.buildChosen('select.advancedSelect', " . json_encode($chosenOptions) . ");
@@ -1082,11 +1082,10 @@ public static function iniRequireJs($shim = array())
$deps[] = 'fab/icongen' . $ext;
}
- $deps[] = 'fab/encoder' . $ext;
+ //$deps[] = 'fab/encoder' . $ext;
self::addRequireJsShim($framework, 'fab/fabrik', $deps);
self::addRequireJsShim($framework, 'fab/window', array('fab/fabrik' . $ext));
- self::addRequireJsShim($framework, 'fab/elementlist', array('fab/fabrik' . $ext, 'fab/element' . $ext));
self::addRequireJsShim($framework, 'fab/autocomplete-bootstrap', array('fab/fabrik' . $ext));
$newShim = array_merge($framework, $newShim);
@@ -1759,18 +1758,21 @@ public static function autoComplete($htmlId, $elementId, $formId, $plugin = 'fie
$str = json_encode($json);
JText::script('COM_FABRIK_NO_RECORDS');
JText::script('COM_FABRIK_AUTOCOMPLETE_AJAX_ERROR');
- $class = $plugin === 'cascadingdropdown' ? 'FabCddAutocomplete' : 'FbAutocomplete';
- $jsFile = FabrikWorker::j3() ? 'autocomplete-bootstrap' : 'autocomplete';
+ $jsFile = 'autocomplete';
+
+ if (FabrikWorker::j3())
+ {
+ $jsFile = $plugin === 'cascadingdropdown' ? 'autocomplete-bootstrap-cdd' : 'autocomplete-bootstrap';
+ }
+
$needed = array();
- $needed[] = self::isDebug() ? 'fab/fabrik' : 'fab/fabrik-min';
$needed[] = self::isDebug() ? 'fab/' . $jsFile : 'fab/' . $jsFile . '-min';
$needed[] = self::isDebug() ? 'fab/lib/debounce/jquery.ba-throttle-debounce' : 'fab/lib/debounce/jquery.ba-throttle-debounce-min';
- $needed[] = self::isDebug() ? 'fab/encoder' : 'fab/encoder-min';
$needed[] = 'fab/lib/Event.mock';
$needed = implode("', '", $needed);
self::addScriptDeclaration(
- "requirejs(['$needed'], function () {
- new $class('$htmlId', $str);
+ "require(['$needed'], function (AutoComplete) {
+ new AutoComplete('$htmlId', $str);
});"
);
}
@@ -5602,15 +5602,6 @@ public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
{
$name = $this->getElement()->plugin;
$ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
- $shimKey = 'element/' . $name . '/' . $name;
-
- if (!array_key_exists($shimKey, $shim))
- {
- $s = new stdClass;
- $s->deps = array('fab/element');
- $shim['element/' . $name . '/' . $name] = $s;
- }
-
$formId = $this->getFormModel()->getId();
static $elementClasses;
@@ -537,7 +537,6 @@ protected function _addJavascript($listId)
$dep->deps = array(
'fab/element',
'lib/form_placeholder/Form.Placeholder',
- 'fab/encoder',
'fab/lib/debounce/jquery.ba-throttle-debounce'
);
@@ -0,0 +1,2 @@
+/*! Fabrik */
+console.log("cdd autocomplete loaded"),define(["jquery","fab/autocomplete-bootstrap","fab/fabrik"],function(a,b,c){var d=new Class({Extends:b,search:function(a){var b,d,e=this.getInputElement().get("value");if(""===e&&(this.element.value=""),e!==this.searchText&&""!==e){var f=document.id(this.options.observerid);if("null"===typeOf(f))return void this.parent(a);this.options.formRef&&(f=c.getBlock(this.options.formRef).formElements[this.options.observerid]),b=f.get("value")+"."+e,this.positionMenu(),this.cache[b]?this.populateMenu(this.cache[b])&&this.openMenu():(this.ajax&&(this.closeMenu(),this.ajax.cancel()),this.ajax=new Request({url:this.options.url,data:{value:e,fabrik_cascade_ajax_update:1,v:f.get("value")},onRequest:function(){c.loader.start(this.getInputElement())}.bind(this),onCancel:function(){c.loader.stop(this.getInputElement())}.bind(this),onSuccess:function(a){c.loader.stop(this.getInputElement()),this.ajax=null,this.completeAjax(a)}.bind(this),onFailure:function(a){c.loader.stop(this.getInputElement()),this.ajax=null,fconsole("Fabrik autocomplete: Ajax failure: Code "+a.status+": "+a.statusText);var b=c.getBlock(this.options.formRef).formElements.get(this.element.id);d=Joomla.JText._("COM_FABRIK_AUTOCOMPLETE_AJAX_ERROR"),b.setErrorMessage(d,"fabrikError",!0)}.bind(this)}).send())}this.searchText=e}});return d});
@@ -0,0 +1,71 @@
+/**
+ * Created by rob on 18/03/2016.
+ */
+console.log('cdd autocomplete loaded');
+define(['jquery', 'fab/autocomplete-bootstrap', 'fab/fabrik'],
+ function (jQuery, AutoComplete, Fabrik) {
+ var FabCddAutocomplete = new Class({
+
+ Extends: AutoComplete,
+
+ search: function (e) {
+ var key, msg;
+ var v = this.getInputElement().get('value');
+ if (v === '') {
+ this.element.value = '';
+ }
+ if (v !== this.searchText && v !== '') {
+ var observer = document.id(this.options.observerid);
+ if (typeOf(observer) !== 'null') {
+ if (this.options.formRef) {
+ observer = Fabrik.getBlock(this.options.formRef).formElements[this.options.observerid];
+ }
+ key = observer.get('value') + '.' + v;
+ } else {
+ this.parent(e);
+ return;
+ }
+ this.positionMenu();
+ if (this.cache[key]) {
+ if (this.populateMenu(this.cache[key])) {
+ this.openMenu();
+ }
+ } else {
+ if (this.ajax) {
+ this.closeMenu();
+ this.ajax.cancel();
+ }
+ this.ajax = new Request({
+ url : this.options.url,
+ data : {
+ value : v,
+ fabrik_cascade_ajax_update: 1,
+ v : observer.get('value')
+ },
+ onRequest: function () {
+ Fabrik.loader.start(this.getInputElement());
+ }.bind(this),
+ onCancel : function () {
+ Fabrik.loader.stop(this.getInputElement());
+ }.bind(this),
+ onSuccess: function (e) {
+ Fabrik.loader.stop(this.getInputElement());
+ this.ajax = null;
+ this.completeAjax(e);
+ }.bind(this),
+ onFailure: function (xhr) {
+ Fabrik.loader.stop(this.getInputElement());
+ this.ajax = null;
+ fconsole('Fabrik autocomplete: Ajax failure: Code ' + xhr.status + ': ' + xhr.statusText);
+ var elModel = Fabrik.getBlock(this.options.formRef).formElements.get(this.element.id);
+ msg = Joomla.JText._('COM_FABRIK_AUTOCOMPLETE_AJAX_ERROR');
+ elModel.setErrorMessage(msg, 'fabrikError', true);
+ }.bind(this)
+ }).send();
+ }
+ }
+ this.searchText = v;
+ }
+ });
+ return FabCddAutocomplete;
+});
Oops, something went wrong.

0 comments on commit 77d1754

Please sign in to comment.