Explorar o código

#1105 Create one function to process HTML after it's shown using JS

Alex Trofimov %!s(int64=8) %!d(string=hai) anos
pai
achega
03b2cba496

+ 6 - 6
inc/js/classes/BxDolCmts.js

@@ -526,10 +526,10 @@ BxDolCmts.prototype._getCmt = function (e, iCmtId)
 
             //--- Some number of comments already loaded ---//
             if($(sListId + ' > li.cmt').length)
-                $(sListId + ' > li.cmt:last').after($(oData.content).hide()).next('li.cmt:hidden').bxTime().bx_anim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
+                $(sListId + ' > li.cmt:last').after($(oData.content).hide()).next('li.cmt:hidden').bxProcessHtml().bx_anim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
             //-- There is no comments at all ---//
             else
-            	$(sListId).hide().html(oData.content).bxTime().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+            	$(sListId).hide().html(oData.content).bxProcessHtml().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
         },
         'json'
     );
@@ -591,19 +591,19 @@ BxDolCmts.prototype._getForm = function (e, iCmtParentId, onLoad)
 
 BxDolCmts.prototype._cmtsAppend = function(sIdTo, sContent)
 {
-	$(sIdTo).append($(sContent).hide()).children(':hidden').bxTime().bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
+	$(sIdTo).append($(sContent).hide()).children(':hidden').bxProcessHtml().bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
 };
 
 BxDolCmts.prototype._cmtsPrepend = function(sIdTo, sContent)
 {
-	$(sIdTo).prepend($(sContent).hide()).children(':hidden').bxTime().bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
+	$(sIdTo).prepend($(sContent).hide()).children(':hidden').bxProcessHtml().bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
 };
 
 BxDolCmts.prototype._cmtsReplace = function(oReplace, sContent, onLoad)
 {
 	var $this = this;
 	$(oReplace).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
-		$(this).after($(sContent).hide()).nextAll(':hidden').bxTime().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+		$(this).after($(sContent).hide()).nextAll(':hidden').bxProcessHtml().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
 			$this._cmtsBlink($(this));
 
 			if(typeof onLoad == 'function')
@@ -616,7 +616,7 @@ BxDolCmts.prototype._cmtsReplaceContent = function(oParent, sContent, onLoad)
 {
 	var $this = this;
 	$(oParent).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
-		$(this).html(sContent).bxTime().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+		$(this).html(sContent).bxProcessHtml().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
 			$this._cmtsBlink($(this));
 
 			if(typeof onLoad == 'function')

+ 2 - 2
inc/js/classes/BxDolGrid.js

@@ -19,7 +19,7 @@ function BxDolGrid (sObject, oOptions) {
     this._sSearchInputText = undefined == oOptions.text_search_input ? '' : oOptions.text_search_input;
     this._oPopupOptions = $.extend({
     	onBeforeShow: function(oElement) {
-    		jQuery(oElement).bxTime();
+    		jQuery(oElement).bxProcessHtml();
     	}
     }, oOptions.popup_options);
     this._oQueryAppend = oOptions.query_append;
@@ -435,7 +435,7 @@ BxDolGrid.prototype._onDataReloaded = function (isSkipSearchInput) {
 
     jQuery('#' + this._sIdTable + ' tbody tr:odd').addClass('bx-def-color-bg-hl');
     
-    jQuery('#' + this._sIdTable).bxTime();
+    jQuery('#' + this._sIdTable).bxProcessHtml();
 
     if (this._oOptions.sorting)
         this.orderable();

+ 37 - 14
inc/js/functions.js

@@ -32,7 +32,7 @@ function processJsonData(oData) {
 	    		oPopup = $(oData.popup);
 
 	    	$('#' + oPopup.attr('id')).remove();
-	        oPopup.hide().prependTo('body').bxTime().dolPopup(oOptions);
+	        oPopup.hide().prependTo('body').bxProcessHtml().dolPopup(oOptions);
 	    }
 
 	    if (oData && oData.eval != undefined)
@@ -84,11 +84,7 @@ function getHtmlData( elem, url, callback, method , confirmation)
 		if (undefined != method && (method == 'post' || method == 'POST')) {
 		    $.post(url, function(data) {
 		        $block.html(data);
-		        $block.css('position', blockPos).bxTime();
-		        if ($.isFunction($.fn.addWebForms))
-		            $block.addWebForms();
-
-		        bx_activate_anim_icons();
+		        $block.css('position', blockPos).bxProcessHtml();
 
 		        if (typeof callback == 'function')
 		            callback.apply($block);
@@ -96,11 +92,7 @@ function getHtmlData( elem, url, callback, method , confirmation)
 		} 
 		else {
 		    $block.load(url + '&_r=' + Math.random(), function() {
-		        $(this).css('position', blockPos).bxTime();
-		        if ($.isFunction($.fn.addWebForms))
-		            $(this).addWebForms();
-
-		        bx_activate_anim_icons();
+		        $(this).css('position', blockPos).bxProcessHtml();
 
 		        if (typeof callback == 'function')
 		            callback.apply(this);
@@ -453,7 +445,7 @@ function bx_menu_slide (sObject, oElement, sPosition, oOptions, oVars) {
         var fOnLoad = function() {
         	bx_loading_content(oLoading, false);
 
-        	$(sIdSel).bxTime().show();
+        	$(sIdSel).bxProcessHtml().show();
         };
 
         $(sIdSel).find(oOptions.container).load(bx_append_url_params('menu.php', $.extend({o:sObject}, oVars)), function () {
@@ -702,10 +694,41 @@ function bx_time(sLang, isAutoupdate, sRootSel) {
 }
 
 (function($) {
+
     $.fn.bxTime = function() {
         bx_time(undefined, undefined, this);
         return this;
-    }; 
+    };
+
+    /**
+     * process HTML which was added dynamicly on the page
+     */ 
+    $.fn.bxProcessHtml = function (oCallback) {
+        var eElement = $(this);
+        if ('undefined' !== typeof(eElement)) {
+            // process js time
+            eElement.bxTime();
+
+            // process web forms
+            if ($.isFunction($.fn.addWebForms))
+	            eElement.addWebForms();
+            
+            // process animating icons
+        	bx_activate_anim_icons();
+        }
+        if ('undefined' !== typeof(oCallback)) {
+            oCallback(eElement);
+        }
+
+        if (typeof glOnProcessHtml !== 'undefined' && glOnProcessHtml instanceof Array) {
+            for (var i = 0; i < glOnProcessHtml.length; i++)
+                if (typeof glOnProcessHtml[i] === "function")
+                    glOnProcessHtml[i](this);
+        }
+        
+        return this;
+    }
+
 } (jQuery));
 
 
@@ -816,7 +839,7 @@ function bx_search (n, sFormSel, sResultsContSel, sLoadingContSel, bSortResults)
                 data += e.outerHTML;
             });
         } 
-        $(sResultsContSel).html(data).bxTime();
+        $(sResultsContSel).html(data).bxProcessHtml();
     });
 
     return false;

+ 1 - 1
inc/js/jquery.dolPopup.js

@@ -471,7 +471,7 @@
                 var fOnLoad = function() {
                 	bx_loading_content(oLoading, false);
 
-                	$('#' + sPopupId + ' ' + options.container).bxTime().show();
+                	$('#' + sPopupId + ' ' + options.container).bxProcessHtml().show();
 
 					$('#' + sPopupId)._dolPopupSetPosition({
 						pointer: oPointerOptions

+ 1 - 1
modules/boonex/notifications/js/view.js

@@ -44,7 +44,7 @@ BxNtfsView.prototype._getPosts = function(oElement) {
         		$this.loadingInBlock(oElement, false);
 
     			$('#' + $this._aHtmlIds['events']).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-	                $(this).html(sEvents).show().bxTime();
+	                $(this).html(sEvents).show().bxProcessHtml();
 	            });
         	}
         },

+ 1 - 1
modules/boonex/timeline/js/post.js

@@ -307,7 +307,7 @@ BxTimelinePost.prototype._onGetPost = function(oData) {
 		if(oEmpty.is(':visible'))
 			oEmpty.hide();
 
-		var oContent = $(oData.item).bxTime();
+		var oContent = $(oData.item).bxProcessHtml();
 		switch(oData.view) {
 			case 'timeline':
 				var oTimeline = $('#' + $this._aHtmlIds['main_timeline']);

+ 6 - 6
modules/boonex/timeline/js/view.js

@@ -191,7 +191,7 @@ BxTimelineView.prototype.changePage = function(oLink, iStart, iPerPage) {
     		case 'timeline':
     			oView = $this.oViewTimeline;
     			oView.find('.' + $this.sClassItems).append($(sItems).hide()).find('.' + $this.sClassItem + ':hidden').bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-					$(this).bxTime();
+					$(this).bxProcessHtml();
 
 					$this.initFlickity();
 
@@ -202,7 +202,7 @@ BxTimelineView.prototype.changePage = function(oLink, iStart, iPerPage) {
 
     		case 'outline':
     			oView = $this.oViewOutline;
-    			$this.appendMasonry($(sItems).bxTime(), function() {
+    			$this.appendMasonry($(sItems).bxProcessHtml(), function() {
     				$this.initFlickity();
 
     				//--- Init Video Layout
@@ -308,7 +308,7 @@ BxTimelineView.prototype.commentItem = function(oLink, sSystem, iId) {
         	if(!oData.content)
         		return;
 
-        	oComments.html($(oData.content).hide()).children(':hidden').bxTime().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+        	oComments.html($(oData.content).hide()).children(':hidden').bxProcessHtml().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
         },
         'json'
     );
@@ -770,7 +770,7 @@ BxTimelineView.prototype._onGetPosts = function(oData) {
 		switch(oData.view) {
 			case 'timeline':
 				oView.find('.' + this.sClassItems).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
-					$(this).html(sItems).show().bxTime();
+					$(this).html(sItems).show().bxProcessHtml();
 
 					$this.blink($(this));
 					$this.initFlickity();
@@ -781,7 +781,7 @@ BxTimelineView.prototype._onGetPosts = function(oData) {
 
 			case 'outline':
 				oView.find('.' + this.sClassItems).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
-			        $(this).html(sItems).show().bxTime();
+			        $(this).html(sItems).show().bxProcessHtml();
 
 			        if($this.isMasonry())
 			        	$this.destroyMasonry();
@@ -804,7 +804,7 @@ BxTimelineView.prototype._onGetPost = function(oData) {
 	if(!$.trim(oData.item).length) 
 		return;
 
-	var oItem = $(oData.item).bxTime();
+	var oItem = $(oData.item).bxProcessHtml();
 	var oView = $('#' + this._aHtmlIds['main_' + oData.view]);
 
 	switch(oData.view) {

+ 2 - 2
studio/js/dashboard.js

@@ -15,7 +15,7 @@ function BxDolStudioDashboard(oOptions) {
 
     var $this = this;
     $(document).ready(function() {
-    	$('.bx-dbd-block-content').bxTime();
+    	$('.bx-dbd-block-content').bxProcessHtml();
     });
 }
 
@@ -192,7 +192,7 @@ BxDolStudioDashboard.prototype.hostTools = function(sAction) {
 			    return;
 
 			$('#' + sDivId).hide().html(sData).bx_anim('show', 'fade', 'slow', function() {
-				$(this).bxTime();
+				$(this).bxProcessHtml();
 			});
 		},
 		'html'

+ 1 - 1
studio/js/store.js

@@ -235,7 +235,7 @@ BxDolStudioStore.prototype.info = function(sModuleName, oLink) {
 			var sId = $this.sIdPopupProduct;
 			if(oData.code == 0 && oData.popup.length > 0) {
 		        $('#' + sId).remove();
-				$(oData.popup).appendTo('body').bxTime();
+				$(oData.popup).appendTo('body').bxProcessHtml();
 				$('#' + sId).dolPopup({
 					onShow: function() {
 						$this.initScreenshots(oData.screenshots);