From 821413607a0718156f9d25d895e89b1c3d37aa8b Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Wed, 06 Feb 2013 13:49:14 +0000 Subject: Copy various bits from gaia --- (limited to 'apps/system/js/source_view.js') diff --git a/apps/system/js/source_view.js b/apps/system/js/source_view.js new file mode 100644 index 0000000..dc6b8e4 --- /dev/null +++ b/apps/system/js/source_view.js @@ -0,0 +1,67 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + +var SourceView = { + get viewer() { + return document.getElementById('appViewsource'); + }, + + get active() { + return !this.viewer ? false : this.viewer.style.visibility === 'visible'; + }, + + init: function sv_init() { + window.addEventListener('home+volume', function() { + if (ScreenManager.screenEnabled) + SourceView.toggle(); + }); + window.addEventListener('locked', function() { + SourceView.hide(); + }); + }, + + show: function sv_show() { + var viewsource = this.viewer; + if (!viewsource) { + var style = '#appViewsource { ' + + ' position: absolute;' + + ' top: -moz-calc(10%);' + + ' left: -moz-calc(10%);' + + ' width: -moz-calc(80% - 2 * 15px);' + + ' height: -moz-calc(80% - 2 * 15px);' + + ' visibility: hidden;' + + ' margin: 15px;' + + ' background-color: white;' + + ' opacity: 0.92;' + + ' color: black;' + + ' z-index: 9999;' + + '}'; + document.styleSheets[0].insertRule(style, 0); + + viewsource = document.createElement('iframe'); + viewsource.id = 'appViewsource'; + document.body.appendChild(viewsource); + } + + var url = WindowManager.getDisplayedApp(); + if (!url) + // Assume the home screen is the visible app. + url = window.location.toString(); + viewsource.src = 'view-source: ' + url; + viewsource.style.visibility = 'visible'; + }, + + hide: function sv_hide() { + var viewsource = this.viewer; + if (viewsource) { + viewsource.style.visibility = 'hidden'; + viewsource.src = 'about:blank'; + } + }, + + toggle: function sv_toggle() { + this.active ? this.hide() : this.show(); + } +}; -- cgit v0.9.1