PageSourceSearch

https://coalizaopeloevangelho.org/wp-content/themes/luther/js/modules/swapsie.js?ver=6.6.8

js coalizaopeloevangelho.org collected 2026-09-26 15:51:58 UTC 7,172 bytes, 166 lines download raw bytes

1/*!
2 * jQuery Swapsie Plugin
3 * Examples and documentation at: http://biostall.com/swap-and-re-order-divs-smoothly-using-jquery-swapsie-plugin
4 * Copyright (c) 2010 Steve Marks - [email protected]
5 * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
6 * Version: extended by ISC
7 */
8
9var swapping = false;
10
11(function ($) {
12    $.fn.extend({
13        swap: function (options) {
14
15            var defaults = {
16                target: "",
17                speed: 1000,
18                opacity: "1",
19                callback: function () { }
20            };
21            var options = $.extend(defaults, options);
22
23            return this.each(function () {
24
25                var obj = $(this);
26
27                if (options.target != "" && !swapping) {
28
29                    swapping = true;
30                    var target_elem = $("#" + options.target);
31
32                    // set primary and secondary elements to relative if not already specified a positon CSS attribute
33                    var current_primary_pos = obj.css("position");
34                    var current_secondary_pos = $(target_elem).css("position");
35                    if (current_primary_pos != "relative" && current_primary_pos != "absolute") {
36                        obj.css({ "position": "relative" });
37                    }
38                    if (current_secondary_pos != "relative" && current_secondary_pos != "absolute") {
39                        $(target_elem).css({ "position": "relative" });
40                    }
41
42
43                    // calculate y-axis movement
44                    var current_primary_position = obj.offset();
45                    var current_primary_top = current_primary_position.top;
46                    var current_secondary_position = $(target_elem).offset();
47                    var current_secondary_top = current_secondary_position.top;
48                    var direction_primary_y = '-';
49                    var direction_secondary_y = '-';
50                    if (current_primary_top <= current_secondary_top) { // if primary above secondary 
51                        var direction_primary_y = '+';
52                        var total_y = current_secondary_top - current_primary_top;
53                    } else { // if primary below secondary 
54                        var total_y = current_primary_top - current_secondary_top;
55                    }
56                    if (direction_primary_y == '-') { direction_secondary_y = '+'; } else { direction_secondary_y = '-'; }
57                    //
58
59                    // calculate x-axis movement
60                    var current_primary_position = obj.offset();
61                    var current_primary_left = current_primary_position.left;
62                    var current_secondary_position = $(target_elem).offset();
63                    var current_secondary_left = current_secondary_position.left;
64                    var direction_primary_x = '-';
65                    var direction_secondary_x = '-';
66                    if (current_primary_left <= current_secondary_left) { // if primary left of secondary 
67                        var direction_primary_x = '+';
68                        var total_x = current_secondary_left - current_primary_left;
69                    } else { // if primary below secondary 
70                        var total_x = current_primary_left - current_secondary_left;
71                    }
72                    if (direction_primary_x == '-') { direction_secondary_x = '+'; } else { direction_secondary_x = '-'; }
73                    //
74
75                    // get widths and heights
76                    var current_primary_width = obj.outerWidth();
77                    var target_width = $(target_elem).outerWidth();
78                    var current_primary_height = obj.outerHeight();
79                    var target_height = $(target_elem).outerHeight();
80                    
81
82                   // debugger;
83                    // do swapping
84                    obj.animate({
85                        opacity: options.opacity
86                    }, 100, function () {
87                        obj.animate({
88                            top: direction_primary_y + "=" + (total_y) + "px",
89                            left: direction_primary_x + "=" + (total_x) + "px",
90                            width: target_width,
91                            // height: target_height
92                        }, options.speed, function () {
93                            obj.animate({
94                                opacity: "1"
95                            }, 100);
96                        });
97                    });
98                    $(target_elem).animate({
99                        opacity: options.opacity
100                    }, 100, function () {
101                        $(target_elem).animate({
102                            top: direction_secondary_y + "=" + (total_y) + "px",
103                            left: direction_secondary_x + "=" + (total_x) + "px",
104                            width: current_primary_width,
105                            // height: current_primary_height
106                        }, options.speed, function () {
107                            $(target_elem).animate({
108                                opacity: "1"
109                            }, 100, function () {
110                                swapping = false; // call the callback and apply the scope:
111                                //switch elem in dom
112                                swapElements(obj, target_elem);
113
114                                //reset styles
115                                $(obj).css({  top: '', left: '', width: '', height: '' });
116                                $(target_elem).css({ top: '', left: '', width: '', height: '' });
117
118                                options.callback.call(this);
119
120
121                            });
122                        });
123                    });
124
125                }
126
127            });
128
129            function swapElements(obj1, target) {
130                var clicked_elm = obj1;
131                var target_elm = target;
132                var clicked_prev = $(obj1).prev();
133                var clicked_next = $(obj1).next();
134                var clicked_parent = $(obj1).parent();
135                var target_prev = $(target).prev();
136                var target_next = $(target).next();
137                var target_parent = $(target).parent();
138
139
140                if (target_prev.length > 0) {
141                    $(clicked_elm).insertAfter(target_prev);
142                } else {
143                    if (target_next.length > 0) {
144                        $(clicked_elm).insertBefore(target_next);
145                    } else {
146                        $(clicked_elm).appendTo(target_parent);
147                    }
148                }
149
150                if (clicked_prev.length > 0) {
151                    $(target_elm).insertAfter(clicked_prev);
152                } else {
153                    if (clicked_next.length > 0) {
154                        $(target_elm).insertBefore(clicked_next);
155                    } else {
156                        $(target_elm).appendTo(clicked_parent);
157                    }
158                }
159
160
161
162            }
163
164        }
165    });
166})(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.