GET How to easily and quickly put your preloader on a standard Bitrix AJAX? / Sudo Null IT News FREE

Introduction

I confabulate Habr for a years, but decided on the article only now. And even so, this is not an article at entirely, but sooner - a note on how to easy and without strenuous, without editing the kernel and troubles with the Ajax itself, supplant and replace the standard despicable bitrix preloader window with your own HTML / CSS code. Let's get started?

Description of the problem

Developers on 1C-Bitrix should know about this problem, and for all the uninitiated - I'll excuse. This CMS uses its custom jquery and Ajax in standard templates and components. There is documentation, merely is there anyone who wants to study it to Doctor of Osteopathy approximately basic things? ..
In rationale, if you do non touch anything in standard templates, the "native" bitrix ajax does not work on badly. Merely if you try to seriously locating something, or even pull your layout together with your native ajax, then the dances with a tambourine begin, and such an elementary thing as replacing the default meager preloader turns into tedious googling and studying the cypher in the CMS core.

Bitrix TP's position on this content is generally amazing:

Now, unfortunately, there is no common way to change the standard preloader

Technical support subject matter screen

All the nearly naive and green will say "unendurable?" comfortably, ok ... "and they will go spell their ajax requests. And we will take IT and get it on!

Implementation

The butt line is simple - a standardised Ajax has two functions BX.showWait and BX.closeWait that are responsible for actions on the page spell waiting for a reply from the ajax. We practice them to onus our default option instead of the nonpayment preloader.

Freshman, we volition find the preloader itself. For example, I liked it in pure HTML / CSS in the style of Windows 8. So, open footnote.php of our template and enter our code in fore of the tag:

                      

I won't insert a long CSS canvass (at the end there will be completely sources). Next, slip in a book with a call to functions that incumbrance our preloader instead of the standard one:

          var lastWait = []; 	/* non-xhr loadings */ 	BX.showWait = work (node, MSG) 	{ 		node = BX(knob) || document.body || document.documentElement; 		MSG = msg || BX.message('JS_CORE_LOADING'); 		var container_id = lymph node.Idaho || Math.random(); 		var obMsg = node.bxmsg = papers.body.appendChild(BX.produce('DIV', { 			props: { 				Idaho: 'wait_' + container_id, 				className: 'bx-substance-waitwindow' 			}, 			text: msg 		})); 		setTimeout(BX.delegate(_adjustWait, node), 10); 		$('#win8_wrapper').show up(); 		lastWait[lastWait.length] = obMsg; 		return obMsg; 	}; 	BX.closeWait = function (knob, obMsg) 	{ 		$('#win8_wrapper').hide(); 		if (node && !obMsg) 			obMsg = node.bxmsg; 		if (node &ere;& !obMsg && BX.hasClass(node, 'bx-nub-waitwindow')) 			obMsg = node; 		if (node && !obMsg) 			obMsg = BX('wait_' + lymph node.id); 		if (!obMsg) 			obMsg = lastWait.bolt down(); 		if (obMsg && obMsg.parentNode) 		{ 			for (var i = 0, len = lastWait.distance; i < len; i++) 			{ 				if (obMsg == lastWait[i]) 				{ 					lastWait = BX.util.deleteFromArray(lastWait, i); 					break; 				} 			} 			obMsg.parentNode.removeChild(obMsg); 			if (node) 				node.bxmsg = null; 			BX.cleanNode(obMsg, true); 		} 	}; 	function _adjustWait() 	{ 		if (!this.bxmsg) 			return; 		var arContainerPos = BX.pos(this), 			div_top = arContainerPos.top; 		if (div_top < BX.GetDocElement().scrollTop) 			div_top = BX.GetDocElement().scrollTop + 5; 		this.bxmsg.style.transcend = (div_top + 5) + 'px'; 		if (this == BX.GetDocElement()) 		{ 			this.bxmsg.style.right = '5px'; 		} 		other 		{ 			this.bxmsg.style.left = (arContainerPos.compensate - this.bxmsg.offsetWidth - 5) + 'px'; 		} 	}                  

Cured, do not forget to add together the CSS styles of your preloader in the standard way - by copying to template_styles.css or copulative to coping.php as a discriminate filing cabinet.

We try to click something connected the locate. Voila - the preloader has been replaced. For a to a greater extent "correct" method acting, I would advise you to move the footer association to a separate enclosed area.

Sources along GitHub

Give thanks you totally for your attention!

DOWNLOAD HERE

GET How to easily and quickly put your preloader on a standard Bitrix AJAX? / Sudo Null IT News FREE

Posted by: burrowswituabled.blogspot.com

0 Response to "GET How to easily and quickly put your preloader on a standard Bitrix AJAX? / Sudo Null IT News FREE"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel