OSDN Git Service

add scroll player
[pettanr/pettanr.git] / app / assets / javascripts / manifest / manifest.js.coffee
index eae9e96..ad044ba 100644 (file)
@@ -16,8 +16,33 @@ class Manifest
     @items = ManifestBase.load_type_name_args(this, @global_json, 'items', Manifest.ItemFactory)\r
     @controllers = Manifest.Controller.load(this, @global_json, 'controllers', Manifest.Controller)\r
     @models = Manifest.Model.load(this, @global_json, 'models', Manifest.Model)\r
+    @replace_action_alias()\r
     true\r
   \r
+  replace_action_alias: () ->\r
+    replaces = {}\r
+    _.each @controllers, (controller_manifest, controller_name) ->\r
+      _.each controller_manifest.actions, (action_manifest, action_name) ->\r
+        return if not action_manifest.alias\r
+        alias_action = action_manifest.alias_action()\r
+        return if alias_action.type != action_manifest.type\r
+        args = {}\r
+        _.each action_manifest.a_arg_names(), (name) ->\r
+          args[name] = action_manifest[name] || alias_action[name]\r
+        _.each action_manifest.b_arg_names(), (name) ->\r
+          args[name] = alias_action[name] || action_manifest[name]\r
+        args.original = action_manifest\r
+        json = {type: alias_action.type, args: args}\r
+        new_action_manifest = Manifest.ControllerModule.ActionFactory.factory(\r
+          controller_manifest, action_manifest.name, json, \r
+          action_manifest.module_name, Manifest.ControllerModule.ActionFactory\r
+        )\r
+        replaces[controller_name] ||= {}\r
+        replaces[controller_name][action_name] = new_action_manifest\r
+    _.each replaces, (controller, controller_name) ->\r
+      _.each controller, (action_manifest, action_name) ->\r
+        Manifest.manifest().controllers[controller_name].actions[action_name] = action_manifest\r
+  \r
   pluralize: (item_name) ->\r
     @item_names[item_name]\r
   \r