PageSourceSearch

https://www.ammersbek.de/wp-content/wp-file-download/themes/wpfd-d…/js/jquery.mediaTable.js?ver=7.0.6

js ammersbek.de collected 2026-10-02 21:33:54 UTC 9,439 bytes, 308 lines download raw bytes

1/**
2 Copyright (c) 2012 Marco Pegoraro, http://movableapp.com/
3
4 Permission is hereby granted, free of charge, to any person obtaining
5 a copy of this software and associated documentation files (the
6 "Software"), to deal in the Software without restriction, including
7 without limitation the rights to use, copy, modify, merge, publish,
8 distribute, sublicense, and/or sell copies of the Software, and to
9 permit persons to whom the Software is furnished to do so, subject to
10 the following conditions:
11
12 The above copyright notice and this permission notice shall be
13 included in all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23
24 WHERE TO FIND MEDIA TABLE:
25 https://github.com/thepeg/MediaTable
26 http://consulenza-web.com/jquery/MediaTable/
27 http://www.consulenza-web.com/2012/01/mediadownloadlist-jquery-plugin/
28
29 **/
30
31
32/**
33 * jQuery Bacheca
34 * Plugin Dimostrativo
35 */
36
37;(function ($) {
38
39
40    /**
41     * DOM Initialization Logic
42     */
43
44    var __loop = function (cfg, i) {
45
46        var $this = $(this),
47            wdg = $this.data('MediaTable');
48
49        // Prevent re-initialization of the widget!
50        if (!$.isEmptyObject(wdg)) return;
51
52        // Build the widget context.
53        wdg = {
54            $wrap: $('<div>'),		// Refer to the main content of the widget
55            $table: $this,			// Refer to the MediaTable DOM (TABLE TAG)
56            $menu: false,			// Refer to the column's toggler menu container
57            cfg: cfg,			// widget local configuration object
58            id: $this.attr('id')
59        };
60
61        // Setup Widget ID if not specified into DOM Table.
62        if (!wdg.id) {
63            wdg.id = 'MediaTable-' + i;
64            wdg.$table.attr('id', wdg.id);
65        }
66
67
68        // Activate the MediaTable.
69        wdg.$table.addClass('activeMediaTable');
70
71        // Create the wrapper.
72        wdg.$wrap.addClass('mediaTableWrapper');
73
74        // Place the wrapper near the table and fill with MediaTable.
75        wdg.$table.before(wdg.$wrap).appendTo(wdg.$wrap);
76
77
78        // Menu initialization logic.
79        if (wdg.cfg.menu) __initMenu(wdg);
80
81        // Columns Initialization Loop.
82        wdg.$table.find('thead th').each(function (i) {
83            __thInit.call(this, i, wdg);
84        });
85
86
87        // Save widget context into table DOM.
88        wdg.$table.data('MediaTable', wdg);
89
90    }; // EndOf: "__loop()" ###
91
92
93    var __initMenu = function (wdg) {
94
95        // Buid menu objects
96        wdg.$menu = $('<div />');
97        wdg.$menu.$header = $('<a title="' + wpfdTableTheme.columns + '" />');
98        wdg.$menu.$list = $('<ul />');
99
100        // Setup menu general properties and append to DOM.
101        wdg.$menu
102            .addClass('mediaTableMenu')
103            .addClass('mediaTableMenuClosed')
104            .append(wdg.$menu.$header)
105            .append(wdg.$menu.$list);
106
107        // Add a class to the wrapper to inform about menu presence.
108        wdg.$wrap.addClass('mediaTableWrapperWithMenu');
109
110        // Setup menu title (handler)
111        wdg.$menu.$header.html(wdg.cfg.menuTitle);
112        wdg.$table.before(wdg.$menu);
113
114        // Bind screen change events to update checkbox status of displayed fields.
115        $(window).bind('orientationchange resize', function () {
116            wdg.$menu.find('input').trigger('updateCheck');
117        });
118
119        // Toggle list visibility when clicking the menu title.
120        wdg.$menu.$header.bind('click', function () {
121            wdg.$menu.toggleClass('mediaTableMenuClosed');
122        });
123
124        wdg.$table.click(function () {
125            wdg.$menu.addClass('mediaTableMenuClosed');
126        });
127
128        // Toggle list visibilty when mouse go outside the list itself.
129        wdg.$menu.$list.bind('mouseleave', function (e) {
130            wdg.$menu.toggleClass('mediaTableMenuClosed');
131            e.stopPropagation();
132        });
133
134
135    }; // EndOf: "__initMenu()" ###
136
137    var __thInit = function (i, wdg) {
138
139        var $th = $(this),
140            id = $th.attr('id'),
141            classes = $th.attr('class');
142
143        // Set up an auto-generated ID for the column.
144        // the ID is based upon widget's ID to allow multiple tables into one page.
145        if (!id) {
146            id = wdg.id + '-mediaTableCol-' + i;
147            $th.attr('id', id);
148        }
149
150        // Add toggle link to the menu.
151        if (wdg.cfg.menu && !$th.is('.persist')) {
152
153            var $li = $('<li><input type="checkbox" name="toggle-cols" id="toggle-col-' + wdg.id + '-' + i + '" value="' + id + '" /> <label for="toggle-col-' + wdg.id + '-' + i + '">' + $th.text() + '</label></li>');
154            wdg.$menu.$list.append($li);
155
156            __liInitActions($th, $li.find('input'), wdg);
157
158        }
159
160        // Propagate column's properties to each cell.
161        $('tbody tr:not(.nohide)', wdg.$table).each(function () {
162            __trInit.call(this, i, id, classes);
163        });
164        $('tbody', wdg.$table).on('change', function () {
165            $('tbody tr:not(.nohide)', wdg.$table).each(function () {
166                __trInit.call(this, i, id, classes);
167            });
168        });
169
170    }; // EndOf: "__thInit()" ###
171
172
173    var __trInit = function (i, id, classes) {
174
175        var $cell = $(this).find('td,th').eq(i);
176
177        $cell.attr('headers', id);
178
179        if (classes) $cell.addClass(classes);
180
181    }; // EndOf: "__trInit()" ###
182
183
184    var __liInitActions = function ($th, $checkbox, wdg) {
185
186        var change = function () {
187
188            var val = $checkbox.val(),  // this equals the header's ID, i.e. "company"
189                cols = wdg.$table.find("#" + val + ", [headers=" + val + "]"); // so we can easily find the matching header (id="company") and cells (headers="company")
190            
191            if ($checkbox.is(":checked")) {
192                cols.show();
193                cols.removeClass('wpfd-col-hidden');
194            } else {
195                cols.hide();
196                cols.addClass('wpfd-col-hidden')
197            }
198            ;
199
200
201            var wpfdTable = $('.wpfd-container table.wpfd-search-result');
202            wpfdTable.each(function () {
203                var visibleRow = $(this).find('thead tr');
204                visibleRow.each(function () {
205                    var visibleColumn = $(this).find('th.optional:not(.wpfd-col-hidden)');
206                    visibleColumn.each(function () {
207                        if ($(this).is(visibleColumn.last())) {
208                            $(this).addClass('wpfd-last-col-downloadlist');
209                            $(this).addClass('wpfd-padding-right');
210                        } else {
211                            $(this).removeClass('wpfd-last-col-downloadlist');
212                            $(this).removeClass('wpfd-padding-right');
213                        }
214                    })
215                })
216            })
217        };
218
219        var updateCheck = function () {
220
221            //if ( $th.css("display") ==  "downloadlist-cell") {
222            if ($th.is(':visible') || $th.css('display') !== 'none') {
223                $checkbox.attr("checked", true);
224            } else {
225                $checkbox.attr("checked", false);
226            }
227            ;
228
229        };
230
231        $checkbox
232            .bind('change', change)
233            .bind('updateCheck', updateCheck)
234            .trigger('updateCheck');
235
236    } // EndOf: "__liInitActions()" ###
237
238
239    /**
240     * Widget Destroy Logic
241     */
242
243    var __destroy = function () {
244
245        // Get the widget context.
246        var wdg = $(this).data('MediaTable');
247        if (!wdg) return;
248
249
250        // Remove the wrapper from the MediaTable.
251        wdg.$wrap.after(wdg.$table).remove();
252
253        // Remove MediaTable active class so media-query will not work.
254        wdg.$table.removeClass('activeMediaTable');
255
256
257        // Remove DOM reference to the widget context.
258        wdg.$table.data('MediaTable', null);
259
260    }; // EndOf: "__destroy()" ###
261
262
263    /**
264     * jQuery Extension
265     */
266    $.fn.mediaTable = function () {
267
268        var cfg = false;
269
270        // Default configuration block
271        if (!arguments.length || $.isPlainObject(arguments[0])) cfg = $.extend({}, {
272
273            // Teach the widget to create a toggle menu to declare column's visibility
274            menu: true,
275            menuTitle: '<i class="zmdi zmdi-settings"></i>',
276
277            t: 'e'
278        }, arguments[0]);
279        // -- default configuration block --
280
281
282        // Items initialization loop:
283        if (cfg !== false) {
284            $(this).each(function (i) {
285                __loop.call(this, cfg, i);
286            });
287
288
289            // Item actions loop - switch throught actions
290        } else if (arguments.length) switch (arguments[0]) {
291
292            case 'destroy':
293                $(this).each(function () {
294                    __destroy.call(this);
295                });
296                break;
297
298        }
299
300
301        // Mantengo la possibilit� di concatenare plugins.
302        return this;
303
304    }; // EndOf: "$.fn.mediaTable()" ###
305
306
307})(jQuery);
308

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.