You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/05/03 06:58:21 UTC

[3/3] git commit: [flex-asjs] [refs/heads/develop] - add ViewSource bead

add ViewSource bead


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/7376da79
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/7376da79
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/7376da79

Branch: refs/heads/develop
Commit: 7376da79fe36348c8664a8c7daec6e7b89231eca
Parents: 355f113
Author: Alex Harui <ah...@apache.org>
Authored: Thu May 2 21:21:47 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu May 2 21:57:35 2013 -0700

----------------------------------------------------------------------
 frameworks/as/basic-manifest.xml                   |    1 +
 .../flex/utils/ViewSourceContextMenuOption.as      |   63 +++++++++++++++
 .../flex/utils/ViewSourceContextMenuOption.js      |   31 +++++++
 3 files changed, 95 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7376da79/frameworks/as/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/basic-manifest.xml b/frameworks/as/basic-manifest.xml
index 8fe7d0f..3998ceb 100644
--- a/frameworks/as/basic-manifest.xml
+++ b/frameworks/as/basic-manifest.xml
@@ -42,5 +42,6 @@
     <component id="LazyCollection" class="org.apache.flex.net.dataConverters.LazyCollection"/>
     <component id="JSONInputParser" class="org.apache.flex.net.JSONInputParser"/>
     <component id="JSONItemConverter" class="org.apache.flex.net.JSONItemConverter"/>
+    <component id="ViewSourceContextMenuOption" class="org.apache.flex.utils.ViewSourceContextMenuOption"/>
 
 </componentPackage>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7376da79/frameworks/as/src/org/apache/flex/utils/ViewSourceContextMenuOption.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/utils/ViewSourceContextMenuOption.as b/frameworks/as/src/org/apache/flex/utils/ViewSourceContextMenuOption.as
new file mode 100644
index 0000000..e119377
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/utils/ViewSourceContextMenuOption.as
@@ -0,0 +1,63 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.utils
+{
+
+import flash.display.InteractiveObject;
+import flash.events.ContextMenuEvent;
+import flash.net.URLRequest;
+import flash.net.navigateToURL;
+import flash.ui.ContextMenu;
+import flash.ui.ContextMenuItem;
+
+import org.apache.flex.core.IBead;
+import org.apache.flex.core.IStrand;
+
+public class ViewSourceContextMenuOption implements IBead
+{
+    public function ViewSourceContextMenuOption()
+    {
+    }
+
+	private var _strand:IStrand;
+	
+	public function set strand(value:IStrand):void
+	{
+		_strand = value;
+		
+		var menuHost:InteractiveObject = InteractiveObject(value);
+		var cm:ContextMenu = menuHost.contextMenu;
+		if (!cm)
+		{
+			cm = new ContextMenu();
+			menuHost.contextMenu = cm;
+		}
+		var cmi:ContextMenuItem = new ContextMenuItem("View Source...");
+		cm.hideBuiltInItems();
+		cm.customItems.push(cmi);
+		cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, viewSource);
+	}
+	
+	private function viewSource(e:ContextMenuEvent):void
+	{
+		var urlRequest:URLRequest = new URLRequest("srcview/index.html");
+		navigateToURL(urlRequest, "_blank");	
+	}
+}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7376da79/frameworks/js/FlexJS/src/org/apache/flex/utils/ViewSourceContextMenuOption.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/utils/ViewSourceContextMenuOption.js b/frameworks/js/FlexJS/src/org/apache/flex/utils/ViewSourceContextMenuOption.js
new file mode 100644
index 0000000..53820b2
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/utils/ViewSourceContextMenuOption.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.
+ */
+
+goog.provide('org.apache.flex.utils.ViewSourceContextMenuOption');
+
+/**
+ * @constructor
+ * @extends {org.apache.flex.events.EventDispatcher}
+ */
+org.apache.flex.utils.ViewSourceContextMenuOption = function() {
+    // no implementation in JS since ViewSource is already in menu
+};
+
+/**
+ * @this {org.apache.flex.utils.ViewSourceContextMenuOption}
+ * @param {object} value The strand (owner) of the bead.
+ */
+org.apache.flex.utils.ViewSourceContextMenuOption.prototype.set_strand = function(value) {
+};
+