%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home1/dimen328/libertysa.com.br/admin/modules/blog/app/web/js/
Upload File :
Create Path :
Current File : //home1/dimen328/libertysa.com.br/admin/modules/blog/app/web/js/pjLoad.js

(function (window, undefined){
	"use strict";
	var document = window.document,
		validate = (pjQ.$.fn.validate !== undefined),
		dialog = (pjQ.$.fn.dialog !== undefined),
		datepicker = (pjQ.$.fn.datepicker !== undefined);
	
	function StivaBlog(opts) {
		if (!(this instanceof StivaBlog)) {
			return new StivaBlog(opts);
		}
		this.reset.call(this);
		this.init.call(this, opts);
		return this;
	}
	
	StivaBlog.prototype = {
		reset: function () {
			this.opts = null;
			this.$container = null;
			this.container = null;
			this.first_click = 0;
			this.menu_status = 0;
			this.search_status = 0;
			
			return this;
		},
		bingRating: function(){
			var self = this;
			if(pjQ.$('.post-rating').length > 0){
				pjQ.$(".post-rating").stars({
				    inputType: "select",
				    oneVoteOnly: true,
				    callback: function(ui, type, value) {
				    	var frm = ui.$form,
				    		rate = value,
				    		post_id = frm.find("input[name='post_id']").val(),
				    		$star_message = pjQ.$('#rating_message_' + post_id);
				    	pjQ.$.ajax({
							type: "POST",
							dataType: "json",
							data: {rate: rate, id: post_id},
							url: self.opts.folder + 'index.php?controller=pjLoad&action=pjActionRating',
							success: function (result) {
								switch (result.code) {
									case 101:
										$star_message.html(self.opts.already_voted);
										break;
									case 102:
										$star_message.html(self.opts.thank_vote);
										break;
								}
							}
						});
				    }
				});
			}
		},
		bindBlog: function(){
			var self = this;
			pjQ.$(".stb-blog-box").hover(
				function () {
					pjQ.$(this).addClass("stb-blog-hover");
				}, 
				function () {
					pjQ.$(this).removeClass("stb-blog-hover");
				}
			);
			
		},
		init: function (opts) {
			var self = this,
				$frmPostComment = pjQ.$('#frmPostComment'),
				$dialogSend = pjQ.$('#stb_send_dialog');
			this.opts = opts;
			this.container = document.getElementById("stb_container");
			this.$container = pjQ.$(this.container);
			
			self.bingRating();
			if(pjQ.$('#stb_blog_list').length > 0){
				self.bindBlog();
			}
			var position = pjQ.$('.stb-search-box').position();
			
			if(position.top > 0)
			{
				pjQ.$('#stb_menu_container').addClass('stb-menu-hide');
			}
			
			if(pjQ.$('.stb-related-container').length > 0){
				self.bindBlog();
			}
			if($frmPostComment.length > 0){
				if (validate) {
					pjQ.$.validator.addMethod('checkwords', function(value, element) {
						var banned_word_str = self.opts.banned_words;
						if(banned_word_str != ""){
					    	banned_word_str = banned_word_str.replace(/\s+/g, '');
					    	banned_word_str = banned_word_str.replace(new RegExp(",","g"),"|");
					    	return !new RegExp(banned_word_str).test(value);
				    	}else{
				    		return true;
				    	}
					});
					pjQ.$.validator.addMethod('checklink', function(value, element) {
						var valid = true,
							reg = /(\b(?:(https?|ftp):\/\/)?((?:www\d{0,3}\.)?([a-z0-9.-]+\.(?:[a-z]{2,4}|museum|travel)(?:\/[^\/\s]+)*))\b)/;
						if(self.opts.reject_links == 'Yes'){
							if(value != "" && value.match(reg) != null){
						    	valid = false;
						    }
						}
						return valid;
					});
					$frmPostComment.validate({
						rules: {
							"name": {	required: true,
										checklink: true},
							"email": {	required: true,
										email: true},
							"comment": {required: true,
										checkwords: true,
										checklink: true},
							"captcha":{	required: true,
										remote: self.opts.folder + "index.php?controller=pjFront&action=pjActionCheckCaptcha"}
						},
						messages: {
							"name": {required: self.opts.required_field,
								     checklink: self.opts.reject_msg},
							"email": {	required: self.opts.required_field,
										email: self.opts.invalid_email},
							"comment": {required: self.opts.required_field,
										checkwords: self.opts.banned_msg,
										checklink: self.opts.reject_msg},
							"captcha": {required: self.opts.required_field,
										remote: self.opts.captcha_incorrect}
						},
						errorPlacement: function (error, element) {
							if (element.hasClass('stb-captcha')) {
								error.insertAfter(element.parent());
							}else{
								error.insertAfter(element);
							}
						},
						onkeyup: false,
						errorClass: "stb-form-error",
						wrapper: "em",
						ignore: ""
					});
				}
				if(self.opts.show_message == true){
					pjQ.$('html,body').animate({
						scrollTop: pjQ.$("#stb_comment_form").offset().top},
			        'slow');
				}
			}
			this.$container.on('click', '.stb-load-more', function(e){
				if (e && e.preventDefault) {
					e.preventDefault();
				}
				var $this = pjQ.$(this),
					page = $this.attr('rel'),
					total_page = $this.attr('rev'),
					$frm = $this.next("form");
				
				pjQ.$.ajax({
					type: "POST",
					data: $frm.serialize(),
					dataType: "html",
					url: self.opts.folder + "index.php?controller=pjLoad&action=pjActionLoadMore" + '&pjPage=' + page,
					success: function (res) {
						pjQ.$('#stb_blog_list').append(res);
						self.bingRating();
						self.bindBlog();
						$this.attr('rel', parseInt(page) + 1);
						if(page == total_page){
							$this.css('display', 'none');
						}
					}
				});
			}).on('click', '.stb-send-to', function(e){
				var $send_form = pjQ.$('#stb_send_form');
				if($send_form.is(':visible')){
					$send_form.css('display', 'none');
				}else{
					$send_form.css('display', 'block');
				}
				pjQ.$('#stb_send_message').css('display', 'none');
			}).on('click', '.stb-cancel-button', function(e){
				pjQ.$('#stb_send_form').css('display', 'none');
				pjQ.$('#stb_send_message').css('display', 'none');
			}).on('click', '.stb-send-button', function(e){
				var $frmSendToFriend = pjQ.$('#frmSendToFriend'),
					$this = pjQ.$(this);
				$frmSendToFriend.validate({
					rules: {
						"subject": {required: true},
						"send_to": {required: true,
									email: true},
						"message": {required: true},
						"captcha": {required: true,
									remote: self.opts.folder + "index.php?controller=pjFront&action=pjActionCheckSendCaptcha"}
					},
					messages: {
						"subject": {required: self.opts.required_field},
						"send_to": {required: self.opts.required_field,
									email: self.opts.invalid_email},
						"message": {required: self.opts.required_field},
						"captcha": {required: self.opts.required_field,
									remote: self.opts.captcha_incorrect}
					},
					errorPlacement: function (error, element) {
						if (element.hasClass('stb-captcha')) {
							error.insertAfter(element.parent());
						}else{
							error.insertAfter(element);
						}
					},
					onkeyup: false,
					errorClass: "stb-form-error",
					wrapper: "em",
					ignore: ""
				});
				
				if($frmSendToFriend.valid()){
					var $send_message = pjQ.$('#stb_send_message');
					$this.disabled = true;
					$send_message.html(self.opts.send_msg);
					$send_message.css('display', 'block');
					pjQ.$.ajax({
						type: "POST",
						dataType: "json",
						data: $frmSendToFriend.serialize(),
						url: self.opts.folder + 'index.php?controller=pjLoad&action=pjActionSend',
						success: function (result) {
							$send_message.html(self.opts.send_ok);
						}
					});
				}
				
			}).on('click', '#stb_home_icon', function(e){
				if(self.opts.show_category == 'Yes'){
					var $menu_container = pjQ.$('#stb_menu_container'),
						$search_container = pjQ.$('#stb_search_container'),
						$white_line = pjQ.$('#stb_white_line');
					if($menu_container.css('position') == 'absolute'){
						if(self.menu_status == 1){
							$menu_container.hide('slide');
							self.menu_status = 0;
							if(pjQ.$('.stb-menu-item').length > 0){
								pjQ.$('.stb-menu-item').removeClass('stb-menu-focus');
							}
						}else{
							$menu_container.show('slide');
							self.menu_status = 1;
							if($search_container.length > 0){
								$search_container.css('display', 'none');
								$white_line.css('display', 'block');
							}
							if(pjQ.$('.stb-menu-item').length > 0){
								pjQ.$('.stb-menu-item').removeClass('stb-menu-focus');
								pjQ.$(this).addClass('stb-menu-focus');
							}
							self.search_status = 0;
						}
					}
				}
			}).on('click', '#stb_search_icon', function(e){
				var $search_container = pjQ.$('#stb_search_container'),
					$white_line = pjQ.$('#stb_white_line'),
					$menu_container = pjQ.$('#stb_menu_container');
				if(self.search_status == 0){
					$search_container.css('display', 'block');
					$white_line.css('display', 'none');
					pjQ.$(this).addClass('stb-menu-focus');
					$menu_container.hide('slide');
					
					if(pjQ.$('.stb-menu-item').length > 0){
						pjQ.$('.stb-menu-item').removeClass('stb-menu-focus');
						pjQ.$(this).addClass('stb-menu-focus');
					}
					
					self.menu_status = 0;
					self.search_status = 1;
				}else{
					$search_container.css('display', 'none');
					$white_line.css('display', 'block');
					self.search_status = 0;
					if(pjQ.$('.stb-menu-item').length > 0){
						pjQ.$('.stb-menu-item').removeClass('stb-menu-focus');
					}
				}
			}).on('focus', '#stb_search_keyword', function(e){
				pjQ.$(this).parent().parent().addClass('stb-search-box-focus');
			}).on('blur', '#stb_search_keyword', function(e){
				var $this = pjQ.$(this);
				if($this.val() == ''){
					$this.parent().parent().removeClass('stb-search-box-focus');
				}
			}).on('mouseenter', '.stb-blog-row', function(e){
				var $this = pjQ.$(this),
					id = pjQ.$(this).attr('lang'),
					$overlay = pjQ.$('#stb_blog_overlay_' + id),
					$reading = pjQ.$('#stb_blog_reading_' + id),
					height = parseInt($overlay.height() / 2) - 16;
				$overlay.css('display', 'block');
				$reading.css("margin-top", height + "px");
			}).on('mouseleave', '.stb-blog-row', function(e){
				var $this = pjQ.$(this),
					id = pjQ.$(this).attr('lang'),
					$overlay = pjQ.$('#stb_blog_overlay_' + id);
				$overlay.css('display', 'none');	
			}).on('mouseenter', '.stb-image-container', function(e){
				var $this = pjQ.$(this),
					id = pjQ.$(this).attr('lang'),
					$overlay = pjQ.$('#stb_blog_overlay_' + id);
				$overlay.css('display', 'block');	
			}).on('mouseleave', '.stb-image-container', function(e){
				var $this = pjQ.$(this),
					id = pjQ.$(this).attr('lang'),
					$overlay = pjQ.$('#stb_blog_overlay_' + id);
				$overlay.css('display', 'none');	
			}).on('click', '.stb-scrollup', function(e){
				pjQ.$("html, body").animate({ scrollTop: 0 }, "slow");
				return false;	
			});
		}
	};
	
	// expose
	window.StivaBlog = StivaBlog;
})(window);

Zerion Mini Shell 1.0