Browse Source

HUE-140. Filter Work - Creating DataGroupToggle Behavior filter, and removing NoOverflow and SideBySideSelect JFrame filters

Marcus McLaughlin 15 years ago
parent
commit
c6c666c915

+ 1 - 5
apps/filebrowser/src/filebrowser/static/js/Source/FileBrowser/CCS.FileEditor.js

@@ -111,7 +111,7 @@ CCS.FileEditor = new Class({
 		});
 		this.addEvents({
 			load: function(){
-				this.addEvent('resize', this.resizeTextarea.bind(this));
+				this.jframe.addEvent('resize', this.resizeTextarea.bind(this));
 				$(this.jframe).setStyle('overflow', 'hidden');
 			}.bind(this)
 		});
@@ -123,10 +123,6 @@ CCS.FileEditor = new Class({
 			width: w - 20,
 			height: h
 		});
-		this.divResize.setStyles({
-			width: w,
-			height: h
-		});
 	}
 
 });

+ 2 - 2
apps/filebrowser/src/filebrowser/templates/edit.mako

@@ -40,11 +40,11 @@
     % endfor
   </div>
 % endif
-<form class="no_overflow fe-editForm" method="post" action="${url('filebrowser.views.save_file')}">
+<form class="fe-editForm" method="post" action="${url('filebrowser.views.save_file')}">
     ${edit.render_field(form["path"], hidden=True, notitle=True)}
     ${edit.render_field(form["encoding"], hidden=True, notitle=True)}
     <h2 class="ccs-hidden">${form["contents"].label_tag() | n}</h2>
-    <div class="fe-divResize">${unicode(form["contents"]) | n}</div>
+    <div class="fe-divResize" data-filters="SizeTo">${unicode(form["contents"]) | n}</div>
     <input class="ccs-hidden" type="submit" name="save" value="saveAs">
     <input class="ccs-hidden" type="submit" name="save" value="save">
 </form>

+ 84 - 0
desktop/core/static/js/Source/BehaviorFilters/Behavior.DataGroupToggle.js

@@ -0,0 +1,84 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+/*
+---
+description: Toggles the display of a group of elements when an element with DataGroupToggle in its data-filters property is clicked or changed 
+provides: [Behavior.DataGroupToggle]
+requires: [Widgets/Behavior, Widgets/Element.Data]
+script: Behavior.DataGroupToggle.js
+
+...
+*/
+
+Behavior.addGlobalFilters({
+	DataGroupToggle: function(element, methods){
+                container = methods.getContentElement();
+                var selectHandler = function(event) {
+                        var selected = element.getSelected()[0];
+                        var toggleData = selected.get('data', 'group-toggle', true);
+                        if(!toggleData) {
+                                dbug.warn("data-group-toggle either not present or unparseable.");
+                                return;
+                        }
+                        var sections = container.getElements(toggleData.group);
+                        if(!sections.length) {
+                                dbug.warn("Search using data-group-toggle[group] as selector returned no elements.");
+                                return;
+                        }
+                        var show = container.getElements(toggleData.show);
+                        if(!show.length) {
+                                dbug.warn("Search using data-group-toggle[show] as selector returned no elements.");
+                                return;
+                        }
+                        sections.each(function(section) {
+                                section.setStyle('display', show.contains(section) ? 'block' : 'none');
+                        });
+                };
+                var linkHandler = function(event) {
+                        var toggleData = element.get('data', 'group-toggle', true);
+                        if(!toggleData) {
+                                dbug.warn("data-group-toggle either not present or unparseable.");
+                                return;
+                        } 
+                        var sections = container.getElements(toggleData.group);
+                        if(!sections.length) {
+                                dbug.warn("Search using data-group-toggle[group] as selector returned no elements.");
+                                return;
+                        }
+                        var show = container.getElements(toggleData.show);
+                        if(!show.length) {
+                                dbug.warn("search using data-group-toggle[show] as selector returned no elements.");
+                                return;
+                        }
+                        sections.each(function(section) {
+                                section.setStyle('display', show.contains(section) ? 'block' : 'none');
+                        });
+                };
+                if(element.tagName == 'SELECT') {
+                        element.addEvent('change', selectHandler);
+                        this.markForCleanup(element, function(){
+                                element.removeEvent('change', selectHandler);
+                        });
+                } else {
+                        element.addEvent('click', linkHandler);
+                        this.markForCleanup(element, function(){
+                                element.removeEvent('click', linkHandler);
+                        }); 
+                }
+	}
+
+});
+

+ 0 - 1
desktop/core/static/js/Source/CCS/CCS.JBrowser.js

@@ -39,7 +39,6 @@ requires:
  - /CCS.JFrame.HtmlTable
  - /CCS.JFrame.Input
  - /CCS.JFrame.Nav
- - /CCS.JFrame.NoOverflow
  - /CCS.JFrame.OverText
  - /CCS.JFrame.PartialRefresh
  - /CCS.JFrame.Prompt

+ 1 - 0
desktop/core/static/js/Source/CCS/CCS.JFrame.js

@@ -39,6 +39,7 @@ requires:
  - Widgets/Behavior.OverText
  - Widgets/Behavior.SplitView
  - /Behavior.ContextMenu
+ - /Behavior.DataGroupToggle
  - /Behavior.FilterInput
  - /Behavior.FitText
  - /Behavior.HtmlTableChromeHack

+ 0 - 79
desktop/core/static/js/Source/JFrameFilters/CCS.JFrame.DataGroupToggle.js

@@ -1,79 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-/*
----
-description: Toggles the display of a group of elements when another is clicked or changed 
-provides: [CCS.JFrame.DataGroupToggle]
-requires: [/CCS.JFrame, Widgets/Element.Data]
-script: CCS.JFrame.DataGroupToggle.js
-
-...
-*/
-
-CCS.JFrame.addGlobalFilters({
-	dataGroupToggle : function(container){
-		if(!container.get('html').contains('ccs-group_toggle')) return;
-		var toggles = container.getElements('.ccs-group_toggle');
-		toggles.each(function(toggle) {
-			if(toggle.tagName == 'SELECT') {
-				toggle.addEvent('change', function(event) {
-					var selected = toggle.getSelected()[0];
-					var toggleData = selected.get('data', 'group-toggle', true);
-					if(!toggleData) {
-						dbug.warn("data-group-toggle either not present or unparseable.");
-						return;
-					}
-					var sections = container.getElements(toggleData.group);
-					if(!sections) {
-						dbug.warn("Search using data-group-toggle[group] as selector returned no elements.");
-						return;
-					}
-					var show = container.getElements(toggleData.show);
-					if(!show) {
-						dbug.warn("Search using data-group-toggle[show] as selector returned no elements.");
-						return;
-					}
-					sections.each(function(section) {
-						section.setStyle('display', show.contains(section) ? 'block' : 'none');
-					});
-				});
-			} else {
-				toggle.addEvent('click', function(event) {
-					var toggleData = toggle.get('data', 'group-toggle', true);
-					if(!toggleData) {
-						dbug.warn("data-group-toggle either not present or unparseable.");
-						return;
-					} 
-					var sections = container.getElements(toggleData.group);
-					if(!sections) {
-						dbug.warn("Search using data-group-toggle[group] as selector returned no elements.");
-						return;
-					}
-					var show = container.getElements(toggleData.show);
-					if(!show) {
-						dbug.warn("search using data-group-toggle[show] as selector returned no elements.");
-						return;
-					}
-					sections.each(function(section) {
-						section.setStyle('display', show.contains(section) ? 'block' : 'none');
-					});
-				});
-			}
-		});
-	}
-
-});
-

+ 25 - 0
desktop/core/static/js/Source/JFrameFilters/CCS.JFrame.Deprecated.js

@@ -22,6 +22,7 @@ provides: [
  CCS.JFrame.DeprecatedFilters,
  CCS.JFrame.ContextMenu,
  CCS.JFrame.ArtButtons,
+ CCS.JFrame.DataGroupToggle,
  CCS.JFrame.FilterInput,
  CCS.JFrame.FitText,
  CCS.JFrame.FormValidator,
@@ -29,6 +30,7 @@ provides: [
  CCS.JFrame.Input,
  CCS.JFrame.OverText,
  CCS.JFrame.SelectWithOther,
+ CCS.JFrame.SideBySideSelect,
  CCS.JFrame.SizeTo,
  CCS.JFrame.SplitView,
  CCS.JFrame.SubmitOnChange,
@@ -199,7 +201,30 @@ script: CCS.JFrame.ArtButtons.js
                                 dbug.warn('you are using a deprecated JFrame filter (ccs-select-with-other) on %o, use the SelectWithOther data-fitler instead.', el);
                                 el.addDataFilter('SelectWithOther');
                         });
+                },
+
+                side_by_side_select: function(container) {
+                        if (!container.get('html').contains('side_by_side_select')) return;
+                        //get the side by side containers
+                        container.getElements('.side_by_side_select').each(function(select) {
+                                //if the element with the side_by_side class is the container of the select, get the 
+                                //select element within it.
+                                if (select && select.get('tag') != "select") select = select.getElement('select');
+                                dbug.warn('you are using a deprecated JFrame filter (side_by_side_select) on %o, use the SideBySideSelect data-filter instead.', select);
+                                select.addDataFilter('SideBySideSelect');
+                        });
+                },
+
+                data_group_toggle : function(container){
+                        if(!container.get('html').contains('ccs-group_toggle')) return;
+                        var toggles = container.getElements('.ccs-group_toggle');
+                        toggles.each(function(toggle) {
+                                dbug.warn("you are using a deprecated JFrameFilter (ccs-group_toggle) on %o, use the DataGroupToggle data-filters propery instead.", toggle);
+                                toggle.addDataFilter('DataGroupToggle');
+                        });
                 }
+
+
 	});
 
 })();

+ 0 - 37
desktop/core/static/js/Source/JFrameFilters/CCS.JFrame.NoOverflow.js

@@ -1,37 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-/*
----
-description: If any element loaded by JFrame has the css class .no_overflow, the jframe wrapper is set to have an overflow value of 'none'.
-provides: [CCS.JFrame.NoOverflow]
-requires: [/CCS.JFrame]
-script: CCS.JFrame.NoOverflow.js
-
-...
-*/
-
-
-CCS.JFrame.addGlobalFilters({
-
-	noOverflow: function(container){
-		//if the container has the class no_overflow, or an element within it has the no_overflow class
-		//set the content to have no overflow; you must handle the overflow in your own css/js
-		if (container.hasClass('no_overflow') || container.getElement('.no_overflow')) {
-			this.element.setStyle('overflow', 'hidden');
-		}
-	}
-
-});

+ 0 - 40
desktop/core/static/js/Source/JFrameFilters/CCS.JFrame.SideBySideSelect.js

@@ -1,40 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-/*
----
-description: Configures ART.SideBySideSelect instances for JFrame content.
-provides: [CCS.JFrame.SideBySideSelect]
-requires: [/CCS.JFrame, /ART.SideBySideSelect]
-script: CCS.JFrame.SideBySideSelect.js
-
-...
-*/
-
-CCS.JFrame.addGlobalFilters({
-
-	side_by_side_select: function(container) {
-		if (!container.get('html').contains('side_by_side_select')) return;
-		//get the side by side containers
-		return container.getElements('.side_by_side_select').map(function(select) {
-			//if the element with the side_by_side class is the container of the select, get the 
-			//select element within it.
-			if (select && select.get('tag') != "select") select = select.getElement('select');
-			dbug.warn('you are using a deprecated JFrame filter (side_by_side_select) on %o, use the SideBySideSelect data-filter instead.', select);
-			select.addDataFilter('SideBySideSelect');
-		}, this);
-	}
-
-});

+ 1 - 3
desktop/core/static/js/package.yml

@@ -2,14 +2,12 @@ copyright: Apache License v2.0
 description: Shared components for Hue
 name: ccs-shared
 sources: [
-  Source/JFrameFilters/CCS.JFrame.NoOverflow.js,
   Source/JFrameFilters/CCS.JFrame.FormRequest.js,
   Source/JFrameFilters/CCS.JFrame.Clearfix.js,
   Source/JFrameFilters/CCS.JFrame.AutoRefresh.js,
   Source/JFrameFilters/CCS.JFrame.DoubleClickDelegate.js,
   Source/JFrameFilters/CCS.JFrame.Collapsible.js,
   Source/JFrameFilters/CCS.JFrame.ToggleHistory.js,
-  Source/JFrameFilters/CCS.JFrame.DataGroupToggle.js,
   Source/JFrameFilters/CCS.JFrame.Deprecated.js,
   Source/Fx/Fx.Shake.js,
   Source/JFrameRenderers/CCS.JFrame.Alert.js,
@@ -31,7 +29,6 @@ sources: [
   Source/CCS/CCS.Desktop.Keys.js,
   Source/CCS/CCS.User.js,
   Source/CCS/CCS.Login.js,
-  Source/JFrameFilters/CCS.JFrame.SideBySideSelect.js,
   Source/Forms/Form.Request.JSON.js,
   Source/Forms/EditInline.js,
   Source/UI/StickyWin.Drawer.js,
@@ -52,6 +49,7 @@ sources: [
   Source/CCS/CCS.PostEditor.Simple.js,
   Source/UI/ART.SideBySideSelect.js,
   Source/BehaviorFilters/Behavior.ContextMenu.js,
+  Source/BehaviorFilters/Behavior.DataGroupToggle.js,
   Source/BehaviorFilters/Behavior.FilterInput.js,
   Source/BehaviorFilters/Behavior.FitText.js,
   Source/BehaviorFilters/Behavior.HtmlTableChromeHack.js,