1/* 2 * jQuery sui microcart @VERSION 3 * 4 * Copyright (c) 2016 AUTHORS.txt (http://www.mediashaker.com) 5 * Dual licensed under the MIT (MIT-LICENSE.txt) 6 * and GPL (GPL-LICENSE.txt) licenses. 7 * 8 * Depends: 9 * jquery.ui.core.js 10 * jquery.ui.widget.js 11 */ 12 13(function($) { 14 $.widget("sui.microcart", { 15 version : "1.0.0", 16 options : { 17 productCount: 0, 18 prefix: '', 19 suffix: '' 20 }, 21 22 _productCount: null, 23 24 // private widget constants 25 _params : { 26 'element' : { 27 'classes' : { 28 'self' : 'ui-widget sui-microcart-widget' 29 }, 30 'selectors' : { 31 'microcart' : '.sui-microcart-widget' 32 }, 33 } 34 }, 35 36 _create : function() 37 { 38 var self = this; 39 self._initialize(); 40 }, 41 42 _initialize: function() 43 { 44 var self = this; 45 var $element = self.element; 46 var href = self.options.href; 47 var productCount = self.options.productCount; 48 49 $element.addClass(self._params.element.classes.self); 50 51 self.productCount(productCount); 52 53 this._on(top.document, { 54 'shoutcms_cart_changed': function(event, eventData) 55 { 56 self.productCount(eventData.productCount); 57 } 58 }); 59 }, 60 61 _destroy : function() 62 { 63 this.element.removeClass(this._params.element.classes.self); 64 $.Widget.prototype.destroy.apply(this, arguments); 65 66 this._super(); 67 }, 68 69 productCount: function(productCount) 70 { 71 var self = this; 72 var $element = self.element; 73 74 // getter 75 if (productCount === undefined) 76 { 77 return self._productCount; 78 } 79 80 // setter 81 self._productCount = productCount; 82 83 var text = [self.options.prefix, self._productCount, self.options.suffix] 84 .filter(function(item){return item !== '';}) 85 .join(''); 86 87 $element.html(text); 88 if (self._productCount === 0) 89 { 90 $element.hide(); 91 } 92 else 93 { 94 $element.show(); 95 } 96 } 97 }); 98})(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.