Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Pull request from Oros to BB10-WebWorks-Samples #93

Merged
merged 1 commit into from

2 participants

@oros

Request contains 'eula' project which was approved for OSS by Richard Wallace.

Project provides an easy way to add UTF-8 formatted EULA agreements when an application is starting up based on device language. User can 'always show' or use the built-in local storage functionality to only show once (until accepted.)

Sample EULA text was populated in a handful of languages.

@oros

Catalog updated here:
blackberry/Catalogs#54

@pelegri

THanks, Erik!

@pelegri pelegri merged commit e67888c into blackberry:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 8, 2013
  1. @oros

    Initial commit of eula project.

    oros authored
This page is out of date. Refresh to see the latest.
View
201 eula/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
View
77 eula/README.md
@@ -0,0 +1,77 @@
+Background
+==========
+This framework is intended to provide an easy-to-use EULA component which can be included with any BlackBerry 10 WebWorks application. The developer can leverage
+a series of translated UTF-8 EULA documents to be presented to the end-user at application launch. The selected EULA is based on the device language.
+
+Agreement Format
+================
+This framework depends on UTF-8 text documents that contain the translated EULA ready to be presented. The framework assumes four (4) sections separated by newline characters as follows:
+* Section 0: Agreement title, example: License Agreement
+* Section 1: Agreement section one; primary agreement text.
+* Section 2: Agreement section two; secondary agreement text.
+* Section 3: Accept/decline verbiage.
+
+The accept/decline verbiage should be separated by a **tab** character. Example:
+
+ Agree Verbiage Decline Verbiage
+
+An example of an agreement is as follows:
+
+ LICENSE AGREEMENT
+ This is the primary text of the agreement. The bulk of the agreement will go here including the terms and conditions of use. This section can be as long as you like as the framework will place this content into a scrollable area. This text, along with the next line of text, will be combined in the main body of the license agreement. It is up to you to determine which sort of agreement you want displayed. Now we are just adding more text for the sake of taking up more space.
+ This is the secondary text of the agreement. It will be combined with the above text into the main body of the agreement. Here you can make notes of things like "If you want to see the full agreement online, it can be obtained here..." and then provide a link to a URL. Or something. It's up to you.
+ I Agree I Do Not Agree
+
+config.xml
+==========
+In order to leverage this framework, the following **feature** elements must be present in **config.xml**:
+
+ <feature id="blackberry.app" />
+ <feature id="blackberry.system" />
+
+index.html
+==========
+In order to leverage this framework, you must include the corresponding CSS resource:
+
+ <link type="text/css" rel="stylesheet" href="./eula/eula.css" />
+
+As well as the corresponding JavaScript resources:
+
+ <script type="text/javascript" src="local:///chrome/webworks.js"></script>
+ <script type="text/javascript" src="./eula/eula.js"></script>
+
+This framework relies on WebWorks APIs, thus must be invoked after the **webworksready** event has fired. Sample usage is as follows:
+
+ <script type="text/javascript">
+ window.addEventListener('DOMContentLoaded', function () {
+ document.addEventListener('webworksready', function () {
+ initEULA(function () {
+ console.log('EULA accepted.');
+ });
+
+ document.querySelector('#eula').show(true);
+ }, false);
+ }, false);
+ </script>
+
+**initEULA** must be called first. It contains an **optional** parameter for a callback function; triggered when the EULA is accepted. Following this, **show** can be called.
+This will display the EULA to the end user if:
+* The *alwaysShow* argument is set to **true**
+* The EULA has not been previously accepted.
+
+If the *alwaysShow* argument is set to **false** or omitted, the EULA will only be shown until the first acceptance. After being accepted, it will not be shown again. This is
+achieved by storing a flag in Local Storage.
+
+In the event that a callback is specified and *alwaysShow* is **not true**, the callback will be triggered even if the EULA has already been accepted; in short, a specified callback
+is **always** triggered after callign **show**.
+
+eula.css
+========
+Essentially all of the styling for this framework is contained in the noted CSS file. By modifying the existing styling, you can safely alter the visual styles.
+
+eula.js
+=======
+The core functionality of this framework relies on retrieving the UTF-8 document via an XMLHttpRequest object. The naming convention for your agreements can be
+modified to suit your needs here:
+
+ xhr.open('GET', './eula/agreements/agreement_' + lang + '.txt', true);
View
31 eula/config.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+- Copyright (c) 2012 Research In Motion Limited.
+-
+- Licensed under the Apache License, Version 2.0 (the "License");
+- you may not use this file except in compliance with the License.
+- You may obtain a copy of the License at
+-
+- http://www.apache.org/licenses/LICENSE-2.0
+-
+- Unless required by applicable law or agreed to in writing, software
+- distributed under the License is distributed on an "AS IS" BASIS,
+- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- See the License for the specific language governing permissions and
+- limitations under the License.
+-->
+
+<widget xmlns="http://www.w3.org/ns/widgets"
+ xmlns:rim="http://www.blackberry.com/ns/widgets"
+ version="1.0.0.0"
+ id="com.oros.eula">
+
+ <name>EULA Example</name>
+ <author>Oros</author>
+ <content src="index.html" />
+
+ <!-- Required for eula.js -->
+ <feature id="blackberry.app" />
+ <feature id="blackberry.system" />
+</widget>
View
4 eula/eula/agreements/agreement_ar.txt
@@ -0,0 +1,4 @@
+اتفاقية الترخيص
+هذا هو النص الرئيسي للاتفاق. والجزء الأكبر من اتفاق انتقل هنا بما في ذلك أحكام وشروط الاستخدام. يمكن أن يكون هذا القسم ما دام تحب كإطار سوف تضع هذا المحتوى إلى منطقة قابلة للتمرير. هذا النص، جنبا إلى جنب مع السطر التالي من النص، سيتم الجمع في الجزء الرئيسي من اتفاقية الترخيص. الأمر متروك لكم لتحديد أي نوع من الاتفاق تريد عرضها. الآن نحن فقط إضافة المزيد من النصوص من أجل اتخاذ المزيد من المساحة.
+هذا هو النص الثانوي للاتفاق. وسيتم دمجها مع النص أعلاه في الجزء الرئيسي من الاتفاق. هنا يمكنك تدوين الملاحظات من أشياء مثل "إذا كنت تريد أن ترى اتفاق كامل على الانترنت، ويمكن الحصول عليه هنا ..." ومن ثم توفير ارتباط إلى URL. أو شيء من هذا. والامر متروك لك.
+أوافق لا أوافق
View
4 eula/eula/agreements/agreement_de.txt
@@ -0,0 +1,4 @@
+LIZENZVEREINBARUNG
+Dies ist die primäre Text der Vereinbarung. Der Großteil der Vereinbarung wird hier gehen auch die Bedingungen und Konditionen der Nutzung. Dieser Abschnitt kann so lang sein, wie Sie möchten, wie das Framework diese Inhalte in einem rollbaren Bereich platzieren. Dieser Text zusammen mit der nächsten Zeile des Textes wird in dem Hauptkörper des Lizenzvertrages kombiniert werden. Es liegt an Ihnen zu bestimmen, welche Art von Vereinbarung, die Sie angezeigt haben möchten. Jetzt sind wir einfach nur mit mehr Text aus Gründen der Aufnahme mehr Platz.
+Dies ist der zweite Text der Vereinbarung. Es wird mit dem obigen Text in den Hauptkörper der Vereinbarung kombiniert werden. Hier können Sie sich Notizen machen von Dingen wie "Wenn du die volle Zustimmung online sehen möchten, kann es hier heruntergeladen werden ..." und geben Sie dann einen Link zu einer URL. Oder so etwas. Es ist bis zu Ihnen.
+Ich stimme zu Ich stimme nicht zu
View
4 eula/eula/agreements/agreement_en.txt
@@ -0,0 +1,4 @@
+LICENSE AGREEMENT
+This is the primary text of the agreement. The bulk of the agreement will go here including the terms and conditions of use. This section can be as long as you like as the framework will place this content into a scrollable area. This text, along with the next line of text, will be combined in the main body of the license agreement. It is up to you to determine which sort of agreement you want displayed. Now we are just adding more text for the sake of taking up more space.
+This is the secondary text of the agreement. It will be combined with the above text into the main body of the agreement. Here you can make notes of things like "If you want to see the full agreement online, it can be obtained here..." and then provide a link to a URL. Or something. It's up to you.
+I Agree I Do Not Agree
View
4 eula/eula/agreements/agreement_fr.txt
@@ -0,0 +1,4 @@
+CONTRAT DE LICENCE
+Ceci est le texte principal de l'accord. La majeure partie de l'accord ira ici, y compris les termes et conditions d'utilisation. Cette section peut être aussi longue que vous le souhaitez tant que cadre placera ce contenu dans une zone de défilement. Ce texte, ainsi que la ligne de texte suivante, seront combinés dans le corps principal de l'accord de licence. C'est à vous de déterminer quel type d'accord que vous souhaitez afficher. Maintenant, nous sommes en train d'ajouter plus de texte pour le plaisir de prendre plus de place.
+Ceci est le texte de l'accord secondaire. Il sera combiné avec le texte ci-dessus dans le corps principal de l'accord. Ici vous pouvez prendre des notes sur des choses comme: «Si vous voulez voir la ligne d'un accord, il peut être obtenu ici ..." puis de fournir un lien vers une URL. Ou quelque chose. C'est à vous.
+J'accepte Je n'accepte pas
View
4 eula/eula/agreements/agreement_is.txt
@@ -0,0 +1,4 @@
+vöruupplýsingabæklinginn
+Þetta er fyrst og fremst texti samningsins. Megnið af samningnum mun fara hér á meðal skilmálum og skilyrðum fyrir notkun. Þessi hluti getur verið eins lengi og þú vilt sem ramma mun setja þetta efni í Skrunanlegur svæði. Þessi texti, ásamt næstu línu af texta, verða sameinuð í meginmáli leyfissamningsins. Það er komið að þér að ákveða hvaða tegund af samningi sem þú vilt birta. Nú erum við bara að bæta meiri texta fyrir sakir taka meira pláss.
+Þetta er annar texti samningsins. Það verður að sameina með ofangreindum texta í meginmáli samningsins. Hér er hægt að gera athugasemdir um hluti eins og "Ef þú vilt sjá fulla samkomulagi á netinu, það er hægt að fá hér ..." og þá afla a hlekkur til a URL. Eða eitthvað. Það er komið að þér.
+Ég samþykki Ég samþykki ekki
View
4 eula/eula/agreements/agreement_lo.txt
@@ -0,0 +1,4 @@
+ສັນຍາໃບອະນຸຍາດ
+ນີ້ແມ່ນຕົວຫນັງສືຂັ້ນປະຖົມຂອງການຕົກລົງ. ຫຼາຍຂອງສັນຍາດັ່ງກ່າວຈະໄປຢູ່ທີ່ນີ້ລວມທັງຂໍ້ກໍານົດແລະເງື່ອນໄຂຂອງການນໍາໃຊ້. ໃນພາກນີ້ຈະສາມາດເປັນທີ່ທ່ານຕ້ອງການເປັນໂຄງຮ່າງການຈະຈັດວາງເນື້ອໃນນີ້ເຂົ້າໄປໃນເຂດພື້ນທີ່ scrollable ໄດ້. ຂໍ້ຄວາມນີ້, ຄຽງຄູ່ກັບເສັ້ນຕໍ່ໄປຂອງດິນ, ຈະໄດ້ຮັບການອະນຸຍາດຂອງຢູ່ໃນຮ່າງກາຍຕົ້ນຕໍຂອງການຕົກລົງໃບອະນຸຍາດໄດ້. ມັນເປັນເຖິງທ່ານເພື່ອກໍານົດທີ່ທຂໍ້ຕົກລົງທີ່ທ່ານຕ້ອງການສະແດງ. ໃນປັດຈຸບັນນີ້ພວກເຮົາບໍ່ແມ່ນເພີ່ມຄວາມຫຼາຍສໍາລັບ sake ຂອງກິນຂຶ້ນຊ່ອງຫຼາຍໄດ້.
+ນີ້ແມ່ນຕົວຫນັງສືຂັ້ນສອງຂອງການຕົກລົງ. ມັນຈະໄດ້ຮັບການອະນຸຍາດຂອງທີ່ມີຄວາມຂ້າງເທິງນີ້ເປັນຮ່າງກາຍຕົ້ນຕໍຂອງການຕົກລົງ. ໃນທີ່ນີ້ທ່ານສາມາດເຮັດໃຫ້ນຂອງສິ່ງຕ່າງໆເຊັ່ນວ່າ "ຖ້າທ່ານຕ້ອງການເບິ່ງໄປອອນໄລນສັນຍາດັ່ງກ່າວຢ່າງເຕັມທີ່, ສາມາດໄດ້ຮັບການນີ້ ... " ແລະຫຼັງຈາກນັ້ນໃຫ້ເຊື່ອມຕໍ່ຫາທີ່ຢູ່ເວັບໄຊໃດຫນຶ່ງ. ຫຼືບາງສິ່ງບາງຢ່າງ. ມັນຂຶ້ນກັບທ່ານ.
+ຂ້າພະເຈົ້າເຫັນດີ ຂ້າພະເຈົ້າບໍ່ເຫັນດີນໍາ
View
4 eula/eula/agreements/agreement_ru.txt
@@ -0,0 +1,4 @@
+ЛИЦЕНЗИОННОЕ СОГЛАШЕНИЕ
+Это основной текст соглашения. Основная часть этого соглашения будет идти здесь в том числе сроки и условия использования. Этот раздел может быть столько, сколько вы хотите в качестве основы будет разместить ссылку на этот материал в прокручиваемой области. Этот текст, наряду со следующей строки текста, будут объединены в основной части лицензионного соглашения. Это до вас, чтобы определить, какой вид соглашения, которое будет отображаться. Сейчас мы просто добавить больше текста, ради занимая дополнительное место.
+Это вторичный текст соглашения. Это будет сочетаться с вышеуказанным текстом в основной части соглашения. Здесь вы можете делать пометки вроде "Если вы хотите, чтобы увидеть полный онлайн-соглашение, он может быть получен здесь ..." , а затем дать ссылку на URL. Или что-то. Это зависит от вас.
+Я согласен я не согласен
View
4 eula/eula/agreements/agreement_sk.txt
@@ -0,0 +1,4 @@
+LICENČNÁ ZMLUVA
+Toto je primárny text dohody. Prevažná časť tejto dohody bude ísť sem, vrátane podmienok použitia. Táto časť môže byť tak dlho, ako sa vám páči, ako rámec umiestniť tento obsah do rolovacie oblasti. Tento text, spolu s ďalší riadok textu, budú zlúčené do hlavnej časti licenčnej zmluvy. Je na vás určiť aký typ zmluvy chcete zobraziť. Teraz sme sa len pridáva ďalší text kvôli nástupu do viac priestoru.
+To je sekundárne text dohody. To bude v kombinácii s vyššie uvedeným textom do hlavnej časti dohody. Tu si môžete robiť poznámky o veciach, ako je "Ak chcete zobraziť úplnú dohodu on-line, môže získať tu ..." a potom poskytnúť odkaz na adresu URL. Alebo tak niečo. Je to len na vás.
+Súhlasím Nesúhlasím
View
130 eula/eula/eula.css
@@ -0,0 +1,130 @@
+@charset 'UTF-8';
+
+/*
+- Copyright (c) 2012 Research In Motion Limited.
+-
+- Licensed under the Apache License, Version 2.0 (the "License");
+- you may not use this file except in compliance with the License.
+- You may obtain a copy of the License at
+-
+- http://www.apache.org/licenses/LICENSE-2.0
+-
+- Unless required by applicable law or agreed to in writing, software
+- distributed under the License is distributed on an "AS IS" BASIS,
+- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- See the License for the specific language governing permissions and
+- limitations under the License.
+*/
+
+#eula {
+ display: none;
+ background-color: #222222;
+ position: fixed;
+ left: 0px;
+ right: 0px;
+ top: 0px;
+ bottom: 0px;
+ margin: 0px;
+ padding: 0px;
+ font-family: "Slate Pro", Slate, "Myriad Pro", "BBAlpha Sans", Helvetica;
+ color: #EEEEEE;
+ -webkit-user-select: none;
+}
+
+#eula > .header {
+ position: fixed;
+ left: 0px;
+ right: 0px;
+ top: 0px;
+ height: 100px;
+
+}
+
+.header > .content {
+ position: fixed;
+ left: 0px;
+ right: 0px;
+ top: 32px;
+ text-align: center;
+ font-size: 32px;
+ color: #EEEEEE;
+}
+
+#eula > .eulabox {
+ background-color: #333333;
+ position: fixed;
+ left: 0px;
+ right: 0px;
+ top: 100px;
+ bottom: 160px;
+ padding: 24px;
+ text-align: center;
+ font-size: 32px;
+ overflow-x: hidden;
+ overflow-y: scroll;
+ -webkit-overflow-scrolling: touch;
+}
+
+.eulabox > .content {
+ text-align: left;
+ font-size: 36px;
+ color: #00A8DF;
+}
+
+.eulabox :nth-child(2) {
+ padding: 24px 0px 0px 0px;
+}
+
+#eula > .accept {
+ position: fixed;
+ left: 0px;
+ right: 50%;
+ bottom: 0px;
+ height: 160px;
+}
+
+.accept > .content.image {
+ position: fixed;
+ left: 0px;
+ right: 50%;
+ bottom: 60px;
+ text-align: center;
+ font-size: 36px;
+}
+
+.accept > .content.text {
+ position: fixed;
+ left: 0px;
+ right: 50%;
+ bottom: 24px;
+ text-align: center;
+ font-size: 36px;
+ color: #11FF11;
+}
+
+#eula > .deny {
+ position: fixed;
+ left: 50%;
+ right: 0px;
+ bottom: 0px;
+ height: 160px;
+}
+
+.deny > .content.image {
+ position: fixed;
+ left: 50%;
+ right: 0px;
+ bottom: 60px;
+ text-align: center;
+ font-size: 36px;
+}
+
+.deny > .content.text {
+ position: fixed;
+ left: 50%;
+ right: 0px;
+ bottom: 24px;
+ text-align: center;
+ font-size: 36px;
+ color: #FF1111;
+}
View
180 eula/eula/eula.js
@@ -0,0 +1,180 @@
+/*global blackberry */
+
+/*
+- Copyright (c) 2012 Research In Motion Limited.
+-
+- Licensed under the Apache License, Version 2.0 (the "License");
+- you may not use this file except in compliance with the License.
+- You may obtain a copy of the License at
+-
+- http://www.apache.org/licenses/LICENSE-2.0
+-
+- Unless required by applicable law or agreed to in writing, software
+- distributed under the License is distributed on an "AS IS" BASIS,
+- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- See the License for the specific language governing permissions and
+- limitations under the License.
+*/
+
+function refreshEULA(lang) {
+ var xhr, html;
+
+ /* Create an XMLHttpRequest to retrieve the agreement based on the language specified. */
+ xhr = new XMLHttpRequest();
+ xhr.open('GET', './eula/agreements/agreement_' + lang + '.txt', true);
+ xhr.responseType = 'text';
+ xhr.onload = function () {
+ var sections, lines, n;
+
+ if (this.status === 200) {
+ /**
+ * The intended format for the agreement is four sections separated by new lines:
+ * Section 0: Agreement title, example: License Agreement
+ * Section 1: Agreement section one; primary agreement text.
+ * Section 2: Agreement section two; secondary agreement text.
+ * Section 3: Accept/decline verbiage.
+ */
+ sections = [];
+
+ /**
+ * Trying to make this framework more robust in the event of erroneous new lines. We'll parse out
+ * the data and ensure we're only taking the four sections with actual content.
+ */
+ lines = this.response.split('\n');
+ for (n = 0; n < lines.length; ++n) {
+ if (lines[n].length > 1) {
+ sections.push(lines[n]);
+ }
+ }
+
+ /* Place Section 0 into the title. */
+ document.querySelector('.header > .content').innerHTML = sections[0];
+
+ /* Merge Section 1 and Section 2 into the main EULA body. */
+ html = '';
+ html += '<div class="content">' + sections[1] + '</div>';
+ html += '<div class="content">' + sections[2] + '</div>';
+ document.querySelector('.eulabox').innerHTML = html;
+
+ /**
+ * The intended format for Section 3 is:
+ * Accept[tab]Decline
+ *
+ * Where:
+ * - Accept refers to the translated acceptance verbiage, example: I Agree
+ * - Decline refers to the translated decline verbiage, example: I Do Not Agree
+ * - [tab] is an actual TAB character separating the two.
+ *
+ * In creating this sample, it was identified that the source was not always consistent, and sometimes
+ * instead of TAB separators &nbsp; characters were used instead. The following code can be expanded on
+ * to deal with additional characters, but for now splits up Section 3's verbiage based on &nbsp; characters
+ * as well as TAB characters.
+ */
+ if (sections[3].indexOf(String.fromCharCode('160')) > -1) {
+ /* &nbsp; */
+ lines = sections[3].split(String.fromCharCode('160'));
+ } else if (sections[3].indexOf(String.fromCharCode('9')) > -1) {
+ /* tab */
+ lines = sections[3].split(String.fromCharCode('9'));
+ }
+ sections = [];
+
+ /* After splitting Section 3, we retrive the Accept and Decline verbiage into the Sections variable. */
+ for (n = 0; n < lines.length; ++n) {
+ if (lines[n].length > 1) {
+ sections.push(lines[n]);
+ }
+ }
+
+ /* Populate the Accept and Decline verbiage on the screen. */
+ document.querySelector('.accept > .content.text').innerHTML = sections[0];
+ document.querySelector('.deny > .content.text').innerHTML = sections[1];
+ }
+ };
+ xhr.send();
+}
+
+function initEULA(acceptCallback) {
+ var elements, zIndex, container, lang, html, n, z;
+
+ /* Grab all elements to find the highest z-index. */
+ elements = document.querySelectorAll('*');
+ zIndex = 0;
+
+ /* Grab the largest z-index. */
+ for (n = elements.length - 1; n > -1; --n) {
+ z = parseInt(elements[n].style.zIndex, 10);
+ if (z > zIndex) {
+ zIndex = z;
+ }
+ }
+
+ /* Retrieve system language. */
+ lang = blackberry.system.language.substring(0, 2);
+
+ /* Create our main container. */
+ container = document.createElement('div');
+ container.id = 'eula';
+ container.style.zIndex = zIndex + 1;
+
+ /* Show the container if (alwaysShow is true) or (the EULA has not yet been accepted). */
+ container.show = function (alwaysShow) {
+ if (alwaysShow === true) {
+ document.querySelector('#eula').style.display = 'block';
+ } else if (window.localStorage.getItem('EULA_ACCEPTED') === null) {
+ document.querySelector('#eula').style.display = 'block';
+ } else {
+ if (typeof (acceptCallback) !== 'undefined') {
+ acceptCallback();
+ }
+ }
+ };
+
+ /* Hide the container. */
+ container.hide = function () {
+ document.querySelector('#eula').style.display = 'none';
+ };
+
+ /* Populate the EULA page. */
+ html = '';
+ html += '<div class="header">';
+ html += '<div class="content">';
+ html += '</div>';
+ html += '</div>';
+ html += '<div class="eulabox"></div>';
+ html += '<div class="accept">';
+ html += '<div class="content image">';
+ html += '<img src="./eula/ic_done.png" />';
+ html += '</div>';
+ html += '<div class="content text">';
+ html += '</div>';
+ html += '</div>';
+ html += '<div class="deny">';
+ html += '<div class="content image">';
+ html += '<img src="./eula/ic_cancel.png" />';
+ html += '</div>';
+ html += '<div class="content text">';
+ html += '</div>';
+ html += '</div>';
+ container.innerHTML = html;
+
+ /* Add the EULA page to the document. */
+ document.body.appendChild(container);
+
+ /* View the license agreement. */
+ refreshEULA(lang);
+
+ /* EULA accepted. */
+ document.querySelector('.accept').addEventListener('click', function () {
+ window.localStorage.setItem('EULA_ACCEPTED', 'true');
+ document.querySelector('#eula').hide();
+ if (typeof (acceptCallback) !== 'undefined') {
+ acceptCallback();
+ }
+ }, false);
+
+ /* EULA rejected. */
+ document.querySelector('.deny').addEventListener('click', function () {
+ blackberry.app.exit();
+ }, false);
+}
View
BIN  eula/eula/ic_cancel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  eula/eula/ic_done.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
66 eula/index.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+
+<!--
+- Copyright (c) 2012 Research In Motion Limited.
+-
+- Licensed under the Apache License, Version 2.0 (the "License");
+- you may not use this file except in compliance with the License.
+- You may obtain a copy of the License at
+-
+- http://www.apache.org/licenses/LICENSE-2.0
+-
+- Unless required by applicable law or agreed to in writing, software
+- distributed under the License is distributed on an "AS IS" BASIS,
+- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- See the License for the specific language governing permissions and
+- limitations under the License.
+-->
+
+<html>
+ <head>
+ <title>EULA Example</title>
+ <link type="text/css" rel="stylesheet" href="./eula/eula.css" />
+ </head>
+ <body>
+ Hello World!
+ <script type="text/javascript" src="local:///chrome/webworks.js"></script>
+ <script type="text/javascript" src="./eula/eula.js"></script>
+ <script type="text/javascript">
+ /*global initEULA, refreshEULA */
+
+ window.addEventListener('DOMContentLoaded', function () {
+ document.addEventListener('webworksready', function () {
+ /**
+ * initEULA: Must be called before calling the show function.
+ * OPTIONAL: Provide a callback function for when the EULA is accepted. This can be used to hold off performing
+ * various actions until the user has actually agreed to the EULA.
+ */
+ initEULA(function () {
+ console.log('EULA accepted.');
+ });
+
+ /**
+ * show: Called to display the EULA.
+ * OPTIONAL: If the developer provides a true flag, the EULA will always be shown on startup. If the developer
+ * provides a false flag, or no flag at all, the EULA will only be shown once, until it is accepted.
+ * Once accepted, a value is set in LocalStorage to keep track of whether it's been accepted for future
+ * reference. If a callback function is provided in initEULA, it will also be invoked upon acceptance.
+ */
+ document.querySelector('#eula').show(true);
+
+ /*****************************************************************************************************************/
+ /** This code is purely for demonstration purposes. Tapping on the EULA will cycle through available languages. **/
+ /*****************************************************************************************************************/
+ /**/ var langs = ['ar', 'de', 'fr', 'is', 'lo', 'ru', 'sk', 'en'],
+ /**/ index = 0; /**/
+ /**/ /**/
+ /**/ document.querySelector('#eula > .eulabox').addEventListener('click', function () { /**/
+ /**/ refreshEULA(langs[index]); /**/
+ /**/ index = (index + 1) % langs.length; /**/
+ /**/ }, false); /**/
+ /*****************************************************************************************************************/
+ }, false);
+ }, false);
+ </script>
+ </body>
+</html>
Something went wrong with that request. Please try again.