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

#24 - Timeline: Combine Manage menu with Actions one.

AntonLV 11 лет назад
Родитель
Сommit
690d8584fc

+ 8 - 8
modules/boonex/ocean/data/template/bx_timeline/css/view.css → modules/boonex/ocean/data/template/bx_timeline/css/view.less

@@ -1,14 +1,14 @@
-@import url(../../../../../timeline/template/css/view.css);
+@import (reference) '../../system/css/default.less';
+@import '../../../../../timeline/template/css/view.css';
 
-div.bx-tl-activity div.bx-tl-item-actions,
-div.bx-tl-activity div.bx-tl-item-menu {
-	margin-left: 10px;
-	margin-left: 0.625rem;
+div.bx-tl-activity ul.bx-menu-object-bx_timeline_menu_item_actions {
+	.bx-def-margin-thd-leftright-neg;
+
+	.margin-top(-@bx-margin-thd);
 }
 
-div.bx-tl-activity div.bx-tl-item-actions:first-child,
-div.bx-tl-activity div.bx-tl-item-menu:first-child {
-	margin-left: 0px;
+div.bx-tl-activity ul.bx-menu-object-bx_timeline_menu_item_actions li  {
+	.bx-def-margin-thd;
 }
 
 /*+++ Item Menu +++*/

+ 6 - 6
modules/boonex/timeline/classes/BxTimelineMenuItemActions.php

@@ -98,23 +98,23 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
      */
     protected function _isVisible ($a)
     {
-        if(!parent::_isVisible($a))
+        if(!parent::_isVisible($a) || empty($this->_aEvent))
             return false;
 
         $sCheckFuncName = '';
-        $aCheckFuncParams = array();
+        $aCheckFuncParams = array($this->_aEvent);
         switch ($a['name']) {
             case 'item-comment':
                 $sCheckFuncName = 'isAllowedComment';
-                if(!empty($this->_aEvent))
-                    $aCheckFuncParams = array($this->_aEvent);
                 break;
 
             case 'item-vote':
                 $sCheckFuncName = 'isAllowedVote';
-                if(!empty($this->_aEvent))
-                    $aCheckFuncParams = array($this->_aEvent);
                 break;
+
+            case 'item-more':
+            	$sCheckFuncName = 'isAllowedMore';
+            	break;
         }
 
         if(!$sCheckFuncName || !method_exists($this->_oModule, $sCheckFuncName))

+ 16 - 12
modules/boonex/timeline/classes/BxTimelineMenuItemManage.php

@@ -16,30 +16,31 @@ bx_import('BxTemplMenu');
  */
 class BxTimelineMenuItemManage extends BxTemplMenu
 {
-    protected $_aEvent;
+	protected $_iEvent;
     protected $_oModule;
 
+
     public function __construct($aObject, $oTemplate = false)
     {
         parent::__construct($aObject, $oTemplate);
 
+        bx_import('BxDolModule');
         $this->_oModule = BxDolModule::getInstance('bx_timeline');
 
+        $this->_iEvent = 0;
+        if(bx_get('content_id') !== false)
+        	$this->_iEvent = (int)bx_get('content_id');
+
         $this->addMarkers(array(
             'js_object_view' => $this->_oModule->_oConfig->getJsObject('view'),
+
+        	'content_id' => $this->_iEvent,
         ));
     }
 
-    public function setEvent($aEvent)
+    public function setEventId($iEventId)
     {
-        if(empty($aEvent) || !is_array($aEvent))
-            return;
-
-        $this->_aEvent = $aEvent;
-
-        $this->addMarkers(array(
-            'content_id' => $aEvent['id'],
-        ));
+    	$this->_iEvent = $iEventId;
     }
 
     public function isVisible()
@@ -69,13 +70,16 @@ class BxTimelineMenuItemManage extends BxTemplMenu
         if(!parent::_isVisible($a))
             return false;
 
+		$aEvent = $this->_oModule->_oDb->getEvents(array('browse' => 'id', 'value' => $this->_iEvent));
+		if(empty($aEvent) || !is_array($aEvent))
+			return false;
+
         $sCheckFuncName = '';
         $aCheckFuncParams = array();
         switch ($a['name']) {
             case 'item-delete':
                 $sCheckFuncName = 'isAllowedDelete';
-                if(!empty($this->_aEvent))
-                    $aCheckFuncParams = array($this->_aEvent);
+				$aCheckFuncParams = array($aEvent);
                 break;
         }
 

+ 9 - 16
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -195,15 +195,6 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         $this->_echoResultJson(array('content' => $sComments));
     }
 
-    public function actionGetManageMenuPopup()
-    {
-        $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
-        if(!$iItemId)
-            return;
-
-        echo $this->getManageMenuObject($iItemId)->getCode();
-    }
-
     public function actionAddAttachLink()
     {
         $aResult = $this->getFormAttachLink();
@@ -591,15 +582,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         return $oMenu;
     }
 
-    public function getManageMenuObject($mixedEvent)
+    public function getManageMenuObject()
     {
-    	if(!is_array($mixedEvent))
-    		$mixedEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => (int)$mixedEvent));
-
         bx_import('BxDolMenu');
-        $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_manage'), $this->_oTemplate);
-        $oMenu->setEvent($mixedEvent);
-        return $oMenu;
+        return BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_manage'), $this->_oTemplate);
     }
 
     //--- Check permissions methods ---//
@@ -674,6 +660,13 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         return $aCheckResult[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
     }
 
+    public function isAllowedMore($aEvent, $bPerform = false)
+    {
+    	$oMoreMenu = $this->getManageMenuObject();
+    	$oMoreMenu->setEventId($aEvent['id']);
+    	return $oMoreMenu->isVisible();
+    }
+
     public function onPost($iId)
     {
         $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));

+ 0 - 8
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -489,14 +489,6 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'js_object' => $sJsObject,
         	'html_id' => $this->_oConfig->getHtmlIds('view', 'item') . $aEvent['id'],
             'class' => $bBrowseItem ? 'bx-tl-view-sizer' : 'bx-tl-grid-sizer',
-            'bx_if:show_menu_item_manage' => array(
-                'condition' => $oModule->getManageMenuObject($aEvent)->isVisible(),
-                'content' => array(
-        			'style_prefix' => $sStylePrefix,
-		            'js_object' => $sJsObject,
-		        	'id' => $aEvent['id'],
-        		)
-            ),
             'bx_if:show_icon' => array(
                 'condition' => $bAuthorIcon,
                 'content' => array(

+ 1 - 0
modules/boonex/timeline/install/langs/en.xml

@@ -81,6 +81,7 @@
     <string name="_bx_timeline_menu_item_title_item_comment"><![CDATA[Comment]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_vote"><![CDATA[Vote]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_share"><![CDATA[Repost]]></string>
+    <string name="_bx_timeline_menu_item_title_system_item_more"><![CDATA[More]]></string>
 
 	<string name="_bx_timeline_menu_title_post_attachments"><![CDATA[Form Attachments]]></string>
     <string name="_bx_timeline_menu_set_title_post_attachments"><![CDATA[Form Attachments]]></string>

+ 2 - 1
modules/boonex/timeline/install/sql/enable.sql

@@ -51,7 +51,8 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `editable`, `order`) VALUES 
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-comment', '_bx_timeline_menu_item_title_system_item_comment', '_bx_timeline_menu_item_title_item_comment', 'javascript:void(0)', 'javascript:{comment_onclick}', '_self', 'comment', 'a:3:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:27:"get_menu_item_addon_comment";s:6:"params";a:2:{i:0;s:16:"{comment_system}";i:1;s:16:"{comment_object}";}}', '', 2147483647, 1, 0, 1, 1),
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-vote', '_bx_timeline_menu_item_title_system_item_vote', '', 'javascript:void(0)', '', '', '', '', '', 2147483647, 1, 0, 0, 2),
-('bx_timeline_menu_item_actions', 'bx_timeline', 'item-share', '_bx_timeline_menu_item_title_system_item_share', '', 'javascript:void(0)', '', '', '', '', '', 2147483647, 1, 0, 0, 3);
+('bx_timeline_menu_item_actions', 'bx_timeline', 'item-share', '_bx_timeline_menu_item_title_system_item_share', '', 'javascript:void(0)', '', '', '', '', '', 2147483647, 1, 0, 0, 3),
+('bx_timeline_menu_item_actions', 'bx_timeline', 'item-more', '_bx_timeline_menu_item_title_system_item_more', '', 'javascript:void(0)', 'bx_menu_popup(''bx_timeline_menu_item_manage'', this, {}, {content_id:{content_id}});', '', 'ellipsis-h', '', 'bx_timeline_menu_item_manage', 2147483647, 1, 0, 0, 4);
 
 -- MENU: Post form attachments (Link, Photo, Video)
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 

+ 0 - 15
modules/boonex/timeline/js/view.js

@@ -87,21 +87,6 @@ BxTimelineView.prototype.showMoreContent = function(oLink) {
 	this.reloadMasonry();
 };
 
-BxTimelineView.prototype.showManageMenu = function(oLink, iId) {
-	var oData = this._getDefaultData();    
-    oData['id'] = iId;
-
-    $(this.sIdView).dolPopupAjax({
-		id: this._aHtmlIds['menu_popup'] + iId,
-		url: bx_append_url_params(this._sActionsUri + 'get_manage_menu_popup/', oData),
-		pointer:{
-			el:$(oLink)
-		}
-	});
-
-	return false;
-};
-
 BxTimelineView.prototype.showPhoto = function(oLink, sUrl) {
 	$('#' + this._aHtmlIds['photo_popup']).dolPopupImage(sUrl, $(oLink).parent());
 };

+ 0 - 21
modules/boonex/timeline/template/css/view.css

@@ -42,21 +42,6 @@ div.bx-tl-item-cnt {
 	overflow: hidden;
 }
 
-/*+++ Item Menu +++*/
-div.bx-tl-item-menu {
-	float: left;
-}
-div.bx-tl-item-menu .bx-menu-ver li {
-	white-space: nowrap;
-}
-div.bx-tl-item-menu-button {
-	text-align: center;
-}
-
-div.bx-tl-item-menu-button i.sys-icon {
-	display: inline-block;
-}
-
 /*+++ Item Owner +++*/
 div.bx-tl-item-owner {
 	position: relative;
@@ -110,12 +95,6 @@ div.bx-tl-shared div.bx-tl-content {
 	color: #999999;
 }
 
-/*+++ Item Actions +++*/
-div.bx-tl-item-actions {
-	float: left;
-}
-
-
 /*--- Empty Style ---*/
 div.bx-tl-empty div.bx-msg-box-container {
 	margin-top: 0px;

+ 4 - 19
modules/boonex/timeline/template/item.html

@@ -25,26 +25,11 @@
 			</div>
 			__content__
 			<bx_if:show_location>
-				<div class="__style_prefix__-location bx-def-margin-top bx-def-font-grayed bx-clearfix">
-					__location__
-				</div>
+				<div class="__style_prefix__-location bx-def-margin-top bx-def-font-grayed bx-clearfix">__location__</div>
 			</bx_if:show_location>
-			<div class="__style_prefix__-activity bx-clearfix">
-				<bx_if:show_menu_item_actions>
-					<div class="__style_prefix__-item-actions bx-def-margin-left-auto bx-def-margin-top">
-						__menu_item_actions__
-					</div>
-				</bx_if:show_menu_item_actions>
-				<bx_if:show_menu_item_manage>
-					<div class="__style_prefix__-item-menu bx-def-margin-left-auto bx-def-margin-top">
-						<div class="__style_prefix__-item-menu-button">
-				   			<a href="javascript:void(0)" onclick="javascript:__js_object__.showManageMenu(this, __id__);">
-								<i class="sys-icon ellipsis-h"></i>
-							</a>
-						</div>
-					</div>
-			   	</bx_if:show_menu_item_manage>
-			</div>
+			<bx_if:show_menu_item_actions>
+				<div class="__style_prefix__-activity bx-def-margin-top bx-clearfix">__menu_item_actions__</div>
+			</bx_if:show_menu_item_actions>
 			<div class="__style_prefix__-item-comments-holder">__comments__</div>
 			__votes__
 		</div>