main.js 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  1. (function($, Drupal, drupalSettings) {
  2. EdlpTheme = function(){
  3. var _ajax_settings = drupalSettings.edlp_ajax;
  4. var _$body = $('body');
  5. var _is_front = _$body.is('.path-frontpage');
  6. var _corpus_ready = false;
  7. var _$corpus_canvas;
  8. var _$row = $('main[role="main"]>.layout-content>.row');
  9. var _$ajaxLinks;
  10. var _audioPlayer;
  11. var _randomPlayer;
  12. var _compoPlayer;
  13. // ___ _ _
  14. // |_ _|_ _ (_) |_
  15. // | || ' \| | _|
  16. // |___|_||_|_|\__|
  17. function init(){
  18. console.log("EdlpTheme init()");
  19. initAjaxLinks();
  20. initHistory();
  21. if(!drupalSettings.path.isFront)
  22. return;
  23. initEvents();
  24. _audioPlayer = new AudioPlayer();
  25. _compoPlayer = new CompoPlayer();
  26. };
  27. // ___ _
  28. // | __|_ _____ _ _| |_ ___
  29. // | _|\ V / -_) ' \ _(_-<
  30. // |___|\_/\___|_||_\__/__/
  31. function initEvents(){
  32. _$body
  33. .on('corpus-map-ready', onCorpusMapReady)
  34. .on('on-studio-chutier-updated', initAjaxLinks)
  35. .on('studio-initialized', function(e){
  36. _compoPlayer.newCompo();
  37. })
  38. .on('studio-not-active', function(e){
  39. _compoPlayer.deactivate();
  40. })
  41. .on('on-studio-compo-updated', function(e){
  42. initAjaxLinks();
  43. _compoPlayer.refresh();
  44. })
  45. .on('on-studio-compo-opened', function(e){
  46. initAjaxLinks();
  47. _compoPlayer.newCompo();
  48. })
  49. .on('search-results-loaded', initAjaxLinks)
  50. // do not close index or notice modale on entree click
  51. .on('open_entree', function(e){
  52. console.log('on_open_entree : e', e);
  53. closeAllModals();
  54. // add body class for currently loaded content
  55. // var body_classes = [
  56. // 'path-'+sys_path.replace(/\//g, '-'),
  57. // 'entity-type-'+data.entity_type,
  58. // 'bundle-'+data.bundle,
  59. // 'view-mode-'+data.view_mode
  60. // ];
  61. _$body.removeClass();//.addClass(body_classes.join(' '));
  62. // record new history state
  63. if(typeof e.url != 'undefined'){
  64. // var state = {
  65. // ajax_path:null,
  66. // sys_path:null,
  67. // entree_tid:e.tid
  68. // };
  69. var state = getSysPathState(e.sys_path);
  70. history.pushState(state, null, e.url);
  71. }
  72. })
  73. .on('close_entree', backToFrontPage);
  74. }
  75. // ___ _ _ ___
  76. // / __| __ _ _ ___| | | _ ) __ _ _ _ ___
  77. // \__ \/ _| '_/ _ \ | | _ \/ _` | '_(_-<
  78. // |___/\__|_| \___/_|_|___/\__,_|_| /__/
  79. function initScrollbars(){
  80. // console.log("initScrollbars");
  81. // TODO: find a better js scroll than overlayScrollbars which does not handle well max-height + overflow-y:auto;
  82. // $('.os-scroll').overlayScrollbars({
  83. // overflowBehavior:{
  84. // x:'h',
  85. // y:'scroll',
  86. // clipAlways:false
  87. // }
  88. // });
  89. };
  90. // _ _
  91. // /_\ (_)__ ___ __
  92. // / _ \ | / _` \ \ /
  93. // /_/ \_\/ \__,_/_\_\
  94. // |__/
  95. function getSysPathState(sys_path, view_mode){
  96. // console.log('Theme : getSysPathState', sys_path);
  97. var state = {
  98. 'sys_path':sys_path,
  99. 'ajax_path': sys_path
  100. };
  101. // convert node link to edlp_ajax_node module links
  102. var node_match = state.ajax_path.match(/^\/?(node\/(\d+))$/i);
  103. console.log('node_match', node_match);
  104. var term_match = state.ajax_path.match(/^\/?(taxonomy\/term\/(\d+))$/i);
  105. console.log('term_match', term_match);
  106. if(node_match){
  107. state.ajax_path = _ajax_settings.entityjson_path+'/'+node_match[1];
  108. state.node_nid = node_match[2];
  109. // check for viewmode attribute
  110. if(view_mode){
  111. state.ajax_path += '/'+view_mode;
  112. }
  113. }else if(term_match){
  114. // terms are always entrees, there's no other vocabulary links in front
  115. state.ajax_path = _ajax_settings.entityjson_path+'/'+term_match[1];
  116. state.ajax_path = state.ajax_path.replace(/taxonomy\/term/, 'taxonomy_term');
  117. state.entree_tid = term_match[2];
  118. // check for viewmode attribute
  119. if(view_mode){
  120. state.ajax_path += '/'+view_mode;
  121. state.view_mode = view_mode;
  122. }else{
  123. state.ajax_path = null;
  124. }
  125. }else{
  126. // convert other link to ajax
  127. // TODO: we assume that other links (no node, no term) are all from own modules (e.g. productions) !! may not be true !!
  128. state.ajax_path += '/ajax'
  129. }
  130. return state;
  131. };
  132. function ajaxLoadContent(state){
  133. console.log('ajaxLoadContent : url', state.url);
  134. _$body.addClass('ajax-loading');
  135. var path = window.location.origin + Drupal.url(state.ajax_path);
  136. $.getJSON(path, {})
  137. .done(function(data){
  138. onAjaxLoaded(data, state);
  139. })
  140. .fail(function(jqxhr, textStatus, error){
  141. onAjaxLoadError(jqxhr, textStatus, error, state.sys_path);
  142. });
  143. };
  144. function onAjaxLoadError(jqxhr, textStatus, error, sys_path){
  145. console.warn('ajaxlink load failed for '+sys_path+' : '+error, jqxhr.responseText);
  146. $('.ajax-loading').removeClass('ajax-loading');
  147. _$body.removeClass('ajax-loading');
  148. };
  149. function onAjaxLoaded(data, state){
  150. console.log('ajax loaded url:'+state.url+' ajax_path:'+state.ajax_path+' sys_path:'+state.sys_path);
  151. // console.log(data);
  152. // reset all style may been added by other pages (like masonry for productions)
  153. // and replace all content with newly loaded
  154. // TODO: build a system to replace or append contents (like studio + search)
  155. _$row.removeAttr('style').html(data.rendered);
  156. // add body class for currently loaded content
  157. var body_classes = [
  158. 'path-'+state.sys_path.replace(/\//g, '-'),
  159. 'entity-type-'+data.entity_type,
  160. 'bundle-'+data.bundle,
  161. 'view-mode-'+data.view_mode
  162. ];
  163. _$body.removeClass().addClass(body_classes.join(' '));
  164. // id node add a generic path-node class to body
  165. // m = state.sys_path.match(/^\/?(node\/\d+)$/g);
  166. // if(m)
  167. if(state.node_nid)
  168. _$body.addClass('path-edlp-node');
  169. // handle clicked link classes
  170. $('.ajax-loading').removeClass('ajax-loading');
  171. $('.is-active').removeClass('is-active');
  172. $('.is-active-trail').removeClass('is-active-trail');
  173. if(typeof state.selector != 'undefined'){
  174. // in case of entree link (actualy, selector is used only for entries links)
  175. console.log('selector', state.selector);
  176. $('a[selector="'+state.selector+'"]').addClass('is-active');
  177. }else{
  178. if(typeof state.view_mode != 'undefined'){
  179. $('a[viewmode="'+state.view_mode+'"][data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');
  180. }else{
  181. $('a[data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');
  182. }
  183. // as new content is not related to entree, we trigger close entree
  184. _$body.trigger({'type':'new-content-not-entree-ajax-loaded'});
  185. }
  186. // if bundle page (productions) activate production links
  187. if (typeof data.bundle != 'undefined' && data.bundle == "page") {
  188. $('a[data-drupal-link-system-path="productions"]').addClass('is-active-trail');
  189. }
  190. // if node is in production menu tree, set first level of tree active, e.g. pieces sonores
  191. if (typeof data.menu_parents != 'undefined') {
  192. for (var i = 0; i < data.menu_parents.length; i++) {
  193. var menu_sys_path = data.menu_parents[i];
  194. $('a[data-drupal-link-system-path="'+menu_sys_path+'"]').addClass('is-active-trail');
  195. }
  196. }
  197. // if block attached (eg : from edlp_productions module)
  198. // not used anymore as production block is always present (but not visible)
  199. if(typeof data.block != 'undefined'){
  200. // if block not already added
  201. if(!$('#'+data.block.id, '.region-'+data.block.region).length){
  202. $('.region-'+data.block.region).append(data.block.rendered);
  203. }
  204. }
  205. // initScrollbars();
  206. if(state.sys_path == "productions"){
  207. initProductions();
  208. }else{
  209. addCloseModalBtnToCols();
  210. }
  211. // enregistrement transcription
  212. if(data.entity_type == "node" && data.bundle == "enregistrement" && data.view_mode == "transcript"){
  213. // window.requestAnimationFrame(initEnregistrementTranscript);
  214. initEnregistrementTranscript();
  215. }
  216. // update the language switcher block if it comes in the response
  217. if(typeof data.translations_links != 'undefined'){
  218. console.log('state',state);
  219. var lang_code = drupalSettings.path.currentLanguage;
  220. var $links = $(data.translations_links);
  221. // set active link
  222. $links.find('li[hreflang="'+lang_code+'"]').addClass('is-active').find('a').addClass('is-active');
  223. if(state.view_mode){
  224. $links.find('a').each(function(i,e){
  225. var $a = $(this);
  226. $a.attr('href', $a.attr('href')+'#'+state.view_mode);
  227. });
  228. }
  229. // if(state.selector){
  230. // $links.find('a').attr('selector', state.selector);
  231. // }
  232. $('ul','.block.language-switcher-language-url').replaceWith($links);
  233. }
  234. initAjaxLinks();
  235. // trigger other modules behaviours
  236. _$body.trigger({'type':'new-content-ajax-loaded'});
  237. // and call druapl behaviours
  238. Drupal.attachBehaviors(_$row[0]);
  239. _$body.attr('booted', 'booted');
  240. _$body.removeClass('ajax-loading');
  241. // url is null means that we are loading content on popState event
  242. // so we don't record the state again
  243. if(state.url){
  244. // var state = {
  245. // ajax_path:ajax_path,
  246. // sys_path:sys_path,
  247. // };
  248. // console.log('url:'+url+' ; state',state);
  249. // console.log(window.location);
  250. // /!\ we can not pushestate with absolute url /!\
  251. history.pushState(state, null, state.url);
  252. }
  253. };
  254. function addCloseModalBtnToCols(){
  255. $('.col', _$row).each(function(index, el) {
  256. if($('span.close-col-btn', this).length)
  257. return true;
  258. $(this).children('.wrapper').prepend($('<span>')
  259. .addClass('close-col-btn')
  260. .on('click', function(e){
  261. // check for theme attribute and emmit event
  262. var $col = $(this).parents('.col');
  263. var theme = $col.attr('theme');
  264. if(theme != ''){
  265. _$body.trigger({'type':theme+'-col-closed'});
  266. }
  267. // remove the col
  268. $col.remove();
  269. // if row is empty and we are not in productions call closeAllModals()
  270. if(!$('.col', _$row).length
  271. && !_$body.is('.entity-type-node.bundle-page')){
  272. backToFrontPage();
  273. }
  274. })
  275. );
  276. });
  277. };
  278. // _ _ ___ _ _
  279. // /_\ (_)__ ___ __ | _ ) |___ __| |__ ___
  280. // / _ \ | / _` \ \ / | _ \ / _ \/ _| / /(_-<
  281. // /_/ \_\/ \__,_/_\_\ |___/_\___/\__|_\_\/__/
  282. // |__/
  283. // NOT USED (YET)
  284. function refreshAllBlocks(){
  285. var path = window.location.origin + Drupal.url(_ajax_settings.blocksjson_path);
  286. $.getJSON(path, {})
  287. .done(function(data){
  288. onAjaxBlockLoaded(data);
  289. })
  290. .fail(function(jqxhr, textStatus, error){
  291. onAjaxBlockLoadError(jqxhr, textStatus, error);
  292. });
  293. };
  294. function onAjaxBlockLoadError(jqxhr, textStatus, error){
  295. console.warn('ajax block load failed: '+error, jqxhr.responseText);
  296. };
  297. function onAjaxBlockLoaded(data){
  298. console.log('onAjaxBlockLoaded', data);
  299. // TODO: update each blocks (exepted language switcher)
  300. for (var blockname in data.blocks) {
  301. var block = data.blocks[blockname];
  302. console.log(blockname, block);
  303. $(block.id).replaceWith(block.rendered);
  304. }
  305. };
  306. // _ _ _ _
  307. // | || (_)__| |_ ___ _ _ _ _
  308. // | __ | (_-< _/ _ \ '_| || |
  309. // |_||_|_/__/\__\___/_| \_, |
  310. // |__/
  311. function initHistory(){
  312. initFirstLoad();
  313. window.addEventListener('popstate', onHistoryPopState);
  314. };
  315. function initFirstLoad(){
  316. console.log('theme : initFirstLoad()');
  317. var origin_sys_path = window.localStorage.getItem('edlp_origin_path');
  318. if(origin_sys_path){
  319. var origin_url = window.localStorage.getItem('edlp_origin_url');
  320. // origin_hash is used as viewmode for taxonomy term entrees load (index or notice)
  321. var origin_hash = window.localStorage.getItem('edlp_origin_hash');
  322. var view_mode = origin_hash.replace('#', '');
  323. if(view_mode){
  324. // TODO first load with index or notice do not activate the right link (activate all)
  325. var $link = $('[href="'+origin_url+'"][viewmode="'+view_mode+'"]');
  326. var selector = $link.attr('selector') || null;
  327. if(selector){
  328. // in case of entree link (actualy, selector is used only for entries links)
  329. if(_corpus_ready){
  330. _$corpus_canvas.trigger({
  331. type:'open-entree',
  332. tid:$link.attr('tid')
  333. });
  334. }else{
  335. // else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
  336. // .is-active class is added by onAjaxLoaded() (when content is loaded)
  337. // but what if corpus ready before onAjaxLoaded
  338. $('li.entree[tid="'+$link.attr('tid')+'"] a.term-link').addClass('is-active');
  339. }
  340. }
  341. }
  342. // create history state
  343. var state = getSysPathState(origin_sys_path, view_mode);
  344. // only if not entree path
  345. if(state.ajax_path){
  346. // load content through ajax
  347. // ajaxLoadContent(null, state.sys_path, state.ajax_path, selector);
  348. ajaxLoadContent(state);
  349. }
  350. // TODO what about entree alone (without notice or index)
  351. if(state.entree_tid){
  352. openEntree(state.entree_tid);
  353. }
  354. // record history state
  355. history.replaceState(state, null, origin_url+origin_hash);
  356. // reset the storage
  357. window.localStorage.removeItem("edlp_origin_path");
  358. window.localStorage.removeItem("edlp_origin_url");
  359. }else{
  360. history.replaceState({home:true}, null, window.location.pathname);
  361. _$body.attr('booted', 'booted');
  362. }
  363. };
  364. function onHistoryPopState(e){
  365. console.log('onPopState',e.state);
  366. if(e.state.home){
  367. backToFrontPage(true);
  368. }else{
  369. if(e.state.entree_tid){
  370. openEntree(e.state.entree_tid);
  371. }
  372. if(e.state.ajax_path){
  373. e.state.url = null;
  374. // ajaxLoadContent(null, e.state.sys_path, e.state.ajax_path)
  375. ajaxLoadContent(e.state);
  376. }
  377. }
  378. };
  379. // _ _ _ _ _
  380. // /_\ (_)__ ___ _| | (_)_ _ | |__ ___
  381. // / _ \ | / _` \ \ / |__| | ' \| / /(_-<
  382. // /_/ \_\/ \__,_/_\_\____|_|_||_|_\_\/__/
  383. // |__/
  384. function initAjaxLinks(){
  385. // console.log('initAjaxLinks');
  386. $('a.site-name', '#block-edlptheme-branding')
  387. .add('a', '#block-mainnavigation')
  388. // .add('a', '.block.language-switcher-language-url')
  389. .add('a', '#block-footer.menu--footer')
  390. .add('a', '#block-productions')
  391. .add('a', 'article.node:not(.node--type-enregistrement) h2.node-title')
  392. .add('a', '.productions-subtree')
  393. .add('a', '.productions-parent')
  394. // .add('a.index-link, a.notice-link', '#block-edlpentreesblock')
  395. .addClass('ajax-link');
  396. _$ajaxLinks = $('.ajax-link:not(.ajax-enabled)')
  397. .each(function(i,e){
  398. var $this = $(this);
  399. // avoid already ajaxified links
  400. if($this.is('.ajax-enable')) return;
  401. if($this.attr('data-drupal-link-system-path')){
  402. $this.on('click', onClickAjaxLink).addClass('ajax-enable');
  403. }
  404. });
  405. };
  406. function onClickAjaxLink(e){
  407. e.preventDefault();
  408. var $link = $(this);
  409. if($link.is('.is-active'))
  410. return false;
  411. // Audio links
  412. // launch audio player and stop here
  413. if($link.is('.audio-link')){
  414. _audioPlayer
  415. .emmit('stop-shuffle')
  416. .openDocument({
  417. nid:$link.attr('nid'),
  418. audio_url:$link.attr('audio_url')
  419. });
  420. return false;
  421. }
  422. // NOT USED (YET)
  423. // if($link.is('.language-link')){
  424. // TODO: change global site current language
  425. // load all blocks translated (exepted language switcher) ... :/
  426. // refreshAllBlocks();
  427. // TODO: use a promise to initAjaxLinks again after blocks updated
  428. // then let load the content
  429. // }
  430. // other links
  431. var sys_path = $(this).attr('data-drupal-link-system-path');
  432. // front page
  433. // just remove contents and stop here
  434. if(sys_path == '<front>'){
  435. backToFrontPage();
  436. return false;
  437. }
  438. var view_mode = $link.attr('viewmode');
  439. var state = getSysPathState(sys_path, view_mode);
  440. state.url = $(this).attr('href');
  441. if(view_mode){
  442. state.url += "#"+view_mode;
  443. }
  444. if($link.is('[selector]')){
  445. state.selector = $link.attr('selector');
  446. }
  447. $link.addClass('ajax-loading');
  448. // ajaxLoadContent(url, sys_path, state.ajax_path, selector);
  449. ajaxLoadContent(state);
  450. return false;
  451. };
  452. // ___
  453. // / __|___ _ _ _ __ _ _ ___
  454. // | (__/ _ \ '_| '_ \ || (_-<
  455. // \___\___/_| | .__/\_,_/__/
  456. // |_|
  457. function onCorpusMapReady(e){
  458. //console.log('theme : onCorpusReady', e);
  459. _corpus_ready = true;
  460. _$corpus_canvas = $('canvas#corpus-map');
  461. _$corpus_canvas
  462. .on('corpus-cliked-on-map', function(e) {
  463. //console.log('theme : corpus-cliked-on-map');
  464. backToFrontPage();
  465. })
  466. .on('corpus-cliked-on-node', function(e) {
  467. //console.log('theme : corpus-cliked-on-node', e);
  468. _audioPlayer
  469. .emmit('stop-shuffle')
  470. .openDocument(e.target_node);
  471. });
  472. _randomPlayer = new RandomPlayer(e.playlist);
  473. _$body.attr('corpus-map', 'ready');
  474. }
  475. function openEntree(tid){
  476. if(tid){
  477. closeAllModals();
  478. _$body.removeClass();//.addClass(body_classes.join(' '));
  479. // open entree
  480. if(_corpus_ready){
  481. _$corpus_canvas.trigger({
  482. type:'open-entree',
  483. tid:tid
  484. });
  485. }else{
  486. // else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
  487. $('li.entree[tid="'+tid+'"] a.term-link').addClass('is-active');
  488. }
  489. }
  490. };
  491. // _ _ _
  492. // /_\ _ _ __| (_)___
  493. // / _ \ || / _` | / _ \
  494. // /_/ \_\_,_\__,_|_\___/
  495. //
  496. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement
  497. // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/samples/gg589528%28v%3dvs.85%29
  498. // https://www.binarytides.com/using-html5-audio-element-javascript/
  499. function AudioPlayer(){
  500. var that = this;
  501. this.fid;
  502. this.audio = new Audio();
  503. // audio events
  504. this.audio_events = ["loadedmetadata","canplay","playing","pause","timeupdate","ended"];
  505. // UI dom objects
  506. this.$container = $('<div id="audio-player">');
  507. // btns
  508. this.$btns = $('<div>').addClass('btns').appendTo(this.$container);
  509. this.$previous = $('<div>').addClass('previous').appendTo(this.$btns);
  510. this.$playpause = $('<div>').addClass('play-pause').appendTo(this.$btns);
  511. this.$next = $('<div>').addClass('next').appendTo(this.$btns);
  512. // timeline
  513. this.$timelinecont= $('<div>').addClass('time-line-container').appendTo(this.$container);
  514. this.$timeline = $('<div>').addClass('time-line').appendTo(this.$timelinecont);
  515. this.$loader = $('<div>').addClass('loader').appendTo(this.$timeline);
  516. this.$cursor = $('<div>').addClass('cursor').appendTo(this.$timeline);
  517. // time
  518. this.$time = $('<div>').addClass('time').appendTo(this.$container);
  519. this.$currentTime = $('<div>').addClass('current-time').html('00:00').appendTo(this.$time);
  520. this.$duration = $('<div>').addClass('duration').html('00:00').appendTo(this.$time);
  521. // favoris
  522. this.$fav = $('<div>').addClass('favoris').appendTo(this.$container);
  523. // cartel
  524. this.$cartel = $('<div>').addClass('cartel').appendTo(this.$container);
  525. // hiding
  526. this.hideTimer = false;
  527. this.hideTimeMS = 10000;
  528. // history
  529. this.currentHistoricIndex = null;
  530. this.historic = [];
  531. this.shuffle_is_active = false;
  532. // object events
  533. this.event_handlers = {
  534. 'audio-open-document':[],
  535. 'audio-play':[],
  536. 'audio-pause':[],
  537. 'audio-play-next':[],
  538. 'audio-ended':[],
  539. 'stop-shuffle':[]
  540. };
  541. this.init();
  542. };
  543. AudioPlayer.prototype = {
  544. init(){
  545. // append ui to document
  546. this.$container.appendTo('header[role="banner"] .region-header');
  547. // record timeline width
  548. this.timeline_w = parseInt(this.$timeline.width());
  549. // init audio events
  550. var fn = '';
  551. for (var i = 0; i < this.audio_events.length; i++) {
  552. fn = this.audio_events[i];
  553. // capitalize first letter of event (only cosmetic :p )
  554. fn = 'on'+fn.charAt(0).toUpperCase()+fn.slice(1);
  555. this.audio.addEventListener(
  556. this.audio_events[i],
  557. this[fn].bind(this),
  558. true);
  559. }
  560. // init btns events
  561. this.$previous.on('click', this.playPrevious.bind(this));
  562. this.$playpause.on('click', this.togglePlayPause.bind(this));
  563. this.$next.on('click', this.playNext.bind(this));
  564. },
  565. openDocument(node, caller){
  566. // console.log('AudioPlayer openDocument', node);
  567. if(typeof node == 'undefined'
  568. || typeof node.nid == 'undefined'
  569. || typeof node.audio_url == 'undfined'){
  570. console.warn('AudioPlayer openDocument() node is malformed', node);
  571. return false;
  572. }
  573. this.historic.push(node);
  574. this.currentHistoricIndex = this.historic.length-1;
  575. // this.shuffle_mode = shuffle_mode || false;
  576. // TODO: add an hash tag to be able to share and play audio from any where
  577. this.emmit('audio-open-document', {caller:caller});
  578. this.launch();
  579. },
  580. launch(){
  581. this.clearTimeOutToHide();
  582. this.setSRC(this.historic[this.currentHistoricIndex].audio_url);
  583. this.loadNode(this.historic[this.currentHistoricIndex].nid);
  584. // emmit new playing doc (e.g.: corpus map nowing that audio played from RandomPlayer)
  585. try {
  586. _$corpus_canvas.trigger({
  587. 'type':'audio-node-opened',
  588. 'nid':this.historic[this.currentHistoricIndex].nid
  589. });
  590. } catch (e) {
  591. console.info('AudioPlayer : _$corpus_canvas does not exists');
  592. }
  593. this.showHidePreviousBtn();
  594. this.showHideNextBtn();
  595. this.show();
  596. },
  597. // audio functions
  598. setSRC(url){
  599. // console.log('AudioPlayer setSRC : url', url);
  600. this.audio.src = url;
  601. },
  602. onLoadedmetadata(){
  603. var rem = parseInt(this.audio.duration, 10),
  604. mins = Math.floor(rem/60,10),
  605. secs = rem - mins*60;
  606. this.$duration.html('<span>'+(mins<10 ? '0':'')+mins+':'+(secs<10 ? '0':'')+secs+'</span>');
  607. this.updateLoadingBar();
  608. },
  609. updateLoadingBar(){
  610. this.$loader.css({
  611. 'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%'
  612. });
  613. if( this.audio.buffered.end(0) < this.audio.duration ){
  614. // loop through this function until file is fully loaded
  615. var that = this;
  616. window.requestAnimationFrame(that.updateLoadingBar.bind(that));
  617. }else{
  618. //console.log('Audio fully loaded');
  619. }
  620. },
  621. onCanplay(){
  622. this.play();
  623. },
  624. play(){
  625. this.clearTimeOutToHide();
  626. this.audio.play();
  627. },
  628. playPrevious(){
  629. if(this.currentHistoricIndex > 0){
  630. this.currentHistoricIndex -= 1;
  631. this.launch();
  632. }
  633. },
  634. playNext(){
  635. if(this.currentHistoricIndex < this.historic.length-1){
  636. this.currentHistoricIndex += 1;
  637. this.launch();
  638. }else{
  639. this.emmit('audio-play-next');
  640. }
  641. },
  642. togglePlayPause(e){
  643. if(this.audio.paused){
  644. this.audio.play();
  645. }else{
  646. this.audio.pause();
  647. }
  648. },
  649. stop(){
  650. // console.log('AudioPlayer stop()');
  651. this.audio.pause();
  652. // TODO: don't close player if article or transcript is open
  653. this.timeOutToHide();
  654. },
  655. // audio events
  656. onPlaying(){
  657. this.$btns.addClass('is-playing');
  658. this.emmit('audio-play');
  659. },
  660. onPause(){
  661. this.$btns.removeClass('is-playing');
  662. this.emmit('audio-pause');
  663. },
  664. onTimeupdate(){
  665. // move cursor
  666. this.$cursor.css({
  667. 'left':(this.audio.currentTime/this.audio.duration * this.timeline_w)+"px"
  668. });
  669. // update time text display
  670. var rem = parseInt(this.audio.currentTime, 10),
  671. mins = Math.floor(rem/60,10),
  672. secs = rem - mins*60;
  673. this.$currentTime.html('<span>'+(mins<10 ? '0':'')+mins+':'+(secs<10 ? '0':'')+secs+'</span>');
  674. },
  675. onEnded(){
  676. this.emmit('audio-ended');
  677. this.stop();
  678. },
  679. // cartel functions
  680. loadNode(nid){
  681. this.$cartel.addClass('loading');
  682. var vm = 'player_cartel';
  683. var ajax_path = _ajax_settings.entityjson_path+'/node/'+nid+'/'+vm;
  684. var path = window.location.origin + Drupal.url(ajax_path);
  685. $.getJSON(path, {})
  686. .done(this.onNodeLoaded.bind(this))
  687. .fail(this.onNodeLoadFail.bind(this));
  688. },
  689. onNodeLoaded(data){
  690. // console.log('AudioPlayer node loaded');
  691. this.$cartel.html(data.rendered).removeClass('loading');
  692. _$body.trigger({'type':'new-audio-cartel-loaded'});
  693. initAjaxLinks();
  694. },
  695. onNodeLoadFail(jqxhr, textStatus, error){
  696. console.warn('AudioPlayer node load failed', jqxhr.responseText);
  697. this.$cartel.removeClass('loading').html('');
  698. },
  699. // global
  700. show(){
  701. this.$container.addClass('visible');
  702. },
  703. showHidePreviousBtn(){
  704. if(this.historic.length > 1 && this.currentHistoricIndex > 0){
  705. this.$previous.addClass('is-active');
  706. }else{
  707. this.$previous.removeClass('is-active');
  708. }
  709. },
  710. showHideNextBtn(){
  711. if(this.currentHistoricIndex < this.historic.length-1 || this.shuffle_is_active){
  712. this.$next.addClass('is-active');
  713. }else{
  714. this.$next.removeClass('is-active');
  715. }
  716. },
  717. timeOutToHide(){
  718. // console.log('AudioPlayer timeOutToHide()');
  719. this.clearTimeOutToHide();
  720. this.hideTimer = setTimeout(this.hide.bind(this), this.hideTimeMS);
  721. },
  722. clearTimeOutToHide(){
  723. // console.log('AudioPlayer clearTimeOutToHide()',this.hideTimer);
  724. if(this.hideTimer){
  725. clearTimeout(this.hideTimer);
  726. this.hideTimer = false;
  727. }
  728. },
  729. hide(){
  730. // console.log('AudioPlayer hide()');
  731. this.$container.removeClass('visible');
  732. // trigger highlighted node remove on corpus map
  733. try {
  734. _$corpus_canvas.trigger('audio-node-closed');
  735. } catch (e) {
  736. console.info('AudioPlayer hide() : _$corpus_canvas does not exists');
  737. }
  738. },
  739. // object events
  740. on(event_name, handler){
  741. if(typeof this.event_handlers[event_name] == 'undefined'){
  742. console.warn('AudioPlayer : event '+event_name+' does not exists');
  743. }
  744. this.event_handlers[event_name].push(handler);
  745. return this;
  746. },
  747. emmit(event_name, args){
  748. // console.log('AudioPlayer emmit() event_name', event_name);
  749. // console.log('AudioPlayer emmit() handlers', this.event_handlers[event_name]);
  750. var handler;
  751. var args = args || {};
  752. for (var i = this.event_handlers[event_name].length-1; i >= 0 ; i--) {
  753. handler = this.event_handlers[event_name][i];
  754. // console.log('AudioPlayer emmit() loop handler', handler);
  755. setTimeout(function(){
  756. // console.log('AudioPlayer emmit() timeout handler', handler);
  757. handler(args);
  758. }, 0);
  759. }
  760. return this;
  761. },
  762. }
  763. // ___ _ ___ _
  764. // | _ \__ _ _ _ __| |___ _ __ | _ \ |__ _ _ _ ___ _ _
  765. // | / _` | ' \/ _` / _ \ ' \| _/ / _` | || / -_) '_|
  766. // |_|_\__,_|_||_\__,_\___/_|_|_|_| |_\__,_|\_, \___|_|
  767. // |__/
  768. function RandomPlayer(playlist){
  769. this.active = false;
  770. this.playlist = playlist;
  771. this.$btn = $('<a>').html('Shuffle').addClass('random-player-btn');
  772. this.init();
  773. };
  774. RandomPlayer.prototype = {
  775. init(){
  776. // this.shuffle();
  777. $('<div>')
  778. .addClass('block random-player')
  779. .append(this.$btn)
  780. // .insertAfter('#block-userlogin, #block-studiolinkblock');
  781. .prependTo('.region-footer-right');
  782. // events
  783. this.$btn.on('click', this.toggleActive.bind(this));
  784. // attach an event on AudioPlayer
  785. _audioPlayer
  786. .on('audio-ended', this.onAudioPlayerEnded.bind(this))
  787. .on('audio-play-next', this.onAudioPlayNext.bind(this))
  788. .on('stop-shuffle', this.stop.bind(this));
  789. },
  790. shuffle(){
  791. var tempPLaylist = [];
  792. for (var i = this.playlist.length-1; i >= 0 ; i--) {
  793. tempPLaylist.push(this.playlist[i]);
  794. }
  795. this.shuffledPlaylist = [];
  796. while(tempPLaylist.length > 0){
  797. var r = Math.floor(Math.random() * tempPLaylist.length);
  798. this.shuffledPlaylist.push(tempPLaylist.splice(r,1)[0]);
  799. }
  800. //console.log('RandomPlayer, this.shuffledPlaylist', this.shuffledPlaylist);
  801. },
  802. toggleActive(e){
  803. if (this.active) {
  804. this.stop();
  805. }else{
  806. this.start();
  807. }
  808. },
  809. start(){
  810. this.active = _audioPlayer.shuffle_is_active = true;
  811. this.$btn.addClass('is-active');
  812. this.shuffle();
  813. this.next();
  814. },
  815. stop(){
  816. this.active = _audioPlayer.shuffle_is_active = false;
  817. this.$btn.removeClass('is-active');
  818. // stop audio player
  819. // _audioPlayer.stop();
  820. },
  821. next(){
  822. if(this.active && this.shuffledPlaylist.length > 0)
  823. _audioPlayer.openDocument(this.shuffledPlaylist.splice(0,1)[0]);
  824. },
  825. onAudioPlayNext(){
  826. //console.log('RandomPlayer : onAudioPlayNext()');
  827. this.next();
  828. },
  829. onAudioPlayerEnded(){
  830. //console.log('RandomPlayer : onAudioPlayerEnded()');
  831. this.next();
  832. }
  833. };
  834. // ___ ___ _
  835. // / __|___ _ __ _ __ ___| _ \ |__ _ _ _ ___ _ _
  836. // | (__/ _ \ ' \| '_ \/ _ \ _/ / _` | || / -_) '_|
  837. // \___\___/_|_|_| .__/\___/_| |_\__,_|\_, \___|_|
  838. // |_| |__/
  839. function CompoPlayer(){
  840. this.active = false;
  841. this.playing = false;
  842. this.paused = false;
  843. this.playlist = [];
  844. this.current_index = 0;
  845. this.$composer = null;
  846. this.$compo = null;
  847. this.$controls = null;
  848. this.init();
  849. };
  850. CompoPlayer.prototype = {
  851. init(){
  852. // console.log('CompoPlayer init()');
  853. // attach an event on AudioPlayer
  854. _audioPlayer
  855. .on('audio-open-document', this.onAudioOpenDocument.bind(this))
  856. .on('audio-play', this.onAudioPlayerPlay.bind(this))
  857. .on('audio-pause', this.onAudioPlayerPause.bind(this))
  858. .on('audio-ended', this.onAudioPlayerEnded.bind(this));
  859. // .on('audio-play-next', this.onAudioPlayNext.bind(this));
  860. // this.newCompo();
  861. },
  862. newCompo(){
  863. //console.log('CompoPlayer newCompo()');
  864. // this.$compo = $('.composition_ui .composer .composition');
  865. this.initControls();
  866. },
  867. initControls(){
  868. //console.log('CompoPlayer initControls()');
  869. this.$composer = $('.composition_ui .composer');
  870. this.$compo = $('.composition_ui .composer .composition');
  871. this.$controls = $('.composition_ui .composer .compo-player-controls');
  872. if(!this.$controls.is('.ready') && this.$compo){
  873. this.$previous = $('<div>').addClass('previous')
  874. .on('click', this.prev.bind(this))
  875. .appendTo(this.$controls);
  876. this.$playpause = $('<div>').addClass('play-pause')
  877. .on('click', this.togglePlayPause.bind(this))
  878. .appendTo(this.$controls);
  879. this.$next = $('<div>').addClass('next')
  880. .on('click', this.next.bind(this))
  881. .appendTo(this.$controls);
  882. this.$controls.addClass('ready');
  883. this.refresh();
  884. this.active = true;
  885. // this.newCompo();
  886. }
  887. },
  888. refresh(){
  889. // console.log('CompoPlayer refresh(), this', this);
  890. this.stop();
  891. // load new playlist
  892. this.playlist = [];
  893. var that = this;
  894. $('.field--name-documents .field__item',this.$compo).each(function(i,el){
  895. var $link = $('a.audio-link',this);
  896. that.playlist.push({
  897. item:$(this),
  898. audio_url:$link.attr("audio_url"),
  899. nid:$link.attr("nid"),
  900. });
  901. });
  902. this.showHideControls();
  903. },
  904. togglePlayPause(){
  905. // console.log('CompoPlayer togglePlayPause');
  906. if (this.playing && !this.paused) {
  907. this.pause();
  908. }else{
  909. if(this.playing && this.paused){
  910. this.play();
  911. }else{
  912. this.start();
  913. }
  914. }
  915. },
  916. start(){
  917. //console.log('start');
  918. // console.log('CompoPlayer start()');
  919. this.playing = true;
  920. this.play();
  921. },
  922. play(){
  923. // console.log('play');
  924. if(this.paused){
  925. this.paused = false;
  926. _audioPlayer.play();
  927. }else{
  928. _audioPlayer.openDocument(this.playlist[this.current_index], this);
  929. }
  930. this.setActiveItem().showHideControls();
  931. },
  932. pause(){
  933. //console.log('pause');
  934. this.paused = true;
  935. this.showHideControls();
  936. _audioPlayer.stop();
  937. },
  938. next(){
  939. // console.log('CompoPlayer next()');
  940. if(this.playing){
  941. this.current_index += 1;
  942. if(this.current_index < this.playlist.length){
  943. this.play();
  944. }else{
  945. this.stop();
  946. }
  947. }
  948. },
  949. prev(){
  950. // console.log('CompoPlayer prev()');
  951. if(this.playing){
  952. this.current_index -= 1;
  953. if(this.current_index >= 0){
  954. this.play();
  955. }else{
  956. this.stop();
  957. }
  958. }
  959. },
  960. stop(){
  961. _audioPlayer.stop();
  962. this.reset();
  963. },
  964. reset(){
  965. this.playing = false;
  966. this.paused = false;
  967. this.resetIndex();
  968. },
  969. resetIndex(){
  970. this.current_index = 0;
  971. this.showHideControls().resetActiveItems();
  972. },
  973. setActiveItem(){
  974. this.resetActiveItems();
  975. if(this.playing && this.current_index >= 0){
  976. this.playlist[this.current_index].item.addClass('is-active');
  977. }
  978. // this call shoud not be here
  979. this.showHideControls();
  980. return this;
  981. },
  982. resetActiveItems(){
  983. for (var n = 0; n < this.playlist.length; n++) {
  984. // console.log('node',node);
  985. this.playlist[n].item.removeClass('is-active');
  986. }
  987. return this;
  988. },
  989. showHideControls(){
  990. // console.log('CompoPlayer showHideNextBtn(), playing:'+this.playing+', paused:'+this.paused);
  991. // global playing
  992. if(this.$controls){
  993. if(this.playing && !this.paused){
  994. this.$controls.addClass('is-playing');
  995. }else{
  996. this.$controls.removeClass('is-playing');
  997. }
  998. }
  999. // playpause
  1000. if(this.$playpause){
  1001. if(this.playlist.length > 0){
  1002. this.$playpause.addClass('is-active');
  1003. }else{
  1004. this.$playpause.removeClass('is-active');
  1005. }
  1006. }
  1007. // next
  1008. if(this.$next){
  1009. if(this.playing && this.playlist.length > 1 && this.current_index < this.playlist.length -1){
  1010. this.$next.addClass('is-active');
  1011. }else{
  1012. this.$next.removeClass('is-active');
  1013. }
  1014. }
  1015. // previous
  1016. if(this.$previous){
  1017. if(this.playing && this.playlist.length > 1 && this.current_index > 0){
  1018. this.$previous.addClass('is-active');
  1019. }else{
  1020. this.$previous.removeClass('is-active');
  1021. }
  1022. }
  1023. return this;
  1024. },
  1025. deactivate(){
  1026. this.stop();
  1027. this.active = false;
  1028. },
  1029. // _audioPlayer events
  1030. onAudioOpenDocument(args){
  1031. if(args.caller !== this){
  1032. // console.log('CompoPlayer onAudioOpenDocument() called by other');
  1033. this.reset();
  1034. }
  1035. // else{
  1036. // // console.log('CompoPlayer onAudioOpenDocument() self calling');
  1037. // }
  1038. },
  1039. onAudioPlayerPlay(){
  1040. if(this.playing && this.paused){
  1041. this.paused = false;
  1042. this.showHideControls();
  1043. }
  1044. },
  1045. onAudioPlayerPause(){
  1046. if(this.playing && !this.paused){
  1047. this.paused = true;
  1048. this.showHideControls();
  1049. }
  1050. },
  1051. onAudioPlayerEnded(){
  1052. this.next();
  1053. },
  1054. // onAudioPlayNext(){
  1055. // this.next();
  1056. // }
  1057. };
  1058. // ___ _ ___
  1059. // | __| _ ___ _ _| |_| _ \__ _ __ _ ___
  1060. // | _| '_/ _ \ ' \ _| _/ _` / _` / -_)
  1061. // |_||_| \___/_||_\__|_| \__,_\__, \___|
  1062. // |___/
  1063. function backToFrontPage(pop_state){
  1064. closeAllModals();
  1065. // assume we are going back to front page
  1066. $('body').removeClass().addClass('path-frontpage');
  1067. $('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
  1068. // close entrees
  1069. _$corpus_canvas.trigger({'type':'close-all-entree'});
  1070. if(!pop_state){
  1071. history.pushState({home:true}, null, window.location.origin);
  1072. }
  1073. }
  1074. function initHome(){
  1075. addCloseModalBtnToCols();
  1076. // console.log('theme : initHome');
  1077. // console.log('theme : initProductions');
  1078. var $grid = $('.grid',_$row).masonry({
  1079. itemSelector:'.col',
  1080. columnWidth:'.col-2',
  1081. horizontalOrder: true,
  1082. containerStyle: null,
  1083. // disable initial layout
  1084. // initLayout: false,
  1085. });
  1086. // bind event
  1087. // $grid.masonry( 'on', 'layoutComplete', function() {
  1088. // console.log('layout is complete');
  1089. // });
  1090. // layout Masonry after each image loads
  1091. $grid.imagesLoaded().progress( function() {
  1092. $grid.masonry('layout');
  1093. });
  1094. $grid.imagesLoaded(function(){
  1095. $grid.masonry('layout');
  1096. });
  1097. }
  1098. // ___ _ _ _
  1099. // | _ \_ _ ___ __| |_ _ __| |_(_)___ _ _ ___
  1100. // | _/ '_/ _ \/ _` | || / _| _| / _ \ ' \(_-<
  1101. // |_| |_| \___/\__,_|\_,_\__|\__|_\___/_||_/__/
  1102. function initProductions(){
  1103. // console.log('theme : initProductions');
  1104. var $grid = $('.grid',_$row).masonry({
  1105. itemSelector:'.col',
  1106. columnWidth:'.col-2',
  1107. horizontalOrder: true,
  1108. containerStyle: null,
  1109. // disable initial layout
  1110. // initLayout: false,
  1111. });
  1112. // bind event
  1113. // $grid.masonry( 'on', 'layoutComplete', function() {
  1114. // console.log('layout is complete');
  1115. // });
  1116. // layout Masonry after each image loads
  1117. $grid.imagesLoaded().progress( function() {
  1118. $grid.masonry('layout');
  1119. });
  1120. $grid.imagesLoaded(function(){
  1121. $grid.masonry('layout');
  1122. });
  1123. };
  1124. // ___ _ _ _
  1125. // | __|_ _ _ _ ___ __ _(_)__| |_ _ _ ___ _ __ ___ _ _| |_
  1126. // | _|| ' \| '_/ -_) _` | (_-< _| '_/ -_) ' \/ -_) ' \ _|
  1127. // |___|_||_|_| \___\__, |_/__/\__|_| \___|_|_|_\___|_||_\__|
  1128. // |___/
  1129. function initEnregistrementTranscript(){
  1130. console.log('initEnregistrementTranscript');
  1131. var $node = _$row.find('article.node--type-enregistrement.node--view-mode-transcript');
  1132. var $nav = $('<nav>').prependTo($node);
  1133. $node.find('.field--name-field-transcript-vo').addClass('visible').find('.field__label')
  1134. .clone().appendTo($nav).addClass('is-active')
  1135. .attr('field_target', '.field--name-field-transcript-vo');
  1136. $node.find('.field--name-field-transcript-trad').find('.field__label')
  1137. .clone().appendTo($nav)
  1138. .attr('field_target', '.field--name-field-transcript-trad');
  1139. $nav.find('.field__label').on('click', function(){
  1140. var $this = $(this).addClass('is-active');
  1141. $this.siblings('.is-active').removeClass('is-active');
  1142. $this.parents('article.node').find('.field.visible').removeClass('visible');
  1143. $this.parents('article.node').find($this.attr('field_target')).addClass('visible');
  1144. });
  1145. };
  1146. // __ __ _ _
  1147. // | \/ |___ __| |__ _| |___
  1148. // | |\/| / _ \/ _` / _` | (_-<
  1149. // |_| |_\___/\__,_\__,_|_/__/
  1150. function closeAllModals(){
  1151. //console.log('theme : closeAllModals');
  1152. // TODO: animate the remove
  1153. _$row.html('');
  1154. _$ajaxLinks.removeClass('is-active');
  1155. _$body.trigger({'type':'all-modal-closed'});
  1156. };
  1157. // _ _ _
  1158. // | || |___| |_ __ ___ _ _ ___
  1159. // | __ / -_) | '_ \/ -_) '_(_-<
  1160. // |_||_\___|_| .__/\___|_| /__/
  1161. // |_|
  1162. // https://plainjs.com/javascript/utilities/set-cookie-get-cookie-and-delete-cookie-5/
  1163. // function getCookie(name) {
  1164. // var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
  1165. // return v ? v[2] : null;
  1166. // }
  1167. // function setCookie(name, value, days) {
  1168. // var d = new Date;
  1169. // d.setTime(d.getTime() + 24*60*60*1000*days);
  1170. // document.cookie = name + "=" + value + ";path=/;expires=" + d.toGMTString();
  1171. // }
  1172. // function deleteCookie(name) { setCookie(name, '', -1); }
  1173. init();
  1174. } // end EdlpTheme()
  1175. $(document).ready(function($) {
  1176. var edlptheme = new EdlpTheme();
  1177. });
  1178. })(jQuery, Drupal, drupalSettings);