PageSourceSearch

https://www.akhbarelbalad.net/themes/publication_1/theme_1/assets/js/materialize.min.js

js akhbarelbalad.net collected 2026-10-02 20:13:34 UTC 12,803 bytes, 410 lines download raw bytes

1$(function(){
2	'use strict';
3	$.fn.hasAttr = function(attribute){
4		var attr = this.attr(attribute);
5		if (typeof attr !== typeof undefined && attr !== false) 
6		   return true;
7		return false;
8	}
9
10	$.fn.materialForm = function() {
11		// Inputs
12	    this.find('input, textarea').each(function(i){
13	    	if(isValidType($(this))){
14	    		var name = $(this).attr('name');
15	    		$(this).attr('id', name);
16		    	var $wrap = $(this).wrap("<div class='material-input'></div>").parent();
17		    	$wrap.append("<span class='material-bar'></span>");
18
19		    	var tagName = $(this).prop("tagName").toLowerCase();
20		    	$wrap.addClass(tagName);
21		    	
22		    	//var placeholder = $(this).attr('placeholder');
23		    	//if(placeholder){
24		    		//$wrap.append("<label for='"+name+"'>"+placeholder+"</label>");
25		    		//$(this).removeAttr('placeholder');
26		    	//}
27
28		    	addFilled($(this));
29	    	}
30
31	    	if(isType($(this), 'radio') || isType($(this), 'checkbox')){
32	    		
33	    		var name = $(this).attr('name').replace('[]','');
34	    		var group_id = 'material-group-' + name;
35	    		var placeholder = $(this).attr('placeholder');
36	    		var item_id = name+ '-' + i;
37	    		var $label = $('<label for="'+item_id+'">'+placeholder+'</label>');
38	    		var $group_item = $('<div class="material-group-item"></div>');
39	    		$(this).attr('id', item_id);
40
41	    		if($("#"+group_id).length){
42	    			var $group = $('#'+group_id);
43	    			$group.append($(this));
44	    		}
45	    		else{
46	    			var $group = $(this).wrap("<div class='material-group' id='"+group_id+"'></div>").parent();
47	    		}
48
49	    		if(isType($(this), 'radio'))
50	    			var $radio = $('<div class="material-radio"></div>');
51	    		else
52	    			var $radio = $('<div class="material-checkbox"></div>');
53
54	    		$group_item.append($(this));
55	    		$group_item.append($label);
56	    		$group_item.append($radio);
57
58	    		$group.append($group_item);
59	    	}
60	    });
61
62	    this.find('input, textarea').on('blur', function(){
63		    if(isValidType($(this)))
64		    	addFilled($(this))
65	    });
66
67	    // Radio
68
69	    function isValidType($el){
70	    	var type = $el.attr('type');
71	    	return (type != 'hidden' && type != 'submit' && type != 'checkbox' && type != 'radio' && type != 'file' ? 1 : 0);
72	    }
73
74	    function isType($el, type){
75	    	var el_type = $el.attr('type');
76	    	return (el_type == type);
77	    }
78
79	    function addFilled($el){
80	    	if($el.val())
81	    		$el.addClass('filled');
82	    	else
83	    		$el.removeClass('filled');
84	    }
85
86	    // Selects
87	    this.find('select').each(function(i){
88	    	var placeholder = $(this).attr('placeholder');
89	    	var type = ($(this).attr('multiple') ? 'checkbox' : 'radio');
90	    	var name = id = $(this).attr('name');
91	    	var $wrap = $(this).wrap("<div class='material-select'></div>").parent();
92	    	if(type == 'checkbox'){
93	    		name += '[]';
94	    		var $bar = $('<span class="material-bar"></span>');
95	    		$wrap.append($bar).addClass('checkbox');
96	    	}
97	    	else{
98	    		var $title = $('<span class="material-title">'+placeholder+'</span>');
99	    		$wrap.prepend($title);
100	    	}
101
102	    	var $label = $('<label for="select-'+i+'"><span>'+placeholder+'</span><strong></strong></label>');
103	    	var $checkbox = $('<input type="checkbox" id="select-'+i+'">');
104
105	    	$wrap.prepend($checkbox);
106	    	$wrap.prepend($label);
107	    	
108	    	var $list = $('<ul class="'+type+'"></ul>');
109	    	$wrap.append($list);
110
111	    	var selected_length = 0;
112	    	var length = $(this).children('option').length;
113	    	var $selected;
114	    	$(this).children('option').each(function(j){
115	    		var title = $(this).text();
116	    		var value = $(this).val();
117	    		
118	    		var selected = $(this).hasAttr('selected');
119
120	    		var $list_item = $('<li></li>');
121	    		$list.append($list_item);
122
123	    		var $label = $('<label for="'+id+'-'+j+'">'+title+'</label>');
124	    		var $input = $('<input type="'+type+'" value="'+value+'" name="'+name+'" id="'+id+'-'+j+'">');
125	    		if(selected){
126	    			$selected = $input.prop('checked', true);
127	    			selected_length++;
128	    		}
129	    		
130	    		$list_item.append($input);
131	    		$list_item.append($label);
132	    	});
133	    	if($bar){
134	    		var percentage = selected_length / length * 100;
135	    		$bar.width(percentage + '%');
136	    	}
137	    	else{
138	    		if(selected_length){
139	    			$label.children('span').text($selected.next('label').text())
140	    			$wrap.addClass('filled');
141	    		}
142	    	}
143	    	$(this).remove();
144	    });
145
146		$(document).on('click', function(e) {
147		    if ( $(e.target).closest('.material-select').length === 0 ) {
148		        // cancel highlighting 
149		        $('.material-select > input').prop('checked', false);
150		    }
151		});
152
153		$('.material-select > input').on('change', function(){
154			var changed_id = $(this).attr('id');
155			$('.material-select > input').each(function(){
156				var this_id = $(this).attr('id');
157				if(changed_id != this_id)
158					$(this).prop('checked', false);
159			});
160		});
161
162		$('.material-select ul input').on('change', function(){
163			if($(this).closest('.material-select.checkbox').length){
164				var $ul = $(this).closest('ul')
165				var length = $ul.find('input').length;
166				var checked_length = $ul.find('input:checked').length;
167				var percentage = checked_length / length * 100;
168				$(this).closest('.material-select').find('.material-bar').width(percentage + '%');
169			}
170			else{
171				var $material_select = $(this).closest('.material-select')
172				var $label = $material_select.children('label').children('span');
173				var $next = $(this).next('label');
174				$label.text($next.text());
175				$material_select.children('input').prop('checked', false);
176				$material_select.addClass('filled');
177			}
178		});
179
180	};
181});
182
183
184
185
186//jQuery time
187var parent, ink, d, x, y;
188$(".manimate").click(function(e){
189	parent = $(this).parent();
190	//create .ink element if it doesn't exist
191	if(parent.find(".ink").length == 0)
192		parent.prepend("<span class='ink'></span>");
193		
194	ink = parent.find(".ink");
195	//incase of quick double clicks stop the previous animation
196	ink.removeClass("animate");
197	
198	//set size of .ink
199	if(!ink.height() && !ink.width())
200	{
201		//use parent's width or height whichever is larger for the diameter to make a circle which can cover the entire element.
202		d = Math.max(parent.outerWidth(), parent.outerHeight());
203		ink.css({height: d, width: d});
204	}
205	
206	//get click coordinates
207	//logic = click coordinates relative to page - parent's position relative to page - half of self height/width to make it controllable from the center;
208	x = e.pageX - parent.offset().left - ink.width()/2;
209	y = e.pageY - parent.offset().top - ink.height()/2;
210	
211	//set the position and add class .animate
212	ink.css({top: y+'px', left: x+'px'}).addClass("animate");
213})
214
215
216
217/*!
218 * Waves v0.2.1
219 * https://publicis-indonesia.github.io/Waves
220 *
221 * Copyright 2014 Publicis Metro Indonesia, PT. and other contributors
222 * Released under the BSD license
223 * https://github.com/publicis-indonesia/Waves/blob/master/LICENSE
224 */
225
226;(function(window) {
227    'use strict';
228
229    function Waves() {
230
231        var $$ = document.querySelectorAll.bind(document);
232
233        // Find exact position of element
234        function position(obj) {
235
236            var left = 0;
237            var top = 0;
238            
239            if (obj.offsetParent) {
240                do {
241                    left += obj.offsetLeft;
242                    top += obj.offsetTop;
243                } while (obj = obj.offsetParent);
244            }
245
246            return {
247                top: top, 
248                left: left
249            };
250        }
251
252        var Effect = {
253
254            // Trigger element action if they are waves-button
255            action: function(e) {
256
257                // catch window.event
258                e = e || window.event; 
259
260                var el = this;
261
262                // Disable action if right click triggered this event
263                if (e.which !== 1) {
264                    return false;
265                }
266
267                if (el.className.indexOf('waves-button') !== -1) {
268
269                    // Get the child
270                    var child = el.childNodes[1];
271                    var tag = child.tagName.toLowerCase();
272
273                    // Redirect page based on href attribute
274                    if (tag === 'a') {
275
276                        if (!child.href.length) {
277                            return false;
278                        }
279
280                        if (child.target === '_blank') {
281                            var win = window.open(child.href, '_blank');
282                            return win.focus();
283                        }
284
285                        return window.location.href = child.href;
286                    }
287
288                    // Click the element or submit the form if exist
289                    if (tag === 'button' || tag === 'input') {
290                        
291                        if (child.submit) {
292                            return child.submit();
293                        }
294
295                        return child.click();
296                    }
297                }
298
299            },
300
301            show: function(e) {
302
303                var el = this;
304
305                // Create ripple
306                var ripple = document.createElement('div');
307                ripple.className = ripple.className + 'waves-ripple';
308                el.appendChild(ripple);
309
310                // Get click coordinate and element witdh
311                var pos         = position(el);
312                var relativeY   = (e.pageY - pos.top);
313                var relativeX   = (e.pageX - pos.left);
314                var width       = el.clientWidth;
315
316                // Attach data to element
317                ripple.setAttribute('data-hold', Date.now());
318                ripple.setAttribute('data-x', relativeX);
319                ripple.setAttribute('data-y', relativeY);
320
321                // Start ripple
322                var positionStyle = 'top:'+relativeY+'px;left:'+relativeX+'px;';
323                var flowStyle = 'border-width:'+width+'px;margin-top:-'+width+'px;margin-left:-'+width+'px;opacity:1;';
324
325                ripple.className = ripple.className + ' waves-notransition';
326                ripple.setAttribute('style', positionStyle);
327                ripple.offsetHeight;
328                ripple.className = ripple.className.replace('waves-notransition', '');
329                ripple.setAttribute('style', positionStyle+flowStyle);
330
331            },
332
333            hide: function(e) {
334                
335                var el = this;
336                var width = el.clientWidth;
337                
338                // Get first ripple
339                var ripple = null;
340
341                for (var a = 0; a < el.children.length; a++) {
342                    if (el.children[a].className.indexOf('waves-ripple') !== -1) {
343                        ripple = el.children[a];
344                        continue;
345                    }
346                }
347
348                if (!ripple) {
349                    return false;
350                }
351
352                var relativeX   = ripple.getAttribute('data-x');
353                var relativeY   = ripple.getAttribute('data-y');
354
355                // Get delay beetween mousedown and mouse leave
356                var diff = Date.now() - Number(ripple.getAttribute('data-hold'));
357                var delay = 500 - diff;
358
359                if (delay < 0) {
360                    delay = 0;
361                }
362
363                // Fade out ripple after delay
364                setTimeout(function() {
365
366                    var style = 'top:'+relativeY+'px;left:'+relativeX+'px;border-width:'+width+'px;margin-top:-'+width+'px;margin-left:-'+width+'px;opacity:0;';
367
368                    ripple.setAttribute('style', style);
369
370                    setTimeout(function() {
371
372                        try {
373                            el.removeChild(ripple);
374                        } catch(e) {
375                            return false;
376                        }
377
378                        
379                    }, 300);
380
381                }, delay);
382
383            },
384        };
385
386        return {
387            displayEffect: function() {
388
389                Array.prototype.forEach.call($$('.waves-effect'), function(i) {
390
391                    if (window.Touch) {
392                        i.addEventListener('touchstart', Effect.show, false);
393                        i.addEventListener('touchend', Effect.hide, false);
394                        i.addEventListener('touchend', Effect.action, false);
395                    }
396
397                    i.addEventListener('mousedown', Effect.show, false);
398                    i.addEventListener('mouseup', Effect.hide, false);
399                    i.addEventListener('mouseleave', Effect.hide, false);
400                    i.addEventListener('mouseup', Effect.action, false);
401
402                });
403
404            }
405        }
406    }
407
408    window.Waves = Waves;
409
410})(window);

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.