Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Unified Diff: samples/third_party/pop-pop-win/web/platform_web.dart

Issue 200723008: samples/poppopwin: upgrade to first-class sample (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixed pkgbuild.status for rename Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/third_party/pop-pop-win/web/index.html ('k') | samples/third_party/pop-pop-win/web/style.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/third_party/pop-pop-win/web/platform_web.dart
diff --git a/samples/third_party/pop-pop-win/web/platform_web.dart b/samples/third_party/pop-pop-win/web/platform_web.dart
deleted file mode 100644
index 721066d2a74f79996d85f4ab498eed606f6cb401..0000000000000000000000000000000000000000
--- a/samples/third_party/pop-pop-win/web/platform_web.dart
+++ /dev/null
@@ -1,99 +0,0 @@
-library ppw_platform_web;
-
-import 'dart:async';
-import 'dart:html';
-import 'dart:js' as js;
-import 'package:poppopwin/platform_target.dart';
-
-class PlatformWeb extends PlatformTarget {
- static const String _BIG_HASH = '#big';
- static const String _ABOUT_HASH = '#about';
-
- final StreamController _aboutController = new StreamController(sync: true);
-
- PlatformWeb() : super.base() {
- window.onPopState.listen((args) => _processUrlHash());
- }
-
- @override
- Future clearValues() {
- window.localStorage.clear();
- return new Future.value();
- }
-
- @override
- Future setValue(String key, String value) {
- window.localStorage[key] = value;
- return new Future.value();
- }
-
- @override
- Future<String> getValue(String key) =>
- new Future.value(window.localStorage[key]);
-
- @override
- void trackAnalyticsEvent(String category, String action, [String label,
- int value]) {
- var args = ['send', 'event', category, action];
- if(label != null) {
- args.add(label);
- }
-
- if(value != null) {
- assert(label != null);
- args.add(value);
- }
-
- js.context.callMethod('ga', args);
- }
-
- bool get renderBig => _urlHash == _BIG_HASH;
-
- bool get showAbout => _urlHash == _ABOUT_HASH;
-
- Stream get aboutChanged => _aboutController.stream;
-
- void toggleAbout([bool value]) {
- final Location loc = window.location;
- // ensure we treat empty hash like '#', which makes comparison easy later
- final hash = loc.hash.length == 0 ? '#' : loc.hash;
-
- final isOpen = hash == _ABOUT_HASH;
- if(value == null) {
- // then toggle the current value
- value = !isOpen;
- }
-
- var targetHash = value ? _ABOUT_HASH : '#';
- if(targetHash != hash) {
- loc.assign(targetHash);
- }
- _aboutController.add(null);
- }
-
- String get _urlHash => window.location.hash;
-
- void _processUrlHash() {
- final Location loc = window.location;
- final hash = loc.hash;
- final href = loc.href;
-
- final History history = window.history;
- switch(hash) {
- case "#reset":
- assert(href.endsWith(hash));
- var newLoc = href.substring(0, href.length - hash.length);
-
- window.localStorage.clear();
-
- loc.replace(newLoc);
- break;
- case _BIG_HASH:
- loc.reload();
- break;
- case _ABOUT_HASH:
- _aboutController.add(null);
- break;
- }
- }
-}
« no previous file with comments | « samples/third_party/pop-pop-win/web/index.html ('k') | samples/third_party/pop-pop-win/web/style.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698