general.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* jshint esnext:true */
  2. import { toggle } from './helpers';
  3. var general = ( api, $ ) => {
  4. 'use strict';
  5. api( 'vamtam_theme[show-splash-screen]', value => {
  6. value.bind( to => {
  7. if ( + to ) {
  8. $( 'body' ).triggerHandler( 'vamtam-preview-splash-screen' );
  9. }
  10. } );
  11. } );
  12. api( 'vamtam_theme[splash-screen-logo]', value => {
  13. value.bind( to => {
  14. var wrapper = $( '.vamtam-splash-screen-progress-wrapper' );
  15. var current_image = wrapper.find( '> img' );
  16. if ( current_image.length === 0 ) {
  17. current_image = $('<img />');
  18. wrapper.prepend( current_image );
  19. }
  20. current_image.attr( 'src', to );
  21. $( 'body' ).triggerHandler( 'vamtam-preview-splash-screen' );
  22. } );
  23. } );
  24. api( 'vamtam_theme[show-scroll-to-top]', value => {
  25. value.bind( to => {
  26. toggle( $( '#scroll-to-top' ), to );
  27. } );
  28. } );
  29. api( 'vamtam_theme[show-related-posts]', value => {
  30. value.bind( to => {
  31. toggle( $( '.vamtam-related-content.related-posts' ), to );
  32. } );
  33. } );
  34. api( 'vamtam_theme[related-posts-title]', value => {
  35. value.bind( to => {
  36. $( '.related-posts .related-content-title' ).html( to );
  37. } );
  38. } );
  39. api( 'vamtam_theme[show-single-post-image]', value => {
  40. value.bind( to => {
  41. toggle( $( '.single-post > .post-media-image' ), to );
  42. } );
  43. } );
  44. api( 'vamtam_theme[post-meta]', value => {
  45. value.bind( to => {
  46. for ( let type in to ) {
  47. toggle( $( '.vamtam-meta-' + type ), + to[ type ] );
  48. }
  49. } );
  50. } );
  51. api( 'vamtam_theme[show-related-portfolios]', value => {
  52. value.bind( to => {
  53. toggle( $( '.vamtam-related-content.related-portfolios' ), to );
  54. } );
  55. } );
  56. api( 'vamtam_theme[related-portfolios-title]', value => {
  57. value.bind( to => {
  58. $( '.related-portfolios .related-content-title' ).html( to );
  59. } );
  60. } );
  61. };
  62. export default general;