Просмотр исходного кода

Ticket #923 - In BxDolFavorite and BxDolFeature.

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

+ 4 - 4
inc/classes/BxDolFavorite.php

@@ -192,7 +192,7 @@ class BxDolFavorite extends BxDolObject
 	protected function _doFavorite()
     {
         if (!$this->isEnabled())
-           return array('code' => 1, 'msg' => _t('_favorite_err_not_enabled'));
+           return array('code' => 1, 'message' => _t('_favorite_err_not_enabled'));
 
         $iObjectId = $this->getId();
         $iObjectAuthorId = $this->_oQuery->getObjectAuthorId($iObjectId);
@@ -203,13 +203,13 @@ class BxDolFavorite extends BxDolObject
         $bPerformUndo = $bPerformed && $bUndo ? true : false;
 
         if(!$bPerformUndo && !$this->isAllowedFavorite())
-            return array('code' => 2, 'msg' => $this->msgErrAllowedFavorite());
+            return array('code' => 2, 'message' => $this->msgErrAllowedFavorite());
 
         if($bPerformed && !$bUndo)
-        	return array('code' => 3, 'msg' => _t('_favorite_err_duplicate_favorite'));
+        	return array('code' => 3, 'message' => _t('_favorite_err_duplicate_favorite'));
 
         if(!$this->_oQuery->{($bPerformUndo ? 'un' : '') . 'doFavorite'}($iObjectId, $iAuthorId))
-            return array('code' => 4, 'msg' => _t('_favorite_err_cannot_perform_action'));
+            return array('code' => 4, 'message' => _t('_favorite_err_cannot_perform_action'));
 
         if(!$bPerformUndo)
             $this->isAllowedFavorite(true);

+ 4 - 4
inc/classes/BxDolFeature.php

@@ -144,7 +144,7 @@ class BxDolFeature extends BxDolObject
 	protected function _doFeature()
     {
         if (!$this->isEnabled())
-           return array('code' => 1, 'msg' => _t('_feature_err_not_enabled'));
+           return array('code' => 1, 'message' => _t('_feature_err_not_enabled'));
 
         $iObjectId = $this->getId();
         $iObjectAuthorId = $this->_oQuery->getObjectAuthorId($iObjectId);
@@ -155,13 +155,13 @@ class BxDolFeature extends BxDolObject
         $bPerformUndo = $bPerformed && $bUndo ? true : false;
 
         if(!$bPerformUndo && !$this->isAllowedFeature())
-            return array('code' => 2, 'msg' => $this->msgErrAllowedFeature());
+            return array('code' => 2, 'message' => $this->msgErrAllowedFeature());
 
         if($bPerformed && !$bUndo)
-        	return array('code' => 3, 'msg' => _t('_feature_err_duplicate_feature'));
+        	return array('code' => 3, 'message' => _t('_feature_err_duplicate_feature'));
 
         if(!$this->_triggerValue($bPerformUndo ? 0 : time()))
-            return array('code' => 4, 'msg' => _t('_feature_err_cannot_perform_action'));
+            return array('code' => 4, 'message' => _t('_feature_err_cannot_perform_action'));
             
         if(!$bPerformUndo)
             $this->isAllowedFeature(true);

+ 46 - 39
inc/js/classes/BxDolFavorite.js

@@ -54,58 +54,65 @@ BxDolFavorite.prototype.favorite = function(oLink) {
 
 BxDolFavorite.prototype.onFavorite = function(oData, oElement)
 {
-	if(oData && oData.msg != undefined && oData.msg.length > 0)
-        alert(oData.msg);
+	var $this = this;
+	var fContinue = function() {
+		if(oData && oData.code != 0)
+	        return;
 
-	if(oData && oData.code != 0)
-        return;
+		if(oData && oData.label_icon)
+			$(oElement).find('.sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
 
-	if(oData && oData.label_icon)
-		$(oElement).find('.sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
+		if(oData && oData.label_title) {
+			$(oElement).attr('title', oData.label_title);
+			$(oElement).find('span').html(oData.label_title);
+		}
 
-	if(oData && oData.label_title) {
-		$(oElement).attr('title', oData.label_title);
-		$(oElement).find('span').html(oData.label_title);
-	}
+		if(oData && oData.disabled)
+			$(oElement).removeAttr('onclick').addClass($(oElement).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-favorite-disabled');
 
-	if(oData && oData.disabled)
-		$(oElement).removeAttr('onclick').addClass($(oElement).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-favorite-disabled');
+	    var oCounter = $this._getCounter(oElement);
+	    if(oCounter && oCounter.length > 0) {
+	    	oCounter.html(oData.countf);
 
-    var oCounter = this._getCounter(oElement);
-    if(oCounter && oCounter.length > 0) {
-    	oCounter.html(oData.countf);
+	    	oCounter.parents('.' + $this._sSP + '-counter-holder:first').bx_anim(oData.count > 0 ? 'show' : 'hide');
+	    }
+	};
 
-    	oCounter.parents('.' + this._sSP + '-counter-holder:first').bx_anim(oData.count > 0 ? 'show' : 'hide');
-    }
+	if(oData && oData.msg != undefined && oData.msg.length > 0)
+        bx_alert(oData.msg, fContinue);
+	else
+		fContinue();
 };
 
 BxDolFavorite.prototype.processJson = function(oData, oElement) {
 	oElement = oElement != undefined ? oElement : this._oParent;
 
+	var fContinue = function() {
+		//--- Show Popup
+	    if(oData && oData.popup != undefined) {
+	    	$('#' + oData.popup_id).remove();
+
+	    	$(oData.popup).hide().prependTo('body').dolPopup({
+	    		pointer: {
+	    			el: oElement
+	    		},
+	            fog: {
+					color: '#fff',
+					opacity: .7
+	            }
+	        });
+	    }
+
+	    //--- Evaluate JS code
+	    if (oData && oData.eval != undefined)
+	        eval(oData.eval);
+	};
+
     //--- Show Message
-    if(oData && oData.msg != undefined)
-        alert(oData.msg);
     if(oData && oData.message != undefined)
-        alert(oData.message);
-
-    //--- Show Popup
-    if(oData && oData.popup != undefined) {
-    	$('#' + oData.popup_id).remove();
-
-    	$(oData.popup).hide().prependTo('body').dolPopup({
-    		pointer: {
-    			el: oElement
-    		},
-            fog: {
-				color: '#fff',
-				opacity: .7
-            }
-        });
-    }
-
-    //--- Evaluate JS code
-    if (oData && oData.eval != undefined)
-        eval(oData.eval);
+        bx_alert(oData.message, fContinue);
+    else
+    	fContinue();
 };
 
 BxDolFavorite.prototype._getButtons = function(oElement) {

+ 42 - 34
inc/js/classes/BxDolFeature.js

@@ -43,51 +43,59 @@ BxDolFeature.prototype.feature = function(oLink) {
 
 BxDolFeature.prototype.onFeature = function(oData, oElement)
 {
-	if(oData && oData.msg != undefined && oData.msg.length > 0)
-        alert(oData.msg);
+	var fContinue = function() {
+		if(oData && oData.code != 0)
+	        return;
 
-	if(oData && oData.code != 0)
-        return;
+		if(oData && oData.label_icon)
+			$(oElement).find('.sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
 
-	if(oData && oData.label_icon)
-		$(oElement).find('.sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
+		if(oData && oData.label_title) {
+			$(oElement).attr('title', oData.label_title);
+			$(oElement).find('span').html(oData.label_title);
+		}
 
-	if(oData && oData.label_title) {
-		$(oElement).attr('title', oData.label_title);
-		$(oElement).find('span').html(oData.label_title);
-	}
+		if(oData && oData.disabled)
+			$(oElement).removeAttr('onclick').addClass($(oElement).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-feature-disabled');
+	};
 
-	if(oData && oData.disabled)
-		$(oElement).removeAttr('onclick').addClass($(oElement).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-feature-disabled');
+	if(oData && oData.msg != undefined && oData.msg.length > 0)
+        bx_alert(oData.msg, fContinue);
+	else
+		fContinue();
+
+	
 };
 
 BxDolFeature.prototype.processJson = function(oData, oElement) {
 	oElement = oElement != undefined ? oElement : this._oParent;
 
+	var fContinue = function() {
+		//--- Show Popup
+	    if(oData && oData.popup != undefined) {
+	    	$('#' + oData.popup_id).remove();
+
+	    	$(oData.popup).hide().prependTo('body').dolPopup({
+	    		pointer: {
+	    			el: oElement
+	    		},
+	            fog: {
+					color: '#fff',
+					opacity: .7
+	            }
+	        });
+	    }
+
+	    //--- Evaluate JS code
+	    if (oData && oData.eval != undefined)
+	        eval(oData.eval);
+	};
+
     //--- Show Message
-    if(oData && oData.msg != undefined)
-        alert(oData.msg);
     if(oData && oData.message != undefined)
-        alert(oData.message);
-
-    //--- Show Popup
-    if(oData && oData.popup != undefined) {
-    	$('#' + oData.popup_id).remove();
-
-    	$(oData.popup).hide().prependTo('body').dolPopup({
-    		pointer: {
-    			el: oElement
-    		},
-            fog: {
-				color: '#fff',
-				opacity: .7
-            }
-        });
-    }
-
-    //--- Evaluate JS code
-    if (oData && oData.eval != undefined)
-        eval(oData.eval);
+        bx_alert(oData.message, fContinue);
+    else
+    	fContinue();
 };
 
 BxDolFeature.prototype._getButtons = function(oElement) {