From 5b87c9f9e2e69425a2e60918fc07ea112c170c22 Mon Sep 17 00:00:00 2001 From: lonalore Date: Fri, 21 Jul 2017 09:13:54 +0200 Subject: [PATCH 1/2] Quickfix for Media Manager filtering. --- e107_handlers/admin_ui.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 100698e5f..e7f0ba1f8 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -6731,13 +6731,12 @@ class e_admin_form_ui extends e_form ",'prototype'); // TODO implement ajax queue - // FIXME - dirty way to register events after ajax update - DO IT RIGHT - see all.jquery, create object - // and use handler, re-register them global after ajax update (context) + // FIXME + // dirty way to register events after ajax update - DO IT RIGHT - see all.jquery, create object and use handler, + // re-register them global after ajax update (context)... use behaviors and call e107.attachBehaviors(); e107::js('footer-inline'," var filterRunning = false, request; var applyAfterAjax = function(context) { - \$('.e-hideme', context).hide(); - \$('.e-expandit', context).show(); \$('.e-expandit', context).click(function () { var href = (\$(this).is('a')) ? \$(this).attr('href') : ''; if(href == '' && \$(this).attr('data-target')) @@ -6786,7 +6785,10 @@ class e_admin_form_ui extends e_form return; } cont.html(data).css({ opacity: 1 }); + // TODO remove applyAfterAjax() and use behaviors! applyAfterAjax(cont); + // Attach behaviors to the newly loaded contents. + e107.attachBehaviors(); }, 700); }, 'html') .error(function() { From 1e3d8d46217f655c6023271ff515aa0495b6ee2a Mon Sep 17 00:00:00 2001 From: lonalore Date: Fri, 21 Jul 2017 09:17:36 +0200 Subject: [PATCH 2/2] Behaviors for .e-hideme and .e-expandit elements. --- e107_web/js/core/all.jquery.js | 36 ++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/e107_web/js/core/all.jquery.js b/e107_web/js/core/all.jquery.js index d5d6d087b..cbeafc9b8 100644 --- a/e107_web/js/core/all.jquery.js +++ b/e107_web/js/core/all.jquery.js @@ -315,6 +315,36 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}}; } }; + /** + * Behavior to hide elements. + * + * @type {{attach: e107.behaviors.eHideMe.attach}} + */ + e107.behaviors.eHideMe = { + attach: function (context, settings) + { + $(context).find('.e-hideme').once('e-hide-me').each(function () + { + $(this).hide(); + }); + } + }; + + /** + * Behavior to show elements. + * + * @type {{attach: e107.behaviors.eExpandIt.attach}} + */ + e107.behaviors.eExpandIt = { + attach: function (context, settings) + { + $(context).find('.e-expandit').once('e-expand-it').each(function () + { + $(this).show(); + }); + } + }; + /** * Check if the selector is valid. * @@ -715,12 +745,6 @@ $.ajaxSetup({ $(document).ready(function() { - $(".e-hideme").hide(); - $(".e-expandit").show(); - - // $(".e-spinner").spinner(); //FIXME breaks tooltips - - //check all $("#check-all").click(function(event){ var val = $(this).val(), selector = '.field-spacer';