PageSourceSearch

https://www.wsw-online.de/typo3temp/assets/compressed/AjaxContent-…02364df0c9a270ae1e3d1973.js.gzip?1790772776

js wsw-online.de collected 2026-10-01 11:51:15 UTC 9,717 bytes, 281 lines download raw bytes

1/**
2 * AjaxContent
3 *
4 * Typo3 Ajax-Content Lib.
5 *
6 * Fuehrt automatisch einen Ajax call fuer bestimmte Links oder Formulare durch.
7 * Dabei wird automatisch die ContentId ermittelt und genau dieses Element
8 * neu gerendert und ersetzt.
9 *
10 * @copyright Copyright (c) 2014 DMK E-BUSINESS GmbH <[email protected]>
11 * @license http://www.gnu.org/licenses/lgpl.html
12 *             GNU Lesser General Public License, version 3 or later
13 * @version 0.1.0
14 * @requires jQuery, Base, Request
15 * @author Michael Wagner <[email protected]>
16 */
17/*
18 * Sample to set the PageType:
19 * DMK.AjaxContent.setData("pageType", 99);
20 */
21/*
22 * Sample to override the RequestCall:
23 *     DMK.Objects.AjaxContentAjaxRequest.prototype.onSuccess = function(data, parameters) {
24 *         // do some thinks
25 *     }
26 */
27(function(DMK, w, $){
28    "use strict";
29    var AjaxRequest, AjaxContent, VERSION = "0.1.0";
30
31
32    AjaxContent = function AjaxContent() {
33        this.setData("version", VERSION);
34        this.setData("pageType", 9267);
35    };
36
37    // Ajax Request definieren
38    AjaxRequest = DMK.Request.extend(function AjaxRequest() {});
39    AjaxRequest.prototype.getLoader = function() { return $(); };
40
41    // wir erben von dem basis objekt
42    AjaxContent = DMK.Base.extend(AjaxContent);
43
44
45    AjaxContent.prototype.init = function() {
46        var _self = this,
47            _event = function(event, element) {
48                return _self.handleAjaxClick(event, element);
49            }
50        ;
51        // click events
52        $("body")
53            .off("click.ajaxcontentlinks")
54            .on(
55                "click.ajaxcontentlinks",
56                ".ajax-links a, a.ajax-link",
57                _event
58            );
59        // submit events
60        $("body")
61            .off("submit.ajaxcontentform")
62            .on(
63                "submit.ajaxcontentform",
64                "form.ajax-form",
65                _event
66            );
67        // autotriger for forms
68        $("body")
69            .off("click.ajaxcontentform")
70            .on(
71                "click.ajaxcontentform",
72                "form.ajax-autotrigger input:not(:text)",
73                _event
74            )
75            .off("change.ajaxcontentform")
76            .on(
77                "change.ajaxcontentform",
78                "form.ajax-autotrigger select",
79                _event
80            );
81
82        $('.ajax-links-autoload').each(function() {
83            _self.handleAjaxClick(null, $(this)[0]);
84        });
85    };
86
87    AjaxContent.prototype.handleAjaxClick = function(event, element) {
88        var _self = this, _request = DMK.Objects.getInstance("AjaxContentAjaxRequest"),
89            parameters = {type : this.getData("pageType")},
90            $el, $linkwrap, $content,
91            xhr
92        ;
93
94        element = _self.isDefined(element) ? element : event.currentTarget;
95
96        // do request only if there is no target attribute
97        if (element.tagName.toLowerCase() === "a") {
98            if (
99                element.target.length > 0
100                || (
101                    element.href.search(':') >= 0
102                    && $.inArray(
103                        element.href.split(':').shift().toLowerCase(),
104                        // complete list of available schemes:
105                        // http://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
106                        ["javascript", "mailto", "tel", "fax", "about", "data"]
107                    ) >= 0
108                )
109            ) {
110                return;
111            }
112        }
113
114        $el = $(element);
115
116        if ($el.hasClass("ajax-autotrigger-ignore")) {
117            return;
118        }
119
120        // wir suchen die contentid! (e.g. id="c516")
121        if ($el.data("ajaxreplaceid") && _self.isNumeric($el.data("ajaxreplaceid").slice(1))) {
122            $content = $el;
123        }
124
125        if (_self.isDefined($content)) {
126            // Abbruch bei nicht vorhandenem Element
127            $content = $("#" + $content.data("ajaxreplaceid"));
128            if (typeof $content === "undefined") {
129                return false;
130            }
131        }
132        else {
133            $el.parents("div[id^='c'], section[id^='c'], article[id^='c']").each(
134                function(index, element) {
135                    $content = $(element);
136                    if (_self.isNumeric($content.attr("id").slice(1))) {
137                        return false;
138                    }
139                    return true;
140                }
141            );
142        }
143        // kein content element gefunden, wir ersetzen nichts!
144        if (!_self.isObjectJQuery($content) || $content.length === 0) {
145            return ;
146        }
147
148        $content.addClass("ajax-content");
149        if ($content.find(".waiting").length === 0) {
150            $content.append($("<div>").addClass("waiting").hide());
151        }
152
153        // ajax parameter sammeln
154        if ($content.data("ajaxreplaceid")) {
155            parameters.contentid = $content.data("ajaxreplaceid").slice(1);
156        }
157        else {
158            parameters.contentid = $content.attr("id").slice(1);
159        }
160
161        // so we know in DMK\Mktools\ContentObject\UserInternalContentObject
162        // that the content should be rendered for real
163        parameters.mktoolsAjaxRequest = true;
164
165        $linkwrap = $el.parent();
166        if ($linkwrap.hasClass("ajax-link-next") || $linkwrap.hasClass("browse_next")) {
167            parameters.page = "next";
168        }
169        else if ($linkwrap.hasClass("ajax-link-prev") || $linkwrap.hasClass("browse_prev")) {
170            parameters.page = "prev";
171        }
172        else {
173            // try to fetch page
174            parameters.page = "";
175        }
176
177        // decide whether action url is written in history or not
178        if (!$el.hasClass("ajax-no-history")) {
179            parameters.useHistory = true;
180        }
181
182        // die events anlegen
183        _request.onStart = function(data, parameters){
184            this.parent().onStart.call(this, data, parameters);
185            $content.find(".waiting").clearQueue().fadeIn();
186        };
187        _request.onComplete = function(data, parameters, jqXHR, textStatus){
188            this.parent().onComplete.call(this, data, parameters, jqXHR, textStatus);
189            $content.find(".waiting").clearQueue().fadeOut();
190        };
191        _request.onSuccess = function(data, parameters, textStatus, jqXHR) {
192            this.parent().onSuccess.call(this, data, parameters, textStatus, jqXHR);
193            var from = 0, to = 0;
194            if (parameters.page === "next") {
195                to = 1;
196            }
197            else if (parameters.page === "prev") {
198                from = 1;
199            }
200            if ($el.data("ajaxCustomReplaceMethod")) {
201                _self[$el.data("ajaxCustomReplaceMethod")](parameters.contentid, data, from, to);
202            } else {
203                _self.replaceContent(parameters.contentid, data, from, to);
204            }
205        };
206
207        if ($el.hasClass("notcachable")) {
208            _request.getCache = function() {
209                return false;
210            };
211        }
212
213        if (
214            (xhr = _request.doCall($el, parameters))
215            && event
216            && !$el.hasClass("test")
217        ) {
218            if (!$el.hasClass("ajax-dont-prevent-default")) {
219                event.preventDefault();
220            }
221        }
222        return xhr;
223    };
224
225    AjaxContent.prototype.replaceContent = function(contentId, html, from, to) {
226        var $cOld = $("#c" + contentId), $cNew,
227            animateTime = 1000;
228        if ($cOld.length === 0) {
229            return;
230        }
231        // wir sliden
232        if (from != to) {
233            var $slidebox = $cOld.parent(),
234                left = from < to, // true > slide to left, false > slide to right
235                old = { width : $cOld.width(), height : $cOld.height() };
236            // slidebox wrap erzeugen, falls nicht existent.
237            if (!$slidebox.hasClass("ajax-wrap")) {
238                $cOld.wrap($("<div>").addClass("ajax-wrap"));
239                $slidebox = $cOld.parent();
240                $slidebox.css({"position" : "relative", "overflow" : "hidden"});
241            }
242            $slidebox.width(old.width).height(old.height);
243            $cOld.css({"position" : "absolute", "top" : 0, "left" : 0, "width" : old.width});
244            // das alte element
245            $cOld.attr('id', contentId + '-old').addClass("ajax-content-old");
246            $cNew = left ? $(html).insertAfter($cOld) : $(html).insertBefore($cOld);
247            if ($cNew.length === 0) {
248                from = to = 0;
249            }
250            else {
251                $cNew.css({"position" : "absolute", "top" : 0, "left" : old.width * (left ? +1 : -1), "width" : old.width});
252                $slidebox.find(".waiting").clearQueue().fadeOut();
253                $slidebox.animate({"height" : $cNew.height()}, animateTime);
254                $cOld.animate({"left" : old.width * (left ? -1 : +1)}, animateTime);
255                $cNew.animate({"left" : 0}, animateTime, function () {
256                    w.setTimeout(function() {
257                        $cOld.remove();
258                    }, 250);
259                });
260            }
261
262        }
263
264        // normales ersetzen
265        if (from == to) {
266            $cOld.replaceWith(html);
267        }
268
269        this.onAfterReplaceContent(contentId);
270    };
271
272    /**
273     * Overwrite this method if you want to do something after the content is replaced
274     */
275    AjaxContent.prototype.onAfterReplaceContent = function(contentId) {
276    };
277
278    // add lib to basic library
279    DMK.Objects.add(AjaxRequest, "AjaxContentAjaxRequest");
280    DMK.Libraries.add(AjaxContent);
281})(DMK, window, jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.