From aa1a68317b56acaa3f3a835603dea67d6f382c60 Mon Sep 17 00:00:00 2001 From: Greg Lincoln Date: Mon, 6 Jul 2015 12:20:45 -0400 Subject: [PATCH 01/16] Fix nested function literal. --- js/angular-winjs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/angular-winjs.js b/js/angular-winjs.js index aa2a835..26e78d4 100644 --- a/js/angular-winjs.js +++ b/js/angular-winjs.js @@ -148,7 +148,7 @@ })); var deferUpdate = false; - function updateOriginalArray() { + var updateOriginalArray = function () { if (deferUpdate) { return; } From d4c4546281232932247b9faee0724860c8a281f6 Mon Sep 17 00:00:00 2001 From: AmazingJaze Date: Tue, 7 Jul 2015 15:25:34 -0700 Subject: [PATCH 02/16] Update README.md Updates section on using the win-control directive to expose the winControl to Angular Scope Adds section describing how to run angular-winjs unit tests. --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e4156bb..62ec196 100644 --- a/README.md +++ b/README.md @@ -203,10 +203,25 @@ Examples of control usage - This Pivot is showing how to access its winControl through Angular + This Pivot is showing how to access its winControl through Angular. + The winControl can now be as a variable on the Angular scope, using the same name that was + specified in the directive. In this case, $scope.pivotWinControl +Running unit tests +------------------------- + +### Install Node +In order build WinJS, ensure that you have [Node.js](http://nodejs.org/download/) installed. + +### Run the tests +From the local angular-winjs repository +``` +npm install +npm test +``` + Notes ----- From 48aa68e25ea7851f738880f7d44b0b8db14853ee Mon Sep 17 00:00:00 2001 From: AmazingJaze Date: Tue, 7 Jul 2015 15:26:23 -0700 Subject: [PATCH 03/16] Update README.md updated title of Unit test section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62ec196..31dc4c3 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ Examples of control usage -Running unit tests +How to run unit tests ------------------------- ### Install Node From 8c2298fd5f0f5c83145c10d426fefc4e92fb6d1d Mon Sep 17 00:00:00 2001 From: AmazingJaze Date: Tue, 7 Jul 2015 15:27:20 -0700 Subject: [PATCH 04/16] Update README.md Grammar fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31dc4c3..b1b13b7 100644 --- a/README.md +++ b/README.md @@ -226,4 +226,4 @@ npm test Notes ----- -For all of the controls you can bind to all public properties and events and the camel cased property names conveniently map to attributes. +For all of the controls you can bind to: all public properties, events, and camel cased property names conveniently map to attributes. From 822c116ecf8fae77fda0273b06503dc9b6ae50e1 Mon Sep 17 00:00:00 2001 From: AmazingJaze Date: Thu, 9 Jul 2015 00:11:23 -0700 Subject: [PATCH 05/16] Update README.md Added missing word from section on accessing the winControl and cleaned up the "Notes" section at the end. --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b1b13b7..e2ed5e0 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ Examples of control usage This Pivot is showing how to access its winControl through Angular. - The winControl can now be as a variable on the Angular scope, using the same name that was + The winControl can now be accessed as a variable on the Angular scope, using the same name that was specified in the directive. In this case, $scope.pivotWinControl @@ -226,4 +226,6 @@ npm test Notes ----- -For all of the controls you can bind to: all public properties, events, and camel cased property names conveniently map to attributes. +For all of the controls you can bind to: all public events, and camel cased property names, conveniently map to attributes. +- ```appBar.closedDisplayMode = "compact"``` maps to `````` +- ```flipView.onpageselected = pagesSelected()``` maps to `````` From b610092de5e9622a8f2b0f75352be20d1b82a5f1 Mon Sep 17 00:00:00 2001 From: AmazingJaze Date: Thu, 9 Jul 2015 11:03:10 -0700 Subject: [PATCH 06/16] Update README.md Collapsed SplitView and SplitViewToggle examples into one. --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index e2ed5e0..f61c692 100644 --- a/README.md +++ b/README.md @@ -155,14 +155,7 @@ Examples of control usage -### SplitView - - - SplitView Navigation Pane - SplitView Content Area - - -### SplitView +### SplitView and optional SplitViewPaneToggle angular.module("yourAngularApp", ["winjs"]).controller("yourController", function ($scope) { $scope.splitViewElement = document.getElementById("splitView"); }); From bb60a36175ba4fb7896bf686b2c87ac3091eefbc Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Fri, 10 Jul 2015 22:35:11 -0700 Subject: [PATCH 07/16] 3.1.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6442045..37e3d2b 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "https://github.com/winjs/angular-winjs/graphs/contributors" }, "license": "MIT", - "version": "3.0.0", + "version": "3.1.0", "main": "js/angular-winjs.js", "scripts": { "test": "karma start karma.config.js" @@ -37,6 +37,6 @@ "devDependencies": { "angular-mocks": "~1.3.13", "karma": "~0.10", - "winjs": "4.0.x" + "winjs": "4.1.x" } } From df5ed58f6787ffac99033f9989121cadb3b45a2b Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Fri, 10 Jul 2015 22:48:33 -0700 Subject: [PATCH 08/16] 3.1.0 --- Angular.WinJS.nuspec | 2 +- bower.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Angular.WinJS.nuspec b/Angular.WinJS.nuspec index c2b661f..351771b 100644 --- a/Angular.WinJS.nuspec +++ b/Angular.WinJS.nuspec @@ -2,7 +2,7 @@ Angular.WinJS - 3.0.0 + 3.1.0 Microsoft Corporation and other contributors https://raw.githubusercontent.com/winjs/angular-winjs/master/License.txt https://github.com/winjs/angular-winjs diff --git a/bower.json b/bower.json index 3ed77ce..2a127e9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-winjs", - "version": "3.0.0", + "version": "3.1.0", "homepage": "https://github.com/winjs/angular-winjs", "authors": [ "Microsoft Corporation and other contributors" From 94730bb9842ec4e16ec3a48878d412ba7a0ece82 Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Mon, 13 Jul 2015 11:44:33 -0700 Subject: [PATCH 09/16] 3.1.1 --- Angular.WinJS.nuspec | 2 +- bower.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Angular.WinJS.nuspec b/Angular.WinJS.nuspec index 351771b..22dade7 100644 --- a/Angular.WinJS.nuspec +++ b/Angular.WinJS.nuspec @@ -2,7 +2,7 @@ Angular.WinJS - 3.1.0 + 3.1.1 Microsoft Corporation and other contributors https://raw.githubusercontent.com/winjs/angular-winjs/master/License.txt https://github.com/winjs/angular-winjs diff --git a/bower.json b/bower.json index 2a127e9..899925c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-winjs", - "version": "3.1.0", + "version": "3.1.1", "homepage": "https://github.com/winjs/angular-winjs", "authors": [ "Microsoft Corporation and other contributors" diff --git a/package.json b/package.json index 37e3d2b..5dc4451 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "https://github.com/winjs/angular-winjs/graphs/contributors" }, "license": "MIT", - "version": "3.1.0", + "version": "3.1.1", "main": "js/angular-winjs.js", "scripts": { "test": "karma start karma.config.js" From e712f960c86ce404549fb0711d960987836b3c6b Mon Sep 17 00:00:00 2001 From: jessesh Date: Fri, 17 Jul 2015 16:20:04 -0700 Subject: [PATCH 10/16] Removes deprecated NavBar controls from angular-winjs bridge Adds new SplitViewCommand control to angular-winjs bridge --- js/angular-winjs.js | 119 ++++++++----------------------------- tests/NavBar.js | 120 -------------------------------------- tests/NavBarCommand.js | 56 ------------------ tests/NavBarContainer.js | 56 ------------------ tests/SplitViewCommand.js | 54 +++++++++++++++++ 5 files changed, 77 insertions(+), 328 deletions(-) delete mode 100644 tests/NavBar.js delete mode 100644 tests/NavBarCommand.js delete mode 100644 tests/NavBarContainer.js create mode 100644 tests/SplitViewCommand.js diff --git a/js/angular-winjs.js b/js/angular-winjs.js index 26e78d4..9e2a18f 100644 --- a/js/angular-winjs.js +++ b/js/angular-winjs.js @@ -634,7 +634,7 @@ } }; }); - + exists("ContentDialog") && module.directive("winContentDialog", function () { var api = { hidden: BINDING_property, @@ -669,16 +669,6 @@ }; }); - exists("NavBarContainer") && module.directive("winCommandTemplate", function () { - return { - require: ["^?winNavBarContainer"], - restrict: "E", - replace: true, - transclude: true, - compile: compileTemplate("template") - }; - }); - exists("DatePicker") && module.directive("winDatePicker", function () { var api = { calendar: BINDING_property, @@ -1100,88 +1090,6 @@ }; }); - exists("NavBar") && module.directive("winNavBar", ['$parse', function ($parse) { - var api = { - closedDisplayMode: BINDING_property, - opened: BINDING_property, - placement: BINDING_property, - onAfterClose: BINDING_event, - onAfterOpen: BINDING_event, - onBeforeClose: BINDING_event, - onBeforeOpen: BINDING_event, - onChildrenProcessed: BINDING_event - }; - - return { - restrict: "E", - replace: true, - scope: getScopeForAPI(api), - template: "
", - transclude: true, - link: function ($scope, elements, attrs) { - var control = initializeControl($scope, elements[0], WinJS.UI.NavBar, api); - - function onVisibilityChanged() { - apply($scope, function () { - $scope["opened"] = control["opened"]; - }); - } - - control.addEventListener("afteropen", onVisibilityChanged); - control.addEventListener("afterclose", onVisibilityChanged); - } - }; - - }]); - - exists("NavBarCommand") && module.directive("winNavBarCommand", function () { - var api = { - icon: BINDING_property, - label: BINDING_property, - location: BINDING_property, - splitButton: BINDING_property, - splitOpened: BINDING_property, - state: BINDING_property, - tooltip: BINDING_property - }; - return { - restrict: "E", - replace: true, - scope: getScopeForAPI(api), - template: "
", - transclude: true, - link: function ($scope, elements) { - initializeControl($scope, elements[0], WinJS.UI.NavBarCommand, api); - } - }; - }); - - exists("NavBarContainer") && module.directive("winNavBarContainer", function () { - var api = { - currentIndex: BINDING_property, - data: BINDING_property, - fixedSize: BINDING_property, - layout: BINDING_property, - template: BINDING_property, - maxRows: BINDING_property, - onInvoked: BINDING_event, - onSplitToggle: BINDING_event - }; - return { - restrict: "E", - replace: true, - scope: getScopeForAPI(api), - template: "
", - transclude: true, - controller: ['$scope', function ($scope) { - proxy($scope, this, "template"); - }], - link: function ($scope, elements) { - initializeControl($scope, elements[0], WinJS.UI.NavBarContainer, api); - } - }; - }); - var pivotHelperDirectives = [ { controlOptionName: "customLeftHeader", @@ -1429,6 +1337,16 @@ }; }); + exists("SplitView") && module.directive("winSplitViewContent", function () { + return { + require: "^winSplitView", + restrict: "E", + replace: true, + transclude: true, + template: "
" + }; + }); + exists("SplitViewPaneToggle") && module.directive("winSplitViewPaneToggle", function () { var api = { splitView: BINDING_property, @@ -1446,13 +1364,22 @@ }; }); - exists("SplitView") && module.directive("winSplitViewContent", function () { + exists("SplitViewCommand") && module.directive("winSplitViewCommand", function () { + var api = { + icon: BINDING_property, + label: BINDING_property, + tooltip: BINDING_property, + onInvoked: BINDING_event, + }; return { - require: "^winSplitView", restrict: "E", replace: true, + scope: getScopeForAPI(api), + template: "
", transclude: true, - template: "
" + link: function ($scope, elements) { + initializeControl($scope, elements[0], WinJS.UI.SplitViewCommand, api); + } }; }); diff --git a/tests/NavBar.js b/tests/NavBar.js deleted file mode 100644 index 8e927ce..0000000 --- a/tests/NavBar.js +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) Microsoft Corp. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. - -describe("NavBar control directive tests", function () { - var testTimeout = 5000; - - var scope, - compile; - - beforeEach(angular.mock.module("winjs")); - beforeEach(angular.mock.inject(function ($rootScope, $compile) { - scope = $rootScope.$new(); - compile = $compile; - })); - - function initControl(markup) { - var element = angular.element(markup)[0]; - document.body.appendChild(element); - var compiledControl = compile(element)(scope)[0]; - scope.$digest(); - return compiledControl; - } - - it("should initialize a simple NavBar", function () { - var compiledControl = initControl(""); - - expect(compiledControl.winControl).toBeDefined(); - expect(compiledControl.winControl instanceof WinJS.UI.NavBar); - expect(compiledControl.className).toContain("win-navbar"); - }); - - it("should use child NavBarCommands", function () { - var compiledControl = initControl("" + - "" + - "" + - "" + - "" + - ""); - - expect(compiledControl.winControl).toBeDefined(); - expect(compiledControl.winControl instanceof WinJS.UI.NavBar); - expect(compiledControl.className).toContain("win-navbar"); - expect(compiledControl.querySelectorAll(".win-navbarcommand").length).toEqual(2); - }); - - it("should use the closedDisplayMode attribute", function () { - var compiledControl = initControl(""); - expect(compiledControl.winControl.closedDisplayMode).toEqual("minimal"); - }); - - it("should use the placement attribute", function () { - var compiledControl = initControl(""); - expect(compiledControl.winControl.placement).toEqual("top"); - }); - - it("should use the onChildrenProcessed event handler", function () { - var gotProcessedEvent = false; - scope.processedEventHandler = function (e) { - gotProcessedEvent = true; - }; - var compiledControl = initControl("" + - "" + - "" + - "" + - ""); - waitsFor(function () { - return gotProcessedEvent; - }, "the NavBar's onChildrenProcessed event", testTimeout); - }); - - it("should use the onopen and onclose event handlers and opened attribute", function () { - var gotBeforeOpenEvent = false, - gotAfterOpenEvent = false, - gotBeforeCloseEvent = false, - gotAfterCloseEvent = false; - scope.beforeOpenEventHandler = function (e) { - gotBeforeOpenEvent = true; - }; - scope.afterOpenEventHandler = function (e) { - gotAfterOpenEvent = true; - }; - scope.beforeCloseEventHandler = function (e) { - gotBeforeCloseEvent = true; - }; - scope.afterCloseEventHandler = function (e) { - gotAfterCloseEvent = true; - }; - scope.navbarOpened = false; - var compiledControl = initControl(""); - runs(function () { - compiledControl.winControl.open(); - }); - - waitsFor(function () { - return (gotBeforeOpenEvent && gotAfterOpenEvent); - }, "the NavBar's before+aftershow events", testTimeout); - - runs(function () { - expect(scope.navbarOpened).toBeTruthy(); - scope.navbarOpened = false; - scope.$digest(); - }); - - waitsFor(function () { - return (gotBeforeCloseEvent && gotAfterCloseEvent); - }, "the NavBar's before+afterhide events", testTimeout); - - runs(function () { - expect(scope.navbarOpened).toBeFalsy(); - expect(compiledControl.winControl.opened).toBeFalsy(); - }); - }); - - afterEach(function () { - var controls = document.querySelectorAll(".win-navbar"); - for (var i = 0; i < controls.length; i++) { - controls[i].parentNode.removeChild(controls[i]); - } - }); -}); diff --git a/tests/NavBarCommand.js b/tests/NavBarCommand.js deleted file mode 100644 index 1892dba..0000000 --- a/tests/NavBarCommand.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corp. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. - -describe("NavBarCommand control directive tests", function () { - var scope, - compile; - - beforeEach(angular.mock.module("winjs")); - beforeEach(angular.mock.inject(function ($rootScope, $compile) { - scope = $rootScope.$new(); - compile = $compile; - })); - - function initControl(markup) { - var element = angular.element(markup)[0]; - document.body.appendChild(element); - var compiledControl = compile(element)(scope)[0]; - scope.$digest(); - return compiledControl; - } - - it("should use initialize a NavBar containing two child NavBarCommands", function () { - var compiledControl = initControl("" + - "" + - "" + - ""); - - expect(compiledControl.querySelectorAll(".win-navbarcommand").length).toEqual(2); - }); - - it("should use the label attribute on NavBarCommands", function () { - var compiledControl = initControl("" + - "" + - "" + - ""); - - var commands = compiledControl.querySelectorAll(".win-navbarcommand"); - expect(commands[0].querySelector(".win-navbarcommand-label").innerHTML).toEqual("command1"); - expect(commands[1].querySelector(".win-navbarcommand-label").innerHTML).toEqual("command2"); - }); - - it("should use the location attribute on NavBarCommands", function () { - var compiledControl = initControl("" + - "" + - ""); - - var commands = compiledControl.querySelectorAll(".win-navbarcommand"); - expect(commands[0].winControl.location).toEqual("someLocation"); - }); - - afterEach(function () { - var controls = document.querySelectorAll(".win-navbarcontainer"); - for (var i = 0; i < controls.length; i++) { - controls[i].parentNode.removeChild(controls[i]); - } - }); -}); diff --git a/tests/NavBarContainer.js b/tests/NavBarContainer.js deleted file mode 100644 index 3fcbddb..0000000 --- a/tests/NavBarContainer.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corp. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. - -describe("NavBarContainer control directive tests", function () { - var testTimeout = 5000; - - var scope, - compile; - - beforeEach(angular.mock.module("winjs")); - beforeEach(angular.mock.inject(function ($rootScope, $compile) { - scope = $rootScope.$new(); - compile = $compile; - })); - - function initControl(markup) { - var element = angular.element(markup)[0]; - document.body.appendChild(element); - var compiledControl = compile(element)(scope)[0]; - scope.$digest(); - return compiledControl; - } - - it("should use the fixedSize attribute", function () { - var compiledControl = initControl(""); - - expect(compiledControl.winControl.fixedSize).toBeTruthy(); - }); - - it("should use the maxRows attribute", function () { - var compiledControl = initControl(""); - - expect(compiledControl.winControl.maxRows).toEqual(3); - }); - - it("should use the layout attribute", function () { - var compiledControl = initControl(""); - - expect(compiledControl.winControl.layout).toEqual("vertical"); - }); - - it("should use the data and template attributes", function () { - scope.data = new WinJS.Binding.List([1, 2, 3]); - scope.template = new WinJS.Binding.Template(); - var control = initControl("").winControl; - - expect(control.data).toEqual(scope.data); - expect(control.template).toEqual(scope.template); - }); - - afterEach(function () { - var controls = document.querySelectorAll(".win-navbarcontainer"); - for (var i = 0; i < controls.length; i++) { - controls[i].parentNode.removeChild(controls[i]); - } - }); -}); diff --git a/tests/SplitViewCommand.js b/tests/SplitViewCommand.js new file mode 100644 index 0000000..09c07b5 --- /dev/null +++ b/tests/SplitViewCommand.js @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corp. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. + +describe("SplitViewCommand control directive tests", function () { + var scope, + compile; + + beforeEach(angular.mock.module("winjs")); + beforeEach(angular.mock.inject(function ($rootScope, $compile) { + scope = $rootScope.$new(); + compile = $compile; + })); + + function initControl(markup) { + var element = angular.element(markup)[0]; + document.body.appendChild(element); + var compiledControl = compile(element)(scope)[0]; + scope.$digest(); + return compiledControl; + } + + it("should initialize a simple SplitViewCommand", function () { + var compiledControl = initControl(""); + + expect(compiledControl.winControl).toBeDefined(); + expect(compiledControl.winControl instanceof WinJS.UI.SplitViewCommand); + expect(compiledControl.className).toContain("win-splitviewcommand"); + }); + + it("should use the label attribute", function () { + var compiledControl = initControl(""); + + expect(compiledControl.querySelector(".win-splitviewcommand-label").innerHTML).toEqual("add"); + }); + + it("should use the onInvoked attribute", function () { + var gotInvokedEvent = false; + scope.onInvoked = function () { + gotInvokedEvent = true; + }; + var compiledControl = initControl(""); + var button = compiledControl.querySelector(".win-splitviewcommand-button"); + expect(gotInvokedEvent).toBeFalsy(); + button.click(); + expect(gotInvokedEvent).toBeTruthy(); + }); + + afterEach(function () { + var controls = document.querySelectorAll(".win-splitviewcommand"); + for (var i = 0; i < controls.length; i++) { + controls[i].parentNode.removeChild(controls[i]); + } + }); +}); + From 9670e7f3ea48e4435f8eb371bc8110f8cb6b4dab Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Thu, 30 Jul 2015 10:46:18 -0700 Subject: [PATCH 11/16] Automate release process You can now use a grunt task to: - Publish a release to GitHub - Publish to npm - Publish to bower - Publish to NuGet The command is: grunt publish This will print a message warning you about what is about to happen and showing you a checklist. Once you're sure you want to proceed, you run this command: grunt publish:force which actually publishes to all of the package managers. Version information in bower.json and Angular.WinJS.nuspec is not used. Deleted it from bower.json. Can't delete it from nuspec so set it at version 1.0.0 as a hint that we don't need to keep it up to date. --- .gitignore | 1 + Angular.WinJS.nuspec | 2 +- Gruntfile.js | 177 +++++++++++++++++++++++++++++++++++++++++++ bower.json | 4 +- package.json | 8 +- 5 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 Gruntfile.js diff --git a/.gitignore b/.gitignore index 636191d..3980dc3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ +dist/ Thumbs.db ehthumbs.db diff --git a/Angular.WinJS.nuspec b/Angular.WinJS.nuspec index 22dade7..7be6529 100644 --- a/Angular.WinJS.nuspec +++ b/Angular.WinJS.nuspec @@ -2,7 +2,7 @@ Angular.WinJS - 3.1.1 + 1.0.0 Microsoft Corporation and other contributors https://raw.githubusercontent.com/winjs/angular-winjs/master/License.txt https://github.com/winjs/angular-winjs diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..464afab --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corp. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. + +"use strict"; + +var exec = require('child_process').exec; +var execSync = require('child_process').execSync; + +module.exports = function(grunt) { + + var publishRoot = 'dist/'; + var npmPublishRoot = publishRoot + 'npm/'; + + // All version number information is derived from package.json. This includes the version + // info used with npm, bower, NuGet, and the GitHub release. + var pkg = grunt.file.readJSON('package.json'); + var fullWinjsVersion = pkg.devDependencies.winjs; + if (!fullWinjsVersion) { + grunt.fail.fatal('Unable to determine WinJS version required by angular-winjs'); + } + // package.json version contains ... We just want . + var winjsVersion = fullWinjsVersion.split(".").slice(0, 2).join("."); + + var currentGitCommitHash = execSync('git rev-parse HEAD').toString().trim(); + + // Project configuration. + grunt.initConfig({ + pkg: pkg, + + clean: { + publish: [publishRoot] + }, + + copy: { + publish: { + files: [{ + expand: true, + src: [ + 'js/**', + 'License.txt', + 'package.json', + 'README.md' + ], + dest: npmPublishRoot + }] + } + }, + + compress: { + publish: { + options: { + archive: publishRoot + 'angular-winjs.zip' + }, + files: [{ + expand: true, + cwd: npmPublishRoot, + src: ["**"] + }] + } + }, + + nugetpack: { + publish: { + src: 'Angular.WinJS.nuspec', + dest: publishRoot, + options: { + version: '<%= pkg.version %>' + } + } + }, + + // Publishes nuget package + nugetpush: { + // Requires NuGet API key to be set. You can do this with: + // grunt nugetkey --key=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + publish: { + src: publishRoot + '*.nupkg', + } + }, + + // Publishes GitHub release and bower package (bower consumes GitHub tags/releases) + 'github-release': { + // Requires this environment variable to be set: GITHUB_ACCESS_TOKEN + // GITHUB_ACCESS_TOKEN can be generated from https://help.github.com/articles/creating-an-access-token-for-command-line-use/ + publish: { + options: { + repository: 'winjs/angular-winjs', + auth: { + user: process.env.GITHUB_ACCESS_TOKEN + }, + release: { + tag_name: 'v<%= pkg.version %>', // Must follow semver syntax in order for bower to pick it up + target_commitish: currentGitCommitHash, + name: '<%= pkg.version %>', + body: + 'Release of angular-winjs <%= pkg.version %>.\n' + + '\n' + + 'Compatible with WinJS ' + winjsVersion + '.\n' + } + }, + files: { + src: [publishRoot + 'angular-winjs.zip'] + } + } + } + }); + + var plugins = [ + 'grunt-contrib-clean', + 'grunt-contrib-compress', + 'grunt-contrib-copy', + 'grunt-nuget', + 'grunt-github-releaser' + ]; + plugins.forEach(function (plugin) { + grunt.loadNpmTasks(plugin); + }); + + // Publishes npm package + grunt.registerTask('npm-release', function (mode) { + var done = this.async(); + var cmd = 'npm publish ' + npmPublishRoot; + + exec(cmd, function (err, stdout) { + if (err) { + grunt.fatal('npm publish failed using command: ' + cmd); + } + done(); + }); + }); + + // Sets up all of the state necessary to do a publish but doesn't actually publish + // to any of the package managers. + grunt.registerTask('prepare-publish', [ + 'clean:publish', + 'copy:publish', + 'compress:publish', + 'nugetpack:publish', + ]); + + grunt.registerTask('finished-publish', function (mode) { + grunt.log.writeln(''); + grunt.log.writeln('Publish complete. Hand tweak the GitHub release description if necessary (https://github.com/winjs/angular-winjs/releases)'); + grunt.log.writeln(''); + }); + + // + // Public tasks designed to be run from the command line + // + + // Populates the 'dist' folder and then uses it to: + // - Create a GitHub release + // - Publish to npm + // - Publish to bower + // - Publish to NuGet + // When debugging publish, it's helpful to run just the 'prepare-publish' + // task which puts all of the publication data into the 'dist' folder but + // doesn't actually send the data to the package managers. + grunt.registerTask('publish', function (mode) { + if (!mode) { + grunt.log.writeln(''); + grunt.log.writeln('Will publish version ' + pkg.version + ' of angular-winjs to npm, NuGet, etc. Double check that:'); + grunt.log.writeln(' * You are on the branch you\'d like to publish'); + grunt.log.writeln(' * The branch has been pushed to GitHub'); + grunt.log.writeln(' * You don\'t have any local edits'); + grunt.log.writeln(''); + grunt.log.writeln('If everything is in order, run "grunt publish:force" to proceed'); + } else if (mode === 'force') { + grunt.task.run([ + 'prepare-publish', + 'nugetpush:publish', + 'github-release:publish', + 'npm-release', + 'finished-publish', + ]); + } + }); +}; diff --git a/bower.json b/bower.json index 899925c..76cd917 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,5 @@ { "name": "angular-winjs", - "version": "3.1.1", "homepage": "https://github.com/winjs/angular-winjs", "authors": [ "Microsoft Corporation and other contributors" @@ -21,6 +20,7 @@ "tests", "package.json", "karma.config.js", - "*.nuspec" + "*.nuspec", + "Gruntfile.js" ] } \ No newline at end of file diff --git a/package.json b/package.json index 5dc4451..f846d87 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,12 @@ "devDependencies": { "angular-mocks": "~1.3.13", "karma": "~0.10", - "winjs": "4.1.x" + "winjs": "4.1.x", + "grunt": "^0.4.5", + "grunt-contrib-clean": "^0.6.0", + "grunt-contrib-compress": "^0.13.0", + "grunt-contrib-copy": "^0.8.0", + "grunt-github-releaser": "^0.1.17", + "grunt-nuget": "^0.1.4" } } From 3d8f71b446f22d059f1c6177329a52f544a055d3 Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Fri, 7 Aug 2015 16:59:16 -0700 Subject: [PATCH 12/16] Verify files have BOM during publish task This verification is designed to simulate part of the Windows App Certification Kit test. Protects us from regressing winjs/winjs#1315 in the future. --- Gruntfile.js | 21 +++++++++++++++++++++ js/angular-winjs.js | 2 +- tasks/check-bom.js | 26 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tasks/check-bom.js diff --git a/Gruntfile.js b/Gruntfile.js index 464afab..93980aa 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -22,6 +22,8 @@ module.exports = function(grunt) { var currentGitCommitHash = execSync('git rev-parse HEAD').toString().trim(); + var bomGlob = "**/*.+(js|css|htm|html)"; + // Project configuration. grunt.initConfig({ pkg: pkg, @@ -58,6 +60,22 @@ module.exports = function(grunt) { } }, + "check-bom": { + publish: { + files: [{ + cwd: 'js', + src: bomGlob, + expand: true, + nocase: true + }, { + cwd: publishRoot, + src: bomGlob, + expand: true, + nocase: true + }] + } + }, + nugetpack: { publish: { src: 'Angular.WinJS.nuspec', @@ -104,6 +122,8 @@ module.exports = function(grunt) { } }); + grunt.loadTasks('tasks/'); + var plugins = [ 'grunt-contrib-clean', 'grunt-contrib-compress', @@ -135,6 +155,7 @@ module.exports = function(grunt) { 'copy:publish', 'compress:publish', 'nugetpack:publish', + 'check-bom:publish', ]); grunt.registerTask('finished-publish', function (mode) { diff --git a/js/angular-winjs.js b/js/angular-winjs.js index 9e2a18f..8d2da21 100644 --- a/js/angular-winjs.js +++ b/js/angular-winjs.js @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corp. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. +// Copyright (c) Microsoft Corp. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. (function (global) { "use strict"; diff --git a/tasks/check-bom.js b/tasks/check-bom.js new file mode 100644 index 0000000..a89face --- /dev/null +++ b/tasks/check-bom.js @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. +(function () { + "use strict"; + + module.exports = function (grunt) { + + // Verifies that files begin with a UTF8 BOM. Files without one will not be able to pass the + // Windows App Certification Kit test. + + grunt.registerMultiTask("check-bom", function () { + function checkBom(filePath) { + if (grunt.file.exists(filePath)) { + var content = grunt.file.read(filePath, { encoding: null }); + if (content.length < 3 || content[0] !== 0xef || content[1] !== 0xbb || content[2] !== 0xbf) { + grunt.fail.fatal("check-bom File is missing BOM: " + filePath); + } + } else { + grunt.log.warn("check-bom No such file: " + filePath); + } + } + + this.filesSrc.forEach(checkBom); + }); + + }; +})(); From 6cf30914fa214c8eb02ed7bb68b04094a3ce895d Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Mon, 17 Aug 2015 18:59:23 -0700 Subject: [PATCH 13/16] 4.0.0: Update to WinJS 4.2 --- js/angular-winjs.js | 3 +++ package.json | 4 ++-- tests/AppBarCommand.js | 4 ++-- tests/ListView.js | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/js/angular-winjs.js b/js/angular-winjs.js index 8d2da21..4ce52a4 100644 --- a/js/angular-winjs.js +++ b/js/angular-winjs.js @@ -977,6 +977,8 @@ itemTemplate: BINDING_property, layout: BINDING_property, maxDeferredItemCleanup: BINDING_property, + maxLeadingPages: BINDING_property, + maxTrailingPages: BINDING_property, scrollPosition: BINDING_property, selection: BINDING_selection, selectionMode: BINDING_property, @@ -985,6 +987,7 @@ onFooterVisibilityChanged: BINDING_event, onGroupHeaderInvoked: BINDING_event, onHeaderVisibilityChanged: BINDING_event, + onAccessibilityAnnotationComplete: BINDING_event, onItemDragStart: BINDING_event, onItemDragEnter: BINDING_event, onItemDragBetween: BINDING_event, diff --git a/package.json b/package.json index f846d87..0b585bc 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "https://github.com/winjs/angular-winjs/graphs/contributors" }, "license": "MIT", - "version": "3.1.1", + "version": "4.0.0", "main": "js/angular-winjs.js", "scripts": { "test": "karma start karma.config.js" @@ -37,7 +37,7 @@ "devDependencies": { "angular-mocks": "~1.3.13", "karma": "~0.10", - "winjs": "4.1.x", + "winjs": "4.2.x", "grunt": "^0.4.5", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-compress": "^0.13.0", diff --git a/tests/AppBarCommand.js b/tests/AppBarCommand.js index 3161b78..2ce812d 100644 --- a/tests/AppBarCommand.js +++ b/tests/AppBarCommand.js @@ -91,8 +91,8 @@ describe("AppBarCommand control directive tests", function () { "
"); var commands = compiledControl.querySelectorAll(".win-command"); - expect(commands[0].style.display).toEqual("none"); - expect(commands[1].style.display).toNotEqual("none"); + expect(commands[0].winControl.hidden).toBeTruthy(); + expect(commands[1].winControl.hidden).toBeFalsy(); }); it("should use the icon attribute on AppBarCommands", function () { diff --git a/tests/ListView.js b/tests/ListView.js index cfbe2e4..94fa82e 100644 --- a/tests/ListView.js +++ b/tests/ListView.js @@ -164,6 +164,16 @@ describe("ListView control directive tests", function () { var compiledControl = initControl(""); expect(compiledControl.winControl.maxDeferredItemCleanup).toEqual(10); }); + + it("should use the maxLeadingPages attribute", function () { + var compiledControl = initControl(""); + expect(compiledControl.winControl.maxLeadingPages).toEqual(7); + }); + + it("should use the maxTrailingPages attribute", function () { + var compiledControl = initControl(""); + expect(compiledControl.winControl.maxTrailingPages).toEqual(7); + }); it("should use the currentItem attribute", function () { scope.testCurrentItem = { @@ -201,6 +211,19 @@ describe("ListView control directive tests", function () { expect(compiledControl.winControl.layout instanceof WinJS.UI.ListLayout).toBeTruthy(); }); }); + + it("should use the onAccessibilityAnnotationComplete event", function () { + var gotEvent = false; + scope.handler = function (e) { + gotEvent = true; + }; + var compiledControl = initControl("" + + "{{item.data.title}}" + + ""); + waitsFor(function () { + return gotEvent; + }, "the ListView's onAccessibilityAnnotationComplete event", testTimeout); + }); it("should use the onContentAnimating event", function () { var gotAnimatingEvent = false; From d88780555f04977d1f9e2605da49f99077cab1a6 Mon Sep 17 00:00:00 2001 From: AmazingJaze Date: Tue, 18 Aug 2015 01:06:24 -0700 Subject: [PATCH 14/16] Update README.md Fixed typo Updated notes to show how to pass event parameters to Dom Level 0 event handling functions. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f61c692..9c1d7ac 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ How to run unit tests ------------------------- ### Install Node -In order build WinJS, ensure that you have [Node.js](http://nodejs.org/download/) installed. +In order Run tests, ensure that you have [Node.js](http://nodejs.org/download/) installed. ### Run the tests From the local angular-winjs repository @@ -221,4 +221,4 @@ Notes For all of the controls you can bind to: all public events, and camel cased property names, conveniently map to attributes. - ```appBar.closedDisplayMode = "compact"``` maps to `````` -- ```flipView.onpageselected = pagesSelected()``` maps to `````` +- ```flipView.onpageselected = pagesSelected(ev)``` maps to `````` From e7a05203a502689173d2c2abdc969c77190d79a5 Mon Sep 17 00:00:00 2001 From: AmazingJaze Date: Tue, 18 Aug 2015 01:07:23 -0700 Subject: [PATCH 15/16] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9c1d7ac..dd17373 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ How to run unit tests ------------------------- ### Install Node -In order Run tests, ensure that you have [Node.js](http://nodejs.org/download/) installed. +In order run tests, ensure that you have [Node.js](http://nodejs.org/download/) installed. ### Run the tests From the local angular-winjs repository @@ -221,4 +221,4 @@ Notes For all of the controls you can bind to: all public events, and camel cased property names, conveniently map to attributes. - ```appBar.closedDisplayMode = "compact"``` maps to `````` -- ```flipView.onpageselected = pagesSelected(ev)``` maps to `````` +- ```flipView.onpageselected = pagesSelected()``` maps to `````` From e39bfad64ded071ce538cc6f43cf1eda986402a7 Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Tue, 18 Aug 2015 16:44:34 -0700 Subject: [PATCH 16/16] Update README for NavBar and SplitViewCommand --- README.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index dd17373..730b370 100644 --- a/README.md +++ b/README.md @@ -106,16 +106,6 @@ Examples of control usage -### NavBar and friends - - - - - - - - - ### Pivot and PivotItem @@ -161,7 +151,11 @@ Examples of control usage }); - SplitView Navigation Pane + + SplitView Navigation Pane + + + SplitView Content Area