瀏覽代碼

HUE-6077 [frontend] Made BS2 span3, span9 and margin variables globally available

Enrico Berti 8 年之前
父節點
當前提交
89bb87b

+ 1 - 1
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflow.mako

@@ -133,7 +133,7 @@ ${ layout.menubar(section='workflows', dashboard=True) }
       </div>
     </div>
 
-    <div class="span10" style="margin-left: 2.127659574468085%;">
+    <div class="span10" style="margin-left: 2.56410256%;">
       <h1 class="card-heading simple card-heading-nopadding card-heading-noborder card-heading-blue" style="margin-bottom: 10px">
         % if oozie_bundle:
           ${ _('Bundle') } <a href="${ oozie_bundle.get_absolute_url() }">${ oozie_bundle.appName }</a> :

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/ko.common-dashboard.js

@@ -69,7 +69,7 @@ var Row = function (widgets, vm, columns) {
   self.columns = ko.observableArray(columns ? columns : []);
   self.columns.subscribe(function (val) {
     self.columns().forEach(function (col) {
-      col.percWidth((100 - self.columns().length * 2.127659574468085) / self.columns().length);
+      col.percWidth((100 - self.columns().length * BOOTSTRAP_RATIOS.MARGIN()) / self.columns().length);
     });
   });
 

+ 30 - 0
desktop/core/src/desktop/templates/common_header_footer_components.mako

@@ -30,6 +30,36 @@ from metadata.conf import has_optimizer, OPTIMIZER
     var IS_S3_ENABLED = '${ is_s3_enabled }' === 'True';
     var HAS_OPTIMIZER = '${ has_optimizer() }' === 'True';
 
+    var BOOTSTRAP_RATIOS = {
+      SPAN3: function () {
+        var _w = $(window).width();
+        if (_w >= 1200) {
+          return 23.07692308;
+        }
+        else if (_w >= 768 && _w <= 979) {
+          return 22.9281768;
+        }
+        else {
+          return 23.17073171;
+        }
+      },
+      SPAN9: function () {
+        var _w = $(window).width();
+        if (_w >= 1200) {
+          return 74.35897436;
+        }
+        else if (_w >= 768 && _w <= 979) {
+          return 74.30939227;
+        }
+        else {
+          return 74.3902439;
+        }
+      },
+      MARGIN: function () {
+        return 2.56410256;
+      }
+    };
+
     var CACHEABLE_TTL = {
       default: ${ conf.CUSTOM.CACHEABLE_TTL.get() },
       optimizer: ${ OPTIMIZER.CACHEABLE_TTL.get() }

+ 6 - 9
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -3332,12 +3332,9 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
       }
 
       function resetResultsResizer(snippet) {
-        var span3Width = 23.404255319148934;
-        var span9Width = 74.46808510638297;
-
-        $("#snippet_" + snippet.id()).find('.table-results .column-side').width(span3Width + '%').data('newWidth', span3Width);
+        $("#snippet_" + snippet.id()).find('.table-results .column-side').width(BOOTSTRAP_RATIOS.SPAN3() + '%').data('newWidth', BOOTSTRAP_RATIOS.SPAN3());
         if (snippet.isResultSettingsVisible()){
-          $("#snippet_" + snippet.id()).find('.table-results .grid-side').data('newWidth', span9Width).width(span9Width + '%');
+          $("#snippet_" + snippet.id()).find('.table-results .grid-side').data('newWidth', BOOTSTRAP_RATIOS.SPAN9()).width(BOOTSTRAP_RATIOS.SPAN9() + '%');
         }
         else {
           $("#snippet_" + snippet.id()).find('.table-results .grid-side').data('newWidth', 100).width('100%');
@@ -3355,7 +3352,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
           containment: $("#snippet_" + snippet.id()).find('.table-results'),
           create: function (event, ui) {
             initialPosition = $("#snippet_" + snippet.id()).find('.resize-bar').position().left;
-            $("#snippet_" + snippet.id()).find('.table-results .column-side').data('newWidth', span3Width);
+            $("#snippet_" + snippet.id()).find('.table-results .column-side').data('newWidth', BOOTSTRAP_RATIOS.SPAN3());
             $("#snippet_" + snippet.id()).find('.meta-filter').width($("#snippet_" + snippet.id()).find('.table-results .column-side').width() - 28)
           },
           drag: function (event, ui) {
@@ -3363,8 +3360,8 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
               initialPosition = $("#snippet_" + snippet.id()).find('.resize-bar').position().left;
             }
             ui.position.left = Math.max(150, ui.position.left);
-            var newSpan3Width = ui.position.left * span3Width / initialPosition;
-            var newSpan9Width = 100 - newSpan3Width - 2.127659574468085;
+            var newSpan3Width = ui.position.left * BOOTSTRAP_RATIOS.SPAN3() / initialPosition;
+            var newSpan9Width = 100 - newSpan3Width - BOOTSTRAP_RATIOS.MARGIN();
             $("#snippet_" + snippet.id()).find('.table-results .column-side').width(newSpan3Width + '%').data('newWidth', newSpan3Width);
             $("#snippet_" + snippet.id()).find('.table-results .grid-side').width(newSpan9Width + '%').data('newWidth', newSpan9Width);
             $("#snippet_" + snippet.id()).find('.meta-filter').width($("#snippet_" + snippet.id()).find('.table-results .column-side').width() - 28)
@@ -3384,7 +3381,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
             scrollInertia: 0
           });
           if (snippet.isResultSettingsVisible()){
-            $("#snippet_" + snippet.id()).find('.table-results .grid-side').width((100 - $("#snippet_" + snippet.id()).find('.table-results .column-side').data('newWidth') - 2.127659574468085) + '%');
+            $("#snippet_" + snippet.id()).find('.table-results .grid-side').width((100 - $("#snippet_" + snippet.id()).find('.table-results .column-side').data('newWidth') - BOOTSTRAP_RATIOS.MARGIN()) + '%');
           }
           else {
             $("#snippet_" + snippet.id()).find('.table-results .grid-side').width('100%');