PageSourceSearch

https://patient.webdoctors.com/js/snackbar.js?v=3.2

js webdoctors.com collected 2026-10-04 03:07:36 UTC 5,847 bytes, 173 lines download raw bytes

vendor: 5,847 bytes, lines 1-173
1/*!
2 * Snackbar v0.1.10
3 * http://polonel.com/Snackbar
4 *
5 * Copyright 2018 Chris Brame and other contributors
6 * Released under the MIT license
7 * https://github.com/polonel/Snackbar/blob/master/LICENSE
8 */
9
10(function(root, factory) {
11    'use strict';
12
13    if (typeof define === 'function' && define.amd) {
14        define([], function() {
15            return (root.Snackbar = factory());
16        });
17    } else if (typeof module === 'object' && module.exports) {
18        module.exports = root.Snackbar = factory();
19    } else {
20        root.Snackbar = factory();
21    }
22})(this, function() {
23    var Snackbar = {};
24
25    Snackbar.current = null;
26    var $defaults = {
27        text: 'Default Text',
28        width: 'auto',
29        showAction: false,
30        showSecondButton: false,
31        secondButtonText: '',
32        pos: 'bottom-center',
33        duration: 3000,
34        customClass: '',
35        onActionClick: function(element) {
36            element.style.opacity = 0;
37        },
38        onSecondButtonClick: function(element) {},
39        onClose: function(element) {}
40    };
41
42    Snackbar.show = function($options) {
43        var options = Extend(true, $defaults, $options);
44
45        if (Snackbar.current) {
46            Snackbar.current.style.opacity = 0;
47            setTimeout(
48                function() {
49                    var $parent = this.parentElement;
50                    if ($parent)
51                    // possible null if too many/fast Snackbars
52                        $parent.removeChild(this);
53                }.bind(Snackbar.current),
54                500
55            );
56        }
57
58        Snackbar.snackbar = document.createElement('div');
59        Snackbar.snackbar.className = 'snackbar-container ' + options.customClass;
60        Snackbar.snackbar.style.width = options.width;
61        var $p = document.createElement('p');
62        $p.style.margin = 0;
63        $p.style.padding = 0;
64        $p.style.color = options.textColor;
65        $p.style.fontSize = 'inherit';
66        $p.style.fontWeight = 300;
67        $p.style.lineHeight = '1em';
68        $p.innerHTML = options.text;
69        Snackbar.snackbar.appendChild($p);
70        Snackbar.snackbar.style.background = options.backgroundColor;
71
72        if (options.showSecondButton) {
73            var secondButton = document.createElement('button');
74            secondButton.className = 'action';
75            secondButton.innerHTML = options.secondButtonText;
76            secondButton.style.color = options.secondButtonTextColor;
77            secondButton.addEventListener('click', function() {
78                options.onSecondButtonClick(Snackbar.snackbar);
79            });
80            Snackbar.snackbar.appendChild(secondButton);
81        }
82
83        if (options.showAction) {
84            var actionButton = document.createElement('button');
85            actionButton.className = 'action';
86            actionButton.innerHTML = options.actionText;
87            actionButton.style.color = options.actionTextColor;
88            actionButton.addEventListener('click', function() {
89                options.onActionClick(Snackbar.snackbar);
90            });
91            Snackbar.snackbar.appendChild(actionButton);
92        }
93
94        if (options.duration) {
95            setTimeout(
96                function() {
97                    if (Snackbar.current === this) {
98                        Snackbar.current.style.opacity = 0;
99                        // When natural remove event occurs let's move the snackbar to its origins
100                        Snackbar.current.style.top = '-100px';
101                        Snackbar.current.style.bottom = '-100px';
102                    }
103                }.bind(Snackbar.snackbar),
104                options.duration
105            );
106        }
107
108        Snackbar.snackbar.addEventListener(
109            'transitionend',
110            function(event, elapsed) {
111                if (event.propertyName === 'opacity' && this.style.opacity === '0') {
112                    if (typeof(options.onClose) === 'function')
113                        options.onClose(this);
114
115                    this.parentElement.removeChild(this);
116                    if (Snackbar.current === this) {
117                        Snackbar.current = null;
118                    }
119                }
120            }.bind(Snackbar.snackbar)
121        );
122
123        Snackbar.current = Snackbar.snackbar;
124
125        document.body.appendChild(Snackbar.snackbar);
126        var $bottom = getComputedStyle(Snackbar.snackbar).bottom;
127        var $top = getComputedStyle(Snackbar.snackbar).top;
128        Snackbar.snackbar.style.opacity = 1;
129        Snackbar.snackbar.className =
130            'snackbar-container ' + options.customClass + ' snackbar-pos ' + options.pos;
131    };
132
133    Snackbar.close = function() {
134        if (Snackbar.current) {
135            Snackbar.current.style.opacity = 0;
136        }
137    };
138
139    // Pure JS Extend
140    // http://gomakethings.com/vanilla-javascript-version-of-jquery-extend/
141    var Extend = function() {
142        var extended = {};
143        var deep = false;
144        var i = 0;
145        var length = arguments.length;
146
147        if (Object.prototype.toString.call(arguments[0]) === '[object Boolean]') {
148            deep = arguments[0];
149            i++;
150        }
151
152        var merge = function(obj) {
153            for (var prop in obj) {
154                if (Object.prototype.hasOwnProperty.call(obj, prop)) {
155                    if (deep && Object.prototype.toString.call(obj[prop]) === '[object Object]') {
156                        extended[prop] = extend(true, extended[prop], obj[prop]);
157                    } else {
158                        extended[prop] = obj[prop];
159                    }
160                }
161            }
162        };
163
164        for (; i < length; i++) {
165            var obj = arguments[i];
166            merge(obj);
167        }
168
169        return extended;
170    };
171
172    return Snackbar;
173});

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.