PageSourceSearch

http://alltex-expo.com.ua/wp-content/themes/javo-directory/assets/js/jquery.favorite.js?ver=0.1

js alltex-expo.com.ua collected 2026-10-03 23:58:04 UTC 2,846 bytes, 127 lines download raw bytes

1;( function($){
2
3	var javo_favorite_func = {
4
5		init: function( data, el, callback )
6		{
7			this.DEFAULT		= {
8				url				: null
9				, before		: null
10				, user			: 0
11				, str_nologin	: "Please login"
12				, str_save		: "Save"
13				, str_unsave	: "UnSave"
14				, str_error		: "Server Error!"
15				, str_fail		: "favorite regist fail."
16				, mypage		: false
17			};
18			this.attr			= $.extend( true, {}, this.DEFAULT, data );
19			this.callback		= callback;
20			this.el				= el;
21
22			// Events
23			$( document )		.on( 'click', el, this.favorite );
24		}
25		, action: function( callback )
26		{
27			if( typeof callback == 'function' )
28			{
29				if( false == callback() )
30				{
31					return false;
32				}
33			}
34			return;
35		}
36
37		, user_check: function( user_id )
38		{
39			if( parseInt( user_id ) > 0 )
40			{
41				return true;
42			}
43			$.javo_msg({ content: attr.str_nologin, delay:5000 });
44			return false;
45		}
46
47		, button_block: function( el, onoff )
48		{
49			if( onoff )
50			{
51				el.addClass( 'disabled' ).prop( 'disabled', true );
52			}else{
53				el.removeClass( 'disabled' ).prop( 'disabled', false );
54			}
55		}
56
57		, favorite: function( e ){
58			e.preventDefault();
59
60			var obj		= javo_favorite_func;
61			var $this	= $( this );
62			var is_save	= $this.hasClass( 'saved' ) ? null : true;
63			var attr	= obj.attr;
64
65			if( false == obj.action( attr.before ) ){ return false; };
66
67			current_user = obj.user_check( attr.user );
68
69			if( ! current_user || $( this ).hasClass( 'disabled' ) ){ return false; }
70			obj.button_block( $( this ), true );
71
72			$.post(
73				attr.url
74				, { post_id: $( this ).data('post-id'), reg: is_save, action: 'favorite' }
75				, function( response )
76				{
77					console.log( response );
78					if( response.return == 'success' )
79					{
80						if( $this.hasClass("saved")){
81
82							$this.removeClass("saved");
83
84							if( ! $this.data('no-swap') ){
85								$this.text(attr.str_unsave);
86							}
87							$.javo_msg({ content: attr.str_unsave, delay:800, close:false});
88
89
90						}else{
91
92							$this.addClass("saved");
93
94							if( ! $this.data('no-swap') ){
95								$this.text(attr.str_save);
96							}
97							$.javo_msg({ content: attr.str_save, delay:800, close:false });
98
99						}
100						if( typeof obj.callback == 'function' ){
101							obj.callback.call( $this );
102						}
103					}else{
104						$.javo_msg({ content: attr.str_fail, delay:5000 });
105					}
106				}
107				, 'json'
108			)
109			.fail( function( response )
110			{
111				console.log( "Favroite Error: " + response.responseText );
112				$.javo_msg({ content: attr.str_error, delay:5000 });
113			})
114			.always( function()
115			{
116				obj.button_block( $this, false );
117			});
118
119		}
120	};
121
122	jQuery.fn.javo_favorite = function(o, p)
123	{
124		var el = this.selector ;
125		javo_favorite_func.init( o, el, p);
126	}
127})(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.