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

Unified Diff: samples/pop_pop_win/web/platform_web.dart

Issue 786443002: Delete pop-pop-win from the repo (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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/pop_pop_win/web/index.html ('k') | samples/samples.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/pop_pop_win/web/platform_web.dart
diff --git a/samples/pop_pop_win/web/platform_web.dart b/samples/pop_pop_win/web/platform_web.dart
deleted file mode 100644
index fbeb0662121c13938a772c531c56d1faee75eeb1..0000000000000000000000000000000000000000
--- a/samples/pop_pop_win/web/platform_web.dart
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-library pop_pop_win.platform_web;
-
-import 'dart:async';
-import 'dart:html';
-import 'package:pop_pop_win/platform_target.dart';
-
-class PlatformWeb extends PlatformTarget {
- static const String _ABOUT_HASH = '#about';
- bool _sizeAccessed = false;
-
- 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]);
-
- int get size {
- _sizeAccessed = true;
- var hash = (_urlHash == null) ? '7' : _urlHash;
- hash = hash.replaceAll('#', '');
- return int.parse(hash, onError: (e) => 7);
- }
-
- bool get showAbout => _urlHash == _ABOUT_HASH;
-
- Stream get aboutChanged => _aboutController.stream;
-
- void toggleAbout([bool value]) {
- var loc = window.location;
- // ensure we treat empty hash like '#', which makes comparison easy later
- var hash = loc.hash.length == 0 ? '#' : loc.hash;
-
- var 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() {
- var loc = window.location;
- var hash = loc.hash;
- var href = loc.href;
-
- 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 _ABOUT_HASH:
- _aboutController.add(null);
- break;
- default:
- if (hash.isNotEmpty && _sizeAccessed) {
- loc.reload();
- }
- break;
- }
- }
-}
« no previous file with comments | « samples/pop_pop_win/web/index.html ('k') | samples/samples.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698