From 87cd4036b820cfcf865d6f6a1b274e2d4e826371 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Fri, 15 Mar 2013 12:11:22 +0100 Subject: [PATCH] panel widget: added data-opened bidi databinding --- Changelog.md | 2 + README.md | 9 +- ...query-mobile-angular-adapter-standalone.js | 83 +++++++++++-------- compiled/jquery-mobile-angular-adapter.js | 83 +++++++++++-------- src/integration/widgetAdapters.js | 83 +++++++++++-------- test/devSnippetPage.html | 34 ++++---- test/unit/integration/panelSpec.js | 39 +++++++++ 7 files changed, 205 insertions(+), 128 deletions(-) create mode 100644 test/unit/integration/panelSpec.js diff --git a/Changelog.md b/Changelog.md index 15b9e20..a4d9f5d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,7 +5,9 @@ Changelog ----- Features: - upgrade to angular 1.0.5, jqm 1.3 and jquery 1.9 + * `table` widget does not refresh if new rows are added. Jqm will add this in jqm 1.3.1 (https://github.com/jquery/jquery-mobile/issues/5570). - popup widget has bidi databinding for `data-opened` attribute. +- panel widget has bidi databinding for `data-opened` attribute. - Refactored build system to grunt.js, testacular and travis-ci. - Added provider `jqmNgWidget` to easily adapter new jqm plugins with angular. Also automatically detects widgets of jqm plugins and registers angular directives for them. diff --git a/README.md b/README.md index 5f7958a..78e6140 100644 --- a/README.md +++ b/README.md @@ -370,12 +370,19 @@ Note: `pagerId.cache` stores the last result that was returns for a `list | page ### widget `popup` -- the jqm adapter does not change the url when a popup is opened, and therefore does not go back when the popup is closed. This is due to the fact that popups cannot be addressed using a url, in contrast to dialogs. +- the jqm adapter does not change the url when a popup is opened/closed. This is due to the fact that the jqm adatper assumes that urls represent routings for pages, and not parts of pages. - The new attribute `data-opened` has bidirectional data binding for opening/closing the popup, e.g.
...
+### widget `panel` + +- the jqm adapter does not change the url when a panel is opened/closed. This is due to the fact that the jqm adatper assumes that urls represent routings for pages, and not parts of pages. + +- The new attribute `data-opened` has bidirectional data binding for opening/closing the panel, e.g. + +
...
### widget `slider` in a ` + + +
+ Popup +
- + +
+
+ Content +
+
diff --git a/test/unit/integration/panelSpec.js b/test/unit/integration/panelSpec.js new file mode 100644 index 0000000..ed7aa2f --- /dev/null +++ b/test/unit/integration/panelSpec.js @@ -0,0 +1,39 @@ +describe("panel", function () { + describe('data-opened', function() { + var panel, scope, panelSpy, widget; + beforeEach(function() { + panelSpy = testutils.spyOnJq('panel').andCallThrough(); + }); + function init(openedAttribute) { + var c = testutils.compile('
'); + panelSpy.reset(); + panel = c.find("#panel1"); + widget = panel.data($.mobile.panel.prototype.widgetFullName); + scope = c.scope(); + } + + it('should update the data-opened variable', function () { + init('openVar'); + expect(scope.openVar).toBeUndefined(); + expect(widget._open).toBe(false); + panel.panel("open"); + expect(scope.openVar).toBe(true); + expect(widget._open).toBe(true); + }); + it('should work with fixed data-opened value', function () { + init('true'); + expect(widget._open).toBe(true); + panel.panel("close"); + // expect no exception here. + expect(widget._open).toBe(false); + }); + it("should update the ui when data-opened changes", function() { + init('openVar'); + expect(widget._open).toBe(false); + scope.openVar = true; + scope.$digest(); + expect(widget._open).toBe(true); + }); + + }); +});