Browse Source

Merge branch 'dev'

pull/25/head
Ned Zimmerman 7 years ago
parent
commit
b4e734fddc
No known key found for this signature in database
GPG Key ID: FF56334A013120CA
  1. 2
      .gitignore
  2. 62
      .travis.yml
  3. 556
      CHANGELOG.md
  4. 39
      LICENSE.md
  5. 60
      app/activation.php
  6. 116
      app/admin.php
  7. 151
      app/controllers/App.php
  8. 37
      app/controllers/FrontPage.php
  9. 111
      app/controllers/PageCatalog.php
  10. 16
      app/filters.php
  11. 121
      app/helpers.php
  12. 38
      app/intervention.php
  13. 111
      app/setup.php
  14. 33
      composer.json
  15. 625
      composer.lock
  16. 2
      config/assets.php
  17. 227
      lib/infusion/Infusion-LICENSE.txt
  18. 212
      lib/infusion/README.md
  19. 344
      lib/infusion/ReleaseNotes.md
  20. 30
      lib/infusion/infusion-uiOptions.js
  21. 1
      lib/infusion/infusion-uiOptions.js.map
  22. 171
      lib/infusion/src/components/slidingPanel/js/SlidingPanel.js
  23. 16
      lib/infusion/src/components/slidingPanel/slidingPanelDependencies.json
  24. 3
      lib/infusion/src/components/tableOfContents/css/TableOfContents.css
  25. 32
      lib/infusion/src/components/tableOfContents/html/TableOfContents.html
  26. 377
      lib/infusion/src/components/tableOfContents/js/TableOfContents.js
  27. 15
      lib/infusion/src/components/tableOfContents/tableOfContentsDependencies.json
  28. 113
      lib/infusion/src/components/textToSpeech/js/MockTTS.js
  29. 288
      lib/infusion/src/components/textToSpeech/js/TextToSpeech.js
  30. 14
      lib/infusion/src/components/textToSpeech/textToSpeechDependencies.json
  31. 312
      lib/infusion/src/components/textfieldSlider/js/TextfieldSlider.js
  32. 18
      lib/infusion/src/components/textfieldSlider/textfieldSliderDependencies.json
  33. 45
      lib/infusion/src/components/uiOptions/js/UIOptions.js
  34. 14
      lib/infusion/src/components/uiOptions/uiOptionsDependencies.json
  35. 69
      lib/infusion/src/framework/core/css/fluid.css
  36. 132
      lib/infusion/src/framework/core/css/fluidDebugging.css
  37. 26
      lib/infusion/src/framework/core/frameworkDependencies.json
  38. BIN
      lib/infusion/src/framework/core/images/debug_tab.png
  39. BIN
      lib/infusion/src/framework/core/images/magnifying_glass.png
  40. 1495
      lib/infusion/src/framework/core/js/DataBinding.js
  41. 2806
      lib/infusion/src/framework/core/js/Fluid.js
  42. 116
      lib/infusion/src/framework/core/js/FluidDOMUtilities.js
  43. 300
      lib/infusion/src/framework/core/js/FluidDebugging.js
  44. 191
      lib/infusion/src/framework/core/js/FluidDocument.js
  45. 2458
      lib/infusion/src/framework/core/js/FluidIoC.js
  46. 266
      lib/infusion/src/framework/core/js/FluidPromises.js
  47. 439
      lib/infusion/src/framework/core/js/FluidRequests.js
  48. 693
      lib/infusion/src/framework/core/js/FluidView.js
  49. 663
      lib/infusion/src/framework/core/js/FluidViewDebugging.js
  50. 117
      lib/infusion/src/framework/core/js/JavaProperties.js
  51. 675
      lib/infusion/src/framework/core/js/ModelTransformation.js
  52. 743
      lib/infusion/src/framework/core/js/ModelTransformationTransforms.js
  53. 73
      lib/infusion/src/framework/core/js/ResourceLoader.js
  54. 623
      lib/infusion/src/framework/core/js/jquery.keyboard-a11y.js
  55. 152
      lib/infusion/src/framework/core/js/jquery.standalone.js
  56. 4
      lib/infusion/src/framework/enhancement/css/ProgressiveEnhancement.css
  57. 14
      lib/infusion/src/framework/enhancement/enhancementDependencies.json
  58. 221
      lib/infusion/src/framework/enhancement/js/ContextAwareness.js
  59. 34
      lib/infusion/src/framework/enhancement/js/ProgressiveEnhancement.js
  60. 1
      lib/infusion/src/framework/preferences/css/Enactors.css
  61. 1
      lib/infusion/src/framework/preferences/css/FullNoPreviewPrefsEditor.css
  62. 1
      lib/infusion/src/framework/preferences/css/FullPrefsEditor.css
  63. 1
      lib/infusion/src/framework/preferences/css/FullPreviewPrefsEditor.css
  64. 1
      lib/infusion/src/framework/preferences/css/PrefsEditor.css
  65. 1
      lib/infusion/src/framework/preferences/css/SeparatedPanelPrefsEditor.css
  66. 1
      lib/infusion/src/framework/preferences/css/SeparatedPanelPrefsEditorFrame.css
  67. 42
      lib/infusion/src/framework/preferences/css/stylus/Enactors.styl
  68. 47
      lib/infusion/src/framework/preferences/css/stylus/FullNoPreviewPrefsEditor.styl
  69. 47
      lib/infusion/src/framework/preferences/css/stylus/FullPrefsEditor.styl
  70. 75
      lib/infusion/src/framework/preferences/css/stylus/FullPreviewPrefsEditor.styl
  71. 420
      lib/infusion/src/framework/preferences/css/stylus/PrefsEditor.styl
  72. 26
      lib/infusion/src/framework/preferences/css/stylus/README.md
  73. 97
      lib/infusion/src/framework/preferences/css/stylus/SeparatedPanelPrefsEditor.styl
  74. 110
      lib/infusion/src/framework/preferences/css/stylus/SeparatedPanelPrefsEditorFrame.styl
  75. 43
      lib/infusion/src/framework/preferences/css/stylus/utils/Helpers.styl
  76. 358
      lib/infusion/src/framework/preferences/css/stylus/utils/Themes.styl
  77. BIN
      lib/infusion/src/framework/preferences/fonts/InfusionIcons-PrefsEditor.eot
  78. BIN
      lib/infusion/src/framework/preferences/fonts/InfusionIcons-PrefsEditor.ttf
  79. 27
      lib/infusion/src/framework/preferences/html/FullNoPreviewPrefsEditor.html
  80. 29
      lib/infusion/src/framework/preferences/html/FullPreviewPrefsEditor.html
  81. 13
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-contrast.html
  82. 2
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-emphasizeLinks.html
  83. 2
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-inputsLarger.html
  84. 10
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-layout.html
  85. 12
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-lineSpace-jQueryUI.html
  86. 12
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-lineSpace-nativeHTML.html
  87. 5
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-linksControls.html
  88. 10
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-speak.html
  89. 6
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-textFont.html
  90. 15
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-textSize-jQueryUI.html
  91. 15
      lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-textSize-nativeHTML.html
  92. 12
      lib/infusion/src/framework/preferences/html/SeparatedPanelPrefsEditor.html
  93. 34
      lib/infusion/src/framework/preferences/html/SeparatedPanelPrefsEditorFrame-jQueryUI.html
  94. 30
      lib/infusion/src/framework/preferences/html/SeparatedPanelPrefsEditorFrame-nativeHTML.html
  95. BIN
      lib/infusion/src/framework/preferences/images/default/separatedpanelbg.png
  96. 498
      lib/infusion/src/framework/preferences/js/AuxBuilder.js
  97. 208
      lib/infusion/src/framework/preferences/js/Builder.js
  98. 431
      lib/infusion/src/framework/preferences/js/Enactors.js
  99. 49
      lib/infusion/src/framework/preferences/js/FullNoPreviewPrefsEditor.js
  100. 80
      lib/infusion/src/framework/preferences/js/FullPreviewPrefsEditor.js
  101. Some files were not shown because too many files have changed in this diff Show More

2
.gitignore vendored

@ -1,8 +1,8 @@
# Include your project-specific ignores in this file # Include your project-specific ignores in this file
# Read about how to use .gitignore: https://help.github.com/articles/ignoring-files # Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
.cache-loader .cache-loader
.sass-cache
dist dist
bower_components
node_modules node_modules
npm-debug.log npm-debug.log
yarn-error.log yarn-error.log

62
.travis.yml

@ -4,36 +4,54 @@ dist: trusty
branches: branches:
only: only:
- dev - dev
- "/\\d+\\.\\d+(\\.\\d+)?(-\\S*)?$/" - "/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+[0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*)?$/"
php: php:
- 7.1 - 7.1
- 7.0 - 7.0
- 5.6 - nightly
- nightly
env: env:
- TRAVIS_NODE_VERSION="6" - TRAVIS_NODE_VERSION="6"
- TRAVIS_NODE_VERSION="7" - TRAVIS_NODE_VERSION="7"
matrix: matrix:
fast_finish: true fast_finish: true
allow_failures: allow_failures:
- php: nightly - php: nightly
cache: cache:
apt: true apt: true
directories: directories:
- $HOME/.composer/cache - "$HOME/.composer/cache"
- $HOME/.yarn-cache - "$HOME/.yarn-cache"
- vendor - vendor
before_install: before_install:
- composer self-update - composer self-update
- source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION && nvm use $TRAVIS_NODE_VERSION - source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION && nvm use $TRAVIS_NODE_VERSION
- export PATH=$HOME/.yarn/bin:$PATH && travis_retry curl -o- -L https://yarnpkg.com/install.sh | bash - export PATH=$HOME/.yarn/bin:$PATH && travis_retry curl -o- -L https://yarnpkg.com/install.sh
| bash
install: install:
- node -v && yarn -V - node -v && yarn -V
- travis_retry yarn - travis_retry yarn
- composer install -o --prefer-dist --no-interaction - composer install -o --prefer-dist --no-interaction
script: script:
- yarn run test - yarn run test
- yarn run build - yarn run build
- yarn run rmdist - yarn run rmdist
- yarn run "build:production" - yarn run "build:production"
- composer test - composer test
before_deploy:
- export TRAVIS_PROJECT_SLUG="$(basename $TRAVIS_BUILD_DIR)"
- composer install --no-dev --optimize-autoloader
- cd ../
- zip -9 -ry $TRAVIS_BUILD_DIR/$TRAVIS_PROJECT_SLUG-$TRAVIS_TAG.zip $TRAVIS_PROJECT_SLUG
-x *.git* *resources/assets/\* *node_modules/\* *tests/\* *.editorconfig* *.gitattributes*
*.github* *.gitignore* *.travis.yml* *package-lock.json* *phpcs.xml* *webpack.mix.js*
*yarn.lock*
- cd $TRAVIS_BUILD_DIR
deploy:
provider: releases
skip_cleanup: true
api_key:
secure: H1gOixA2icGJrrJQBqU8ta9/pws8V3RM3JJF3G8CXtQ7mWOlC20Ntev1nB+fQS4mdiIWJ92eum4KKXBr80Od4m/hGIO2JSbpzN2v7bTlAx9eWB6wyShrfq+/IMw1vuqo9SyZM5+TJMbWAIu21pXFt6r7gPzX676iV9l2QQ2EJVV3s8VxYlfOGk/w+tVSp8t6Iq6FHVbks3QQ8bQriHwIC6LvvtRalarwTXI0vUfNNRrNpMATkxdddbleKnEfXpIuwvtblTWTuGp8ZIiC2QUKKraU4cbYWoAK/sJ+6gK3wIaXFbhhv85B/CW5xbbB916Bz5EKeZXm2QTRdKHFD13xQH3m9iqIZdK1w1SmwkyuhcwLvqF5fl087RWBz8w9pLp5dHI7HmoXVDHQrtNkyWN4uSXQpPweZmCf2D0qgRR3dRaPRdOG0PK+SXoRU1hr4dsTQ/tpbCYzJRXejnrOqOd/YvkuMZzzpE17YaogkGz5U55//cdwIr47wxWPspB0xCtDidrvualY2o+hdjeXN7Pv/pGXos+TYpHmjjEsp5dOmIAx+djTk5dn0LK/oJzHR1kfFGDWFTp0xNTywCG/x2224BO3vTyBKELR4NPeGX2goUO2VK6inntUXDf5OsfBeVsf0B0NhFR76VtkriXBpo/K4ppmXVNxKmK0etqS88V+HX4=
file: "pressbooks-aldine-$TRAVIS_TAG.zip"
on:
tags: true
repo: pressbooks/pressbooks-aldine

556
CHANGELOG.md

@ -1,556 +0,0 @@
### 9.0.0-beta.3: April 21st, 2017
* Move required theme files to `sage/resources` ([#1877](https://github.com/roots/sage/pull/1877))
* Move `src/` to `app/` ([#1868](https://github.com/roots/sage/pull/1868))
* Move `templates/` to `resources/views/`, move `assets/` to `resources/assets/`, rename `base.blade.php` to `app.blade.php` ([#1864](https://github.com/roots/sage/pull/1864))
* Add option to configure build settings ([#1822](https://github.com/roots/sage/pull/1822))
* Add support for HTML injection ([#1817](https://github.com/roots/sage/pull/1817))
* Add Tachyons as a CSS framework option ([#1867](https://github.com/roots/sage/pull/1867))
### 9.0.0-beta.2: January 19th, 2017
* Fix Browersync ([#1815](https://github.com/roots/sage/pull/1815))
* Add option to select CSS framework, add Foundation as an option ([#1813](https://github.com/roots/sage/pull/1813))
* Add option to add Font Awesome ([#1812](https://github.com/roots/sage/pull/1812))
* Add option to change theme file headers ([#1811](https://github.com/roots/sage/pull/1811))
* Add option to remove Bootstrap ([#1810](https://github.com/roots/sage/pull/1810))
* Remove Font Awesome ([#1809](https://github.com/roots/sage/pull/1809))
* Remove grid defaults ([#1808](https://github.com/roots/sage/pull/1808))
* Fix for `publicPath` ([#1806](https://github.com/roots/sage/pull/1806))
* Update clean task name ([#1800](https://github.com/roots/sage/pull/1800))
* Allow browser versions to be configured in `config.json` ([#1798](https://github.com/roots/sage/pull/1798))
* Use stock ESLint ([#1796](https://github.com/roots/sage/pull/1796))
### 9.0.0-beta.1: January 10th, 2017
* Update to Bootstrap 4 Alpha 6 ([#1792](https://github.com/roots/sage/pull/1792))
* Add Blade ([#1765](https://github.com/roots/sage/pull/1765) and [#1777](https://github.com/roots/sage/pull/1777))
* Remove sidebar defaults ([#1760](https://github.com/roots/sage/pull/1760))
* Remove post formats ([#1759](https://github.com/roots/sage/pull/1759))
### 9.0.0-alpha.4: November 16th, 2016
* Use new webpack api schema ([8ac5f15](https://github.com/roots/sage/commit/e6e60aa))
* Update dependencies ([70ebba7](https://github.com/roots/sage/commit/70ebba7))
* Variables organization ([8ac5f15](https://github.com/roots/sage/commit/8ac5f15))
* Use `$.fn.ready()` (reverts [724d550](https://github.com/roots/sage/commit/724d550)) ([e7fccbe](https://github.com/roots/sage/commit/e7fccbe))
* Theme activation updates 'stylesheet' option instead of 'template' ([fb19145](https://github.com/roots/sage/commit/fb19145))
* Reorganize and refactor build routine ([8c9ba05](https://github.com/roots/sage/commit/8c9ba05))
* Switch assets manifest plugin ([c1bb2b3](https://github.com/roots/sage/commit/c1bb2b3))
* Add images to assets manifest ([c49793c](https://github.com/roots/sage/commit/c49793c))
* Switch from babel to buble ([0d38ab8](https://github.com/roots/sage/commit/0d38ab8))
* Update dependencies & webpack compatibility ([eae52fd](https://github.com/roots/sage/commit/eae52fd))
* Use http by default (not https) to be consistent with Trellis ([e6f2f49](https://github.com/roots/sage/commit/e6f2f49))
### 9.0.0-alpha.3: September 11th, 2016
* Fix webpack HMR ([#1713](https://github.com/roots/sage/issues/1713))
* Remove minor edits from CHANGELOG.md ([3516629](https://github.com/roots/sage/commit/3516629))
### 9.0.0-alpha.2: September 4th, 2016
* Refactor build routine ([#1703](https://github.com/roots/sage/pull/1703))
* Update `_grid.scss` to use `@include make-col-ready()` mixin ([#1706](https://github.com/roots/sage/pull/1706))
### 9.0.0-alpha.1: August 30th, 2016
* Move assets found in `node_modules/` to `dist/vendor`, simpler `assets/config.json` ([#1697](https://github.com/roots/sage/pull/1697))
* Set dynamically absolute public path ([#1696](https://github.com/roots/sage/pull/1696))
* Load Tether ([#1686](https://github.com/roots/sage/pull/1686))
* Squash asset pipeline bugs ([4d58f88](https://github.com/roots/sage/commit/4d58f88))
* Update dependencies, incl Bootstrap 4 alpha 3 ([447c24d](https://github.com/roots/sage/commit/447c24d))
* Fix path to stylesheet in `add_editor_style` ([#1684](https://github.com/roots/sage/pull/1684))
* Update required Node.js version ([72b2d89](https://github.com/roots/sage/commit/72b2d89))
* Router doesn't require jQuery, use default params ([339cc8e](https://github.com/roots/sage/commit/339cc8e))
* Fix display of theme name in Customizer ([3425386](https://github.com/roots/sage/commit/3425386))
* Convert scripts to ES6 ([f34af48](https://github.com/roots/sage/commit/f34af48))
* Refactor functions.php ([eae36be](https://github.com/roots/sage/commit/eae36be))
* Rework template wrapper, bring back template_part() ([#1678](https://github.com/roots/sage/pull/1678))
* Remove unused static variable in Wrapper ([9bfdd5a](https://github.com/roots/sage/commit/9bfdd5a))
* Remove `path.extname()` check ([#1673](https://github.com/roots/sage/pull/1673))
* Updated to align with the Bootstrap 4 docs ([#1667](https://github.com/roots/sage/pull/1667))
* Add `npm prune` to Travis CI ([#1663](https://github.com/roots/sage/pull/1663))
* Bootstrap NPM ^4.0.0-alpha.2 ([#1650](https://github.com/roots/sage/pull/1650))
* Fix Bootstrap 4 styles ([#1642](https://github.com/roots/sage/pull/1642))
* Fix autoloader load order issue when including Sage 9 via composer.json in Bedrock ([#1628](https://github.com/roots/sage/pull/1628))
* `is_page_template()` requires the name of the subfolder ([#1626](https://github.com/roots/sage/pull/1626))
* Webpack config improvements ([#1629](https://github.com/roots/sage/pull/1629))
* Webpack implementation improvements ([#1627](https://github.com/roots/sage/pull/1627))
* Webpack implementation ([#1625](https://github.com/roots/sage/pull/1625))
* Fix BS4 grid after their grid updates ([5551dde](https://github.com/roots/sage/commit/5551dde))
* Pass the correct template ([856a482](https://github.com/roots/sage/commit/856a482))
* Optimize travis a bit ([b42c425](https://github.com/roots/sage/commit/b42c425))
* Move single-post loop to single.php, closes #1582 ([6efa099](https://github.com/roots/sage/commit/6efa099))
* All function braces need to be on new line ([b491f76](https://github.com/roots/sage/commit/b491f76))
* Fix issue with WP loading wrong index.php ([9e2917e](https://github.com/roots/sage/commit/9e2917e))
* Use 4 spaces for `src/*.php` ([fe659f4](https://github.com/roots/sage/commit/fe659f4))
* Use phpcs.xml for all rules ([246955c](https://github.com/roots/sage/commit/246955c))
* Conform to new rules ([6a4d3bd](https://github.com/roots/sage/commit/6a4d3bd))
* Create new phpcs rules ([2d02544](https://github.com/roots/sage/commit/2d02544))
* Remove Template class ([1df3fee](https://github.com/roots/sage/commit/1df3fee))
* Remove closure from sidebar registration ([12d6ac3](https://github.com/roots/sage/commit/12d6ac3))
* Remove sage.pot ([d4461fa](https://github.com/roots/sage/commit/d4461fa))
* Remove template_part, template_sidebar, temp sidebar fix ([abeea0f](https://github.com/roots/sage/commit/abeea0f))
* Update asset handles ([fa0e51f](https://github.com/roots/sage/commit/fa0e51f))
* Remove comment-reply JS ([d217ba6](https://github.com/roots/sage/commit/d217ba6))
* Update node in travis, remove unsupported php ([8712dc8](https://github.com/roots/sage/commit/8712dc8))
* Update dependencies, switch to eslint ([e51e41e](https://github.com/roots/sage/commit/e51e41e))
* Bootstrap 4 ([c9ef232](https://github.com/roots/sage/commit/c9ef232))
* Fix: page title not displaying ([9283bbb](https://github.com/roots/sage/commit/9283bbb))
* Rename interfaces, unset after unwrapping ([97906e9](https://github.com/roots/sage/commit/97906e9))
* Restructure theme, use autoloader ([9eaffa3](https://github.com/roots/sage/commit/9eaffa3a2d4df462dd8020a10551334208bd32a3))
### 8.5.0: September 20th, 2016
* Update installation instructions
* Update dependencies
* Update to Bootstrap 4.0.0-alpha.4 ([5eb01fd](https://github.com/roots/sage/commit/5eb01fd0319a7b6576e31579dc50e16b023abb74))
### 8.4.2: February 19th, 2016
* Add Composer vendor directory to gitignore ([#1618](https://github.com/roots/sage/issues/1618))
* Fix build test by removing trailing space ([#1617](https://github.com/roots/sage/issues/1617))
* Replace deprecated gulp-minify-css with gulp-cssnano ([#1610](https://github.com/roots/sage/issues/1610))
### 8.4.1: January 27th, 2016
* Add `composer.json` and update installation instructions ([#1583](https://github.com/roots/sage/issues/1583))
### 8.4.0: December 1st, 2015
* Update to Bootstrap 3.3.6 ([#1578](https://github.com/roots/sage/pull/1578))
* Remove unnecessary underscore ([#1577](https://github.com/roots/sage/pull/1577))
* Drop support for older browsers ([#1571](https://github.com/roots/sage/pull/1571))
* Add support for theme customizer ([#1573](https://github.com/roots/sage/pull/1573))
* Remove extraneous no-js ([#1562](https://github.com/roots/sage/pull/1562))
* Simplify/speed up editor style process ([#1560](https://github.com/roots/sage/pull/1560))
### 8.3.0: October 13th, 2015
* Setup organization ([#1558](https://github.com/roots/sage/pull/1558))
* Remove redundancy with WAI-ARIA in HTML ([#1557](https://github.com/roots/sage/pull/1557))
* Rename config.php to setup.php ([#1556](https://github.com/roots/sage/pull/1556))
* Move init.php to config.php ([#1555](https://github.com/roots/sage/pull/1555))
* Use Sass to style search form, remove search template ([#1545](https://github.com/roots/sage/pull/1545))
* Remove Modernizr ([#1541](https://github.com/roots/sage/pull/1541))
* Remove references to WP_ENV ([#1554](https://github.com/roots/sage/pull/1554))
* Use WP core's HTML5 gallery markup ([#1546](https://github.com/roots/sage/pull/1546))
* Use slash in handle names for theme CSS and JS ([#1537](https://github.com/roots/sage/pull/1537))
* Add compatibility with WooCommerce Multilingual plugin ([#1530](https://github.com/roots/sage/pull/1530))
* Remove ConditionalTagCheck class ([#1494](https://github.com/roots/sage/pull/1494))
* Add search templates ([#1459](https://github.com/roots/sage/issues/1459))
* Allow `debugger` statements in development JavaScript ([#1487](https://github.com/roots/sage/issues/1487))
### 8.2.1: May 7th, 2015
* Update BrowserSync ([#1457](https://github.com/roots/sage/issues/1457))
* Bump dependencies ([#1448](https://github.com/roots/sage/issues/1448))
* Allow revved files to resolve in development if they exist ([#1456](https://github.com/roots/sage/issues/1456))
* Disable advanced minification features to fix incorrect file path in compiled CSS ([#1452](https://github.com/roots/sage/issues/1452))
* Fix Glyphicon font path ([#1455](https://github.com/roots/sage/issues/1455))
### 8.2.0: April 29th, 2015
* Use Sass Bootstrap by default ([#1437](https://github.com/roots/sage/issues/1437))
* Remove nav walker and Bootstrap navbar ([#1427](https://github.com/roots/sage/issues/1427))
* Remove Bootstrap gallery ([#1421](https://github.com/roots/sage/issues/1421))
* Remove hardcoded feed link ([#1426](https://github.com/roots/sage/issues/1426))
* Move jQuery CDN feature to Soil ([#1422](https://github.com/roots/sage/issues/1422))
* Bump `gulp-load-plugins` to 0.10.0 ([#1419](https://github.com/roots/sage/issues/1419))
* Switch from [yargs](https://github.com/bcoe/yargs) to [minimist](https://github.com/substack/minimist) ([#1418](https://github.com/roots/sage/issues/1418))
* Remove `$content_width` ([#1417](https://github.com/roots/sage/issues/1417))
* Lowercase `X-UA-Compatible` ([#1409](https://github.com/roots/sage/issues/1409))
* Remove mention of Google Analytics from the config ([#1384](https://github.com/roots/sage/issues/1384))
### 8.1.1: March 31st, 2015
* Remove pleeease dependency in favor of vanilla gulp-autoprefixer and gulp-minify-css ([#1402](https://github.com/roots/sage/issues/1402))
* Fix `gulp --production` race condition ([#1398](https://github.com/roots/sage/issues/1398))
* Update to Bootstrap 3.3.4 ([#1387](https://github.com/roots/sage/issues/1387))
### 8.1.0: March 13th, 2015
* Move HTML5 Boilerplate's Google Analytics snippet to Soil ([#1382](https://github.com/roots/sage/issues/1382))
* Run `gulp build` if `bower.json` is changed ([#1378](https://github.com/roots/sage/issues/1378))
* Remove namespace from base.php ([#1372](https://github.com/roots/sage/issues/1372))
* Allow build directory to be customized ([#1352](https://github.com/roots/sage/issues/1352), [#1366](https://github.com/roots/sage/issues/1366))
* Update ConditionalTagCheck and usage docs ([#1365](https://github.com/roots/sage/issues/1365))
* Change default gallery columns to 3 ([#1364](https://github.com/roots/sage/issues/1364))
* Apply `script_loader_src` filter to jQuery fallback ([#1363](https://github.com/roots/sage/issues/1363))
### 8.0.1: February 26th, 2015
* Update asset-builder version to fix Windows compatibility ([#1351](https://github.com/roots/sage/issues/1351))
* Fix broken wiredep imports with main.scss.example ([Discussion](https://discourse.roots.io/t/issue-with-sage-sass-version/2962))
### 8.0.0: February 25th, 2015
* Change theme name from Roots to Sage
* Bump required PHP version to >=5.4
* Add coding standards based on PSR-2
* Add Travis CI
* Add namespace
* Use short array syntax
* Use short echo syntax
* Switch from Grunt to gulp, new front-end development workflow
* Switch from Livereload to [BrowserSync](http://www.browsersync.io/)
* Use wiredep for Sass and Less injection
* Implement JSON file based asset pipeline with [asset-builder](https://github.com/austinpray/asset-builder)
* Re-organize asset file structure
* Re-organize stylesheet file structure
* Add main.scss.example and instructions for using Sass
* Use the primary theme stylesheet for the editor stylesheet
* Remove theme activation, move to [wp-cli-theme-activation](https://github.com/roots/wp-cli-theme-activation)
* Simplify 404 page
* Convert Sidebar to ConditionalTagCheck
* Update to jQuery 1.11.2
* Use new core navigation template tag
* Update sidebar to fix default template check
* Update nav walker to correctly assign `active` classes for custom post types
* Better support for CPT templates
### 7.0.3: December 18th, 2014
* Use `get_the_archive_title`
* Remove `wp_title`, add title-tag theme support
* Remove `Roots_Nav_Walker` as default for all menus
* Update to Bootstrap 3.3.1
* Add some base comment styling
* Make search term `required` in search form
### 7.0.2: October 24th, 2014
* Simplify comments, use core comment form and list
* Remove HTML5 shiv from Modernizr build
* Move JavaScript to footer
* Update hEntry schema to use `updated` instead of `published`
* Move variables into `main.less`
* Add `roots_body_class` function that checks for page slug in `body_class`
* Move `wp_footer` from footer template into `base.php`
### 7.0.1: August 15th, 2014
* Move `<main>` and `.sidebar` markup out of PHP and into LESS
* Define `WP_ENV` if it is not already defined
* Only load Google Analytics in production environment
### 7.0.0: July 3rd, 2014
* Updated Grunt workflow
* Use grunt-modernizr to make a lean Modernizr build
* Use Bower for front-end package management
* Update to Bootstrap 3.2.0
* Update to Modernizr 2.8.2
* Update to jQuery 1.11.1
* Move clean up, relative URLs, and nice search to [Soil](https://github.com/roots/soil)
* Update LESS organization
* Move [community translations](https://github.com/roots/roots-translations) to separate repository
### 6.5.2: February 4th, 2014
* Update to Bootstrap 3.1.0
* Move DOM routing into an anonymous function to support jQuery noConflict
* Update to jQuery 1.11.0
* Add notice to theme activation, tidy activation table markup
* Remove changing media folder from theme activation (use [Bedrock](https://github.com/roots/bedrock) for clean URLs out of the box)
* Switch `div.main` to `main` element now that Modernizr uses the latest HTML5 Shiv
* Update to Modernizr 2.7.0
* Don't run JSHint on plugins (`assets/js/plugins/`)
* Disable warnings about undefined variables (JSHint)
* Merge in updates from HTML5 Boilerplate
* Add JS source map (disabled by default)
* Replace `grunt-recess` with `grunt-contrib-less`, add LESS source map support
### 6.5.1: November 5th, 2013
* Move clean URLs to a [plugin](https://github.com/roots/roots-rewrites)
* Update to Bootstrap 3.0.1
### 6.5.0: August 23rd, 2013
* Reference new site, [http://roots.io/](http://roots.io/)
* Remove bundled docs, reference [http://roots.io/docs/](http://roots.io/docs/)
* Use Bootstrap variables for media queries
* Update to Bootstrap 3.0.0
* Update to jQuery 1.10.2
* Change media directory from `/assets/` to `/media/`
* Update to Google Universal Analytics
* Show author display name for author archives
* Add Serbian translation
* Remove post tags from templates
* Remove TinyMCE valid elements tweaks (no longer necessary)
* Remove additional widget classes
* Move `/assets/css/less/` to `/assets/less/`
* Add wrapper templates filter
* Fix relative external URLs issue
### 6.4.0: May 1st, 2013
* Fix Theme Activation page issues
* Fix issues with root relative URLs and rewrites on non-standard setups
* Make sure rewrites are added to `.htaccess` immediately after activation
* Move HTML5 Boilerplate's `.htaccess` to a [plugin](https://github.com/roots/wp-h5bp-htaccess)
* Rename `page-custom.php` to `template-custom.php`
* Don't warn about unwritable htaccess if that option is disabled
* Add missing collapse class for top navbar
* Add comment template
* Update is_dropdown evaluation in nav walker
* Re-organize archives template
* Add missing comment ID
* hNews consistency with entry-title class
* Add `wp_title()` filter
* Fix missing closing div in comments
* Fix for navbar dropdowns
* Add option for using jQuery on Google CDN
* Correct logic in `roots_enable_root_relative_urls`
* Add Greek translation, update Brazilian Portuguese translation
* Update to Bootstrap 2.3.1
* Simplify alerts
* Remove disabled post nav links
* Use Bootstrap media object for listing comments
* Move Google Analytics to `lib/scripts.php`
* Static top navbar instead of fixed
### 6.3.0: February 8th, 2013
* Update to Bootstrap 2.3.0
* Update to jQuery 1.9.1
* Output author title with `get_the_author()`
* Add EditorConfig
* Update 404 template based on H5BP
* Update H5BP's included .htaccess
* Don't show comments on passworded posts
* Add `do_action('get_header')` for WooSidebars compatibility
* Simplify entry meta
* Allow `get_search_form()` to be called more than once per request
* Move plugins.js and main.js to footer
* JavaScript clean up (everything is now enqueued)
* Remove conditional feed
* Introduce `add_theme_support('bootstrap-gallery')`
* Rewrites organization (introduce `lib/rewrites.php`)
* Fix `add_editor_style` path
* Updated translations: French, Bulgarian, Turkish, Korean
* Enable `add_theme_support` for Nice Search
* Replace ID's with classes
* Add support for dynamic sidebar templates
* Fix PHP notice on search with no results
* Update to jQuery 1.9.0
### 6.2.0: January 13th, 2013
* Implement latest Nice Search
* Update [gallery] shortcode
* Add Simplified Chinese, Indonesian, Korean translations
* Move template title to `lib/utils.php`
* Update to Bootstrap 2.2.2
* Update to jQuery 1.8.3
* Use `entry-summary` class for excerpts per Readability's Article Publishing Guidelines
* Cleanup/refactor `lib/activation.php`
* Remove `lib/post-types.php` and `lib/metaboxes.php`
* Make sure Primary Navigation menu always gets created and has the location set upon activation, update activation permalink method
* Update to Bootstrap 2.2.1
* Update conditional feed method
* Update to Bootstrap 2.2.0
* Return instead of echo class names in `roots_main_class` and `roots_sidebar_class`
* Move nav customizations into `lib/nav.php`
### 6.1.0: October 2nd, 2012
* Change roots_sidebar into a more explicit configuration array
* Re-organize configuration/setup files
* Update to jQuery 1.8.2
* Refactor/simplify Roots vCard Widget
* Move custom entry_meta code into template
* Move Google Analytics code into footer template
* Add CONTRIBUTING.md to assist with the new GitHub UI
* Add nav walker support for CSS dividers and nav-header
### 6.0.0: September 16th, 2012
* Simplify nav walker and support 3rd level dropdowns
* Update to Bootstrap 2.1.1, jQuery 1.8.1, Modernizr 2.6.2
* Add bundled docs
* Update all templates to use [PHP Alternative Syntax](http://php.net/manual/en/control-structures.alternative-syntax.php)
* Add MIT License
* Implement scribu's [Theme Wrapper](http://scribu.net/wordpress/theme-wrappers.html) (see `base.php`)
* Move `css/`, `img/`, and `js/` folders within a new `assets/` folder
* Move templates, `comments.php`, and `searchform.php` to `templates/` folder
* Rename `inc/` to `lib/`
* Add placeholder `lib/post-types.php` and `lib/metaboxes.php` files
* Rename `loop-` files to `content-`
* Remove all hooks
* Use `templates/page-header.php` for page titles
* Use `head.php` for everything in `<head>`
### 5.2.0: August 18th, 2012
* Update to jQuery 1.8.0 and Modernizr 2.6.1
* Fix duplicate active class in `wp_nav_menu` items
* Merge `Roots_Navbar_Nav_Walker` into `Roots_Nav_Walker`
* Add and update code documentation
* Use `wp_get_theme()` to get the theme name on activation
* Use `<figure>` & `<figcaption>` for captions
* Wrap embedded media as suggested by Readability
* Remove unnecessary `remove_action`'s on `wp_head` as of WordPress 3.2.1
* Add updates from HTML5 Boilerplate
* Remove well class from sidebar
* Flush permalinks on activation to avoid 404s with clean URLs
* Show proper classes on additional `wp_nav_menu()`'s
* Clean up `inc/cleanup.php`
* Remove old admin notice for tagline
* Remove default tagline admin notice, hide from feed
* Fix for duplicated classes in widget markup
* Show title on custom post type archive template
* Fix for theme preview in WordPress 3.3.2
* Introduce `inc/config.php` with options for clean URLs, H5BP's `.htaccess`, root relative URLs, and Bootstrap features
* Allow custom CSS classes in menus, walker cleanup
* Remove WordPress version numbers from stylesheets
* Don't include HTML5 Boilerplate's `style.css` by default
* Allow `inc/htaccess.php` to work with Litespeed
* Update to Bootstrap 2.0.4
* Update Bulgarian translation
* Don't use clean URLs with default permalink structure
* Add translations for Catalan, Polish, Hungarian, Norwegian, Russian
### 5.1.0: April 14th, 2012
* Various bugfixes for scripts, stylesheets, root relative URLs, clean URLs, and htaccess issues
* Add a conditional feed link
* Temporarily remove Gravity Forms customizations
* Update to Bootstrap 2.0.2
* Update `roots.pot` for translations
* Add/update languages: Vietnamese, Swedish, Bulgarian, Turkish, Norwegian, Brazilian Portugese
* Change widgets to use `<section>` instead of `<article>`
* Add comment-reply.js
* Remove optimized robots.txt
* HTML5 Boilerplate, Modernizr, and jQuery updates
### 5.0.0: February 5th, 2012
* Remove all frameworks except Bootstrap
* Update to Bootstrap 2.0
* Remove `roots-options.php` and replaced with a more simple `roots-config.php`
* Now using Bootstrap markup on forms, page titles, image galleries, alerts and errors, post and comment navigation
* Remove Roots styles from `style.css` and introduced `app.css` for site-specific CSS
* Remove almost all previous default Roots styling
* Latest updates from HTML5 Boilerplate
### 4.1.0: February 1st, 2012
* Update translations
* HTML5 Boilerplate updates
* Fix for Server 500 errors
* Add `roots-scripts.php`, now using `wp_enqueue_script`
* Re-organize `roots-actions.php`
* Allow `<script>` tags in TinyMCE
* Add full width class and search form to 404 template
* Remove Blueprint CSS specific markup
* Use Roots Nav Walker as default
* Add author name and taxonomy name to archive template title
* Add Full Width CSS class options
### 4.0.0: January 4th, 2012
* Add theme activation options
* HTML5 Boilerplate updates
* Add CSS frameworks: Bootstrap, Foundation
* Add translations: Dutch, Italian, Macedonian, German, Finnish, Danish, Spanish, and Turkish
* Update jQuery
* Remove included jQuery plugins
* Clean up whitespace, switched to two spaces for tabs
* Clean up `body_class()` some more with `roots_body_class()`
* Post meta information is now displayed using a function (similar to Twenty Eleven)
* Bugfixes for 1140 options
* Add first and last classes to widgets
* Fix bug with initial options save
* Remove sitemap and listing subpages templates
* Child themes can now unregister sidebars
* Add fix for empty search query
* Update README
* Blocking access to readme.html and license.txt to hide WordPress version information
### 3.6.0: August 12th, 2011
* HTML5 Boilerplate 2.0 updates
* Cleaner output of enqueued styles and scripts
* Adde option for root relative URLs
* Small fixes to root relative URLs and clean assets
* Update included jQuery plugins
* Add French translation (thanks @johnraz)
* Add Brazilian Portuguese translation (thanks @weslly)
* Switch the logo to use `add_custom_image_header`
* Add a function that strips unnecessary self-closing tags
* Code cleanup and re-organization
### 3.5.0: July 30th, 2011
* Complete rewrite of theme options based on Twenty Eleven
* CSS frameworks: refactor code and add default classes for each framework
* CSS frameworks: add support for Adapt.js and LESS
* CSS frameworks: add option for None
* Add support for WPML and theme translation
* Add option for cleaner nav menu output
* Add option for FOUT-B-Gone
* Add authorship rel attribute to post author link
* Activation bugfix for pages being added multiple times
* Bugfixes to the root relative URL function
* Child themes will now load their CSS automatically and properly
* HTML5 Boilerplate updates (including Normalize.css, Modernizr 2.0, and Respond.js)
* Introduce cleaner way of including HTML5 Boilerplate's `.htaccess`
* Add hooks &amp; actions
* Rename `includes/` directory to `inc/`
* Add a blank `inc/roots-custom.php` file
### 3.2.4: May 19th, 2011
* Bugfixes
* Match latest changes to HTML5 Boilerplate and Blueprint CSS
* Update jQuery to 1.6.1
### 3.2.3: May 10th, 2011
* Bugfixes
* Add `language_attributes()` to `<html>`
* Match latest changes to HTML5 Boilerplate and Blueprint CSS
* Update jQuery to 1.6
### 3.2.2: April 24th, 2011
* Bugfixes
### 3.2.1: April 20th, 2011
* Add support for child themes
### 3.2.0: April 15th, 2011
* Add support for the 1140px Grid
* Update the conditional comment code to match latest changes to HTML5 Boilerplate
### 3.1.1: April 7th, 2011
* Fix relative path function to work correctly when WordPress is installed in a subdirectory
* Update jQuery to 1.5.2
* Fix comments to show avatars correctly
### 3.1.0: April 1st, 2011
* Add support for 960.gs thanks to John Liuti
* Add more onto the `.htaccess` from HTML5 Boilerplate
* Allow the theme directory and name to be renamable
### 3.0.0: March 28th, 2011
* Change name from BB to Roots and release to the public
* Update various areas to match the latest changes to HTML5 Boilerplate
* Change the theme markup based on hCard/Readability Guidelines and work by Jonathan Neal
* Create the navigation menus and automatically set their locations during theme activation
* Set permalink structure to `/%year%/%postname%/`
* Set uploads folder to `/assets/`
* Rewrite static folders in `/wp-content/themes/roots/` (`css/`, `js/`, `img/`) to the root (`/css/`, `/js/`, `/img/`)
* Rewrite `/wp-content/plugins/` to `/plugins/`
* Add more root relative URLs on WordPress functions
* Search results (`/?s=query`) rewrite to `/search/query/`
* `l10n.js` is deregistered
* Change [gallery] to output `<figure>` and `<figcaption>` and link to file by default
* Add more `loop.php` templates
* Made the HTML editor have a monospaced font
* Add `front-page.php`
* Update CSS for Gravity Forms 1.5
* Add `searchform.php template`
### 2.4.0: January 25th, 2011
* Add a notification when saving the theme settings
* Add support for navigation menus
* Create function that makes sure there is a Home page on theme activation
* Update various areas to match the latest changes to HTML5 Boilerplate
### 2.3.0: December 8th, 2010
* Logo is no longer an `<h1>`
* Add ARIA roles again
* Change `ul#nav` to `nav#nav-main`
* Add vCard to footer
* Made all URL's root relative
* Add Twitter and Facebook widgets to footer
* Add SEO optimized `robots.txt` from WordPress codex
### 2.2.0: September 20th, 2010
* Add asynchronous Google Analytics
* Update `.htaccess` with latest changes from HTML5 Boilerplate
### 2.1.0: August 19th, 2010
* Remove optimizeLegibility from headings
* Update jQuery to latest version
* Implement HTML5 Boilerplate `.htaccess`
### 2.0.1: August 2nd, 2010
* Add some presentational CSS classes
* Add footer widget
* Add more Gravity Forms default styling
### 2.0.0: July 19th, 2010
* Add HTML5 Boilerplate changes
* Implement `loop.php`
* wp_head cleanup
* Add `page-subpages.php` template
### 1.5.0: April 15th, 2010
* Integrate Paul Irish's frontend-pro-template (the original HTML5 Boilerplate)
### 1.0.0: December 18th, 2009
* Add Blueprint CSS to Starkers

39
LICENSE.md

@ -1,19 +1,24 @@
Copyright (c) 2017 Pressbooks (Book Oven Inc.)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
This project is based on work covered by the following copyright and permission notice:
Copyright (c) Ben Word and Scott Walkinshaw Copyright (c) Ben Word and Scott Walkinshaw
Permission is hereby granted, free of charge, to any person obtaining a copy of 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:
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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 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.
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.

60
app/activation.php

@ -0,0 +1,60 @@
<?php
namespace Aldine;
add_action('admin_init', function () {
$extra = new \ParsedownExtra();
$about = $extra->text(file_get_contents(get_stylesheet_directory() . '/docs/about.md'));
$help = $extra->text(file_get_contents(get_stylesheet_directory() . '/docs/help.md'));
$default_pages = [
'about' => [
'post_title' => __('About', 'aldine'),
'post_content' => apply_filters('pb_root_about_page_content', $about)
],
'help' => [
'post_title' => __('Help', 'aldine'),
'post_content' => apply_filters('pb_root_help_page_content', $help)
],
'catalog' => [
'post_title' => __('Catalog', 'aldine'),
'post_content' => ''
],
'home' => [
'post_title' => __('Home', 'aldine'),
'post_content' => ''
],
];
if (! get_option('pb_aldine_activated')) {
// Add our pages
$pages = [];
foreach ($default_pages as $slug => $page) {
$check = get_page_by_path($slug);
if (empty($check)) {
$pages[$slug] = wp_insert_post(array_merge($page, ['post_type' => 'page', 'post_status' => 'publish']));
} else {
$pages[$slug] = $check->ID;
}
}
// Set front page to Home
update_option('show_on_front', 'page');
update_option('page_on_front', $pages['home']);
// Remove content generated by wp_install_defaults
if (! wp_delete_post(1, true)) {
return;
}
if (! wp_delete_post(2, true)) {
return;
}
if (! wp_delete_comment(1, true)) {
return;
}
// Add "pb_aldine_activated" option to enable check above
add_option('pb_aldine_activated', 1);
}
});

116
app/admin.php

@ -1,6 +1,6 @@
<?php <?php
namespace App; namespace Aldine;
/** /**
* Theme customizer * Theme customizer
@ -9,16 +9,126 @@ add_action('customize_register', function (\WP_Customize_Manager $wp_customize)
// Add postMessage support // Add postMessage support
$wp_customize->get_setting('blogname')->transport = 'postMessage'; $wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial('blogname', [ $wp_customize->selective_refresh->add_partial('blogname', [
'selector' => '.brand', 'selector' => '.branding h1 a',
'render_callback' => function () { 'render_callback' => function () {
bloginfo('name'); bloginfo('name');
} }
]); ]);
// Add settings
foreach ([
[
'slug' => 'primary',
'hex' => '#b01109',
'label' => __('Primary Color', 'aldine'),
'description' => __('Primary color, used for links and other primary elements.', 'aldine'),
],
[
'slug' => 'accent',
'hex' => '#015d75',
'label' => __('Accent Color', 'aldine'),
'description' => __('Accent color, used for flourishes and secondary elements.', 'aldine'),
],
[
'slug' => 'primary_fg',
'hex' => '#ffffff',
'label' => __('Primary Foreground Color', 'aldine'),
'description' => __('Used for text on a primary background.', 'aldine'),
],
[
'slug' => 'accent_fg',
'hex' => '#ffffff',
'label' => __('Accent Foreground Color', 'aldine'),
'description' => __('Used for text on an accent color background.', 'aldine'),
],
] as $color) {
$wp_customize->add_setting("pb_network_color_{$color['slug']}", [
'type' => 'option',
'default' => $color['hex'],
]);
$wp_customize->add_control(new \WP_Customize_Color_Control(
$wp_customize,
"pb_network_color_{$color['slug']}",
[
'label' => $color['label'],
'section' => 'colors',
'description' => $color['description'],
'settings' => "pb_network_color_{$color['slug']}",
]
));
}
$wp_customize->add_section('pb_network_social', [
'title' => __('Social Media', 'aldine'),
'priority' => 30,
]);
$wp_customize->add_setting('pb_network_facebook', [
'type' => 'option',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control('pb_network_facebook', [
'label' => __('Facebook', 'aldine'),
'section' => 'pb_network_social',
'settings' => 'pb_network_facebook',
]);
$wp_customize->add_setting('pb_network_twitter', [
'type' => 'option',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control('pb_network_twitter', [
'label' => __('Twitter', 'aldine'),
'section' => 'pb_network_social',
'settings' => 'pb_network_twitter',
]);
$wp_customize->add_section('pb_front_page_catalog', [
'title' => __('Front Page Catalog', 'aldine'),
'priority' => 25,
]);
$wp_customize->add_setting('pb_front_page_catalog', [
'type' => 'option',
]);
$wp_customize->add_control('pb_front_page_catalog', [
'label' => __('Show Front Page Catalog', 'aldine'),
'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog',
'type' => 'checkbox'
]);
$wp_customize->add_setting('pb_front_page_catalog_title', [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field'
]);
$wp_customize->add_control('pb_front_page_catalog_title', [
'label' => __('Front Page Catalog Title', 'aldine'),
'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog_title',
]);
$wp_customize->add_section('pb_network_contact_form', [
'title' => __('Contact Form', 'aldine'),
'priority' => 25,
]);
$wp_customize->add_setting('pb_network_contact_form', [
'type' => 'option',
]);
$wp_customize->add_control('pb_network_contact_form', [
'label' => __('Show Contact Form', 'aldine'),
'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form',
'type' => 'checkbox'
]);
$wp_customize->add_setting('pb_network_contact_form_title', [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field'
]);
$wp_customize->add_control('pb_network_contact_form_title', [
'label' => __('Contact Form Title', 'aldine'),
'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form_title',
]);
}); });
/** /**
* Customizer JS * Customizer JS
*/ */
add_action('customize_preview_init', function () { add_action('customize_preview_init', function () {
wp_enqueue_script('sage/customizer.js', asset_path('scripts/customizer.js'), ['customize-preview'], null, true); wp_enqueue_script('aldine/customizer.js', asset_path('scripts/customizer.js'), ['customize-preview'], null, true);
wp_localize_script('aldine/customizer.js', 'SAGE_DIST_PATH', get_theme_file_uri() . '/dist/');
}); });

151
app/controllers/App.php

@ -0,0 +1,151 @@
<?php
namespace Aldine;
use Sober\Controller\Controller;
class App extends Controller
{
public function siteLogo()
{
$custom_logo_id = get_theme_mod('custom_logo');
if (has_custom_logo()) {
return wp_get_attachment_image($custom_logo_id, 'original');
} else {
return file_get_contents(get_theme_file_path() . '/dist/' . asset_dir('images/logo.svg'));
}
}
public function siteName()
{
return get_bloginfo('name');
}
public function networkFacebook()
{
return get_option('pb_network_facebook');
}
public function networkTwitter()
{
return get_option('pb_network_twitter');
}
public static function networkFooter($index)
{
if ($index === 2) {
if (get_option('pb_network_facebook')
|| get_option('pb_network_twitter')
|| is_active_sidebar("network-footer-block-$index")
) {
return "network-footer__block--$index";
} else {
return 'network-footer__block--empty';
}
}
return (is_active_sidebar("network-footer-block-$index")) ? "network-footer__block--$index" : 'network-footer__block--empty';
}
public static function title()
{
if (is_home()) {
if ($home = get_option('page_for_posts', true)) {
return get_the_title($home);
}
return __('Latest Posts', 'aldine');
}
if (is_archive()) {
return get_the_archive_title();
}
if (is_search()) {
return sprintf(__('Search Results for %s', 'aldine'), get_search_query());
}
if (is_404()) {
return __('Not Found', 'aldine');
}
return get_the_title();
}
public function contactFormTitle()
{
$title = get_option('pb_network_contact_form_title');
if ($title) {
return $title;
}
return __('Contact Us', 'aldine');
}
public function currentPage()
{
if (is_front_page()) {
return (get_query_var('page')) ? get_query_var('page') : 1;
} else {
return (get_query_var('paged')) ? get_query_var('paged') : 1;
}
}
public function currentSubject()
{
return (get_query_var('subject')) ? get_query_var('subject') : '';
}
public function currentLicense()
{
return (get_query_var('license')) ? get_query_var('license') : '';
}
public function currentOrderBy()
{
return (get_query_var('orderby')) ? get_query_var('orderby') : 'title';
}
public function previousPage()
{
if (is_front_page()) {
$page = (get_query_var('page')) ? get_query_var('page') : 1;
} else {
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
}
return ($page > 1) ? $page - 1 : 0;
}
public function nextPage()
{
if (is_front_page()) {
$page = (get_query_var('page')) ? get_query_var('page') : 1;
} else {
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
}
return $page + 1;
}
public static function catalogData($page = 1, $per_page = 10, $orderby = 'title', $license = '', $subject = '')
{
$request = new \WP_REST_Request('GET', '/pressbooks/v2/books');
$request->set_query_params([
'page' => $page,
'per_page' => $per_page,
]);
$response = rest_do_request($request);
$pages = $response->headers['X-WP-TotalPages'];
$data = rest_get_server()->response_to_data($response, true);
$books = [];
foreach ($data as $key => $book) {
$book['title'] = $book['metadata']['name'];
$book['date-published'] = (isset($book['metadata']['datePublished'])) ?
$book['metadata']['datePublished'] :
'';
$book['subject'] = (isset($book['metadata']['keywords'])) ? $book['metadata']['keywords'] : '';
$books[] = $book;
}
if ($orderby === 'latest') {
$books = wp_list_sort($books, $orderby, 'desc');
} else {
$books = wp_list_sort($books, $orderby);
}
return ['pages' => $pages, 'books' => $books];
}
}

37
app/controllers/FrontPage.php

@ -0,0 +1,37 @@
<?php
namespace Aldine;
use Sober\Controller\Controller;
class FrontPage extends Controller
{
public function blockCount()
{
global $_wp_sidebars_widgets;
if (empty($_wp_sidebars_widgets)) {
$_wp_sidebars_widgets = get_option('sidebars_widgets', []);
}
$sidebars_widgets_count = $_wp_sidebars_widgets;
if (isset($sidebars_widgets_count['front-page-block'])) {
return count($sidebars_widgets_count['front-page-block']);
}
return 1;
}
public function latestBooksTitle()
{
$title = get_option('pb_front_page_catalog_title');
if ($title) {
return $title;
}
return __('Our Latest Titles', 'aldine');
}
public function catalogData()
{
$page = (get_query_var('page')) ? get_query_var('page') : 1;
return App::catalogData($page, 3);
}
}

111
app/controllers/PageCatalog.php

@ -0,0 +1,111 @@
<?php
namespace Aldine;
use Sober\Controller\Controller;
class PageCatalog extends Controller
{
public function licenses()
{
$licenses = (new \Pressbooks\Licensing())->getSupportedTypes();
foreach ($licenses as $key => $value) {
$licenses[$key] = preg_replace("/\([^)]+\)/", '', $value['desc']);
}
return $licenses;
}
public function subjectGroups()
{
return [
'business-finance' => [
'title' => __('Business and Finance', 'aldine'),
'subjects' => [
'accounting' => 'Accounting',
'finance' => 'Finance',
'information-systems' => 'Information Systems',
'management' => 'Management',
'marketing' => 'Marketing',
'economics' => 'Economics',
],
],
'engineering-technology' => [
'title' => __('Engineering &amp; Technology', 'aldine'),
'subjects' => [
'architecture' => 'Architecture',
'bioengineering' => 'Bioengineering',
'chemical' => 'Chemical',
'civil' => 'Civil',
'electrical' => 'Electrical',
'mechanical' => 'Mechanical',
'mining-and-materials' => 'Mining and Materials',
'urban-planning' => 'Urban Planning',
'computer-science' => 'Computer Science',
],
],
'health-sciences' => [
'title' => __('Health Sciences', 'aldine'),
'subjects' => [
'nursing' => 'Nursing',
'dentistry' => 'Dentistry',
'medicine' => 'Medicine',
],
],
'humanities-arts' => [
'title' => __('Humanities &amp; Arts', 'aldine'),
'subjects' => [
'archaeology' => 'Archaeology',
'art' => 'Art',
'classics' => 'Classics',
'literature' => 'Literature',
'history' => 'History',
'media' => 'Media',
'music' => 'Music',
'philosophy' => 'Philosophy',
'religion' => 'Religion',
'language' => 'Language',
],
],
'reference' => [
'title' => __('Reference', 'aldine'),
'subjects' => [
'student-guides' => 'Student Guides',
'teaching-guides' => 'Teaching Guides',
],
],
'science' => [
'title' => __('Sciences', 'aldine'),
'subjects' => [
'biology' => 'Biology',
'chemistry' => 'Chemistry',
'environent-and-earth-sciences' => 'Environment and Earth Sciences',
'geography' => 'Geography',
'mathematics' => 'Mathematics',
'physics' => 'Physics',
],
],
'social-sciences' => [
'title' => __('Social Sciences', 'aldine'),
'subjects' => [
'anthropology' => 'Anthropology',
'gender-studies' => 'Gender Studies',
'linguistics' => 'Linguistics',
'museums-libraries-and-information-sciences' => 'Museums, Libraries, and Information Sciences',
'political-science' => 'Political Science',
'psychology' => 'Psychology',
'social-work' => 'Social Work',
'sociology' => 'Sociology',
],
],
];
}
public function catalogData()
{
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$orderby = (get_query_var('orderby')) ? get_query_var('orderby') : 'title';
$subject = (get_query_var('subject')) ? get_query_var('subject') : '';
$license = (get_query_var('license')) ? get_query_var('license') : '';
return App::catalogData($page, 9, $orderby, $license, $subject);
}
}

16
app/filters.php

@ -1,6 +1,6 @@
<?php <?php
namespace App; namespace Aldine;
/** /**
* Add <body> classes * Add <body> classes
@ -13,11 +13,6 @@ add_filter('body_class', function (array $classes) {
} }
} }
/** Add class if sidebar is active */
if (display_sidebar()) {
$classes[] = 'sidebar-primary';
}
/** Clean up class names for custom templates */ /** Clean up class names for custom templates */
$classes = array_map(function ($class) { $classes = array_map(function ($class) {
return preg_replace(['/-blade(-php)?$/', '/^page-template-views/'], '', $class); return preg_replace(['/-blade(-php)?$/', '/^page-template-views/'], '', $class);
@ -30,7 +25,7 @@ add_filter('body_class', function (array $classes) {
* Add "… Continued" to the excerpt * Add "… Continued" to the excerpt
*/ */
add_filter('excerpt_more', function () { add_filter('excerpt_more', function () {
return ' &hellip; <a href="' . get_permalink() . '">' . __('Continued', 'sage') . '</a>'; return ' &hellip; <a href="' . get_permalink() . '">' . __('Continued', 'aldine') . '</a>';
}); });
/** /**
@ -68,3 +63,10 @@ add_filter('comments_template', function ($comments_template) {
); );
return template_path(locate_template(["views/{$comments_template}", $comments_template]) ?: $comments_template); return template_path(locate_template(["views/{$comments_template}", $comments_template]) ?: $comments_template);
}); });
/**
* Remove Admin Bar callback
*/
add_action('admin_bar_init', function () {
remove_action('wp_head', '_admin_bar_bump_cb');
});

121
app/helpers.php

@ -1,6 +1,6 @@
<?php <?php
namespace App; namespace Aldine;
use Roots\Sage\Container; use Roots\Sage\Container;
@ -52,6 +52,10 @@ function config($key = null, $default = null)
*/ */
function template($file, $data = []) function template($file, $data = [])
{ {
if (remove_action('wp_head', 'wp_enqueue_scripts', 1)) {
wp_enqueue_scripts();
}
return sage('blade')->render($file, $data); return sage('blade')->render($file, $data);
} }
@ -72,7 +76,16 @@ function template_path($file, $data = [])
*/ */
function asset_path($asset) function asset_path($asset)
{ {
return sage('assets')->getUri($asset); return fix_path(sage('assets')->getUri('/' . $asset));
}
/**
* @param $asset
* @return string
*/
function asset_dir($asset)
{
return fix_path(sage('assets')->get('/' . $asset));
} }
/** /**
@ -81,12 +94,25 @@ function asset_path($asset)
*/ */
function filter_templates($templates) function filter_templates($templates)
{ {
$paths = apply_filters('sage/filter_templates/paths', [
'views',
'resources/views'
]);
$paths_pattern = "#^(" . implode('|', $paths) . ")/#";
return collect($templates) return collect($templates)
->map(function ($template) { ->map(function ($template) use ($paths_pattern) {
return preg_replace('#\.(blade\.)?php$#', '', ltrim($template)); /** Remove .blade.php/.blade/.php from template names */
$template = preg_replace('#\.(blade\.?)?(php)?$#', '', ltrim($template));
/** Remove partial $paths from the beginning of template names */
if (strpos($template, '/')) {
$template = preg_replace($paths_pattern, '', $template);
}
return $template;
}) })
->flatMap(function ($template) { ->flatMap(function ($template) use ($paths) {
$paths = apply_filters('sage/filter_templates/paths', ['views', 'resources/views']);
return collect($paths) return collect($paths)
->flatMap(function ($path) use ($template) { ->flatMap(function ($path) use ($template) {
return [ return [
@ -112,36 +138,65 @@ function locate_template($templates)
} }
/** /**
* Determine whether to show the sidebar *
* @return bool * Catch a contact form submission.
*
* @return false | array
*/ */
function display_sidebar() function contact_form_submission()
{ {
static $display; if (isset($_POST['submitted'])) {
isset($display) || $display = apply_filters('sage/display_sidebar', false); $output = [];
return $display; $name = (isset($_POST['visitor_name'])) ? $_POST['visitor_name'] : false;
$email = (isset($_POST['visitor_email'])) ? $_POST['visitor_email'] : false;
$institution = (isset($_POST['visitor_institution'])) ? $_POST['visitor_institution'] : false;
$message = (isset($_POST['message'])) ? $_POST['message'] : false;
if (!$name) {
$output['message'] = __('Name is required.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'visitor_name';
} elseif (!$email) {
$output['message'] = __('Email is required.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'visitor_email';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$output['message'] = __('Email is invalid.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'visitor_email';
} elseif (!$institution) {
$output['message'] = __('Institution is required.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'visitor_institution';
} elseif (!$message) {
$output['message'] = __('Message is required.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'message';
} else {
$sent = wp_mail(
get_option('admin_email'),
sprintf(__('Contact Form Submission from %s', 'aldine'), $name),
sprintf(
"From: %1\$s <%2\$s>\n%3\$s",
$name,
$email,
strip_tags($message)
),
"From: ${email}\r\nReply-To: ${email}\r\n"
);
if ($sent) {
$output['message'] = __('Your message was sent!', 'aldine');
$output['status'] = 'success';
} else {
$output['message'] = __('Your message could not be sent.', 'aldine');
$output['status'] = 'error';
}
}
return $output;
}
return false;
} }
/** function fix_path($path)
* Page titles
* @return string
*/
function title()
{ {
if (is_home()) { return str_replace('/dist//', '/dist/', $path);
if ($home = get_option('page_for_posts', true)) {
return get_the_title($home);
}
return __('Latest Posts', 'sage');
}
if (is_archive()) {
return get_the_archive_title();
}
if (is_search()) {
return sprintf(__('Search Results for %s', 'sage'), get_search_query());
}
if (is_404()) {
return __('Not Found', 'sage');
}
return get_the_title();
} }

38
app/intervention.php

@ -0,0 +1,38 @@
<?php
namespace Aldine;
use function \Sober\Intervention\intervention;
if (function_exists('\Sober\Intervention\intervention')) {
intervention('remove-customizer-items', 'static-front-page', 'all');
intervention('remove-emoji');
intervention('remove-howdy', __('Hello,', 'aldine'));
intervention('remove-dashboard-items', ['activity', 'quick-draft']);
intervention('remove-menu-items', [
'posts',
'tools',
'setting-writing',
'setting-reading',
'setting-permalink'
], 'all');
intervention('remove-widgets', [
'pages',
'calendar',
'archives',
'links',
'media-audio',
'meta',
'search',
'categories',
'recent-posts',
'recent-comments',
'rss',
'tag-cloud',
'custom-menu',
'custom-html',
'media-video',
'akismet',
], 'all');
intervention('remove-toolbar-frontend', 'all');
}

111
app/setup.php

@ -1,6 +1,6 @@
<?php <?php
namespace App; namespace Aldine;
use Roots\Sage\Container; use Roots\Sage\Container;
use Roots\Sage\Assets\JsonManifest; use Roots\Sage\Assets\JsonManifest;
@ -11,24 +11,17 @@ use Roots\Sage\Template\BladeProvider;
* Theme assets * Theme assets
*/ */
add_action('wp_enqueue_scripts', function () { add_action('wp_enqueue_scripts', function () {
wp_enqueue_style('sage/main.css', asset_path('styles/main.css'), false, null); $webfonts = 'https://fonts.googleapis.com/css?family=Karla:400,400i,700|Spectral:400,400i,600';
wp_enqueue_script('sage/main.js', asset_path('scripts/main.js'), ['jquery'], null, true); wp_enqueue_style('aldine/webfonts', $webfonts, false, null);
wp_enqueue_style('aldine/main.css', asset_path('styles/main.css'), false, null);
wp_enqueue_script('aldine/main.js', asset_path('scripts/main.js'), ['jquery'], null, true);
wp_localize_script('aldine/main.js', 'SAGE_DIST_PATH', get_theme_file_uri() . '/dist/');
}, 100); }, 100);
/** /**
* Theme setup * Theme setup
*/ */
add_action('after_setup_theme', function () { add_action('after_setup_theme', function () {
/**
* Enable features from Soil when plugin is activated
* @link https://roots.io/plugins/soil/
*/
add_theme_support('soil-clean-up');
add_theme_support('soil-jquery-cdn');
add_theme_support('soil-nav-walker');
add_theme_support('soil-nice-search');
add_theme_support('soil-relative-urls');
/** /**
* Enable plugins to manage the document title * Enable plugins to manage the document title
* @link https://developer.wordpress.org/reference/functions/add_theme_support/#title-tag * @link https://developer.wordpress.org/reference/functions/add_theme_support/#title-tag
@ -40,7 +33,29 @@ add_action('after_setup_theme', function () {
* @link https://developer.wordpress.org/reference/functions/register_nav_menus/ * @link https://developer.wordpress.org/reference/functions/register_nav_menus/
*/ */
register_nav_menus([ register_nav_menus([
'primary_navigation' => __('Primary Navigation', 'sage') 'network-footer-menu' => __('Network Footer Menu', 'aldine')
]);
/**
* Enable custom headers
* @link https://developer.wordpress.org/themes/functionality/custom-headers/
*/
add_theme_support('custom-header', [
'default-image' => asset_path('images/header.jpg'),
'width' => 1920,
'height' => 884,
'default-text-color' => '#000',
]);
/**
* Enable custom logos
* @link https://developer.wordpress.org/themes/functionality/custom-logo/
*/
add_theme_support('custom-logo', [
'height' => 40,
'width' => 265,
'flex-width' => true,
'flex-height' => true,
]); ]);
/** /**
@ -75,16 +90,40 @@ add_action('widgets_init', function () {
$config = [ $config = [
'before_widget' => '<section class="widget %1$s %2$s">', 'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>', 'after_widget' => '</section>',
'before_title' => '<h3>', 'before_title' => '<h2>',
'after_title' => '</h3>' 'after_title' => '</h2>'
]; ];
register_sidebar([ register_sidebar([
'name' => __('Primary', 'sage'), 'name' => __('Front Page Content', 'aldine'),
'id' => 'sidebar-primary' 'description' => __(
'Add content for your network&rsquo;s front page here. Currently, only text widgets are supported.',
'aldine'
),
'id' => 'front-page-block',
'before_widget' => '<section class="block %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2>',
'after_title' => '</h2>'
]);
register_sidebar([
'name' => __('Network Footer Block 1', 'aldine'),
'description' => __(
'Add content for your network&rsquo;s customizeable footer here.
Currently, only text and image widgets are supported.
Content in this widget area will appear in the first row (on mobile) or the first column (on desktops).',
'aldine'
),
'id' => 'network-footer-block-1'
] + $config); ] + $config);
register_sidebar([ register_sidebar([
'name' => __('Footer', 'sage'), 'name' => __('Network Footer Block 2', 'aldine'),
'id' => 'sidebar-footer' 'description' => __(
'Add content for your network&rsquo;s customizeable footer here.
Currently, only text and image widgets are supported.
Content in this widget area will appear in the second row (on mobile) or the middle column (on desktop).',
'aldine'
),
'id' => 'network-footer-block-2'
] + $config); ] + $config);
}); });
@ -126,3 +165,35 @@ add_action('after_setup_theme', function () {
return "<?= " . __NAMESPACE__ . "\\asset_path({$asset}); ?>"; return "<?= " . __NAMESPACE__ . "\\asset_path({$asset}); ?>";
}); });
}); });
add_action('wp_head', function () {
$primary = get_option('pb_network_color_primary');
$accent = get_option('pb_network_color_accent');
$primary_fg = get_option('pb_network_color_primary_fg');
$accent_fg = get_option('pb_network_color_accent_fg');
$header_text = get_header_textcolor();
if ($primary || $accent || $primary_fg || $accent_fg || $header_text) { ?>
<style type="text/css">:root {
<?php if ($primary) { ?>
--primary: <?= $primary ?>;
<?php }
if ($accent) { ?>
--accent: <?= $accent ?>;
<?php }
if ($primary_fg) { ?>
--primary-fg: <?= $primary_fg ?>;
<?php }
if ($accent_fg) { ?>
--accent-fg: <?= $accent_fg ?>;
<?php }
if ($header_text) { ?>
--header-text: <?= $header_text ?>;
<?php } ?>
}</style>
<?php }
});
add_action('wp_head', function () {
$response = contact_form_submission();
sage('blade')->share('contact_form_response', $response);
});

33
composer.json

@ -1,7 +1,7 @@
{ {
"name": "pressbooks/pressbooks-aldine", "name": "pressbooks/pressbooks-aldine",
"type": "wordpress-theme", "type": "wordpress-theme",
"license": "MIT", "license": "GPL-3",
"description": "Aldine is the new root theme for Pressbooks, based on Sage.", "description": "Aldine is the new root theme for Pressbooks, based on Sage.",
"homepage": "https://github.com/pressbooks/pressbooks-aldine/", "homepage": "https://github.com/pressbooks/pressbooks-aldine/",
"authors": [ "authors": [
@ -9,6 +9,21 @@
"name": "Pressbooks (Book Oven Inc.)", "name": "Pressbooks (Book Oven Inc.)",
"email": "code@pressbooks.com", "email": "code@pressbooks.com",
"homepage": "https://pressbooks.org" "homepage": "https://pressbooks.org"
},
{
"name": "Ben Word",
"email": "ben@benword.com",
"homepage": "https://github.com/retlehs"
},
{
"name": "Scott Walkinshaw",
"email": "scott.walkinshaw@gmail.com",
"homepage": "https://github.com/swalkinshaw"
},
{
"name": "QWp6t",
"email": "hi@qwp6t.me",
"homepage": "https://github.com/qwp6t"
} }
], ],
"keywords": [ "keywords": [
@ -23,26 +38,24 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/" "Aldine\\": "app/"
} }
}, },
"require": { "require": {
"php": ">=5.6.4", "php": ">=7",
"composer/installers": "~1.0", "composer/installers": "~1.0",
"illuminate/support": "~5.4", "illuminate/support": "~5.4",
"roots/sage-lib": "~9.0.0-beta.3", "roots/sage-lib": "~9.0.0-beta.4",
"soberwp/controller": "dev-master" "soberwp/controller": "~9.0.0-beta.4",
"soberwp/intervention": "1.2.0-p",
"erusev/parsedown-extra": "^0.7.1"
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "^2.8.0", "squizlabs/php_codesniffer": "^2.8.0"
"roots/sage-installer": "~1.1"
}, },
"scripts": { "scripts": {
"test": [ "test": [
"phpcs" "phpcs"
],
"post-create-project-cmd": [
"Roots\\Sage\\Installer\\ComposerScript::postCreateProject"
] ]
} }
} }

625
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "9a56b0654d7dff65e2aebe6ed81833f3", "content-hash": "f7726a4926f063ad567227228ba400b8",
"packages": [ "packages": [
{ {
"name": "brain/hierarchy", "name": "brain/hierarchy",
@ -64,16 +64,16 @@
}, },
{ {
"name": "composer/installers", "name": "composer/installers",
"version": "v1.3.0", "version": "v1.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/composer/installers.git", "url": "https://github.com/composer/installers.git",
"reference": "79ad876c7498c0bbfe7eed065b8651c93bfd6045" "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/composer/installers/zipball/79ad876c7498c0bbfe7eed065b8651c93bfd6045", "url": "https://api.github.com/repos/composer/installers/zipball/9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b",
"reference": "79ad876c7498c0bbfe7eed065b8651c93bfd6045", "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -119,6 +119,7 @@
"Hurad", "Hurad",
"ImageCMS", "ImageCMS",
"Kanboard", "Kanboard",
"Lan Management System",
"MODX Evo", "MODX Evo",
"Mautic", "Mautic",
"Maya", "Maya",
@ -142,6 +143,7 @@
"croogo", "croogo",
"dokuwiki", "dokuwiki",
"drupal", "drupal",
"eZ Platform",
"elgg", "elgg",
"expressionengine", "expressionengine",
"fuelphp", "fuelphp",
@ -158,6 +160,7 @@
"mediawiki", "mediawiki",
"modulework", "modulework",
"moodle", "moodle",
"osclass",
"phpbb", "phpbb",
"piwik", "piwik",
"ppi", "ppi",
@ -174,37 +177,37 @@
"zend", "zend",
"zikula" "zikula"
], ],
"time": "2017-04-24T06:37:16+00:00" "time": "2017-08-09T07:53:48+00:00"
}, },
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
"version": "v1.1.0", "version": "v1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/inflector.git", "url": "https://github.com/doctrine/inflector.git",
"reference": "90b2128806bfde671b6952ab8bea493942c1fdae" "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae", "url": "https://api.github.com/repos/doctrine/inflector/zipball/e11d84c6e018beedd929cff5220969a3c6d1d462",
"reference": "90b2128806bfde671b6952ab8bea493942c1fdae", "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.2" "php": "^7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "4.*" "phpunit/phpunit": "^6.2"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.1.x-dev" "dev-master": "1.2.x-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Doctrine\\Common\\Inflector\\": "lib/" "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -241,7 +244,93 @@
"singularize", "singularize",
"string" "string"
], ],
"time": "2015-11-06T14:35:42+00:00" "time": "2017-07-22T12:18:28+00:00"
},
{
"name": "erusev/parsedown",
"version": "1.6.3",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "728952b90a333b5c6f77f06ea9422b94b585878d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/728952b90a333b5c6f77f06ea9422b94b585878d",
"reference": "728952b90a333b5c6f77f06ea9422b94b585878d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Parsedown": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "Parser for Markdown.",
"homepage": "http://parsedown.org",
"keywords": [
"markdown",
"parser"
],
"time": "2017-05-14T14:47:48+00:00"
},
{
"name": "erusev/parsedown-extra",
"version": "0.7.1",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown-extra.git",
"reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/0db5cce7354e4b76f155d092ab5eb3981c21258c",
"reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c",
"shasum": ""
},
"require": {
"erusev/parsedown": "~1.4"
},
"type": "library",
"autoload": {
"psr-0": {
"ParsedownExtra": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "An extension of Parsedown that adds support for Markdown Extra.",
"homepage": "https://github.com/erusev/parsedown-extra",
"keywords": [
"markdown",
"markdown extra",
"parsedown",
"parser"
],
"time": "2015-11-01T10:19:22+00:00"
}, },
{ {
"name": "hassankhan/config", "name": "hassankhan/config",
@ -726,26 +815,26 @@
}, },
{ {
"name": "roots/sage-lib", "name": "roots/sage-lib",
"version": "9.0.0-beta.3", "version": "9.0.0-beta.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/roots/sage-lib.git", "url": "https://github.com/roots/sage-lib.git",
"reference": "d7789609eae857e910812cf62ae55355b836ad58" "reference": "71ed6e54e831fd1ced5bae028f0515d277e8c1c1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/roots/sage-lib/zipball/d7789609eae857e910812cf62ae55355b836ad58", "url": "https://api.github.com/repos/roots/sage-lib/zipball/71ed6e54e831fd1ced5bae028f0515d277e8c1c1",
"reference": "d7789609eae857e910812cf62ae55355b836ad58", "reference": "71ed6e54e831fd1ced5bae028f0515d277e8c1c1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"composer/installers": "~1.0", "composer/installers": "~1.0",
"illuminate/config": "~5.4", "illuminate/config": "~5.4",
"illuminate/view": "~5.4", "illuminate/view": "~5.4",
"php": ">=5.6.4" "php": ">=7"
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "^2.8.0" "squizlabs/php_codesniffer": "~3.0"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -774,20 +863,20 @@
"keywords": [ "keywords": [
"wordpress" "wordpress"
], ],
"time": "2017-07-09T11:48:17+00:00" "time": "2017-08-11T23:38:23+00:00"
}, },
{ {
"name": "soberwp/controller", "name": "soberwp/controller",
"version": "dev-master", "version": "9.0.0-beta.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/soberwp/controller.git", "url": "https://github.com/soberwp/controller.git",
"reference": "e9358ff900d6065f5252a114fb187403fbc594ec" "reference": "2b6c8450f4a3100b16bfc482c825d89422b6adc6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/soberwp/controller/zipball/e9358ff900d6065f5252a114fb187403fbc594ec", "url": "https://api.github.com/repos/soberwp/controller/zipball/2b6c8450f4a3100b16bfc482c825d89422b6adc6",
"reference": "e9358ff900d6065f5252a114fb187403fbc594ec", "reference": "2b6c8450f4a3100b16bfc482c825d89422b6adc6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -826,20 +915,69 @@
"keywords": [ "keywords": [
"wordpress" "wordpress"
], ],
"time": "2017-06-25T13:13:49+00:00" "time": "2017-08-22T17:35:30+00:00"
},
{
"name": "soberwp/intervention",
"version": "1.2.0-p",
"source": {
"type": "git",
"url": "https://github.com/soberwp/intervention.git",
"reference": "1698e51efe696c5867fb78ef7c5d2efff9b79260"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/soberwp/intervention/zipball/1698e51efe696c5867fb78ef7c5d2efff9b79260",
"reference": "1698e51efe696c5867fb78ef7c5d2efff9b79260",
"shasum": ""
},
"require": {
"composer/installers": "~1.0",
"php": ">=5.4.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "2.*"
},
"type": "package",
"autoload": {
"psr-4": {
"Sober\\Intervention\\": "src/",
"Sober\\Intervention\\Module\\": "src/modules/"
},
"files": [
"intervention.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Darren Jacoby",
"email": "darren@jacoby.co.za",
"homepage": "https://twitter.com/withjacoby"
}
],
"description": "WordPress plugin containing modules to cleanup and customize wp-admin.",
"homepage": "https://github.com/soberwp",
"keywords": [
"wordpress"
],
"time": "2017-08-26T12:21:27+00:00"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v3.3.4", "version": "v3.3.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
"reference": "63b85a968486d95ff9542228dc2e4247f16f9743" "reference": "7c13ae8ce1e2adbbd574fc39de7be498e1284e13"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/63b85a968486d95ff9542228dc2e4247f16f9743", "url": "https://api.github.com/repos/symfony/debug/zipball/7c13ae8ce1e2adbbd574fc39de7be498e1284e13",
"reference": "63b85a968486d95ff9542228dc2e4247f16f9743", "reference": "7c13ae8ce1e2adbbd574fc39de7be498e1284e13",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -882,11 +1020,11 @@
], ],
"description": "Symfony Debug Component", "description": "Symfony Debug Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-07-05T13:02:37+00:00" "time": "2017-07-28T15:27:31+00:00"
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v3.3.4", "version": "v3.3.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
@ -935,16 +1073,16 @@
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v3.3.4", "version": "v3.3.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
"reference": "1f93a8d19b8241617f5074a123e282575b821df8" "reference": "ddc23324e6cfe066f3dd34a37ff494fa80b617ed"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/1f93a8d19b8241617f5074a123e282575b821df8", "url": "https://api.github.com/repos/symfony/yaml/zipball/ddc23324e6cfe066f3dd34a37ff494fa80b617ed",
"reference": "1f93a8d19b8241617f5074a123e282575b821df8", "reference": "ddc23324e6cfe066f3dd34a37ff494fa80b617ed",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -986,173 +1124,10 @@
], ],
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-06-15T12:58:50+00:00" "time": "2017-07-23T12:43:26+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
{
"name": "illuminate/console",
"version": "v5.4.27",
"source": {
"type": "git",
"url": "https://github.com/illuminate/console.git",
"reference": "bdc5c6f53cb474e2aeec46b6a9999fcedfb62a4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/console/zipball/bdc5c6f53cb474e2aeec46b6a9999fcedfb62a4e",
"reference": "bdc5c6f53cb474e2aeec46b6a9999fcedfb62a4e",
"shasum": ""
},
"require": {
"illuminate/contracts": "5.4.*",
"illuminate/support": "5.4.*",
"nesbot/carbon": "~1.20",
"php": ">=5.6.4",
"symfony/console": "~3.2"
},
"suggest": {
"guzzlehttp/guzzle": "Required to use the ping methods on schedules (~6.0).",
"mtdowling/cron-expression": "Required to use scheduling component (~1.0).",
"symfony/process": "Required to use scheduling component (~3.2)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.4-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Console\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Console package.",
"homepage": "https://laravel.com",
"time": "2017-06-10T13:11:18+00:00"
},
{
"name": "nesbot/carbon",
"version": "1.22.1",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc",
"reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/translation": "~2.6 || ~3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2",
"phpunit/phpunit": "~4.0 || ~5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.23-dev"
}
},
"autoload": {
"psr-4": {
"Carbon\\": "src/Carbon/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brian Nesbitt",
"email": "brian@nesbot.com",
"homepage": "http://nesbot.com"
}
],
"description": "A simple API extension for DateTime.",
"homepage": "http://carbon.nesbot.com",
"keywords": [
"date",
"datetime",
"time"
],
"time": "2017-01-16T07:55:07+00:00"
},
{
"name": "roots/sage-installer",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/roots/sage-installer.git",
"reference": "837411acf1337d35e1b497c4ba3a8ed7cf6077fa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/roots/sage-installer/zipball/837411acf1337d35e1b497c4ba3a8ed7cf6077fa",
"reference": "837411acf1337d35e1b497c4ba3a8ed7cf6077fa",
"shasum": ""
},
"require": {
"illuminate/console": "~5.4",
"illuminate/filesystem": "~5.4",
"symfony/process": "~3.3"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.0"
},
"bin": [
"bin/sage"
],
"type": "library",
"autoload": {
"psr-4": {
"Roots\\Sage\\Installer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ben Word",
"email": "ben@benword.com",
"homepage": "https://github.com/retlehs"
},
{
"name": "QWp6t",
"email": "hi@qwp6t.me",
"homepage": "https://github.com/qwp6t"
}
],
"description": "Sage installer.",
"keywords": [
"FontAwesome",
"bootstrap",
"foundation",
"sage",
"tachyons",
"theme",
"wordpress"
],
"time": "2017-07-04T17:57:47+00:00"
},
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "2.9.1", "version": "2.9.1",
@ -1230,260 +1205,18 @@
"standards" "standards"
], ],
"time": "2017-05-22T02:43:20+00:00" "time": "2017-05-22T02:43:20+00:00"
},
{
"name": "symfony/console",
"version": "v3.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "a97e45d98c59510f085fa05225a1acb74dfe0546"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/a97e45d98c59510f085fa05225a1acb74dfe0546",
"reference": "a97e45d98c59510f085fa05225a1acb74dfe0546",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/debug": "~2.8|~3.0",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"symfony/dependency-injection": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.3",
"symfony/dependency-injection": "~3.3",
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/filesystem": "~2.8|~3.0",
"symfony/http-kernel": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0"
},
"suggest": {
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/filesystem": "",
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Console\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2017-07-03T13:19:36+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "f29dca382a6485c3cbe6379f0c61230167681937"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937",
"reference": "f29dca382a6485c3cbe6379f0c61230167681937",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"time": "2017-06-09T14:24:12+00:00"
},
{
"name": "symfony/process",
"version": "v3.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "5ab8949b682b1bf9d4511a228b5e045c96758c30"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/5ab8949b682b1bf9d4511a228b5e045c96758c30",
"reference": "5ab8949b682b1bf9d4511a228b5e045c96758c30",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Process\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2017-07-03T08:12:02+00:00"
},
{
"name": "symfony/translation",
"version": "v3.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "35dd5fb003c90e8bd4d8cabdf94bf9c96d06fdc3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/35dd5fb003c90e8bd4d8cabdf94bf9c96d06fdc3",
"reference": "35dd5fb003c90e8bd4d8cabdf94bf9c96d06fdc3",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"symfony/config": "<2.8",
"symfony/yaml": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~2.8|~3.0",
"symfony/intl": "^2.8.18|^3.2.5",
"symfony/yaml": "~3.3"
},
"suggest": {
"psr/log": "To use logging capability in translator",
"symfony/config": "",
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Translation\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2017-06-24T16:45:30+00:00"
} }
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {
"roots/sage-lib": 10, "roots/sage-lib": 10,
"soberwp/controller": 20 "soberwp/controller": 10
}, },
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": ">=5.6.4" "php": ">=7"
}, },
"platform-dev": [] "platform-dev": []
} }

2
config/assets.php

@ -14,7 +14,7 @@ return [
| |
*/ */
'manifest' => get_theme_file_path().'/dist/assets.json', 'manifest' => get_theme_file_path().'/dist/mix-manifest.json',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

227
lib/infusion/Infusion-LICENSE.txt

@ -0,0 +1,227 @@
Infusion is available under either the terms of the New BSD license or the
Educational Community License, Version 2.0. As a recipient of Infusion, you may
choose which license to receive this code under (except as noted in per-module
LICENSE files). All modules are Copyright 2011 OCAD University except
where noted otherwise in the code itself, or if the modules reside in a separate
directory, they may contain explicit declarations of copyright in both the
LICENSE file in the directory in which they reside and in the code itself. No
external contributions are allowed under licenses which are fundamentally
incompatible with the ECL or BSD licenses that Infusion is distributed under.
The text of the ECL and BSD licenses is reproduced below.
Educational Community License, Version 2.0
*************************************
Copyright 2011 OCAD University
Educational Community License, Version 2.0, April 2007
The Educational Community License version 2.0 ("ECL") consists of the Apache 2.0
license, modified to change the scope of the patent grant in section 3 to be
specific to the needs of the education communities using this license. The
original Apache 2.0 license can be found at:
http://www.apache.org/licenses/LICENSE-2.0
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. Any
patent license granted hereby with respect to contributions by an individual
employed by an institution or organization is limited to patent claims where the
individual that is the author of the Work is also the inventor of the patent
claims licensed, and where the organization or institution has the right to
grant such license under applicable grant and research funding agreements. No
other express or implied licenses are granted.
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:
1. You must give any other recipients of the Work or Derivative Works a copy
of this License; and
2. You must cause any modified files to carry prominent notices stating that
You changed the files; and
3. 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
4. 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 FOR ECL 2.0
The New BSD license
**********************
Copyright 2011 OCAD University
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of OCAD University nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
END OF TERMS AND CONDITIONS FOR THE NEW BSD LICENSE

212
lib/infusion/README.md

@ -0,0 +1,212 @@
## What Is Infusion? ##
Infusion is a different kind of JavaScript framework. Our approach is to leave you in control—it's your interface, using your markup, your way. Infusion is accessible and very, very configurable.
Infusion includes:
* an application framework for developing flexible stuff with JavaScript and jQuery
* a collection of accessible UI components
## Where Can I See Infusion Components? ##
<http://fluidproject.org/infusion.html>
## How Do I Get Infusion? ##
* [Download a Release](https://github.com/fluid-project/infusion/releases)
* [Install from NPM](https://www.npmjs.com/package/infusion)
* [Fork on GitHub](https://github.com/fluid-project/infusion)
See [How Do I Create an Infusion Package?](#how-do-i-create-an-infusion-package), for details on creating complete or custom packages of Infusion.
## Where is the Infusion Documentation? ##
Infusion has comprehensive documentation at <http://docs.fluidproject.org/infusion>.
## Who Makes Infusion, and How Can I Help? ##
The Fluid community is an international group of designers, developers, and testers who focus on a common mission: improving the user experience and accessibility of the open web.
The best way to join the Fluid Community is to jump into any of our community activities. Visit our [website](http://fluidproject.org/) for links to our mailing lists, chat room, wiki, etc.
## Where is Infusion Used? ##
Infusion is the cornerstone of a number of Fluid's own projects dedicated to supporting inclusive design on the Web. You can see some of them featured on our [Projects page](http://fluidproject.org/projects.html). Infusion is also used in a variety of third-party applications, which are listed on the [Infusion Integrations](https://wiki.fluidproject.org/display/fluid/Infusion+Integrations) wiki page.
## How Do I Create an Infusion Package? ##
For simplicity and performance reasons, you may wish to create a concatenated, minified file. However, such a file is often difficult to read. To address this, source maps for the minified file are automatically generated to make debugging easier.
### Source Maps ###
Source maps are supported in all of the major browsers: [Chrome](https://developer.chrome.com/devtools/docs/javascript-debugging#source-maps), [Firefox](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map),
[IE 11](https://msdn.microsoft.com/library/dn255007#source_maps), and Safari. To make use of them, enable source maps in your debugging environment, and ensure that the source maps are hosted adjacent to the file they are associated with.
#### Source Map Example ####
* From the command line, run `grunt` to create a build of Infusion
* All Infusion packages come with a source map for the concatenated JavaScript file
* In the Infusion package, modify one of the demos to replace the individual javascript includes with a reference to "infusion-all.js"
* The "infusion-all.js" includes a reference to the "infusion-all.js.map" file, which is assumed to be hosted as its sibling
* Open the demo in a browser
* In the browser's debugger ensure that source maps are enabled
* In Firefox open the debugger
* In the debugger options, ensure that "Show Original Sources" is enabled
* see [MDN: Use a source map](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map)
* In the debugger you should now be able to view and debug the individual JavaScript files as though they were included separately
### Dependencies ###
* [node.js](http://nodejs.org/)
* [grunt-cli](http://gruntjs.com/)
All other development dependencies will be installed by running the following from the project root:
```bash
npm install
```
### Package Types ###
#### Infusion All Build ####
Will include all of Infusion. The source files packaged along with the single concatenated js file will include all of the demos and unit tests. This is a good choice if you are trying to learn Infusion.
```bash
grunt
```
##### Custom Build #####
Will only include the modules you request, and all of their dependencies, minus any that are explicitly excluded. Unlike the "all" build, none of the demos or tests are included with a custom package.
```bash
grunt custom
```
### Build Options ###
#### --source ####
__value__: true (Boolean)
_the value can be omitted if --source is the last flag specified_
By default all packages are minified. This option will allow you to maintain the readable spacing and comments.
```bash
grunt --source=true
grunt custom --source=true
```
#### --include ####
__value__: "module(s)" (String)
_only available to custom packages_
The `--include` option takes in a comma-separated string of the [Modules](#modules) to be included in a custom package. If omitted, all modules will be included (demos and tests will not be included).
```bash
grunt custom --include="inlineEdit, uiOptions"
```
#### --exclude ####
__value__: "module(s)" (String)
_only available to custom packages_
The exclude option takes in a comma-separated string of the [Modules](#modules) to be excluded from a custom package. The `--exclude` option takes priority over `--include`.
```bash
grunt custom --exclude="jQuery"
grunt custom --include="framework" --exclude="jQuery"
```
#### --name ####
__value__: "custom suffix" (String)
_only available to custom packages_
By default, custom packages are given a name with the form _infusion-custom-<version>.zip_ and the concatenated js file is called _infusion-custom.js_. By supplying the `--name` option, you can replace "custom" with any other valid string you like.
```bash
# this produces infusion-myPackage.js
grunt custom --name="myPackage"
```
### Modules ###
#### Framework Modules ####
* enhancement
* framework
* preferences
* renderer
#### Component Modules ####
* inlineEdit
* overviewPanel
* pager
* progress
* reorderer
* slidingPanel
* tableOfContents
* tabs
* textfieldSlider
* textToSpeech
* tooltip
* uiOptions
* undo
* uploader
#### External Libraries ####
* fastXmlPull
* jQuery
* jQueryUI
* jQueryScrollToPlugin
* jQueryTouchPunchPlugin
* normalize
All of these libraries are already bundled within the Infusion image.
## How Do I Run Tests? ##
There are two options available for running tests. The first option involves using browsers installed on your computer and the second uses browsers available in a VM.
### Run Tests Using Browsers Installed On Your Computer ###
Using this option requires the installation of [Testem](https://github.com/testem/testem/#installation) and then running ``testem ci --file tests/testem.json`` in this directory. Any browsers that Testem finds on your platform will be launched sequentially with each browser running the full Infusion test suite. The results will be returned in your terminal in the [TAP](https://testanything.org/) format. You can use the ``testem launchers`` command to get a list of available browsers.
**Note:** Any browser launched will need to be focused and remain the active window. Some of the tests require focus, and will report errors if they are not focused.
### Run Tests Using Browsers Installed In a VM ###
A [Fedora VM](https://github.com/idi-ops/packer-fedora) can be automatically created using tools provided by the [Prosperity4All Quality Infrastructure](https://github.com/GPII/qi-development-environments/). After meeting the [QI development VM requirements](https://github.com/GPII/qi-development-environments/#requirements) the ``vagrant up`` command can be used to launch a VM which will contain Testem and several browsers. Typing ``grunt tests`` will run the Infusion tests in the VM and the results will be displayed in your terminal.
When this VM is first created Chrome and Firefox will be upgraded to the latest versions available in the Fedora and Google package repositories. The ``vagrant provision`` command can be used at a later time to trigger the browser upgrade and general VM provisioning mechanism.
The benefits of using a VM include the following:
* Does not require testem to be installed on the host machine
* Allows other applications on the host machine to have focus while the tests are run
## Developing with the Preferences Framework ##
Infusion is in the process of switching to use [Stylus](http://learnboost.github.io/stylus/) for CSS pre-processing.
CSS files for the Preferences Framework have been re-written in Stylus. Only Stylus files are pushed into the github repository.
For developing the Preferences Framework, run the following from the project root to compile Stylus files to CSS:
```bash
grunt buildStylus
```
A `watch` task using [grunt-contrib-watch](https://github.com/gruntjs/grunt-contrib-watch) is also supplied to ease Stylus development. This task launches a process that watches all Stylus files in the `src` directory and recompiles them when they are changed. This task can be run using the following command:
```bash
grunt watch:buildStylus
```

344
lib/infusion/ReleaseNotes.md

@ -0,0 +1,344 @@
# Release Notes for Fluid Infusion 2.0.0 #
[Fluid Project](http://fluidproject.org)
[Infusion Documentation](https://github.com/fluid-project/infusion-docs)
## What's New in 2.0.0? ##
See [API Changes from 1.5 to 2.0](http://docs.fluidproject.org/infusion/development/APIChangesFrom1_5To2_0.html) and [Deprecations in 1.5](http://docs.fluidproject.org/infusion/development/DeprecationsIn1_5.html) on the [Infusion Documentation](https://github.com/fluid-project/infusion-docs) site.
For a complete list of Fixes and Improvements see the [Version 2.0](https://issues.fluidproject.org/projects/FLUID/versions/10041) summary in the [JIRA](https://issues.fluidproject.org) issue tracker.
**Note:** Infusion 1.9 was not officially released, but is available as an official branch. It is is available on GitHub at [Infusion 1.9.x](https://github.com/fluid-project/infusion/tree/1.9.x). For a complete list of Fixes and Improvements see the [Version 1.9](https://issues.fluidproject.org/projects/FLUID/versions/10520) summary in the [JIRA](https://issues.fluidproject.org) issue tracker.
### New Features ###
* Constraint-based priorities, supported by `listeners`, `modelListeners`, `modelRelay`, `distributeOptions`, `contextAwareness`, and `components`. This allows the specific order of those items to be configured. (See: [Priorities](http://docs.fluidproject.org/infusion/development/Priorities.html))
* Context Awareness - and things it relies on:
* Global Instantiator
* Every Infusion component, regardless of how it is instantiated, ends up in a single-rooted tree of components
* This enables use of modern IoC features such as model relay and declarative event binding
* Enables use of the root distributeOptions context "/"
* Enables the removal of "demands blocks"
* Useful debugging tip: Watch `fluid.globalInstantiator` in your JS debugging tools to see the structure of your application and its tree.
* `fluid.notImplemented` function for implementing abstract grades
* [Lazy loading for UI Options](http://docs.fluidproject.org/infusion/development/UserInterfaceOptionsAPI.html#lazyload) and instructions for how to use the Preferences Framework with a [zero initial load time](http://docs.fluidproject.org/infusion/development/tutorial-prefsFrameworkMinimalFootprint/MinimalFootprint.html).
* This should assist in improving performance when using the Preferences Framework, particularly for resource intensive sites and applications
* Much faster invokers and boiled listeners (c. 60x faster)
* Support for using Infusion with npm for both Node.js and web-based projects.
* Provides a variety of prebuilt versions of Infusion in the module's `dist` directory.
* Source Maps are generated for the concatenated JavaScript files
* View oriented IoC debugging tools
* Including FluidViewDebugging.js on the page of any Infusion application gives you access to the _IoC View Inspector_. Click on the small cogwheel icon at the bottom right of the page to open a panel which shows the details of the view components and their grades, that are attached to DOM nodes in the browser pane. This interface works similarly to the _DOM Inspector_ familiar from modern web browsers, but is an experimental implementation with an engineer-level UI.
### Removal of Deprecated Features ###
* Manual lifecycle points finalInit, postInit, etc.
* Obsolete syntax for arguments, options, etc.
* `"autoInit"` grade
* Static and dynamic environments, replaced by Global Instantiator
* The old model component hierarchy and "old ChangeApplier" implementation
* `fluid.demands`
* No more distinction between fast and dynamic invokers
* Model Relay specific component grades have been removed, model relay now works with any model grade.
## Obtaining Infusion ##
* [Fork on GitHub](https://github.com/fluid-project/infusion)
* [Download a Build](https://github.com/fluid-project/infusion/releases)
* [NPM](https://www.npmjs.com/package/infusion)
You can create your own custom build of Infusion using the [grunt build script](README.md#how-do-i-create-an-infusion-package).
## Demos ##
Infusion ships with demos of all of the components in action. You can find them in the _**demos**_ folder in the release bundle or on our [build site](http://build.fluidproject.org/).
When running the demos on your local machine, a web server is recommended. Several of the demos make use of AJAX calls; which typically are not allowed by
the browser when run from the local file system.
## License ##
Fluid Infusion is licensed under both the ECL 2.0 and new BSD licenses.
More information is available in our [wiki](http://wiki.fluidproject.org/display/fluid/Fluid+Licensing).
## Third Party Software in Infusion ##
This is a list of publicly available software that is redistributed with Fluid Infusion,
categorized by license:
### Apache 2.0 ###
* [`fluid.load.scripts` is based on Jake Archibald's script loading example](http://www.html5rocks.com/en/tutorials/speed/script-loading/#toc-dom-rescue)
* [Open Sans Light font](http://www.google.com/fonts/specimen/Open+Sans)
### MIT License ###
* [Buzz v1.1.0](http://buzz.jaysalvat.com)
* [Foundation v6.2.3](http://foundation.zurb.com/index.html)
* [HTML5 Boilerplate v4.3](http://html5boilerplate.com/)
* [html5shiv v3.7.2](https://code.google.com/p/html5shiv/)
* [jQuery v3.1.0](http://jquery.com/)
* [jQuery Mockjax v2.2.1](https://github.com/jakerella/jquery-mockjax)
* [jQuery QUnit v1.12.0](http://qunitjs.com)
* [jQuery QUnit Composite v1.0.1](https://github.com/jquery/qunit-composite)
* [jQuery scrollTo v1.4.2](http://flesler.blogspot.com/2007/10/jqueryscrollto.html)
* [jQuery Touch Punch v0.2.2](http://touchpunch.furf.com/)
* [jQuery UI (Core; Interactions: draggable, resizable; Widgets: button, checkboxradio, controlgroup, dialog, mouse, slider, tabs, and tooltip) v1.12.1](http://ui.jquery.com/)
* [jquery.selectbox v0.5 (forked)](https://github.com/fluid-project/jquery.selectbox)
* [jquery.simulate](https://github.com/eduardolundgren/jquery-simulate)
* [Micro Clearfix](http://nicolasgallagher.com/micro-clearfix-hack/)
* [Normalize v4.1.1](https://necolas.github.io/normalize.css/)
### zlib/libpng License ###
* [fastXmlPull is based on XML for Script's Fast Pull Parser v3.1](http://wiki.fluidproject.org/display/fluid/Licensing+for+fastXmlPull.js)
## Documentation ##
Documentation and tutorials can found on the [Infusion Documentation](http://docs.fluidproject.org/infusion/development/) site.
## Supported Browsers ##
Infusion 2.0 was tested with the following browsers:
* Chrome current (version 54)
* Firefox current (versions 49-50)
* Internet Explorer (version 11)
* Microsoft Edge (version 38)
* Safari (version 10)
Additional testing for mobile devices was performed with the following:
* Chrome (Android 6.0.1)
* Safari (iOS 10.1.1)
For more information see the [Fluid Infusion browser support](https://wiki.fluidproject.org/display/fluid/Prior+Browser+Support) wiki page.
### Testing Configurations ####
<table>
<summary>Testing Configurations</summary>
<thead>
<tr>
<th rowspan="2">Testing Task</th>
<th colspan="5">Desktop Browser</th>
<th colspan="2">Mobile Browser</th>
</tr>
<tr>
<th>Chrome</th>
<th>Firefox</th>
<th>IE 11</th>
<th>MS Edge</th>
<th>Safari</th>
<th>Chrome for Android</th>
<th>Safari iOS</th>
</tr>
</thead>
<tbody>
<tr>
<th>Run All Unit Tests</th>
<td>Chrome 54 (macOS 10.12)</td>
<td>Firefox 49 (macOS 10.12)</td>
<td>IE 11 (Win 10)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>Chrome 54 (Android 6.0.1 & 7.0.0)</td>
<td>Safari (iOS 10.1.1)</td>
</tr>
<tr>
<th>Smoke Tests - All Manual Tests</th>
<td>Chrome 54 (macOS 10.11.6)</td>
<td>Firefox 50 (macOS 10.12.1)</td>
<td>IE 11 (Win 8.1)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12.1)</td>
<td>Chrome 54 (Android 6.0.1)</td>
<td>Safari (iOS 10.1.1)</td>
</tr>
<tr>
<th>Smoke Tests - All Demos</th>
<td>Chrome 54 (macOS 10.12.1)</td>
<td>Firefox 50 (macOS 10.12.1)</td>
<td>IE 11 (Win 8.1)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12.1)</td>
<td>Chrome 54 (Android 6.0.1)</td>
<td>Safari (iOS 10.1.1)</td>
</tr>
<tr>
<th>Smoke Tests - All Examples</th>
<td>Chrome 54 (macOS 10.12.1)</td>
<td>Firefox 50 (macOS 10.12.1)</td>
<td>IE 11 (Win 8.1)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12.1)</td>
<td>Chrome 54 (Android 6.0.1)</td>
<td>Safari (iOS 10.1.1)</td>
</tr>
<tr>
<th>Inline Edit QA Test Plan - Simple Text</th>
<td>Chrome 54 (macOS 10.10)</td>
<td>Firefox 49 (openSUSE Linux 42.1)</td>
<td>IE 11 (Win 8.1)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>Keyboard Accessibility QA Test Plan</th>
<td>Chrome 54 (Win 10)</td>
<td>Firefox 49.0.2 (macOS 10.12)</td>
<td>IE 11 (Win 8.1)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>Pager QA Test Plan</th>
<td>Chrome 54 (Win 10)</td>
<td>Firefox 49.0.2 (macOS 10.12)</td>
<td>IE 11 (Win 7)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>Progress QA Test Plan</th>
<td>Chrome 54 (macOS 10.11.6)</td>
<td>Firefox 49.0.2 (macOS 10.12)</td>
<td>IE 11 (Win 7)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>Reorderer QA Test Plan - Image Reorderer</th>
<td>Chrome 54 (Win 10)</td>
<td>Firefox 49.0.2 (macOS 10.12)</td>
<td>IE 11 (Win 7)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>Reorderer QA Test Plan - Layout Reorderer</th>
<td>Chrome 54 (macOS 10.11.6)</td>
<td>Firefox 49.0.2 (macOS 10.12)</td>
<td>IE 11 (Win 7)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>Reorderer QA Test Plan - List Reorderer</th>
<td>Chrome 54 (macOS 10.11.6)</td>
<td>Firefox 49.0.2 (macOS 10.12)</td>
<td>IE 11 (Win 7)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>Reorderer QA Test Plan - Grid Reorderer</th>
<td>Chrome 54 (macOS 10.11.6)</td>
<td>Firefox 49.0.2 (macOS 10.12)</td>
<td>IE 11 (Win 7)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>Preferences Framework QA Test Plan</th>
<td>Chrome 54 (Win 10)</td>
<td>Firefox 49.0.2 (macOS 10.12)</td>
<td>IE 11 (Win 7)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>UI Options QA Test Plan - Separated Panel</th>
<td>Chrome 54 (Win 10)</td>
<td>Firefox 49.0.2 (Win 10)</td>
<td>IE 11 (Win 7)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>Uploader QA Test Plan</th>
<td>Chrome 54 (macOS 10.12.1)</td>
<td>Firefox 49.0.2 (macOS 10.12.1)</td>
<td>IE 11 (Win 10)</td>
<td>MS Edge 38 (Win 10)</td>
<td>Safari 10 (macOS 10.12.1)</td>
<td>N/A</td>
<td>N/A</td>
</tr>
</tbody>
</table>
## Known Issues ##
The Fluid Project uses a [JIRA](http://issues.fluidproject.org) website to track bugs. Some of the known issues in this release are described here:
### Framework ###
* [FLUID-5912: "{arguments}" IoC references in dynamicComponents model block are incorrectly interpreted as implicit model relays](https://issues.fluidproject.org/browse/FLUID-5912)
* [FLUID-5546: Framework fails to deregister listeners to events which are injected from other components](https://issues.fluidproject.org/browse/FLUID-5546)
* [FLUID-5519: Timing of "initial transaction" in new model relay system is problematic](https://issues.fluidproject.org/browse/FLUID-5519)
### Inline Edit ###
* [FLUID-5392: Two clicks required to edit an empty inline edit field](https://issues.fluidproject.org/browse/FLUID-5392)
* [FLUID-1600: Pressing the "Tab" key to exit edit mode places focus on the wrong item](http://issues.fluidproject.org/browse/FLUID-1600)
### Layout Reorderer ###
* [FLUID-3864: Layout Reorderer failed to move portlets back to the first column in three-columns view with keyboard](http://issues.fluidproject.org/browse/FLUID-3864)
* [FLUID-3089: If columns become stacked, can't drag item into lower column](http://issues.fluidproject.org/browse/FLUID-3089)
### Pager ###
[FLUID-6081: VoiceOver on Pager doesn't announce the page number when the focus is on a page link](https://issues.fluidproject.org/browse/FLUID-6081)
### Reorderer ###
* [FLUID-6013: The Grid Reorderer and Image Reorderer are missing ARIA role=row containers](https://issues.fluidproject.org/browse/FLUID-6013)
* [FLUID-5870: Reorderer demo failures on IE 11](https://issues.fluidproject.org/browse/FLUID-5870)
* [FLUID-44737: Focus styling persists after moving focus from Reorderer](https://issues.fluidproject.org/browse/FLUID-4437)
* [FLUID-3925: With no wrapping on, the keyboard movement keystrokes are captured by the browser where a wrap would have occurred.](http://issues.fluidproject.org/browse/FLUID-3925)
### UI Options / Preferences Framework ###
* [FLUID-5928: Schema and Grade version save preferences to different values](https://issues.fluidproject.org/browse/FLUID-5928)
* [FLUID-5372: Increasing font size does not increase width of UIO panel](https://issues.fluidproject.org/browse/FLUID-5372)
* [FLUID-5223: If there's exactly one text field in the prefs editor, pressing enter on most inputs causes the form to submit](http://issues.fluidproject.org/browse/FLUID-5223)
* [FLUID-5218: Prefs editor requires iFrame template to be in the same place as panel templates; it probably shouldn't](http://issues.fluidproject.org/browse/FLUID-5218)
* [FLUID-5066: UIO Integrators shouldn't have to edit Infusion's copy of html templates to add panels, css](http://issues.fluidproject.org/browse/FLUID-5066)
* [FLUID-4491: Line spacing doesn't affect elements that have a line-height style set](http://issues.fluidproject.org/browse/FLUID-4491)
* [FLUID-4394: Separated Panel UI Options' iFrame HTML page (SeparatedPanelFrame.html) doesn't play nice with a concatenated build of Infusion](http://issues.fluidproject.org/browse/FLUID-4394)
### Undo ###
* [FLUID-3697: Undo hard-codes selector classes instead of using user-configured values](http://issues.fluidproject.org/browse/FLUID-3697)
### Uploader ###
* [FLUID-6079: Uploader error, when chosen files are too large, is not read by screenreader](https://issues.fluidproject.org/browse/FLUID-6079)
* [FLUID-6065: The focus remains on the "Browse Files" button with 2 keyboard tabbings in IE 11 and IE Edge](https://issues.fluidproject.org/browse/FLUID-6065)
* [FLUID-6045: The table header scrolls out of view as the file queue is scrolled](https://issues.fluidproject.org/browse/FLUID-6045)
* [FLUID-5737: Uploading size is higher than total size](https://issues.fluidproject.org/browse/FLUID-5737)
* [FLUID-4726: Cannot change uploader's button text through the string options.](https://issues.fluidproject.org/browse/FLUID-4726)

30
lib/infusion/infusion-uiOptions.js

File diff suppressed because one or more lines are too long

1
lib/infusion/infusion-uiOptions.js.map

File diff suppressed because one or more lines are too long

171
lib/infusion/src/components/slidingPanel/js/SlidingPanel.js

@ -0,0 +1,171 @@
/*
Copyright 2011-2015 OCAD University
Copyright 2011 Lucendo Development Ltd.
Copyright 2016 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
/**********************
* Sliding Panel *
*********************/
fluid.defaults("fluid.slidingPanel", {
gradeNames: ["fluid.viewComponent"],
selectors: {
panel: ".flc-slidingPanel-panel",
toggleButton: ".flc-slidingPanel-toggleButton",
toggleButtonLabel: ".flc-slidingPanel-toggleButton"
},
strings: {
showText: "show",
hideText: "hide",
panelLabel: "panel"
},
events: {
onPanelHide: null,
onPanelShow: null,
afterPanelHide: null,
afterPanelShow: null
},
listeners: {
"onCreate.bindClick": {
"this": "{that}.dom.toggleButton",
"method": "click",
"args": ["{that}.togglePanel"]
},
"onCreate.bindModelChange": {
listener: "{that}.applier.modelChanged.addListener",
args: ["isShowing", "{that}.refreshView"]
},
"onCreate.setAriaProps": "{that}.setAriaProps",
"onCreate.setInitialState": {
listener: "{that}.refreshView"
},
"onPanelHide.setText": {
"this": "{that}.dom.toggleButtonLabel",
"method": "text",
"args": ["{that}.options.strings.showText"],
"priority": "first"
},
"onPanelHide.setAriaLabel": {
"this": "{that}.dom.toggleButtonLabel",
"method": "attr",
"args": ["aria-label", "{that}.options.strings.showTextAriaLabel"]
},
"onPanelShow.setText": {
"this": "{that}.dom.toggleButtonLabel",
"method": "text",
"args": ["{that}.options.strings.hideText"],
"priority": "first"
},
"onPanelShow.setAriaLabel": {
"this": "{that}.dom.toggleButtonLabel",
"method": "attr",
"args": ["aria-label", "{that}.options.strings.hideTextAriaLabel"]
},
"onPanelHide.operate": {
listener: "{that}.operateHide"
},
"onPanelShow.operate": {
listener: "{that}.operateShow"
},
"onCreate.setAriaStates": "{that}.setAriaStates"
},
members: {
panelId: {
expander: {
// create an id for panel
// and set that.panelId to the id value
funcName: "fluid.allocateSimpleId",
args: "{that}.dom.panel"
}
}
},
model: {
isShowing: false
},
modelListeners: {
"isShowing": {
funcName: "{that}.setAriaStates",
excludeSource: "init"
}
},
invokers: {
operateHide: {
"this": "{that}.dom.panel",
"method": "slideUp",
"args": ["{that}.options.animationDurations.hide", "{that}.events.afterPanelHide.fire"]
},
operateShow: {
"this": "{that}.dom.panel",
"method": "slideDown",
"args": ["{that}.options.animationDurations.show", "{that}.events.afterPanelShow.fire"]
},
hidePanel: {
func: "{that}.applier.change",
args: ["isShowing", false]
},
showPanel: {
func: "{that}.applier.change",
args: ["isShowing", true]
},
setAriaStates: {
funcName: "fluid.slidingPanel.setAriaStates",
args: ["{that}", "{that}.model.isShowing"]
},
setAriaProps: {
funcName: "fluid.slidingPanel.setAriaProperties",
args: ["{that}", "{that}.panelId"]
},
togglePanel: {
funcName: "fluid.slidingPanel.togglePanel",
args: ["{that}"]
},
refreshView: {
funcName: "fluid.slidingPanel.refreshView",
args: ["{that}"]
}
},
animationDurations: {
hide: 400,
show: 400
}
});
fluid.slidingPanel.togglePanel = function (that) {
that.applier.change("isShowing", !that.model.isShowing);
};
fluid.slidingPanel.refreshView = function (that) {
that.events[that.model.isShowing ? "onPanelShow" : "onPanelHide"].fire();
};
// panelId is passed in to ensure that it is evaluated before this
// function is called.
fluid.slidingPanel.setAriaProperties = function (that, panelId) {
that.locate("toggleButton").attr({
"role": "button",
"aria-controls": panelId
});
that.locate("panel").attr({
"aria-label": that.options.strings.panelLabel,
"role": "group"
});
};
fluid.slidingPanel.setAriaStates = function (that, isShowing) {
that.locate("toggleButton").attr("aria-pressed", isShowing);
that.locate("panel").attr("aria-expanded", isShowing);
};
})(jQuery, fluid_2_0_0);

16
lib/infusion/src/components/slidingPanel/slidingPanelDependencies.json

@ -0,0 +1,16 @@
{
"slidingPanel": {
"name": "Sliding Panel",
"description": "A widget that slides a panel in and out of view.",
"cssFiles": [],
"files": [
"./js/SlidingPanel.js"
],
"dependencies": [
"jQuery",
"jQueryUI",
"normalize",
"framework"
]
}
}

3
lib/infusion/src/components/tableOfContents/css/TableOfContents.css

@ -0,0 +1,3 @@
.fl-tableOfContents-hide-bullet {
list-style-type: none;
}

32
lib/infusion/src/components/tableOfContents/html/TableOfContents.html

@ -0,0 +1,32 @@
<!-- Table of contents template -->
<h2 class="flc-toc-header">Table of Contents Header</h2>
<ul class="flc-toc-levels-level1">
<li class="flc-toc-levels-items1">
<a class="flc-toc-levels-link1" href="">1</a>
<ul class="flc-toc-levels-level2">
<li class="flc-toc-levels-items2">
<a class="flc-toc-levels-link2" href="">2</a>
<ul class="flc-toc-levels-level3">
<li class="flc-toc-levels-items3">
<a class="flc-toc-levels-link3" href="">3</a>
<ul class="flc-toc-levels-level4">
<li class="flc-toc-levels-items4">
<a class="flc-toc-levels-link4" href="">4</a>
<ul class="flc-toc-levels-level5">
<li class="flc-toc-levels-items5">
<a class="flc-toc-levels-link5" href="">5</a>
<ul class="flc-toc-levels-level6">
<li class="flc-toc-levels-items6">
<a class="flc-toc-levels-link6" href="">6</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

377
lib/infusion/src/components/tableOfContents/js/TableOfContents.js

@ -0,0 +1,377 @@
/*
Copyright 2011-2016 OCAD University
Copyright 2011 Lucendo Development Ltd.
Copyright 2012 Raising the Floor - US
Copyright 2015-2016 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
/******
* ToC *
*******/
fluid.registerNamespace("fluid.tableOfContents");
fluid.tableOfContents.headingTextToAnchorInfo = function (heading) {
var id = fluid.allocateSimpleId(heading);
var anchorInfo = {
id: id,
url: "#" + id
};
return anchorInfo;
};
fluid.tableOfContents.locateHeadings = function (that) {
var headings = that.locate("headings");
fluid.each(that.options.ignoreForToC, function (sel) {
headings = headings.not(sel).not(sel + " :header");
});
return headings;
};
fluid.tableOfContents.refreshView = function (that) {
var headings = that.locateHeadings();
that.anchorInfo = fluid.transform(headings, function (heading) {
return that.headingTextToAnchorInfo(heading);
});
var headingsModel = that.modelBuilder.assembleModel(headings, that.anchorInfo);
that.applier.change("", headingsModel);
that.events.onRefresh.fire();
};
fluid.defaults("fluid.tableOfContents", {
gradeNames: ["fluid.viewComponent"],
components: {
levels: {
type: "fluid.tableOfContents.levels",
createOnEvent: "onCreate",
container: "{tableOfContents}.dom.tocContainer",
options: {
model: {
headings: "{tableOfContents}.model"
},
events: {
afterRender: "{tableOfContents}.events.afterRender"
},
listeners: {
"{tableOfContents}.events.onRefresh": "{that}.refreshView"
},
strings: "{tableOfContents}.options.strings"
}
},
modelBuilder: {
type: "fluid.tableOfContents.modelBuilder"
}
},
model: [],
invokers: {
headingTextToAnchorInfo: "fluid.tableOfContents.headingTextToAnchorInfo",
locateHeadings: {
funcName: "fluid.tableOfContents.locateHeadings",
args: ["{that}"]
},
refreshView: {
funcName: "fluid.tableOfContents.refreshView",
args: ["{that}"]
},
// TODO: is it weird to have hide and show on a component?
hide: {
"this": "{that}.dom.tocContainer",
"method": "hide"
},
show: {
"this": "{that}.dom.tocContainer",
"method": "show"
}
},
strings: {
tocHeader: "Table of Contents"
},
selectors: {
headings: ":header:visible",
tocContainer: ".flc-toc-tocContainer"
},
ignoreForToC: {
tocContainer: "{that}.options.selectors.tocContainer"
},
events: {
onRefresh: null,
afterRender: null,
onReady: {
events: {
"onCreate": "onCreate",
"afterRender": "afterRender"
},
args: ["{that}"]
}
},
listeners: {
"onCreate.refreshView": "{that}.refreshView"
}
});
/*******************
* ToC ModelBuilder *
********************/
fluid.registerNamespace("fluid.tableOfContents.modelBuilder");
fluid.tableOfContents.modelBuilder.toModel = function (headingInfo, modelLevelFn) {
var headings = fluid.copy(headingInfo);
var buildModelLevel = function (headings, level) {
var modelLevel = [];
while (headings.length > 0) {
var heading = headings[0];
if (heading.level < level) {
break;
}
if (heading.level > level) {
var subHeadings = buildModelLevel(headings, level + 1);
if (modelLevel.length > 0) {
modelLevel[modelLevel.length - 1].headings = subHeadings;
} else {
modelLevel = modelLevelFn(modelLevel, subHeadings);
}
}
if (heading.level === level) {
modelLevel.push(heading);
headings.shift();
}
}
return modelLevel;
};
return buildModelLevel(headings, 1);
};
fluid.tableOfContents.modelBuilder.gradualModelLevelFn = function (modelLevel, subHeadings) {
// Clone the subHeadings because we don't want to modify the reference of the subHeadings.
// the reference will affect the equality condition in generateTree(), resulting an unwanted tree.
var subHeadingsClone = fluid.copy(subHeadings);
subHeadingsClone[0].level--;
return subHeadingsClone;
};
fluid.tableOfContents.modelBuilder.skippedModelLevelFn = function (modelLevel, subHeadings) {
modelLevel.push({headings: subHeadings});
return modelLevel;
};
fluid.tableOfContents.modelBuilder.convertToHeadingObjects = function (that, headings, anchorInfo) {
headings = $(headings);
return fluid.transform(headings, function (heading, index) {
return {
level: that.headingCalculator.getHeadingLevel(heading),
text: $(heading).text(),
url: anchorInfo[index].url
};
});
};
fluid.tableOfContents.modelBuilder.assembleModel = function (that, headings, anchorInfo) {
var headingInfo = that.convertToHeadingObjects(headings, anchorInfo);
return that.toModel(headingInfo);
};
fluid.defaults("fluid.tableOfContents.modelBuilder", {
gradeNames: ["fluid.component"],
components: {
headingCalculator: {
type: "fluid.tableOfContents.modelBuilder.headingCalculator"
}
},
invokers: {
toModel: {
funcName: "fluid.tableOfContents.modelBuilder.toModel",
args: ["{arguments}.0", "{modelBuilder}.modelLevelFn"]
},
modelLevelFn: "fluid.tableOfContents.modelBuilder.gradualModelLevelFn",
convertToHeadingObjects: "fluid.tableOfContents.modelBuilder.convertToHeadingObjects({that}, {arguments}.0, {arguments}.1)", // headings, anchorInfo
assembleModel: "fluid.tableOfContents.modelBuilder.assembleModel({that}, {arguments}.0, {arguments}.1)" // headings, anchorInfo
}
});
/*************************************
* ToC ModelBuilder headingCalculator *
**************************************/
fluid.registerNamespace("fluid.tableOfContents.modelBuilder.headingCalculator");
fluid.tableOfContents.modelBuilder.headingCalculator.getHeadingLevel = function (that, heading) {
return that.options.levels.indexOf(heading.tagName) + 1;
};
fluid.defaults("fluid.tableOfContents.modelBuilder.headingCalculator", {
gradeNames: ["fluid.component"],
invokers: {
getHeadingLevel: "fluid.tableOfContents.modelBuilder.headingCalculator.getHeadingLevel({that}, {arguments}.0)" // heading
},
levels: ["H1", "H2", "H3", "H4", "H5", "H6"]
});
/*************
* ToC Levels *
**************/
fluid.registerNamespace("fluid.tableOfContents.levels");
/**
* Create an object model based on the type and ID. The object should contain an
* ID that maps the selectors (ie. level1:), and the object should contain a children
* @param string Accepted values are: level, items
* @param int The current level which is used here as the ID.
*/
fluid.tableOfContents.levels.objModel = function (type, ID) {
var objModel = {
ID: type + ID + ":",
children: []
};
return objModel;
};
/**
* Configure item object when item object has no text, uri, level in it.
* defaults to add a decorator to hide the bullets.
*/
fluid.tableOfContents.levels.handleEmptyItemObj = function (itemObj) {
itemObj.decorators = [{
type: "addClass",
classes: "fl-tableOfContents-hide-bullet"
}];
};
/**
* @param Object that.model, the model with all the headings, it should be in the format of {headings: [...]}
* @param int the current level we want to generate the tree for. default to 1 if not defined.
* @return Object A tree that looks like {children: [{ID: x, subTree:[...]}, ...]}
*/
fluid.tableOfContents.levels.generateTree = function (headingsModel, currentLevel) {
currentLevel = currentLevel || 0;
var levelObj = fluid.tableOfContents.levels.objModel("level", currentLevel);
// FLUID-4352, run generateTree if there are headings in the model.
if (headingsModel.headings.length === 0) {
return currentLevel ? [] : {children: []};
}
// base case: level is 0, returns {children:[generateTree(nextLevel)]}
// purpose is to wrap the first level with a children object.
if (currentLevel === 0) {
var tree = {
children: [
fluid.tableOfContents.levels.generateTree(headingsModel, currentLevel + 1)
]
};
return tree;
}
// Loop through the heading array, which can have multiple headings on the same level
$.each(headingsModel.headings, function (index, model) {
var itemObj = fluid.tableOfContents.levels.objModel("items", currentLevel);
var linkObj = {
ID: "link" + currentLevel,
target: model.url,
linktext: model.text
};
// If level is undefined, then add decorator to it, otherwise add the links to it.
if (!model.level) {
fluid.tableOfContents.levels.handleEmptyItemObj(itemObj);
} else {
itemObj.children.push(linkObj);
}
// If there are sub-headings, go into the next level recursively
if (model.headings) {
itemObj.children.push(fluid.tableOfContents.levels.generateTree(model, currentLevel + 1));
}
// At this point, the itemObj should be in a tree format with sub-headings children
levelObj.children.push(itemObj);
});
return levelObj;
};
/**
* @return Object Returned produceTree must be in {headings: [trees]}
*/
fluid.tableOfContents.levels.produceTree = function (that) {
var tree = fluid.tableOfContents.levels.generateTree(that.model);
// Add the header to the tree
tree.children.push({
ID: "tocHeader",
messagekey: "tocHeader"
});
return tree;
};
fluid.tableOfContents.levels.fetchResources = function (that) {
fluid.fetchResources(that.options.resources, function () {
that.container.append(that.options.resources.template.resourceText);
that.refreshView();
});
};
fluid.defaults("fluid.tableOfContents.levels", {
gradeNames: ["fluid.rendererComponent"],
produceTree: "fluid.tableOfContents.levels.produceTree",
strings: {
tocHeader: "Table of Contents"
},
selectors: {
tocHeader: ".flc-toc-header",
level1: ".flc-toc-levels-level1",
level2: ".flc-toc-levels-level2",
level3: ".flc-toc-levels-level3",
level4: ".flc-toc-levels-level4",
level5: ".flc-toc-levels-level5",
level6: ".flc-toc-levels-level6",
items1: ".flc-toc-levels-items1",
items2: ".flc-toc-levels-items2",
items3: ".flc-toc-levels-items3",
items4: ".flc-toc-levels-items4",
items5: ".flc-toc-levels-items5",
items6: ".flc-toc-levels-items6",
link1: ".flc-toc-levels-link1",
link2: ".flc-toc-levels-link2",
link3: ".flc-toc-levels-link3",
link4: ".flc-toc-levels-link4",
link5: ".flc-toc-levels-link5",
link6: ".flc-toc-levels-link6"
},
repeatingSelectors: ["level1", "level2", "level3", "level4", "level5", "level6", "items1", "items2", "items3", "items4", "items5", "items6"],
model: {
headings: [] // [text: heading, url: linkURL, headings: [ an array of subheadings in the same format]
},
listeners: {
"onCreate.fetchResources": "fluid.tableOfContents.levels.fetchResources"
},
resources: {
template: {
forceCache: true,
url: "../html/TableOfContents.html"
}
},
rendererFnOptions: {
noexpand: true
},
rendererOptions: {
debugMode: false
}
});
})(jQuery, fluid_2_0_0);

15
lib/infusion/src/components/tableOfContents/tableOfContentsDependencies.json

@ -0,0 +1,15 @@
{
"tableOfContents": {
"name": "Table of Contents",
"description": "Present an automatic table of contents from any HTML page.",
"files": [
"./js/TableOfContents.js"
],
"dependencies": [
"jQuery",
"normalize",
"framework",
"renderer"
]
}
}

113
lib/infusion/src/components/textToSpeech/js/MockTTS.js

@ -0,0 +1,113 @@
/*
Copyright 2015 OCAD University
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
/* global fluid */
(function () {
"use strict";
// Mocks the fluid.textToSpeech component, removing calls to the
// Web Speech API. This will allow for tests to run in browsers
// that don't support the Web Speech API.
fluid.defaults("fluid.mock.textToSpeech", {
gradeNames: ["fluid.textToSpeech"],
members: {
// An archive of all the calls to queueSpeech.
// Will contain an ordered set of objects -- {text: String, options: Object}.
speechRecord: [],
// An archive of all the events fired
// Will contain a key/value pairing where key is the name of the event and the
// value is the number of times the event was fired.
eventRecord: {}
},
listeners: {
"onStart.recordEvent": {
listener: "{that}.recordEvent",
args: ["onStart"]
},
"onStop.recordEvent": {
listener: "{that}.recordEvent",
args: ["onStop"]
},
"onSpeechQueued.recordEvent": {
listener: "{that}.recordEvent",
args: ["onSpeechQueued"]
}
},
invokers: {
queueSpeech: {
funcName: "fluid.mock.textToSpeech.queueSpeech",
args: ["{that}", "{that}.handleStart", "{that}.handleEnd", "{that}.speechRecord", "{arguments}.0", "{arguments}.1", "{arguments}.2"]
},
cancel: {
funcName: "fluid.mock.textToSpeech.cancel",
args: ["{that}", "{that}.handleEnd"]
},
pause: {
"this": null, // TODO: This needs to be removed once FLUID-5714 is fixed
method: null,
func: "{that}.events.onPause.fire"
},
resume: {
"this": null,
method: null,
func: "{that}.events.onResume.fire"
},
getVoices: {
"this": null,
method: null,
funcName: "fluid.identity",
args: []
},
recordEvent: {
funcName: "fluid.mock.textToSpeech.recordEvent",
args: ["{that}.eventRecord", "{arguments}.0"]
}
}
});
fluid.mock.textToSpeech.queueSpeech = function (that, handleStart, handleEnd, speechRecord, text, interrupt, options) {
if (interrupt) {
that.cancel();
}
var record = {
text: text,
interrupt: !!interrupt
};
if (options) {
record.options = options;
}
speechRecord.push(record);
that.queue.push(text);
that.events.onSpeechQueued.fire(text);
// mocking speechSynthesis speak
handleStart();
// using setTimeout to preserve asynchronous behaviour
setTimeout(handleEnd, 0);
};
fluid.mock.textToSpeech.cancel = function (that, handleEnd) {
that.queue = [];
handleEnd();
};
fluid.mock.textToSpeech.recordEvent = function (eventRecord, name) {
eventRecord[name] = (eventRecord[name] || 0) + 1;
};
})();

288
lib/infusion/src/components/textToSpeech/js/TextToSpeech.js

@ -0,0 +1,288 @@
/*
Copyright 2015-2016 OCAD University
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
Includes code from Underscore.js 1.8.3
http://underscorejs.org
(c) 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
Underscore may be freely distributed under the MIT license.
*/
/* global speechSynthesis, SpeechSynthesisUtterance*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
fluid.registerNamespace("fluid.textToSpeech");
/******************************************************************************************* *
* fluid.textToSpeech provides a wrapper around the SpeechSynthesis Interface *
* from the Web Speech API ( https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html ) *
*********************************************************************************************/
fluid.textToSpeech.isSupported = function () {
return !!(window && window.speechSynthesis);
};
/**
* Ensures that TTS is supported in the browser, including cases where the
* feature is detected, but where the underlying audio engine is missing.
* For example in VMs on SauceLabs, the behaviour for browsers which report that the speechSynthesis
* API is implemented is for the `onstart` event of an utterance to never fire. If we don't receive this
* event within a timeout, this API's behaviour is to return a promise which rejects.
*
* @param delay {Number} A time in milliseconds to wait for the speechSynthesis to fire its onStart event
* by default it is 5000ms (5s). This is crux of the test, as it needs time to attempt to run the speechSynthesis.
* @return {fluid.promise} A promise which will resolve if the TTS is supported (the onstart event is fired within the delay period)
* or be rejected otherwise.
*/
fluid.textToSpeech.checkTTSSupport = function (delay) {
var promise = fluid.promise();
if (fluid.textToSpeech.isSupported()) {
// MS Edge speech synthesizer won't speak if the text string is blank,
// so this must contain actual text
var toSpeak = new SpeechSynthesisUtterance("short"); // short text to attempt to speak
toSpeak.volume = 0; // mutes the Speech Synthesizer
// Same timeout as the timeout in the IoC testing framework
var timeout = setTimeout(function () {
fluid.textToSpeech.deferredSpeechSynthesisControl("cancel");
promise.reject();
}, delay || 5000);
toSpeak.onend = function () {
clearTimeout(timeout);
fluid.textToSpeech.deferredSpeechSynthesisControl("cancel");
promise.resolve();
};
fluid.textToSpeech.deferredSpeechSynthesisControl("speak", toSpeak);
} else {
setTimeout(promise.reject, 0);
}
return promise;
};
fluid.defaults("fluid.textToSpeech", {
gradeNames: ["fluid.modelComponent"],
events: {
onStart: null,
onStop: null,
onError: null,
onSpeechQueued: null
},
members: {
queue: []
},
// Model paths: speaking, pending, paused, utteranceOpts, pauseRequested, resumeRequested
model: {
// Changes to the utteranceOpts will only text that is queued after the change.
// All of these options can be overriden in the queueSpeech method by passing in
// options directly there. It is useful in cases where a single instance needs to be
// spoken with different options (e.g. single text in a different language.)
utteranceOpts: {
// text: "", // text to synthesize. avoid as it will override any other text passed in
// lang: "", // the language of the synthesized text
// voice: {} // a WebSpeechSynthesis object; if not set, will use the default one provided by the browser
// volume: 1, // a value between 0 and 1
// rate: 1, // a value from 0.1 to 10 although different synthesizers may have a smaller range
// pitch: 1, // a value from 0 to 2
}
},
modelListeners: {
"speaking": {
listener: "fluid.textToSpeech.speak",
args: ["{that}", "{change}.value"]
},
"pauseRequested": {
listener: "fluid.textToSpeech.requestControl",
args: ["{that}", "pause", "{change}"]
},
"resumeRequested": {
listener: "fluid.textToSpeech.requestControl",
args: ["{that}", "resume", "{change}"]
}
},
invokers: {
queueSpeech: {
funcName: "fluid.textToSpeech.queueSpeech",
args: ["{that}", "{arguments}.0", "{arguments}.1", "{arguments}.2"]
},
cancel: {
funcName: "fluid.textToSpeech.cancel",
args: ["{that}"]
},
pause: {
changePath: "pauseRequested",
value: true
},
resume: {
changePath: "resumeRequested",
value: true
},
getVoices: {
"this": "speechSynthesis",
"method": "getVoices"
},
handleStart: {
changePath: "speaking",
value: true
},
// The handleEnd method is assumed to be triggered asynchronously
// as it is processed/triggered by the mechanism voicing the utterance.
handleEnd: {
funcName: "fluid.textToSpeech.handleEnd",
args: ["{that}"]
},
handleError: "{that}.events.onError.fire",
handlePause: {
changePath: "paused",
value: true
},
handleResume: {
changePath: "paused",
value: false
}
}
});
// Issue commands to the speechSynthesis interface with deferral (1 ms timeout);
// this makes the wrapper behave better when issuing commands, especially
// play and pause
fluid.textToSpeech.deferredSpeechSynthesisControl = function (control, args) {
setTimeout(function () {
speechSynthesis[control](args);
}, 1);
};
// Throttle implementation adapted from underscore.js 1.8.3; see
// file header for license details
// Returns a version of a function that will only be called max once
// every "wait" MS
fluid.textToSpeech.throttle = function (func, wait, options) {
var timeout, context, args, result;
var previous = 0;
if (!options) {
options = {};
}
var later = function () {
previous = options.leading === false ? 0 : new Date().getTime();
timeout = null;
result = func.apply(context, args);
if (!timeout) {
context = args = null;
}
};
var throttled = function () {
var now = new Date().getTime();
if (!previous && options.leading === false) {
previous = now;
}
var remaining = wait - (now - previous);
context = this;
args = arguments;
if (remaining <= 0 || remaining > wait) {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
previous = now;
result = func.apply(context, args);
if (!timeout) {
context = args = null;
}
} else if (!timeout && options.trailing !== false) {
timeout = setTimeout(later, remaining);
}
return result;
};
throttled.cancel = function () {
clearTimeout(timeout);
previous = 0;
timeout = context = args = null;
};
return throttled;
};
// Throttled version of deferred speech synthesis control
fluid.textToSpeech.throttleControl = fluid.textToSpeech.throttle(fluid.textToSpeech.deferredSpeechSynthesisControl, 100, {leading: false});
fluid.textToSpeech.speak = function (that, speaking) {
that.events[speaking ? "onStart" : "onStop"].fire();
};
fluid.textToSpeech.requestControl = function (that, control, change) {
// If there's a control request (value change to true), clear and
// execute it
if (change.value) {
that.applier.change(change.path, false);
fluid.textToSpeech.throttleControl(control);
}
};
fluid.textToSpeech.handleEnd = function (that) {
that.queue.shift();
var resetValues = {
speaking: false,
pending: false,
paused: false
};
if (that.queue.length) {
that.applier.change("pending", true);
} else if (!that.queue.length) {
var newModel = $.extend({}, that.model, resetValues);
that.applier.change("", newModel);
}
};
fluid.textToSpeech.queueSpeech = function (that, text, interrupt, options) {
if (interrupt) {
that.cancel();
}
var errorFn = function () {
that.handleError(text);
};
var toSpeak = new SpeechSynthesisUtterance(text);
var eventBinding = {
onstart: that.handleStart,
onend: that.handleEnd,
onerror: errorFn,
onpause: that.handlePause,
onresume: that.handleResume
};
$.extend(toSpeak, that.model.utteranceOpts, options, eventBinding);
// Store toSpeak additionally on the queue to help deal
// with premature garbage collection described at https://bugs.chromium.org/p/chromium/issues/detail?id=509488#c11
// this makes the speech synthesis behave much better in Safari in
// particular
that.queue.push({text: text, utterance: toSpeak});
that.events.onSpeechQueued.fire(text);
fluid.textToSpeech.deferredSpeechSynthesisControl("speak", toSpeak);
};
fluid.textToSpeech.cancel = function (that) {
that.queue = [];
fluid.textToSpeech.deferredSpeechSynthesisControl("cancel");
};
})(jQuery, fluid_2_0_0);

14
lib/infusion/src/components/textToSpeech/textToSpeechDependencies.json

@ -0,0 +1,14 @@
{
"textToSpeech": {
"name": "Text To Speech",
"description": "A wrapper around the Web Speech API for Speech Synthesis",
"cssFiles": [],
"files": [
"./js/TextToSpeech.js"
],
"dependencies": [
"jQuery",
"framework"
]
}
}

312
lib/infusion/src/components/textfieldSlider/js/TextfieldSlider.js

@ -0,0 +1,312 @@
/*
Copyright 2013-2016 OCAD University
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
/********************
* Textfield Slider *
********************/
fluid.defaults("fluid.textfieldSlider", {
gradeNames: ["fluid.viewComponent", "fluid.contextAware"],
components: {
textfield: {
type: "fluid.textfieldSlider.textfield",
container: "{textfieldSlider}.dom.textfield",
options: {
model: "{textfieldSlider}.model",
range: "{textfieldSlider}.options.range",
ariaOptions: "{textfieldSlider}.options.ariaOptions",
strings: "{textfieldSlider}.options.strings"
}
},
slider: {
container: "{textfieldSlider}.dom.slider",
options: {
model: "{textfieldSlider}.model",
range: "{textfieldSlider}.options.range",
sliderOptions: "{textfieldSlider}.options.sliderOptions",
ariaOptions: "{textfieldSlider}.options.ariaOptions",
strings: "{textfieldSlider}.options.strings"
}
}
},
contextAwareness: {
sliderVariety: {
checks: {
jQueryUI: {
contextValue: "{fluid.prefsWidgetType}",
equals: "jQueryUI",
gradeNames: "fluid.textfieldSlider.jQueryUI"
}
},
defaultGradeNames: "fluid.textfieldSlider.nativeHTML"
}
},
selectors: {
textfield: ".flc-textfieldSlider-field",
slider: ".flc-textfieldSlider-slider"
},
model: {
value: null
},
modelRelay: {
target: "value",
singleTransform: {
type: "fluid.transforms.limitRange",
input: "{that}.model.value",
min: "{that}.options.range.min",
max: "{that}.options.range.max"
}
},
range: {
min: 0,
max: 100
},
ariaOptions: {
// Specified by implementor
// ID of an external label to refer to with aria-labelledby
// attribute
// "aria-labelledby": ""
},
sliderOptions: {
orientation: "horizontal",
step: 1.0
},
strings: {
// Specified by implementor
// text of label to apply to both textfield and slider input
// via aria-label attribute
// "aria-label": ""
}
});
fluid.defaults("fluid.textfieldSlider.nativeHTML", {
components: {
slider: {
type: "fluid.slider.native"
}
}
});
fluid.defaults("fluid.textfieldSlider.jQueryUI", {
components: {
slider: {
type: "fluid.slider.jQuery"
}
}
});
fluid.defaults("fluid.textfieldSlider.textfield", {
gradeNames: ["fluid.viewComponent"],
range: {}, // should be used to specify the min, max range e.g. {min: 0, max: 100}
modelRelay: {
target: "value",
singleTransform: {
type: "fluid.transforms.stringToNumber",
input: "{that}.model.stringValue"
}
},
modelListeners: {
value: {
"this": "{that}.container",
"method": "val",
args: ["{change}.value"]
},
// TODO: This listener is to deal with the issue that, when the input field receives a invalid input such as a string value,
// ignore it and populate the field with the previous value.
// This is an area in which UX has spilled over into our model configuration, which to some extent we should try to prevent.
// Whenever we receive a "change" event or some other similar checkpoint, if these updates occurred any faster, the user would
// be infuriated by being unable to type into the field. This situation doesn't occur at the moment because the change event is
// only fired when users leave the input feild. At the very least, we need to give a namespace to this listener - unfortunately
// the current dataBinding implementation will ignore it. Having this listener here represents an interaction decision rather
// than an implementation decision. This issue needs to be revisited.
stringValue: {
"this": "{that}.container",
"method": "val",
args: ["{that}.model.value"]
}
},
listeners: {
"onCreate.bindChangeEvt": {
"this": "{that}.container",
"method": "change",
"args": ["{that}.setModel"]
},
"onCreate.initTextfieldAttributes": {
"this": "{that}.container",
method: "attr",
args: [{
"aria-labelledby": "{that}.options.ariaOptions.aria-labelledby",
"aria-label": "{that}.options.strings.aria-label"
}]
}
},
invokers: {
setModel: {
changePath: "stringValue",
value: "{arguments}.0.target.value"
}
}
});
// Base slider grade
fluid.defaults("fluid.slider", {
gradeNames: ["fluid.viewComponent"],
range: {} // should be used to specify the min, max range e.g. {min: 0, max: 100}
});
fluid.defaults("fluid.slider.native", {
gradeNames: ["fluid.slider"],
modelRelay: {
target: "value",
singleTransform: {
type: "fluid.transforms.stringToNumber",
input: "{that}.model.stringValue"
}
},
invokers: {
setModel: {
changePath: "stringValue",
value: {
expander: {
"this": "{that}.container",
"method": "val"
}
}
}
},
listeners: {
"onCreate.initSliderAttributes": {
"this": "{that}.container",
method: "attr",
args: [{
"min": "{that}.options.range.min",
"max": "{that}.options.range.max",
"step": "{that}.options.sliderOptions.step",
"type": "range",
"value": "{that}.model.value",
"aria-labelledby": "{that}.options.ariaOptions.aria-labelledby",
"aria-label": "{that}.options.strings.aria-label"
}]
},
"onCreate.bindSlideEvt": {
"this": "{that}.container",
"method": "on",
"args": ["input", "{that}.setModel"]
},
"onCreate.bindRangeChangeEvt": {
"this": "{that}.container",
"method": "on",
"args": ["change", "{that}.setModel"]
}
},
modelListeners: {
"value": [{
"this": "{that}.container",
"method": "val",
args: ["{change}.value"],
// If we don't exclude init, the value can get
// set before onCreate.initSliderAttributes
// sets min / max / step, which messes up the
// initial slider rendering
excludeSource: "init"
}]
}
});
fluid.defaults("fluid.slider.jQuery", {
gradeNames: ["fluid.slider"],
selectors: {
thumb: ".ui-slider-handle"
},
styles: {
handle: "fl-slider-handle",
range: "fl-slider-range"
},
members: {
slider: {
expander: {
"this": "{that}.container",
method: "slider",
args: ["{that}.combinedSliderOptions"]
}
},
combinedSliderOptions: {
expander: {
funcName: "fluid.slider.combineSliderOptions",
args: ["{that}.options.sliderOptions", "{that}.options.range"]
}
}
},
sliderOptions: {
orientation: "horizontal",
step: 1.0,
classes: {
"ui-slider-handle": "{that}.options.styles.handle",
"ui-slider-range": "{that}.options.styles.range"
}
},
invokers: {
setSliderValue: {
"this": "{that}.slider",
"method": "slider",
args: ["value", "{arguments}.0"]
},
setSliderAriaValueNow: {
"this": "{that}.dom.thumb",
"method": "attr",
args: ["aria-valuenow", "{arguments}.0"]
},
setModel: {
changePath: "value",
value: "{arguments}.1.value"
}
},
listeners: {
// This can be removed once the jQuery UI slider has built in ARIA
"onCreate.initSliderAria": {
"this": "{that}.dom.thumb",
method: "attr",
args: [{
role: "slider",
"aria-valuenow": "{that}.combinedSliderOptions.value",
"aria-valuemin": "{that}.combinedSliderOptions.min",
"aria-valuemax": "{that}.combinedSliderOptions.max",
"aria-labelledby": "{that}.options.ariaOptions.aria-labelledby",
"aria-label": "{that}.options.strings.aria-label"
}]
},
"onCreate.bindSlideEvt": {
"this": "{that}.slider",
"method": "on",
"args": ["slide", "{that}.setModel"]
}
},
modelListeners: {
"value": [{
listener: "{that}.setSliderValue",
args: ["{change}.value"]
}, {
listener: "{that}.setSliderAriaValueNow",
args: ["{change}.value"]
}]
}
});
fluid.slider.combineSliderOptions = function (sliderOptions, model, range) {
return $.extend(true, {}, sliderOptions, model, range);
};
})(jQuery, fluid_2_0_0);

18
lib/infusion/src/components/textfieldSlider/textfieldSliderDependencies.json

@ -0,0 +1,18 @@
{
"textfieldSlider": {
"name": "Textfield Slider",
"description": "A synchronized slider and textfield",
"cssFiles": [],
"files": [
"./js/TextfieldSlider.js"
],
"dependencies": [
"jQuery",
"jQueryUI",
"normalize",
"framework",
"enhancement",
"jQueryTouchPunchPlugin"
]
}
}

45
lib/infusion/src/components/uiOptions/js/UIOptions.js

@ -0,0 +1,45 @@
/*
Copyright 2013-2016 OCAD University
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
// Gradename to invoke "fluid.uiOptions.prefsEditor"
fluid.prefs.builder({
gradeNames: ["fluid.prefs.auxSchema.starter"]
});
fluid.defaults("fluid.uiOptions.prefsEditor", {
gradeNames: ["fluid.prefs.constructed.prefsEditor"],
lazyLoad: false,
distributeOptions: [{
record: "{that}.options.lazyLoad",
target: "{that separatedPanel}.options.lazyLoad"
}, {
source: "{that}.options.tocTemplate",
target: "{that uiEnhancer}.options.tocTemplate"
}, {
source: "{that}.options.ignoreForToC",
target: "{that uiEnhancer}.options.ignoreForToC"
}],
enhancer: {
distributeOptions: [{
source: "{that}.options.tocTemplate",
target: "{that > fluid.prefs.enactor.tableOfContents}.options.tocTemplate"
}, {
source: "{that}.options.ignoreForToC",
target: "{that > fluid.prefs.enactor.tableOfContents}.options.ignoreForToC"
}]
}
});
})(jQuery, fluid_2_0_0);

14
lib/infusion/src/components/uiOptions/uiOptionsDependencies.json

@ -0,0 +1,14 @@
{
"uiOptions": {
"name": "User Interface Options",
"description": "An instance of a preference editor created by the Infusion Preferences Framework. Users customize their preferences and needs for viewing content.",
"files": [
"./js/UIOptions.js"
],
"dependencies": [
"jQuery",
"framework",
"preferences"
]
}
}

69
lib/infusion/src/framework/core/css/fluid.css

@ -0,0 +1,69 @@
/* focus */
.fl-focus:focus,
.fl-focus :focus {
outline: 2px solid black;
}
/* Container alignment */
.fl-force-right {float:right;}
.fl-force-left {float:left;}
.fl-centered {margin-left:auto; margin-right:auto; display:block;}
/* The following styles are based on 3rd party software */
/*
* The following styles are based on the Micro Clearfix solution:
* http://nicolasgallagher.com/micro-clearfix-hack/
*/
.fl-clearfix:before, .fl-clearfix:after {content:""; display:table;}
.fl-clearfix:after {clear:both;}
/* End of Micro Clearfix based styles */
/*
* The following styles are based on css from HTML5 Boilerplate v4.3:
* http://html5boilerplate.com
*/
/* Hide from both screenreaders and browsers */
.fl-hidden {
display: none !important;
visibility: hidden;
}
/* Hide visually and from screenreaders, but maintain layout */
.fl-hidden-invisible {
visibility: hidden;
}
/* Hide only visually, but have it available for screenreaders */
.fl-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
/*
* Extends the .visuallyhidden class to allow the element to be focusable
* when navigated to via the keyboard
*/
.fl-hidden-accessible.fl-focus:active,
.fl-hidden-accessible.fl-focus:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
}
/* End of HTML5 Boilerplate based styles */

132
lib/infusion/src/framework/core/css/fluidDebugging.css

@ -0,0 +1,132 @@
.fl-debug-holder {
position: fixed;
bottom: 0;
right: 0;
width: 100%;
height: 0px;
background-color: #dff;
}
.fl-debug-holder-open {
height: 20em;
}
.fl-debug-holder-closed {
height: 0px;
}
.fl-debug-open-pane-trigger {
width: 32px;
height: 32px;
position: absolute;
top: -37px;
right: 5px;
background: url("../images/debug_tab.png");
}
.fl-debug-open-pane-trigger:hover {
background-color: #bbb;
}
.fl-debug-pane {
width: 100%;
height: 100%;
font-family: OpenSans, 'Helvetica Neue', Helvetica, Helvetica, Arial, sans-serif;
font-size: 16px;
color: black;
padding-top: 40px;
overflow-y: scroll;
overflow-x: hidden;
}
.fl-debug-pane thead {
padding-bottom: 2px;
font-weight: bold;
}
.fl-debug-pointer-events-none {
pointer-events: none;
}
.fl-debug-highlightElement {
z-index: 999999;
position: absolute;
width: 100%;
height: 100%;
pointer-events: none;
}
.fl-debug-highlightRoot {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
.flc-debug-pane-indexel {
width: 2em;
height: 1em;
margin: 0.2em;
border: 2px solid black
}
.fl-debug-inspect-trigger {
width: 32px;
height: 32px;
position: absolute;
top: 5px;
left: 5px;
background: url("../images/magnifying_glass.png");
}
.fl-debug-inspect-trigger:hover {
background-color: #ddd;
}
.fl-debug-inspect-active {
background-color: #aaa;
}
.fl-debug-inspect-active:hover {
background-color: #888;
}
.fl-debug-selector-cell {
text-align: right;
padding-right: 1em;
}
/* See http://stackoverflow.com/questions/14765817/why-does-css-td-width-not-work */
.fl-debug-pane-index {
min-width: 3em;
}
.fl-debug-pane-dom-id {
min-width: 11em;
}
.fl-debug-pane-component-id {
min-width: 11em;
}
.fl-debug-pane-grades {
min-width: 40em;
}
.fl-debug-line {
min-width: 18em;
}
.fl-debug-tooltip {
width: 40em;
font-size: 10px;
position: absolute;
background-color: #FFC;
border: 2px solid #444;
padding: 0.5em;
}
.flc-debug-tooltip-trigger:hover {
background-color: rgba(128, 128, 128, 0.3);
}

26
lib/infusion/src/framework/core/frameworkDependencies.json

@ -0,0 +1,26 @@
{
"framework": {
"name": "Infusion Framework Core",
"description": "A suite of core Infusion framework features, including support for events, views, data binding, and keyboard accessibility. Required by all Fluid components.",
"files": [
"./js/Fluid.js",
"./js/FluidPromises.js",
"./js/FluidDocument.js",
"./js/FluidDOMUtilities.js",
"./js/JavaProperties.js",
"./js/FluidDebugging.js",
"./js/FluidIoC.js",
"./js/DataBinding.js",
"./js/ModelTransformation.js",
"./js/ModelTransformationTransforms.js",
"./js/jquery.keyboard-a11y.js",
"./js/FluidView.js",
"./js/FluidRequests.js",
"./js/ResourceLoader.js"
],
"dependencies": [
"jQuery",
"jQueryUI"
]
}
}

BIN
lib/infusion/src/framework/core/images/debug_tab.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
lib/infusion/src/framework/core/images/magnifying_glass.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

1495
lib/infusion/src/framework/core/js/DataBinding.js

File diff suppressed because it is too large Load Diff

2806
lib/infusion/src/framework/core/js/Fluid.js

File diff suppressed because it is too large Load Diff

116
lib/infusion/src/framework/core/js/FluidDOMUtilities.js

@ -0,0 +1,116 @@
/*
Copyright 2008-2010 University of Cambridge
Copyright 2008-2009 University of Toronto
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
fluid.dom = fluid.dom || {};
// Node walker function for iterateDom.
var getNextNode = function (iterator) {
if (iterator.node.firstChild) {
iterator.node = iterator.node.firstChild;
iterator.depth += 1;
return iterator;
}
while (iterator.node) {
if (iterator.node.nextSibling) {
iterator.node = iterator.node.nextSibling;
return iterator;
}
iterator.node = iterator.node.parentNode;
iterator.depth -= 1;
}
return iterator;
};
/**
* Walks the DOM, applying the specified acceptor function to each element.
* There is a special case for the acceptor, allowing for quick deletion of elements and their children.
* Return "delete" from your acceptor function if you want to delete the element in question.
* Return "stop" to terminate iteration.
* Implementation note - this utility exists mainly for performance reasons. It was last tested
* carefully some time ago (around jQuery 1.2) but at that time was around 3-4x faster at raw DOM
* filtration tasks than the jQuery equivalents, which was an important source of performance loss in the
* Reorderer component. General clients of the framework should use this method with caution if at all, and
* the performance issues should be reassessed when we have time.
*
* @param {Element} node the node to start walking from
* @param {Function} acceptor the function to invoke with each DOM element
* @param {Boolean} allnodes Use <code>true</code> to call acceptor on all nodes,
* rather than just element nodes (type 1)
*/
fluid.dom.iterateDom = function (node, acceptor, allNodes) {
var currentNode = {node: node, depth: 0};
var prevNode = node;
var condition;
while (currentNode.node !== null && currentNode.depth >= 0 && currentNode.depth < fluid.dom.iterateDom.DOM_BAIL_DEPTH) {
condition = null;
if (currentNode.node.nodeType === 1 || allNodes) {
condition = acceptor(currentNode.node, currentNode.depth);
}
if (condition) {
if (condition === "delete") {
currentNode.node.parentNode.removeChild(currentNode.node);
currentNode.node = prevNode;
}
else if (condition === "stop") {
return currentNode.node;
}
}
prevNode = currentNode.node;
currentNode = getNextNode(currentNode);
}
};
// Work around IE circular DOM issue. This is the default max DOM depth on IE.
// http://msdn2.microsoft.com/en-us/library/ms761392(VS.85).aspx
fluid.dom.iterateDom.DOM_BAIL_DEPTH = 256;
/**
* Checks if the specified container is actually the parent of containee.
*
* @param {Element} container the potential parent
* @param {Element} containee the child in question
*/
fluid.dom.isContainer = function (container, containee) {
for (; containee; containee = containee.parentNode) {
if (container === containee) {
return true;
}
}
return false;
};
/** Return the element text from the supplied DOM node as a single String.
* Implementation note - this is a special-purpose utility used in the framework in just one
* position in the Reorderer. It only performs a "shallow" traversal of the text and was intended
* as a quick and dirty means of extracting element labels where the user had not explicitly provided one.
* It should not be used by general users of the framework and its presence here needs to be
* reassessed.
*/
fluid.dom.getElementText = function (element) {
var nodes = element.childNodes;
var text = "";
for (var i = 0; i < nodes.length; ++i) {
var child = nodes[i];
if (child.nodeType === 3) {
text = text + child.nodeValue;
}
}
return text;
};
})(jQuery, fluid_2_0_0);

300
lib/infusion/src/framework/core/js/FluidDebugging.js

@ -0,0 +1,300 @@
/*
Copyright 2007-2010 University of Cambridge
Copyright 2007-2009 University of Toronto
Copyright 2007-2009 University of California, Berkeley
Copyright 2010 OCAD University
Copyright 2010-2011 Lucendo Development Ltd.
Copyright 2012 Raising the Floor - US
Copyright 2014-2015 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
var fluid = fluid || fluid_2_0_0;
(function ($, fluid) {
"use strict";
/** Render a timestamp from a Date object into a helpful fixed format for debug logs to millisecond accuracy
* @param date {Date} The date to be rendered
* @return {String} A string format consisting of hours:minutes:seconds.millis for the datestamp padded to fixed with
*/
fluid.renderTimestamp = function (date) {
var zeropad = function (num, width) {
if (!width) { width = 2; }
var numstr = (num === undefined ? "" : num.toString());
return "00000".substring(5 - width + numstr.length) + numstr;
};
return zeropad(date.getHours()) + ":" + zeropad(date.getMinutes()) + ":" + zeropad(date.getSeconds()) + "." + zeropad(date.getMilliseconds(), 3);
};
fluid.isTracing = false;
fluid.registerNamespace("fluid.tracing");
fluid.tracing.pathCount = [];
fluid.tracing.summarisePathCount = function (pathCount) {
pathCount = pathCount || fluid.tracing.pathCount;
var togo = {};
for (var i = 0; i < pathCount.length; ++i) {
var path = pathCount[i];
if (!togo[path]) {
togo[path] = 1;
}
else {
++togo[path];
}
}
var toReallyGo = [];
fluid.each(togo, function (el, path) {
toReallyGo.push({path: path, count: el});
});
toReallyGo.sort(function (a, b) {return b.count - a.count;});
return toReallyGo;
};
fluid.tracing.condensePathCount = function (prefixes, pathCount) {
prefixes = fluid.makeArray(prefixes);
var prefixCount = {};
fluid.each(prefixes, function (prefix) {
prefixCount[prefix] = 0;
});
var togo = [];
fluid.each(pathCount, function (el) {
var path = el.path;
if (!fluid.find(prefixes, function (prefix) {
if (path.indexOf(prefix) === 0) {
prefixCount[prefix] += el.count;
return true;
}
})) {
togo.push(el);
}
});
fluid.each(prefixCount, function (count, path) {
togo.unshift({path: path, count: count});
});
return togo;
};
// Exception stripping code taken from https://github.com/emwendelin/javascript-stacktrace/blob/master/stacktrace.js
// BSD licence, see header
fluid.detectStackStyle = function (e) {
var style = "other";
var stackStyle = {
offset: 0
};
if (e.arguments) {
style = "chrome";
} else if (typeof window !== "undefined" && window.opera && e.stacktrace) {
style = "opera10";
} else if (e.stack) {
style = "firefox";
// Detect FireFox 4-style stacks which are 1 level less deep
stackStyle.offset = e.stack.indexOf("Trace exception") === -1 ? 1 : 0;
} else if (typeof window !== "undefined" && window.opera && !("stacktrace" in e)) { //Opera 9-
style = "opera";
}
stackStyle.style = style;
return stackStyle;
};
fluid.obtainException = function () {
try {
throw new Error("Trace exception");
}
catch (e) {
return e;
}
};
var stackStyle = fluid.detectStackStyle(fluid.obtainException());
fluid.registerNamespace("fluid.exceptionDecoders");
fluid.decodeStack = function () {
if (stackStyle.style !== "firefox") {
return null;
}
var e = fluid.obtainException();
return fluid.exceptionDecoders[stackStyle.style](e);
};
fluid.exceptionDecoders.firefox = function (e) {
var delimiter = "at ";
var lines = e.stack.replace(/(?:\n@:0)?\s+$/m, "").replace(/^\(/gm, "{anonymous}(").split("\n");
return fluid.transform(lines, function (line) {
line = line.replace(/\)/g, "");
var atind = line.indexOf(delimiter);
return atind === -1 ? [line] : [line.substring(atind + delimiter.length), line.substring(0, atind)];
});
};
// Main entry point for callers.
fluid.getCallerInfo = function (atDepth) {
atDepth = (atDepth || 3) - stackStyle.offset;
var stack = fluid.decodeStack();
var element = stack && stack[atDepth][0];
if (element) {
var lastslash = element.lastIndexOf("/");
if (lastslash === -1) {
lastslash = 0;
}
var nextColon = element.indexOf(":", lastslash);
return {
path: element.substring(0, lastslash),
filename: element.substring(lastslash + 1, nextColon),
index: element.substring(nextColon + 1)
};
} else {
return null;
}
};
/** Generates a string for padding purposes by replicating a character a given number of times
* @param c {Character} A character to be used for padding
* @param count {Integer} The number of times to repeat the character
* @return A string of length <code>count</code> consisting of repetitions of the supplied character
*/
// UNOPTIMISED
fluid.generatePadding = function (c, count) {
var togo = "";
for (var i = 0; i < count; ++i) {
togo += c;
}
return togo;
};
// Marker so that we can render a custom string for properties which are not direct and concrete
fluid.SYNTHETIC_PROPERTY = {};
// utility to avoid triggering custom getter code which could throw an exception - e.g. express 3.x's request object
fluid.getSafeProperty = function (obj, key) {
var desc = Object.getOwnPropertyDescriptor(obj, key); // supported on all of our environments - is broken on IE8
return desc && !desc.get ? obj[key] : fluid.SYNTHETIC_PROPERTY;
};
function printImpl(obj, small, options) {
function out(str) {
options.output += str;
}
var big = small + options.indentChars, isFunction = typeof(obj) === "function";
if (options.maxRenderChars !== undefined && options.output.length > options.maxRenderChars) {
return true;
}
if (obj === null) {
out("null");
} else if (obj === undefined) {
out("undefined"); // NB - object invalid for JSON interchange
} else if (obj === fluid.SYNTHETIC_PROPERTY) {
out("[Synthetic property]");
} else if (fluid.isPrimitive(obj) && !isFunction) {
out(JSON.stringify(obj));
}
else {
if (options.stack.indexOf(obj) !== -1) {
out("(CIRCULAR)"); // NB - object invalid for JSON interchange
return;
}
options.stack.push(obj);
var i;
if (fluid.isArrayable(obj)) {
if (obj.length === 0) {
out("[]");
} else {
out("[\n" + big);
for (i = 0; i < obj.length; ++i) {
if (printImpl(obj[i], big, options)) {
return true;
}
if (i !== obj.length - 1) {
out(",\n" + big);
}
}
out("\n" + small + "]");
}
}
else {
out("{" + (isFunction ? " Function" : "") + "\n" + big); // NB - Function object invalid for JSON interchange
var keys = fluid.keys(obj);
for (i = 0; i < keys.length; ++i) {
var key = keys[i];
var value = fluid.getSafeProperty(obj, key);
out(JSON.stringify(key) + ": ");
if (printImpl(value, big, options)) {
return true;
}
if (i !== keys.length - 1) {
out(",\n" + big);
}
}
out("\n" + small + "}");
}
options.stack.pop();
}
return;
}
/** Render a complex JSON object into a nicely indented format suitable for human readability.
* @param obj {Object} The object to be rendered
* @param options {Object} An options structure governing the rendering process. This supports the following options:
* <code>indent</code> {Integer} the number of space characters to be used to indent each level of containment (default value: 4)
* <code>maxRenderChars</code> {Integer} rendering the object will cease once this number of characters has been generated
*/
fluid.prettyPrintJSON = function (obj, options) {
options = $.extend({indent: 4, stack: [], output: ""}, options);
options.indentChars = fluid.generatePadding(" ", options.indent);
printImpl(obj, "", options);
return options.output;
};
/**
* Dumps a DOM element into a readily recognisable form for debugging - produces a
* "semi-selector" summarising its tag name, class and id, whichever are set.
*
* @param {jQueryable} element The element to be dumped
* @return A string representing the element.
*/
fluid.dumpEl = function (element) {
var togo;
if (!element) {
return "null";
}
if (element.nodeType === 3 || element.nodeType === 8) {
return "[data: " + element.data + "]";
}
if (element.nodeType === 9) {
return "[document: location " + element.location + "]";
}
if (!element.nodeType && fluid.isArrayable(element)) {
togo = "[";
for (var i = 0; i < element.length; ++i) {
togo += fluid.dumpEl(element[i]);
if (i < element.length - 1) {
togo += ", ";
}
}
return togo + "]";
}
element = $(element);
togo = element.get(0).tagName;
if (element.id) {
togo += "#" + element.id;
}
if (element.attr("class")) {
togo += "." + element.attr("class");
}
return togo;
};
})(jQuery, fluid_2_0_0);

191
lib/infusion/src/framework/core/js/FluidDocument.js

@ -0,0 +1,191 @@
/*
Copyright 2007-2010 University of Cambridge
Copyright 2007-2009 University of Toronto
Copyright 2010-2011 Lucendo Development Ltd.
Copyright 2010-2016 OCAD University
Copyright 2013-2014 Raising the Floor - US
Copyright 2005-2013 jQuery Foundation, Inc. and other contributors
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
/** This file contains functions which depend on the presence of a DOM document
* but which do not depend on the contents of Fluid.js **/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
// polyfill for $.browser which was removed in jQuery 1.9 and later
// Taken from jquery-migrate-1.2.1.js,
// jQuery Migrate - v1.2.1 - 2013-05-08
// https://github.com/jquery/jquery-migrate
// Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
fluid.uaMatch = function (ua) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || [];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
var matched, browser;
// Don't clobber any existing jQuery.browser in case it's different
if (!$.browser) {
if (!!navigator.userAgent.match(/Trident\/7\./)) {
browser = { // From http://stackoverflow.com/questions/18684099/jquery-fail-to-detect-ie-11
msie: true,
version: 11
};
} else {
matched = fluid.uaMatch(navigator.userAgent);
browser = {};
if (matched.browser) {
browser[matched.browser] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if (browser.chrome) {
browser.webkit = true;
} else if (browser.webkit) {
browser.safari = true;
}
}
$.browser = browser;
}
// Private constants.
var NAMESPACE_KEY = "fluid-scoped-data";
/**
* Gets stored state from the jQuery instance's data map.
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.getScopedData = function (target, key) {
var data = $(target).data(NAMESPACE_KEY);
return data ? data[key] : undefined;
};
/**
* Stores state in the jQuery instance's data map. Unlike jQuery's version,
* accepts multiple-element jQueries.
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.setScopedData = function (target, key, value) {
$(target).each(function () {
var data = $.data(this, NAMESPACE_KEY) || {};
data[key] = value;
$.data(this, NAMESPACE_KEY, data);
});
};
/** Global focus manager - makes use of "focusin" event supported in jquery 1.4.2 or later.
*/
var lastFocusedElement = null;
$(document).on("focusin", function (event) {
lastFocusedElement = event.target;
});
fluid.getLastFocusedElement = function () {
return lastFocusedElement;
};
var ENABLEMENT_KEY = "enablement";
/** Queries or sets the enabled status of a control. An activatable node
* may be "disabled" in which case its keyboard bindings will be inoperable
* (but still stored) until it is reenabled again.
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.enabled = function (target, state) {
target = $(target);
if (state === undefined) {
return fluid.getScopedData(target, ENABLEMENT_KEY) !== false;
}
else {
$("*", target).add(target).each(function () {
if (fluid.getScopedData(this, ENABLEMENT_KEY) !== undefined) {
fluid.setScopedData(this, ENABLEMENT_KEY, state);
}
else if (/select|textarea|input/i.test(this.nodeName)) {
$(this).prop("disabled", !state);
}
});
fluid.setScopedData(target, ENABLEMENT_KEY, state);
}
};
fluid.initEnablement = function (target) {
fluid.setScopedData(target, ENABLEMENT_KEY, true);
};
// This utility is required through the use of newer versions of jQuery which will obscure the original
// event responsible for interaction with a target. This is currently use in Tooltip.js and FluidView.js
// "dead man's blur" but would be of general utility
fluid.resolveEventTarget = function (event) {
while (event.originalEvent && event.originalEvent.target) {
event = event.originalEvent;
}
return event.target;
};
// These function (fluid.focus() and fluid.blur()) serve several functions. They should be used by
// all implementation both in test cases and component implementation which require to trigger a focus
// event. Firstly, they restore the old behaviour in jQuery versions prior to 1.10 in which a focus
// trigger synchronously relays to a focus handler. In newer jQueries this defers to the real browser
// relay with numerous platform and timing-dependent effects.
// Secondly, they are necessary since simulation of focus events by jQuery under IE
// is not sufficiently good to intercept the "focusin" binding. Any code which triggers
// focus or blur synthetically throughout the framework and client code must use this function,
// especially if correct cross-platform interaction is required with the "deadMansBlur" function.
function applyOp(node, func) {
node = $(node);
node.trigger("fluid-" + func);
node.triggerHandler(func);
node[func]();
return node;
}
$.each(["focus", "blur"], function (i, name) {
fluid[name] = function (elem) {
return applyOp(elem, name);
};
});
/* Sets the value to the DOM element and triggers the change event on the element.
* Note: when using jQuery val() function to change the node value, the change event would
* not be fired automatically, it requires to be initiated by the user.
*
* @param node {A jQueryable DOM element} A selector, a DOM node, or a jQuery instance
* @param value {String|Number|Array} A string of text, a number, or an array of strings
* corresponding to the value of each matched element to set in the node
*/
fluid.changeElementValue = function (node, value) {
node = $(node);
node.val(value).change();
};
})(jQuery, fluid_2_0_0);

2458
lib/infusion/src/framework/core/js/FluidIoC.js

File diff suppressed because it is too large Load Diff

266
lib/infusion/src/framework/core/js/FluidPromises.js

@ -0,0 +1,266 @@
/*!
Copyright 2011 unscriptable.com / John Hann
Copyright 2014 Lucendo Development Ltd.
Copyright 2014 Raising the Floor - US
Copyright 2014-2016 Raising the Floor - International
License MIT
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
// Light fluidification of minimal promises library. See original gist at
// https://gist.github.com/unscriptable/814052 for limitations and commentary
// This implementation provides what could be described as "flat promises" with
// no support for structured programming idioms involving promise composition.
// It provides what a proponent of mainstream promises would describe as
// a "glorified callback aggregator"
fluid.promise = function () {
var that = {
onResolve: [],
onReject: []
// disposition
// value
};
that.then = function (onResolve, onReject) {
if (onResolve) {
if (that.disposition === "resolve") {
onResolve(that.value);
} else {
that.onResolve.push(onResolve);
}
}
if (onReject) {
if (that.disposition === "reject") {
onReject(that.value);
} else {
that.onReject.push(onReject);
}
}
return that;
};
that.resolve = function (value) {
if (that.disposition) {
fluid.fail("Error: resolving promise ", that,
" which has already received \"" + that.disposition + "\"");
} else {
that.complete("resolve", that.onResolve, value);
}
return that;
};
that.reject = function (reason) {
if (that.disposition) {
fluid.fail("Error: rejecting promise ", that,
"which has already received \"" + that.disposition + "\"");
} else {
that.complete("reject", that.onReject, reason);
}
return that;
};
// PRIVATE, NON-API METHOD
that.complete = function (which, queue, arg) {
that.disposition = which;
that.value = arg;
for (var i = 0; i < queue.length; ++i) {
queue[i](arg);
}
};
return that;
};
/** Any object with a member <code>then</code> of type <code>function</code> passes this test.
* This includes essentially every known variety, including jQuery promises.
*/
fluid.isPromise = function (totest) {
return totest && typeof(totest.then) === "function";
};
/** Coerces any value to a promise
* @param promiseOrValue The value to be coerced
* @return If the supplied value is already a promise, it is returned unchanged. Otherwise a fresh promise is created with the value as resolution and returned
*/
fluid.toPromise = function (promiseOrValue) {
if (fluid.isPromise(promiseOrValue)) {
return promiseOrValue;
} else {
var togo = fluid.promise();
togo.resolve(promiseOrValue);
return togo;
}
};
/** Chains the resolution methods of one promise (target) so that they follow those of another (source).
* That is, whenever source resolves, target will resolve, or when source rejects, target will reject, with the
* same payloads in each case.
*/
fluid.promise.follow = function (source, target) {
source.then(target.resolve, target.reject);
};
/** Returns a promise whose resolved value is mapped from the source promise or value by the supplied function.
* @param source {Object|Promise} An object or promise whose value is to be mapped
* @param func {Function} A function which will map the resolved promise value
* @return {Promise} A promise for the resolved mapped value.
*/
fluid.promise.map = function (source, func) {
var promise = fluid.toPromise(source);
var togo = fluid.promise();
promise.then(function (value) {
var mapped = func(value);
if (fluid.isPromise(mapped)) {
fluid.promise.follow(mapped, togo);
} else {
togo.resolve(mapped);
}
}, function (error) {
togo.reject(error);
});
return togo;
};
/* General skeleton for all sequential promise algorithms, e.g. transform, reduce, sequence, etc.
* These accept a variable "strategy" pair to customise the interchange of values and final return
*/
fluid.promise.makeSequencer = function (sources, options, strategy) {
if (!fluid.isArrayable(sources)) {
fluid.fail("fluid.promise sequence algorithms must be supplied an array as source");
}
return {
sources: sources,
resolvedSources: [], // the values of "sources" only with functions invoked (an array of promises or values)
index: 0,
strategy: strategy,
options: options, // available to be supplied to each listener
returns: [],
promise: fluid.promise() // the final return value
};
};
fluid.promise.progressSequence = function (that, retValue) {
that.returns.push(retValue);
that.index++;
// No we dun't have no tail recursion elimination
fluid.promise.resumeSequence(that);
};
fluid.promise.processSequenceReject = function (that, error) { // Allow earlier promises in the sequence to wrap the rejection supplied by later ones (FLUID-5584)
for (var i = that.index - 1; i >= 0; --i) {
var resolved = that.resolvedSources[i];
var accumulator = fluid.isPromise(resolved) && typeof(resolved.accumulateRejectionReason) === "function" ? resolved.accumulateRejectionReason : fluid.identity;
error = accumulator(error);
}
that.promise.reject(error);
};
fluid.promise.resumeSequence = function (that) {
if (that.index === that.sources.length) {
that.promise.resolve(that.strategy.resolveResult(that));
} else {
var value = that.strategy.invokeNext(that);
that.resolvedSources[that.index] = value;
if (fluid.isPromise(value)) {
value.then(function (retValue) {
fluid.promise.progressSequence(that, retValue);
}, function (error) {
fluid.promise.processSequenceReject(that, error);
});
} else {
fluid.promise.progressSequence(that, value);
}
}
};
// SEQUENCE ALGORITHM APPLYING PROMISES
fluid.promise.makeSequenceStrategy = function () {
return {
invokeNext: function (that) {
var source = that.sources[that.index];
return typeof(source) === "function" ? source(that.options) : source;
},
resolveResult: function (that) {
return that.returns;
}
};
};
// accepts an array of values, promises or functions returning promises - in the case of functions returning promises,
// will assure that at most one of these is "in flight" at a time - that is, the succeeding function will not be invoked
// until the promise at the preceding position has resolved
fluid.promise.sequence = function (sources, options) {
var sequencer = fluid.promise.makeSequencer(sources, options, fluid.promise.makeSequenceStrategy());
fluid.promise.resumeSequence(sequencer);
return sequencer.promise;
};
// TRANSFORM ALGORITHM APPLYING PROMISES
fluid.promise.makeTransformerStrategy = function () {
return {
invokeNext: function (that) {
var lisrec = that.sources[that.index];
lisrec.listener = fluid.event.resolveListener(lisrec.listener);
var value = lisrec.listener(that.returns[that.index], that.options);
return value;
},
resolveResult: function (that) {
return that.returns[that.index];
}
};
};
// Construct a "mini-object" managing the process of a sequence of transforms,
// each of which may be synchronous or return a promise
fluid.promise.makeTransformer = function (listeners, payload, options) {
listeners.unshift({listener:
function () {
return payload;
}
});
var sequencer = fluid.promise.makeSequencer(listeners, options, fluid.promise.makeTransformerStrategy());
sequencer.returns.push(null); // first dummy return from initial entry
fluid.promise.resumeSequence(sequencer);
return sequencer;
};
fluid.promise.filterNamespaces = function (listeners, namespaces) {
if (!namespaces) {
return listeners;
}
return fluid.remove_if(fluid.makeArray(listeners), function (element) {
return element.namespace && !element.softNamespace && !fluid.contains(namespaces, element.namespace);
});
};
/** Top-level API to operate a Fluid event which manages a sequence of
* chained transforms. Rather than being a standard listener accepting the
* same payload, each listener to the event accepts the payload returned by the
* previous listener, and returns either a transformed payload or else a promise
* yielding such a payload.
* @param event {fluid.eventFirer} A Fluid event to which the listeners are to be interpreted as
* elements cooperating in a chained transform. Each listener will receive arguments <code>(payload, options)</code> where <code>payload</code>
* is the (successful, resolved) return value of the previous listener, and <code>options</code> is the final argument to this function
* @param payload {Object|Promise} The initial payload input to the transform chain
* @param options {Object} A free object containing options governing the transform. Fields interpreted at this top level are:
* reverse {Boolean}: <code>true</code> if the listeners are to be called in reverse order of priority (typically the case for an inverse transform)
* filterTransforms {Array}: An array of listener namespaces. If this field is set, only the transform elements whose listener namespaces listed in this array will be applied.
* @return {fluid.promise} A promise which will yield either the final transformed value, or the response of the first transform which fails.
*/
fluid.promise.fireTransformEvent = function (event, payload, options) {
options = options || {};
var listeners = options.reverse ? fluid.makeArray(event.sortedListeners).reverse() :
fluid.makeArray(event.sortedListeners);
listeners = fluid.promise.filterNamespaces(listeners, options.filterNamespaces);
var transformer = fluid.promise.makeTransformer(listeners, payload, options);
return transformer.promise;
};
})(jQuery, fluid_2_0_0);

439
lib/infusion/src/framework/core/js/FluidRequests.js

@ -0,0 +1,439 @@
/*
Copyright 2010-2011 OCAD University
Copyright 2010-2011 Lucendo Development Ltd.
Copyright 2013 Raising the Floor - US
Copyright 2014-2015 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
/** NOTE: All contents of this file are DEPRECATED and no entry point should be considered a supported API **/
fluid.explodeLocalisedName = function (fileName, locale, defaultLocale) {
var lastDot = fileName.lastIndexOf(".");
if (lastDot === -1 || lastDot === 0) {
lastDot = fileName.length;
}
var baseName = fileName.substring(0, lastDot);
var extension = fileName.substring(lastDot);
var segs = locale.split("_");
var exploded = fluid.transform(segs, function (seg, index) {
var shortSegs = segs.slice(0, index + 1);
return baseName + "_" + shortSegs.join("_") + extension;
});
if (defaultLocale) {
exploded.unshift(baseName + "_" + defaultLocale + extension);
}
return exploded;
};
/** Framework-global caching state for fluid.fetchResources **/
var resourceCache = {};
var pendingClass = {};
/** Accepts a hash of structures with free keys, where each entry has either
* href/url or nodeId set - on completion, callback will be called with the populated
* structure with fetched resource text in the field "resourceText" for each
* entry. Each structure may contain "options" holding raw options to be forwarded
* to jQuery.ajax().
*/
fluid.fetchResources = function (resourceSpecs, callback, options) {
var that = {
options: fluid.copy(options || {})
};
that.resourceSpecs = resourceSpecs;
that.callback = callback;
that.operate = function () {
fluid.fetchResources.fetchResourcesImpl(that);
};
fluid.each(resourceSpecs, function (resourceSpec, key) {
resourceSpec.recurseFirer = fluid.makeEventFirer({name: "I/O completion for resource \"" + key + "\""});
resourceSpec.recurseFirer.addListener(that.operate);
if (resourceSpec.url && !resourceSpec.href) {
resourceSpec.href = resourceSpec.url;
}
if (that.options.defaultLocale) {
resourceSpec.defaultLocale = that.options.defaultLocale;
if (resourceSpec.locale === undefined) {
resourceSpec.locale = that.options.defaultLocale;
}
}
});
if (that.options.amalgamateClasses) {
fluid.fetchResources.amalgamateClasses(resourceSpecs, that.options.amalgamateClasses, that.operate);
}
fluid.fetchResources.explodeForLocales(resourceSpecs);
that.operate();
return that;
};
fluid.fetchResources.explodeForLocales = function (resourceSpecs) {
fluid.each(resourceSpecs, function (resourceSpec, key) {
if (resourceSpec.locale) {
var exploded = fluid.explodeLocalisedName(resourceSpec.href, resourceSpec.locale, resourceSpec.defaultLocale);
for (var i = 0; i < exploded.length; ++i) {
var newKey = key + "$localised-" + i;
var newRecord = $.extend(true, {}, resourceSpec, {
href: exploded[i],
localeExploded: true
});
resourceSpecs[newKey] = newRecord;
}
resourceSpec.localeExploded = exploded.length;
}
});
return resourceSpecs;
};
fluid.fetchResources.condenseOneResource = function (resourceSpecs, resourceSpec, key, localeCount) {
var localeSpecs = [resourceSpec];
for (var i = 0; i < localeCount; ++i) {
var localKey = key + "$localised-" + i;
localeSpecs.unshift(resourceSpecs[localKey]);
delete resourceSpecs[localKey];
}
var lastNonError = fluid.find_if(localeSpecs, function (spec) {
return !spec.fetchError;
});
if (lastNonError) {
resourceSpecs[key] = lastNonError;
}
};
fluid.fetchResources.condenseForLocales = function (resourceSpecs) {
fluid.each(resourceSpecs, function (resourceSpec, key) {
if (typeof(resourceSpec.localeExploded) === "number") {
fluid.fetchResources.condenseOneResource(resourceSpecs, resourceSpec, key, resourceSpec.localeExploded);
}
});
};
fluid.fetchResources.notifyResources = function (that, resourceSpecs, callback) {
fluid.fetchResources.condenseForLocales(resourceSpecs);
callback(resourceSpecs);
};
/*
* This function is unsupported: It is not really intended for use by implementors.
*/
// Add "synthetic" elements of *this* resourceSpec list corresponding to any
// still pending elements matching the PROLEPTICK CLASS SPECIFICATION supplied
fluid.fetchResources.amalgamateClasses = function (specs, classes, operator) {
fluid.each(classes, function (clazz) {
var pending = pendingClass[clazz];
fluid.each(pending, function (pendingrec, canon) {
specs[clazz + "!" + canon] = pendingrec;
pendingrec.recurseFirer.addListener(operator);
});
});
};
/*
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.fetchResources.timeSuccessCallback = function (resourceSpec) {
if (resourceSpec.timeSuccess && resourceSpec.options && resourceSpec.options.success) {
var success = resourceSpec.options.success;
resourceSpec.options.success = function () {
var startTime = new Date();
var ret = success.apply(null, arguments);
fluid.log("External callback for URL " + resourceSpec.href + " completed - callback time: " +
(new Date().getTime() - startTime.getTime()) + "ms");
return ret;
};
}
};
// TODO: Integrate punch-through from old Engage implementation
function canonUrl(url) {
return url;
}
fluid.fetchResources.clearResourceCache = function (url) {
if (url) {
delete resourceCache[canonUrl(url)];
}
else {
fluid.clear(resourceCache);
}
};
/*
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.fetchResources.handleCachedRequest = function (resourceSpec, response, fetchError) {
var canon = canonUrl(resourceSpec.href);
var cached = resourceCache[canon];
if (cached.$$firer$$) {
fluid.log("Handling request for " + canon + " from cache");
var fetchClass = resourceSpec.fetchClass;
if (fetchClass && pendingClass[fetchClass]) {
fluid.log("Clearing pendingClass entry for class " + fetchClass);
delete pendingClass[fetchClass][canon];
}
var result = {response: response, fetchError: fetchError};
resourceCache[canon] = result;
cached.fire(response, fetchError);
}
};
/*
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.fetchResources.completeRequest = function (thisSpec) {
thisSpec.queued = false;
thisSpec.completeTime = new Date();
fluid.log("Request to URL " + thisSpec.href + " completed - total elapsed time: " +
(thisSpec.completeTime.getTime() - thisSpec.initTime.getTime()) + "ms");
thisSpec.recurseFirer.fire();
};
/*
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.fetchResources.makeResourceCallback = function (thisSpec) {
return {
success: function (response) {
thisSpec.resourceText = response;
thisSpec.resourceKey = thisSpec.href;
if (thisSpec.forceCache) {
fluid.fetchResources.handleCachedRequest(thisSpec, response);
}
fluid.fetchResources.completeRequest(thisSpec);
},
error: function (response, textStatus, errorThrown) {
thisSpec.fetchError = {
status: response.status,
textStatus: response.textStatus,
errorThrown: errorThrown
};
if (thisSpec.forceCache) {
fluid.fetchResources.handleCachedRequest(thisSpec, null, thisSpec.fetchError);
}
fluid.fetchResources.completeRequest(thisSpec);
}
};
};
/*
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.fetchResources.issueCachedRequest = function (resourceSpec, options) {
var canon = canonUrl(resourceSpec.href);
var cached = resourceCache[canon];
if (!cached) {
fluid.log("First request for cached resource with url " + canon);
cached = fluid.makeEventFirer({name: "cache notifier for resource URL " + canon});
cached.$$firer$$ = true;
resourceCache[canon] = cached;
var fetchClass = resourceSpec.fetchClass;
if (fetchClass) {
if (!pendingClass[fetchClass]) {
pendingClass[fetchClass] = {};
}
pendingClass[fetchClass][canon] = resourceSpec;
}
options.cache = false; // TODO: Getting weird "not modified" issues on Firefox
$.ajax(options);
}
else {
if (!cached.$$firer$$) {
if (cached.response) {
options.success(cached.response);
} else {
options.error(cached.fetchError);
}
}
else {
fluid.log("Request for cached resource which is in flight: url " + canon);
cached.addListener(function (response, fetchError) {
if (response) {
options.success(response);
} else {
options.error(fetchError);
}
});
}
}
};
/*
* This function is unsupported: It is not really intended for use by implementors.
*/
// Compose callbacks in such a way that the 2nd, marked "external" will be applied
// first if it exists, but in all cases, the first, marked internal, will be
// CALLED WITHOUT FAIL
fluid.fetchResources.composeCallbacks = function (internal, external) {
return external ? (internal ?
function () {
try {
external.apply(null, arguments);
}
catch (e) {
fluid.log("Exception applying external fetchResources callback: " + e);
}
internal.apply(null, arguments); // call the internal callback without fail
} : external ) : internal;
};
// unsupported, NON-API function
fluid.fetchResources.composePolicy = function (target, source) {
return fluid.fetchResources.composeCallbacks(target, source);
};
fluid.defaults("fluid.fetchResources.issueRequest", {
mergePolicy: {
success: fluid.fetchResources.composePolicy,
error: fluid.fetchResources.composePolicy,
url: "reverse"
}
});
// unsupported, NON-API function
fluid.fetchResources.issueRequest = function (resourceSpec, key) {
var thisCallback = fluid.fetchResources.makeResourceCallback(resourceSpec);
var options = {
url: resourceSpec.href,
success: thisCallback.success,
error: thisCallback.error,
dataType: resourceSpec.dataType || "text"
};
fluid.fetchResources.timeSuccessCallback(resourceSpec);
options = fluid.merge(fluid.defaults("fluid.fetchResources.issueRequest").mergePolicy,
options, resourceSpec.options);
resourceSpec.queued = true;
resourceSpec.initTime = new Date();
fluid.log("Request with key " + key + " queued for " + resourceSpec.href);
if (resourceSpec.forceCache) {
fluid.fetchResources.issueCachedRequest(resourceSpec, options);
}
else {
$.ajax(options);
}
};
fluid.fetchResources.fetchResourcesImpl = function (that) {
var complete = true;
var allSync = true;
var resourceSpecs = that.resourceSpecs;
for (var key in resourceSpecs) {
var resourceSpec = resourceSpecs[key];
if (!resourceSpec.options || resourceSpec.options.async) {
allSync = false;
}
if (resourceSpec.href && !resourceSpec.completeTime) {
if (!resourceSpec.queued) {
fluid.fetchResources.issueRequest(resourceSpec, key);
}
if (resourceSpec.queued) {
complete = false;
}
}
else if (resourceSpec.nodeId && !resourceSpec.resourceText) {
var node = document.getElementById(resourceSpec.nodeId);
// upgrade this to somehow detect whether node is "armoured" somehow
// with comment or CDATA wrapping
resourceSpec.resourceText = fluid.dom.getElementText(node);
resourceSpec.resourceKey = resourceSpec.nodeId;
}
}
if (complete && that.callback && !that.callbackCalled) {
that.callbackCalled = true;
if ($.browser.mozilla && !allSync) {
// Defer this callback to avoid debugging problems on Firefox
setTimeout(function () {
fluid.fetchResources.notifyResources(that, resourceSpecs, that.callback);
}, 1);
}
else {
fluid.fetchResources.notifyResources(that, resourceSpecs, that.callback);
}
}
};
// TODO: This framework function is a stop-gap before the "ginger world" is capable of
// asynchronous instantiation. It currently performs very poor fidelity expansion of a
// component's options to discover "resources" only held in the static environment
fluid.fetchResources.primeCacheFromResources = function (componentName) {
var resources = fluid.defaults(componentName).resources;
var expanded = (fluid.expandOptions ? fluid.expandOptions : fluid.identity)(fluid.copy(resources));
fluid.fetchResources(expanded);
};
/** Utilities invoking requests for expansion **/
fluid.registerNamespace("fluid.expander");
/*
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.expander.makeDefaultFetchOptions = function (successdisposer, failid, options) {
return $.extend(true, {dataType: "text"}, options, {
success: function (response, environmentdisposer) {
var json = JSON.parse(response);
environmentdisposer(successdisposer(json));
},
error: function (response, textStatus) {
fluid.log("Error fetching " + failid + ": " + textStatus);
}
});
};
/*
* This function is unsupported: It is not really intended for use by implementors.
*/
fluid.expander.makeFetchExpander = function (options) {
return { expander: {
type: "fluid.expander.deferredFetcher",
href: options.url,
options: fluid.expander.makeDefaultFetchOptions(options.disposer, options.url, options.options),
resourceSpecCollector: "{resourceSpecCollector}",
fetchKey: options.fetchKey
}};
};
fluid.expander.deferredFetcher = function (deliverer, source, expandOptions) {
var expander = source.expander;
var spec = fluid.copy(expander);
// fetch the "global" collector specified in the external environment to receive
// this resourceSpec
var collector = fluid.expand(expander.resourceSpecCollector, expandOptions);
delete spec.type;
delete spec.resourceSpecCollector;
delete spec.fetchKey;
var environmentdisposer = function (disposed) {
deliverer(disposed);
};
// replace the callback which is there (taking 2 arguments) with one which
// directly responds to the request, passing in the result and OUR "disposer" -
// which once the user has processed the response (say, parsing JSON and repackaging)
// finally deposits it in the place of the expander in the tree to which this reference
// has been stored at the point this expander was evaluated.
spec.options.success = function (response) {
expander.options.success(response, environmentdisposer);
};
var key = expander.fetchKey || fluid.allocateGuid();
collector[key] = spec;
return fluid.NO_VALUE;
};
})(jQuery, fluid_2_0_0);

693
lib/infusion/src/framework/core/js/FluidView.js

@ -0,0 +1,693 @@
/*
Copyright 2010-2011 Lucendo Development Ltd.
Copyright 2010-2016 OCAD University
Copyright 2012-2014 Raising the Floor - US
Copyright 2014-2016 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
/** This file contains functions which depend on the presence of a DOM document
* and which depend on the contents of Fluid.js **/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
fluid.defaults("fluid.viewComponent", {
gradeNames: ["fluid.modelComponent"],
initFunction: "fluid.initView",
argumentMap: {
container: 0,
options: 1
},
members: { // Used to allow early access to DOM binder via IoC, but to also avoid triggering evaluation of selectors
dom: "@expand:fluid.initDomBinder({that}, {that}.options.selectors)"
}
});
// unsupported, NON-API function
fluid.dumpSelector = function (selectable) {
return typeof (selectable) === "string" ? selectable :
selectable.selector ? selectable.selector : "";
};
// unsupported, NON-API function
// NOTE: this function represents a temporary strategy until we have more integrated IoC debugging.
// It preserves the 1.3 and previous framework behaviour for the 1.x releases, but provides a more informative
// diagnostic - in fact, it is perfectly acceptable for a component's creator to return no value and
// the failure is really in assumptions in fluid.initLittleComponent. Revisit this issue for 2.0
fluid.diagnoseFailedView = function (componentName, that, options, args) {
if (!that && fluid.hasGrade(options, "fluid.viewComponent")) {
var container = fluid.wrap(args[1]);
var message1 = "Instantiation of view component with type " + componentName + " failed, since ";
if (!container) {
fluid.fail(message1 + " container argument is empty");
}
else if (container.length === 0) {
fluid.fail(message1 + "selector \"", fluid.dumpSelector(args[1]), "\" did not match any markup in the document");
} else {
fluid.fail(message1 + " component creator function did not return a value");
}
}
};
fluid.checkTryCatchParameter = function () {
var location = window.location || { search: "", protocol: "file:" };
var GETparams = location.search.slice(1).split("&");
return fluid.find(GETparams, function (param) {
if (param.indexOf("notrycatch") === 0) {
return true;
}
}) === true;
};
fluid.notrycatch = fluid.checkTryCatchParameter();
/**
* Wraps an object in a jQuery if it isn't already one. This function is useful since
* it ensures to wrap a null or otherwise falsy argument to itself, rather than the
* often unhelpful jQuery default of returning the overall document node.
*
* @param {Object} obj the object to wrap in a jQuery
* @param {jQuery} userJQuery the jQuery object to use for the wrapping, optional - use the current jQuery if absent
*/
fluid.wrap = function (obj, userJQuery) {
userJQuery = userJQuery || $;
return ((!obj || obj.jquery) ? obj : userJQuery(obj));
};
/**
* If obj is a jQuery, this function will return the first DOM element within it. Otherwise, the object will be returned unchanged.
*
* @param {jQuery} obj the jQuery instance to unwrap into a pure DOM element
*/
fluid.unwrap = function (obj) {
return obj && obj.jquery ? obj[0] : obj;
};
/**
* Fetches a single container element and returns it as a jQuery.
*
* @param {String||jQuery||element} containerSpec an id string, a single-element jQuery, or a DOM element specifying a unique container
* @param {Boolean} fallible <code>true</code> if an empty container is to be reported as a valid condition
* @return a single-element jQuery of container
*/
fluid.container = function (containerSpec, fallible, userJQuery) {
var selector = containerSpec.selector || containerSpec;
if (userJQuery) {
containerSpec = fluid.unwrap(containerSpec);
}
var container = fluid.wrap(containerSpec, userJQuery);
if (fallible && (!container || container.length === 0)) {
return null;
}
if (!container || !container.jquery || container.length !== 1) {
if (typeof (containerSpec) !== "string") {
containerSpec = container.selector;
}
var count = container.length !== undefined ? container.length : 0;
fluid.fail((count > 1 ? "More than one (" + count + ") container elements were"
: "No container element was") + " found for selector " + containerSpec);
}
if (!fluid.isDOMNode(container[0])) {
fluid.fail("fluid.container was supplied a non-jQueryable element");
}
// To address FLUID-5966, manually adding back the selector and context properties that were removed from jQuery v3.0.
// ( see: https://jquery.com/upgrade-guide/3.0/#breaking-change-deprecated-context-and-selector-properties-removed )
// In most cases the "selector" property will already be restored through the DOM binder;
// however, when a selector or pure jQuery element is supplied directly as a component's container, we need to add them
// if it is possible to infer them. This feature is rarely used but is crucial for the prefs framework infrastructure
// in Panels.js fluid.prefs.subPanel.resetDomBinder
container.selector = selector;
container.context = container.context || containerSpec.ownerDocument || document;
return container;
};
/**
* Creates a new DOM Binder instance, used to locate elements in the DOM by name.
*
* @param {Object} container the root element in which to locate named elements
* @param {Object} selectors a collection of named jQuery selectors
*/
fluid.createDomBinder = function (container, selectors) {
// don't put on a typename to avoid confusing primitive visitComponentChildren
var that = {
id: fluid.allocateGuid(),
cache: {}
};
var userJQuery = container.constructor;
function cacheKey(name, thisContainer) {
return fluid.allocateSimpleId(thisContainer) + "-" + name;
}
function record(name, thisContainer, result) {
that.cache[cacheKey(name, thisContainer)] = result;
}
that.locate = function (name, localContainer) {
var selector, thisContainer, togo;
selector = selectors[name];
thisContainer = localContainer ? $(localContainer) : container;
if (!thisContainer) {
fluid.fail("DOM binder invoked for selector " + name + " without container");
}
if (selector === "") {
togo = thisContainer;
}
else if (!selector) {
togo = userJQuery();
}
else {
if (typeof (selector) === "function") {
togo = userJQuery(selector.call(null, fluid.unwrap(thisContainer)));
} else {
togo = userJQuery(selector, thisContainer);
}
}
if (!togo.selector) {
togo.selector = selector;
togo.context = thisContainer;
}
togo.selectorName = name;
record(name, thisContainer, togo);
return togo;
};
that.fastLocate = function (name, localContainer) {
var thisContainer = localContainer ? localContainer : container;
var key = cacheKey(name, thisContainer);
var togo = that.cache[key];
return togo ? togo : that.locate(name, localContainer);
};
that.clear = function () {
that.cache = {};
};
that.refresh = function (names, localContainer) {
var thisContainer = localContainer ? localContainer : container;
if (typeof names === "string") {
names = [names];
}
if (thisContainer.length === undefined) {
thisContainer = [thisContainer];
}
for (var i = 0; i < names.length; ++i) {
for (var j = 0; j < thisContainer.length; ++j) {
that.locate(names[i], thisContainer[j]);
}
}
};
that.resolvePathSegment = that.locate;
return that;
};
/** Expect that jQuery selector query has resulted in a non-empty set of
* results. If none are found, this function will fail with a diagnostic message,
* with the supplied message prepended.
*/
fluid.expectFilledSelector = function (result, message) {
if (result && result.length === 0 && result.jquery) {
fluid.fail(message + ": selector \"" + result.selector + "\" with name " + result.selectorName +
" returned no results in context " + fluid.dumpEl(result.context));
}
};
/**
* The central initialiation method called as the first act of every Fluid
* component. This function automatically merges user options with defaults,
* attaches a DOM Binder to the instance, and configures events.
*
* @param {String} componentName The unique "name" of the component, which will be used
* to fetch the default options from store. By recommendation, this should be the global
* name of the component's creator function.
* @param {jQueryable} container A specifier for the single root "container node" in the
* DOM which will house all the markup for this component.
* @param {Object} userOptions The configuration options for this component.
*/
// 4th argument is NOT SUPPORTED, see comments for initLittleComponent
fluid.initView = function (componentName, containerSpec, userOptions, localOptions) {
var container = fluid.container(containerSpec, true);
fluid.expectFilledSelector(container, "Error instantiating component with name \"" + componentName);
if (!container) {
return null;
}
// Need to ensure container is set early, without relying on an IoC mechanism - rethink this with asynchrony
var receiver = function (that) {
that.container = container;
};
var that = fluid.initLittleComponent(componentName, userOptions, localOptions || {gradeNames: ["fluid.viewComponent"]}, receiver);
if (!that.dom) {
fluid.initDomBinder(that);
}
// TODO: cannot afford a mutable container - put this into proper workflow
var userJQuery = that.options.jQuery; // Do it a second time to correct for jQuery injection
// if (userJQuery) {
// container = fluid.container(containerSpec, true, userJQuery);
// }
fluid.log("Constructing view component " + componentName + " with container " + container.constructor.expando +
(userJQuery ? " user jQuery " + userJQuery.expando : "") + " env: " + $.expando);
return that;
};
/**
* Creates a new DOM Binder instance for the specified component and mixes it in.
*
* @param {Object} that the component instance to attach the new DOM Binder to
*/
fluid.initDomBinder = function (that, selectors) {
if (!that.container) {
fluid.fail("fluid.initDomBinder called for component with typeName " + that.typeName +
" without an initialised container - this has probably resulted from placing \"fluid.viewComponent\" in incorrect position in grade merging order. " +
" Make sure to place it to the right of any non-view grades in the gradeNames list to ensure that it overrides properly: resolved gradeNames is ", that.options.gradeNames, " for component ", that);
}
that.dom = fluid.createDomBinder(that.container, selectors || that.options.selectors || {});
that.locate = that.dom.locate;
return that.dom;
};
// DOM Utilities.
/**
* Finds the nearest ancestor of the element that matches a predicate
* @param {Element} element DOM element
* @param {Function} test A function (predicate) accepting a DOM element, returning a truthy value representing a match
* @return The first element parent for which the predicate returns truthy - or undefined if no parent matches
*/
fluid.findAncestor = function (element, test) {
element = fluid.unwrap(element);
while (element) {
if (test(element)) {
return element;
}
element = element.parentNode;
}
};
fluid.findForm = function (node) {
return fluid.findAncestor(node, function (element) {
return element.nodeName.toLowerCase() === "form";
});
};
/** A utility with the same signature as jQuery.text and jQuery.html, but without the API irregularity
* that treats a single argument of undefined as different to no arguments */
// in jQuery 1.7.1, jQuery pulled the same dumb trick with $.text() that they did with $.val() previously,
// see comment in fluid.value below
fluid.each(["text", "html"], function (method) {
fluid[method] = function (node, newValue) {
node = $(node);
return newValue === undefined ? node[method]() : node[method](newValue);
};
});
/** A generalisation of jQuery.val to correctly handle the case of acquiring and
* setting the value of clustered radio button/checkbox sets, potentially, given
* a node corresponding to just one element.
*/
fluid.value = function (nodeIn, newValue) {
var node = fluid.unwrap(nodeIn);
var multiple = false;
if (node.nodeType === undefined && node.length > 1) {
node = node[0];
multiple = true;
}
if ("input" !== node.nodeName.toLowerCase() || !/radio|checkbox/.test(node.type)) {
// resist changes to contract of jQuery.val() in jQuery 1.5.1 (see FLUID-4113)
return newValue === undefined ? $(node).val() : $(node).val(newValue);
}
var name = node.name;
if (name === undefined) {
fluid.fail("Cannot acquire value from node " + fluid.dumpEl(node) + " which does not have name attribute set");
}
var elements;
if (multiple) {
elements = nodeIn;
} else {
elements = node.ownerDocument.getElementsByName(name);
var scope = fluid.findForm(node);
elements = $.grep(elements, function (element) {
if (element.name !== name) {
return false;
}
return !scope || fluid.dom.isContainer(scope, element);
});
}
if (newValue !== undefined) {
if (typeof(newValue) === "boolean") {
newValue = (newValue ? "true" : "false");
}
// jQuery gets this partially right, but when dealing with radio button array will
// set all of their values to "newValue" rather than setting the checked property
// of the corresponding control.
$.each(elements, function () {
this.checked = (newValue instanceof Array ?
newValue.indexOf(this.value) !== -1 : newValue === this.value);
});
} else { // this part jQuery will not do - extracting value from <input> array
var checked = $.map(elements, function (element) {
return element.checked ? element.value : null;
});
return node.type === "radio" ? checked[0] : checked;
}
};
fluid.BINDING_ROOT_KEY = "fluid-binding-root";
/** Recursively find any data stored under a given name from a node upwards
* in its DOM hierarchy **/
fluid.findData = function (elem, name) {
while (elem) {
var data = $.data(elem, name);
if (data) {
return data;
}
elem = elem.parentNode;
}
};
fluid.bindFossils = function (node, data, fossils) {
$.data(node, fluid.BINDING_ROOT_KEY, {data: data, fossils: fossils});
};
fluid.boundPathForNode = function (node, fossils) {
node = fluid.unwrap(node);
var key = node.name || node.id;
var record = fossils[key];
return record ? record.EL : null;
};
/** "Automatically" apply to whatever part of the data model is
* relevant, the changed value received at the given DOM node*/
fluid.applyBoundChange = function (node, newValue, applier) {
node = fluid.unwrap(node);
if (newValue === undefined) {
newValue = fluid.value(node);
}
if (node.nodeType === undefined && node.length > 0) {
node = node[0];
} // assume here that they share name and parent
var root = fluid.findData(node, fluid.BINDING_ROOT_KEY);
if (!root) {
fluid.fail("Bound data could not be discovered in any node above " + fluid.dumpEl(node));
}
var name = node.name;
var fossil = root.fossils[name];
if (!fossil) {
fluid.fail("No fossil discovered for name " + name + " in fossil record above " + fluid.dumpEl(node));
}
if (typeof(fossil.oldvalue) === "boolean") { // deal with the case of an "isolated checkbox"
newValue = newValue[0] ? true : false;
}
var EL = root.fossils[name].EL;
if (applier) {
applier.fireChangeRequest({path: EL, value: newValue, source: "DOM:" + node.id});
} else {
fluid.set(root.data, EL, newValue);
}
};
/**
* Returns a jQuery object given the id of a DOM node. In the case the element
* is not found, will return an empty list.
*/
fluid.jById = function (id, dokkument) {
dokkument = dokkument && dokkument.nodeType === 9 ? dokkument : document;
var element = fluid.byId(id, dokkument);
var togo = element ? $(element) : [];
togo.selector = "#" + id;
togo.context = dokkument;
return togo;
};
/**
* Returns an DOM element quickly, given an id
*
* @param {Object} id the id of the DOM node to find
* @param {Document} dokkument the document in which it is to be found (if left empty, use the current document)
* @return The DOM element with this id, or null, if none exists in the document.
*/
fluid.byId = function (id, dokkument) {
dokkument = dokkument && dokkument.nodeType === 9 ? dokkument : document;
var el = dokkument.getElementById(id);
if (el) {
// Use element id property here rather than attribute, to work around FLUID-3953
if (el.id !== id) {
fluid.fail("Problem in document structure - picked up element " +
fluid.dumpEl(el) + " for id " + id +
" without this id - most likely the element has a name which conflicts with this id");
}
return el;
} else {
return null;
}
};
/**
* Returns the id attribute from a jQuery or pure DOM element.
*
* @param {jQuery||Element} element the element to return the id attribute for
*/
fluid.getId = function (element) {
return fluid.unwrap(element).id;
};
/**
* Allocate an id to the supplied element if it has none already, by a simple
* scheme resulting in ids "fluid-id-nnnn" where nnnn is an increasing integer.
*/
fluid.allocateSimpleId = function (element) {
element = fluid.unwrap(element);
if (!element || fluid.isPrimitive(element)) {
return null;
}
if (!element.id) {
var simpleId = "fluid-id-" + fluid.allocateGuid();
element.id = simpleId;
}
return element.id;
};
/**
* Returns the document to which an element belongs, or the element itself if it is already a document
*
* @param {jQuery||Element} element The element to return the document for
* @return {Document} dokkument The document in which it is to be found
*/
fluid.getDocument = function (element) {
var node = fluid.unwrap(element);
// DOCUMENT_NODE - guide to node types at https://developer.mozilla.org/en/docs/Web/API/Node/nodeType
return node.nodeType === 9 ? node : node.ownerDocument;
};
fluid.defaults("fluid.ariaLabeller", {
gradeNames: ["fluid.viewComponent"],
labelAttribute: "aria-label",
liveRegionMarkup: "<div class=\"liveRegion fl-hidden-accessible\" aria-live=\"polite\"></div>",
liveRegionId: "fluid-ariaLabeller-liveRegion",
invokers: {
generateLiveElement: {
funcName: "fluid.ariaLabeller.generateLiveElement",
args: "{that}"
},
update: {
funcName: "fluid.ariaLabeller.update",
args: ["{that}", "{arguments}.0"]
}
},
listeners: {
onCreate: {
func: "{that}.update",
args: [null]
}
}
});
fluid.ariaLabeller.update = function (that, newOptions) {
newOptions = newOptions || that.options;
that.container.attr(that.options.labelAttribute, newOptions.text);
if (newOptions.dynamicLabel) {
var live = fluid.jById(that.options.liveRegionId);
if (live.length === 0) {
live = that.generateLiveElement();
}
live.text(newOptions.text);
}
};
fluid.ariaLabeller.generateLiveElement = function (that) {
var liveEl = $(that.options.liveRegionMarkup);
liveEl.prop("id", that.options.liveRegionId);
$("body").append(liveEl);
return liveEl;
};
var LABEL_KEY = "aria-labelling";
fluid.getAriaLabeller = function (element) {
element = $(element);
var that = fluid.getScopedData(element, LABEL_KEY);
return that;
};
/** Manages an ARIA-mediated label attached to a given DOM element. An
* aria-labelledby attribute and target node is fabricated in the document
* if they do not exist already, and a "little component" is returned exposing a method
* "update" that allows the text to be updated. */
fluid.updateAriaLabel = function (element, text, options) {
options = $.extend({}, options || {}, {text: text});
var that = fluid.getAriaLabeller(element);
if (!that) {
that = fluid.ariaLabeller(element, options);
fluid.setScopedData(element, LABEL_KEY, that);
} else {
that.update(options);
}
return that;
};
/** "Global Dismissal Handler" for the entire page. Attaches a click handler to the
* document root that will cause dismissal of any elements (typically dialogs) which
* have registered themselves. Dismissal through this route will automatically clean up
* the record - however, the dismisser themselves must take care to deregister in the case
* dismissal is triggered through the dialog interface itself. This component can also be
* automatically configured by fluid.deadMansBlur by means of the "cancelByDefault" option */
var dismissList = {};
$(document).click(function (event) {
var target = fluid.resolveEventTarget(event);
while (target) {
if (dismissList[target.id]) {
return;
}
target = target.parentNode;
}
fluid.each(dismissList, function (dismissFunc, key) {
dismissFunc(event);
delete dismissList[key];
});
});
// TODO: extend a configurable equivalent of the above dealing with "focusin" events
/** Accepts a free hash of nodes and an optional "dismissal function".
* If dismissFunc is set, this "arms" the dismissal system, such that when a click
* is received OUTSIDE any of the hierarchy covered by "nodes", the dismissal function
* will be executed.
*/
fluid.globalDismissal = function (nodes, dismissFunc) {
fluid.each(nodes, function (node) {
// Don't bother to use the real id if it is from a foreign document - we will never receive events
// from it directly in any case - and foreign documents may be under the control of malign fiends
// such as tinyMCE who allocate the same id to everything
var id = fluid.unwrap(node).ownerDocument === document ? fluid.allocateSimpleId(node) : fluid.allocateGuid();
if (dismissFunc) {
dismissList[id] = dismissFunc;
}
else {
delete dismissList[id];
}
});
};
/** Provides an abstraction for determing the current time.
* This is to provide a fix for FLUID-4762, where IE6 - IE8
* do not support Date.now().
*/
fluid.now = function () {
return Date.now ? Date.now() : (new Date()).getTime();
};
/** Sets an interation on a target control, which morally manages a "blur" for
* a possibly composite region.
* A timed blur listener is set on the control, which waits for a short period of
* time (options.delay, defaults to 150ms) to discover whether the reason for the
* blur interaction is that either a focus or click is being serviced on a nominated
* set of "exclusions" (options.exclusions, a free hash of elements or jQueries).
* If no such event is received within the window, options.handler will be called
* with the argument "control", to service whatever interaction is required of the
* blur.
*/
fluid.deadMansBlur = function (control, options) {
// TODO: This should be rewritten as a proper component
var that = {options: $.extend(true, {}, fluid.defaults("fluid.deadMansBlur"), options)};
that.blurPending = false;
that.lastCancel = 0;
that.canceller = function (event) {
fluid.log("Cancellation through " + event.type + " on " + fluid.dumpEl(event.target));
that.lastCancel = fluid.now();
that.blurPending = false;
};
that.noteProceeded = function () {
fluid.globalDismissal(that.options.exclusions);
};
that.reArm = function () {
fluid.globalDismissal(that.options.exclusions, that.proceed);
};
that.addExclusion = function (exclusions) {
fluid.globalDismissal(exclusions, that.proceed);
};
that.proceed = function (event) {
fluid.log("Direct proceed through " + event.type + " on " + fluid.dumpEl(event.target));
that.blurPending = false;
that.options.handler(control);
};
fluid.each(that.options.exclusions, function (exclusion) {
exclusion = $(exclusion);
fluid.each(exclusion, function (excludeEl) {
$(excludeEl).on("focusin", that.canceller).
on("fluid-focus", that.canceller).
click(that.canceller).mousedown(that.canceller);
// Mousedown is added for FLUID-4212, as a result of Chrome bug 6759, 14204
});
});
if (!that.options.cancelByDefault) {
$(control).on("focusout", function (event) {
fluid.log("Starting blur timer for element " + fluid.dumpEl(event.target));
var now = fluid.now();
fluid.log("back delay: " + (now - that.lastCancel));
if (now - that.lastCancel > that.options.backDelay) {
that.blurPending = true;
}
setTimeout(function () {
if (that.blurPending) {
that.options.handler(control);
}
}, that.options.delay);
});
}
else {
that.reArm();
}
return that;
};
fluid.defaults("fluid.deadMansBlur", {
gradeNames: "fluid.function",
delay: 150,
backDelay: 100
});
})(jQuery, fluid_2_0_0);

663
lib/infusion/src/framework/core/js/FluidViewDebugging.js

@ -0,0 +1,663 @@
/*
Copyright 2015 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
fluid.registerNamespace("fluid.debug");
fluid.debug.toggleClass = function (styles, element, openStyle, closedStyle, state) {
if (openStyle) {
element.toggleClass(styles[openStyle], state);
}
if (closedStyle) {
element.toggleClass(styles[closedStyle], !state);
}
};
fluid.debug.bindToggleClick = function (element, applier, path) {
element.click(function () {
var state = fluid.get(applier.holder.model, path);
applier.change(path, !state);
});
};
fluid.defaults("fluid.debug.highlighter", {
gradeNames: ["fluid.viewComponent"],
selectors: {
highlightRoot: "#fluid-debug-highlightRoot"
},
markup: {
highlightRoot: "<div id=\"fluid-debug-highlightRoot\" class=\"fluid-debug-highlightRoot\"></div>",
highlightElement: "<div class=\"fl-debug-highlightElement\"></div>"
},
events: {
highlightClick: null
},
listeners: {
onCreate: "fluid.debug.highlighter.renderRoot"
},
invokers: {
clear: "fluid.debug.highlighter.clear({that}.dom.highlightRoot)",
highlight: "fluid.debug.highlighter.highlight({that}, {that}.dom.highlightRoot, {arguments}.0)" // dispositions
}
});
fluid.debug.highlighter.renderRoot = function (that) {
var highlightRoot = $(that.options.markup.highlightRoot);
that.container.append(highlightRoot);
highlightRoot.click(that.events.highlightClick.fire);
};
fluid.debug.highlighter.clear = function (highlightRoot) {
highlightRoot.empty();
};
fluid.debug.highlighter.positionProps = ["width","height","marginLeft","marginTop","paddingLeft","paddingTop"];
fluid.debug.highlighter.colours = {
components: [
[0, 0, 0], // black
[255, 0, 0], // red
[255, 255, 0] // yellow
],
domBinder: [0, 255, 0], // green
renderer: [0, 255, 255] // cyan
};
fluid.debug.arrayToRGBA = function (array) {
return "rgba(" + array.join(", ") + ")";
};
fluid.debug.assignColour = function (colour, alpha) {
return [colour[0], colour[1], colour[2], alpha];
};
fluid.debug.highlighter.indexToColour = function (i, isDomBind, isRenderer) {
var a = fluid.debug.assignColour, c = fluid.debug.highlighter.colours.components;
var base;
if (isRenderer) {
base = a(fluid.debug.highlighter.colours.renderer, 0.5);
} else if (isDomBind) {
base = a(fluid.debug.highlighter.colours.domBinder, 0.5);
} else {
base = a(c[i % c.length], i > c.length ? 0.2 : 0.5);
}
return base;
};
fluid.debug.isRendererSelector = function (component, selectorName) {
var isRendererComponent = fluid.componentHasGrade(component, "fluid.rendererComponent");
var ignoreContains = fluid.contains(component.options.selectorsToIgnore, selectorName);
return isRendererComponent ? (!selectorName || ignoreContains ? false : true) : false;
};
fluid.debug.highlighter.disposeEntries = function (entries, domIds) {
return fluid.transform(entries, function (entry, i) {
var component = entry.component;
var container = component.container;
var element = fluid.jById(domIds[i], container[0].ownerDocument);
var selectorName = entry.selectorName;
var isRendererSelector = fluid.debug.isRendererSelector(component, selectorName);
var noHighlight = container.is("body");
return {
component: component,
container: element,
noHighlight: noHighlight,
selectorName: selectorName,
colour: fluid.debug.highlighter.indexToColour(i, selectorName, isRendererSelector)
};
});
};
fluid.debug.domIdtoHighlightId = function (domId) {
return "highlight-for:" + domId;
};
fluid.debug.highlighter.construct = function (markup, highlightRoot, container) {
var highlight = $(markup);
highlight.prop("id", fluid.debug.domIdtoHighlightId(container.prop("id")));
highlightRoot.append(highlight);
return highlight;
};
fluid.debug.highlighter.position = function (highlight, disp, container) {
var p = fluid.debug.highlighter.positionProps;
for (var j = 0; j < p.length; ++j) {
highlight.css(p[j], container.css(p[j] || ""));
}
var offset = container.offset();
var containerBody = container[0].ownerDocument.body;
if (containerBody !== document.body) { // TODO: This primitive algorithm will not account for nested iframes
offset.left -= $(containerBody).scrollLeft();
offset.top -= $(containerBody).scrollTop();
}
highlight.offset(offset);
};
fluid.debug.highlighter.highlight = function (that, highlightRoot, dispositions) {
for (var i = 0; i < dispositions.length; ++i) {
var disp = dispositions[i];
if (disp.noHighlight) {
continue;
}
var container = disp.container;
var highlight = fluid.debug.highlighter.construct(that.options.markup.highlightElement, highlightRoot, container);
highlight.css("background-color", fluid.debug.arrayToRGBA(disp.colour));
fluid.debug.highlighter.position(highlight, disp, container);
}
};
fluid.debug.ignorableGrades = ["fluid.debug.listeningView", "fluid.debug.listeningPanel", "fluid.debug.listeningRenderer"];
fluid.debug.frameworkGrades = fluid.frameworkGrades;
fluid.debug.filterGrades = function (gradeNames) {
var highestFrameworkIndex = -1;
var output = [];
fluid.each(gradeNames, function (gradeName) { // TODO: remove fluid.indexOf
var findex = fluid.debug.frameworkGrades.indexOf(gradeName);
if (findex > highestFrameworkIndex) {
highestFrameworkIndex = findex;
} else if (findex === -1 && fluid.debug.ignorableGrades.indexOf(gradeName) === -1 && gradeName.indexOf("{") === -1) {
output.push(gradeName);
}
});
output.push(fluid.debug.frameworkGrades[highestFrameworkIndex]);
return output;
};
fluid.debug.renderDefaults = function (defaultsTemplate, typeName, options) {
return fluid.stringTemplate(defaultsTemplate, {
typeName: typeName,
options: JSON.stringify(options, null, 4)
});
};
fluid.debug.renderSelectorUsageRecurse = function (source, segs, options) {
if (fluid.isPrimitive(source)) {
if (typeof(source) === "string" && source.indexOf(options.findString) !== -1) {
var path = segs.slice(0, 2);
var usage = fluid.copy(fluid.get(options.fullSource, path));
fluid.set(options.target, path, usage);
}
} else if (fluid.isPlainObject(source)) {
fluid.each(source, function (value, key) {
segs.push(key);
fluid.debug.renderSelectorUsageRecurse(source[key], segs, options);
segs.pop(key);
});
}
};
fluid.debug.renderSelectorUsage = function (selectorUsageTemplate, selectorName, options) {
var target = {}, segs = [], findString = "}.dom." + selectorName;
fluid.debug.renderSelectorUsageRecurse(options, segs, {
findString: findString,
target: target,
fullSource: options
});
var markup = fluid.stringTemplate(selectorUsageTemplate, {selectorUsage: JSON.stringify(target, null, 4)});
return markup;
};
fluid.debug.renderIndexElement = function (indexElTemplate, colour) {
return fluid.stringTemplate(indexElTemplate, {colour: fluid.debug.arrayToRGBA(colour)});
};
fluid.debug.domIdtoRowId = function (domId) {
return "row-for:" + domId;
};
fluid.debug.rowForDomId = function (row, indexElTemplate, disp, rowIdToDomId) {
row.indexEl = fluid.debug.renderIndexElement(indexElTemplate, disp.colour);
row.domId = disp.container.prop("id");
row.rowId = fluid.debug.domIdtoRowId(row.domId);
rowIdToDomId[row.rowId] = row.domId;
};
fluid.debug.renderSelectorUsageRows = function (disp, markup, defaultsIdToContent) {
var tooltipTriggerId = fluid.allocateGuid();
var options = disp.component.options;
defaultsIdToContent[tooltipTriggerId] = fluid.debug.renderSelectorUsage(markup.selectorUsage, disp.selectorName, options);
var rows = [{
componentId: "",
extraTooltipClass: "flc-debug-tooltip-trigger",
extraGradesClass: "fl-debug-selector-cell",
grade: options.selectors[disp.selectorName],
line: disp.selectorName,
tooltipTriggerId: tooltipTriggerId
}];
return rows;
};
fluid.debug.renderDefaultsRows = function (oneGrade, markup, defaultsIdToContent) {
var defaults = fluid.defaultsStore[oneGrade];
var line = defaults && defaults.callerInfo ? defaults.callerInfo.filename + ":" + defaults.callerInfo.index : "";
// horrible mixture of semantic levels in this rendering function - don't we need a new renderer!
var extraTooltipClass = "";
var tooltipTriggerId = fluid.allocateGuid();
if (line) {
extraTooltipClass = "flc-debug-tooltip-trigger";
defaultsIdToContent[tooltipTriggerId] = fluid.debug.renderDefaults(markup.defaults, oneGrade, defaults.options);
}
return {
rowId: fluid.allocateGuid(),
indexEl: "",
domId: "",
componentId: "",
grade: oneGrade,
line: line,
extraGradesClass: "",
extraTooltipClass: extraTooltipClass,
tooltipTriggerId: tooltipTriggerId
};
};
fluid.debug.renderOneDisposition = function (disp, markup, defaultsIdToContent, rowIdToDomId) {
var rows;
if (disp.selectorName) {
rows = fluid.debug.renderSelectorUsageRows(disp, markup, defaultsIdToContent);
} else {
var filtered = fluid.debug.filterGrades(disp.component.options.gradeNames);
rows = fluid.transform(filtered, function (oneGrade) {
return fluid.debug.renderDefaultsRows(oneGrade, markup, defaultsIdToContent);
});
rows[0].componentId = disp.component.id;
}
fluid.debug.rowForDomId(rows[0], markup.indexElement, disp, rowIdToDomId);
return rows;
};
fluid.debug.renderInspecting = function (that, paneBody, markup, inspecting) {
if (!paneBody || !that.highlighter) { // stupid ginger world failure
return;
}
var defaultsIdToContent = {}; // driver for tooltips showing defaults source
paneBody.empty();
that.highlighter.clear();
var ids = fluid.keys(inspecting).reverse(); // TODO: more principled ordering
var entries = fluid.transform(ids, function (inspectingId) {
return that.viewMapper.domIdToEntry[inspectingId];
});
var dispositions = fluid.debug.highlighter.disposeEntries(entries, ids);
var rowIdToDomId = {};
var allRows = fluid.transform(dispositions, function (disp) {
return fluid.debug.renderOneDisposition(disp, markup, defaultsIdToContent, rowIdToDomId);
});
var flatRows = fluid.flatten(allRows);
var contents = fluid.transform(flatRows, function (row) {
return fluid.stringTemplate(markup.paneRow, row);
});
paneBody.html(contents.join(""));
that.highlighter.highlight(dispositions);
that.tooltips.applier.change("idToContent", defaultsIdToContent);
that.rowIdToDomId = rowIdToDomId;
that.dispositions = dispositions; // currently for looking up colour
var initSelection = fluid.arrayToHash(fluid.values(rowIdToDomId));
that.applier.change("highlightSelected", initSelection);
};
fluid.defaults("fluid.debug.browser", {
gradeNames: ["fluid.viewComponent"],
model: {
isOpen: false,
isInspecting: false,
isFrozen: false,
inspecting: {},
highlightSelected: {}
},
members: {
rowIdToDomId: {}
},
modelListeners: {
isOpen: {
funcName: "fluid.debug.toggleClass",
args: ["{that}.options.styles", "{that}.dom.holder", "holderOpen", "holderClosed", "{change}.value"]
},
isInspecting: [{
funcName: "fluid.debug.toggleClass",
args: ["{that}.options.styles", "{that}.dom.inspectTrigger", "inspecting", null, "{change}.value"]
}, {
funcName: "fluid.debug.browser.finishInspecting",
args: ["{that}", "{change}.value"]
}],
inspecting: {
funcName: "fluid.debug.renderInspecting",
args: ["{that}", "{that}.dom.paneBody", "{that}.options.markup", "{change}.value"]
},
"highlightSelected.*": {
funcName: "fluid.debug.renderHighlightSelection",
args: ["{that}", "{change}.value", "{change}.path"]
}
},
styles: {
holderOpen: "fl-debug-holder-open",
holderClosed: "fl-debug-holder-closed",
inspecting: "fl-debug-inspect-active"
},
markup: {
holder: "<div class=\"flc-debug-holder fl-debug-holder\"><div class=\"flc-debug-open-pane-trigger fl-debug-open-pane-trigger\"></div><div class=\"flc-debug-pane fl-debug-pane\"><div class=\"flc-debug-inspect-trigger fl-debug-inspect-trigger\"></div></div></div>",
pane: "<table><thead><tr><td class=\"fl-debug-pane-index\"></td><td class=\"fl-debug-pane-dom-id\">DOM ID</td><td class=\"fl-debug-pane-component-id\">Component ID</td><td class=\"fl-debug-pane-grades\">Grades / Selector</td><td class=\"fl-debug-pane-line\">Line / Selector name</td></tr></thead><tbody class=\"flc-debug-pane-body\"></tbody></table>",
paneRow: "<tr class=\"flc-debug-pane-row\" id=\"%rowId\"><td class=\"fl-debug-pane-index\">%indexEl</td><td class=\"flc-debug-dom-id\">%domId</td><td class=\"flc-debug-component-id\">%componentId</td><td class=\"flc-debug-pane-grades %extraGradesClass\">%grade</td><td class=\"flc-debug-pane-line %extraTooltipClass\" id=\"%tooltipTriggerId\">%line</td></tr>",
indexElement: "<div class=\"flc-debug-pane-indexel\" style=\"background-color: %colour\"></div>",
defaults: "<pre>fluid.defaults(\"%typeName\", %options);\n</pre>",
selectorUsage: "<pre>%selectorUsage</pre>"
},
selectors: {
openPaneTrigger: ".flc-debug-open-pane-trigger",
inspectTrigger: ".flc-debug-inspect-trigger",
holder: ".fl-debug-holder",
pane: ".fl-debug-pane",
paneBody: ".flc-debug-pane-body",
indexEl: ".flc-debug-pane-indexel",
row: ".flc-debug-pane-row"
},
events: {
onNewDocument: null,
onMarkupReady: null,
highlightClick: null
},
listeners: {
"onCreate.render": {
priority: "first",
funcName: "fluid.debug.browser.renderMarkup",
args: ["{that}", "{that}.options.markup.holder", "{that}.options.markup.pane"]
},
"onCreate.toggleTabClick": {
funcName: "fluid.debug.bindToggleClick",
args: ["{that}.dom.openPaneTrigger", "{that}.applier", "isOpen"]
},
"onCreate.toggleInspectClick": {
funcName: "fluid.debug.bindToggleClick",
args: ["{that}.dom.inspectTrigger", "{that}.applier", "isInspecting"]
},
"onCreate.bindHighlightSelection": {
funcName: "fluid.debug.browser.bindHighlightSelection",
args: ["{that}", "{that}.dom.pane"]
},
"onNewDocument.bindHover": {
funcName: "fluid.debug.browser.bindHover",
args: ["{that}", "{arguments}.0"]
},
"onNewDocument.bindHighlightClick": {
funcName: "fluid.debug.browser.bindHighlightClick",
args: ["{that}", "{arguments}.0"]
},
highlightClick: {
funcName: "fluid.debug.browser.highlightClick",
args: "{that}"
}
},
components: {
tooltips: {
createOnEvent: "onMarkupReady",
type: "fluid.tooltip",
container: "{browser}.dom.pane",
options: {
items: ".flc-debug-tooltip-trigger",
styles: {
tooltip: "fl-debug-tooltip"
},
position: {
my: "right center",
at: "left center"
},
duration: 0,
delay: 0
}
},
viewMapper: {
type: "fluid.debug.viewMapper",
options: {
events: {
onNewDocument: "{fluid.debug.browser}.events.onNewDocument"
}
}
},
highlighter: {
type: "fluid.debug.highlighter",
container: "{fluid.debug.browser}.container",
options: {
events: {
highlightClick: "{browser}.events.highlightClick"
}
}
}
}
});
fluid.debug.browser.finishInspecting = function (that, isInspecting) {
if (!isInspecting) {
var ation = that.applier.initiate();
ation.change("inspecting", null, "DELETE"); // TODO - reform this terrible API through FLUID-5373
ation.change("", {
"inspecting": {}
});
ation.change("isFrozen", false);
ation.commit();
}
};
// go into frozen state if we are not in it and are inspecting.
// if we are already frozen, finish inspecting (which will also finish frozen)
fluid.debug.browser.highlightClick = function (that) {
if (that.model.isFrozen) {
that.applier.change("isInspecting", false);
} else if (that.model.isInspecting) {
that.applier.change("isFrozen", true);
}
};
fluid.debug.browser.renderMarkup = function (that, holderMarkup, paneMarkup) {
that.container.append(holderMarkup);
var debugPane = that.locate("pane");
debugPane.append(paneMarkup);
that.events.onMarkupReady.fire();
};
fluid.debug.browser.domIdForElement = function (rowIdToDomId, rowSelector, element) {
var row = $(element).closest(rowSelector);
if (row.length > 0) {
var rowId = row[0].id;
return rowIdToDomId[rowId];
}
};
fluid.debug.browser.bindHighlightSelection = function (that, pane) {
pane.on("click", that.options.selectors.indexEl, function (evt) {
var domId = fluid.debug.browser.domIdForElement(that.rowIdToDomId, that.options.selectors.row, evt.target);
var path = ["highlightSelected", domId];
that.applier.change(path, !fluid.get(that.model, path));
});
};
fluid.debug.renderHighlightSelection = function (that, newState, path) {
var domId = path[1];
var disposition = fluid.find_if(that.dispositions, function (disp) {
return disp.container.prop("id") === domId;
});
if (disposition.noHighlight) {
return;
}
var outColour = fluid.copy(disposition.colour);
outColour[3] = outColour[3] * (newState ? 1.0 : 0.1);
var colourString = fluid.debug.arrayToRGBA(outColour);
var row = fluid.jById(fluid.debug.domIdtoRowId(domId));
$(that.options.selectors.indexEl, row).css("background-color", colourString);
fluid.jById(fluid.debug.domIdtoHighlightId(domId)).css("background-color", colourString);
};
fluid.debug.browser.bindHighlightClick = function (that, dokkument) {
// We have a global problem in that we can't accept pointer events on the highlight elements
// themselves since this will cause their own mouseenter/mouseleave events to self-block.
dokkument.on("mousedown", "*", function (evt) {
var target = $(evt.target);
var holderParents = target.parents(that.options.selectors.holder);
if (holderParents.length > 0) {
return;
}
if (that.model.isInspecting) {
that.events.highlightClick.fire();
return false;
}
});
};
fluid.debug.browser.bindHover = function (that, dokkument) {
var listener = function (event) {
if (!that.model.isInspecting || that.model.isFrozen) {
return;
}
var allParents = $(event.target).parents().addBack().get();
for (var i = 0; i < allParents.length; ++i) {
var id = allParents[i].id;
var entry = that.viewMapper.domIdToEntry[id];
if (entry) {
if (event.type === "mouseleave") {
that.applier.change(["inspecting", id], null, "DELETE");
} else if (event.type === "mouseenter") {
that.applier.change(["inspecting", id], true);
}
}
}
};
dokkument.on("mouseenter mouseleave", "*", listener);
};
fluid.defaults("fluid.debug.listeningView", {
listeners: {
onCreate: {
funcName: "fluid.debug.viewMapper.registerView",
args: ["{fluid.debug.viewMapper}", "{that}", "add"]
},
onDestroy: {
funcName: "fluid.debug.viewMapper.registerView",
args: ["{fluid.debug.viewMapper}", "{that}", "remove"]
}
}
});
fluid.defaults("fluid.debug.listeningPanel", {
listeners: {
onDomBind: {
funcName: "fluid.debug.viewMapper.registerView",
args: ["{fluid.debug.viewMapper}", "{that}", "rebind"]
}
}
});
fluid.defaults("fluid.debug.listeningRenderer", {
listeners: {
afterRender: {
funcName: "fluid.debug.viewMapper.registerView",
args: ["{fluid.debug.viewMapper}", "{that}", "rebind"]
}
}
});
fluid.defaults("fluid.debug.viewMapper", {
gradeNames: ["fluid.component", "fluid.resolveRoot"],
members: {
seenDocuments: {},
idToEntry: {},
domIdToEntry: {}
},
distributeOptions: [{
record: "fluid.debug.listeningView",
target: "{/ fluid.viewComponent}.options.gradeNames"
}, {
record: "fluid.debug.listeningPanel",
target: "{/ fluid.prefs.panel}.options.gradeNames"
}, {
record: "fluid.debug.listeningRenderer",
target: "{/ fluid.rendererComponent}.options.gradeNames"
}],
events: {
onNewDocument: null
},
listeners: {
onCreate: {
funcName: "fluid.debug.viewMapper.scanInit"
}
}
});
fluid.debug.viewMapper.registerComponent = function (that, component, containerId) {
var domBound = fluid.transform(component.options.selectors, function (selector, selectorName) {
return fluid.allocateSimpleId(component.locate(selectorName));
});
var entry = {
component: component,
containerId: containerId,
domBound: domBound
};
that.idToEntry[component.id] = entry;
if (containerId) {
that.domIdToEntry[containerId] = entry;
fluid.each(domBound, function (subId, selectorName) {
var subEntry = $.extend({}, entry);
subEntry.selectorName = selectorName;
that.domIdToEntry[subId] = subEntry;
});
}
};
fluid.debug.viewMapper.deregisterComponent = function (that, id) {
var entry = that.idToEntry[id];
delete that.idToEntry[id];
delete that.domIdToEntry[entry.containerId];
fluid.each(entry.domBound, function (subId) {
delete that.domIdToEntry[subId];
});
};
fluid.debug.viewMapper.registerView = function (that, component, action) {
var id = component.id;
var containerId = fluid.allocateSimpleId(component.container);
if (containerId) {
var dokkument = $(component.container[0].ownerDocument);
var dokkumentId = fluid.allocateSimpleId(dokkument);
if (!that.seenDocuments[dokkumentId]) {
that.seenDocuments[dokkumentId] = true;
that.events.onNewDocument.fire(dokkument);
}
}
if (action === "add") {
fluid.debug.viewMapper.registerComponent(that, component, containerId);
} else if (action === "remove") {
fluid.debug.viewMapper.deregisterComponent(that, id);
} else if (action === "rebind") {
fluid.debug.viewMapper.deregisterComponent(that, id);
fluid.debug.viewMapper.registerComponent(that, component, containerId);
}
};
fluid.debug.viewMapper.scanInit = function (that) {
var views = fluid.queryIoCSelector(fluid.rootComponent, "fluid.viewComponent");
for (var i = 0; i < views.length; ++i) {
fluid.debug.viewMapper.registerView(that, views[i], true);
}
};
$(document).ready(function () {
fluid.debug.browser("body");
});
})(jQuery, fluid_2_0_0);

117
lib/infusion/src/framework/core/js/JavaProperties.js

@ -0,0 +1,117 @@
/*
Copyright 2008-2010 University of Cambridge
Copyright 2008-2009 University of Toronto
Copyright 2010 Lucendo Development Ltd.
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
var unUnicode = /(\\u[\dabcdef]{4}|\\x[\dabcdef]{2})/g;
fluid.unescapeProperties = function (string) {
string = string.replace(unUnicode, function (match) {
var code = match.substring(2);
var parsed = parseInt(code, 16);
return String.fromCharCode(parsed);
});
var pos = 0;
while (true) {
var backpos = string.indexOf("\\", pos);
if (backpos === -1) {
break;
}
if (backpos === string.length - 1) {
return [string.substring(0, string.length - 1), true];
}
var replace = string.charAt(backpos + 1);
if (replace === "n") { replace = "\n"; }
if (replace === "r") { replace = "\r"; }
if (replace === "t") { replace = "\t"; }
string = string.substring(0, backpos) + replace + string.substring(backpos + 2);
pos = backpos + 1;
}
return [string, false];
};
var breakPos = /[^\\][\s:=]/;
fluid.parseJavaProperties = function (text) {
// File format described at http://java.sun.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader)
var togo = {};
text = text.replace(/\r\n/g, "\n");
text = text.replace(/\r/g, "\n");
var lines = text.split("\n");
var contin, key, valueComp, valueRaw, valueEsc;
for (var i = 0; i < lines.length; ++i) {
var line = $.trim(lines[i]);
if (!line || line.charAt(0) === "#" || line.charAt(0) === "!") {
continue;
}
if (!contin) {
valueComp = "";
var breakpos = line.search(breakPos);
if (breakpos === -1) {
key = line;
valueRaw = "";
}
else {
key = $.trim(line.substring(0, breakpos + 1)); // +1 since first char is escape exclusion
valueRaw = $.trim(line.substring(breakpos + 2));
if (valueRaw.charAt(0) === ":" || valueRaw.charAt(0) === "=") {
valueRaw = $.trim(valueRaw.substring(1));
}
}
key = fluid.unescapeProperties(key)[0];
valueEsc = fluid.unescapeProperties(valueRaw);
}
else {
valueEsc = fluid.unescapeProperties(line);
}
contin = valueEsc[1];
if (!valueEsc[1]) { // this line was not a continuation line - store the value
togo[key] = valueComp + valueEsc[0];
}
else {
valueComp += valueEsc[0];
}
}
return togo;
};
/**
* Expand a message string with respect to a set of arguments, following a basic
* subset of the Java MessageFormat rules.
* http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html
*
* The message string is expected to contain replacement specifications such
* as {0}, {1}, {2}, etc.
* @param messageString {String} The message key to be expanded
* @param args {String/Array of String} An array of arguments to be substituted into the message.
* @return The expanded message string.
*/
fluid.formatMessage = function (messageString, args) {
if (!args) {
return messageString;
}
if (typeof(args) === "string") {
args = [args];
}
for (var i = 0; i < args.length; ++i) {
messageString = messageString.replace("{" + i + "}", args[i]);
}
return messageString;
};
})(jQuery, fluid_2_0_0);

675
lib/infusion/src/framework/core/js/ModelTransformation.js

@ -0,0 +1,675 @@
/*
Copyright 2010 University of Toronto
Copyright 2010-2014 OCAD University
Copyright 2012-2014 Raising the Floor - US
Copyright 2014-2016 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
var fluid = fluid || fluid_2_0_0;
(function ($, fluid) {
"use strict";
fluid.registerNamespace("fluid.model.transform");
/** Grade definitions for standard transformation function hierarchy **/
fluid.defaults("fluid.transformFunction", {
gradeNames: "fluid.function"
});
// uses standard layout and workflow involving inputPath - an undefined input value
// will short-circuit the evaluation
fluid.defaults("fluid.standardInputTransformFunction", {
gradeNames: "fluid.transformFunction"
});
fluid.defaults("fluid.standardOutputTransformFunction", {
gradeNames: "fluid.transformFunction"
});
// defines a set of options "inputVariables" referring to its inputs, which are converted
// to functions that the transform may explicitly use to demand the input value
fluid.defaults("fluid.multiInputTransformFunction", {
gradeNames: "fluid.transformFunction"
});
// uses the standard layout and workflow involving inputPath and outputPath
fluid.defaults("fluid.standardTransformFunction", {
gradeNames: ["fluid.standardInputTransformFunction", "fluid.standardOutputTransformFunction"]
});
fluid.defaults("fluid.lens", {
gradeNames: "fluid.transformFunction",
invertConfiguration: null
// this function method returns "inverted configuration" rather than actually performing inversion
// TODO: harmonise with strategy used in VideoPlayer_framework.js
});
/***********************************
* Base utilities for transformers *
***********************************/
// unsupported, NON-API function
fluid.model.transform.pathToRule = function (inputPath) {
return {
transform: {
type: "fluid.transforms.value",
inputPath: inputPath
}
};
};
// unsupported, NON-API function
fluid.model.transform.literalValueToRule = function (input) {
return {
transform: {
type: "fluid.transforms.literalValue",
input: input
}
};
};
/** Accepts two fully escaped paths, either of which may be empty or null **/
fluid.model.composePaths = function (prefix, suffix) {
prefix = prefix === 0 ? "0" : prefix || "";
suffix = suffix === 0 ? "0" : suffix || "";
return !prefix ? suffix : (!suffix ? prefix : prefix + "." + suffix);
};
fluid.model.transform.accumulateInputPath = function (inputPath, transformer, paths) {
if (inputPath !== undefined) {
paths.push(fluid.model.composePaths(transformer.inputPrefix, inputPath));
}
};
fluid.model.transform.accumulateStandardInputPath = function (input, transformSpec, transformer, paths) {
fluid.model.transform.getValue(undefined, transformSpec[input], transformer);
fluid.model.transform.accumulateInputPath(transformSpec[input + "Path"], transformer, paths);
};
fluid.model.transform.accumulateMultiInputPaths = function (inputVariables, transformSpec, transformer, paths) {
fluid.each(inputVariables, function (v, k) {
fluid.model.transform.accumulateStandardInputPath(k, transformSpec, transformer, paths);
});
};
fluid.model.transform.getValue = function (inputPath, value, transformer) {
var togo;
if (inputPath !== undefined) { // NB: We may one day want to reverse the crazy jQuery-like convention that "no path means root path"
togo = fluid.get(transformer.source, fluid.model.composePaths(transformer.inputPrefix, inputPath), transformer.resolverGetConfig);
}
if (togo === undefined) {
// FLUID-5867 - actually helpful behaviour here rather than the insane original default of expecting a short-form value document
togo = fluid.isPrimitive(value) ? value :
("literalValue" in value ? value.literalValue :
(value.transform === undefined ? value : transformer.expand(value)));
}
return togo;
};
// distinguished value which indicates that a transformation rule supplied a
// non-default output path, and so the user should be prevented from making use of it
// in a compound transform definition
fluid.model.transform.NONDEFAULT_OUTPUT_PATH_RETURN = {};
fluid.model.transform.setValue = function (userOutputPath, value, transformer) {
// avoid crosslinking to input object - this might be controlled by a "nocopy" option in future
var toset = fluid.copy(value);
var outputPath = fluid.model.composePaths(transformer.outputPrefix, userOutputPath);
// TODO: custom resolver config here to create non-hash output model structure
if (toset !== undefined) {
transformer.applier.change(outputPath, toset);
}
return userOutputPath ? fluid.model.transform.NONDEFAULT_OUTPUT_PATH_RETURN : toset;
};
/* Resolves the <key> given as parameter by looking up the path <key>Path in the object
* to be transformed. If not present, it resolves the <key> by using the literal value if primitive,
* or expanding otherwise. <def> defines the default value if unableto resolve the key. If no
* default value is given undefined is returned
*/
fluid.model.transform.resolveParam = function (transformSpec, transformer, key, def) {
var val = fluid.model.transform.getValue(transformSpec[key + "Path"], transformSpec[key], transformer);
return (val !== undefined) ? val : def;
};
// Compute a "match score" between two pieces of model material, with 0 indicating a complete mismatch, and
// higher values indicating increasingly good matches
fluid.model.transform.matchValue = function (expected, actual, partialMatches) {
var stats = {changes: 0, unchanged: 0, changeMap: {}};
fluid.model.diff(expected, actual, stats);
// i) a pair with 0 matches counts for 0 in all cases
// ii) without "partial match mode" (the default), we simply count matches, with any mismatch giving 0
// iii) with "partial match mode", a "perfect score" in the top 24 bits is
// penalised for each mismatch, with a positive score of matches store in the bottom 24 bits
return stats.unchanged === 0 ? 0
: (partialMatches ? 0xffffff000000 - 0x1000000 * stats.changes + stats.unchanged :
(stats.changes ? 0 : 0xffffff000000 + stats.unchanged));
};
fluid.model.transform.invertPaths = function (transformSpec, transformer) {
// TODO: this will not behave correctly in the face of compound "input" which contains
// further transforms
var oldOutput = fluid.model.composePaths(transformer.outputPrefix, transformSpec.outputPath);
transformSpec.outputPath = fluid.model.composePaths(transformer.inputPrefix, transformSpec.inputPath);
transformSpec.inputPath = oldOutput;
return transformSpec;
};
// TODO: prefixApplier is a transform which is currently unused and untested
fluid.model.transform.prefixApplier = function (transformSpec, transformer) {
if (transformSpec.inputPrefix) {
transformer.inputPrefixOp.push(transformSpec.inputPrefix);
}
if (transformSpec.outputPrefix) {
transformer.outputPrefixOp.push(transformSpec.outputPrefix);
}
transformer.expand(transformSpec.input);
if (transformSpec.inputPrefix) {
transformer.inputPrefixOp.pop();
}
if (transformSpec.outputPrefix) {
transformer.outputPrefixOp.pop();
}
};
fluid.defaults("fluid.model.transform.prefixApplier", {
gradeNames: ["fluid.transformFunction"]
});
// unsupported, NON-API function
fluid.model.makePathStack = function (transform, prefixName) {
var stack = transform[prefixName + "Stack"] = [];
transform[prefixName] = "";
return {
push: function (prefix) {
var newPath = fluid.model.composePaths(transform[prefixName], prefix);
stack.push(transform[prefixName]);
transform[prefixName] = newPath;
},
pop: function () {
transform[prefixName] = stack.pop();
}
};
};
// unsupported, NON-API function
fluid.model.transform.doTransform = function (transformSpec, transformer, transformOpts) {
var expdef = transformOpts.defaults;
var transformFn = fluid.getGlobalValue(transformOpts.typeName);
if (typeof(transformFn) !== "function") {
fluid.fail("Transformation record specifies transformation function with name " +
transformSpec.type + " which is not a function - ", transformFn);
}
if (!fluid.hasGrade(expdef, "fluid.transformFunction")) {
// If no suitable grade is set up, assume that it is intended to be used as a standardTransformFunction
expdef = fluid.defaults("fluid.standardTransformFunction");
}
var transformArgs = [transformSpec, transformer];
if (fluid.hasGrade(expdef, "fluid.multiInputTransformFunction")) {
var inputs = {};
fluid.each(expdef.inputVariables, function (v, k) {
inputs[k] = function () {
var input = fluid.model.transform.getValue(transformSpec[k + "Path"], transformSpec[k], transformer);
// TODO: This is a mess, null might perfectly well be a possible default
// if no match, assign default if one exists (v != null)
input = (input === undefined && v !== null) ? v : input;
return input;
};
});
transformArgs.unshift(inputs);
}
if (fluid.hasGrade(expdef, "fluid.standardInputTransformFunction")) {
if (!("input" in transformSpec) && !("inputPath" in transformSpec)) {
fluid.fail("Error in transform specification. Either \"input\" or \"inputPath\" must be specified for a standardInputTransformFunction: received ", transformSpec);
}
var expanded = fluid.model.transform.getValue(transformSpec.inputPath, transformSpec.input, transformer);
transformArgs.unshift(expanded);
// if the function has no input, the result is considered undefined, and this is returned
if (expanded === undefined) {
return undefined;
}
}
var transformed = transformFn.apply(null, transformArgs);
if (fluid.hasGrade(expdef, "fluid.standardOutputTransformFunction")) {
// "doOutput" flag is currently set nowhere, but could be used in future
var outputPath = transformSpec.outputPath !== undefined ? transformSpec.outputPath : (transformOpts.doOutput ? "" : undefined);
if (outputPath !== undefined && transformed !== undefined) {
//If outputPath is given in the expander we want to:
// (1) output to the document
// (2) return undefined, to ensure that expanders higher up in the hierarchy doesn't attempt to output it again
fluid.model.transform.setValue(transformSpec.outputPath, transformed, transformer);
transformed = undefined;
}
}
return transformed;
};
// OLD PATHUTIL utilities: Rescued from old DataBinding implementation to support obsolete "schema" scheme for transforms - all of this needs to be rethought
var globalAccept = [];
fluid.registerNamespace("fluid.pathUtil");
/** Parses a path segment, following escaping rules, starting from character index i in the supplied path */
fluid.pathUtil.getPathSegment = function (path, i) {
fluid.pathUtil.getPathSegmentImpl(globalAccept, path, i);
return globalAccept[0];
};
/** Returns just the head segment of an EL path */
fluid.pathUtil.getHeadPath = function (path) {
return fluid.pathUtil.getPathSegment(path, 0);
};
/** Returns all of an EL path minus its first segment - if the path consists of just one segment, returns "" */
fluid.pathUtil.getFromHeadPath = function (path) {
var firstdot = fluid.pathUtil.getPathSegmentImpl(null, path, 0);
return firstdot === path.length ? "" : path.substring(firstdot + 1);
};
/** Determines whether a particular EL path matches a given path specification.
* The specification consists of a path with optional wildcard segments represented by "*".
* @param spec (string) The specification to be matched
* @param path (string) The path to be tested
* @param exact (boolean) Whether the path must exactly match the length of the specification in
* terms of path segments in order to count as match. If exact is falsy, short specifications will
* match all longer paths as if they were padded out with "*" segments
* @return (array of string) The path segments which matched the specification, or <code>null</code> if there was no match
*/
fluid.pathUtil.matchPath = function (spec, path, exact) {
var togo = [];
while (true) {
if (((path === "") ^ (spec === "")) && exact) {
return null;
}
// FLUID-4625 - symmetry on spec and path is actually undesirable, but this
// quickly avoids at least missed notifications - improved (but slower)
// implementation should explode composite changes
if (!spec || !path) {
break;
}
var spechead = fluid.pathUtil.getHeadPath(spec);
var pathhead = fluid.pathUtil.getHeadPath(path);
// if we fail to match on a specific component, fail.
if (spechead !== "*" && spechead !== pathhead) {
return null;
}
togo.push(pathhead);
spec = fluid.pathUtil.getFromHeadPath(spec);
path = fluid.pathUtil.getFromHeadPath(path);
}
return togo;
};
// unsupported, NON-API function
fluid.model.transform.expandWildcards = function (transformer, source) {
fluid.each(source, function (value, key) {
var q = transformer.queuedTransforms;
transformer.pathOp.push(fluid.pathUtil.escapeSegment(key.toString()));
for (var i = 0; i < q.length; ++i) {
if (fluid.pathUtil.matchPath(q[i].matchPath, transformer.path, true)) {
var esCopy = fluid.copy(q[i].transformSpec);
if (esCopy.inputPath === undefined || fluid.model.transform.hasWildcard(esCopy.inputPath)) {
esCopy.inputPath = "";
}
// TODO: allow some kind of interpolation for output path
// TODO: Also, we now require outputPath to be specified in these cases for output to be produced as well.. Is that something we want to continue with?
transformer.inputPrefixOp.push(transformer.path);
transformer.outputPrefixOp.push(transformer.path);
var transformOpts = fluid.model.transform.lookupType(esCopy.type);
var result = fluid.model.transform.doTransform(esCopy, transformer, transformOpts);
if (result !== undefined) {
fluid.model.transform.setValue(null, result, transformer);
}
transformer.outputPrefixOp.pop();
transformer.inputPrefixOp.pop();
}
}
if (!fluid.isPrimitive(value)) {
fluid.model.transform.expandWildcards(transformer, value);
}
transformer.pathOp.pop();
});
};
// unsupported, NON-API function
fluid.model.transform.hasWildcard = function (path) {
return typeof(path) === "string" && path.indexOf("*") !== -1;
};
// unsupported, NON-API function
fluid.model.transform.maybePushWildcard = function (transformSpec, transformer) {
var hw = fluid.model.transform.hasWildcard;
var matchPath;
if (hw(transformSpec.inputPath)) {
matchPath = fluid.model.composePaths(transformer.inputPrefix, transformSpec.inputPath);
}
else if (hw(transformer.outputPrefix) || hw(transformSpec.outputPath)) {
matchPath = fluid.model.composePaths(transformer.outputPrefix, transformSpec.outputPath);
}
if (matchPath) {
transformer.queuedTransforms.push({transformSpec: transformSpec, outputPrefix: transformer.outputPrefix, inputPrefix: transformer.inputPrefix, matchPath: matchPath});
return true;
}
return false;
};
fluid.model.sortByKeyLength = function (inObject) {
var keys = fluid.keys(inObject);
return keys.sort(fluid.compareStringLength(true));
};
// Three handler functions operating the (currently) three different processing modes
// unsupported, NON-API function
fluid.model.transform.handleTransformStrategy = function (transformSpec, transformer, transformOpts) {
if (fluid.model.transform.maybePushWildcard(transformSpec, transformer)) {
return;
}
else {
return fluid.model.transform.doTransform(transformSpec, transformer, transformOpts);
}
};
// unsupported, NON-API function
fluid.model.transform.handleInvertStrategy = function (transformSpec, transformer, transformOpts) {
transformSpec = fluid.copy(transformSpec);
// if we have a standardTransformFunction we can switch input and output arguments:
if (fluid.hasGrade(transformOpts.defaults, "fluid.standardTransformFunction")) {
transformSpec = fluid.model.transform.invertPaths(transformSpec, transformer);
}
var invertor = transformOpts.defaults && transformOpts.defaults.invertConfiguration;
if (invertor) {
var inverted = fluid.invokeGlobalFunction(invertor, [transformSpec, transformer]);
transformer.inverted.push(inverted);
}
};
// unsupported, NON-API function
fluid.model.transform.handleCollectStrategy = function (transformSpec, transformer, transformOpts) {
var defaults = transformOpts.defaults;
var standardInput = fluid.hasGrade(defaults, "fluid.standardInputTransformFunction");
var multiInput = fluid.hasGrade(defaults, "fluid.multiInputTransformFunction");
if (standardInput) {
fluid.model.transform.accumulateStandardInputPath("input", transformSpec, transformer, transformer.inputPaths);
}
if (multiInput) {
fluid.model.transform.accumulateMultiInputPaths(defaults.inputVariables, transformSpec, transformer, transformer.inputPaths);
}
if (!multiInput && !standardInput) {
var collector = defaults.collectInputPaths;
if (collector) {
var collected = fluid.makeArray(fluid.invokeGlobalFunction(collector, [transformSpec, transformer]));
transformer.inputPaths = transformer.inputPaths.concat(collected);
}
}
};
fluid.model.transform.lookupType = function (typeName, transformSpec) {
if (!typeName) {
fluid.fail("Transformation record is missing a type name: ", transformSpec);
}
if (typeName.indexOf(".") === -1) {
typeName = "fluid.transforms." + typeName;
}
var defaults = fluid.defaults(typeName);
return { defaults: defaults, typeName: typeName};
};
// unsupported, NON-API function
fluid.model.transform.processRule = function (rule, transformer) {
if (typeof(rule) === "string") {
rule = fluid.model.transform.pathToRule(rule);
}
// special dispensation to allow "literalValue" to escape any value
else if (rule.literalValue !== undefined) {
rule = fluid.model.transform.literalValueToRule(rule.literalValue);
}
var togo;
if (rule.transform) {
var transformSpec, transformOpts;
if (fluid.isArrayable(rule.transform)) {
// if the transform holds an array, each transformer within that is responsible for its own output
var transforms = rule.transform;
togo = undefined;
for (var i = 0; i < transforms.length; ++i) {
transformSpec = transforms[i];
transformOpts = fluid.model.transform.lookupType(transformSpec.type);
transformer.transformHandler(transformSpec, transformer, transformOpts);
}
} else {
// else we just have a normal single transform which will return 'undefined' as a flag to defeat cascading output
transformSpec = rule.transform;
transformOpts = fluid.model.transform.lookupType(transformSpec.type);
togo = transformer.transformHandler(transformSpec, transformer, transformOpts);
}
}
// if rule is an array, save path for later use in schema strategy on final applier (so output will be interpreted as array)
if (fluid.isArrayable(rule)) {
transformer.collectedFlatSchemaOpts = transformer.collectedFlatSchemaOpts || {};
transformer.collectedFlatSchemaOpts[transformer.outputPrefix] = "array";
}
fluid.each(rule, function (value, key) {
if (key !== "transform") {
transformer.outputPrefixOp.push(key);
var togo = transformer.expand(value, transformer);
// Value expanders and arrays as rules implicitly output, unless they have nothing (undefined) to output
if (togo !== undefined) {
fluid.model.transform.setValue(null, togo, transformer);
// ensure that expanders further up does not try to output this value as well.
togo = undefined;
}
transformer.outputPrefixOp.pop();
}
});
return togo;
};
// unsupported, NON-API function
// 3rd arg is disused by the framework and always defaults to fluid.model.transform.processRule
fluid.model.transform.makeStrategy = function (transformer, handleFn, transformFn) {
transformFn = transformFn || fluid.model.transform.processRule;
transformer.expand = function (rules) {
return transformFn(rules, transformer);
};
transformer.outputPrefixOp = fluid.model.makePathStack(transformer, "outputPrefix");
transformer.inputPrefixOp = fluid.model.makePathStack(transformer, "inputPrefix");
transformer.transformHandler = handleFn;
};
fluid.model.transform.invertConfiguration = function (rules) {
var transformer = {
inverted: []
};
fluid.model.transform.makeStrategy(transformer, fluid.model.transform.handleInvertStrategy);
transformer.expand(rules);
return {
transform: transformer.inverted
};
};
fluid.model.transform.collectInputPaths = function (rules) {
var transformer = {
inputPaths: []
};
fluid.model.transform.makeStrategy(transformer, fluid.model.transform.handleCollectStrategy);
transformer.expand(rules);
return transformer.inputPaths;
};
// unsupported, NON-API function
fluid.model.transform.flatSchemaStrategy = function (flatSchema, getConfig) {
var keys = fluid.model.sortByKeyLength(flatSchema);
return function (root, segment, index, segs) {
var path = getConfig.parser.compose.apply(null, segs.slice(0, index));
// TODO: clearly this implementation could be much more efficient
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
if (fluid.pathUtil.matchPath(key, path, true) !== null) {
return flatSchema[key];
}
}
};
};
// unsupported, NON-API function
fluid.model.transform.defaultSchemaValue = function (schemaValue) {
var type = fluid.isPrimitive(schemaValue) ? schemaValue : schemaValue.type;
return type === "array" ? [] : {};
};
// unsupported, NON-API function
fluid.model.transform.isomorphicSchemaStrategy = function (source, getConfig) {
return function (root, segment, index, segs) {
var existing = fluid.get(source, segs.slice(0, index), getConfig);
return fluid.isArrayable(existing) ? "array" : "object";
};
};
// unsupported, NON-API function
fluid.model.transform.decodeStrategy = function (source, options, getConfig) {
if (options.isomorphic) {
return fluid.model.transform.isomorphicSchemaStrategy(source, getConfig);
}
else if (options.flatSchema) {
return fluid.model.transform.flatSchemaStrategy(options.flatSchema, getConfig);
}
};
// unsupported, NON-API function
fluid.model.transform.schemaToCreatorStrategy = function (strategy) {
return function (root, segment, index, segs) {
if (root[segment] === undefined) {
var schemaValue = strategy(root, segment, index, segs);
root[segment] = fluid.model.transform.defaultSchemaValue(schemaValue);
return root[segment];
}
};
};
/** Transforms a model by a sequence of rules. Parameters as for fluid.model.transform,
* only with an array accepted for "rules"
*/
fluid.model.transform.sequence = function (source, rules, options) {
for (var i = 0; i < rules.length; ++i) {
source = fluid.model.transform(source, rules[i], options);
}
return source;
};
fluid.model.compareByPathLength = function (changea, changeb) {
var pdiff = changea.path.length - changeb.path.length;
return pdiff === 0 ? changea.sequence - changeb.sequence : pdiff;
};
/** Fires an accumulated set of change requests in increasing order of target pathlength
*/
fluid.model.fireSortedChanges = function (changes, applier) {
changes.sort(fluid.model.compareByPathLength);
fluid.fireChanges(applier, changes);
};
/**
* Transforms a model based on a specified expansion rules objects.
* Rules objects take the form of:
* {
* "target.path": "value.el.path" || {
* transform: {
* type: "transform.function.path",
* ...
* }
* }
* }
*
* @param {Object} source the model to transform
* @param {Object} rules a rules object containing instructions on how to transform the model
* @param {Object} options a set of rules governing the transformations. At present this may contain
* the values <code>isomorphic: true</code> indicating that the output model is to be governed by the
* same schema found in the input model, or <code>flatSchema</code> holding a flat schema object which
* consists of a hash of EL path specifications with wildcards, to the values "array"/"object" defining
* the schema to be used to construct missing trunk values.
*/
fluid.model.transformWithRules = function (source, rules, options) {
options = options || {};
var getConfig = fluid.model.escapedGetConfig;
var setConfig = fluid.model.escapedSetConfig;
var schemaStrategy = fluid.model.transform.decodeStrategy(source, options, getConfig);
var transformer = {
source: source,
target: {
// TODO: This should default to undefined to allow return of primitives, etc.
model: schemaStrategy ? fluid.model.transform.defaultSchemaValue(schemaStrategy(null, "", 0, [""])) : {}
},
resolverGetConfig: getConfig,
resolverSetConfig: setConfig,
collectedFlatSchemaOpts: undefined, // to hold options for flat schema collected during transforms
queuedChanges: [],
queuedTransforms: [] // TODO: This is used only by wildcard applier - explain its operation
};
fluid.model.transform.makeStrategy(transformer, fluid.model.transform.handleTransformStrategy);
transformer.applier = {
fireChangeRequest: function (changeRequest) {
changeRequest.sequence = transformer.queuedChanges.length;
transformer.queuedChanges.push(changeRequest);
}
};
fluid.bindRequestChange(transformer.applier);
transformer.expand(rules);
var rootSetConfig = fluid.copy(setConfig);
// Modify schemaStrategy if we collected flat schema options for the setConfig of finalApplier
if (transformer.collectedFlatSchemaOpts !== undefined) {
$.extend(transformer.collectedFlatSchemaOpts, options.flatSchema);
schemaStrategy = fluid.model.transform.flatSchemaStrategy(transformer.collectedFlatSchemaOpts, getConfig);
}
rootSetConfig.strategies = [fluid.model.defaultFetchStrategy, schemaStrategy ? fluid.model.transform.schemaToCreatorStrategy(schemaStrategy)
: fluid.model.defaultCreatorStrategy];
transformer.finalApplier = options.finalApplier || fluid.makeHolderChangeApplier(transformer.target, {resolverSetConfig: rootSetConfig});
if (transformer.queuedTransforms.length > 0) {
transformer.typeStack = [];
transformer.pathOp = fluid.model.makePathStack(transformer, "path");
fluid.model.transform.expandWildcards(transformer, source);
}
fluid.model.fireSortedChanges(transformer.queuedChanges, transformer.finalApplier);
return transformer.target.model;
};
$.extend(fluid.model.transformWithRules, fluid.model.transform);
fluid.model.transform = fluid.model.transformWithRules;
/** Utility function to produce a standard options transformation record for a single set of rules **/
fluid.transformOne = function (rules) {
return {
transformOptions: {
transformer: "fluid.model.transformWithRules",
config: rules
}
};
};
/** Utility function to produce a standard options transformation record for multiple rules to be applied in sequence **/
fluid.transformMany = function (rules) {
return {
transformOptions: {
transformer: "fluid.model.transform.sequence",
config: rules
}
};
};
})(jQuery, fluid_2_0_0);

743
lib/infusion/src/framework/core/js/ModelTransformationTransforms.js

@ -0,0 +1,743 @@
/*
Copyright 2010 University of Toronto
Copyright 2010-2015 OCAD University
Copyright 2013-2014 Raising the Floor - US
Copyright 2013-2016 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
var fluid = fluid || fluid_2_0_0;
(function ($, fluid) {
"use strict";
fluid.registerNamespace("fluid.model.transform");
fluid.registerNamespace("fluid.transforms");
/**********************************
* Standard transformer functions *
**********************************/
fluid.defaults("fluid.transforms.value", {
gradeNames: "fluid.standardTransformFunction",
invertConfiguration: "fluid.identity"
});
fluid.transforms.value = fluid.identity;
// Export the use of the "value" transform under the "identity" name for FLUID-5293
fluid.transforms.identity = fluid.transforms.value;
fluid.defaults("fluid.transforms.identity", {
gradeNames: "fluid.transforms.value"
});
// A helpful utility function to be used when a transform's inverse is the identity
fluid.transforms.invertToIdentity = function (transformSpec) {
transformSpec.type = "fluid.transforms.identity";
return transformSpec;
};
fluid.defaults("fluid.transforms.literalValue", {
gradeNames: "fluid.standardOutputTransformFunction"
});
fluid.transforms.literalValue = function (transformSpec) {
return transformSpec.input;
};
fluid.defaults("fluid.transforms.stringToNumber", {
gradeNames: ["fluid.standardTransformFunction", "fluid.lens"],
invertConfiguration: "fluid.transforms.stringToNumber.invert"
});
fluid.transforms.stringToNumber = function (value) {
var newValue = Number(value);
return isNaN(newValue) ? undefined : newValue;
};
fluid.transforms.stringToNumber.invert = function (transformSpec) {
transformSpec.type = "fluid.transforms.numberToString";
return transformSpec;
};
fluid.defaults("fluid.transforms.numberToString", {
gradeNames: ["fluid.standardTransformFunction", "fluid.lens"],
invertConfiguration: "fluid.transforms.numberToString.invert"
});
fluid.transforms.numberToString = function (value) {
return (typeof value !== "number") ? undefined : "" + value;
};
fluid.transforms.numberToString.invert = function (transformSpec) {
transformSpec.type = "fluid.transforms.stringToNumber";
return transformSpec;
};
fluid.defaults("fluid.transforms.count", {
gradeNames: "fluid.standardTransformFunction"
});
fluid.transforms.count = function (value) {
return fluid.makeArray(value).length;
};
fluid.defaults("fluid.transforms.round", {
gradeNames: ["fluid.standardTransformFunction", "fluid.lens"],
invertConfiguration: "fluid.transforms.invertToIdentity"
});
fluid.transforms.round = function (value) {
return Math.round(value);
};
fluid.defaults("fluid.transforms.delete", {
gradeNames: "fluid.transformFunction"
});
fluid.transforms["delete"] = function (transformSpec, transformer) {
var outputPath = fluid.model.composePaths(transformer.outputPrefix, transformSpec.outputPath);
transformer.applier.change(outputPath, null, "DELETE");
};
fluid.defaults("fluid.transforms.firstValue", {
gradeNames: "fluid.standardOutputTransformFunction"
});
fluid.transforms.firstValue = function (transformSpec, transformer) {
if (!transformSpec.values || !transformSpec.values.length) {
fluid.fail("firstValue transformer requires an array of values at path named \"values\", supplied", transformSpec);
}
for (var i = 0; i < transformSpec.values.length; i++) {
var value = transformSpec.values[i];
// TODO: problem here - all of these transforms will have their side-effects (setValue) even if only one is chosen
var expanded = transformer.expand(value);
if (expanded !== undefined) {
return expanded;
}
}
};
fluid.defaults("fluid.transforms.linearScale", {
gradeNames: ["fluid.multiInputTransformFunction",
"fluid.standardTransformFunction",
"fluid.lens" ],
invertConfiguration: "fluid.transforms.linearScale.invert",
inputVariables: {
factor: 1,
offset: 0
}
});
/* simple linear transformation */
fluid.transforms.linearScale = function (input, extraInputs) {
var factor = extraInputs.factor();
var offset = extraInputs.offset();
if (typeof(input) !== "number" || typeof(factor) !== "number" || typeof(offset) !== "number") {
return undefined;
}
return input * factor + offset;
};
/* TODO: This inversion doesn't work if the value and factors are given as paths in the source model */
fluid.transforms.linearScale.invert = function (transformSpec) {
// delete the factor and offset paths if present
delete transformSpec.factorPath;
delete transformSpec.offsetPath;
if (transformSpec.factor !== undefined) {
transformSpec.factor = (transformSpec.factor === 0) ? 0 : 1 / transformSpec.factor;
}
if (transformSpec.offset !== undefined) {
transformSpec.offset = -transformSpec.offset * (transformSpec.factor !== undefined ? transformSpec.factor : 1);
}
return transformSpec;
};
fluid.defaults("fluid.transforms.binaryOp", {
gradeNames: [ "fluid.multiInputTransformFunction", "fluid.standardOutputTransformFunction" ],
inputVariables: {
left: null,
right: null
}
});
fluid.transforms.binaryLookup = {
"===": function (a, b) { return fluid.model.isSameValue(a, b); },
"!==": function (a, b) { return !fluid.model.isSameValue(a, b); },
"<=": function (a, b) { return a <= b; },
"<": function (a, b) { return a < b; },
">=": function (a, b) { return a >= b; },
">": function (a, b) { return a > b; },
"+": function (a, b) { return a + b; },
"-": function (a, b) { return a - b; },
"*": function (a, b) { return a * b; },
"/": function (a, b) { return a / b; },
"%": function (a, b) { return a % b; },
"&&": function (a, b) { return a && b; },
"||": function (a, b) { return a || b; }
};
fluid.transforms.binaryOp = function (inputs, transformSpec, transformer) {
var left = inputs.left();
var right = inputs.right();
var operator = fluid.model.transform.getValue(undefined, transformSpec.operator, transformer);
var fun = fluid.transforms.binaryLookup[operator];
return (fun === undefined || left === undefined || right === undefined) ?
undefined : fun(left, right);
};
fluid.defaults("fluid.transforms.condition", {
gradeNames: [ "fluid.multiInputTransformFunction", "fluid.standardOutputTransformFunction" ],
inputVariables: {
"true": null,
"false": null,
"condition": null
}
});
fluid.transforms.condition = function (inputs) {
var condition = inputs.condition();
if (condition === null) {
return undefined;
}
return inputs[condition ? "true" : "false"]();
};
fluid.defaults("fluid.transforms.valueMapper", {
gradeNames: ["fluid.transformFunction", "fluid.lens"],
invertConfiguration: "fluid.transforms.valueMapper.invert",
collectInputPaths: "fluid.transforms.valueMapper.collect"
});
/* unsupported, NON-API function
* sorts by the object's 'matchValue' property, where higher is better.
* Tiebreaking is done via the `index` property, where a lower index takes priority
*/
fluid.model.transform.compareMatches = function (speca, specb) {
var matchDiff = specb.matchValue - speca.matchValue;
return matchDiff === 0 ? speca.index - specb.index : matchDiff; // tiebreak using 'index'
};
fluid.transforms.valueMapper = function (transformSpec, transformer) {
if (!transformSpec.match) {
fluid.fail("valueMapper requires an array or hash of matches at path named \"match\", supplied ", transformSpec);
}
var value = fluid.model.transform.getValue(transformSpec.defaultInputPath, undefined, transformer);
var matchedEntry = (fluid.isArrayable(transformSpec.match)) ? // long form with array of records?
fluid.transforms.valueMapper.longFormMatch(value, transformSpec, transformer) :
transformSpec.match[value];
if (matchedEntry === undefined) { // if no matches found, default to noMatch
matchedEntry = transformSpec.noMatch;
}
if (matchedEntry === undefined) { // if there was no noMatch directive, return undefined
return;
}
var outputPath = matchedEntry.outputPath === undefined ? transformSpec.defaultOutputPath : matchedEntry.outputPath;
transformer.outputPrefixOp.push(outputPath);
var outputValue;
if (fluid.isPrimitive(matchedEntry)) {
outputValue = matchedEntry;
} else if (matchedEntry.outputUndefinedValue) { // if outputUndefinedValue is set, outputValue `undefined`
outputValue = undefined;
} else {
// get value from outputValue. If none is found set the outputValue to be that of defaultOutputValue (or undefined)
outputValue = fluid.model.transform.resolveParam(matchedEntry, transformer, "outputValue", undefined);
outputValue = (outputValue === undefined) ? transformSpec.defaultOutputValue : outputValue;
}
// output if we have a path and something to output
if (typeof(outputPath) === "string" && outputValue !== undefined) {
fluid.model.transform.setValue(undefined, outputValue, transformer, transformSpec.merge);
outputValue = undefined; // make sure we don't also return value
}
transformer.outputPrefixOp.pop();
return outputValue;
};
// unsupported, NON-API function
fluid.transforms.valueMapper.longFormMatch = function (valueFromDefaultPath, transformSpec, transformer) {
var o = transformSpec.match;
if (o.length === 0) {
fluid.fail("valueMapper supplied empty list of matches: ", transformSpec);
}
var matchPower = [];
for (var i = 0; i < o.length; ++i) {
var option = o[i];
var value = option.inputPath ?
fluid.model.transform.getValue(option.inputPath, undefined, transformer) : valueFromDefaultPath;
var matchValue = fluid.model.transform.matchValue(option.inputValue, value, option.partialMatches);
matchPower[i] = {index: i, matchValue: matchValue};
}
matchPower.sort(fluid.model.transform.compareMatches);
return matchPower[0].matchValue <= 0 ? undefined : o[matchPower[0].index];
};
fluid.transforms.valueMapper.invert = function (transformSpec, transformer) {
var match = [];
var togo = {
type: "fluid.transforms.valueMapper",
match: match
};
var isArray = fluid.isArrayable(transformSpec.match);
togo.defaultInputPath = fluid.model.composePaths(transformer.outputPrefix, transformSpec.defaultOutputPath);
togo.defaultOutputPath = fluid.model.composePaths(transformer.inputPrefix, transformSpec.defaultInputPath);
var def = fluid.firstDefined;
fluid.each(transformSpec.match, function (option, key) {
if (option.outputUndefinedValue === true) {
return; // don't attempt to invert undefined output value entries
}
var outOption = {};
var origInputValue = def(isArray ? option.inputValue : key, transformSpec.defaultInputValue);
if (origInputValue === undefined) {
fluid.fail("Failure inverting configuration for valueMapper - inputValue could not be resolved for record " + key + ": ", transformSpec);
}
outOption.outputValue = origInputValue;
outOption.inputValue = !isArray && fluid.isPrimitive(option) ?
option : def(option.outputValue, transformSpec.defaultOutputValue);
if (option.outputPath) {
outOption.inputPath = fluid.model.composePaths(transformer.outputPrefix, def(option.outputPath, transformSpec.outputPath));
}
if (option.inputPath) {
outOption.outputPath = fluid.model.composePaths(transformer.inputPrefix, def(option.inputPath, transformSpec.inputPath));
}
match.push(outOption);
});
return togo;
};
fluid.transforms.valueMapper.collect = function (transformSpec, transformer) {
var togo = [];
fluid.model.transform.accumulateInputPath(transformSpec.defaultInputPath, transformer, togo);
fluid.each(transformSpec.match, function (option) {
fluid.model.transform.accumulateInputPath(option.inputPath, transformer, togo);
});
return togo;
};
/* -------- arrayToSetMembership and setMembershipToArray ---------------- */
fluid.defaults("fluid.transforms.arrayToSetMembership", {
gradeNames: ["fluid.standardTransformFunction", "fluid.lens"],
invertConfiguration: "fluid.transforms.arrayToSetMembership.invert"
});
fluid.transforms.arrayToSetMembership = function (value, transformSpec, transformer) {
var output = {};
var options = transformSpec.options;
if (!value || !fluid.isArrayable(value)) {
fluid.fail("arrayToSetMembership didn't find array at inputPath nor passed as value.", transformSpec);
}
if (!options) {
fluid.fail("arrayToSetMembership requires an options block set");
}
if (transformSpec.presentValue === undefined) {
transformSpec.presentValue = true;
}
if (transformSpec.missingValue === undefined) {
transformSpec.missingValue = false;
}
fluid.each(options, function (outPath, key) {
// write to output object the value <presentValue> or <missingValue> depending on whether key is found in user input
var outVal = (value.indexOf(key) !== -1) ? transformSpec.presentValue : transformSpec.missingValue;
fluid.set(output, outPath, outVal, transformer.resolverSetConfig);
});
return output;
};
/**
* NON-API function; Copies the entire transformSpec with the following modifications:
* * A new type is set (from argument)
* * each [key]=value entry in the options is swapped to be: [value]=key
*/
fluid.transforms.arrayToSetMembership.invertWithType = function (transformSpec, transformer, newType) {
transformSpec.type = newType;
var newOptions = {};
fluid.each(transformSpec.options, function (path, oldKey) {
newOptions[path] = oldKey;
});
transformSpec.options = newOptions;
return transformSpec;
};
fluid.transforms.arrayToSetMembership.invert = function (transformSpec, transformer) {
return fluid.transforms.arrayToSetMembership.invertWithType(transformSpec, transformer,
"fluid.transforms.setMembershipToArray");
};
fluid.defaults("fluid.transforms.setMembershipToArray", {
gradeNames: ["fluid.standardTransformFunction", "fluid.lens"],
invertConfiguration: "fluid.transforms.setMembershipToArray.invert"
});
fluid.transforms.setMembershipToArray = function (input, transformSpec, transformer) {
var options = transformSpec.options;
if (!options) {
fluid.fail("setMembershipToArray requires an options block specified");
}
if (transformSpec.presentValue === undefined) {
transformSpec.presentValue = true;
}
if (transformSpec.missingValue === undefined) {
transformSpec.missingValue = false;
}
var outputArr = [];
fluid.each(options, function (outputVal, key) {
var value = fluid.get(input, key, transformer.resolverGetConfig);
if (value === transformSpec.presentValue) {
outputArr.push(outputVal);
}
});
return outputArr;
};
fluid.transforms.setMembershipToArray.invert = function (transformSpec, transformer) {
return fluid.transforms.arrayToSetMembership.invertWithType(transformSpec, transformer,
"fluid.transforms.arrayToSetMembership");
};
/* -------- deindexIntoArrayByKey and indexArrayByKey -------------------- */
/**
* Transforms the given array to an object.
* Uses the transformSpec.options.key values from each object within the array as new keys.
*
* For example, with transformSpec.key = "name" and an input object like this:
*
* {
* b: [
* { name: b1, v: v1 },
* { name: b2, v: v2 }
* ]
* }
*
* The output will be:
* {
* b: {
* b1: {
* v: v1
* }
* },
* {
* b2: {
* v: v2
* }
* }
* }
*/
fluid.model.transform.applyPaths = function (operation, pathOp, paths) {
for (var i = 0; i < paths.length; ++i) {
if (operation === "push") {
pathOp.push(paths[i]);
} else {
pathOp.pop();
}
}
};
fluid.model.transform.expandInnerValues = function (inputPath, outputPath, transformer, innerValues) {
var inputPrefixOp = transformer.inputPrefixOp;
var outputPrefixOp = transformer.outputPrefixOp;
var apply = fluid.model.transform.applyPaths;
apply("push", inputPrefixOp, inputPath);
apply("push", outputPrefixOp, outputPath);
var expanded = {};
fluid.each(innerValues, function (innerValue) {
var expandedInner = transformer.expand(innerValue);
if (!fluid.isPrimitive(expandedInner)) {
$.extend(true, expanded, expandedInner);
} else {
expanded = expandedInner;
}
});
apply("pop", outputPrefixOp, outputPath);
apply("pop", inputPrefixOp, inputPath);
return expanded;
};
fluid.defaults("fluid.transforms.indexArrayByKey", {
gradeNames: ["fluid.standardTransformFunction", "fluid.lens" ],
invertConfiguration: "fluid.transforms.indexArrayByKey.invert"
});
/** Transforms an array of objects into an object of objects, by indexing using the option "key" which must be supplied within the transform specification.
* The key of each element will be taken from the value held in each each original object's member derived from the option value in "key" - this member should
* exist in each array element. The member with name agreeing with "key" and its value will be removed from each original object before inserting into the returned
* object.
* For example,
* <code>fluid.transforms.indexArrayByKey([{k: "e1", b: 1, c: 2}, {k: "e2", b: 2: c: 3}], {key: "k"})</code> will output the object
* <code>{e1: {b: 1, c: 2}, e2: {b: 2: c, 3}</code>
* Note: This transform frequently arises in the context of data which arose in XML form, which often represents "morally indexed" data in repeating array-like
* constructs where the indexing key is held, for example, in an attribute.
*/
fluid.transforms.indexArrayByKey = function (arr, transformSpec, transformer) {
if (transformSpec.key === undefined) {
fluid.fail("indexArrayByKey requires a 'key' option.", transformSpec);
}
if (!fluid.isArrayable(arr)) {
fluid.fail("indexArrayByKey didn't find array at inputPath.", transformSpec);
}
var newHash = {};
var pivot = transformSpec.key;
fluid.each(arr, function (v, k) {
// check that we have a pivot entry in the object and it's a valid type:
var newKey = v[pivot];
var keyType = typeof(newKey);
if (keyType !== "string" && keyType !== "boolean" && keyType !== "number") {
fluid.fail("indexArrayByKey encountered untransformable array due to missing or invalid key", v);
}
// use the value of the key element as key and use the remaining content as value
var content = fluid.copy(v);
delete content[pivot];
// fix sub Arrays if needed:
if (transformSpec.innerValue) {
content = fluid.model.transform.expandInnerValues([transformer.inputPrefix, transformSpec.inputPath, k.toString()],
[transformSpec.outputPath, newKey], transformer, transformSpec.innerValue);
}
newHash[newKey] = content;
});
return newHash;
};
fluid.transforms.indexArrayByKey.invert = function (transformSpec) {
transformSpec.type = "fluid.transforms.deindexIntoArrayByKey";
// invert transforms from innerValue as well:
// TODO: The Model Transformations framework should be capable of this, but right now the
// issue is that we use a "private contract" to operate the "innerValue" slot. We need to
// spend time thinking of how this should be formalised
if (transformSpec.innerValue) {
var innerValue = transformSpec.innerValue;
for (var i = 0; i < innerValue.length; ++i) {
innerValue[i] = fluid.model.transform.invertConfiguration(innerValue[i]);
}
}
return transformSpec;
};
fluid.defaults("fluid.transforms.deindexIntoArrayByKey", {
gradeNames: [ "fluid.standardTransformFunction", "fluid.lens" ],
invertConfiguration: "fluid.transforms.deindexIntoArrayByKey.invert"
});
/**
* Transforms an object of objects into an array of objects, by deindexing by the option "key" which must be supplied within the transform specification.
* The key of each object will become split out into a fresh value in each array element which will be given the key held in the transformSpec option "key".
* For example:
* <code>fluid.transforms.deindexIntoArrayByKey({e1: {b: 1, c: 2}, e2: {b: 2: c, 3}, {key: "k"})</code> will output the array
* <code>[{k: "e1", b: 1, c: 2}, {k: "e2", b: 2: c: 3}]</code>
*
* This performs the inverse transform of fluid.transforms.indexArrayByKey.
*/
fluid.transforms.deindexIntoArrayByKey = function (hash, transformSpec, transformer) {
if (transformSpec.key === undefined) {
fluid.fail("deindexIntoArrayByKey requires a \"key\" option.", transformSpec);
}
var newArray = [];
var pivot = transformSpec.key;
fluid.each(hash, function (v, k) {
var content = {};
content[pivot] = k;
if (transformSpec.innerValue) {
v = fluid.model.transform.expandInnerValues([transformSpec.inputPath, k], [transformSpec.outputPath, newArray.length.toString()],
transformer, transformSpec.innerValue);
}
$.extend(true, content, v);
newArray.push(content);
});
return newArray;
};
fluid.transforms.deindexIntoArrayByKey.invert = function (transformSpec) {
transformSpec.type = "fluid.transforms.indexArrayByKey";
// invert transforms from innerValue as well:
// TODO: The Model Transformations framework should be capable of this, but right now the
// issue is that we use a "private contract" to operate the "innerValue" slot. We need to
// spend time thinking of how this should be formalised
if (transformSpec.innerValue) {
var innerValue = transformSpec.innerValue;
for (var i = 0; i < innerValue.length; ++i) {
innerValue[i] = fluid.model.transform.invertConfiguration(innerValue[i]);
}
}
return transformSpec;
};
fluid.defaults("fluid.transforms.limitRange", {
gradeNames: "fluid.standardTransformFunction"
});
fluid.transforms.limitRange = function (value, transformSpec) {
var min = transformSpec.min;
if (min !== undefined) {
var excludeMin = transformSpec.excludeMin || 0;
min += excludeMin;
if (value < min) {
value = min;
}
}
var max = transformSpec.max;
if (max !== undefined) {
var excludeMax = transformSpec.excludeMax || 0;
max -= excludeMax;
if (value > max) {
value = max;
}
}
return value;
};
fluid.defaults("fluid.transforms.indexOf", {
gradeNames: ["fluid.standardTransformFunction", "fluid.lens"],
invertConfiguration: "fluid.transforms.indexOf.invert"
});
fluid.transforms.indexOf = function (value, transformSpec) {
// We do not allow a positive number as 'notFound' value, as it threatens invertibility
if (typeof (transformSpec.notFound) === "number" && transformSpec.notFound >= 0) {
fluid.fail("A positive number is not allowed as 'notFound' value for indexOf");
}
var offset = fluid.transforms.parseIndexationOffset(transformSpec.offset, "indexOf");
var array = fluid.makeArray(transformSpec.array);
var originalIndex = array.indexOf(value);
return originalIndex === -1 && transformSpec.notFound ? transformSpec.notFound : originalIndex + offset;
};
fluid.transforms.indexOf.invert = function (transformSpec, transformer) {
var togo = fluid.transforms.invertArrayIndexation(transformSpec, transformer);
togo.type = "fluid.transforms.dereference";
return togo;
};
fluid.defaults("fluid.transforms.dereference", {
gradeNames: ["fluid.standardTransformFunction", "fluid.lens"],
invertConfiguration: "fluid.transforms.dereference.invert"
});
fluid.transforms.dereference = function (value, transformSpec) {
if (typeof (value) !== "number") {
return undefined;
}
var offset = fluid.transforms.parseIndexationOffset(transformSpec.offset, "dereference");
var array = fluid.makeArray(transformSpec.array);
var index = value + offset;
return array[index];
};
fluid.transforms.dereference.invert = function (transformSpec, transformer) {
var togo = fluid.transforms.invertArrayIndexation(transformSpec, transformer);
togo.type = "fluid.transforms.indexOf";
return togo;
};
fluid.transforms.parseIndexationOffset = function (offset, transformName) {
var parsedOffset = 0;
if (offset !== undefined) {
parsedOffset = fluid.parseInteger(offset);
if (isNaN(parsedOffset)) {
fluid.fail(transformName + " requires the value of \"offset\" to be an integer or a string that can be converted to an integer. " + offset + " is invalid.");
}
}
return parsedOffset;
};
fluid.transforms.invertArrayIndexation = function (transformSpec) {
if (!isNaN(Number(transformSpec.offset))) {
transformSpec.offset = Number(transformSpec.offset) * (-1);
}
return transformSpec;
};
fluid.defaults("fluid.transforms.stringTemplate", {
gradeNames: "fluid.standardOutputTransformFunction"
});
fluid.transforms.stringTemplate = function (transformSpec) {
return fluid.stringTemplate(transformSpec.template, transformSpec.terms);
};
fluid.defaults("fluid.transforms.free", {
gradeNames: "fluid.transformFunction"
});
fluid.transforms.free = function (transformSpec) {
var args = fluid.makeArray(transformSpec.args);
return fluid.invokeGlobalFunction(transformSpec.func, args);
};
fluid.defaults("fluid.transforms.quantize", {
gradeNames: "fluid.standardTransformFunction"
});
/**
* Quantize function maps a continuous range into discrete values. Given an input, it will
* be matched into a discrete bucket and the corresponding output will be done.
*/
fluid.transforms.quantize = function (value, transformSpec, transform) {
if (!transformSpec.ranges || !transformSpec.ranges.length) {
fluid.fail("fluid.transforms.quantize should have a key called ranges containing an array defining ranges to quantize");
}
// TODO: error checking that upper bounds are all numbers and increasing
for (var i = 0; i < transformSpec.ranges.length; i++) {
var rangeSpec = transformSpec.ranges[i];
if (value <= rangeSpec.upperBound || rangeSpec.upperBound === undefined && value >= Number.NEGATIVE_INFINITY) {
return fluid.isPrimitive(rangeSpec.output) ? rangeSpec.output : transform.expand(rangeSpec.output);
}
}
};
/**
* inRange transformer checks whether a value is within a given range and returns true if it is,
* and false if it's not.
*
* The range is defined by the two inputs: "min" and "max" (both inclusive). If one of these inputs
* is not present it is considered -infinite and +infinite, respectively - In other words, if no
* `min` value is defined, any value below or equal to the given "max" value will result in true.
*/
fluid.defaults("fluid.transforms.inRange", {
gradeNames: "fluid.standardTransformFunction"
});
fluid.transforms.inRange = function (value, transformSpec) {
return (transformSpec.min === undefined || transformSpec.min <= value) &&
(transformSpec.max === undefined || transformSpec.max >= value) ? true : false;
};
})(jQuery, fluid_2_0_0);

73
lib/infusion/src/framework/core/js/ResourceLoader.js

@ -0,0 +1,73 @@
/*
Copyright 2011-2016 OCAD University
Copyright 2011 Lucendo Development Ltd.
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
/**
* A configurable component to allow users to load multiple resources via AJAX requests.
* The resources can be localised by means of options `locale`, `defaultLocale`. Once all
* resources are loaded, the event `onResourceLoaded` will be fired, which can be used
* to time the creation of components dependent on the resources.
*
* @param {Object} options
*/
fluid.defaults("fluid.resourceLoader", {
gradeNames: ["fluid.component"],
listeners: {
"onCreate.loadResources": {
listener: "fluid.resourceLoader.loadResources",
args: ["{that}", {expander: {func: "{that}.resolveResources"}}]
}
},
defaultLocale: null,
locale: null,
terms: {}, // Must be supplied by integrators
resources: {}, // Must be supplied by integrators
resourceOptions: {},
// Unsupported, non-API option
invokers: {
transformURL: {
funcName: "fluid.stringTemplate",
args: ["{arguments}.0", "{that}.options.terms"]
},
resolveResources: {
funcName: "fluid.resourceLoader.resolveResources",
args: "{that}"
}
},
events: {
onResourcesLoaded: null
}
});
fluid.resourceLoader.resolveResources = function (that) {
var mapped = fluid.transform(that.options.resources, that.transformURL);
return fluid.transform(mapped, function (url) {
var resourceSpec = {url: url, forceCache: true, options: that.options.resourceOptions};
return $.extend(resourceSpec, fluid.filterKeys(that.options, ["defaultLocale", "locale"]));
});
};
fluid.resourceLoader.loadResources = function (that, resources) {
fluid.fetchResources(resources, function () {
that.resources = resources;
that.events.onResourcesLoaded.fire(resources);
});
};
})(jQuery, fluid_2_0_0);

623
lib/infusion/src/framework/core/js/jquery.keyboard-a11y.js

@ -0,0 +1,623 @@
/*
Copyright 2008-2010 University of Cambridge
Copyright 2008-2010 University of Toronto
Copyright 2010-2011 Lucendo Development Ltd.
Copyright 2010-2016 OCAD University
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
var fluid = fluid || fluid_2_0_0;
(function ($, fluid) {
"use strict";
// $().fluid("selectable", args)
// $().fluid("selectable".that()
// $().fluid("pager.pagerBar", args)
// $().fluid("reorderer", options)
/** Create a "bridge" from code written in the Fluid standard "that-ist" style,
* to the standard JQuery UI plugin architecture specified at http://docs.jquery.com/UI/Guidelines .
* Every Fluid component corresponding to the top-level standard signature (JQueryable, options)
* will automatically convert idiomatically to the JQuery UI standard via this adapter.
* Any return value which is a primitive or array type will become the return value
* of the "bridged" function - however, where this function returns a general hash
* (object) this is interpreted as forming part of the Fluid "return that" pattern,
* and the function will instead be bridged to "return this" as per JQuery standard,
* permitting chaining to occur. However, as a courtesy, the particular "this" returned
* will be augmented with a function that() which will allow the original return
* value to be retrieved if desired.
* @param {String} name The name under which the "plugin space" is to be injected into
* JQuery
* @param {Object} peer The root of the namespace corresponding to the peer object.
*/
fluid.thatistBridge = function (name, peer) {
var togo = function (funcname) {
var segs = funcname.split(".");
var move = peer;
for (var i = 0; i < segs.length; ++i) {
move = move[segs[i]];
}
var args = [this];
if (arguments.length === 2) {
args = args.concat($.makeArray(arguments[1]));
}
var ret = move.apply(null, args);
this.that = function () {
return ret;
};
var type = typeof(ret);
return !ret || type === "string" || type === "number" || type === "boolean" ||
(ret && ret.length !== undefined) ? ret : this;
};
$.fn[name] = togo;
return togo;
};
fluid.thatistBridge("fluid", fluid);
fluid.thatistBridge("fluid_2_0_0", fluid_2_0_0);
/*************************************************************************
* Tabindex normalization - compensate for browser differences in naming
* and function of "tabindex" attribute and tabbing order.
*/
// -- Private functions --
var normalizeTabindexName = function () {
return $.browser.msie ? "tabIndex" : "tabindex";
};
var canHaveDefaultTabindex = function (elements) {
if (elements.length <= 0) {
return false;
}
return $(elements[0]).is("a, input, button, select, area, textarea, object");
};
var getValue = function (elements) {
if (elements.length <= 0) {
return undefined;
}
if (!fluid.tabindex.hasAttr(elements)) {
return canHaveDefaultTabindex(elements) ? Number(0) : undefined;
}
// Get the attribute and return it as a number value.
var value = elements.attr(normalizeTabindexName());
return Number(value);
};
var setValue = function (elements, toIndex) {
return elements.each(function (i, item) {
$(item).attr(normalizeTabindexName(), toIndex);
});
};
// -- Public API --
/**
* Gets the value of the tabindex attribute for the first item, or sets the tabindex value of all elements
* if toIndex is specified.
*
* @param {String|Number} toIndex
*/
fluid.tabindex = function (target, toIndex) {
target = $(target);
if (toIndex !== null && toIndex !== undefined) {
return setValue(target, toIndex);
} else {
return getValue(target);
}
};
/**
* Removes the tabindex attribute altogether from each element.
*/
fluid.tabindex.remove = function (target) {
target = $(target);
return target.each(function (i, item) {
$(item).removeAttr(normalizeTabindexName());
});
};
/**
* Determines if an element actually has a tabindex attribute present.
*/
fluid.tabindex.hasAttr = function (target) {
target = $(target);
if (target.length <= 0) {
return false;
}
var togo = target.map(
function () {
var attributeNode = this.getAttributeNode(normalizeTabindexName());
return attributeNode ? attributeNode.specified : false;
}
);
return togo.length === 1 ? togo[0] : togo;
};
/**
* Determines if an element either has a tabindex attribute or is naturally tab-focussable.
*/
fluid.tabindex.has = function (target) {
target = $(target);
return fluid.tabindex.hasAttr(target) || canHaveDefaultTabindex(target);
};
// Keyboard navigation
// Public, static constants needed by the rest of the library.
fluid.a11y = $.a11y || {};
fluid.a11y.orientation = {
HORIZONTAL: 0,
VERTICAL: 1,
BOTH: 2
};
var UP_DOWN_KEYMAP = {
next: $.ui.keyCode.DOWN,
previous: $.ui.keyCode.UP
};
var LEFT_RIGHT_KEYMAP = {
next: $.ui.keyCode.RIGHT,
previous: $.ui.keyCode.LEFT
};
// Private functions.
var unwrap = function (element) {
return element.jquery ? element[0] : element; // Unwrap the element if it's a jQuery.
};
var makeElementsTabFocussable = function (elements) {
// If each element doesn't have a tabindex, or has one set to a negative value, set it to 0.
elements.each(function (idx, item) {
item = $(item);
if (!item.fluid("tabindex.has") || item.fluid("tabindex") < 0) {
item.fluid("tabindex", 0);
}
});
};
// Public API.
/**
* Makes all matched elements available in the tab order by setting their tabindices to "0".
*/
fluid.tabbable = function (target) {
target = $(target);
makeElementsTabFocussable(target);
};
/***********************************************************************
* Selectable functionality - geometrising a set of nodes such that they
* can be navigated (by setting focus) using a set of directional keys
*/
var CONTEXT_KEY = "selectionContext";
var NO_SELECTION = -32768;
var cleanUpWhenLeavingContainer = function (selectionContext) {
if (selectionContext.activeItemIndex !== NO_SELECTION) {
if (selectionContext.options.onLeaveContainer) {
selectionContext.options.onLeaveContainer(
selectionContext.selectables[selectionContext.activeItemIndex]
);
} else if (selectionContext.options.onUnselect) {
selectionContext.options.onUnselect(
selectionContext.selectables[selectionContext.activeItemIndex]
);
}
}
if (!selectionContext.options.rememberSelectionState) {
selectionContext.activeItemIndex = NO_SELECTION;
}
};
/**
* Does the work of selecting an element and delegating to the client handler.
*/
var drawSelection = function (elementToSelect, handler) {
if (handler) {
handler(elementToSelect);
}
};
/**
* Does does the work of unselecting an element and delegating to the client handler.
*/
var eraseSelection = function (selectedElement, handler) {
if (handler && selectedElement) {
handler(selectedElement);
}
};
var unselectElement = function (selectedElement, selectionContext) {
eraseSelection(selectedElement, selectionContext.options.onUnselect);
};
var selectElement = function (elementToSelect, selectionContext) {
// It's possible that we're being called programmatically, in which case we should clear any previous selection.
unselectElement(selectionContext.selectedElement(), selectionContext);
elementToSelect = unwrap(elementToSelect);
var newIndex = selectionContext.selectables.index(elementToSelect);
// Next check if the element is a known selectable. If not, do nothing.
if (newIndex === -1) {
return;
}
// Select the new element.
selectionContext.activeItemIndex = newIndex;
drawSelection(elementToSelect, selectionContext.options.onSelect);
};
var selectableFocusHandler = function (selectionContext) {
return function (evt) {
// FLUID-3590: newer browsers (FF 3.6, Webkit 4) have a form of "bug" in that they will go bananas
// on attempting to move focus off an element which has tabindex dynamically set to -1.
$(evt.target).fluid("tabindex", 0);
selectElement(evt.target, selectionContext);
// Force focus not to bubble on some browsers.
return evt.stopPropagation();
};
};
var selectableBlurHandler = function (selectionContext) {
return function (evt) {
$(evt.target).fluid("tabindex", selectionContext.options.selectablesTabindex);
unselectElement(evt.target, selectionContext);
// Force blur not to bubble on some browsers.
return evt.stopPropagation();
};
};
var reifyIndex = function (sc_that) {
var elements = sc_that.selectables;
if (sc_that.activeItemIndex >= elements.length) {
sc_that.activeItemIndex = (sc_that.options.noWrap ? elements.length - 1 : 0);
}
if (sc_that.activeItemIndex < 0 && sc_that.activeItemIndex !== NO_SELECTION) {
sc_that.activeItemIndex = (sc_that.options.noWrap ? 0 : elements.length - 1);
}
if (sc_that.activeItemIndex >= 0) {
fluid.focus(elements[sc_that.activeItemIndex]);
}
};
var prepareShift = function (selectionContext) {
// FLUID-3590: FF 3.6 and Safari 4.x won't fire blur() when programmatically moving focus.
var selElm = selectionContext.selectedElement();
if (selElm) {
fluid.blur(selElm);
}
unselectElement(selectionContext.selectedElement(), selectionContext);
if (selectionContext.activeItemIndex === NO_SELECTION) {
selectionContext.activeItemIndex = -1;
}
};
var focusNextElement = function (selectionContext) {
prepareShift(selectionContext);
++selectionContext.activeItemIndex;
reifyIndex(selectionContext);
};
var focusPreviousElement = function (selectionContext) {
prepareShift(selectionContext);
--selectionContext.activeItemIndex;
reifyIndex(selectionContext);
};
var arrowKeyHandler = function (selectionContext, keyMap) {
return function (evt) {
if (evt.which === keyMap.next) {
focusNextElement(selectionContext);
evt.preventDefault();
} else if (evt.which === keyMap.previous) {
focusPreviousElement(selectionContext);
evt.preventDefault();
}
};
};
var getKeyMapForDirection = function (direction) {
// Determine the appropriate mapping for next and previous based on the specified direction.
var keyMap;
if (direction === fluid.a11y.orientation.HORIZONTAL) {
keyMap = LEFT_RIGHT_KEYMAP;
}
else if (direction === fluid.a11y.orientation.VERTICAL) {
// Assume vertical in any other case.
keyMap = UP_DOWN_KEYMAP;
}
return keyMap;
};
var tabKeyHandler = function (selectionContext) {
return function (evt) {
if (evt.which !== $.ui.keyCode.TAB) {
return;
}
cleanUpWhenLeavingContainer(selectionContext);
// Catch Shift-Tab and note that focus is on its way out of the container.
if (evt.shiftKey) {
selectionContext.focusIsLeavingContainer = true;
}
};
};
var containerFocusHandler = function (selectionContext) {
return function (evt) {
var shouldOrig = selectionContext.options.autoSelectFirstItem;
var shouldSelect = typeof(shouldOrig) === "function" ? shouldOrig() : shouldOrig;
// Override the autoselection if we're on the way out of the container.
if (selectionContext.focusIsLeavingContainer) {
shouldSelect = false;
}
// This target check works around the fact that sometimes focus bubbles, even though it shouldn't.
if (shouldSelect && evt.target === selectionContext.container.get(0)) {
if (selectionContext.activeItemIndex === NO_SELECTION) {
selectionContext.activeItemIndex = 0;
}
fluid.focus(selectionContext.selectables[selectionContext.activeItemIndex]);
}
// Force focus not to bubble on some browsers.
return evt.stopPropagation();
};
};
var containerBlurHandler = function (selectionContext) {
return function (evt) {
selectionContext.focusIsLeavingContainer = false;
// Force blur not to bubble on some browsers.
return evt.stopPropagation();
};
};
var makeElementsSelectable = function (container, defaults, userOptions) {
var options = $.extend(true, {}, defaults, userOptions);
var keyMap = getKeyMapForDirection(options.direction);
var selectableElements = options.selectableElements ? options.selectableElements :
container.find(options.selectableSelector);
// Context stores the currently active item(undefined to start) and list of selectables.
var that = {
container: container,
activeItemIndex: NO_SELECTION,
selectables: selectableElements,
focusIsLeavingContainer: false,
options: options
};
that.selectablesUpdated = function (focusedItem) {
// Remove selectables from the tab order and add focus/blur handlers
if (typeof(that.options.selectablesTabindex) === "number") {
that.selectables.fluid("tabindex", that.options.selectablesTabindex);
}
that.selectables.off("focus." + CONTEXT_KEY);
that.selectables.off("blur." + CONTEXT_KEY);
that.selectables.on("focus." + CONTEXT_KEY, selectableFocusHandler(that));
that.selectables.on("blur." + CONTEXT_KEY, selectableBlurHandler(that));
if (keyMap && that.options.noBubbleListeners) {
that.selectables.off("keydown." + CONTEXT_KEY);
that.selectables.on("keydown." + CONTEXT_KEY, arrowKeyHandler(that, keyMap));
}
if (focusedItem) {
selectElement(focusedItem, that);
}
else {
reifyIndex(that);
}
};
that.refresh = function () {
if (!that.options.selectableSelector) {
fluid.fail("Cannot refresh selectable context which was not initialised by a selector");
}
that.selectables = container.find(options.selectableSelector);
that.selectablesUpdated();
};
that.selectedElement = function () {
return that.activeItemIndex < 0 ? null : that.selectables[that.activeItemIndex];
};
// Add various handlers to the container.
if (keyMap && !that.options.noBubbleListeners) {
container.keydown(arrowKeyHandler(that, keyMap));
}
container.keydown(tabKeyHandler(that));
container.focus(containerFocusHandler(that));
container.blur(containerBlurHandler(that));
that.selectablesUpdated();
return that;
};
/**
* Makes all matched elements selectable with the arrow keys.
* Supply your own handlers object with onSelect: and onUnselect: properties for custom behaviour.
* Options provide configurability, including direction: and autoSelectFirstItem:
* Currently supported directions are jQuery.a11y.directions.HORIZONTAL and VERTICAL.
*/
fluid.selectable = function (target, options) {
target = $(target);
var that = makeElementsSelectable(target, fluid.selectable.defaults, options);
fluid.setScopedData(target, CONTEXT_KEY, that);
return that;
};
/**
* Selects the specified element.
*/
fluid.selectable.select = function (target, toSelect) {
fluid.focus(toSelect);
};
/**
* Selects the next matched element.
*/
fluid.selectable.selectNext = function (target) {
target = $(target);
focusNextElement(fluid.getScopedData(target, CONTEXT_KEY));
};
/**
* Selects the previous matched element.
*/
fluid.selectable.selectPrevious = function (target) {
target = $(target);
focusPreviousElement(fluid.getScopedData(target, CONTEXT_KEY));
};
/**
* Returns the currently selected item wrapped as a jQuery object.
*/
fluid.selectable.currentSelection = function (target) {
target = $(target);
var that = fluid.getScopedData(target, CONTEXT_KEY);
return $(that.selectedElement());
};
fluid.selectable.defaults = {
direction: fluid.a11y.orientation.VERTICAL,
selectablesTabindex: -1,
autoSelectFirstItem: true,
rememberSelectionState: true,
selectableSelector: ".selectable",
selectableElements: null,
onSelect: null,
onUnselect: null,
onLeaveContainer: null,
noWrap: false
};
/********************************************************************
* Activation functionality - declaratively associating actions with
* a set of keyboard bindings.
*/
var checkForModifier = function (binding, evt) {
// If no modifier was specified, just return true.
if (!binding.modifier) {
return true;
}
var modifierKey = binding.modifier;
var isCtrlKeyPresent = modifierKey && evt.ctrlKey;
var isAltKeyPresent = modifierKey && evt.altKey;
var isShiftKeyPresent = modifierKey && evt.shiftKey;
return isCtrlKeyPresent || isAltKeyPresent || isShiftKeyPresent;
};
/** Constructs a raw "keydown"-facing handler, given a binding entry. This
* checks whether the key event genuinely triggers the event and forwards it
* to any "activateHandler" registered in the binding.
*/
var makeActivationHandler = function (binding) {
return function (evt) {
var target = evt.target;
if (!fluid.enabled(target)) {
return;
}
// The following 'if' clause works in the real world, but there's a bug in the jQuery simulation
// that causes keyboard simulation to fail in Safari, causing our tests to fail:
// http://ui.jquery.com/bugs/ticket/3229
// The replacement 'if' clause works around this bug.
// When this issue is resolved, we should revert to the original clause.
// if (evt.which === binding.key && binding.activateHandler && checkForModifier(binding, evt)) {
var code = evt.which ? evt.which : evt.keyCode;
if (code === binding.key && binding.activateHandler && checkForModifier(binding, evt)) {
var event = $.Event("fluid-activate");
$(target).trigger(event, [binding.activateHandler]);
if (event.isDefaultPrevented()) {
evt.preventDefault();
}
}
};
};
var makeElementsActivatable = function (elements, onActivateHandler, defaultKeys, options) {
// Create bindings for each default key.
var bindings = [];
$(defaultKeys).each(function (index, key) {
bindings.push({
modifier: null,
key: key,
activateHandler: onActivateHandler
});
});
// Merge with any additional key bindings.
if (options && options.additionalBindings) {
bindings = bindings.concat(options.additionalBindings);
}
fluid.initEnablement(elements);
// Add listeners for each key binding.
for (var i = 0; i < bindings.length; ++i) {
var binding = bindings[i];
elements.keydown(makeActivationHandler(binding));
}
elements.on("fluid-activate", function (evt, handler) {
handler = handler || onActivateHandler;
return handler ? handler(evt) : null;
});
};
/**
* Makes all matched elements activatable with the Space and Enter keys.
* Provide your own handler function for custom behaviour.
* Options allow you to provide a list of additionalActivationKeys.
*/
fluid.activatable = function (target, fn, options) {
target = $(target);
makeElementsActivatable(target, fn, fluid.activatable.defaults.keys, options);
};
/**
* Activates the specified element.
*/
fluid.activate = function (target) {
$(target).trigger("fluid-activate");
};
// Public Defaults.
fluid.activatable.defaults = {
keys: [$.ui.keyCode.ENTER, $.ui.keyCode.SPACE]
};
})(jQuery, fluid_2_0_0);

152
lib/infusion/src/framework/core/js/jquery.standalone.js

@ -0,0 +1,152 @@
/*
* Definitions in this file taken from:
*
* jQuery JavaScript Library v1.6.1
* http://jquery.com/
*
* This implementation is only intended to be used in contexts where the Fluid Infusion framework
* is required to be used without a functioning DOM being available (node.js or other standalone contexts).
* It includes the minimum definitions taken from jQuery required to operate the core of Fluid.js
* without FluidView.js. Consult http://issues.fluidproject.org/browse/FLUID-4568 for more details.
*
* Copyright 2011, John Resig
* Copyright 2011- OCAD University
*
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
* Date: Thu May 12 15:04:36 2011 -0400
*/
/* global jQuery:true, global */
/* exported jQuery */
var fluid_2_0_0 = fluid_2_0_0 || {};
var fluid = fluid || fluid_2_0_0;
(function (fluid) {
"use strict";
// Save a reference to some core methods
var toString = Object.prototype.toString;
var hasOwn = Object.prototype.hasOwnProperty;
var globalScope = typeof window !== "undefined" ? window :
typeof self !== "undefined" ? self : global;
// Map over jQuery in case of overwrite
var _jQuery = globalScope.jQuery;
// Map over the $ in case of overwrite
var _$ = globalScope.$;
var jQuery = fluid.jQueryStandalone = {
// The current version of jQuery being used
jquery: "1.6.1-fluidStandalone",
noConflict: function (deep) {
if (globalScope.$ === jQuery) {
globalScope.$ = _$;
}
if (deep && globalScope.jQuery === jQuery) {
globalScope.jQuery = _jQuery;
}
return jQuery;
},
isArray: Array.isArray || function (obj) {
return toString.call(obj) === "[object Array]";
},
// A crude way of determining if an object is a window
isWindow: function (obj) {
return obj && typeof obj === "object" && "setInterval" in obj;
},
isPlainObject: function (obj) {
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false;
}
// Not own constructor property must be Object
if ( obj.constructor &&
!hasOwn.call(obj, "constructor") &&
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
return false;
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
// TODO: Isn't this enormously expensive?
var key;
for (key in obj) {} // eslint-disable-line no-empty
return key === undefined || hasOwn.call( obj, key );
},
trim: function (str) {
return str.trim();
},
isEmptyObject: function (obj) {
for ( var name in obj ) { // eslint-disable-line no-unused-vars
return false;
}
return true;
},
extend: function () {
var options,
target = arguments[0] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if (typeof target === "boolean") {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
i = 2;
}
// Handle case when target is a string or something (possible in deep copy)
if (typeof target !== "object" && typeof(target) !== "function") {
target = {};
}
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( (options = arguments[ i ]) !== null ) {
// Extend the base object
for (var name in options) {
var src = target[ name ];
var copy = options[ name ];
// Prevent never-ending loop
if ( target === copy ) {
continue;
}
var copyIsArray, clone;
// Recurse if we're merging plain objects or arrays
if (deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy))) ) {
if (copyIsArray) {
copyIsArray = false;
clone = src && jQuery.isArray(src) ? src : [];
} else {
clone = src && jQuery.isPlainObject(src) ? src : {};
}
// Never move original objects, clone them
target[name] = jQuery.extend( deep, clone, copy );
} else if (copy !== undefined) {
// Don't bring in undefined values
target[name] = copy;
}
}
}
}
return target;
}
};
})(fluid_2_0_0);
var jQuery = fluid.jQueryStandalone;

4
lib/infusion/src/framework/enhancement/css/ProgressiveEnhancement.css

@ -0,0 +1,4 @@
/* Progressive Enhancement: JS will reverse the display setup if it is enabled */
.fl-progEnhance-enhanced {display:none}
.fl-progEnhance-basic {}

14
lib/infusion/src/framework/enhancement/enhancementDependencies.json

@ -0,0 +1,14 @@
{
"enhancement": {
"name": "Progressive Enhancement",
"description": "Provides support for progressively enhancing components based on the capabilities of the browser.",
"files": [
"./js/ContextAwareness.js",
"./js/ProgressiveEnhancement.js"
],
"dependencies": [
"jQuery",
"framework"
]
}
}

221
lib/infusion/src/framework/enhancement/js/ContextAwareness.js

@ -0,0 +1,221 @@
/*
Copyright 2008-2009 University of Toronto
Copyright 2010-2016 OCAD University
Copyright 2015-2016 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
fluid.registerNamespace("fluid.contextAware");
fluid.defaults("fluid.contextAware.marker", {
gradeNames: ["fluid.component"]
});
// unsupported, NON-API function
fluid.contextAware.makeCheckMarkers = function (checks, path, instantiator) {
fluid.each(checks, function (value, markerTypeName) {
fluid.constructSingle(path, {
type: markerTypeName,
gradeNames: "fluid.contextAware.marker",
value: value
}, instantiator);
});
};
/** Peforms the computation for `fluid.contextAware.makeChecks` and returns a structure suitable for being sent to `fluid.contextAware.makeCheckMarkers` -
*
* @return A hash of marker type names to grade names - this can be sent to fluid.contextAware.makeCheckMarkers
*/
// unsupported, NON-API function
fluid.contextAware.performChecks = function (checkHash) {
return fluid.transform(checkHash, function (checkRecord) {
if (typeof(checkRecord) === "function") {
checkRecord = {func: checkRecord};
} else if (typeof(checkRecord) === "string") {
checkRecord = {funcName: checkRecord};
}
if (fluid.isPrimitive(checkRecord)) {
return checkRecord;
} else if ("value" in checkRecord) {
return checkRecord.value;
} else if ("func" in checkRecord) {
return checkRecord.func();
} else if ("funcName" in checkRecord) {
return fluid.invokeGlobalFunction(checkRecord.funcName);
} else {
fluid.fail("Error in contextAwareness check record ", checkRecord, " - must contain an entry with name value, func, or funcName");
}
});
};
/**
* Takes an object whose keys are check context names and whose values are check records, designating a collection of context markers which might be registered at a location
* in the component tree.
* @param checkHash {Object} The keys in this structure are the context names to be supplied if the check passes, and the values are check records.
* A check record contains:
* ONE OF:
* value {Any} [optional] A literal value name to be attached to the context
* func {Function} [optional] A zero-arg function to be called to compute the value
* funcName {String} [optional] The name of a zero-arg global function which will compute the value
* If the check record consists of a Number or Boolean, it is assumed to be the value given to "value".
* @param path {String|Array} [optional] The path in the component tree at which the check markers are to be registered. If omitted, "" is assumed
* @param instantiator {Instantiator} [optional] The instantiator holding the component tree which will receive the markers. If omitted, use `fluid.globalInstantiator`.
*/
fluid.contextAware.makeChecks = function (checkHash, path, instantiator) {
var checkOptions = fluid.contextAware.performChecks(checkHash);
fluid.contextAware.makeCheckMarkers(checkOptions, path, instantiator);
};
/**
* Forgets a check made at a particular level of the component tree.
* @param markerNames {Array of String} The marker typeNames whose check values are to be forgotten
* @param path {String|Array} [optional] The path in the component tree at which the check markers are to be removed. If omitted, "" is assumed
* @param instantiator {Instantiator} [optional] The instantiator holding the component tree the markers are to be removed from. If omitted, use `fluid.globalInstantiator`.
*/
fluid.contextAware.forgetChecks = function (markerNames, path, instantiator) {
instantiator = instantiator || fluid.globalInstantiator;
path = path || [];
var markerArray = fluid.makeArray(markerNames);
fluid.each(markerArray, function (markerName) {
var memberName = fluid.typeNameToMemberName(markerName);
var segs = fluid.model.parseToSegments(path, instantiator.parseEL, true);
segs.push(memberName);
fluid.destroy(segs, instantiator);
});
};
/** A grade to be given to a component which requires context-aware adaptation.
* This grade consumes configuration held in the block named "contextAwareness", which is an object whose keys are check namespaces and whose values hold
* sequences of "checks" to be made in the component tree above the component. The value searched by
* each check is encoded as the element named `contextValue` - this either represents an IoC reference to a component
* or a particular value held at the component. If this reference has no path component, the path ".options.value" will be assumed.
* These checks seek contexts which
* have been previously registered using fluid.contextAware.makeChecks. The first context which matches
* with a value of `true` terminates the search, and returns by applying the grade names held in `gradeNames` to the current component.
* If no check matches, the grades held in `defaultGradeNames` will be applied.
*/
fluid.defaults("fluid.contextAware", {
gradeNames: ["{that}.check"],
mergePolicy: {
contextAwareness: "noexpand"
},
contextAwareness: {
// Hash of names (check namespaces) to records: {
// checks: {}, // Hash of check namespace to: {
// contextValue: IoCExpression testing value in environment,
// gradeNames: gradeNames which will be output,
// priority: String/Number for priority of check [optional]
// equals: Value to be compared to contextValue [optional - default is `true`]
// defaultGradeNames: // String or Array of String holding default gradeNames which will be output if no check matches [optional]
// priority: // Number or String encoding priority relative to other records (same format as with event listeners) [optional]
// }
},
invokers: {
check: {
funcName: "fluid.contextAware.check",
args: ["{that}", "{that}.options.contextAwareness"]
}
}
});
fluid.contextAware.getCheckValue = function (that, reference) {
// cf. core of distributeOptions!
var targetRef = fluid.parseContextReference(reference);
var targetComponent = fluid.resolveContext(targetRef.context, that);
var path = targetRef.path || ["options", "value"];
var value = fluid.getForComponent(targetComponent, path);
return value;
};
// unsupported, NON-API function
fluid.contextAware.checkOne = function (that, contextAwareRecord) {
if (contextAwareRecord.checks && contextAwareRecord.checks.contextValue) {
fluid.fail("Nesting error in contextAwareness record ", contextAwareRecord, " - the \"checks\" entry must contain a hash and not a contextValue/gradeNames record at top level");
}
var checkList = fluid.parsePriorityRecords(contextAwareRecord.checks, "contextAwareness checkRecord");
return fluid.find(checkList, function (check) {
if (!check.contextValue) {
fluid.fail("Cannot perform check for contextAwareness record ", check, " without a valid field named \"contextValue\"");
}
var value = fluid.contextAware.getCheckValue(that, check.contextValue);
if (check.equals === undefined ? value : value === check.equals) {
return check.gradeNames;
}
}, contextAwareRecord.defaultGradeNames);
};
// unsupported, NON-API function
fluid.contextAware.check = function (that, contextAwarenessOptions) {
var gradeNames = [];
var contextAwareList = fluid.parsePriorityRecords(contextAwarenessOptions, "contextAwareness adaptationRecord");
fluid.each(contextAwareList, function (record) {
var matched = fluid.contextAware.checkOne(that, record);
gradeNames = gradeNames.concat(fluid.makeArray(matched));
});
return gradeNames;
};
/** Given a set of options, broadcast an adaptation to all instances of a particular component in a particular context. ("new demands blocks").
* This has the effect of fabricating a grade with a particular name with an options distribution to `{/ typeName}` for the required component,
* and then constructing a single well-known instance of it.
* Options layout:
* distributionName {String} A grade name - the name to be given to the fabricated grade
* targetName {String} A grade name - the name of the grade to receive the adaptation
* adaptationName {String} the name of the contextAwareness record to receive the record - this will be a simple string
* checkName {String} the name of the check within the contextAwareness record to receive the record - this will be a simple string
* record {Object} the record to be broadcast into contextAwareness - should contain entries
* contextValue {IoC expression} the context value to be checked to activate the adaptation
* gradeNames {String/Array of String} the grade names to be supplied to the adapting target (matching advisedName)
*/
fluid.contextAware.makeAdaptation = function (options) {
fluid.expect("fluid.contextAware.makeAdaptation", options, ["distributionName", "targetName", "adaptationName", "checkName", "record"]);
fluid.defaults(options.distributionName, {
gradeNames: ["fluid.component"],
distributeOptions: {
target: "{/ " + options.targetName + "}.options.contextAwareness." + options.adaptationName + ".checks." + options.checkName,
record: options.record
}
});
fluid.constructSingle([], options.distributionName);
};
// Context awareness for the browser environment
fluid.contextAware.isBrowser = function () {
return typeof(window) !== "undefined" && window.document;
};
fluid.contextAware.makeChecks({
"fluid.browser": {
funcName: "fluid.contextAware.isBrowser"
}
});
// Context awareness for the reported browser platform name (operating system)
fluid.registerNamespace("fluid.contextAware.browser");
fluid.contextAware.browser.getPlatformName = function () {
return typeof(navigator) !== "undefined" && navigator.platform ? navigator.platform : undefined;
};
fluid.contextAware.makeChecks({
"fluid.browser.platformName": {
funcName: "fluid.contextAware.browser.getPlatformName"
}
});
})(jQuery, fluid_2_0_0);

34
lib/infusion/src/framework/enhancement/js/ProgressiveEnhancement.js

@ -0,0 +1,34 @@
/*
Copyright 2008-2009 University of Toronto
Copyright 2010-2011 OCAD University
Copyright 2013 Raising the Floor - US
Copyright 2015 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
fluid.registerNamespace("fluid.enhance");
/**********************************************************
* This code runs immediately upon inclusion of this file *
**********************************************************/
// Use JavaScript to hide any markup that is specifically in place for cases when JavaScript is off.
// Note: the use of fl-ProgEnhance-basic is deprecated, and replaced by fl-progEnhance-basic.
// It is included here for backward compatibility only.
// Distinguish the standalone jQuery from the real one so that this can be included in IoC standalone tests
if (fluid.contextAware.isBrowser() && $.fn) {
$("head").append("<style type='text/css'>.fl-progEnhance-basic, .fl-ProgEnhance-basic { display: none; } .fl-progEnhance-enhanced, .fl-ProgEnhance-enhanced { display: block; }</style>");
}
})(jQuery, fluid_2_0_0);

1
lib/infusion/src/framework/preferences/css/Enactors.css

File diff suppressed because one or more lines are too long

1
lib/infusion/src/framework/preferences/css/FullNoPreviewPrefsEditor.css

@ -0,0 +1 @@
body{max-width:60em;min-width:56em}.fl-prefsEditor-fullNoPreview .fl-prefsEditor-category{border-top:2px solid #ddd;clear:both;-webkit-column-break-inside:avoid;page-break-inside:avoid;break-inside:avoid;}.fl-prefsEditor-fullNoPreview .fl-prefsEditor-category h2 img{padding-top:10px;margin-bottom:-4px}.fl-prefsEditor-fullNoPreview .fl-prefsEditor-buttons{text-align:right}.fl-prefsEditor-fullNoPreview .fl-prefsEditors-controls{-webkit-columns:15.625rem 4;-moz-columns:15.625rem 4;columns:15.625rem 4}.fl-prefsEditor-fullNoPreview ul{float:left;}.fl-prefsEditor-fullNoPreview ul li{clear:left}.fl-prefsEditor-fullNoPreview label,.fl-prefsEditor-fullNoPreview .fl-inputs{margin-bottom:15px}

1
lib/infusion/src/framework/preferences/css/FullPrefsEditor.css

@ -0,0 +1 @@
.fl-prefsEditor h2{font-size:1.29em;font-weight:bold;clear:both;color:#444;padding:14px 0 5px 25px}.fl-prefsEditor .fl-prefsEditor-buttons{margin-top:1em;float:left;width:100%;}.fl-prefsEditor .fl-prefsEditor-buttons input{text-transform:uppercase;text-decoration:underline;font-weight:bold;border:2px solid #cecece;font-size:1em;padding:5px;height:2.5em;margin-right:3px;background-color:#f0f0f0}.fl-prefsEditor h2 img{margin-bottom:-3px;padding-right:5px}.fl-prefsEditor .fl-prefsEditor-text ul li{clear:left;height:3.5em}.fl-prefsEditor .fl-slider-input{float:right}

1
lib/infusion/src/framework/preferences/css/FullPreviewPrefsEditor.css

@ -0,0 +1 @@
.fl-prefsEditor-fullPreview{min-width:800px;}.fl-prefsEditor-fullPreview ul li{clear:left}.fl-prefsEditor-fullPreview .fl-prefsEditor-fullPreview-adjusters{width:60%}.fl-prefsEditor-fullPreview .fl-prefsEditor-fullPreview-previewContainer{width:35%}.fl-prefsEditor-fullPreview h2{border-top:2px solid #ddd;margin-bottom:20px}.fl-prefsEditor-fullPreview .fl-prefsEditor-category{padding-bottom:20px}.fl-prefsEditor-fullPreview ul{margin-left:0;}.fl-prefsEditor-fullPreview ul li{list-style:none;width:100%}.fl-prefsEditor-fullPreview .fl-slider{float:left}.fl-prefsEditor-fullPreview label{display:block;width:16em}.fl-prefsEditor-fullPreview .fl-prefsEditor-layout li,.fl-prefsEditor-fullPreview .fl-prefsEditor-links li{padding-bottom:10px}.fl-prefsEditor-fullPreview .fl-prefsEditor-preview iframe{height:480px;width:100%;border:2px solid #d7d7d7}.fl-prefsEditor-fullPreview .fl-prefsEditor-preview h2{font-weight:lighter;font-size:1.8em;color:#4d4d4d;padding:18px 0 0 0}.fl-prefsEditor .fl-inputs{float:left}.fl-prefsEditor input[type="text"]{width:2em}

1
lib/infusion/src/framework/preferences/css/PrefsEditor.css

File diff suppressed because one or more lines are too long

1
lib/infusion/src/framework/preferences/css/SeparatedPanelPrefsEditor.css

@ -0,0 +1 @@
@font-face{font-family:'OpenSans';src:url("../../../lib/fonts/OpenSans-Light.ttf");font-weight:300;font-style:normal}@font-face{font-family:'OpenSans';src:url("../../../lib/fonts/OpenSans-Regular.ttf");font-weight:normal;font-style:normal}@font-face{font-family:'OpenSans';src:url("../../../lib/fonts/OpenSans-Semibold.ttf");font-weight:600;font-style:normal}.fl-prefsEditor-separatedPanel .fl-panelBar{width:100%;background-color:#fff;border-bottom:1px solid #ccc;}.fl-prefsEditor-separatedPanel .fl-panelBar .fl-prefsEditor-buttons{box-shadow:2px 2px 3px 0 #6f6f6f;border-bottom:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;border-bottom-left-radius:8px;border-bottom-right-radius:8px;background-color:#fff;min-height:2em;margin-right:10em;display:block;float:right}.fl-prefsEditor-separatedPanel .fl-prefsEditor-showHide{min-width:15em}.fl-prefsEditor-separatedPanel .fl-prefsEditor-showHide,.fl-prefsEditor-separatedPanel .fl-prefsEditor-reset{text-transform:lowercase;font-weight:bold;border:0;background-color:#fff;height:1.8em;color:#2f2b2a;font-family:'OpenSans',"Myriad Pro",Helvetica,Arial,sans-serif;font-size:1.1em;margin-right:.5em;margin-left:.5em}.fl-prefsEditor-separatedPanel .fl-prefsEditor-reset{border-right:1px solid #ccc}.fl-prefsEditor-separatedPanel .fl-icon-undo{font-family:'InfusionIcons' !important;speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;float:left;margin-right:.3em;margin-top:-.1em;font-size:1em}.fl-prefsEditor-separatedPanel .fl-icon-undo:before{content:"\e008"}.fl-prefsEditor-separatedPanel-iframe{border:0;background-color:#fff;height:0;display:block;width:100%}.fl-theme-bw{background-image:none !important;background-color:#fff;border-color:#000;color:#000;}.fl-theme-bw .fl-prefsEditor-separatedPanel .fl-panelBar,.fl-theme-bw .fl-prefsEditor-separatedPanel .fl-prefsEditor-reset{background-color:#fff;border-color:#000;color:#000}.fl-theme-bw .fl-prefsEditor-separatedPanel .fl-prefsEditor-buttons{box-shadow:none}.fl-theme-wb{background-image:none !important;background-color:#000;border-color:#fff;color:#fff;}.fl-theme-wb .fl-prefsEditor-separatedPanel .fl-panelBar,.fl-theme-wb .fl-prefsEditor-separatedPanel .fl-prefsEditor-reset{background-color:#000;border-color:#fff;color:#fff}.fl-theme-wb .fl-prefsEditor-separatedPanel .fl-prefsEditor-buttons{box-shadow:none}.fl-theme-yb{background-image:none !important;background-color:#000;border-color:#ff0;color:#ff0;}.fl-theme-yb .fl-prefsEditor-separatedPanel .fl-panelBar,.fl-theme-yb .fl-prefsEditor-separatedPanel .fl-prefsEditor-reset{background-color:#000;border-color:#ff0;color:#ff0}.fl-theme-yb .fl-prefsEditor-separatedPanel .fl-prefsEditor-buttons{box-shadow:none}.fl-theme-by{background-image:none !important;background-color:#ff0;border-color:#000;color:#000;}.fl-theme-by .fl-prefsEditor-separatedPanel .fl-panelBar,.fl-theme-by .fl-prefsEditor-separatedPanel .fl-prefsEditor-reset{background-color:#ff0;border-color:#000;color:#000}.fl-theme-by .fl-prefsEditor-separatedPanel .fl-prefsEditor-buttons{box-shadow:none}.fl-theme-lgdg{background-image:none !important;background-color:#555;border-color:#bdbdbb;color:#bdbdbb;}.fl-theme-lgdg .fl-prefsEditor-separatedPanel .fl-panelBar,.fl-theme-lgdg .fl-prefsEditor-separatedPanel .fl-prefsEditor-reset{background-color:#555;border-color:#bdbdbb;color:#bdbdbb}.fl-theme-lgdg .fl-prefsEditor-separatedPanel .fl-prefsEditor-buttons{box-shadow:none}

1
lib/infusion/src/framework/preferences/css/SeparatedPanelPrefsEditorFrame.css

@ -0,0 +1 @@
@font-face{font-family:"OpenSans";src:url("../../../lib/fonts/OpenSans-Light.ttf");font-weight:300;font-style:normal}@font-face{font-family:'OpenSans';src:url("../../../lib/fonts/OpenSans-Regular.ttf");font-weight:normal;font-style:normal}@font-face{font-family:'OpenSans';src:url("../../../lib/fonts/OpenSans-Semibold.ttf");font-weight:600;font-style:normal}html{overflow:visible}.fl-prefsEditor-separatedPanel{background-color:#fff;background-image:url("../images/default/separatedpanelbg.png");background-repeat:repeat;height:100%;overflow-x:auto;overflow-y:hidden;color:#766d68;padding:1px 0;margin:0;}.fl-prefsEditor-separatedPanel .fl-prefsEditor{font-family:'OpenSans',"Myriad Pro",Helvetica,Arial,sans-serif;line-height:1.2em !important}.fl-prefsEditor-separatedPanel .fl-prefsEditor-panels{white-space:nowrap;display:table;border-spacing:20px 0;}.fl-prefsEditor-separatedPanel .fl-prefsEditor-panels .fl-prefsEditor-panel{border:1px solid #615e59;border-radius:5px;box-shadow:2px 2px #7a766d;display:inline-block;padding:1em;min-width:25em;background-color:#fff;white-space:normal;display:table-cell}.fl-prefsEditor-separatedPanel h2{color:#766d68;padding:0 0 .5em 0;margin:0 0 1.5em 0;width:100%;border-bottom:solid #ccc 1px;box-shadow:0 6px 7px -6px rgba(0,0,0,0.3);font-size:1.2em;text-transform:lowercase;line-height:1.7em;height:2em}.fl-prefsEditor-separatedPanel .fl-inputs{float:none;padding:0}.fl-prefsEditor-separatedPanel label{font-size:1em;display:block}.fl-prefsEditor-separatedPanel .fl-links-buttons-options label{width:21em;display:inline-block}.fl-prefsEditor-separatedPanel .fl-links-buttons-options li{margin-bottom:.4em}.fl-prefsEditor-separatedPanel h2 label,.fl-prefsEditor-separatedPanel h2 .fl-heading-text{float:left;padding-top:.2em;font-size:1.3em;font-weight:600}.fl-prefsEditor-separatedPanel.fl-theme-bw{background-image:none}.fl-prefsEditor-separatedPanel.fl-theme-wb{background-image:none}.fl-prefsEditor-separatedPanel.fl-theme-yb{background-image:none}.fl-prefsEditor-separatedPanel.fl-theme-by{background-image:none}.fl-prefsEditor-separatedPanel.fl-theme-lgdg{background-image:none}

42
lib/infusion/src/framework/preferences/css/stylus/Enactors.styl

@ -0,0 +1,42 @@
/*
* General prefs editor styling used to apply preferences
* !important is used for all styles to ensure that Preferences Framework's enactors are able to override the page's default styles.
*/
@import "utils/Themes"
.fl-font-arial,
.fl-font-arial * {
font-family: "Arial" !important;
}
.fl-font-verdana,
.fl-font-verdana * {
font-family: "Verdana" !important;
}
.fl-font-times,
.fl-font-times * {
font-family: Georgia, Times, "Times New Roman", serif !important;
}
.fl-font-comic-sans,
.fl-font-comic-sans * {
font-family: "Comic Sans MS", sans-serif !important;
}
// UI Enhancer "Enlarge text" link options
.fl-text-larger input,
.fl-text-larger button {
font-size: 125% !important;
}
// UI Enhancer 'enhanced links' styling
.fl-link-enhanced a {
font-size: 125% !important;
text-decoration: underline !important;
font-weight: bold !important;
}
// Theming
build-themes-Enactors(themes);

47
lib/infusion/src/framework/preferences/css/stylus/FullNoPreviewPrefsEditor.styl

@ -0,0 +1,47 @@
// UI Option styles for Full page without preview
body {
max-width: 60em;
min-width: 56em;
}
.fl-prefsEditor-fullNoPreview {
// Category separator
.fl-prefsEditor-category {
border-top: 2px solid #dddddd;
clear: both;
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
// Section header icons
h2 img {
padding-top: 10px;
margin-bottom: -4px;
}
}
// Save, reset, cancel buttons
.fl-prefsEditor-buttons {
text-align: right;
}
// Controls
.fl-prefsEditors-controls {
-webkit-columns: 15.625rem 4;
-moz-columns: 15.625rem 4;
columns: 15.625rem 4;
}
ul {
float: left;
li {
clear: left;
}
}
label, .fl-inputs {
margin-bottom: 15px; // adds space between label, inputs when browser window is narrow
}
}

47
lib/infusion/src/framework/preferences/css/stylus/FullPrefsEditor.styl

@ -0,0 +1,47 @@
// UI Option styles for full page layouts both with and without preview
// Control section headers
.fl-prefsEditor {
h2 {
font-size: 1.29em;
font-weight: bold;
clear: both;
color: #444444;
padding: 14px 0px 5px 25px;
}
// Save, reset, cancel buttons
.fl-prefsEditor-buttons {
margin-top: 1em;
float: left;
width: 100%;
input {
text-transform: uppercase;
text-decoration: underline;
font-weight: bold;
border: 2px solid #cecece;
font-size: 1em;
padding: 5px;
height: 2.5em;
margin-right: 3px;
background-color: #F0F0F0;
}
}
// Section header icons
h2 img {
margin-bottom: -3px;
padding-right: 5px;
}
// Text controls
.fl-prefsEditor-text ul li {
clear: left;
height: 3.5em;
}
.fl-slider-input {
float: right;
}
}

75
lib/infusion/src/framework/preferences/css/stylus/FullPreviewPrefsEditor.styl

@ -0,0 +1,75 @@
// UI Option styles for full page layout with preview
.fl-prefsEditor-fullPreview {
min-width: 800px;
ul li {
clear: left;
}
.fl-prefsEditor-fullPreview-adjusters {
width: 60%;
}
.fl-prefsEditor-fullPreview-previewContainer {
width: 35%;
}
// Control section headers
h2 {
border-top: 2px solid #dddddd;
margin-bottom: 20px;
}
.fl-prefsEditor-category {
padding-bottom: 20px;
}
// Controls
ul {
margin-left: 0px;
li {
list-style: none;
width: 100%;
}
}
// Slider
.fl-slider {
float:left;
}
// Text controls
label {
display: block;
width: 16em;
}
// Layout and link controls
.fl-prefsEditor-layout li, .fl-prefsEditor-links li {
padding-bottom: 10px;
}
// Preview Area
.fl-prefsEditor-preview iframe {
height: 480px;
width: 100%;
border: 2px solid #d7d7d7;
}
.fl-prefsEditor-preview h2 {
font-weight: lighter;
font-size: 1.8em;
color: #4D4D4D;
padding: 18px 0px 0px 0px;
}
}
.fl-prefsEditor .fl-inputs {
float: left;
}
.fl-prefsEditor input[type="text"] {
width: 2em;
}

420
lib/infusion/src/framework/preferences/css/stylus/PrefsEditor.styl

@ -0,0 +1,420 @@
/* General Preferences Editor styles, used for all layouts */
@import "utils/Helpers"
@import "utils/Themes"
@font-face {
font-family: 'InfusionIcons';
src: url('../fonts/InfusionIcons-PrefsEditor.ttf'),
url('../fonts/InfusionIcons-PrefsEditor.eot');
}
.fl-prefsEditor {
font-family: "Myriad Pro", Helvetica, Arial, sans-serif;
// Controls
.fl-prefsEditor-panels {
margin-left: 0;
padding: 0;
li {
list-style: none;
}
}
label {
font-size: 1.2em;
}
input {
&[type="text"] {
width:2em;
font-size: 1em;
}
// Check boxes
&[type="checkbox"] {
margin-right:10px;
border: 1px solid black;
}
}
// Fieldset (remove default browser visual styling)
fieldset {
border: 0 transparent;
margin: 0;
padding: 0;
}
// Legend
legend {
padding: 0;
margin: 0 0 1em 0;
display: block;
}
// Drop downs
select {
border: 2px solid #ebebeb;
}
select {
&#textFont {
font-weight:bold;
option {
&.times {
font-family: "Times New Roman";
}
&.comic {
font-family: "Comic Sans MS";
}
&.arial {
font-family: Arial;
}
&.verdana {
font-family: Verdana;
}
}
}
&#theme {
font-weight:bold;
text-transform: uppercase;
option.fl-prefsEditor-default-theme {
color: #000 !important;
background-color: #efefef !important;
}
}
}
// Text and display controls
.fl-prefsEditor-text {
label {
display: block;
}
.fl-inputs {
float: left;
font-size: 1em;
}
}
.fl-prefsEditor-layout div,
.fl-prefsEditor-links div {
margin-left: 25px;
}
// Sliders
.fl-slider {
float:left;
border: 1px solid #b3b3b3;
border-radius: 0.3em;
background-color: #dad6d3;
padding: 0;
position: relative;
height: 1em;
margin-top: 0;
margin-left: 0.8em;
margin-right: 1.8em;
a, .fl-slider-handle {
position:absolute;
display:block;
top:0;
left:0;
margin-top: -0.4em;
margin-left: -0.4em;
slider-thumb-common();
&:active {
outline: none;
}
}
}
// Native slider appearance
// based on techniques described at https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/
// and http://brennaobrien.com/blog/2014/05/style-input-type-range-in-every-browser.html
input[type=range].fl-slider {
-webkit-appearance: none; /* Hides the slider so that custom slider can be made */
// Native slider thumb appearance
&::-webkit-slider-thumb {
-webkit-appearance: none;
slider-thumb-common();
}
&::-moz-range-thumb {
slider-thumb-common();
}
&::-ms-thumb {
slider-thumb-common();
}
// Native slider track appearance
// We hide any inherent track styling and let the styles
// set with the fl-slider class be used without interference
// from native widget styling
&::-webkit-slider-runnable-track {
slider-native-track-common();
}
&::-moz-range-track {
slider-native-track-common();
}
&::-ms-track {
slider-native-track-common();
color: transparent;
}
&::-ms-fill-lower {
background: none;
background-color: transparent;
border: 0;
}
&::-ms-fill-upper {
background: none;
background-color: transparent;
border: 0;
}
}
.fl-slider-horz {
width: 8.8em;
}
.fl-slider-input {
margin-left: 1em;
float:left;
}
.fl-slider-range {
background-color: #62bb3d;
height: 100%;
}
.fl-inputs div[class*='fl-icon-'] {
font-size: 1.5em;
margin-top: -0.15em;
}
// Theme radio buttons
.fl-choice {
display: inline;
float: left;
label {
margin-right: 5px;
border: 1px solid black;
border-radius: 5px;
height: 3em;
width: 3em;
text-align: center;
vertical-align: middle;
display: inline-block;
line-height: 3em !important;
padding: 2px;
}
.fl-preview-A {
font-size: 2em;
}
// Pseudo content to prevent AT from reading display 'a'
.fl-preview-A:before {
content: "a";
}
input:focus ~ label {
outline: 2px solid black;
}
}
// ON/OFF Switch for checkboxes
// The container for the toggle, which is also a label for the hidden checkbox.
.fl-prefsEditor-onoff {
.fl-prefsEditor-switch {
border-radius:50px;
border: 1px solid #776D67;
width: 5em;
height: 2em;
background-color: #E6E6E6;
box-shadow: 1em 1.1em 0 0 rgba(250,250,250,0.53) inset;
overflow: hidden;
vertical-align: middle;
display: block;
margin-top: 1em;
transition-duration: 0.2s;
transition-property: padding-left, width, background-color, margin-left;
font-size: 1.2em;
font-weight: 600;
text-transform: lowercase;
}
// Hide input while still being screen reader accessible
input {
border: 0 none;
clip: rect(0px, 0px, 0px, 0px);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
input:focus + label {
outline: 2px solid black;
}
input:checked + label .fl-prefsEditor-switch {
padding-left: 3em;
width: 2em;
background-color: #2da750;
box-shadow: -1em 1.1em 0.1em 0 rgba(172, 216, 92, 0.63) inset;
.fl-prefsEditor-switch-inner {
top:-1.6em;
left: 0.46em;
}
}
// With data attributes defining the on/off text, localizing the templates is easier
input + label {
[data-checkboxStateOn]:before {
content: attr(data-checkboxStateOn);
}
[data-checkboxStateOff]:after {
content: attr(data-checkboxStateOff);
}
// The "on" portion of the toggle and the knob.
.fl-prefsEditor-switch {
&:before {
color: #fff;
border: 1px solid #776D67;
border-radius: 50px;
float:left;
width:1.9em;
height: 1.9em; // Width and height of the knob.
text-indent:-1.6em;
line-height:1.7em;
text-shadow: 1px 1px 1px #000;
background-color: #fff;
box-shadow: 0.2em 0.2em 0.5em #888;
background-image: linear-gradient(bottom, rgb(205,204,202) 0%, rgb(244,244,244) 100%);
}
// The "off" portion of the toggle.
&:after {
float: left;
position: relative;
top: 0.36em;
left: 0.5em;
}
}
}
// The dark inner circle to the toggle knob.
.fl-prefsEditor-switch-inner {
border: 1px solid #493A30;
border-radius: 50px;
width: 1em;
height: 1em;
position: relative;
left: -2.85em;
top: 0.46em;
background-color: #675243;
box-shadow: 0 -0.2em 0.3em 0.05em rgba(250, 250, 250, 0.3) inset;
display: inline-block;
}
}
// Font Icons
.fl-icon-indicator, .fl-icon-crossout, .fl-icon-big-a, .fl-icon-small-a, .fl-icon-line-space-expanded, .fl-icon-line-space-condensed,
.fl-icon-contrast, .fl-icon-undo, .fl-icon-line-space, .fl-icon-links, .fl-icon-simplify, .fl-icon-font, .fl-icon-size, .fl-icon-text-to-speech, .fl-icon-toc {
font-family: 'InfusionIcons' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
-webkit-font-smoothing: antialiased;
float: left;
margin: 0.2em 0.3em 0 0;
font-size: 1.5em;
}
// control icons
.fl-icon-crossout:before, .fl-choice .fl-prefsEditor-contrast-defaultThemeLabel .fl-crossout:before {
content: "\e004";
}
.fl-icon-big-a:before {
content: "\e006";
}
.fl-icon-small-a:before {
content: "\e007";
}
.fl-icon-line-space-expanded:before {
content: "\e009";
}
.fl-icon-line-space-condensed:before {
content: "\e00a";
}
.fl-icon-indicator:before, .fl-choice input:checked + div:before {
content: "\e003";
}
.fl-choice {
.fl-indicator {
font-family: 'InfusionIcons' !important;
font-size: 1.3em;
margin: -0.75em 0 0 0.75em;
height: 1em;
}
.fl-prefsEditor-contrast-defaultThemeLabel .fl-crossout {
font-family: 'InfusionIcons' !important;
margin-top: -1.75em;
font-size: 1.85em;
}
label.fl-theme-prefsEditor-default,
label.fl-theme-prefsEditor-default span,
label.fl-prefsEditor-contrast-defaultThemeLabel .fl-crossout {
background-color: #FFFFFF !important;
border-color: #433F3D !important;
color: #433F3D !important;
}
}
// header icons
.fl-icon-contrast:before {
content: "\e005";
}
.fl-icon-line-space:before {
content: "\e00b";
}
.fl-icon-links:before {
content: "\e00c";
}
.fl-icon-simplify:before {
content: "\e00e";
}
.fl-icon-font:before {
content: "\e00f";
}
.fl-icon-size:before {
content: "\e010";
}
.fl-icon-text-to-speech:before {
content: "\e011";
}
.fl-icon-toc:before {
content: "\e012";
}
}
// Theming
build-themes-prefsEditor(themes);

26
lib/infusion/src/framework/preferences/css/stylus/README.md

@ -0,0 +1,26 @@
## Overview ##
The "[stylus](./)" directory contains Stylus files for generating the Preference Framework stylesheets.
### How to add a new theme ###
Define your own themes variable that looks like:
```
contrastThemes = {
"theme-selector": {
foregroundColor: #000000,
backgroundColor: #ffffff
}
...
}
```
When calling Stylus mixins defined in "[utils/Themes.styl](./utils/Themes.styl)", pass in your own themes variable as a parameter, such as:
```
build-themes-Enactors(contrastThemes);
```
### How to prevent grunt from compiling utility Stylus files ###
Some Stylus files may only contain mixins or functions for other Stylus files to import. Those files should not be compiled into CSS. To prevent the grunt task `grunt buildStylus` from compiling them, place these files in the "[utils](./utils)" directory.

97
lib/infusion/src/framework/preferences/css/stylus/SeparatedPanelPrefsEditor.styl

@ -0,0 +1,97 @@
@import "utils/Themes"
@font-face {
font-family: 'OpenSans';
src:url('../../../lib/fonts/OpenSans-Light.ttf');
font-weight: 300;
font-style: normal;
}
@font-face {
font-family: 'OpenSans';
src:url('../../../lib/fonts/OpenSans-Regular.ttf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'OpenSans';
src:url('../../../lib/fonts/OpenSans-Semibold.ttf');
font-weight: 600;
font-style: normal;
}
// Top bar and show/hide button
.fl-prefsEditor-separatedPanel {
.fl-panelBar {
width: 100%;
background-color: #fff;
border-bottom: 1px solid #ccc;
.fl-prefsEditor-buttons {
box-shadow: 2px 2px 3px 0 #6f6f6f;
border-bottom: 1px solid #ccc;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc; //FLUID-4991: The shadow effect around the hide/show preferences bug fix. (Border right added)
border-bottom-left-radius:8px;
border-bottom-right-radius:8px;
background-color: white;
min-height: 2em;
margin-right: 10em;
display: block;
float: right;
}
}
.fl-prefsEditor-showHide {
min-width: 15em;
}
.fl-prefsEditor-showHide, .fl-prefsEditor-reset {
text-transform: lowercase;
font-weight: bold;
border: 0;
background-color: white;
height: 1.8em;
color: #2f2b2a;
font-family: 'OpenSans',"Myriad Pro", Helvetica, Arial, sans-serif;
font-size: 1.1em;
margin-right: 0.5em;
margin-left: 0.5em;
}
.fl-prefsEditor-reset {
border-right: 1px solid #ccc;
}
// Font icon for reset tab
.fl-icon-undo {
font-family: 'InfusionIcons' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
-webkit-font-smoothing: antialiased;
float: left;
margin-right: 0.3em;
margin-top: -0.1em;
font-size: 1em;
}
.fl-icon-undo:before {
content: "\e008";
}
}
// IFrame
.fl-prefsEditor-separatedPanel-iframe {
border: 0;
background-color: #fff;
height: 0px;
display: block;
width: 100%;
}
// Theming
build-themes-separatedPanelPrefsEditor(themes);

110
lib/infusion/src/framework/preferences/css/stylus/SeparatedPanelPrefsEditorFrame.styl

@ -0,0 +1,110 @@
@import "utils/Themes"
@font-face {
font-family: "OpenSans";
src: url("../../../lib/fonts/OpenSans-Light.ttf");
font-weight: 300;
font-style: normal;
}
@font-face {
font-family: 'OpenSans';
src:url('../../../lib/fonts/OpenSans-Regular.ttf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'OpenSans';
src:url('../../../lib/fonts/OpenSans-Semibold.ttf');
font-weight: 600;
font-style: normal;
}
html {
overflow: visible
}
/* Preferences Editor Separated Panel styles */
.fl-prefsEditor-separatedPanel {
background-color: #fff;
background-image: url('../images/default/separatedpanelbg.png');
background-repeat: repeat;
height: 100%;
overflow-x: auto;
overflow-y: hidden;
color: #766d68;
padding: 1px 0px;
margin: 0px;
.fl-prefsEditor {
font-family: 'OpenSans',"Myriad Pro", Helvetica, Arial, sans-serif;
line-height: 1.2em !important; // FLUID-4959: fix the line height so it doesn't scale with the Preferences Editor line space scaling.
}
// Preference Panels
.fl-prefsEditor-panels {
white-space: nowrap;
display: table;
border-spacing: 20px 0px;
.fl-prefsEditor-panel {
border: 1px solid #615e59;
border-radius: 5px;
box-shadow: 2px 2px #7a766d;
display: inline-block;
padding: 1em;
min-width: 25em;
background-color: #fff;
white-space: normal;
display: table-cell;
}
}
h2 {
color: #766d68;
padding: 0 0 0.5em 0;
margin: 0 0 1.5em 0;
width: 100%;
border-bottom: solid #ccc 1px;
box-shadow: 0px 6px 7px -6px rgba(0,0,0,0.3);
font-size: 1.2em;
text-transform: lowercase;
line-height:1.7em;
height: 2em;
}
.fl-inputs {
float: none;
padding: 0;
}
label {
font-size: 1em;
display: block;
}
// Emphasize links buttons panel
.fl-links-buttons-options {
label {
width: 21em;
display:inline-block;
}
li {
margin-bottom: 0.4em;
}
}
h2 {
label, .fl-heading-text {
float: left;
padding-top: 0.2em;
font-size: 1.3em;
font-weight: 600;
}
}
}
// Theming
build-themes-separatedPanelPrefsEditorFrame(themes);

43
lib/infusion/src/framework/preferences/css/stylus/utils/Helpers.styl

@ -0,0 +1,43 @@
// Basic stylus functions used by other stylus files
vendors = webkit moz o ms
linear-gradient() {
// Generate the gradient effect used by linear-gradient()
content = arguments[0];
count = 0;
for element in arguments {
if (count != 0) {
content = content, element;
}
count = count + 1;
}
if current-property {
for vendor in vendors {
add-property(current-property[0], s('-%s-linear-gradient(%s)', vendor, content));
}
s('linear-gradient(%s)', content);
}
}
// Mixin for common styles of the "thumb" (slider control)
// used by both the jQuery and native HTML sliders
slider-thumb-common() {
height: 1.5em;
width: 1.5em;
background-color: #fff;
border: 1px solid #b3b3b3;
border-radius: 2em;
box-shadow: 4px 2px 3px rgba(0,0,0,0.3);
background-image: linear-gradient(right top, #fff 46%, #e9eaea 73%);
}
// Mixin for common styles of the "track" on the native HTML sliders
slider-native-track-common() {
background: transparent;
border: 0px;
}

358
lib/infusion/src/framework/preferences/css/stylus/utils/Themes.styl

@ -0,0 +1,358 @@
// Contains utility functions for building contrast themes
// !important is used for all styles to ensure that Preferences Framework's enactors are able to override the pages default styles.
themes = {
".fl-theme-bw": {
foregroundColor: #000000,
backgroundColor: #ffffff
}
".fl-theme-wb": {
foregroundColor: #ffffff,
backgroundColor: #000000
}
".fl-theme-yb": {
foregroundColor: #ffff00,
backgroundColor: #000000
}
".fl-theme-by": {
foregroundColor: #000000,
backgroundColor: #ffff00
}
".fl-theme-lgdg": {
foregroundColor: #bdbdbb,
backgroundColor: #555555
}
}
slider-thumb-common-contrastTheme() {
background: none;
background-color: fColor;
box-shadow: none !important;
}
build-themes-prefsEditor(contrastThemes) {
for themeName in contrastThemes {
fColor = contrastThemes[themeName].foregroundColor;
bColor = contrastThemes[themeName].backgroundColor;
{themeName} {
.fl-prefsEditor {
// slider
& .fl-slider {
background: none;
background-color: fColor;
a, a:hover,
.fl-slider-handle, .fl-slider-handle:hover {
slider-thumb-common-contrastTheme();
}
}
input[type=range].fl-slider {
background: none;
background-color: fColor;
&::-webkit-slider-thumb {
slider-thumb-common-contrastTheme();
}
&::-moz-range-thumb {
slider-thumb-common-contrastTheme();
}
&::-ms-thumb {
slider-thumb-common-contrastTheme();
}
}
// ON/OFF switch
.fl-prefsEditor-switch,
.fl-prefsEditor-switch-inner,
input + label .fl-prefsEditor-switch:before {
box-shadow: none !important;
text-shadow: none;
color: inherit;
background-image: none;
background-color: inherit;
}
input:focus + label,
.fl-choice input:focus ~ label {
outline: 0.2em solid fColor;
}
}
}
.fl-prefsEditor .fl-choice label {
&{themeName},
&{themeName} span,
&{themeName} .fl-crossout {
background-color: bColor !important;
border-color: fColor !important;
color: fColor !important;
}
}
}
}
// For the separated panel
get-colors-for-separatedPanelPrefsEditor(fColor, bColor) {
background-color: bColor;
border-color: fColor;
color: fColor;
}
build-themes-separatedPanelPrefsEditor(contrastThemes) {
for themeName in contrastThemes {
fColor = contrastThemes[themeName].foregroundColor;
bColor = contrastThemes[themeName].backgroundColor;
{themeName} {
background-image: none !important;
get-colors-for-separatedPanelPrefsEditor(fColor, bColor);
.fl-prefsEditor-separatedPanel {
.fl-panelBar, .fl-prefsEditor-reset {
get-colors-for-separatedPanelPrefsEditor(fColor, bColor);
}
.fl-prefsEditor-buttons { //FLUID-4991: The shadow effect around the hide/show preferences bug fix.
box-shadow:none;
}
}
}
}
}
// For the separated panel iframe
build-themes-separatedPanelPrefsEditorFrame(contrastThemes) {
for themeName in contrastThemes {
fColor = contrastThemes[themeName].foregroundColor;
bColor = contrastThemes[themeName].backgroundColor;
.fl-prefsEditor-separatedPanel{themeName} {
background-image: none;
}
}
}
// For the general theme styling that applies to html elements and infusion components
build-themes-Enactors(contrastThemes) {
for themeName in contrastThemes {
fColor = contrastThemes[themeName].foregroundColor;
bColor = contrastThemes[themeName].backgroundColor;
{themeName} {
// General Styling
&, *, .fl-preview-theme&,
div, input,
h1, h2, h3, h4, h5, h6 {
color: fColor !important;
background-color: bColor !important;
border-top-color: fColor !important;
border-right-color: fColor !important;
border-bottom-color: fColor !important;
border-left-color: fColor !important;
}
iframe {
border-top-color: fColor !important;
border-right-color: fColor !important;
border-bottom-color: fColor !important;
border-left-color: fColor !important;
}
a {
color: fColor !important;
font-weight: bold !important;
background-color: bColor !important;
}
// Tables
th {
border-top-width: 0.1em;
border-top-style: solid;
border-top-color: fColor !important;
border-right-width: 0.1em;
border-right-style: solid;
border-right-color: fColor !important;
border-bottom-width: 0.1em;
border-bottom-style: solid;
border-bottom-color: fColor !important;
border-left-width: 0.1em;
border-left-style: solid;
border-left-color: fColor !important;
background-color: fColor !important;
color: bColor !important;
}
td {
border-top-width: 0.1em;
border-top-style: solid;
border-top-color: fColor !important;
border-right-width: 0.1em;
border-right-style: solid;
border-right-color: fColor !important;
border-bottom-width: 0.1em;
border-bottom-style: solid;
border-bottom-color: fColor !important;
border-left-width: 0.1em;
border-left-style: solid;
border-left-color: fColor !important;
}
// Focus
.fl-focus:focus, .fl-focus :focus, &.fl-focus :focus, .selectable {
outline-width: 0.2em;
outline-style: solid;
outline-color: fColor;
}
// Infusion Components
// Reorderer
.fl-reorderer-dropMarker {
background-color: #f00 !important;
}
// Inline edit
.fl-inlineEdit-edit {
background-color: fColor !important;
color: bColor !important;
border-top-width: 0.1em;
border-top-style: solid;
border-top-color: bColor !important;
border-right-width: 0.1em;
border-right-style: solid;
border-right-color: bColor !important;
border-bottom-width: 0.1em;
border-bottom-style: solid;
border-bottom-color: bColor !important;
border-left-width: 0.1em;
border-left-style: solid;
border-left-color: bColor !important;
padding-top: 0.1em;
padding-right: 0.1em;
padding-bottom: 0.1em;
padding-left: 0.1em;
margin-top: -0.1em;
margin-right: -0.1em;
margin-bottom: -0.1em;
margin-left: -0.1em;
}
// Inverted color
// General Styling
&.fl-inverted-color, &.fl-inverted-color *, .fl-preview-theme&.fl-inverted-color {
color: bColor !important;
background-color: fColor !important;
border-top-color: bColor !important;
border-right-color: bColor !important;
border-bottom-color: bColor !important;
border-left-color: bColor !important;
}
// Focus
&.fl-inverted-color.fl-focus :focus {
outline-width: 0.2em;
outline-style: solid;
outline-color: bColor;
}
.fl-inverted-color {
&, *,
div, input,
h1, h2, h3, h4, h5, h6 {
color: bColor !important;
background-color: fColor !important;
border-top-color: bColor !important;
border-right-color: bColor !important;
border-bottom-color: bColor !important;
border-left-color: bColor !important;
}
iframe {
border-top-color: bColor !important;
border-right-color: bColor !important;
border-bottom-color: bColor !important;
border-left-color: bColor !important;
}
a {
color: bColor !important;
font-weight: bold !important;
background-color: fColor !important;
}
// Tables
th {
border-top-width: 0.1em;
border-top-style: solid;
border-top-color: bColor !important;
border-right-width: 0.1em;
border-right-style: solid;
border-right-color: bColor !important;
border-bottom-width: 0.1em;
border-bottom-style: solid;
border-bottom-color: bColor !important;
border-left-width: 0.1em;
border-left-style: solid;
border-left-color: bColor !important;
background-color: bColor !important;
color: fColor !important;
}
td {
border-top-width: 0.1em;
border-top-style: solid;
border-top-color: bColor !important;
border-right-width: 0.1em;
border-right-style: solid;
border-right-color: bColor !important;
border-bottom-width: 0.1em;
border-bottom-style: solid;
border-bottom-color: bColor !important;
border-left-width: 0.1em;
border-left-style: solid;
border-left-color: bColor !important;
}
// Infusion focus element
.fl-focus:focus, .fl-focus :focus, .selectable {
outline-width: 0.2em;
outline-style: solid;
outline-color: bColor;
}
// Infusion Components
// Reorderer
.fl-reorderer-dropMarker {
background-color: #f00 !important;
}
// Inline Edit
.fl-inlineEdit-edit {
background-color: bColor !important;
color: fColor !important;
border-top-width: 0.1em;
border-top-style: solid;
border-top-color: fColor !important;
border-right-width: 0.1em;
border-right-style: solid;
border-right-color: fColor !important;
border-bottom-width: 0.1em;
border-bottom-style: solid;
border-bottom-color: fColor !important;
border-left-width: 0.1em;
border-left-style: solid;
border-left-color: fColor !important;
padding-top: 0.1em;
padding-right: 0.1em;
padding-bottom: 0.1em;
padding-left: 0.1em;
margin-top: -0.1em;
margin-right: -0.1em;
margin-bottom: -0.1em;
margin-left: -0.1em;
}
}
}
}
}

BIN
lib/infusion/src/framework/preferences/fonts/InfusionIcons-PrefsEditor.eot

Binary file not shown.

BIN
lib/infusion/src/framework/preferences/fonts/InfusionIcons-PrefsEditor.ttf

Binary file not shown.

27
lib/infusion/src/framework/preferences/html/FullNoPreviewPrefsEditor.html

@ -0,0 +1,27 @@
<form id="options" class="fl-prefsEditor fl-prefsEditor-fullNoPreview fl-focus">
<div class="fl-prefsEditors-controls">
<div class="fl-prefsEditor-category">
<h2 class="fl-force-left">Text and display</h2>
<div class="flc-prefsEditor-text-size fl-prefsEditor-text"></div>
<div class="flc-prefsEditor-text-font fl-prefsEditor-text"></div>
<div class="flc-prefsEditor-line-space fl-prefsEditor-text"></div>
<div class="flc-prefsEditor-contrast fl-prefsEditor-text"></div>
</div>
<div class="fl-prefsEditor-category">
<h2 class="fl-force-left">Layout and navigation</h2>
<div class="flc-prefsEditor-layout-controls fl-prefsEditor-layout"></div>
</div>
<div class="fl-prefsEditor-category">
<h2 class="fl-force-left">Links and buttons</h2>
<div class="flc-prefsEditor-links-controls fl-prefsEditor-links"></div>
</div>
</div>
<div class="fl-prefsEditor-buttons">
<input class="flc-prefsEditor-save" type="button" value="Save and apply" />
<input class="flc-prefsEditor-reset" type="button" value="Reset and apply" />
<input class="flc-prefsEditor-cancel" type="button" value="Cancel" />
</div>
</form>

29
lib/infusion/src/framework/preferences/html/FullPreviewPrefsEditor.html

@ -0,0 +1,29 @@
<form id="options" class="fl-prefsEditor fl-prefsEditor-fullPreview fl-focus">
<div class="fl-prefsEditor-fullPreview-adjusters fl-force-left">
<h2>Text and display</h2>
<div class="flc-prefsEditor-text-size fl-prefsEditor-category fl-prefsEditor-text"></div>
<div class="flc-prefsEditor-text-font fl-prefsEditor-category fl-prefsEditor-text"></div>
<div class="flc-prefsEditor-line-space fl-prefsEditor-category fl-prefsEditor-text"></div>
<div class="flc-prefsEditor-contrast fl-prefsEditor-category fl-prefsEditor-text"></div>
<h2>Layout and navigation</h2>
<div class="flc-prefsEditor-layout-controls fl-prefsEditor-category fl-prefsEditor-layout">
</div>
<h2>Links and buttons</h2>
<div class="flc-prefsEditor-links-controls fl-prefsEditor-category fl-prefsEditor-links"></div>
</div>
<div class="fl-prefsEditor-fullPreview-previewContainer fl-force-right">
<div class="fl-prefsEditor-preview">
<h2>Preview your changes</h2>
<iframe class="flc-prefsEditor-preview-frame"></iframe>
</div>
<div class="fl-prefsEditor-buttons">
<input class="flc-prefsEditor-save" type="button" value="Save and apply" />
<input class="flc-prefsEditor-reset" type="button" value="Reset" />
<input class="flc-prefsEditor-cancel" type="button" value="Cancel" />
</div>
</div>
</form>

13
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-contrast.html

@ -0,0 +1,13 @@
<h2><span class="fl-icon-contrast"></span><span class="flc-prefsEditor-contrast-label fl-heading-text"></span></h2>
<fieldset>
<legend class="flc-prefsEditor-contrast-descr"></legend>
<div class="flc-prefsEditor-themeRow fl-choice">
<input type="radio" class="flc-prefsEditor-themeInput fl-hidden-accessible" name="theme" id="default" value="default" />
<div class="fl-indicator"></div>
<label for="default" class="flc-prefsEditor-theme-label">
<span class="fl-preview-A"></span>
<span class="fl-hidden-accessible"></span>
<span class="fl-crossout"></span>
</label>
</div>
</fieldset>

2
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-emphasizeLinks.html

@ -0,0 +1,2 @@
<input type="checkbox" id="links-choice" class="flc-prefsEditor-links fl-force-left" />
<label class="flc-prefsEditor-links-choice-label" for="links-choice"></label>

2
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-inputsLarger.html

@ -0,0 +1,2 @@
<input type="checkbox" id="inputs-choice" class="flc-prefsEditor-inputs-larger fl-force-left" />
<label class="flc-prefsEditor-links-inputs-choice-label" for="inputs-choice"></label>

10
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-layout.html

@ -0,0 +1,10 @@
<h2><span class="fl-icon-toc"></span><span class="flc-prefsEditor-toc-label fl-heading-text"></span></h2>
<div class="fl-prefsEditor-onoff">
<input type="checkbox" id="toc-choice" class="flc-prefsEditor-toc" />
<label for="toc-choice">
<span class="flc-prefsEditor-toc-descr"></span>
<span class="fl-prefsEditor-switch" data-checkboxStateOn="ON" data-checkboxStateOff="OFF">
<span class="fl-prefsEditor-switch-inner"></span>
</span>
</label>
</div>

12
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-lineSpace-jQueryUI.html

@ -0,0 +1,12 @@
<div class="flc-prefsEditor-line-space">
<h2><span class="fl-icon-line-space"></span><label class="flc-prefsEditor-line-space-label" for="line-space"></label></h2>
<p class="flc-prefsEditor-line-space-descr"></p>
<div class="fl-inputs">
<div class="fl-force-left">
<div class="fl-icon-line-space-condensed" role="presentation"></div>
<div class="flc-textfieldSlider-slider fl-force-left fl-slider fl-slider-horz"> </div>
<div class="fl-icon-line-space-expanded" role="presentation"></div>
</div>
<div class="fl-slider-input"><input id="line-space" class="flc-textfieldSlider-field" type="text" /> <span class="flc-prefsEditor-multiplier"></span></div>
</div>
</div>

12
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-lineSpace-nativeHTML.html

@ -0,0 +1,12 @@
<div class="flc-prefsEditor-line-space">
<h2><span class="fl-icon-line-space"></span><label class="flc-prefsEditor-line-space-label" id="line-space-label"></label></h2>
<p class="flc-prefsEditor-line-space-descr"></p>
<div class="fl-inputs">
<div class="fl-force-left">
<div class="fl-icon-line-space-condensed" role="presentation"></div>
<input aria-labelledby="line-space-label" class="flc-textfieldSlider-slider fl-force-left fl-slider fl-slider-horz" />
<div class="fl-icon-line-space-expanded" role="presentation"></div>
</div>
<div class="fl-slider-input"><input aria-labelledby="line-space-label" class="flc-textfieldSlider-field" type="text" /> <span class="flc-prefsEditor-multiplier"></span></div>
</div>
</div>

5
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-linksControls.html

@ -0,0 +1,5 @@
<h2><span class="fl-icon-links"></span><span class="flc-prefsEditor-linksControls-label fl-heading-text"></span></h2>
<ul class="fl-inputs fl-links-buttons-options">
<li class="flc-prefsEditor-emphasizeLinks"></li>
<li class="flc-prefsEditor-inputsLarger"></li>
</ul>

10
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-speak.html

@ -0,0 +1,10 @@
<h2><span class="flc-prefsEditor-speak-label fl-heading-text"></span></h2>
<div class="fl-prefsEditor-onoff">
<input type="checkbox" id="speak-choice" class="flc-prefsEditor-speak" />
<label for="speak-choice">
<span class="flc-prefsEditor-speak-descr"></span>
<span class="fl-prefsEditor-switch" data-checkboxStateOn="ON" data-checkboxStateOff="OFF">
<span class="fl-prefsEditor-switch-inner"></span>
</span>
</label>
</div>

6
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-textFont.html

@ -0,0 +1,6 @@
<h2>
<span class="fl-icon-font"></span>
<label class="flc-prefsEditor-text-font-label" for="text-font"></label>
</h2>
<p class="flc-prefsEditor-text-font-descr"></p>
<select class="flc-prefsEditor-text-font fl-inputs" id="text-font"></select>

15
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-textSize-jQueryUI.html

@ -0,0 +1,15 @@
<div class="flc-prefsEditor-min-text-size">
<h2>
<span class="fl-icon-size"></span>
<label class="flc-prefsEditor-min-text-size-label" for="min-text-size"></label>
</h2>
<p class="flc-prefsEditor-text-size-descr"></p>
<div class="fl-inputs">
<div class="fl-force-left">
<div class="fl-icon-small-a" role="presentation"></div>
<div class="flc-textfieldSlider-slider fl-force-left fl-slider fl-slider-horz"> </div>
<div class="fl-icon-big-a" role="presentation"></div>
</div>
<div class="fl-slider-input"><input id="min-text-size" class="flc-textfieldSlider-field" type="text" /> <span class="flc-prefsEditor-multiplier"></span></div>
</div>
</div>

15
lib/infusion/src/framework/preferences/html/PrefsEditorTemplate-textSize-nativeHTML.html

@ -0,0 +1,15 @@
<div class="flc-prefsEditor-min-text-size">
<h2>
<span class="fl-icon-size"></span>
<label id="text-size-label" class="flc-prefsEditor-min-text-size-label"></label>
</h2>
<p class="flc-prefsEditor-text-size-descr"></p>
<div class="fl-inputs">
<div class="fl-force-left">
<div class="fl-icon-small-a" role="presentation"></div>
<input aria-labelledby="text-size-label" class="flc-textfieldSlider-slider fl-force-left fl-slider fl-slider-horz" />
<div class="fl-icon-big-a" role="presentation"></div>
</div>
<div class="fl-slider-input"><input aria-labelledby="text-size-label" class="flc-textfieldSlider-field" type="text" /> <span class="flc-prefsEditor-multiplier"></span></div>
</div>
</div>

12
lib/infusion/src/framework/preferences/html/SeparatedPanelPrefsEditor.html

@ -0,0 +1,12 @@
<form id="options" class="fl-prefsEditor">
<div>
<ul class="fl-prefsEditor-panels">
<li class="fl-prefsEditor-panel"><div class="flc-prefsEditor-text-size"></div></li>
<li class="fl-prefsEditor-panel"><div class="flc-prefsEditor-text-font"></div></li>
<li class="fl-prefsEditor-panel"><div class="flc-prefsEditor-line-space"></div></li>
<li class="fl-prefsEditor-panel"><div class="flc-prefsEditor-contrast"></div></li>
<li class="fl-prefsEditor-panel"><div class="flc-prefsEditor-layout-controls"></div></li>
<li class="fl-prefsEditor-panel"><div class="flc-prefsEditor-links-controls"></div></li>
</ul>
</div>
</form>

34
lib/infusion/src/framework/preferences/html/SeparatedPanelPrefsEditorFrame-jQueryUI.html

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../../../lib/normalize/css/normalize.css" />
<link rel="stylesheet" type="text/css" href="../../../framework/core/css/fluid.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-bw/bw.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-wb/wb.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-by/by.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-yb/yb.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-lgdg/lgdg.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-dglg/dglg.css" />
<!-- Component styles -->
<link rel="stylesheet" type="text/css" href="../../../framework/preferences/css/Enactors.css" />
<link rel="stylesheet" type="text/css" href="../css/PrefsEditor.css" />
<link rel="stylesheet" type="text/css" href="../css/SeparatedPanelPrefsEditorFrame.css" />
<title>Preferences Editor</title>
<script type="text/javascript" src="../../../lib/jquery/core/js/jquery.js"></script>
<script type="text/javascript" src="../../../lib/jquery/ui/js/jquery-ui.js"></script>
<script type="text/javascript" src="../../../lib/jquery/plugins/touchPunch/js/jquery.ui.touch-punch.js"></script>
</head>
<body class="fl-prefsEditor-separatedPanel fl-focus">
<div class="fl-hidden">
<div class="flc-toc-tocContainer"></div>
</div>
</body>
</html>

30
lib/infusion/src/framework/preferences/html/SeparatedPanelPrefsEditorFrame-nativeHTML.html

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../../../lib/normalize/css/normalize.css" />
<link rel="stylesheet" type="text/css" href="../../../framework/core/css/fluid.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-bw/bw.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-wb/wb.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-by/by.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-yb/yb.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-lgdg/lgdg.css" />
<link rel="stylesheet" type="text/css" href="../../../lib/jquery/ui/css/fl-theme-dglg/dglg.css" />
<!-- Component styles -->
<link rel="stylesheet" type="text/css" href="../../../framework/preferences/css/Enactors.css" />
<link rel="stylesheet" type="text/css" href="../css/PrefsEditor.css" />
<link rel="stylesheet" type="text/css" href="../css/SeparatedPanelPrefsEditorFrame.css" />
<title>Preferences Editor</title>
</head>
<body class="fl-prefsEditor-separatedPanel fl-focus">
<div class="fl-hidden">
<div class="flc-toc-tocContainer"></div>
</div>
</body>
</html>

BIN
lib/infusion/src/framework/preferences/images/default/separatedpanelbg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

498
lib/infusion/src/framework/preferences/js/AuxBuilder.js

@ -0,0 +1,498 @@
/*
Copyright 2013-2016 OCAD University
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
fluid.registerNamespace("fluid.prefs");
/*******************************************************************************
* Base auxiliary schema grade
*******************************************************************************/
fluid.defaults("fluid.prefs.auxSchema", {
gradeNames: ["fluid.component"],
auxiliarySchema: {
"loaderGrades": ["fluid.prefs.separatedPanel"]
}
});
/**
* Look up the value on the given source object by using the path.
* Takes a template string containing tokens in the form of "@source-path-to-value".
* Returns a value (any type) or undefined if the path is not found.
*
* @param {object} root an object to retrieve the returned value from
* @param {String} pathRef a string that the path to the requested value is embedded into
*
* Example:
* 1. Parameters:
* source:
* {
* path1: {
* path2: "here"
* }
* }
*
* template: "@path1.path2"
*
* 2. Return: "here"
*/
fluid.prefs.expandSchemaValue = function (root, pathRef) {
if (pathRef.charAt(0) !== "@") {
return pathRef;
}
return fluid.get(root, pathRef.substring(1));
};
fluid.prefs.addAtPath = function (root, path, object) {
var existingObject = fluid.get(root, path);
fluid.set(root, path, $.extend(true, {}, existingObject, object));
return root;
};
// only works with top level elements
fluid.prefs.removeKey = function (root, key) {
var value = root[key];
delete root[key];
return value;
};
fluid.prefs.rearrangeDirect = function (root, toPath, sourcePath) {
var result = {};
var sourceValue = fluid.prefs.removeKey(root, sourcePath);
if (sourceValue) {
fluid.set(result, toPath, sourceValue);
}
return result;
};
fluid.prefs.addCommonOptions = function (root, path, commonOptions, templateValues) {
templateValues = templateValues || {};
var existingValue = fluid.get(root, path);
if (!existingValue) {
return root;
}
var opts = {}, mergePolicy = {};
fluid.each(commonOptions, function (value, key) {
// Adds "container" option only for view and renderer components
if (key === "container") {
var componentType = fluid.get(root, [path, "type"]);
var componentOptions = fluid.defaults(componentType);
// Note that this approach is not completely reliable, although it has been reviewed as "good enough" -
// a grade which modifies the creation signature of its principal type would cause numerous other problems.
// We can review this awkward kind of "anticipatory logic" when the new renderer arrives.
if (fluid.get(componentOptions, ["argumentMap", "container"]) === undefined) {
return false;
}
}
// Merge grade names defined in aux schema and system default grades
if (key.indexOf("gradeNames") !== -1) {
mergePolicy[key] = fluid.arrayConcatPolicy;
}
key = fluid.stringTemplate(key, templateValues);
value = typeof (value) === "string" ? fluid.stringTemplate(value, templateValues) : value;
fluid.set(opts, key, value);
});
fluid.set(root, path, fluid.merge(mergePolicy, existingValue, opts));
return root;
};
fluid.prefs.containerNeeded = function (root, path) {
var componentType = fluid.get(root, [path, "type"]);
var componentOptions = fluid.defaults(componentType);
return (fluid.hasGrade(componentOptions, "fluid.viewComponent") || fluid.hasGrade(componentOptions, "fluid.rendererComponent"));
};
fluid.prefs.checkPrimarySchema = function (primarySchema, prefKey) {
if (!primarySchema) {
fluid.fail("The primary schema for " + prefKey + " is not defined.");
}
return !!primarySchema;
};
fluid.prefs.expandSchemaComponents = function (auxSchema, type, prefKey, componentConfig, index, commonOptions, modelCommonOptions, mappedDefaults) {
var componentOptions = fluid.copy(componentConfig) || {};
var components = {};
var initialModel = {};
var componentName = fluid.prefs.removeKey(componentOptions, "type");
var regexp = new RegExp("\\.", "g");
var memberName = componentName.replace(regexp, "_");
var flattenedPrefKey = prefKey.replace(regexp, "_");
if (componentName) {
components[memberName] = {
type: componentName,
options: componentOptions
};
var selectors = fluid.prefs.rearrangeDirect(componentOptions, memberName, "container");
var templates = fluid.prefs.rearrangeDirect(componentOptions, memberName, "template");
var messages = fluid.prefs.rearrangeDirect(componentOptions, memberName, "message");
var preferenceMap = fluid.defaults(componentName).preferenceMap;
var map = preferenceMap[prefKey];
var prefSchema = mappedDefaults[prefKey];
fluid.each(map, function (primaryPath, internalPath) {
if (fluid.prefs.checkPrimarySchema(prefSchema, prefKey)) {
var opts = {};
if (internalPath.indexOf("model.") === 0) {
var internalModelName = internalPath.slice(6);
// Set up the binding in "rules" accepted by the modelRelay base grade of every panel
fluid.set(opts, "model", fluid.get(opts, "model") || {});
fluid.prefs.addCommonOptions(opts, "model", modelCommonOptions, {
internalModelName: internalModelName,
externalModelName: flattenedPrefKey
});
fluid.set(initialModel, ["members", "initialModel", "preferences", flattenedPrefKey], prefSchema[primaryPath]);
} else {
fluid.set(opts, internalPath, prefSchema[primaryPath]);
}
$.extend(true, componentOptions, opts);
}
});
fluid.prefs.addCommonOptions(components, memberName, commonOptions, {
prefKey: memberName
});
fluid.prefs.addAtPath(auxSchema, [type, "components"], components);
fluid.prefs.addAtPath(auxSchema, [type, "selectors"], selectors);
fluid.prefs.addAtPath(auxSchema, ["templateLoader", "resources"], templates);
fluid.prefs.addAtPath(auxSchema, ["messageLoader", "resources"], messages);
fluid.prefs.addAtPath(auxSchema, "initialModel", initialModel);
}
return auxSchema;
};
/**
* Expands a all "@" path references from an auxiliary schema.
* Note that you cannot chain "@" paths.
*
* @param {object} schemaToExpand the shcema which will be expanded
* @param {object} altSource an alternative look up object. This is primarily used for the internal recursive call.
* @return {object} an expaneded version of the schema.
*/
fluid.prefs.expandSchemaImpl = function (schemaToExpand, altSource) {
var expandedSchema = fluid.copy(schemaToExpand);
altSource = altSource || expandedSchema;
fluid.each(expandedSchema, function (value, key) {
if (typeof value === "object") {
expandedSchema[key] = fluid.prefs.expandSchemaImpl(value, altSource);
} else if (typeof value === "string") {
var expandedVal = fluid.prefs.expandSchemaValue(altSource, value);
if (expandedVal !== undefined) {
expandedSchema[key] = expandedVal;
} else {
delete expandedSchema[key];
}
}
});
return expandedSchema;
};
fluid.prefs.expandCompositePanels = function (auxSchema, compositePanelList, panelIndex, panelCommonOptions, subPanelCommonOptions,
compositePanelBasedOnSubCommonOptions, panelModelCommonOptions, mappedDefaults) {
var panelsToIgnore = [];
fluid.each(compositePanelList, function (compositeDetail, compositeKey) {
var compositePanelOptions = {};
var components = {};
var initialModel = {};
var selectors = {};
var templates = {};
var messages = {};
var selectorsToIgnore = [];
var thisCompositeOptions = fluid.copy(compositeDetail);
fluid.set(compositePanelOptions, "type", thisCompositeOptions.type);
delete thisCompositeOptions.type;
selectors = fluid.prefs.rearrangeDirect(thisCompositeOptions, compositeKey, "container");
templates = fluid.prefs.rearrangeDirect(thisCompositeOptions, compositeKey, "template");
messages = fluid.prefs.rearrangeDirect(thisCompositeOptions, compositeKey, "message");
var subPanelList = []; // list of subpanels to generate options for
var subPanels = {};
var subPanelRenderOn = {};
// thisCompositeOptions.panels can be in two forms:
// 1. an array of names of panels that should always be rendered;
// 2. an object that describes what panels should be always rendered,
// and what panels should be rendered when a preference is turned on
// The loop below is only needed for processing the latter.
if (fluid.isPlainObject(thisCompositeOptions.panels) && !fluid.isArrayable(thisCompositeOptions.panels)) {
fluid.each(thisCompositeOptions.panels, function (subpanelArray, pref) {
subPanelList = subPanelList.concat(subpanelArray);
if (pref !== "always") {
fluid.each(subpanelArray, function (onePanel) {
fluid.set(subPanelRenderOn, onePanel, pref);
});
}
});
} else {
subPanelList = thisCompositeOptions.panels;
}
fluid.each(subPanelList, function (subPanelID) {
panelsToIgnore.push(subPanelID);
var subPanelPrefsKey = fluid.get(auxSchema, [subPanelID, "type"]);
var safeSubPanelPrefsKey = fluid.prefs.subPanel.safePrefKey(subPanelPrefsKey);
selectorsToIgnore.push(safeSubPanelPrefsKey);
var subPanelOptions = fluid.copy(fluid.get(auxSchema, [subPanelID, "panel"]));
var subPanelType = fluid.get(subPanelOptions, "type");
fluid.set(subPanels, [safeSubPanelPrefsKey, "type"], subPanelType);
var renderOn = fluid.get(subPanelRenderOn, subPanelID);
if (renderOn) {
fluid.set(subPanels, [safeSubPanelPrefsKey, "options", "renderOnPreference"], renderOn);
}
// Deal with preferenceMap related options
var map = fluid.defaults(subPanelType).preferenceMap[subPanelPrefsKey];
var prefSchema = mappedDefaults[subPanelPrefsKey];
fluid.each(map, function (primaryPath, internalPath) {
if (fluid.prefs.checkPrimarySchema(prefSchema, subPanelPrefsKey)) {
var opts;
if (internalPath.indexOf("model.") === 0) {
// Set up the binding in "rules" accepted by the modelRelay base grade of every panel
fluid.set(compositePanelOptions, ["options", "model"], fluid.get(compositePanelOptions, ["options", "model"]) || {});
fluid.prefs.addCommonOptions(compositePanelOptions, ["options", "model"], panelModelCommonOptions, {
internalModelName: safeSubPanelPrefsKey,
externalModelName: safeSubPanelPrefsKey
});
fluid.set(initialModel, ["members", "initialModel", "preferences", safeSubPanelPrefsKey], prefSchema[primaryPath]);
} else {
opts = opts || {options: {}};
fluid.set(opts, "options." + internalPath, prefSchema[primaryPath]);
}
$.extend(true, subPanels[safeSubPanelPrefsKey], opts);
}
});
fluid.set(templates, safeSubPanelPrefsKey, fluid.get(subPanelOptions, "template"));
fluid.set(messages, safeSubPanelPrefsKey, fluid.get(subPanelOptions, "message"));
fluid.set(compositePanelOptions, ["options", "selectors", safeSubPanelPrefsKey], fluid.get(subPanelOptions, "container"));
fluid.set(compositePanelOptions, ["options", "resources"], fluid.get(compositePanelOptions, ["options", "resources"]) || {});
fluid.prefs.addCommonOptions(compositePanelOptions.options, "resources", compositePanelBasedOnSubCommonOptions, {
subPrefKey: safeSubPanelPrefsKey
});
// add additional options from the aux schema for subpanels
delete subPanelOptions.type;
delete subPanelOptions.template;
delete subPanelOptions.message;
delete subPanelOptions.container;
fluid.set(subPanels, [safeSubPanelPrefsKey, "options"], $.extend(true, {}, fluid.get(subPanels, [safeSubPanelPrefsKey, "options"]), subPanelOptions));
fluid.prefs.addCommonOptions(subPanels, safeSubPanelPrefsKey, subPanelCommonOptions, {
compositePanel: compositeKey,
prefKey: safeSubPanelPrefsKey
});
});
delete thisCompositeOptions.panels;
// add additional options from the aux schema for the composite panel
fluid.set(compositePanelOptions, ["options"], $.extend(true, {}, compositePanelOptions.options, thisCompositeOptions));
fluid.set(compositePanelOptions, ["options", "selectorsToIgnore"], selectorsToIgnore);
fluid.set(compositePanelOptions, ["options", "components"], subPanels);
components[compositeKey] = compositePanelOptions;
fluid.prefs.addCommonOptions(components, compositeKey, panelCommonOptions, {
prefKey: compositeKey
});
// Add onto auxSchema
fluid.prefs.addAtPath(auxSchema, ["panels", "components"], components);
fluid.prefs.addAtPath(auxSchema, ["panels", "selectors"], selectors);
fluid.prefs.addAtPath(auxSchema, ["templateLoader", "resources"], templates);
fluid.prefs.addAtPath(auxSchema, ["messageLoader", "resources"], messages);
fluid.prefs.addAtPath(auxSchema, "initialModel", initialModel);
$.extend(true, auxSchema, {panelsToIgnore: panelsToIgnore});
});
return auxSchema;
};
// Processes the auxiliary schema to output an object that contains all grade component definitions
// required for building the preferences editor, uiEnhancer and the settings store. These grade components
// are: panels, enactors, initialModel, messageLoader, templateLoader and terms.
// These grades are consumed and integrated by builder.js
// (https://github.com/fluid-project/infusion/blob/master/src/framework/preferences/js/Builder.js)
fluid.prefs.expandSchema = function (schemaToExpand, indexes, topCommonOptions, elementCommonOptions, mappedDefaults) {
var auxSchema = fluid.prefs.expandSchemaImpl(schemaToExpand);
auxSchema.namespace = auxSchema.namespace || "fluid.prefs.created_" + fluid.allocateGuid();
var terms = fluid.get(auxSchema, "terms");
if (terms) {
delete auxSchema.terms;
fluid.set(auxSchema, ["terms", "terms"], terms);
}
var compositePanelList = fluid.get(auxSchema, "groups");
if (compositePanelList) {
fluid.prefs.expandCompositePanels(auxSchema, compositePanelList, fluid.get(indexes, "panel"),
fluid.get(elementCommonOptions, "panel"), fluid.get(elementCommonOptions, "subPanel"),
fluid.get(elementCommonOptions, "compositePanelBasedOnSub"), fluid.get(elementCommonOptions, "panelModel"),
mappedDefaults);
}
fluid.each(auxSchema, function (category, prefName) {
// TODO: Replace this cumbersome scheme with one based on an extensible lookup to handlers
var type = "panel";
// Ignore the subpanels that are only for composing composite panels
if (category[type] && !fluid.contains(auxSchema.panelsToIgnore, prefName)) {
fluid.prefs.expandSchemaComponents(auxSchema, "panels", category.type, category[type], fluid.get(indexes, type),
fluid.get(elementCommonOptions, type), fluid.get(elementCommonOptions, type + "Model"), mappedDefaults);
}
type = "enactor";
if (category[type]) {
fluid.prefs.expandSchemaComponents(auxSchema, "enactors", category.type, category[type], fluid.get(indexes, type),
fluid.get(elementCommonOptions, type), fluid.get(elementCommonOptions, type + "Model"), mappedDefaults);
}
fluid.each(["template", "message"], function (type) {
if (prefName === type) {
fluid.set(auxSchema, [type + "Loader", "resources", "prefsEditor"], auxSchema[type]);
delete auxSchema[type];
}
});
});
// Remove subPanels array. It is to keep track of the panels that are only used as sub-components of composite panels.
if (auxSchema.panelsToIgnore) {
delete auxSchema.panelsToIgnore;
}
// Add top common options
fluid.each(topCommonOptions, function (topOptions, type) {
fluid.prefs.addCommonOptions(auxSchema, type, topOptions);
});
return auxSchema;
};
fluid.defaults("fluid.prefs.auxBuilder", {
gradeNames: ["fluid.prefs.auxSchema"],
mergePolicy: {
elementCommonOptions: "noexpand"
},
topCommonOptions: {
panels: {
gradeNames: ["fluid.prefs.prefsEditor"]
},
enactors: {
gradeNames: ["fluid.uiEnhancer"]
},
templateLoader: {
gradeNames: ["fluid.resourceLoader"]
},
messageLoader: {
gradeNames: ["fluid.resourceLoader"]
},
initialModel: {
gradeNames: ["fluid.prefs.initialModel"]
},
terms: {
gradeNames: ["fluid.component"]
}
},
elementCommonOptions: {
panel: {
"createOnEvent": "onPrefsEditorMarkupReady",
"container": "{prefsEditor}.dom.%prefKey",
"options.gradeNames": "fluid.prefs.prefsEditorConnections",
"options.resources.template": "{templateLoader}.resources.%prefKey",
"options.messageBase": "{messageLoader}.resources.%prefKey.resourceText"
},
panelModel: {
"%internalModelName": "{prefsEditor}.model.preferences.%externalModelName"
},
compositePanelBasedOnSub: {
"%subPrefKey": "{templateLoader}.resources.%subPrefKey"
},
subPanel: {
"container": "{%compositePanel}.dom.%prefKey",
"options.messageBase": "{messageLoader}.resources.%prefKey.resourceText"
},
enactor: {
"container": "{uiEnhancer}.container"
},
enactorModel: {
"%internalModelName": "{uiEnhancer}.model.%externalModelName"
}
},
indexes: {
panel: {
expander: {
func: "fluid.indexDefaults",
args: ["panelsIndex", {
gradeNames: "fluid.prefs.panel",
indexFunc: "fluid.prefs.auxBuilder.prefMapIndexer"
}]
}
},
enactor: {
expander: {
func: "fluid.indexDefaults",
args: ["enactorsIndex", {
gradeNames: "fluid.prefs.enactor",
indexFunc: "fluid.prefs.auxBuilder.prefMapIndexer"
}]
}
}
},
mappedDefaults: {},
expandedAuxSchema: {
expander: {
func: "fluid.prefs.expandSchema",
args: [
"{that}.options.auxiliarySchema",
"{that}.options.indexes",
"{that}.options.topCommonOptions",
"{that}.options.elementCommonOptions",
"{that}.options.mappedDefaults"
]
}
}
});
fluid.prefs.auxBuilder.prefMapIndexer = function (defaults) {
return fluid.keys(defaults.preferenceMap);
};
})(jQuery, fluid_2_0_0);

208
lib/infusion/src/framework/preferences/js/Builder.js

@ -0,0 +1,208 @@
/*
Copyright 2013-2015 OCAD University
Copyright 2015-2016 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
fluid.registerNamespace("fluid.prefs");
fluid.defaults("fluid.prefs.builder", {
gradeNames: ["fluid.component", "fluid.prefs.auxBuilder"],
mergePolicy: {
auxSchema: "expandedAuxSchema"
},
assembledPrefsEditorGrade: {
expander: {
func: "fluid.prefs.builder.generateGrade",
args: ["prefsEditor", "{that}.options.auxSchema.namespace", {
gradeNames: ["fluid.prefs.assembler.prefsEd", "fluid.viewComponent"],
componentGrades: "{that}.options.constructedGrades",
loaderGrades: "{that}.options.auxSchema.loaderGrades"
}]
}
},
assembledUIEGrade: {
expander: {
func: "fluid.prefs.builder.generateGrade",
args: ["uie", "{that}.options.auxSchema.namespace", {
gradeNames: ["fluid.viewComponent", "fluid.prefs.assembler.uie"],
componentGrades: "{that}.options.constructedGrades"
}]
}
},
constructedGrades: {
expander: {
func: "fluid.prefs.builder.constructGrades",
args: ["{that}.options.auxSchema", ["enactors", "messages", "panels", "initialModel", "templateLoader", "messageLoader", "terms"]]
}
},
mappedDefaults: "{primaryBuilder}.options.schema.properties",
components: {
primaryBuilder: {
type: "fluid.prefs.primaryBuilder",
options: {
typeFilter: {
expander: {
func: "fluid.prefs.builder.parseAuxSchema",
args: "{builder}.options.auxiliarySchema"
}
}
}
}
},
distributeOptions: [{
source: "{that}.options.primarySchema",
removeSource: true,
target: "{that > primaryBuilder}.options.primarySchema"
}]
});
fluid.defaults("fluid.prefs.assembler.uie", {
gradeNames: ["fluid.viewComponent"],
components: {
// These two components become global
store: {
type: "fluid.prefs.globalSettingsStore",
options: {
distributeOptions: {
target: "{that fluid.prefs.store}.options.contextAwareness.strategy.checks.user",
record: {
contextValue: "{fluid.prefs.assembler.uie}.options.storeType",
gradeNames: "{fluid.prefs.assembler.uie}.options.storeType"
}
}
}
},
enhancer: {
type: "fluid.component",
options: {
gradeNames: "{that}.options.enhancerType",
enhancerType: "fluid.pageEnhancer",
components: {
uiEnhancer: {
options: {
gradeNames: ["{fluid.prefs.assembler.uie}.options.componentGrades.enactors"]
}
}
}
}
}
},
distributeOptions: [{
source: "{that}.options.enhancer",
target: "{that uiEnhancer}.options",
removeSource: true
}, { // TODO: not clear that this hits anything since settings store is not a subcomponent
source: "{that}.options.store",
target: "{that fluid.prefs.store}.options"
}, {
source: "{that}.options.enhancerType",
target: "{that > enhancer}.options.enhancerType"
}]
});
fluid.defaults("fluid.prefs.assembler.prefsEd", {
gradeNames: ["fluid.viewComponent", "fluid.prefs.assembler.uie"],
components: {
prefsEditorLoader: {
type: "fluid.viewComponent",
container: "{fluid.prefs.assembler.prefsEd}.container",
priority: "last",
options: {
gradeNames: [
"{fluid.prefs.assembler.prefsEd}.options.componentGrades.terms",
"{fluid.prefs.assembler.prefsEd}.options.componentGrades.messages",
"{fluid.prefs.assembler.prefsEd}.options.componentGrades.initialModel",
"{that}.options.loaderGrades"
],
templateLoader: {
gradeNames: ["{fluid.prefs.assembler.prefsEd}.options.componentGrades.templateLoader"]
},
messageLoader: {
gradeNames: ["{fluid.prefs.assembler.prefsEd}.options.componentGrades.messageLoader"]
},
prefsEditor: {
gradeNames: ["{fluid.prefs.assembler.prefsEd}.options.componentGrades.panels", "fluid.prefs.uiEnhancerRelay"]
},
events: {
onReady: "{fluid.prefs.assembler.prefsEd}.events.onPrefsEditorReady"
}
}
}
},
events: {
onPrefsEditorReady: null,
onReady: {
events: {
onPrefsEditorReady: "onPrefsEditorReady",
onCreate: "onCreate"
},
args: ["{that}"]
}
},
distributeOptions: [{
source: "{that}.options.loaderGrades",
removeSource: true,
target: "{that > prefsEditorLoader}.options.loaderGrades"
}, {
source: "{that}.options.prefsEditor",
removeSource: true,
target: "{that prefsEditor}.options"
}, {
source: "{that}.options.terms",
removeSource: true,
target: "{that prefsEditorLoader}.options.terms"
}]
});
fluid.prefs.builder.generateGrade = function (name, namespace, options) {
var gradeNameTemplate = "%namespace.%name";
var gradeName = fluid.stringTemplate(gradeNameTemplate, {name: name, namespace: namespace});
fluid.defaults(gradeName, options);
return gradeName;
};
fluid.prefs.builder.constructGrades = function (auxSchema, gradeCategories) {
var constructedGrades = {};
fluid.each(gradeCategories, function (category) {
var gradeOpts = auxSchema[category];
if (fluid.get(gradeOpts, "gradeNames")) {
constructedGrades[category] = fluid.prefs.builder.generateGrade(category, auxSchema.namespace, gradeOpts);
}
});
return constructedGrades;
};
fluid.prefs.builder.parseAuxSchema = function (auxSchema) {
var auxTypes = [];
fluid.each(auxSchema, function parse(field) {
var type = field.type;
if (type) {
auxTypes.push(type);
}
});
return auxTypes;
};
/*
* A one-stop-shop function to build and instantiate a prefsEditor from a schema.
*/
fluid.prefs.create = function (container, options) {
options = options || {};
var builder = fluid.prefs.builder(options.build);
return fluid.invokeGlobalFunction(builder.options.assembledPrefsEditorGrade, [container, options.prefsEditor]);
};
})(jQuery, fluid_2_0_0);

431
lib/infusion/src/framework/preferences/js/Enactors.js

@ -0,0 +1,431 @@
/*
Copyright 2013-2016 OCAD University
Copyright 2015 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
fluid.defaults("fluid.prefs.enactor", {
gradeNames: ["fluid.modelComponent"]
});
/**********************************************************************************
* styleElements
*
* Adds or removes the classname to/from the elements based upon the model value.
* This component is used as a grade by emphasizeLinks & inputsLarger
**********************************************************************************/
fluid.defaults("fluid.prefs.enactor.styleElements", {
gradeNames: ["fluid.prefs.enactor"],
cssClass: null, // Must be supplied by implementors
elementsToStyle: null, // Must be supplied by implementors
invokers: {
applyStyle: {
funcName: "fluid.prefs.enactor.styleElements.applyStyle",
args: ["{arguments}.0", "{arguments}.1"]
},
resetStyle: {
funcName: "fluid.prefs.enactor.styleElements.resetStyle",
args: ["{arguments}.0", "{arguments}.1"]
},
handleStyle: {
funcName: "fluid.prefs.enactor.styleElements.handleStyle",
args: ["{arguments}.0", "{that}.options.elementsToStyle", "{that}.options.cssClass", "{that}.applyStyle", "{that}.resetStyle"]
}
},
modelListeners: {
value: {
listener: "{that}.handleStyle",
args: ["{change}.value"]
}
}
});
fluid.prefs.enactor.styleElements.applyStyle = function (elements, cssClass) {
elements.addClass(cssClass);
};
fluid.prefs.enactor.styleElements.resetStyle = function (elements, cssClass) {
$(elements, "." + cssClass).addBack().removeClass(cssClass);
};
fluid.prefs.enactor.styleElements.handleStyle = function (value, elements, cssClass, applyStyleFunc, resetStyleFunc) {
var func = value ? applyStyleFunc : resetStyleFunc;
func(elements, cssClass);
};
/*******************************************************************************
* ClassSwapper
*
* Has a hash of classes it cares about and will remove all those classes from
* its container before setting the new class.
* This component tends to be used as a grade by textFont and contrast
*******************************************************************************/
fluid.defaults("fluid.prefs.enactor.classSwapper", {
gradeNames: ["fluid.prefs.enactor", "fluid.viewComponent"],
classes: {}, // Must be supplied by implementors
invokers: {
clearClasses: {
funcName: "fluid.prefs.enactor.classSwapper.clearClasses",
args: ["{that}.container", "{that}.classStr"]
},
swap: {
funcName: "fluid.prefs.enactor.classSwapper.swap",
args: ["{arguments}.0", "{that}", "{that}.clearClasses"]
}
},
modelListeners: {
value: {
listener: "{that}.swap",
args: ["{change}.value"]
}
},
members: {
classStr: {
expander: {
func: "fluid.prefs.enactor.classSwapper.joinClassStr",
args: "{that}.options.classes"
}
}
}
});
fluid.prefs.enactor.classSwapper.clearClasses = function (container, classStr) {
container.removeClass(classStr);
};
fluid.prefs.enactor.classSwapper.swap = function (value, that, clearClassesFunc) {
clearClassesFunc();
that.container.addClass(that.options.classes[value]);
};
fluid.prefs.enactor.classSwapper.joinClassStr = function (classes) {
var classStr = "";
fluid.each(classes, function (oneClassName) {
if (oneClassName) {
classStr += classStr ? " " + oneClassName : oneClassName;
}
});
return classStr;
};
/*******************************************************************************
* emphasizeLinks
*
* The enactor to emphasize links in the container according to the value
*******************************************************************************/
// Note that the implementors need to provide the container for this view component
fluid.defaults("fluid.prefs.enactor.emphasizeLinks", {
gradeNames: ["fluid.prefs.enactor.styleElements", "fluid.viewComponent"],
preferenceMap: {
"fluid.prefs.emphasizeLinks": {
"model.value": "default"
}
},
cssClass: null, // Must be supplied by implementors
elementsToStyle: "{that}.container"
});
/*******************************************************************************
* inputsLarger
*
* The enactor to enlarge inputs in the container according to the value
*******************************************************************************/
// Note that the implementors need to provide the container for this view component
fluid.defaults("fluid.prefs.enactor.inputsLarger", {
gradeNames: ["fluid.prefs.enactor.styleElements", "fluid.viewComponent"],
preferenceMap: {
"fluid.prefs.inputsLarger": {
"model.value": "default"
}
},
cssClass: null, // Must be supplied by implementors
elementsToStyle: "{that}.container"
});
/*******************************************************************************
* textFont
*
* The enactor to change the font face used according to the value
*******************************************************************************/
// Note that the implementors need to provide the container for this view component
fluid.defaults("fluid.prefs.enactor.textFont", {
gradeNames: ["fluid.prefs.enactor.classSwapper"],
preferenceMap: {
"fluid.prefs.textFont": {
"model.value": "default"
}
}
});
/*******************************************************************************
* contrast
*
* The enactor to change the contrast theme according to the value
*******************************************************************************/
// Note that the implementors need to provide the container for this view component
fluid.defaults("fluid.prefs.enactor.contrast", {
gradeNames: ["fluid.prefs.enactor.classSwapper"],
preferenceMap: {
"fluid.prefs.contrast": {
"model.value": "default"
}
}
});
/*******************************************************************************
* Functions shared by textSize and lineSpace
*******************************************************************************/
/**
* return "font-size" in px
* @param (Object) container
* @param (Object) fontSizeMap: the mapping between the font size string values ("small", "medium" etc) to px values
*/
fluid.prefs.enactor.getTextSizeInPx = function (container, fontSizeMap) {
var fontSize = container.css("font-size");
if (fontSizeMap[fontSize]) {
fontSize = fontSizeMap[fontSize];
}
// return fontSize in px
return parseFloat(fontSize);
};
/*******************************************************************************
* textSize
*
* Sets the text size on the root element to the multiple provided.
*******************************************************************************/
// Note that the implementors need to provide the container for this view component
fluid.defaults("fluid.prefs.enactor.textSize", {
gradeNames: ["fluid.prefs.enactor", "fluid.viewComponent"],
preferenceMap: {
"fluid.prefs.textSize": {
"model.value": "default"
}
},
members: {
root: {
expander: {
"this": "{that}.container",
"method": "closest", // ensure that the correct document is being used. i.e. in an iframe
"args": ["html"]
}
}
},
fontSizeMap: {}, // must be supplied by implementors
invokers: {
set: {
funcName: "fluid.prefs.enactor.textSize.set",
args: ["{arguments}.0", "{that}", "{that}.getTextSizeInPx"]
},
getTextSizeInPx: {
funcName: "fluid.prefs.enactor.getTextSizeInPx",
args: ["{that}.root", "{that}.options.fontSizeMap"]
}
},
modelListeners: {
value: {
listener: "{that}.set",
args: ["{change}.value"]
}
}
});
fluid.prefs.enactor.textSize.set = function (times, that, getTextSizeInPxFunc) {
times = times || 1;
// Calculating the initial size here rather than using a members expand because the "font-size"
// cannot be detected on hidden containers such as separated paenl iframe.
if (!that.initialSize) {
that.initialSize = getTextSizeInPxFunc();
}
if (that.initialSize) {
var targetSize = times * that.initialSize;
that.root.css("font-size", targetSize + "px");
}
};
/*******************************************************************************
* lineSpace
*
* Sets the line space on the container to the multiple provided.
*******************************************************************************/
// Note that the implementors need to provide the container for this view component
fluid.defaults("fluid.prefs.enactor.lineSpace", {
gradeNames: ["fluid.prefs.enactor", "fluid.viewComponent"],
preferenceMap: {
"fluid.prefs.lineSpace": {
"model.value": "default"
}
},
fontSizeMap: {}, // must be supplied by implementors
invokers: {
set: {
funcName: "fluid.prefs.enactor.lineSpace.set",
args: ["{arguments}.0", "{that}", "{that}.getLineHeightMultiplier"]
},
getTextSizeInPx: {
funcName: "fluid.prefs.enactor.getTextSizeInPx",
args: ["{that}.container", "{that}.options.fontSizeMap"]
},
getLineHeight: {
funcName: "fluid.prefs.enactor.lineSpace.getLineHeight",
args: "{that}.container"
},
getLineHeightMultiplier: {
funcName: "fluid.prefs.enactor.lineSpace.getLineHeightMultiplier",
args: [{expander: {func: "{that}.getLineHeight"}}, {expander: {func: "{that}.getTextSizeInPx"}}]
}
},
modelListeners: {
value: {
listener: "{that}.set",
args: ["{change}.value"]
}
}
});
// Get the line-height of an element
// In IE8 and IE9 this will return the line-height multiplier
// In other browsers it will return the pixel value of the line height.
fluid.prefs.enactor.lineSpace.getLineHeight = function (container) {
return container.css("line-height");
};
// Interprets browser returned "line-height" value, either a string "normal", a number with "px" suffix or "undefined"
// into a numeric value in em.
// Return 0 when the given "lineHeight" argument is "undefined" (http://issues.fluidproject.org/browse/FLUID-4500).
fluid.prefs.enactor.lineSpace.getLineHeightMultiplier = function (lineHeight, fontSize) {
// Handle the given "lineHeight" argument is "undefined", which occurs when firefox detects
// "line-height" css value on a hidden container. (http://issues.fluidproject.org/browse/FLUID-4500)
if (!lineHeight) {
return 0;
}
// Needs a better solution. For now, "line-height" value "normal" is defaulted to 1.2em
// according to https://developer.mozilla.org/en/CSS/line-height
if (lineHeight === "normal") {
return 1.2;
}
// Continuing the work-around of jQuery + IE bug - http://bugs.jquery.com/ticket/2671
if (lineHeight.match(/[0-9]$/)) {
return Number(lineHeight);
}
return Math.round(parseFloat(lineHeight) / fontSize * 100) / 100;
};
fluid.prefs.enactor.lineSpace.set = function (times, that, getLineHeightMultiplierFunc) {
// Calculating the initial size here rather than using a members expand because the "line-height"
// cannot be detected on hidden containers such as separated paenl iframe.
if (!that.initialSize) {
that.initialSize = getLineHeightMultiplierFunc();
}
// that.initialSize === 0 when the browser returned "lineHeight" css value is undefined,
// which occurs when firefox detects "line-height" value on a hidden container.
// @ See getLineHeightMultiplier() & http://issues.fluidproject.org/browse/FLUID-4500
if (that.initialSize) {
var targetLineSpace = times * that.initialSize;
that.container.css("line-height", targetLineSpace);
}
};
/*******************************************************************************
* tableOfContents
*
* To create and show/hide table of contents
*******************************************************************************/
// Note that the implementors need to provide the container for this view component
fluid.defaults("fluid.prefs.enactor.tableOfContents", {
gradeNames: ["fluid.prefs.enactor", "fluid.viewComponent"],
preferenceMap: {
"fluid.prefs.tableOfContents": {
"model.toc": "default"
}
},
tocTemplate: null, // must be supplied by implementors
components: {
tableOfContents: {
type: "fluid.tableOfContents",
container: "{fluid.prefs.enactor.tableOfContents}.container",
createOnEvent: "onCreateTOCReady",
options: {
components: {
levels: {
type: "fluid.tableOfContents.levels",
options: {
resources: {
template: {
forceCache: true,
url: "{fluid.prefs.enactor.tableOfContents}.options.tocTemplate"
}
}
}
}
},
listeners: {
"afterRender.boilAfterTocRender": "{fluid.prefs.enactor.tableOfContents}.events.afterTocRender"
}
}
}
},
invokers: {
applyToc: {
funcName: "fluid.prefs.enactor.tableOfContents.applyToc",
args: ["{arguments}.0", "{that}"]
}
},
events: {
onCreateTOCReady: null,
afterTocRender: null,
onLateRefreshRelay: null
},
modelListeners: {
toc: {
listener: "{that}.applyToc",
args: ["{change}.value"]
}
},
distributeOptions: {
source: "{that}.options.ignoreForToC",
target: "{that tableOfContents}.options.ignoreForToC"
}
});
fluid.prefs.enactor.tableOfContents.applyToc = function (value, that) {
if (value) {
if (that.tableOfContents) {
that.tableOfContents.show();
} else {
that.events.onCreateTOCReady.fire();
}
} else if (that.tableOfContents) {
that.tableOfContents.hide();
}
};
})(jQuery, fluid_2_0_0);

49
lib/infusion/src/framework/preferences/js/FullNoPreviewPrefsEditor.js

@ -0,0 +1,49 @@
/*
Copyright 2011-2016 OCAD University
Copyright 2011 Lucendo Development Ltd.
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
/**************************************
* Full No Preview Preferences Editor *
**************************************/
fluid.defaults("fluid.prefs.fullNoPreview", {
gradeNames: ["fluid.prefs.prefsEditorLoader"],
components: {
prefsEditor: {
container: "{that}.container",
options: {
listeners: {
"afterReset.applyChanges": {
listener: "{that}.applyChanges"
},
"afterReset.save": {
listener: "{that}.save",
priority: "after:applyChanges"
},
"onReady.boilOnReady": {
listener: "{fullNoPreview}.events.onReady",
args: "{fullNoPreview}"
}
}
}
}
},
events: {
onReady: null
}
});
})(jQuery, fluid_2_0_0);

80
lib/infusion/src/framework/preferences/js/FullPreviewPrefsEditor.js

@ -0,0 +1,80 @@
/*
Copyright 2011-2016 OCAD University
Copyright 2011 Lucendo Development Ltd.
Copyright 2015 Raising the Floor - International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
var fluid_2_0_0 = fluid_2_0_0 || {};
(function ($, fluid) {
"use strict";
/***********************************
* Full Preview Preferences Editor *
***********************************/
fluid.defaults("fluid.prefs.fullPreview", {
gradeNames: ["fluid.prefs.prefsEditorLoader"],
outerUiEnhancerOptions: "{originalEnhancerOptions}.options.originalUserOptions",
outerUiEnhancerGrades: "{originalEnhancerOptions}.uiEnhancer.options.userGrades",
components: {
prefsEditor: {
container: "{that}.container",
options: {
components: {
preview: {
type: "fluid.prefs.preview",
createOnEvent: "onReady",
container: "{prefsEditor}.dom.previewFrame",
options: {
listeners: {
"onReady.boilOnPreviewReady": "{fullPreview}.events.onPreviewReady"
}
}
}
},
listeners: {
"onReady.boilOnPrefsEditorReady": "{fullPreview}.events.onPrefsEditorReady"
},
distributeOptions: {
source: "{that}.options.preview",
removeSource: true,
target: "{that > preview}.options"
}
}
}
},
events: {
onPrefsEditorReady: null,
onPreviewReady: null,
onReady: {
events: {
onPrefsEditorReady: "onPrefsEditorReady",
onPreviewReady: "onPreviewReady"
},
args: "{that}"
}
},
distributeOptions: [{
source: "{that}.options.outerUiEnhancerOptions",
target: "{that enhancer}.options"
}, {
source: "{that}.options.preview",
target: "{that preview}.options"
}, {
source: "{that}.options.previewEnhancer",
target: "{that enhancer}.options"
}, {
source: "{that}.options.outerUiEnhancerGrades",
target: "{that enhancer}.options.gradeNames"
}]
});
})(jQuery, fluid_2_0_0);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save