You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by wk...@apache.org on 2014/07/15 09:51:41 UTC
svn commit: r1610605 [1/7] - in /incubator/devicemap/trunk/browsermap: ./
.settings/ branches/ tags/ tags/browsermap-1.3.0/ tags/browsermap-1.3.0/ci/
tags/browsermap-1.3.0/src/ tags/browsermap-1.3.0/src/main/
tags/browsermap-1.3.0/src/main/js/ tags/bro...
Author: wkeil
Date: Tue Jul 15 07:51:39 2014
New Revision: 1610605
URL: http://svn.apache.org/r1610605
Log:
Trying to bring back the redundancies in Browsermap to allow adjustments to Git sync
Added:
incubator/devicemap/trunk/browsermap/.project
incubator/devicemap/trunk/browsermap/.settings/
incubator/devicemap/trunk/browsermap/.settings/org.jboss.ide.eclipse.as.core.prefs
incubator/devicemap/trunk/browsermap/branches/
incubator/devicemap/trunk/browsermap/branches/.gitignore
incubator/devicemap/trunk/browsermap/tags/
incubator/devicemap/trunk/browsermap/tags/.gitignore
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.gitignore
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.travis.yml
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/Gruntfile.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/LICENSE
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/NOTICE
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/README.md
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/ci/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/ci/jenkins_build.sh
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/package.json
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/js/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/js/bmap.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/js/bmaputil.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/js/devicegroups.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/js/probes.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/lib/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/lib/matchMedia/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/lib/matchMedia/matchMedia.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/lib/modernizr/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/lib/modernizr/modernizr.custom.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/resources/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/resources/demo/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/resources/demo/css/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/resources/demo/css/style.css
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/resources/demo/index.html
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/resources/demo/js/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/resources/demo/js/showcase.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/test/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/test/js/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/test/js/tests.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/test/karma.conf.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/test/resources/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/test/resources/qunit/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/test/resources/qunit/qunit-1.9.0.css
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/test/resources/qunit/qunit-1.9.0.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/test/resources/tests.html
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/.gitignore
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/.travis.yml
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/Gruntfile.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/LICENSE
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/NOTICE
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/README.md
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/ci/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/ci/jenkins_build.sh
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/package.json
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/js/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/js/bmap.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/js/bmaputil.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/js/devicegroups.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/js/probes.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/lib/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/lib/matchMedia/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/lib/matchMedia/matchMedia.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/lib/modernizr/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/lib/modernizr/modernizr.custom.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/resources/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/resources/demo/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/resources/demo/css/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/resources/demo/css/style.css
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/resources/demo/index.html
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/resources/demo/js/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/main/resources/demo/js/showcase.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/test/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/test/js/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/test/js/tests.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/test/karma.conf.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/test/resources/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/test/resources/qunit/
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/test/resources/qunit/qunit-1.9.0.css
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/test/resources/qunit/qunit-1.9.0.js
incubator/devicemap/trunk/browsermap/tags/browsermap-1.4.0/src/test/resources/tests.html
incubator/devicemap/trunk/browsermap/trunk/
incubator/devicemap/trunk/browsermap/trunk/.gitignore
incubator/devicemap/trunk/browsermap/trunk/.travis.yml
incubator/devicemap/trunk/browsermap/trunk/Gruntfile.js
incubator/devicemap/trunk/browsermap/trunk/LICENSE
incubator/devicemap/trunk/browsermap/trunk/NOTICE
incubator/devicemap/trunk/browsermap/trunk/README.md
incubator/devicemap/trunk/browsermap/trunk/ci/
incubator/devicemap/trunk/browsermap/trunk/ci/jenkins_build.sh
incubator/devicemap/trunk/browsermap/trunk/package.json
incubator/devicemap/trunk/browsermap/trunk/src/
incubator/devicemap/trunk/browsermap/trunk/src/main/
incubator/devicemap/trunk/browsermap/trunk/src/main/js/
incubator/devicemap/trunk/browsermap/trunk/src/main/js/bmap.js
incubator/devicemap/trunk/browsermap/trunk/src/main/js/bmaputil.js
incubator/devicemap/trunk/browsermap/trunk/src/main/js/devicegroups.js
incubator/devicemap/trunk/browsermap/trunk/src/main/js/probes.js
incubator/devicemap/trunk/browsermap/trunk/src/main/lib/
incubator/devicemap/trunk/browsermap/trunk/src/main/lib/matchMedia/
incubator/devicemap/trunk/browsermap/trunk/src/main/lib/matchMedia/matchMedia.js
incubator/devicemap/trunk/browsermap/trunk/src/main/lib/modernizr/
incubator/devicemap/trunk/browsermap/trunk/src/main/lib/modernizr/modernizr.custom.js
incubator/devicemap/trunk/browsermap/trunk/src/main/resources/
incubator/devicemap/trunk/browsermap/trunk/src/main/resources/demo/
incubator/devicemap/trunk/browsermap/trunk/src/main/resources/demo/css/
incubator/devicemap/trunk/browsermap/trunk/src/main/resources/demo/css/style.css
incubator/devicemap/trunk/browsermap/trunk/src/main/resources/demo/index.html
incubator/devicemap/trunk/browsermap/trunk/src/main/resources/demo/js/
incubator/devicemap/trunk/browsermap/trunk/src/main/resources/demo/js/showcase.js
incubator/devicemap/trunk/browsermap/trunk/src/test/
incubator/devicemap/trunk/browsermap/trunk/src/test/js/
incubator/devicemap/trunk/browsermap/trunk/src/test/js/tests.js
incubator/devicemap/trunk/browsermap/trunk/src/test/karma.conf.js
incubator/devicemap/trunk/browsermap/trunk/src/test/resources/
incubator/devicemap/trunk/browsermap/trunk/src/test/resources/qunit/
incubator/devicemap/trunk/browsermap/trunk/src/test/resources/qunit/qunit-1.9.0.css
incubator/devicemap/trunk/browsermap/trunk/src/test/resources/qunit/qunit-1.9.0.js
incubator/devicemap/trunk/browsermap/trunk/src/test/resources/tests.html
Added: incubator/devicemap/trunk/browsermap/.project
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/.project?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/.project (added)
+++ incubator/devicemap/trunk/browsermap/.project Tue Jul 15 07:51:39 2014
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>browsermap0</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
Added: incubator/devicemap/trunk/browsermap/.settings/org.jboss.ide.eclipse.as.core.prefs
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/.settings/org.jboss.ide.eclipse.as.core.prefs?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/.settings/org.jboss.ide.eclipse.as.core.prefs (added)
+++ incubator/devicemap/trunk/browsermap/.settings/org.jboss.ide.eclipse.as.core.prefs Tue Jul 15 07:51:39 2014
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.jboss.ide.eclipse.as.core.singledeployable.deployableList=
Added: incubator/devicemap/trunk/browsermap/branches/.gitignore
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/branches/.gitignore?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/branches/.gitignore (added)
+++ incubator/devicemap/trunk/browsermap/branches/.gitignore Tue Jul 15 07:51:39 2014
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
Added: incubator/devicemap/trunk/browsermap/tags/.gitignore
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/.gitignore?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/.gitignore (added)
+++ incubator/devicemap/trunk/browsermap/tags/.gitignore Tue Jul 15 07:51:39 2014
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
Added: incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.gitignore
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.gitignore?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.gitignore (added)
+++ incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.gitignore Tue Jul 15 07:51:39 2014
@@ -0,0 +1,4 @@
+node_modules/
+target/
+.idea/
+*.iml
Added: incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.travis.yml
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.travis.yml?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.travis.yml (added)
+++ incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/.travis.yml Tue Jul 15 07:51:39 2014
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+language: node_js
+
+node_js:
+ - 0.8
+
+before_install:
+ - git submodule update --init --recursive
+
+before_script:
+ - npm install -g grunt-cli
+ - npm install -g jscoverage
+
+# whitelist
+branches:
+ only:
+ - trunk
Added: incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/Gruntfile.js
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/Gruntfile.js?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/Gruntfile.js (added)
+++ incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/Gruntfile.js Tue Jul 15 07:51:39 2014
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/*global module:false,require:false */
+module.exports = function (grunt) {
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+ karma: {
+ unit: {
+ configFile: 'src/test/karma.conf.js',
+ autoWatch: true
+ },
+ continuous: {
+ configFile: 'src/test/karma.conf.js',
+ singleRun: true,
+ browsers: ['PhantomJS']
+ }
+ },
+ jshint: {
+ // only check BrowserMap files and Gruntfile.js
+ files: {
+ src: [
+ 'Gruntfile.js',
+ 'src/main/js/*.js'
+ ]
+ },
+ options: {
+ browser: true,
+ curly: true,
+ forin: true,
+ camelcase: true,
+ quotmark: true,
+ undef: true,
+ unused: true,
+ trailing: true,
+ maxlen: 140,
+ multistr: true
+ }
+ },
+ copy: {
+ browsermap: {
+ files: [
+ {src: ['src/main/js/*.js'], dest: 'target/libs/browsermap/', expand: true, flatten: true},
+ {cwd: 'src/main/resources/demo/', src: ['**'], dest: 'target/demo/', expand: true},
+ {cwd: 'src/main/lib/', src: ['**'], dest: 'target/libs/externals/', expand: true}
+ ]
+ },
+ minified: {
+ files: [
+ {src: ['target/libs/min/browsermap.min.js'], dest: 'target/demo/js/browsermap.min.js'}
+ ]
+ }
+ },
+ uglify: {
+ options: {
+ banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n',
+ mangle: {
+ except: ['BrowserMap', 'BrowserMapUtil', 'Modernizr']
+ }
+ },
+ target: {
+ files: {
+ 'target/libs/min/browsermap.min.js': [
+ 'target/libs/browsermap/bmaputil.js',
+ 'target/libs/browsermap/bmap.js',
+ 'target/libs/externals/modernizr/modernizr.custom.js',
+ 'target/libs/externals/matchMedia/matchMedia.js',
+ 'target/libs/browsermap/probes.js',
+ 'target/libs/browsermap/devicegroups.js'
+ ]
+ }
+ }
+ },
+ jsdoc: {
+ dist: {
+ src: ['src/main/js/*.js', 'README.md'],
+ dest: 'target/doc'
+ }
+ },
+ compress: {
+ browsermap: {
+ options: {
+ archive: 'target/browsermap-<%= pkg.version %>.zip',
+ mode: 'zip'
+ },
+ files: [
+ {src: ['LICENSE', 'NOTICE', 'README.md'], dest: '.'},
+ {cwd: 'target/demo', src: ['**'], dest: 'demo/', expand: true},
+ {cwd: 'target/doc/', src: ['**'], dest: 'doc/', expand: true},
+ {cwd: 'target/libs/', src: ['browsermap/**'], dest: 'libs/', expand: true},
+ {cwd: 'target/libs/', src: ['externals/**'], dest: 'libs/', expand: true},
+ {cwd: 'target/libs/min/', src: ['*.js'], dest: 'libs/', expand: true}
+ ]
+ }
+ },
+ 'qunit-cov': {
+ test: {
+ minimum: 0.4,
+ srcDir: 'src/main/js',
+ depDirs: ['src/test'],
+ outDir: 'target/coverage',
+ testFiles: ['src/test/resources/*.html']
+ }
+ },
+ clean: ['target/'],
+ demo: {
+ demoFolder: 'target/demo/',
+ templateFile: 'index.html',
+ selectors: [
+ 'browser',
+ 'highResolutionDisplay',
+ 'oldBrowser',
+ 'smartphone.highResolutionDisplay',
+ 'smartphone',
+ 'tablet.highResolutionDisplay',
+ 'tablet'
+ ]
+ },
+ sourcetemplates: {
+ files: ['target/libs/browsermap/bmap.js']
+ }
+ });
+
+ grunt.registerTask('demo', 'Provides the demo pages', function() {
+ grunt.task.requires('clean', 'test', 'copy:browsermap', 'minify', 'copy:minified');
+ var data = grunt.config('demo'),
+ evaluatedContent,
+ path = require('path');
+ if (data) {
+ if (!data.demoFolder) {
+ grunt.log.error('No demo folder has been defined (demo.demoFolder).');
+ return;
+ }
+ if (!data.templateFile) {
+ grunt.log.error('No template file has been defined (demo.templateFile).');
+ return;
+ }
+ if (!data.selectors || data.selectors.length < 1) {
+ grunt.log.error('No selectors have been defined (demo.selectors).');
+ return;
+ }
+ var templateFile = path.join(data.demoFolder, data.templateFile);
+ evaluatedContent = grunt.template.process(grunt.file.read(templateFile));
+ grunt.file.write(templateFile, evaluatedContent);
+ for (var i = 0; i < data.selectors.length; i++) {
+ var fileName = data.templateFile.replace('.html', '.' + data.selectors[i] + '.html');
+ grunt.file.write(path.join(data.demoFolder, fileName), evaluatedContent);
+ }
+ grunt.log.writeln('Generated demo site at ' + data.demoFolder);
+ } else {
+ grunt.log.error('Cannot find a configuration for the demo task!');
+ return;
+ }
+ });
+
+ grunt.registerTask('sourcetemplates', 'Replaces templates from source files', function() {
+ grunt.task.requires('clean', 'test', 'copy:browsermap');
+ var data = grunt.config('sourcetemplates'),
+ path = require('path'),
+ files,
+ file,
+ content;
+ if (data) {
+ files = data.files;
+ if (!files || !(files instanceof Array)) {
+ grunt.log.error('No files array defined.');
+ return;
+ }
+ for (var i = 0; i < files.length; i++) {
+ file = path.normalize(files[i]);
+ content = grunt.template.process(grunt.file.read(file));
+ grunt.file.write(file, content);
+ grunt.log.writeln('Replaced template variables at ' + file);
+ }
+ } else {
+ grunt.log.error('Cannot find a configuration for the sourcetemplates task!');
+ return;
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-karma');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-jsdoc');
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ grunt.loadNpmTasks('grunt-contrib-copy');
+ grunt.loadNpmTasks('grunt-contrib-compress');
+ grunt.loadNpmTasks('grunt-qunit-cov');
+
+ grunt.registerTask('minify', ['uglify']);
+ grunt.registerTask('coverage', ['qunit-cov']);
+ grunt.registerTask('test', ['jshint', 'karma:continuous', 'coverage']);
+ grunt.registerTask('package', ['clean', 'test', 'copy:browsermap', 'sourcetemplates', 'minify', 'copy:minified', 'demo', 'jsdoc',
+ 'compress']);
+};
Added: incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/LICENSE
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/LICENSE?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/LICENSE (added)
+++ incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/LICENSE Tue Jul 15 07:51:39 2014
@@ -0,0 +1,176 @@
+ 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
Added: incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/NOTICE
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/NOTICE?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/NOTICE (added)
+++ incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/NOTICE Tue Jul 15 07:51:39 2014
@@ -0,0 +1,53 @@
+Apache DeviceMap
+Copyright 2013 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache DeviceMap includes subcomponents with separate copyright notices and
+license terms. Your use of these subcomponents is subject to the terms
+and conditions of the following licenses.
+
+Modernizr
+
+ Copyright (c) 2009â2013
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+matchMedia.js
+
+ Copyright (c) 2012 Scott Jehl
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
Added: incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/README.md
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/README.md?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/README.md (added)
+++ incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/README.md Tue Jul 15 07:51:39 2014
@@ -0,0 +1,81 @@
+# Apache DeviceMap - BrowserMap module [![Build Status](https://travis-ci.org/apache/devicemap-browsermap.png?branch=trunk)](https://travis-ci.org/apache/devicemap-browsermap)
+
+BrowserMap is a JavaScript browser features detection library. It uses modular probes and code snippets that detect specific features of the client; these are then used to detect the client's type and to optimize page rendering or to provide the client with alternate website versions.
+
+In addition, BrowserMap is capable of detecting the device groups a client belongs to. The following groups are provided by default:
+
+* `smartphone` - feature phones / smartphones;
+* `tablet` - various tablets, based on screen size and the presence of touch capabilities (the touch events Modernizr test is used for this feature);
+* `highResolutionDisplay` - devices that report a device pixel ratio greater or equal than 2, such as: iPhone 4 and above, iPod Touch gen. 4 and above, iPad 3, Samsung Galaxy S3, etc.;
+* `browser` - desktop browsers capable of CSS 3D transitions (another Modernizr test is used for this feature)
+* `oldBrowser` - less modern desktop browsers
+
+## Demo
+A small demo is available at [http://devicemap-vm.apache.org/browsermap/index.html](http://devicemap-vm.apache.org/browsermap/index.html).
+
+## Features
+
+* extensible probing mechanism;
+* on-demand probing with probes' results cache and cache clearing mechanism;
+* easy mechanism for overriding pre-defined device groups / adding new device groups;
+* three ways of determining the correct URL to which a client should be forwarded, depending on its device group, in order of importance:
+ * usage of `<link rel="alternate" hreflang="<language_code>" data-bmap-devgroups="<device_group_name_list>" href="<alternate_url>" />` tags in BrowserMap enabled pages;
+ * a specific URL defined for each `DeviceGroup` JavaScript object added to the `BrowserMap` JavaScript object (e.g. `http://www.example.com` for `browser`, `http://m.example.com` for `smartphone`);
+ * modify the current URL to include a `DeviceGroup` selector, in case none of the previous two methods has been set up (e.g. `http://www.example.com/index.smartphone.html` for the `smartphone` device group);
+* device group override (by using a combined mechanism of a `GET` parameter and cookie storage) so that a client from a certain device group can access the pages designed for a different device group; for clients that do not support cookies, the device group override uses just a `GET` parameter which can optionally be appended to each URL pointing to a resource from the same domain as the current resource.
+
+## BrowserMap relevant files
+The BrowserMap code is organised in two base folders:
+
+* `libs/browsermap/`:
+ * `bmap.js` - this is where the `BrowserMap` object is defined (main object used for device detection)
+ * `bmaputil.js` - file containing helper objects and methods
+ * `devicegroups.js` - file containing the `DeviceGroups` object descriptions for each identified device group
+ * `probes.js` - file containing various `BrowserMap` probes used to detect various browser features that can determine a client's capabilities
+* `libs/externals/`:
+ * `modernizr/modernizr.custom.js` - a reduced [Modernizr](http://modernizr.com/ "Modernizr") configuration
+ * `matchMedia/matchMedia.js` - the [`matchMedia.js` polyfill project](https://github.com/paulirish/matchMedia.js/ "matchMedia.js") written by Paul Irish
+
+### Correct order of files inclusion in an HTML page
+In order to have a functional BrowserMap instance, the previous files have to be included in this order:
+
+ <script type="text/javascript" src="libs/browsermap/bmaputil.js"></script>
+ <script type="text/javascript" src="libs/browsermap/bmap.js"></script>
+ <script type="text/javascript" src="libs/externals/modernizr/modernizr.custom.js"></script>
+ <script type="text/javascript" src="libs/externals/matchMedia/matchMedia.js"></script>
+ <script type="text/javascript" src="libs/browsermap/probes.js"></script>
+ <script type="text/javascript" src="libs/browsermap/devicegroups.js"></script>
+
+## `DeviceGroup`s configuration
+A `DeviceGroup` object has the following attributes:
+
+* `ranking` - determines the order in which, when added to the `BrowserMap` object, the `DeviceGroup`s will be matched; a lower ranking means an earlier evaluation (e.g. 0 is evaluated before 10);
+* `name` - the name of the `DeviceGroup`; can also act as a URL selector which will be used to create `DeviceGroup`s-specific URLs to which the clients will be forwarded
+* `description` - a string used to store a brief description of the `DeviceGroup`
+* `testFunction` - a test function that must return a boolean value; the test function is used to check if a client matches the `DeviceGroup` or not; the test function can use `BrowserMap` probe functions
+* `isSelector` - a boolean flag which is checked to see if a `DeviceGroup`'s name should be used as a selector or not.
+
+To add a `DeviceGroup` to the `BrowserMap` object, one can use the `BrowserMap.addDeviceGroup(DeviceGroup object)` method. The last `DeviceGroup` added to `BrowserMap` with the same name as a previously existing `DeviceGroup` will be the one which will be stored, which can be useful if one tries to override the default `DeviceGroups`.
+
+## Development
+BrowserMap's own source files are located in `src/main/js`.
+
+The main test file is located in `src/test/js` and the tests are based on [QUnit](http://qunitjs.com/ "QUnit").
+
+The builds are handled with [Grunt](http://gruntjs.com/ "Grunt"). In order to build the project you need to install
+[PhantomJS](http://phantomjs.org/ "PhantomJS"), [Node.js](http://nodejs.org/ "Node.js") and [npm](https://github.com/isaacs/npm "npm").
+Afterwards use `npm` to globally install `grunt-cli` and `jscoverage`:
+
+ npm install -g grunt-cli
+ npm install -g jscoverage
+
+The tests can be run with `grunt test` inside the browsermap folder.
+
+Packaging the app is done with `grunt package`.
+
+## How to report issues or request enhancements
+Please file a JIRA issue at [https://issues.apache.org/jira/browse/DMAP](https://issues.apache.org/jira/browse/DMAP) and use the "browsermap"
+label.
+
+If you're reporting a bug please provide an accurate description of the problem together with the debug output found on the demo page from
+[http://devicemap-vm.apache.org/browsermap/index.html](http://devicemap-vm.apache.org/browsermap/index.html).
Added: incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/ci/jenkins_build.sh
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/ci/jenkins_build.sh?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/ci/jenkins_build.sh (added)
+++ incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/ci/jenkins_build.sh Tue Jul 15 07:51:39 2014
@@ -0,0 +1,26 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+# sample script for building BrowserMap on Jenkins; adjust to your own needs
+export PATH="/Users/Shared/Jenkins/.nvm/v0.8.18/bin:$PATH"
+export JAVA_HOME="`/usr/libexec/java_home`"
+source /Users/Shared/Jenkins/.nvm/nvm.sh
+nvm use 0.8.18
+rm -rf node_modules
+npm install
+grunt package
\ No newline at end of file
Added: incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/package.json
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/package.json?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/package.json (added)
+++ incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/package.json Tue Jul 15 07:51:39 2014
@@ -0,0 +1,32 @@
+{
+ "name": "BrowserMap",
+ "version": "1.3.0",
+ "description": "YABFDL - yet another browser features detection library",
+ "main": "index.js",
+ "scripts": {
+ "test": "grunt test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:raducotescu/browsermap.git"
+ },
+ "author": {
+ "name": "The Apache DeviceMap team"
+ },
+ "license": {
+ "type": "Apache License",
+ "url": "http://www.apache.org/licenses/LICENSE-2.0"
+ },
+ "readmeFilename": "README.md",
+ "devDependencies": {
+ "grunt": "0.4.0",
+ "grunt-karma": "0.4.4",
+ "grunt-contrib-jshint": "0.1.1",
+ "grunt-contrib-clean": "0.4.0",
+ "grunt-contrib-uglify": "0.1.1",
+ "grunt-jsdoc": "0.2.3",
+ "grunt-contrib-copy": "0.4.0",
+ "grunt-contrib-compress": "0.4.0",
+ "grunt-qunit-cov": "git+https://raducotescu@github.com/raducotescu/grunt-qunit-cov.git"
+ }
+}
Added: incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/js/bmap.js
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/js/bmap.js?rev=1610605&view=auto
==============================================================================
--- incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/js/bmap.js (added)
+++ incubator/devicemap/trunk/browsermap/tags/browsermap-1.3.0/src/main/js/bmap.js Tue Jul 15 07:51:39 2014
@@ -0,0 +1,586 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/*global BrowserMapUtil:false, Cookie:false */
+/**
+ * The BrowserMap object is used to identify the client's device group, based on JavaScript detection tests ("probes") that find out
+ * which features the client supports.
+ *
+ * @class BrowserMap
+ */
+(function(BrowserMap) {
+ 'use strict';
+
+ var cookiePrefix = 'BMAP_',
+ deviceGroupCookieName = 'device',
+ deviceOverrideParameter = 'device',
+ languageOverrideParameter = 'language',
+ enableForwardingWhenCookiesDisabled = false,
+ matchRun = false,
+ languageOverride = null,
+ matchedDeviceGroups = {},
+ probes = {},
+ probeCache = {},
+ deviceGroups = {};
+ // Android 4.x phones in landscape view use 42 pixels for displaying the "soft buttons"
+ BrowserMap.THE_ANSWER_TO_LIFE_THE_UNIVERSE_AND_EVERYTHING = 42;
+
+ BrowserMap.VERSION = '<%= pkg.version %>'; // replaced at build time by Grunt
+
+ var linkDataDevgroups = 'data-bmap-devgroups';
+
+ /**
+ * Retrieves the probes Map - useful for outputting debugging information.
+ *
+ * @return {Object} an Object holding the probes and their results
+ */
+ BrowserMap.getProbingResults = function () {
+ var probingResults = {},
+ probe;
+ for (probe in probes) {
+ if (probes.hasOwnProperty(probe)) {
+ probingResults[probe] = BrowserMap.probe(probe);
+ }
+ }
+ return probingResults;
+ };
+
+ /**
+ * Initialises BrowserMap with a configuration object.
+ *
+ * @param {Object} config - a hash object with various properties that can be used to configure BrowserMap
+ * <p>
+ * The following proprerties can be be used:
+ * <ol>
+ * <li><code>config.cookiePrefix</code> - the prefix used to name cookies used throughout the detection</li>
+ * <li><code>config.deviceGroupCookieName</code> - the name of the device group cookie (the final name will be of the form
+ * <code>config.cookiePrefix + config.deviceGroupCookieName</code>)</li>
+ * <li><code>config.deviceOverrideParameter</code> - the name of the GET parameter that triggers a device override</li>
+ * <li><code>config.languageOverrideParameter</code> - the name of the GET parameter that triggers a language override</li>
+ * <li><code>config.enableForwardingWhenCookiesDisabled</code> - if true, it will allow for all the URLs pointing to resources
+ * from the current domain to be modified in order to include the deviceOverrideParameter; this is useful if the client
+ * does not support cookies</li>
+ * </ol>
+ * </p>
+ */
+ BrowserMap.config = function (config) {
+ if (config.cookiePrefix !== null) {
+ cookiePrefix = config.cookiePrefix;
+ }
+ if (config.deviceGroupCookieName !== null) {
+ deviceGroupCookieName = config.deviceGroupCookieName;
+ }
+ if (config.deviceOverrideParameter !== null) {
+ deviceOverrideParameter = config.deviceOverrideParameter;
+ }
+ if (config.languageOverrideParameter !== null) {
+ languageOverrideParameter = config.languageOverrideParameter;
+ }
+ if (config.enableForwardingWhenCookiesDisabled !== null) {
+ enableForwardingWhenCookiesDisabled = config.enableForwardingWhenCookiesDisabled;
+ }
+ };
+
+ /**
+ * Returns an Array of the alternate sites by analysing the link elements with rel='alternate' and the data-bmap-devgroups attribute
+ * not null or empty.
+ *
+ * @return {Array} an array of alternate sites defined as objects with the <code>id, href, hreflang, devgroups</code> set of
+ * attributes; an empty array if no alternate site is found
+ */
+ BrowserMap.getAllAlternateSites = function () {
+ var alternateSites = [],
+ links,
+ i,
+ link,
+ headElement,
+ onIE7 = false,
+ linkHref,
+ devgroups;
+ onIE7 = navigator.appVersion.indexOf('MSIE 7') !== -1;
+ headElement = document.getElementsByTagName('head')[0];
+ if (headElement) {
+ links = headElement.getElementsByTagName('link');
+ for (i = 0; i < links.length; i++) {
+ link = links[i];
+ devgroups = link.getAttribute(linkDataDevgroups);
+ if (link.rel == 'alternate' && devgroups && devgroups !== '') {
+ if (onIE7) {
+ linkHref = BrowserMapUtil.Url.qualifyURL(link.href);
+ } else {
+ linkHref = link.href;
+ }
+ alternateSites.push(
+ {'id' : link.id, 'href' : linkHref, 'hreflang' : link.hreflang, 'devgroups' : devgroups}
+ );
+ }
+ }
+ }
+ return alternateSites;
+ };
+
+ /**
+ * <p>
+ * Looks for the best matching alternate site. The primary criterion is the number of matched device groups which also provides the
+ * score of the alternate site. More criteria can be added by providing a filtering function.
+ * </p>
+ * <p>
+ * The filtering function receives an alternate site as a parameter and it must return a boolean value if the filter matches or not. The
+ * filter is applied to alternate sites that have matched at least one device group. If the alternate site matches the filter, the total
+ * score of the alternate site will increase by 1. The alternate site's object attributes are id, href, hreflang and media.
+ * </p>
+ *
+ * @param {Array} deviceGroups - an array containing the names of the device groups for which to get the best alternate link
+ * @param {Function} filter - a callback function that acts as a filter and which must return a boolean; the callback will receive a
+ * hash object representing an alternate site with the following attributes: "id", "href", "hreflang", "devgroups"
+ * @return {String} the alternate link that matches the most device groups matched by the client
+ */
+ BrowserMap.getAlternateSite = function (deviceGroups, filter) {
+ var alternateSites = BrowserMap.getAllAlternateSites(),
+ maxLinkScore = 0,
+ alternateSite = null,
+ currentURL = window.location.href,
+ currentURLParameters = BrowserMapUtil.Url.getURLParametersString(currentURL),
+ i,
+ j,
+ linkScore,
+ devices;
+ if (currentURLParameters && currentURLParameters !== '') {
+ currentURL = currentURL.substring(0, currentURL.indexOf(currentURLParameters));
+ }
+ for (i = 0; i < alternateSites.length; i++) {
+ linkScore = 0;
+ devices = alternateSites[i].devgroups.split(',');
+ for (j = 0; j < devices.length; j++) {
+ if (deviceGroups.indexOf(devices[j].trim()) !== -1) {
+ linkScore++;
+ }
+ }
+ if (typeof filter == 'function' && linkScore > 0) {
+ if(filter(alternateSites[i])) {
+ linkScore++;
+ }
+ }
+ if (linkScore > maxLinkScore) {
+ alternateSite = alternateSites[i];
+ maxLinkScore = linkScore;
+ }
+ }
+ return alternateSite;
+ };
+
+ /**
+ * Returns the defined DeviceGroups for this BrowserMap as an array in which the elements are ordered by their ranking property.
+ *
+ * @return {Array}
+ */
+ BrowserMap.getDeviceGroupsInRankingOrder = function () {
+ var dgs = [],
+ dg;
+ for (dg in deviceGroups) {
+ if (deviceGroups.hasOwnProperty(dg)) {
+ dgs.push(deviceGroups[dg]);
+ }
+ }
+ dgs.sort(function(a, b) {
+ return a.ranking - b.ranking;
+ });
+ return dgs;
+ };
+
+ /**
+ * Executes a probe that was previously added via <code>addProbe</code>. The result of the probe is cached so a second call
+ * with the same probeName will not run the probe again. You can use <code>BrowserMap.clearProbeCache()</code> to avoid that.
+ *
+ * @param {String} probeName - the name of the requested probe
+ * @return {Object} the result of the probe, or null if the probe has not been defined
+ */
+ BrowserMap.probe = function (probeName) {
+ if (!probes[probeName]) {
+ return null;
+ }
+ if (!probeCache.hasOwnProperty(probeName)) {
+ probeCache[probeName] = probes[probeName]();
+ }
+ return probeCache[probeName];
+ };
+
+ /**
+ * Starting from a currentURL, an array of device groups and an array of url selectors returns the alternate URL for the current URL.
+ *
+ * @param {String} currentURL - the current URL
+ * @param {Array} detectedDeviceGroups - the Array of detected device groups
+ * @prama {Attay} urlSelectors - the Array of URL selectors, in the order of their device group ranking
+ * @return {String} the specific URL for the identified device groups
+ */
+ BrowserMap.getNewURL = function (currentURL, detectedDeviceGroups, urlSelectors) {
+ var newURL = null,
+ alternateSite = BrowserMap.getAlternateSite(detectedDeviceGroups, function(alternateLink) {
+ if (languageOverride && alternateLink.hreflang && alternateLink.hreflang.lastIndexOf(languageOverride) === 0) {
+ return true;
+ }
+ }),
+ i,
+ dg,
+ parameters = BrowserMapUtil.Url.getURLParametersString(currentURL),
+ urlNoParams = currentURL.replace(parameters, '');
+ if (alternateSite) {
+ newURL = alternateSite.href;
+ }
+ if (!newURL) {
+ for (i = 0; i < detectedDeviceGroups.length; i++) {
+ dg = BrowserMap.getDeviceGroupByName(detectedDeviceGroups[i]);
+ if (dg) {
+ newURL = dg.url;
+ if (newURL) {
+ break;
+ }
+ }
+ }
+ }
+ if (!newURL) {
+ newURL = BrowserMapUtil.Url.addSelectorsToURL(urlNoParams, urlSelectors);
+ }
+ if (parameters) {
+ newURL += parameters;
+ }
+ return newURL;
+ };
+
+ /**
+ * Removes the device group override, whether it was set up by using the override cookie or just by using the specific device group
+ * override parameter.
+ */
+ BrowserMap.removeOverride = function () {
+ var oCookie = BrowserMapUtil.CookieManager.getCookie('o_' + cookiePrefix + deviceGroupCookieName),
+ currentURL = window.location.href,
+ parameters = BrowserMapUtil.Url.getURLParametersString(currentURL),
+ overrideParameter,
+ indexOfOverride;
+ if (oCookie) {
+ BrowserMapUtil.CookieManager.removeCookie(cookiePrefix + deviceGroupCookieName);
+ BrowserMapUtil.CookieManager.removeCookie(oCookie.name);
+ oCookie.name = cookiePrefix + deviceGroupCookieName;
+ oCookie.path = '/';
+ BrowserMapUtil.CookieManager.setCookie(oCookie);
+ }
+ if (parameters) {
+ overrideParameter = deviceOverrideParameter + '=' +
+ BrowserMapUtil.Url.getValueForParameter(currentURL, deviceOverrideParameter);
+ currentURL = currentURL.replace(parameters, '');
+ indexOfOverride = parameters.indexOf(overrideParameter);
+ if (indexOfOverride !== -1) {
+ if (parameters.length > indexOfOverride + overrideParameter.length) {
+ if (parameters[indexOfOverride - 1] == '?') {
+ parameters = parameters.replace(overrideParameter + '&', '');
+ }
+ else {
+ parameters = parameters.replace('&' + overrideParameter, '');
+ }
+ }
+ else {
+ parameters = parameters.replace('?' + overrideParameter, '');
+ }
+ }
+ currentURL += parameters;
+ }
+ window.location = currentURL;
+ };
+
+ /**
+ * <p>Decides if the client should be forwarded to the best matching alternate link, depending on the detected device group.</p>
+ * <p>
+ * Three options are available for determining the correct representation of a page depending on the detected device group, listed in
+ * the order of their importance:
+ * <ol>
+ * <li>alternate links: <code><link rel="alternate" href="..." hreflang="..." media="device_groups" ></code></li>
+ * <li><code>DeviceGroup</code> level URLs (check the <code>DeviceGroup</code> objects description)</li>
+ * <li>selector-based URLs (the device group names will be appended to the current URL: <code>index.html ->
+ * index.tablet.html</code>)</li>
+ * </ol>
+ * In either case <code>GET</code> parameters will be maintained.
+ */
+ BrowserMap.forwardRequest = function () {
+ var currentURL = window.location.href,
+ deviceOverride = BrowserMapUtil.Url.getValueForParameter(currentURL, deviceOverrideParameter),
+ detectedDeviceGroups = [],
+ urlSelectors = [],
+ oCookie = BrowserMapUtil.CookieManager.getCookie('o_' + cookiePrefix + deviceGroupCookieName),
+ cookie = BrowserMapUtil.CookieManager.getCookie(cookiePrefix + deviceGroupCookieName),
+ dgs = [],
+ i,
+ g,
+ registeredDeviceGroups,
+ dgName,
+ domain,
+ aTags,
+ url,
+ parameters,
+ newURL,
+ canonicalURL = BrowserMapUtil.Url.getCanonicalURL();
+ if (BrowserMap.isEnabled()) {
+ languageOverride = BrowserMapUtil.Url.getValueForParameter(currentURL, languageOverrideParameter);
+ if (deviceOverride) {
+ // override detected
+ detectedDeviceGroups = deviceOverride.split(',');
+ if (detectedDeviceGroups.length > 0) {
+ if (BrowserMapUtil.CookieManager.cookiesEnabled()) {
+ if (!oCookie && !cookie) {
+ // tried to access resource directly with override parameter without passing through detection
+ // run detection code to detect the original device groups
+ oCookie = new Cookie();
+ oCookie.name = 'o_' + cookiePrefix + deviceGroupCookieName;
+ oCookie.path = '/';
+ BrowserMap.matchDeviceGroups();
+ for (g in matchedDeviceGroups) {
+ if (matchedDeviceGroups.hasOwnProperty(g)) {
+ dgs.push(matchedDeviceGroups[g].name);
+ }
+ }
+ if (deviceOverride !== dgs.join(',')) {
+ oCookie.value = dgs.join(',');
+ BrowserMapUtil.CookieManager.setCookie(oCookie);
+ }
+ }
+ else if (!oCookie) {
+ // detection has been performed; override detected; store original values
+ if (cookie.value !== detectedDeviceGroups.join(',')) {
+ cookie.name = 'o_' + cookie.name;
+ cookie.path = '/';
+ BrowserMapUtil.CookieManager.setCookie(cookie);
+ }
+ }
+ // store the override
+ cookie = new Cookie();
+ cookie.name = cookiePrefix + deviceGroupCookieName;
+ cookie.value = detectedDeviceGroups.join(',');
+ cookie.path = '/';
+ BrowserMapUtil.CookieManager.setCookie(cookie);
+ if (oCookie) {
+ if (oCookie.value == cookie.value) {
+ BrowserMapUtil.CookieManager.removeCookie(oCookie.name);
+ }
+ }
+ }
+ }
+ }
+ if (cookie !== null || deviceOverride) {
+ /**
+ * cookie was either set by the detection code before, or we have an override;
+ *
+ * in either case, the matchDeviceGroups must match the detectedDeviceGroups which can come from the cookie or from the
+ * override parameter
+ */
+ registeredDeviceGroups = BrowserMap.getDeviceGroups();
+ if (detectedDeviceGroups.length === 0) {
+ detectedDeviceGroups = cookie.value.split(',');
+ }
+ matchedDeviceGroups = { };
+ for (i = 0 ; i < detectedDeviceGroups.length; i++) {
+ dgName = detectedDeviceGroups[i].trim();
+ if (registeredDeviceGroups.hasOwnProperty(dgName)) {
+ if (registeredDeviceGroups[dgName].isSelector) {
+ urlSelectors.push(dgName);
+ }
+ matchedDeviceGroups[dgName] = registeredDeviceGroups[dgName];
+ }
+ }
+ // add the device override parameter to links using the same domain if a device override was detected
+ if (deviceOverride && cookie === null && enableForwardingWhenCookiesDisabled) {
+ domain = BrowserMapUtil.Url.getDomainFromURL(window.location.href);
+ aTags = document.getElementsByTagName('a');
+ for (i = 0; i < aTags.length; i++) {
+ url = aTags[i].href;
+ if (url && url.indexOf(domain) !== -1) {
+ parameters = BrowserMapUtil.Url.getURLParametersString(url);
+ if (parameters) {
+ if (parameters.indexOf(languageOverrideParameter + '=' + deviceOverride) == -1) {
+ aTags[i].href = url + '&' + deviceOverrideParameter + '=' + deviceOverride;
+ }
+ }
+ else {
+ aTags[i].href = url + '?' + deviceOverrideParameter + '=' + deviceOverride;
+ }
+ }
+ }
+ }
+ }
+ else {
+ // no override has been detected, nor a cookie has been set previous to this call
+ // perform the match and then set the cookie
+ BrowserMap.matchDeviceGroups();
+ for (g in matchedDeviceGroups) {
+ if (matchedDeviceGroups.hasOwnProperty(g)) {
+ if (matchedDeviceGroups[g].isSelector) {
+ urlSelectors.push(matchedDeviceGroups[g].name);
+ }
+ detectedDeviceGroups.push(matchedDeviceGroups[g].name);
+ }
+ }
+ cookie = new Cookie();
+ cookie.name = cookiePrefix + deviceGroupCookieName;
+ cookie.value = detectedDeviceGroups.join(',');
+ cookie.path = '/';
+ BrowserMapUtil.CookieManager.setCookie(cookie);
+ }
+ newURL = BrowserMap.getNewURL(currentURL, detectedDeviceGroups, urlSelectors);
+ if (currentURL !== newURL && canonicalURL !== newURL) {
+ window.location = newURL;
+ }
+ }
+ };
+
+ /**
+ * Clears the probe result cache.
+ */
+ BrowserMap.clearProbeCache = function () {
+ probeCache = { };
+ };
+
+ /**
+ * Adds a <code>DeviceGroup</code> to the <code>BrowserMap</code> object. The key which is used to store the <code>DeviceGroup</code> is
+ * represented by its name. The last <code>DeviceGroup</code> added to <code>BrowserMap</code> with the same name as a previously
+ * existing <code>DeviceGroup</code> will be the one which will be stored.
+ *
+ * @param {Object} deviceGroup - the DeviceGroup to be added to the list
+ * <p>
+ * A DeviceGroup is represented by a hash object with the following attributes:
+ * <ol>
+ * <li><code>Number</code> <code>ranking</code> - the order number of the DeviceGroup (when it comes to matching the
+ * <code>DeviceGroups</code> to the client's capabilites, the defined <code>DeviceGroups</code> will be evaluated in order)
+ * </li>
+ * <li><code>String</code> <code>name</code> - the name of the <code>DeviceGroup</code> as one word (use camelCase if you need
+ * more words)</li>
+ * <li><code>Function</code> <code>testFunction</code> - the function that is to be evaluated to check if the client matches
+ * the <code>DeviceGroup</code>; this function <strong>must</strong> return a boolean value</li>
+ * <li><code>String</code> <code>url</code> (optional) - the URL to which a client will be forwarded in case the
+ * <code>DeviceGroup</code> matches and the current page does not contain an alternate link to which the client can be
+ * forwarded</li>
+ * <li><code>String</code> <code>description</code> (optional) - the description of the <code>DeviceGroup</code></li>
+ * <li><code>Boolean</code> <code>isSelector</code> (optional) - if present and set to <code>true</code>, the name of the
+ * <code>DeviceGroup</code> will be used to create a URL with a selector to which BrowserMap can forward the client
+ * (e.g. index.selector.html)</li>
+ * </ol>
+ * </p>
+ */
+ BrowserMap.addDeviceGroup = function (deviceGroup) {
+ // validate the deviceGroup object
+ if (typeof deviceGroup.ranking !== 'number') {
+ throw new TypeError('Expected a Number for device group ' + deviceGroup.name + ' ranking');
+ }
+ if (typeof deviceGroup.testFunction !== 'function') {
+ throw new TypeError('Expected a Function for device group ' + deviceGroup.name + ' testFunction');
+ }
+ deviceGroups[deviceGroup.name] = deviceGroup;
+ };
+
+ /**
+ * Adds a probe to BrowserMap and returns the BrowserMap object (useful for chaining). The probe name must be unique. If one tries to
+ * overwrite an existing probe nothing will happen and the BrowserMap object will be returned as it was before the method was called.
+ *
+ * @param name a String containing the name of the probe
+ * @param probe a Function that returns the result of the probe
+ *
+ * @return the BrowserMap object
+ */
+ BrowserMap.addProbe = function (name, probe) {
+ if (typeof name !== 'string' || name.length < 1) {
+ throw new TypeError('invalid probe name');
+ }
+ if (typeof probe !== 'function') {
+ throw new TypeError('invalid probe function');
+ }
+ if (!probes.hasOwnProperty(name)) {
+ probes[name] = probe;
+ }
+ return BrowserMap;
+ };
+
+ /**
+ * Returns the DeviceGroups that a client has matched.
+ *
+ * @return {Object} a hash object containing the matched device groups
+ */
+ BrowserMap.getMatchedDeviceGroups = function () {
+ return matchedDeviceGroups;
+ };
+
+ /**
+ * Returns all the DeviceGroups defined for the BrowserMap object.
+ *
+ * @return {Object} a hash object containing the defined device groups for this BrowserMap instance
+ */
+ BrowserMap.getDeviceGroups = function () {
+ return deviceGroups;
+ };
+
+ /**
+ * Matches the DeviceGroups to the client's capabilities by evaluating the DeviceGroup's test function.
+ */
+ BrowserMap.matchDeviceGroups = function () {
+ var deviceGroupsArray = BrowserMap.getDeviceGroupsInRankingOrder(),
+ i,
+ deviceGroup;
+ for (i = 0; i < deviceGroupsArray.length; i++) {
+ deviceGroup = deviceGroupsArray[i];
+ if (!!deviceGroup.testFunction.call()) {
+ matchedDeviceGroups[deviceGroup.name] = deviceGroup;
+ }
+ }
+ matchRun = true;
+ };
+
+ /**
+ * Queries the list of DeviceGroups associated to this BrowserMap object using a DeviceGroup name and returns it if found.
+ *
+ * @param {String} groupName - the name of the DeviceGroup
+ * @return {DeviceGroup} the DeviceGroup with the respective name, null otherwise
+ */
+ BrowserMap.getDeviceGroupByName = function (groupName) {
+ return deviceGroups[groupName];
+ };
+
+ /**
+ * Checks if BrowserMap should be enabled by searching the current document for tags like <code><meta name="browsermap.enabled"
+ * content="false"></code> in the <head> section. If such a tag exists, then this method returns <code>false</code>.
+ *
+ * @return {Boolean} false if the previously mentioned tag exists, true otherwise
+ */
+ BrowserMap.isEnabled = function () {
+ var headElement = document.getElementsByTagName('head')[0],
+ metaTags,
+ i,
+ name,
+ tag;
+ if (headElement) {
+ metaTags = headElement.getElementsByTagName('meta');
+ for (i = 0; i < metaTags.length; i++) {
+ if ((tag = metaTags[i]) && (name = tag.getAttribute('name'))) {
+ if (name === 'browsermap.enabled' && tag.getAttribute('content') === 'false') {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ };
+
+ return BrowserMap;
+
+})(window.BrowserMap = window.BrowserMap || {});