cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [01/22] git commit: Support for adding UI elements to windows phone plugins
Date Thu, 11 Jul 2013 20:29:08 GMT
Updated Branches:
  refs/heads/plugman-registry bf9751330 -> c9a42d689


Support for adding UI elements to windows phone plugins


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/e3043a68
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/e3043a68
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/e3043a68

Branch: refs/heads/plugman-registry
Commit: e3043a68506ea1ac66b87ace7561f449aff330a5
Parents: f99d0f4
Author: Benn Mapes <benn.mapes@gmail.com>
Authored: Mon Jun 10 17:06:35 2013 -0700
Committer: Benn Mapes <benn.mapes@gmail.com>
Committed: Mon Jun 10 17:06:35 2013 -0700

----------------------------------------------------------------------
 src/util/csproj.js | 55 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/e3043a68/src/util/csproj.js
----------------------------------------------------------------------
diff --git a/src/util/csproj.js b/src/util/csproj.js
index 12ed5db..34be9a5 100644
--- a/src/util/csproj.js
+++ b/src/util/csproj.js
@@ -14,22 +14,55 @@ csproj.prototype = {
     },
     addSourceFile:function(relative_path) {
         relative_path = relative_path.split('/').join('\\');
+        // make ItemGroup to hold file.
         var item = new et.Element('ItemGroup');
-        var compile = new et.Element('Compile');
-        compile.attrib.Include = relative_path;
-        item.append(compile);
+        // check if it's a .xaml page
+        if(relative_path.indexOf('.xaml', relative_path.length - 5) > -1) {
+            var page = new et.Element('Page');
+            page.attrib.Include = relative_path;
+            var gen = new et.Element('Generator');
+            gen.text = "MSBuild:Compile";
+            page.append(gen);
+            var sub_type = new et.Element('SubType');
+            sub_type.text = "Designer";
+            page.append(sub_type);
+            item.append(page);
+        }
+        // check if it's a .xaml.cs page that would depend on a .xaml of the same name
+        else if (relative_path.indexOf('.xaml.cs', relative_path.length - 8) > -1) {
+            var compile = new et.Element('Compile');
+            compile.attrib.Include = relative_path;
+            var dep = new et.Element('DependentUpon');
+            var parts = relative_path.split('\\');
+            var xaml_file = parts[parts.length - 1].substr(0, parts[parts.length - 1].length
- 3);
+            dep.text = xaml_file;
+            compile.append(dep);
+            item.append(compile);
+        }
+        // otherwise add it normally
+        else {
+            var compile = new et.Element('Compile');
+            compile.attrib.Include = relative_path;
+            item.append(compile);
+        }
         this.xml.getroot().append(item);
     },
     removeSourceFile:function(relative_path) {
         relative_path = relative_path.split('/').join('\\');
-        var groups = this.xml.findall('ItemGroup');
-        for (var i = 0, l = groups.length; i < l; i++) {
-            var group = groups[i];
-            var compiles = group.findall('Compile');
-            for (var j = 0, k = compiles.length; j < k; j++) {
-                var compile = compiles[j];
-                if (compile.attrib.Include == relative_path) {
-                    group.remove(0, compile);
+        var item_groups = this.xml.findall('ItemGroup');
+        for (var i = 0, l = item_groups.length; i < l; i++) {
+            var group = item_groups[i];
+            var files = group.findall('Compile').concat(group.findall('Page'));
+            for (var j = 0, k = files.length; j < k; j++) {
+                var file = files[j];
+                if (file.attrib.Include == relative_path) {
+                    // remove file reference
+                    group.remove(0, file);
+                    // remove ItemGroup if empty
+                    var new_group = group.findall('Compile').concat(group.findall('Page'));
+                    if(new_group.length < 1) {
+                        this.xml.getroot().remove(0, group);
+                    }
                     return true;
                 }
             }


Mime
View raw message