1/* vim: set ts=2 sw=2 sts=2 et: */ 2 3/** 4 * Reloadable layout block widget controller 5 * 6 * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved. 7 * See https://www.x-cart.com/license-agreement.html for license details. 8 */ 9 10if (_.isUndefined(jQuery.getQueryParameters)) { 11 jQuery.extend({ 12 getQueryParameters : function(str) { 13 return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0]; 14 } 15 }); 16} 17 18function LayoutBlockWidget(base) 19{ 20 LayoutBlockWidget.superclass.constructor.apply(this, arguments); 21 22 this.widgetClass = this.base.data('widget'); 23 24 this.widgetTarget = core.getTarget(); 25 26 core.bind('layout.block.reload', _.bind(this.reload, this)); 27 28 this.base.data('controller', this); 29} 30 31extend(LayoutBlockWidget, ALoadable); 32 33LayoutBlockWidget.prototype.reloadIfError = false; 34 35LayoutBlockWidget.prototype.shadeWidget = true; 36 37LayoutBlockWidget.prototype.defineWidgetParams = function() { 38 return _.defaults( 39 { 40 'displayGroup': this.base.data('display') 41 }, 42 jQuery.getQueryParameters() 43 ); 44}; 45 46LayoutBlockWidget.prototype.reload = function(event, args) { 47 if (args.id == this.base.data('id')) { 48 this.widgetParams = this.defineWidgetParams(); 49 this.load(); 50 } 51}; 52 53// Place parsed request data into DOM 54LayoutBlockWidget.prototype.insertIntoDOM = function(box) 55{ 56 this.base.find('.list-item-content').html(box); 57 return this.base; 58}; 59 60// Extract widget content 61LayoutBlockWidget.prototype.extractContent = function(box) 62{ 63 box = jQuery(this.containerRequestPattern, box); 64 return box.children(); 65}; 66 67LayoutBlockWidget.autoload = function() { 68 jQuery('.list-item[data-display]').each(function () { 69 new LayoutBlockWidget(this); 70 }); 71}; 72 73core.autoload(LayoutBlockWidget);
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.