PageSourceSearch

https://www.nysabprl.org/wp-content/themes/tsm-theme-1/plugins/_the_list/js/scripts-fe_ver-176_9.js

js nysabprl.org collected 2026-10-08 13:13:35 UTC 15,814 bytes, 410 lines download raw bytes

1/*
2 * Revised: Dec 17, 2014
3 *          Jan 12, 2015
4 */
5
6if (typeof(tsmb2b)=="undefined") tsmb2b = new Object();
7if (typeof(tsmb2b._the_list)=="undefined") tsmb2b._the_list = new Object();
8if (typeof(tsmb2b._the_list.fe)=="undefined") tsmb2b._the_list.fe = new Object();
9if (typeof(tsmb2b._the_list.fe.sorteable)=="undefined") tsmb2b._the_list.fe.sorteable = new Object();
10
11tsmb2b._the_list.fe.addNew = function(o) {
12    var o = jQuery(o),
13        slug = o.attr("data-slug"),
14        code = o.attr("data-code");
15    tsmb2b._the_list.fe.admin({
16        "slug":slug,
17        "module_col":0,
18        "module_id":tsmb2b.UUID(),
19        "module_page":b2b.post_id,
20        "module_page_type":b2b.isFrontPage?"home":"",
21        "module_code":code
22    });
23}
24
25tsmb2b._the_list.fe.admin = function(args) {
26    goTo = "plugins.php?page="+args.slug;
27    goTo += "&module_col="+args.module_col+"&module_id="+args.module_id+"&module_page="+args.module_page+"&module_page_type="+args.module_page_type+"&module_code="+args.module_code;
28    tsmb2b.page.set(goTo);
29}
30
31tsmb2b._the_list.fe.sorteable.done = function() {
32    jQuery("#_the_list_wrapper ._the_list").each(function () {
33        var e = jQuery(this)
34            isMovable = e.hasClass("movable");
35        if (isMovable) {
36            // Restore its original width after moving
37            e.attr("style","").removeClass("movable").find("._the_list_item.mod_1").each(function () {
38                var o = jQuery(this),
39                    margin = parseInt(o.css("margin-right"),10)+2;
40                o.css("margin-right",margin);
41            });
42        }
43    });
44    tsmb2b._the_list.fe.sorteable.destroy();
45}
46
47tsmb2b._the_list.fe.sorteable.init = function() {
48    jQuery("#_the_list_wrapper .connectedColumn").sortable({
49        connectWith: ".connectedColumn",
50        stop: function(event, ui) { tsmb2b._the_list.fe.sorteable.stop() },
51        start: function(event, ui) { tsmb2b._the_list.fe.sorteable.start() }
52    }).disableSelection();
53    tsmb2b._the_list.fe.sorteable.active = true;
54}
55
56tsmb2b._the_list.fe.sorteable.destroy = function() {
57    //jQuery("#_the_list_wrapper .connectedColumn").sortable("destroy");
58}
59
60tsmb2b._the_list.fe.sorteable.enable = function() {
61    jQuery("#_the_list_wrapper .connectedColumn").sortable("enable");
62}
63
64tsmb2b._the_list.fe.sorteable.start = function() {
65
66}
67
68tsmb2b._the_list.fe.sorteable.stop = function() {
69
70    var data = {"modules":{}};
71    jQuery("#_the_list_wrapper .connectedColumn").each(function () {
72        var column = jQuery(this),
73            module_col = column.attr("id").replace("column","");
74        column.find("._the_list").each(function () {
75            var module = jQuery(this),
76                module_id = module.attr("id").replace("_the_list_module_","");
77            if (typeof(data.modules[module_col]) == "undefined") data.modules[module_col] = new Array();
78            data.modules[module_col].push(module_id);
79            module.attr("data-module_col",module_col);
80        });
81    });
82
83    jQuery.post(b2b.admin_url+"admin-ajax.php", {
84        action: "save_order",
85        module_page: b2b.post_id,
86        data: data
87    }, function(retval) {
88
89    });
90
91}
92
93tsmb2b._the_list.fe.after = function(columns, module_code) {
94    if (module_code=="grid") {
95        tsmb2b._the_list.fe.grid(columns, module_code);
96    } else if (module_code=="team") {
97        tsmb2b._the_list.fe.team(columns, module_code);
98    } else if (module_code=="eflyer") {
99        tsmb2b._the_list.fe.eflyer(columns, module_code);
100    } else if (module_code=="events") {
101        tsmb2b._the_list.fe.events(columns, module_code);
102    } else if (module_code=="services") {
103        tsmb2b._the_list.fe.services(columns, module_code);
104    } else {
105        tsmb2b._the_list.fe.menu(columns, module_code)
106    }
107}
108
109tsmb2b._the_list.fe.menu = function(columns, module_code) {
110    var isMobile = jQuery("body.isMobile").length == 0 ? false : true,
111        columns = isMobile ? 1 : columns,
112        content = jQuery("#content"),
113        cnt = 1,
114        vars = {};
115
116    vars.module_code = module_code;
117    vars.columns = columns;
118    vars.pageWidth = content.width();
119    vars.colGapWidth = 30;
120    vars.innGapWidth = 20;
121    vars.gapQty = columns - 1;
122    vars.colWidth = parseInt((vars.pageWidth-(vars.gapQty*vars.colGapWidth)) / columns, 10);
123
124    // Column Width based on column qty
125    jQuery("#_the_list_wrapper .connectedColumn").each(function () {
126        var ele = jQuery(this);
127        marginRight = (cnt<columns)?vars.colGapWidth:0;
128        ele.css({
129            "width":vars.colWidth+"px",
130            "margin-right":marginRight+"px",
131            "padding-bottom":vars.colGapWidth+"px" 
132        }).find("li").css({"margin-bottom":vars.colGapWidth+"px"});
133        ++cnt;
134    });
135
136    // Image, Text Block and subheader width based on column with
137    jQuery("#_the_list_wrapper .connectedColumn ._the_list").each(function () {
138        var obj = jQuery(this);
139        if (!isMobile) obj.parent().parent().addClass("page_cols_"+columns);
140        tsmb2b._the_list.fe.menuModule(obj, vars)
141    });
142
143}
144
145tsmb2b._the_list.fe.menuModule = function(module, vars) {
146    var isMobile = jQuery("body.isMobile").length == 0 ? false : true,
147        txtblqWidth = 0,
148        imgWidth = 0,
149        subheaderWidth = 0,
150        isAlignRight = module.hasClass("items_align_right");
151
152    module.find("._the_list_item_subheader").each(function () {
153        var ele = jQuery(this),
154            width = ele.width();
155        if (width>subheaderWidth) subheaderWidth = width;
156    });
157
158    if (isMobile) subheaderWidth = 0;
159
160    if (subheaderWidth!=0) {
161        subheaderWidth += 5;
162        module.find("._the_list_item_subheader").css({"width":subheaderWidth+"px"});
163        module.find("._the_list_item_txtblq").css({"margin-right":vars.innGapWidth+"px"});
164    }
165
166    module.find("._the_list_item_image img").each(function () {
167        if (jQuery(this).attr("data-src")!="") imgWidth = 1;
168    });
169    if (imgWidth!=0) {
170        parts = (subheaderWidth!=0) ? 4 : 3;
171        imgWidth = parseInt((vars.colWidth-vars.innGapWidth)/parts,10);
172        imgWidth = (vars.columns == 2) ? 104 : ((vars.columns == 1) ? ((vars.module_code == "events") ? 104 : 300) : imgWidth);
173        module.find("._the_list_item_image").css({"width":imgWidth+"px","margin-right":vars.innGapWidth+"px"}).find("img").attr("width",imgWidth+"px");
174        module.find("._the_list_item_image img").each(function () {
175            var img = jQuery(this);
176            if (img.attr("data-src")=="") {
177                img.parent().html("&nbsp;");
178            } else {
179                tsmb2b._the_list.imgSize(img, imgWidth, "menu");
180            }
181        });
182    } else {
183        module.remove("._the_list_item_image")
184    }
185
186    txtblqWidth = vars.colWidth - imgWidth - ((imgWidth==0)?0:vars.innGapWidth) - subheaderWidth - ((subheaderWidth==0)?0:vars.innGapWidth);
187    module.find("._the_list_item_txtblq").css({"width":(txtblqWidth-2)+"px"});
188
189    if (isAlignRight) {
190        if (subheaderWidth==0) {
191            module.find("._the_list_item_txtblq").css({"margin-left":"","margin-right":vars.innGapWidth+"px"});
192        }
193    }
194
195    //console.log(module.html() + " -> " + vars.colWidth + ", " + imgWidth + ", " + subheaderWidth + " = " + txtblqWidth)
196}
197
198tsmb2b._the_list.fe.services = function(columns, module_code) {
199    tsmb2b._the_list.fe.menu(columns, module_code);
200}
201
202tsmb2b._the_list.fe.grid = function(columns, module_code) {
203    jQuery("#_the_list_global_grid .connectedColumn ._the_list").each(function () {
204        tsmb2b._the_list.fe.gridItem(jQuery(this))
205    });
206}
207
208tsmb2b._the_list.fe.gridItem = function(item, whatIsIt) {
209    var isMobile = jQuery("body.isMobile").length == 0 ? false : true,
210        whatIsIt = whatIsIt || "isGrid",
211        content = jQuery("#content"),
212        columns = isMobile ? 1 : parseInt(item.attr('data-itemcols'),10),
213        txtblqWidth = 0,
214        imgWidth = 0,
215        rowWidth = 0,
216        cnt = 1,
217        vars = {};
218
219    vars.pageWidth = content.width();
220    vars.colGapWidth = 30;
221    vars.gapQty = columns - 1;
222    vars.colWidth = parseInt((vars.pageWidth-(vars.gapQty*vars.colGapWidth)) / columns, 10);
223
224    imgWidth = columns<=2 ? 464 : (columns==3 ? 300 : (columns==4 ? 212 : vars.colWidth)) //(isMobile && whatIsIt=="isTeam") ? parseInt(vars.colWidth/2, 10) : vars.colWidth;
225    imgWidth = isMobile ? 300 : imgWidth;
226
227    item.addClass("_the_list_"+whatIsIt).find("._the_list_item").css({"width":vars.colWidth+"px"}).find("._the_list_item_image").css({"width":imgWidth+"px"}).find("img").each(function () {
228        var img = jQuery(this);
229        if (img.attr("data-src")=="") {
230            img.parent().html("&nbsp;");
231        } else {
232            tsmb2b._the_list.imgSize(img, imgWidth, "grid");
233        }
234    });
235
236    item.find("._the_list_item").each(function () {
237        var item = jQuery(this),
238            mod = cnt % columns,
239            marginRight = (mod!=0)?vars.colGapWidth:0;
240        item.addClass("mod_"+mod).css({"margin-right":marginRight+"px","margin-bottom":vars.colGapWidth+"px"});
241        if (cnt <= columns) rowWidth += marginRight + vars.colWidth;
242        ++cnt;
243    });
244
245    if (item.find("._the_list_item").length < columns) {
246        item.wrap('<div style="margin:0 auto;width:'+rowWidth+'px" />').parent().parent().css("width",vars.pageWidth+"px");
247    }
248}
249
250tsmb2b._the_list.fe.team = function(columns, module_code) {
251    jQuery("#_the_list_global_team .connectedColumn ._the_list").each(function () {
252        tsmb2b._the_list.fe.teamItem(jQuery(this))
253    });
254}
255
256tsmb2b._the_list.fe.teamItem = function(item) {
257    var isMobile = jQuery("body.isMobile").length == 0 ? false : true,
258        content = jQuery("#content"),
259        columns = isMobile ? 1 : parseInt(item.attr('data-itemcols'),10),
260        txtblqWidth = 0,
261        imgWidth = 0,
262        numItems = item.find("._the_list_item").length,
263        cnt = 1,
264        vars = {};
265
266    if (isMobile || columns!=2) {
267        // Same format as Photo Grid
268        tsmb2b._the_list.fe.gridItem(item, 'isTeam');
269    } else {
270        vars.pageWidth = content.width();
271        vars.colGapWidth = 30;
272        vars.gapQty = columns - 1;
273        vars.colWidth = (numItems==1) ? vars.pageWidth : parseInt((vars.pageWidth-(vars.gapQty*vars.colGapWidth)) / columns, 10);
274
275        item.find("._the_list_item").each(function () {
276            var item = jQuery(this),
277                mod = cnt % columns
278                marginRight = (mod!=0 && numItems!=1) ? vars.colGapWidth : 0,
279                intPadding = parseInt(vars.colGapWidth / 2,10),
280                imgWidth = parseInt(vars.colWidth * ((numItems==1) ? 0.25 : 0.413), 10),
281                imgWidth = (columns == 2) ? 192 : imgWidth;
282                txtblqWidth = vars.colWidth - intPadding - imgWidth;
283
284            item.append("<div style='clear:both'></div>").addClass("mod_"+mod).css({"width":vars.colWidth+"px","margin-right":marginRight+"px","margin-bottom":vars.colGapWidth+"px"});
285            item.find("._the_list_item_txtblq").css({"width":txtblqWidth+"px"})
286            item.find("._the_list_item_image").css({"width":imgWidth+"px","margin-right":intPadding+"px"}).find("img").each(function () {
287                var img = jQuery(this);
288                if (img.attr("data-src")=="") {
289                    img.parent().html("&nbsp;");
290                } else {
291                    tsmb2b._the_list.imgSize(img, imgWidth, "team");
292                }
293            });
294
295            ++cnt;
296        });
297    }
298}
299
300tsmb2b._the_list.fe.eflyer = function(columns, module_code) {
301    jQuery("#_the_list_global_eflyer .connectedColumn ._the_list").each(function () {
302        tsmb2b._the_list.fe.gridItem(jQuery(this), 'isFlyer');
303    });
304}
305
306tsmb2b._the_list.fe.events = function(columns, module_code) {
307    tsmb2b._the_list.fe.menu(columns, module_code);
308    jQuery("#_the_list_global_events ._the_list_item").css("margin-bottom","30px");
309}
310
311tsmb2b._the_list.imgSize = function(img, imgWidth, code) {
312	if( jQuery.sonar !== undefined ){	//rishi - check if the lazy load JS file is present. in case it fails to load, the images will load normal, without the laziness.
313		var sonarClass = img.parents( '._the_feature_item' ).length?'._the_feature_item':'._the_list_item';
314		img.parents( sonarClass ).bind( 'scrollin._b2b_the_list', function(){	//rishi - add a scroll in event here. this event gets triggered when the elements come on screen. we bind the event to the item instead of image, because image is display:none
315			var $elem = jQuery(this),
316				img = $elem.find( 'img' );
317
318			$elem.unbind( 'scrollin._b2b_the_list' );		//rishi - unbind the scrollin event to prevent refiring. 
319			tsmb2b._the_list.imgSize_Intermediate( img, imgWidth, code );
320		});
321	}
322	else{	//rishi - simply load the images if lazy load file is not present.
323		tsmb2b._the_list.imgSize_Intermediate( img, imgWidth, code );
324	}
325}
326
327tsmb2b._the_list.imgSize_Intermediate = function(img, imgWidth, code){	//rishi - moved the imgSize to imgSize_Intermediate
328	img.attr({
329        "width":imgWidth+"px",
330        "data-code":code
331    }).load(function() {
332    	var img = jQuery(this),
333    		badge = img.parents( '._the_feature_item_image' ).find( '.b2b-badge' );
334    	
335    		tsmb2b._the_list.imgSizeCalculate( img );
336    		img.unbind( 'load' ).fadeIn( 200 );
337    		badge.fadeIn( 200 );
338    }).attr( 'src', img.attr( 'data-src' ) );
339}
340
341tsmb2b._the_list.imgSizeCalculate = function(img) {
342	
343	var imgSrc = img.attr( 'src' ),
344		imgWidth = parseInt(img.attr("width"),10),
345        code = img.attr("data-code"),
346        imgsize = img.hasClass("imgsize_scale") ? "scale" : (img.hasClass("imgsize_trim") ? "trim" : "original"),
347
348        ratio_4_3 = function() { return Math.round(imgWidth * 0.75); }, // 300 x 226 - 122 x 92
349        sizeV = function() { return Math.round(imgWidth * 1.5); },      // 300 x 450
350        sizeF = function() { return Math.round(imgWidth * 1.06); },     // 300 x 318
351        sizeS = function() { return Math.round(imgWidth * 1.153); },    // 190 x 219
352
353        maxW = imgWidth,
354        maxH = ratio_4_3(), //code=="team" ? sizeS() : ratio_4_3(); //(code=="menu"||code=="events") ? ratio_4_3() : ((code=="team") ? sizeS() : sizeF());
355        css = {};
356        
357    if (imgsize=="scale") {
358        /*
359         * SCALE TO FIT
360         */
361        imgWidth = 0;
362        imgHeight = 0;
363        maxH = maxW;
364
365        img.parents("._the_list_item_image, ._the_feature_item_image").css({
366            "width":maxW+"px",
367            "height":maxH+"px"
368        });
369
370        if (img.height() > img.width()) {
371            imgHeight = maxH; // Vertical
372            imgWidth = Math.round(img.width() * (maxH / img.height()));
373        } else {
374            imgWidth = maxW; // Horizontal
375        }
376
377
378    } else if (imgsize=="trim") {
379        /*
380         * TRIM & CROP
381         */
382        img.parents("._the_list_item_image, ._the_feature_item_image").css({
383            "width":maxW+"px",
384            "height":maxH+"px",
385            "overflow":"hidden"
386        });
387
388        //imgHeight = img.height() > maxH ? maxH : 0;
389        imgHeight = maxH;
390
391
392    } else {
393        /*
394         * ORIGINAL
395         */
396        imgHeight = 0; // Ignore
397
398
399    }
400    css = {};
401    if (imgWidth!=0) { img.attr("width",imgWidth+"px"); css.width = imgWidth; }
402    if (imgHeight!=0) { img.attr("height",imgHeight+"px"); css.height = imgHeight; }
403    //img.attr("src",(img.attr("src")+"?"+((imgWidth!=0)?"&w="+imgWidth:"")+(imgHeight!=0?"&h="+imgHeight:"")).replace("?&","?"));
404    if( imgWidth > 464 ){
405    	imgSrc = imgSrc.split( '?' )[0];
406    	img.attr( 'src', imgSrc + '?w=' + imgWidth );
407    }
408    //img.removeClass( 'list-lazy-load' ).attr("src",(imgSrc+"?"+((imgWidth!=0)?"&w="+imgWidth:"")+(imgHeight!=0?"&h="+imgHeight:"")).replace("?&","?"));
409    img.css( css );
410}

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.