Repository: flex-asjs Updated Branches: refs/heads/develop c4811e365 -> 72b15bb39
A set of FlexJS components for mobile devices which handle basic stack and tab navigation. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/72b15bb3 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/72b15bb3 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/72b15bb3 Branch: refs/heads/develop Commit: 72b15bb392cf0925d286c623433ae79647d28b6c Parents: c4811e3 Author: Peter Ent <[email protected]> Authored: Wed Mar 11 14:10:18 2015 -0400 Committer: Peter Ent <[email protected]> Committed: Wed Mar 11 14:10:18 2015 -0400 ---------------------------------------------------------------------- .../as/projects/FlexJSJX/basic-manifest.xml | 7 + frameworks/as/projects/FlexJSJX/defaults.css | 10 + .../as/projects/FlexJSJX/src/FlexJSJXClasses.as | 6 + .../src/org/apache/flex/mobile/IView.as | 43 +++ .../src/org/apache/flex/mobile/IViewManager.as | 42 +++ .../apache/flex/mobile/StackedViewManager.as | 285 +++++++++++++++++++ .../org/apache/flex/mobile/TabbedViewManager.as | 249 ++++++++++++++++ .../FlexJSJX/src/org/apache/flex/mobile/View.as | 68 +++++ .../flex/mobile/beads/StackedViewManagerView.as | 184 ++++++++++++ .../flex/mobile/beads/TabbedViewManagerView.as | 184 ++++++++++++ .../apache/flex/mobile/chrome/NavigationBar.as | 103 +++++++ .../src/org/apache/flex/mobile/chrome/TabBar.as | 80 ++++++ .../org/apache/flex/mobile/chrome/ToolBar.as | 81 ++++++ .../flex/mobile/models/ViewManagerModel.as | 257 +++++++++++++++++ .../as/projects/FlexJSUI/src/FlexJSUIClasses.as | 3 + .../flex/html/beads/BackgroundImageBead.as | 112 ++++++++ .../apache/flex/html/beads/CSSTextButtonView.as | 4 + .../org/apache/flex/html/beads/ContainerView.as | 10 +- .../src/org/apache/flex/mobile/ManagerBase.as | 139 +++++++++ .../FlexJS/src/org/apache/flex/core/IChrome.js | 31 ++ .../src/org/apache/flex/core/UIMetrics.js | 51 ++++ .../src/org/apache/flex/mobile/ManagerBase.js | 128 +++++++++ .../src/org/apache/flex/utils/BeadMetrics.js | 48 ++++ 23 files changed, 2124 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/basic-manifest.xml b/frameworks/as/projects/FlexJSJX/basic-manifest.xml index 92f3700..fcbf10f 100644 --- a/frameworks/as/projects/FlexJSJX/basic-manifest.xml +++ b/frameworks/as/projects/FlexJSJX/basic-manifest.xml @@ -21,6 +21,13 @@ <componentPackage> + <component id="StackedViewManager" class="org.apache.flex.mobile.StackedViewManager" /> + <component id="TabbedViewManager" class="org.apache.flex.mobile.TabbedViewManager" /> + <component id="View" class="org.apache.flex.mobile.View" /> + <component id="NavigationBar" class="org.apache.flex.mobile.chrome.NavigationBar" /> + <component id="ToolBar" class="org.apache.flex.mobile.chrome.ToolBar" /> + <component id="TabBar" class="org.apache.flex.mobile.chrome.TabBar" /> + <component id="DataGrid" class="org.apache.flex.html.DataGrid"/> <component id="DataGridColumn" class="org.apache.flex.html.supportClasses.DataGridColumn"/> <component id="DataGridLayout" class="org.apache.flex.html.beads.layouts.DataGridLayout" /> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/defaults.css ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/defaults.css b/frameworks/as/projects/FlexJSJX/defaults.css index 4ba635b..1cbc544 100644 --- a/frameworks/as/projects/FlexJSJX/defaults.css +++ b/frameworks/as/projects/FlexJSJX/defaults.css @@ -19,6 +19,16 @@ @namespace "library://ns.apache.org/flexjs/basic"; +StackedViewManager { + IBeadModel: ClassReference("org.apache.flex.mobile.models.ViewManagerModel"); + IBeadView: ClassReference("org.apache.flex.mobile.beads.StackedViewManagerView"); +} + +TabbedViewManager { + IBeadModel: ClassReference("org.apache.flex.mobile.models.ViewManagerModel"); + IBeadView: ClassReference("org.apache.flex.mobile.beads.TabbedViewManagerView"); +} + BarChart { IBeadModel: ClassReference("org.apache.flex.html.beads.models.ArraySelectionModel"); http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as b/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as index 06fa320..9454aad 100644 --- a/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as +++ b/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as @@ -27,6 +27,12 @@ package */ internal class FlexJSJXClasses { + import org.apache.flex.mobile.beads.StackedViewManagerView; StackedViewManagerView; + import org.apache.flex.mobile.beads.TabbedViewManagerView; TabbedViewManagerView; + import org.apache.flex.mobile.chrome.NavigationBar; NavigationBar; + import org.apache.flex.mobile.chrome.TabBar; TabBar; + import org.apache.flex.mobile.chrome.ToolBar; ToolBar; + import org.apache.flex.mobile.models.ViewManagerModel; ViewManagerModel; import org.apache.flex.charts.beads.ChartView; ChartView; import org.apache.flex.charts.beads.ChartItemRendererFactory; ChartItemRendererFactory; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/IView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/IView.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/IView.as new file mode 100644 index 0000000..232d212 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/IView.as @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile +{ + /** + * The IView interface is implemented by any class that can be managed by + * an IViewManager. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface IView + { + /** + * The parent view manager. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + function get viewManager():IViewManager; + function set viewManager(value:IViewManager):void; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/IViewManager.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/IViewManager.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/IViewManager.as new file mode 100644 index 0000000..54bb22a --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/IViewManager.as @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile +{ + /** + * The IViewManager interface is implemented by classes that manage or control + * IViews. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface IViewManager extends IView + { + /** + * The view that is currently active in the view manager. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + function get selectedView():IView; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/StackedViewManager.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/StackedViewManager.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/StackedViewManager.as new file mode 100644 index 0000000..58dd312 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/StackedViewManager.as @@ -0,0 +1,285 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile +{ + import org.apache.flex.events.Event; + import org.apache.flex.mobile.ManagerBase; + import org.apache.flex.mobile.chrome.NavigationBar; + import org.apache.flex.mobile.chrome.ToolBar; + import org.apache.flex.mobile.models.ViewManagerModel; + + /** + * Event dispatched when the currently selected view changes. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event("viewChanged")] + + /** + * The StackedViewManager displays a single View at a time from a + * collection of Views where views[0] is at the bottom and views[n-1] + * is at the top and displayed. + * + * The StackedViewManager has an optional navigation bar at the top + * and an optional tool bar at the bottom. The views are displayed + * within the StackedViewManager's content area. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class StackedViewManager extends ManagerBase implements IViewManager + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function StackedViewManager() + { + super(); + + className = "StackedViewManager"; + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + var n:int = ViewManagerModel(model).views.length; + if (n > 0) { + var view:IView = ViewManagerModel(model).views[n-1] as IView; + addElement(view,false); + _topView = view; + } + } + + /** + * The title to use in the NavigationBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get title():String + { + return ViewManagerModel(model).title; + } + public function set title(value:String):void + { + ViewManagerModel(model).title = value; + } + + /** + * @private + */ + override public function toString():String + { + return ViewManagerModel(model).title; + } + + /** + * True if this view manager is displaying a NavigationBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get hasNavigationBar():Boolean + { + return ViewManagerModel(model).navigationBarItems != null; + } + + /** + * The contents of the NavigationBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get navigationBarItems():Array + { + return ViewManagerModel(model).navigationBarItems; + } + public function set navigationBarItems(value:Array):void + { + ViewManagerModel(model).navigationBarItems = value; + } + + /** + * The NavigationBar (or null if not present). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get navigationBar():NavigationBar + { + return ViewManagerModel(model).navigationBar; + } + + /** + * True if this view manager is displaying a ToolBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get hasToolBar():Boolean + { + return ViewManagerModel(model).toolBarItems != null; + } + + /** + * The contents of the ToolBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get toolBarItems():Array + { + return ViewManagerModel(model).toolBarItems; + } + public function set toolBarItems(value:Array):void + { + ViewManagerModel(model).toolBarItems = value; + } + + /** + * The ToolBar (or null if not present). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get toolBar():ToolBar + { + return ViewManagerModel(model).toolBar; + } + + private var _topView:IView; + + /** + * The top-most (current) view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedView():IView + { + return _topView; + } + + /** + * The current set of views in the stack. The last entry is + * the top-most (visible) view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get views():Array + { + return ViewManagerModel(model).views; + } + public function set views(value:Array):void + { + ViewManagerModel(model).views = value; + } + + /** + * Pushes the next view onto the navigation stack. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function push(nextView:IView):void + { + nextView.viewManager = this; + ViewManagerModel(model).pushView(nextView); + + removeElement(_topView); + _topView = nextView; + addElement(_topView); + + dispatchEvent( new Event("viewChanged") ); + } + /** + * Pops the top-most view from the navigation stack. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function pop():void + { + if (ViewManagerModel(model).views.length > 1) { + var lastView:Object = ViewManagerModel(model).popView(); + removeElement(_topView); + addElement(lastView); + _topView = lastView as IView; + + dispatchEvent( new Event("viewChanged") ); + } + } + + private var _viewManager:IViewManager; + + /** + * This view manager's parent view manager, if any. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get viewManager():IViewManager + { + return _viewManager; + } + public function set viewManager(value:IViewManager):void + { + _viewManager = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/TabbedViewManager.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/TabbedViewManager.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/TabbedViewManager.as new file mode 100644 index 0000000..2c9665e --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/TabbedViewManager.as @@ -0,0 +1,249 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile +{ + import org.apache.flex.events.Event; + import org.apache.flex.mobile.ManagerBase; + import org.apache.flex.mobile.chrome.NavigationBar; + import org.apache.flex.mobile.chrome.TabBar; + import org.apache.flex.mobile.chrome.ToolBar; + import org.apache.flex.mobile.models.ViewManagerModel; + + /** + * Event dispatched when the current (selected) view changes. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="viewChanged")] + + /** + * The TabbedViewManager displays a set of views, only one of which is active at + * a time. The other views are reachable via a set of tab buttons at the bottom of + * the view manager's space. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TabbedViewManager extends ManagerBase implements IViewManager + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TabbedViewManager() + { + super(); + + className = "TabbedViewManager"; + + model.addEventListener("selectedIndexChanged", changeView); + } + + /** + * A title that can be used in the NavigationBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get title():String + { + return ViewManagerModel(model).title; + } + public function set title(value:String):void + { + ViewManagerModel(model).title = value; + } + + /** + * @private + */ + override public function toString():String + { + return ViewManagerModel(model).title; + } + + /** + * True if this view manager instance is displaying a NavigationBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get hasNavigationBar():Boolean + { + return ViewManagerModel(model).navigationBarItems != null; + } + + /** + * The items that make up the NavigationBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get navigationBarItems():Array + { + return ViewManagerModel(model).navigationBarItems; + } + public function set navigationBarItems(value:Array):void + { + ViewManagerModel(model).navigationBarItems = value; + } + + /** + * The NavigationBar (or null if not present). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get navigationBar():NavigationBar + { + return ViewManagerModel(model).navigationBar; + } + + /** + * The TabBar (or null if not present). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get tabBar():TabBar + { + return ViewManagerModel(model).tabBar; + } + + /** + * The index (starting at zero) of the currently visible view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedIndex():Number + { + return ViewManagerModel(model).selectedIndex; + } + public function set selectedIndex(value:Number):void + { + ViewManagerModel(model).selectedIndex = value; + } + + private var _currentView:IView; + + /** + * The currently visible view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedView():IView + { + return _currentView; + } + + /** + * The current set of views in the stack. The last entry is + * the top-most (visible) view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get views():Array + { + return ViewManagerModel(model).views; + } + public function set views(value:Array):void + { + ViewManagerModel(model).views = value; + } + + /** + * @private + */ + private function changeView( event:Event ):void + { + var index:Number = ViewManagerModel(model).selectedIndex; + if (_currentView) { + removeElement(_currentView); + } + _currentView = views[index]; + addElement(_currentView); + + dispatchEvent( new Event("viewChanged") ); + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + var n:int = ViewManagerModel(model).views.length; + if (n > 0) { + ViewManagerModel(model).selectedIndex = 0; + } + } + + /** + * IViewManager + */ + + private var _viewManager:IViewManager; + + /** + * This view manager's parent view manager, if any. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get viewManager():IViewManager + { + return _viewManager; + } + public function set viewManager(value:IViewManager):void + { + _viewManager = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/View.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/View.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/View.as new file mode 100644 index 0000000..6b355f1 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/View.as @@ -0,0 +1,68 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile +{ + import org.apache.flex.core.IUIBase; + import org.apache.flex.html.Container; + + /** + * The View class represents the area for a mobile app's primary + * interface elements. + */ + public class View extends Container implements IView + { + public function View() + { + super(); + } + + private var _title:String; + public function get title():String + { + return _title; + } + public function set title(value:String):void + { + _title = value; + } + + override public function toString():String + { + return _title; + } + + private var _viewManager:IViewManager; + public function get viewManager():IViewManager + { + return _viewManager; + } + public function set viewManager(value:IViewManager):void + { + _viewManager = value; + } + + override public function addedToParent():void + { + super.addedToParent(); +// this.width = this.viewManager.contentWidth; +// this.height = this.viewManager.contentHeight; +// trace("Set View to "+this.width+"x"+this.height); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/beads/StackedViewManagerView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/beads/StackedViewManagerView.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/beads/StackedViewManagerView.as new file mode 100644 index 0000000..1d3ae57 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/beads/StackedViewManagerView.as @@ -0,0 +1,184 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile.beads +{ + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.events.Event; + import org.apache.flex.html.beads.layouts.NonVirtualHorizontalLayout; + import org.apache.flex.mobile.ManagerBase; + import org.apache.flex.mobile.chrome.NavigationBar; + import org.apache.flex.mobile.chrome.ToolBar; + import org.apache.flex.mobile.models.ViewManagerModel; + + /** + * The StackedViewManagerView creates the visual elements of the StackedViewManager. This + * includes a NavigationBar, ToolBar, and contentArea. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class StackedViewManagerView implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function StackedViewManagerView() + { + super(); + + layoutReady = false; + } + + private var _navigationBar:NavigationBar; + private var _toolBar:ToolBar; + + private var layoutReady:Boolean; + + private var _strand:ManagerBase; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + _strand = value as ManagerBase; + _strand.addEventListener("widthChanged", changeHandler); + _strand.addEventListener("heightChanged", changeHandler); + + var model:ViewManagerModel = value.getBeadByType(IBeadModel) as ViewManagerModel; + model.addEventListener("viewsChanged", handleModelChanged); + model.addEventListener("viewPushed", handleModelChanged); + model.addEventListener("viewPopped", handleModelChanged); + + if (model.navigationBarItems) + { + _navigationBar = new NavigationBar(); + _navigationBar.controls = model.navigationBarItems; + _navigationBar.addBead(new NonVirtualHorizontalLayout()); + _strand.addElement(_navigationBar); + } + + if (model.toolBarItems) + { + _toolBar = new ToolBar(); + _toolBar.controls = model.toolBarItems; + _toolBar.addBead(new NonVirtualHorizontalLayout()); + _strand.addElement(_toolBar); + } + + layoutReady = true; + layoutChromeElements(); + } + + /** + * @private + */ + private function layoutChromeElements():void + { + var contentAreaY:Number = 0; + var contentAreaHeight:Number = _strand.height; + + var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel; + + if (_navigationBar) + { + _navigationBar.x = 0; + _navigationBar.y = 0; + _navigationBar.width = _strand.width; + + contentAreaY = _navigationBar.height; + contentAreaHeight -= _navigationBar.height; + + model.navigationBar = _navigationBar; + } + + if (_toolBar) + { + _toolBar.x = 0; + _toolBar.y = _strand.height - _toolBar.height; + _toolBar.width = _strand.width; + + contentAreaHeight -= _toolBar.height; + + model.toolBar = _toolBar; + } + + _strand.contentArea.x = 0; + _strand.contentArea.y = contentAreaY; + _strand.contentArea.width = _strand.width; + _strand.contentArea.height = contentAreaHeight; + } + + + /** + * @private + */ + protected function changeHandler(event:Event):void + { + if (layoutReady) layoutChromeElements(); + } + + /** + * @private + */ + private function handleModelChanged(event:Event):void + { + trace("Model event: "+event.type); + } + + /** + * @private + */ + public function get host():IUIBase + { + return _strand; + } + + /** + * @private + */ + public function get viewWidth():Number + { + return _strand.width; + } + + /** + * @private + */ + public function get viewHeight():Number + { + return _strand.height; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/beads/TabbedViewManagerView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/beads/TabbedViewManagerView.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/beads/TabbedViewManagerView.as new file mode 100644 index 0000000..e5652c8 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/beads/TabbedViewManagerView.as @@ -0,0 +1,184 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile.beads +{ + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.events.Event; + import org.apache.flex.html.beads.layouts.NonVirtualHorizontalLayout; + import org.apache.flex.mobile.ManagerBase; + import org.apache.flex.mobile.chrome.NavigationBar; + import org.apache.flex.mobile.chrome.TabBar; + import org.apache.flex.mobile.models.ViewManagerModel; + + /** + * The TabbedViewManagerView constructs the visual elements of the TabbedViewManager. The + * elements may be a navigation bar, a tab bar, and the contentArea. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TabbedViewManagerView implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TabbedViewManagerView() + { + super(); + layoutReady = false; + } + + private var _navigationBar:NavigationBar; + private var _tabBar:TabBar; + + private var layoutReady:Boolean; + + private var _strand:ManagerBase; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + _strand = value as ManagerBase; + _strand.addEventListener("widthChanged", changeHandler); + _strand.addEventListener("heightChanged", changeHandler); + + var model:ViewManagerModel = value.getBeadByType(IBeadModel) as ViewManagerModel; + model.addEventListener("viewsChanged", changeHandler); + + if (model.navigationBarItems) + { + _navigationBar = new NavigationBar(); + _navigationBar.controls = model.navigationBarItems; + _navigationBar.addBead(new NonVirtualHorizontalLayout()); + _strand.addElement(_navigationBar); + } + + // TabbedViewManager always has a TabBar + _tabBar = new TabBar(); + _tabBar.dataProvider = model.views; + _tabBar.labelField = "title"; + _strand.addElement(_tabBar); + _tabBar.addEventListener("change",handleButtonBarChange); + + layoutReady = true; + layoutChromeElements(); + } + + /** + * @private + */ + private function layoutChromeElements():void + { + var contentAreaY:Number = 0; + var contentAreaHeight:Number = _strand.height; + + var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel; + + if (_navigationBar) + { + _navigationBar.x = 0; + _navigationBar.y = 0; + _navigationBar.width = _strand.width; + + contentAreaY = _navigationBar.height; + contentAreaHeight -= _navigationBar.height; + + model.navigationBar = _navigationBar; + } + + if (_tabBar) + { + _tabBar.x = 0; + _tabBar.y = _strand.height - _tabBar.height; + _tabBar.width = _strand.width; + + contentAreaHeight -= _tabBar.height; + + model.tabBar = _tabBar; + } + + _strand.contentArea.x = 0; + _strand.contentArea.y = contentAreaY; + _strand.contentArea.width = _strand.width; + _strand.contentArea.height = contentAreaHeight; + } + + /** + * @private + */ + protected function changeHandler(event:Event):void + { + if (layoutReady) layoutChromeElements(); + } + + /** + * @private + */ + private function handleButtonBarChange(event:Event):void + { + var newIndex:Number = _tabBar.selectedIndex; + var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel; + + // doing this will trigger the selectedIndexChanged event which will + // tell the strand to switch views + model.selectedIndex = newIndex; + } + + /** + * @private + */ + public function get host():IUIBase + { + return _strand; + } + + /** + * @private + */ + public function get viewWidth():Number + { + return _strand.width; + } + + /** + * @private + */ + public function get viewHeight():Number + { + return _strand.height; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/NavigationBar.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/NavigationBar.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/NavigationBar.as new file mode 100644 index 0000000..5e7873e --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/NavigationBar.as @@ -0,0 +1,103 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile.chrome +{ + import org.apache.flex.core.IChrome; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.Container; + + /** + * The NavigationBar class is part of the mobile view manager's chrome. When present, + * it provides a place for content at the top of the view, above the contentArea. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class NavigationBar extends Container implements IChrome + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function NavigationBar() + { + super(); + + className = "NavigationBar"; + } + + public function hidesBackButton(value:Boolean):void + { + + } + + private var _controls:Array; + + /** + * The controls of the NavigationBar (eg, a button to go back and a title). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set controls(value:Array):void + { + _controls = value; + } + public function get controls():Array + { + return _controls; + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + for (var i:int=0; i < _controls.length; i++) + { + addElement( _controls[i], false ); + + var ctrl:IEventDispatcher = _controls[i] as IEventDispatcher; + ctrl.addEventListener("show", handleVisibilityChange); + ctrl.addEventListener("hide", handleVisibilityChange); + } + + dispatchEvent(new Event("layoutNeeded")); + } + + /** + * @private + */ + private function handleVisibilityChange(event:Event):void + { + dispatchEvent(new Event("layoutNeeded")); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/TabBar.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/TabBar.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/TabBar.as new file mode 100644 index 0000000..7ab2047 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/TabBar.as @@ -0,0 +1,80 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile.chrome +{ + import org.apache.flex.core.IChrome; + import org.apache.flex.html.ButtonBar; + + /** + * The TabBar class displays a set of buttons that can be used to + * switch between navigation panels. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TabBar extends ButtonBar implements IChrome + { + /** + * Constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TabBar() + { + super(); + + className = "TabBar"; + } + + /** + * Sets the width of the TabBar. + * + * @param value The new width in pixels. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set width(value:Number):void + { + super.width = value; + } + + /** + * Sets the height of the TabBar. + * + * @param value The new height in pixels. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set height(value:Number):void + { + super.height = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/ToolBar.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/ToolBar.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/ToolBar.as new file mode 100644 index 0000000..6c8c748 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/chrome/ToolBar.as @@ -0,0 +1,81 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile.chrome +{ + import org.apache.flex.core.IBeadLayout; + import org.apache.flex.core.IChrome; + import org.apache.flex.events.Event; + import org.apache.flex.html.Container; + + /** + * The ToolBar class provides a space below the contentArea of a view manager which can + * be used to house controls for the view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ToolBar extends Container implements IChrome + { + public function ToolBar() + { + super(); + + className = "ToolBar"; + } + + private var _controls:Array; + + /** + * The control components of the ToolBar (eg, a settings button). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set controls(value:Array):void + { + _controls = value; + } + public function get controls():Array + { + return _controls; + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + var layout:IBeadLayout = this.getBeadByType(IBeadLayout) as IBeadLayout; + trace("layout = "+layout); + + for (var i:int=0; i < _controls.length; i++) + { + addElement( _controls[i], false ); + } + + dispatchEvent(new Event("layoutNeeded")); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/models/ViewManagerModel.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/models/ViewManagerModel.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/models/ViewManagerModel.as new file mode 100644 index 0000000..faa3936 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/mobile/models/ViewManagerModel.as @@ -0,0 +1,257 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile.models +{ + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.mobile.chrome.NavigationBar; + import org.apache.flex.mobile.chrome.TabBar; + import org.apache.flex.mobile.chrome.ToolBar; + + /** + * The ViewManagerModel houses properties and values common to the components + * which make up view managers. These properties include the title, which view + * is currently active and selected. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ViewManagerModel extends EventDispatcher implements IBeadModel + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ViewManagerModel() + { + super(); + + _views = new Array(); + } + + private var _strand:IStrand; + + public function set strand(value:IStrand):void + { + _strand = value; + } + + private var _views:Array; + + /** + * The array of views displayed in the contentArea of the ViewManager. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get views():Array + { + return _views; + } + public function set views(value:Array):void + { + if (value != _views) { + _views = value; + _selectedIndex = value.length - 1; + dispatchEvent(new Event("viewsChanged")); + } + } + + /** + * Pushes a view onto the top/end of the stack of views. This view becomes + * the active view. Mostly used by the StackedViewManager. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function pushView(value:Object):void + { + _views.push(value); + _selectedIndex = _views.length - 1; + dispatchEvent(new Event("viewPushed")); + } + + /** + * Removes the most recently added view. The next view in the stack becomes the + * active view. Mostly used by StackedViewManager. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function popView():Object + { + if (_views.length > 1) { + var discard:Object = _views.pop(); + _selectedIndex = _views.length - 1; + dispatchEvent(new Event("viewPopped")); + } + return _views[_views.length-1]; + } + + private var _selectedIndex:Number = -1; + + /** + * The index into the views array of the currently active view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedIndex():Number + { + return _selectedIndex; + } + public function set selectedIndex(value:Number):void + { + if (value != _selectedIndex) { + _selectedIndex = value; + dispatchEvent(new Event("selectedIndexChanged")); + } + } + + private var _title:String; + + /** + * The title of the view.. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get title():String + { + return _title; + } + public function set title(value:String):void + { + _title = value; + } + + private var _navigationBarItems:Array; + + /** + * The array of controls that make up the NavigationBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get navigationBarItems():Array + { + return _navigationBarItems; + } + public function set navigationBarItems(value:Array):void + { + _navigationBarItems = value; + } + + private var _navigationBar:NavigationBar; + + /** + * The NavigationBar (or null if not present). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get navigationBar():NavigationBar + { + return _navigationBar; + } + public function set navigationBar(value:NavigationBar):void + { + _navigationBar = value; + } + + private var _toolBarItems:Array; + + /** + * The array of controls that make up the ToolBar.. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get toolBarItems():Array + { + return _toolBarItems; + } + public function set toolBarItems(value:Array):void + { + _toolBarItems = value; + } + + private var _toolBar:ToolBar; + + /** + * The ToolBar (or null if not present). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get toolBar():ToolBar + { + return _toolBar; + } + public function set toolBar(value:ToolBar):void + { + _toolBar = value; + } + + private var _tabBar:TabBar; + + /** + * The TabBar (or null if not present). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get tabBar():TabBar + { + return _tabBar; + } + public function set tabBar(value:TabBar):void + { + _tabBar = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as index f49da88..2886df2 100644 --- a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as +++ b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as @@ -53,6 +53,7 @@ internal class FlexJSUIClasses import org.apache.flex.html.accessories.PasswordInputBead; PasswordInputBead; import org.apache.flex.html.accessories.TextPromptBead; TextPromptBead; import org.apache.flex.html.beads.AlertView; AlertView; + import org.apache.flex.html.beads.BackgroundImageBead; BackgroundImageBead; import org.apache.flex.html.beads.ButtonBarView; ButtonBarView; import org.apache.flex.html.beads.CheckBoxView; CheckBoxView; import org.apache.flex.html.beads.ComboBoxView; ComboBoxView; @@ -143,6 +144,8 @@ internal class FlexJSUIClasses import org.apache.flex.events.DragEvent; DragEvent; import org.apache.flex.events.utils.MouseUtils; MouseUtils; import org.apache.flex.geom.Rectangle; Rectangle; + + import org.apache.flex.mobile.ManagerBase; ManagerBase; import mx.core.ClassFactory; ClassFactory; import mx.states.AddItems; AddItems; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/BackgroundImageBead.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/BackgroundImageBead.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/BackgroundImageBead.as new file mode 100644 index 0000000..bee07e9 --- /dev/null +++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/BackgroundImageBead.as @@ -0,0 +1,112 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import flash.display.Bitmap; + import flash.display.Loader; + import flash.display.LoaderInfo; + import flash.display.Sprite; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.net.URLRequest; + + import org.apache.flex.core.IBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + + /** + * The BackgroundImageBead is used to render an image as the background to any component + * that supports it, such as Container. + * + * Note that this bead is for ActionScript only since CSS/HTML allows this just by specifying + * a background image in the style selector. To use this bead, place a ClassReference to it + * within @media -flex-flash { } group in the CSS declarations. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class BackgroundImageBead implements IBead, IBackgroundBead + { + /** + * Constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function BackgroundImageBead() + { + backgroundSprite = new Sprite(); + } + + private var _strand:IStrand; + private var backgroundSprite:Sprite; + private var bitmap:Bitmap; + private var loader:Loader; + + public function set strand(value:IStrand):void + { + _strand = value; + + setupBackground(backgroundSprite); + } + + /** + * @private + */ + private function setupBackground(sprite:Sprite, state:String = null):void + { + var backgroundImage:Object = ValuesManager.valuesImpl.getValue(_strand, "background-image", state); + if (backgroundImage) + { + loader = new Loader(); + var url:String = backgroundImage as String; + loader.load(new URLRequest(url)); + loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (e:IOErrorEvent):void { + trace(e); + e.preventDefault(); + }); + loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function (e:flash.events.Event):void { + var host:UIBase = UIBase(_strand); + if (bitmap) { + host.removeChild(bitmap); + } + + bitmap = Bitmap(LoaderInfo(e.target).content); + + host.addChildAt(bitmap,0); + + if (isNaN(host.explicitWidth) && isNaN(host.percentWidth)) + host.setWidth(loader.content.width); + else + bitmap.width = UIBase(_strand).width; + + if (isNaN(host.explicitHeight) && isNaN(host.percentHeight)) + host.setHeight(loader.content.height); + else + bitmap.height = UIBase(_strand).height; + }); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as index ff97004..cd8c354 100644 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as +++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as @@ -202,6 +202,10 @@ package org.apache.flex.html.beads updateHitArea(); }); } + var textColor:Object = ValuesManager.valuesImpl.getValue(_strand, "color", state); + if (textColor) { + textField.textColor = Number(textColor); + } } private function drawSkin() : void http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as index 9019315..9ca7bd2 100644 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as +++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as @@ -119,6 +119,7 @@ package org.apache.flex.html.beads if (actualParent == null || actualParent == host) { actualParent = new ContainerContentArea(); + actualParent.className = "ActualParent"; host.addElement(actualParent); Container(host).setActualParent(actualParent); } @@ -223,6 +224,8 @@ package org.apache.flex.html.beads { var paddingLeft:Object; var paddingTop:Object; + var paddingRight:Object; + var paddingBottom:Object; var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding"); if (padding is Array) { @@ -243,15 +246,20 @@ package org.apache.flex.html.beads { paddingLeft = ValuesManager.valuesImpl.getValue(_strand, "padding-left"); paddingTop = ValuesManager.valuesImpl.getValue(_strand, "padding-top"); + paddingRight = ValuesManager.valuesImpl.getValue(_strand, "padding-right"); + paddingBottom = ValuesManager.valuesImpl.getValue(_strand, "padding-bottom"); } else { paddingLeft = paddingTop = padding; + paddingRight = paddingBottom = padding; } var pl:Number = Number(paddingLeft); var pt:Number = Number(paddingTop); + var pr:Number = Number(paddingRight); + var pb:Number = Number(paddingBottom); - return {paddingLeft:pl, paddingTop:pt}; + return {paddingLeft:pl, paddingTop:pt, paddingRight:pr, paddingBottom:pb}; } /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/as/projects/FlexJSUI/src/org/apache/flex/mobile/ManagerBase.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/mobile/ManagerBase.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/mobile/ManagerBase.as new file mode 100644 index 0000000..c6b0ec0 --- /dev/null +++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/mobile/ManagerBase.as @@ -0,0 +1,139 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.mobile +{ + import org.apache.flex.core.IChrome; + import org.apache.flex.core.UIBase; + + /** + * The ManagerBase is a base class for mobile display managers such as StackedViewManager + * and TabbedViewManager. This class encapsulates the features common to all view + * managers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ManagerBase extends UIBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ManagerBase() + { + super(); + + _contentArea = new UIBase(); + super.addElement(_contentArea,false); + } + + private var _contentArea:UIBase; + + /** + * The contentArea of a view manager is where the child elements are placed. Areas outside + * of the contentArea are chrome (identified by implementing IChrome). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get contentArea():UIBase + { + return _contentArea; + } + + /** + * Adds elements to the view manager. If an element implements IChrome it is placed + * in the chrome area otherwise it is placed in the contentArea. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function addElement(c:Object, dispatchEvent:Boolean=true):void + { + if (c is IChrome) { + super.addElementAt(c,0,dispatchEvent); + } + else { + (c as UIBase).width = _contentArea.width; + (c as UIBase).height = _contentArea.height; + _contentArea.addElement(c, dispatchEvent); + } + } + + /** + * @private. + */ + override public function addElementAt(c:Object, index:int, dispatchEvent:Boolean=true):void + { + if (c is IChrome) { + super.addElementAt(c, index, dispatchEvent); + } + else { + _contentArea.addElement(c, dispatchEvent); + } + } + + /** + * @private + */ + override public function removeElement(c:Object, dispatchEvent:Boolean=true):void + { + if (c is IChrome) { + super.removeElement(c, dispatchEvent); + } + else { + _contentArea.removeElement(c, dispatchEvent); + } + } + + /** + * @private + */ + override public function getElementAt(index:int):Object + { + return _contentArea.getElementAt(index); + } + + /** + * @private + */ + override public function getElementIndex(c:Object):int + { + return _contentArea.getElementIndex(c); + } + + /** + * @private + */ + override public function get numElements():int + { + return _contentArea.numElements; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/js/FlexJS/src/org/apache/flex/core/IChrome.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/IChrome.js b/frameworks/js/FlexJS/src/org/apache/flex/core/IChrome.js new file mode 100644 index 0000000..0f1bf86 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/IChrome.js @@ -0,0 +1,31 @@ +/** + * Licensed 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. + */ + +/** + * org_apache_flex_core_IChrome + * + * @fileoverview + * + * @suppress {checkTypes} + */ + +goog.provide('org_apache_flex_core_IChrome'); + + + +/** + * @interface + */ +org_apache_flex_core_IChrome = function() { +}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/js/FlexJS/src/org/apache/flex/core/UIMetrics.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/UIMetrics.js b/frameworks/js/FlexJS/src/org/apache/flex/core/UIMetrics.js new file mode 100644 index 0000000..026e8ee --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/UIMetrics.js @@ -0,0 +1,51 @@ +/** + * Licensed 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. + */ + +goog.provide('org_apache_flex_core_UIMetrics'); + + + +/** + * @constructor + */ +org_apache_flex_core_UIMetrics = function() { +}; + + +/** + * @expose + * @type {number} + */ +org_apache_flex_core_UIMetrics.prototype.top = 0; + + +/** + * @expose + * @type {number} + */ +org_apache_flex_core_UIMetrics.prototype.left = 0; + + +/** + * @expose + * @type {number} + */ +org_apache_flex_core_UIMetrics.prototype.bottom = 0; + + +/** + * @expose + * @type {number} + */ +org_apache_flex_core_UIMetrics.prototype.right = 0; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/js/FlexJS/src/org/apache/flex/mobile/ManagerBase.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/mobile/ManagerBase.js b/frameworks/js/FlexJS/src/org/apache/flex/mobile/ManagerBase.js new file mode 100644 index 0000000..0c705e6 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/mobile/ManagerBase.js @@ -0,0 +1,128 @@ +/** + * Licensed 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. + */ + +goog.provide('org_apache_flex_mobile_ManagerBase'); + +goog.require('org_apache_flex_core_IChrome'); +goog.require('org_apache_flex_core_UIBase'); +goog.require('org_apache_flex_utils_Language'); + + + +/** + * @constructor + * @extends {org_apache_flex_core_UIBase} + */ +org_apache_flex_mobile_ManagerBase = function() { + org_apache_flex_mobile_ManagerBase.base(this, 'constructor'); +}; +goog.inherits(org_apache_flex_mobile_ManagerBase, + org_apache_flex_core_UIBase); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +org_apache_flex_mobile_ManagerBase.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'ManagerBase', + qName: 'org_apache_flex_mobile_ManagerBase' }] }; + + +/** + * @type {org_apache_flex_core_UIBase} + */ +org_apache_flex_mobile_ManagerBase.prototype._contentArea = null; + + +/** + * @expose + * @return {Object} The content area for this manager. + */ +org_apache_flex_mobile_ManagerBase.prototype.get_contentArea = + function() { + return this._contentArea; +}; + + +/** + * @override + * @param {Object} c Element being added. + */ +org_apache_flex_mobile_ManagerBase.prototype.addElement = function(c) { + if (org_apache_flex_utils_Language.is(c, org_apache_flex_core_IChrome)) { + org_apache_flex_mobile_ManagerBase.base(this, 'addElement', c); + } + else { + this._contentArea.addElement(c); + } +}; + + +/** + * @override + * @param {Object} c The child element. + * @param {number} index The index. + */ +org_apache_flex_mobile_ManagerBase.prototype.addElementAt = + function(c, index) { + if (org_apache_flex_utils_Language.is(c, org_apache_flex_core_IChrome)) { + org_apache_flex_mobile_ManagerBase.base(this, 'addElementAt', c, index); + } + else { + this._contentArea.addElementAt(c, index); + } +}; + + +/** + * @override + * @param {Object} c The child element. + * @return {number} The index in parent. + */ +org_apache_flex_mobile_ManagerBase.prototype.getElementIndex = + function(c) { + return this._contentArea.getElementIndex(c); +}; + + +/** + * @override + * @param {Object} c The child element. + */ +org_apache_flex_mobile_ManagerBase.prototype.removeElement = + function(c) { + this._contentArea.removeElement(c); +}; + + +/** + * @override + */ +org_apache_flex_mobile_ManagerBase.prototype.createElement = + function() { + + this.element = document.createElement('div'); + this.element.className = 'ManagerBase'; + + this.positioner = this.element; + this.element.flexjs_wrapper = this; + + this._contentArea = new org_apache_flex_core_UIBase(); + this._contentArea.set_className('ContentArea'); + org_apache_flex_core_UIBase.prototype.addElement.call(this, this._contentArea); + + return this.element; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b15bb3/frameworks/js/FlexJS/src/org/apache/flex/utils/BeadMetrics.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/utils/BeadMetrics.js b/frameworks/js/FlexJS/src/org/apache/flex/utils/BeadMetrics.js new file mode 100644 index 0000000..98de8da --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/utils/BeadMetrics.js @@ -0,0 +1,48 @@ +/** + * Licensed 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. + */ + +goog.provide('org_apache_flex_utils_BeadMetrics'); + +goog.require('org_apache_flex_core_UIMetrics'); + + + +/** + * @constructor + */ +org_apache_flex_utils_BeadMetrics = function() { +}; + + +/** + * @expose + * @param {org_apache_flex_core_IStrand} strand The strand whose bounds are required. + * @return {org_apache_flex_core_UIMetrics} The bounding box. + */ +org_apache_flex_utils_BeadMetrics.getMetrics = function(strand) { + var box = new org_apache_flex_core_UIMetrics(); + var style = strand.element.style; + if (style['padding']) { + box.top = Number(style.padding); + box.left = Number(style.padding); + box.right = Number(style.padding); + box.bottom = Number(style.padding); + } else { + if (style['padding_top']) box.top = Number(style.padding_top); + if (style['padding_left']) box.left = Number(style.padding_left); + if (style['padding_right']) box.right = Number(style.padding_right); + if (style['padding_bottom']) box.bottom = Number(style.padding_bottom); + } + return box; +}; \ No newline at end of file
