Sfoglia il codice sorgente

Ticket #3073 - Clean up and improvements.

AntonLV 5 anni fa
parent
commit
6c24185233

+ 9 - 0
studio/classes/BxDolStudioWidgets.php

@@ -15,6 +15,7 @@ define('BX_DOL_STUDIO_WTYPE_DEFAULT', 'library');
 class BxDolStudioWidgets extends BxTemplStudioPage
 {
     protected $sCacheKeyNotices = 'std_widgets_notices';
+    protected $sCookieKeyFeatured = 'bx_studio_featured';
 
     protected $_sType;
 
@@ -48,6 +49,14 @@ class BxDolStudioWidgets extends BxTemplStudioPage
         $this->aWidgetsNotices = $oCache->getData($sCacheKey);
     }
 
+    /**
+     * Checks whether 'Featured Only' mode is enabled or not.
+     */
+    public function isFeatured()
+    {
+        return isset($_COOKIE[$this->sCookieKeyFeatured]) && (int)$_COOKIE[$this->sCookieKeyFeatured] == 1;
+    }
+
     public function updateCache()
     {
     	$aWidgets = $this->oDb->getWidgets(array('type' => 'all_with_notices'));

+ 0 - 22
studio/js/designs.js

@@ -1,22 +0,0 @@
-/**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup    UnaStudio UNA Studio
- * @{
- */
-function BxDolStudioDesigns(oOptions) {
-	this.sActionsUrl = oOptions.sActionUrl;
-    this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioDesigns' : oOptions.sObjName;
-    this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
-    this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
-}
-
-BxDolStudioDesigns.prototype.popup = function(sType, sValue) {
-	var sId = 'bx-std-dsg-popup-' + sType;
-
-    $('#' + sId).remove();
-    $('<div id="' + sId + '" style="display: none;"></div>').prependTo('body').html(sValue);
-    $('#' + sId).dolPopup({});
-};
-/** @} */

+ 0 - 22
studio/js/languages.js

@@ -1,22 +0,0 @@
-/**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup    UnaStudio UNA Studio
- * @{
- */
-function BxDolStudioLanguages(oOptions) {
-	this.sActionsUrl = oOptions.sActionUrl;
-    this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioLanguages' : oOptions.sObjName;
-    this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
-    this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
-}
-
-BxDolStudioLanguages.prototype.popup = function(sType, sValue) {
-    var sId = 'bx-std-lang-popup-' + sType;
-
-    $('#' + sId).remove();
-    $('<div id="' + sId + '" style="display: none;"></div>').prependTo('body').html(sValue);
-    $('#' + sId).dolPopup({});
-};
-/** @} */

+ 4 - 36
studio/js/launcher.js

@@ -31,10 +31,6 @@ function BxDolStudioLauncher(oOptions) {
 BxDolStudioLauncher.prototype.init = function() {
     var $this = this;
 
-    $(window).bind('resize', function(e) {
-        $this.resize();
-    });
-
     $(document).ready(function() {
     	//--- Enable Sorting for Page Edit mode ---//
     	$($this.aSortingConf.parent).sortable({
@@ -44,21 +40,13 @@ BxDolStudioLauncher.prototype.init = function() {
             placeholder: $this.aSortingConf.placeholder,
             start: function(oEvent, oUi) {
                 oUi.item.addClass('bx-std-widget-dragging');
-                $this.resize();
-            },
-            change: function(oEvent, oUi) {
-                $this.resize();
             },
             stop: function(oEvent, oUi) {
                 oUi.item.removeClass('bx-std-widget-dragging');
-                $this.resize();
                 $this.reorder(oUi.item);
             }
     	});
 
-    	//--- Enable autoresizing for correct alignment ---//
-    	$this.resize();
-
     	//--- Check for Featured mode.
     	if($this._isFeatured())
             $('.bx-menu-tab-featured').addClass('bx-menu-tab-active');
@@ -102,22 +90,6 @@ BxDolStudioLauncher.prototype.updateCache = function() {
     );
 };
 
-BxDolStudioLauncher.prototype.resize = function() {
-    $('.bx-std-widgets').each(function() {
-        var oWidgets = $(this);
-        var oWidget = oWidgets.find('.bx-std-widget').removeClass('bx-std-widget-nl').filter(':visible:not(.bx-std-widget-dragging)');
-
-        var iWidgetsTotal = oWidget.length;
-        var iWidgetsPerLine = oWidgets.width()/oWidget.innerWidth()>>0;
-
-        if(iWidgetsTotal <= iWidgetsPerLine)
-            return;
-
-        for(var i = 1; i * iWidgetsPerLine <= iWidgetsTotal; i++)
-            oWidget.eq(i * iWidgetsPerLine).addClass('bx-std-widget-nl');
-    });
-};
-
 BxDolStudioLauncher.prototype.reorder = function(oDraggable) {
     var oDate = new Date();
 
@@ -240,13 +212,13 @@ BxDolStudioLauncher.prototype.enableFeatured = function() {
     this.disableJitter();
     $('.bx-menu-tab-edit').removeClass('bx-menu-tab-active');
 
-    $.cookie('bx_studio_featured', '1');
+    $.cookie('bx_studio_featured', '1', {path: '/'});
 
     this._enableFeatured();
 };
 
 BxDolStudioLauncher.prototype.disableFeatured = function() {
-    $.cookie('bx_studio_featured', '0');
+    $.cookie('bx_studio_featured', '0', {path: '/'});
 
     this._disableFeatured();
 };
@@ -258,16 +230,12 @@ BxDolStudioLauncher.prototype._isFeatured = function() {
 BxDolStudioLauncher.prototype._enableFeatured = function() {
     var $this = this;
 
-    $('.bx-std-widget:not(.bx-std-widget-icon-featured)').bx_anim('hide', this.sAnimationEffect, this.iAnimationSpeed, function() {
-        $this.resize();
-    });
+    $('.bx-std-widget:not(.bx-std-widget-icon-featured)').bx_anim('hide', this.sAnimationEffect, this.iAnimationSpeed);
 };
 
 BxDolStudioLauncher.prototype._disableFeatured = function() {
     var $this = this;
 
-    $('.bx-std-widget:not(.bx-std-widget-icon-featured)').bx_anim('show', this.sAnimationEffect, this.iAnimationSpeed, function() {
-        $this.resize();
-    });
+    $('.bx-std-widget:not(.bx-std-widget-icon-featured)').bx_anim('show', this.sAnimationEffect, this.iAnimationSpeed);
 };
 /** @} */

+ 0 - 22
studio/js/modules.js

@@ -1,22 +0,0 @@
-/**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup    UnaStudio UNA Studio
- * @{
- */
-function BxDolStudioModules(oOptions) {
-    this.sActionsUrl = oOptions.sActionUrl;
-    this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioModules' : oOptions.sObjName;
-    this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
-    this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
-}
-
-BxDolStudioModules.prototype.popup = function(sType, sValue) {
-    var sId = 'bx-std-mod-popup-' + sType;
-
-    $('#' + sId).remove();
-    $('<div id="' + sId + '" style="display: none;"></div>').prependTo('body').html(sValue);
-    $('#' + sId).dolPopup({});
-};
-/** @} */

+ 0 - 6
studio/template/css/designs.css

@@ -1,6 +0,0 @@
-/*--- Designs pages -> Action popups ---*/
-div.bx-dsn-confirm {}
-div.bx-dsn-confirm-cnt{}
-
-div.bx-dsn-action-result {}
-div.bx-dsn-action-result-cnt {}

+ 0 - 6
studio/template/css/languages.css

@@ -1,6 +0,0 @@
-/*--- Languages pages -> Action popups ---*/
-div.bx-lang-confirm {}
-div.bx-lang-confirm-cnt{}
-
-div.bx-lang-action-result {}
-div.bx-lang-action-result-cnt {}

+ 19 - 13
studio/template/css/launcher.css

@@ -42,35 +42,29 @@ div.bx-std-launcher {
  */
 div.bx-std-widgets-wrp {
     position: relative;
-    float: left;
     top: 0px;
     width: 100%;
 }
-div.bx-std-widgets-center {
-    position: relative;
-    float: left;
-    left: 50%;
-}
 div.bx-std-widgets {
     position: relative;
-    float: left;
-    left: -50%;
+    display: -webkit-flex;
+    display: flex;
+    -webkit-flex-wrap: wrap;
+    flex-wrap: wrap;
+    -webkit-justify-content: center;
+    justify-content: center;
 }
 div.bx-std-widgets-highlight {
     background-color: red;
 }
 div.bx-std-widget {
     position: relative;
-    float: left;
     padding: 24px;
 }
 div.bx-std-widget-empty {
     width: 96px;
     height: 128px;
 }
-div.bx-std-widget-nl {
-    clear: both;
-}
 
 .bx-std-widget-dragging {
     -webkit-transform: scale(1.05, 1.05);
@@ -316,6 +310,10 @@ body.shepherd-active .bx-std-widget-cont.shepherd-enabled {
     color: rgba(255, 255, 255, 0.85);
 }
 
+.bx-std-launcher-browser .bx-std-lb-content {
+    -webkit-flex-grow: 1;
+    flex-grow: 1;
+}
 .bx-std-lb-widgets {
     position: relative;
     display: none;
@@ -325,7 +323,15 @@ body.shepherd-active .bx-std-widget-cont.shepherd-enabled {
 .bx-std-lb-widgets.bx-std-lbw-active {
     display: block;
 }
-
+.bx-std-lb-widgets-cnt {
+    position: relative;
+    display: -webkit-flex;
+    display: flex;
+    -webkit-flex-wrap: wrap;
+    flex-wrap: wrap;
+    -webkit-justify-content: center;
+    justify-content: center;
+}
 .bx-std-launcher-browser .bx-std-widget-icon {
     width: 4rem;
     height: 4rem;

+ 0 - 14
studio/template/css/modules.css

@@ -1,14 +0,0 @@
-/*--- Modules(Store) pages -> Action popups ---*/
-div.bx-mod-confirm {}
-div.bx-mod-confirm-cnt{}
-
-div.bx-mod-action-result {}
-div.bx-mod-action-result-cnt {}
-
-div.bx-mod-action-result-step {
-	max-width: 480px;
-	max-width: 30rem;
-}
-div.bx-mod-ars-content {
-	overflow-x: auto;
-}

+ 0 - 7
studio/template/dsn_js.html

@@ -1,7 +0,0 @@
-<script defer language="javascript">
-<!--
-var __js_object__ = new BxDolStudioDesigns({
-    sActionUrl: '<bx_url_studio />templates.php'
-});
--->
-</script>

+ 0 - 7
studio/template/lang_js.html

@@ -1,7 +0,0 @@
-<script defer language="javascript">
-<!--
-var __js_object__ = new BxDolStudioLanguages({
-    sActionUrl: '<bx_url_studio />languages.php'
-});
--->
-</script>

+ 1 - 2
studio/template/launcher_browser.html

@@ -8,8 +8,7 @@
             <div class="bx-std-lb-content-cnt">
                 <bx_repeat:types>
                     <div id="bx-std-lbw-__type__" class="bx-std-lb-widgets bx-std-lbw-__type__ __class__">
-                        __widgets__
-                        <div class="bx-std-cb"></div>
+                        <div class="bx-std-lb-widgets-cnt">__widgets__</div>
                     </div>
                 </bx_repeat:types>
             </div>

+ 0 - 3
studio/template/mod_action_result.html

@@ -1,3 +0,0 @@
-<div class="bx-mod-action-result bx-def-popup-width bx-def-color-bg-block">
-    <div class="bx-mod-action-result-cnt bx-def-padding">__content__</div>
-</div>

+ 0 - 7
studio/template/mod_js.html

@@ -1,7 +0,0 @@
-<script defer language="javascript">
-<!--
-var __js_object__ = new BxDolStudioModules({
-    sActionUrl: '<bx_url_studio />modules.php'
-});
--->
-</script>

+ 9 - 3
studio/template/scripts/BxBaseStudioFunctions.php

@@ -60,16 +60,22 @@ class BxBaseStudioFunctions extends BxBaseFunctions implements iBxDolSingleton
         $oTemplate->getPageCode();
     }
 
-    public function getWidget($mixedWidget, $aNotices = array())
+    public function getWidget($mixedWidget, $aParams = array())
     {
         $oTemplate = BxDolStudioTemplate::getInstance();
 
+        $bFeatured = isset($aParams['featured']) && $aParams['featured'] === true;
+
+        $aNotices = array();
+        if(!empty($aParams['notices']) && is_array($aParams['notices']))
+            $aNotices = $aParams['notices'];           
+
         $aMarkers = array(
             'url_root' => BX_DOL_URL_ROOT,
             'url_studio' => BX_DOL_URL_STUDIO,
             'url_studio_icons' => BX_DOL_URL_STUDIO_BASE . 'images/icons/'
         );
-        
+
         if(!is_array($mixedWidget)) 
             $mixedWidget = BxDolStudioWidgetsQuery::getInstance()->getWidgets(array('type' => 'by_id', 'value' => (int)$mixedWidget));
 
@@ -163,7 +169,7 @@ class BxBaseStudioFunctions extends BxBaseFunctions implements iBxDolSingleton
             'caption' => _t($mixedWidget['caption']),
             'widget_disabled_class' => !$bEnabled ? 'bx-std-widget-icon-disabled' : '',
             'widget_featured_class' => (int)$mixedWidget['featured'] == 1 ? 'bx-std-widget-icon-featured' : '',
-            'widget_styles' => isset($_COOKIE['bx_studio_featured']) && (int)$_COOKIE['bx_studio_featured'] == 1 && (int)$mixedWidget['featured'] != 1 ? 'display:none;' : ''
+            'widget_styles' => $bFeatured && (int)$mixedWidget['featured'] != 1 ? 'display:none;' : ''
         ));
     }
 

+ 8 - 0
studio/template/scripts/BxBaseStudioMenuAccountPopup.php

@@ -20,6 +20,14 @@ class BxBaseStudioMenuAccountPopup extends BxDolStudioMenuAccountPopup
             'url_studio' => BX_DOL_URL_STUDIO
         ));
     }
+
+    protected function _getMenuItem ($a)
+    {
+        if($a['name'] == 'featured')
+            $a['selected'] = BxTemplStudioLauncher::getInstance()->isFeatured();
+
+        return parent::_getMenuItem($a);
+    }
 }
 
 /** @} */

+ 1 - 1
studio/template/scripts/BxBaseStudioStore.php

@@ -19,7 +19,7 @@ class BxBaseStudioStore extends BxDolStudioStore
 
     function getPageCss()
     {
-        return array_merge(parent::getPageCss(), array('modules.css', 'store.css', 'store-media-tablet.css', 'store-media-desktop.css'));
+        return array_merge(parent::getPageCss(), array('module.css', 'store.css', 'store-media-tablet.css', 'store-media-desktop.css'));
     }
 
     function getPageJs()

+ 9 - 4
studio/template/scripts/BxBaseStudioWidgets.php

@@ -49,12 +49,17 @@ class BxBaseStudioWidgets extends BxDolStudioWidgets
         if($sResult === false)
             return false;
 
+        $aWidgetsParams = array(
+            'featured' => $this->isFeatured(),
+            'notices' => $this->aWidgetsNotices
+        );
+
         if(!$this->bPageMultiple)
-            return $this->wrapWidgets($this->aPage['name'], $this->getWidgets($this->aPage['name'], $this->aWidgets));
+            return $this->wrapWidgets($this->aPage['name'], $this->getWidgets($this->aPage['name'], $this->aWidgets, $aWidgetsParams));
 
         $sContent = "";
         foreach($this->aWidgets as $sPage => $aWidgets)
-            $sContent .= $this->wrapWidgets($sPage, $this->getWidgets($sPage, $aWidgets), $sPage != $this->sPageSelected);
+            $sContent .= $this->wrapWidgets($sPage, $this->getWidgets($sPage, $aWidgets, $aWidgetsParams), $sPage != $this->sPageSelected);
 
         return $sContent;
     }
@@ -109,13 +114,13 @@ class BxBaseStudioWidgets extends BxDolStudioWidgets
         ));
     }
 
-    protected function getWidgets($sPage, $aWidgets)
+    protected function getWidgets($sPage, $aWidgets, $aParams = array())
     {
         $oFunction = BxTemplStudioFunctions::getInstance();
 
         $aTmplVars = array();
         foreach($aWidgets as $aWidget) {
-            $sWidget = $oFunction->getWidget($aWidget, $this->aWidgetsNotices);
+            $sWidget = $oFunction->getWidget($aWidget, $aParams);
             if(empty($sWidget))
                 continue;
 

+ 1 - 4
studio/template/widgets_page.html

@@ -1,8 +1,5 @@
 <div id="bx-std-widgets-__page__" class="bx-std-widgets-wrp" <bx_if:page_hidden>style="display:none"</bx_if:page_hidden>>
-    <div class="bx-std-widgets-center">
-        <div class="bx-std-widgets">__content__</div>
-    </div>
-    <div class="bx-std-cb"></div>
+    <div class="bx-std-widgets">__content__</div>
 </div>
 <script>
     $(document).ready(function(){