AntonLV 9 лет назад
Родитель
Сommit
e6618727b8

+ 12 - 12
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -70,7 +70,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $mixedAllowed = $this->isAllowedPost(true);
         if($mixedAllowed !== true) {
-            echoJson(array('msg' => strip_tags($mixedAllowed)));
+            echoJson(array('message' => strip_tags($mixedAllowed)));
             return;
         }
 
@@ -87,7 +87,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $mixedAllowed = $this->{'isAllowed' . ((int)$aEvent['pinned'] == 0 ? 'Pin' : 'Unpin')}($aEvent, true);
         if($mixedAllowed !== true)
-            return echoJson(array('code' => 1, 'msg' => strip_tags($mixedAllowed)));
+            return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
 
 		$aEvent['pinned'] = (int)$aEvent['pinned'] == 0 ? time() : 0;
         if(!$this->_oDb->updateEvent(array('pinned' => $aEvent['pinned']), array('id' => $iId)))
@@ -108,7 +108,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $mixedAllowed = $this->isAllowedDelete($aEvent, true);
         if($mixedAllowed !== true)
-            return echoJson(array('code' => 1, 'msg' => strip_tags($mixedAllowed)));
+            return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
 
         if(!$this->deleteEvent($aEvent))
             return echoJson(array('code' => 2));
@@ -133,19 +133,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
         if(empty($aReposted) || !is_array($aReposted)) {
-            echoJson(array('code' => 1, 'msg' => _t('_bx_timeline_txt_err_cannot_repost')));
+            echoJson(array('code' => 1, 'message' => _t('_bx_timeline_txt_err_cannot_repost')));
             return;
         }
 
         $mixedAllowed = $this->isAllowedRepost($aReposted, true);
         if($mixedAllowed !== true) {
-            echoJson(array('code' => 2, 'msg' => strip_tags($mixedAllowed)));
+            echoJson(array('code' => 2, 'message' => strip_tags($mixedAllowed)));
             return;
         }
 
         $bReposted = $this->_oDb->isReposted($aReposted['id'], $iOwnerId, $iAuthorId);
 		if($bReposted) {
-        	echoJson(array('code' => 3, 'msg' => _t('_bx_timeline_txt_err_already_reposted')));
+        	echoJson(array('code' => 3, 'message' => _t('_bx_timeline_txt_err_already_reposted')));
             return;
         }
 
@@ -161,7 +161,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         ));
 
         if(empty($iId)) {
-	        echoJson(array('code' => 4, 'msg' => _t('_bx_timeline_txt_err_cannot_repost')));        
+	        echoJson(array('code' => 4, 'message' => _t('_bx_timeline_txt_err_cannot_repost')));        
 	        return;
         }
 
@@ -172,7 +172,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
 		echoJson(array(
 			'code' => 0, 
-			'msg' => _t('_bx_timeline_txt_msg_success_repost'), 
+			'message' => _t('_bx_timeline_txt_msg_success_repost'), 
 			'count' => $aReposted['reposts'], 
 			'counter' => $sCounter,
 			'disabled' => !$bReposted
@@ -270,7 +270,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if($this->_oDb->deleteUnusedLinks($iUserId, $iLinkId))
             $aResult = array('code' => 0);
         else
-            $aResult = array('code' => 1, 'msg' => _t('_bx_timeline_form_post_input_link_err_delete'));
+            $aResult = array('code' => 1, 'message' => _t('_bx_timeline_form_post_input_link_err_delete'));
 
         echoJson($aResult);
     }
@@ -1294,7 +1294,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 return array('item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId));
             }
 
-            return array('msg' => _t('_bx_timeline_txt_err_cannot_perform_action'));
+            return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
         }
 
         return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
@@ -1344,7 +1344,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             $bVideoIds = !empty($aVideoIds) && is_array($aVideoIds);
 
             if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds)
-            	return array('msg' => _t('_bx_timeline_txt_err_empty_post'));
+            	return array('message' => _t('_bx_timeline_txt_err_empty_post'));
 
             $sTitle = $bText ? $this->_oConfig->getTitle($sText) : $this->_oTemplate->getItemIcon($bText, $bLinkIds, $bPhotoIds, $bVideoIds);
             $sDescription = _t('_bx_timeline_txt_user_added_sample', $sUserName, _t('_bx_timeline_txt_sample_with_article'));
@@ -1381,7 +1381,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 return array('id' => $iId);
             }
 
-            return array('msg' => _t('_bx_timeline_txt_err_cannot_perform_action'));
+            return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
         }
 
         return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);

+ 0 - 37
modules/boonex/timeline/js/main.js

@@ -141,43 +141,6 @@ BxTimelineMain.prototype.initFlickity = function() {
 	});
 };
 
-BxTimelineMain.prototype.processResult = function(oData) {
-	var $this = this;
-
-	if(oData && oData.msg != undefined && oData.msg.length != 0)
-    	alert(oData.msg);
-
-	if(oData && oData.message != undefined && oData.message.length != 0)
-    	alert(oData.message);
-
-    if(oData && oData.reload != undefined && parseInt(oData.reload) == 1)
-    	document.location = document.location;
-
-    if(oData && oData.popup != undefined) {
-    	var oPopup = null;
-    	var oOptions = {
-            fog: {
-				color: '#fff',
-				opacity: .7
-            },
-            closeOnOuterClick: false
-        };
-
-    	if(typeof(oData.popup) == 'object') {
-    		oOptions = $.extend({}, oOptions, oData.popup.options);
-    		oPopup = $(oData.popup.html);
-    	}
-    	else 
-    		oPopup = $(oData.popup);
-
-    	$('#' + oPopup.attr('id')).remove();
-        oPopup.hide().prependTo('body').bxTime().dolPopup(oOptions);
-    }
-
-    if (oData && oData.eval != undefined)
-        eval(oData.eval);
-};
-
 BxTimelineMain.prototype.loadingInButton = function(e, bShow) {
 	if($(e).length)
 		bx_loading_btn($(e), bShow);

+ 62 - 49
modules/boonex/timeline/js/post.js

@@ -57,33 +57,38 @@ BxTimelinePost.prototype.beforeFormPostSubmit = function(oForm)
 
 BxTimelinePost.prototype.afterFormPostSubmit = function (oForm, oData)
 {
-	this.loadingInButton($(oForm).children().find(':submit'), false);
+	var $this = this;
+	var fContinue = function() {
+		if(oData && oData.id != undefined) {
+			var iId = parseInt(oData.id);
+	        if(iId <= 0) 
+	        	return;
 
-	if(oData && oData.msg != undefined)
-        alert(oData.msg);
+	        if($('#' + $this._aHtmlIds['main_timeline']).length)
+	        	$this._getPost(oForm, iId, 'timeline');
 
-	if(oData && oData.id != undefined) {
-		var iId = parseInt(oData.id);
-        if(iId <= 0) 
-        	return;
+	        if($('#' + $this._aHtmlIds['main_outline']).length)
+	        	$this._getPost(oForm, iId, 'outline');
 
-        if($('#' + this._aHtmlIds['main_timeline']).length)
-        	this._getPost(oForm, iId, 'timeline');
+	        $this._getForm(oForm, $(oForm).find("input[name = 'type']").val());
 
-        if($('#' + this._aHtmlIds['main_outline']).length)
-        	this._getPost(oForm, iId, 'outline');
+	        return;
+		}
 
-        this._getForm(oForm, $(oForm).find("input[name = 'type']").val());
+		if(oData && oData.form != undefined && oData.form_id != undefined) {
+			$('#' + oData.form_id).replaceWith(oData.form);
+			$this.initFormPost(oData.form_id);
 
-        return;
-	}
+			return;
+		}
+	};
 
-	if(oData && oData.form != undefined && oData.form_id != undefined) {
-		$('#' + oData.form_id).replaceWith(oData.form);
-		this.initFormPost(oData.form_id);
+	this.loadingInButton($(oForm).children().find(':submit'), false);
 
-		return;
-	}
+	if(oData && oData.message != undefined)
+        bx_alert(oData.message, fContinue);
+	else
+		fContinue();
 };
 
 BxTimelinePost.prototype.initFormAttachLink = function(sFormId)
@@ -110,34 +115,38 @@ BxTimelinePost.prototype.beforeFormAttachLinkSubmit = function(oForm)
 
 BxTimelinePost.prototype.afterFormAttachLinkSubmit = function (oForm, oData)
 {
-	oForm = $(oForm);
-	this.loadingInButton(oForm.find(':submit'), false);
+	var $this = this;
+	var fContinue = function() {
+		if(oData && oData.item != undefined) {
+			$('#' + $this._aHtmlIds['attach_link_popup']).dolPopupHide({onHide: function() {
+				$(oForm).find('.bx-form-warn').hide();
+			}});
 
-	if(oData && oData.msg != undefined)
-        alert(oData.msg);
+			if(!$.trim(oData.item).length)
+				return;
 
-	if(oData && oData.item != undefined) {
-		$('#' + this._aHtmlIds['attach_link_popup']).dolPopupHide({onHide: function() {
-			oForm.find('.bx-form-warn').hide();
-		}});
+			var oItem = $(oData.item).hide();
+			$('#' + $this._aHtmlIds['attach_link_form_field']).prepend(oItem).find('#' + oItem.attr('id')).bx_anim('show', $this._sAnimationEffect, $this._sAnimationSpeed, function() {
+				$(this).find('a.bx-link').dolConverLinks();
+			});
 
-		if(!$.trim(oData.item).length)
-			return;
+	        return;
+		}
 
-		var oItem = $(oData.item).hide();
-		$('#' + this._aHtmlIds['attach_link_form_field']).prepend(oItem).find('#' + oItem.attr('id')).bx_anim('show', this._sAnimationEffect, this._sAnimationSpeed, function() {
-			$(this).find('a.bx-link').dolConverLinks();
-		});
+		if(oData && oData.form != undefined && oData.form_id != undefined) {
+			$('#' + oData.form_id).replaceWith(oData.form);
+			$this.initFormAttachLink(oData.form_id);
 
-        return;
-	}
+			return;
+		}
+	};
 
-	if(oData && oData.form != undefined && oData.form_id != undefined) {
-		$('#' + oData.form_id).replaceWith(oData.form);
-		this.initFormAttachLink(oData.form_id);
+	this.loadingInButton($(oForm).find(':submit'), false);
 
-		return;
-	}
+	if(oData && oData.message != undefined)
+        bx_alert(oData.message, fContinue);
+	else
+		fContinue();
 };
 
 BxTimelinePost.prototype.deleteAttachLink = function(oLink, iId) {
@@ -152,16 +161,20 @@ BxTimelinePost.prototype.deleteAttachLink = function(oLink, iId) {
         this._sActionsUrl + 'delete_attach_link/',
         oData,
         function(oData) {
-        	bx_loading(oAttachLink, false);
+        	var fContinue = function() {
+        		if(oData && oData.code != undefined && oData.code == 0) {
+            		oAttachLink.bx_anim('hide', $this._sAnimationEffect, $this._sAnimationSpeed, function() {
+            			$(this).remove;
+            		});
+            	}
+        	};
 
-        	if(oData && oData.msg != undefined)
-                alert(oData.msg);
+        	bx_loading(oAttachLink, false);
 
-        	if(oData && oData.code != undefined && oData.code == 0) {
-        		oAttachLink.bx_anim('hide', $this._sAnimationEffect, $this._sAnimationSpeed, function() {
-        			$(this).remove;
-        		});
-        	}
+        	if(oData && oData.message != undefined)
+                bx_alert(oData.message, fContinue);
+        	else
+        		fContinue();
         },
         'json'
     );
@@ -213,7 +226,7 @@ BxTimelinePost.prototype._getPost = function(oElement, iId, sView) {
         function(oData) {
         	$this.loadingInBlock(oElementView, false);
 
-        	$this.processResult(oData);
+        	processJsonData(oData);
         },
         'json'
     );

+ 14 - 11
modules/boonex/timeline/js/repost.js

@@ -46,19 +46,22 @@ BxTimelineRepost.prototype.repostItem = function(oLink, iOwnerId, sType, sAction
 
         	var oCounter = $this._getCounter(oLink);
         	var bCounter = oCounter && oCounter.length > 0;
-        	
-        	if(oData && oData.msg != undefined && oData.msg.length > 0 && !bCounter)
-                alert(oData.msg);
-        	
-        	if(oData && oData.counter != undefined && bCounter) {
-        		var oCounterHolder = oCounter.parents('.' + $this.sSP + '-repost-counter-holder:first');
+        	var fContinue = function() {
+        		if(oData && oData.counter != undefined && bCounter) {
+            		var oCounterHolder = oCounter.parents('.' + $this.sSP + '-repost-counter-holder:first');
 
-        		oCounter.replaceWith(oData.counter);
-        		oCounterHolder.bx_anim(oData.count > 0 ? 'show' : 'hide');
-        	}
+            		oCounter.replaceWith(oData.counter);
+            		oCounterHolder.bx_anim(oData.count > 0 ? 'show' : 'hide');
+            	}
 
-        	if(oData && oData.disabled)
-    			$(oLink).removeAttr('onclick').addClass($(oLink).hasClass('bx-btn') ? 'bx-btn-disabled' : $this.sSP + '-repost-disabled');
+            	if(oData && oData.disabled)
+        			$(oLink).removeAttr('onclick').addClass($(oLink).hasClass('bx-btn') ? 'bx-btn-disabled' : $this.sSP + '-repost-disabled');
+        	};
+
+        	if(oData && oData.message != undefined && oData.message.length > 0 && !bCounter)
+                bx_alert(oData.message, fContinue);
+        	else
+        		fContinue();
         },
         'json'
     );

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

@@ -228,7 +228,7 @@ BxTimelineView.prototype.pinPost = function(oLink, iId, iWay) {
         this._sActionsUrl + 'pin/',
         oData,
         function(oData) {
-        	$this.processResult(oData);
+        	processJsonData(oData);
         },
         'json'
     );
@@ -246,7 +246,7 @@ BxTimelineView.prototype.onPinPost = function(oData) {
         	$(sItemTimeline).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
     	        $(this).remove();
 
-    	        $this.processResult(oData);
+    	        processJsonData(oData);
         	});
         });
 	}
@@ -258,7 +258,7 @@ BxTimelineView.prototype.onPinPost = function(oData) {
 		this._oRequestParams['outline'].start = 0;
         this._getPosts(this.oViewOutline, function(oData) {
         	$this.removeMasonry(sItemOutline, function() {
-        		$this.processResult(oData);
+        		processJsonData(oData);
     		});
         });
 	}
@@ -281,7 +281,7 @@ BxTimelineView.prototype.deletePost = function(oLink, iId) {
         this._sActionsUrl + 'delete/',
         oData,
         function(oData) {
-        	$this.processResult(oData);
+        	processJsonData(oData);
         },
         'json'
     );
@@ -333,7 +333,7 @@ BxTimelineView.prototype._getPosts = function(oElement, onComplete) {
 
         	$this.loadingInBlock(oElement, false);
 
-        	$this.processResult(oData);
+        	processJsonData(oData);
         },
         'json'
     );