corpus.js 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  1. /**
  2. * @Author: Bachir Soussi Chiadmi <bach>
  3. * @Date: 18-12-2017
  4. * @Email: bachir@figureslibres.io
  5. * @Filename: corpus.js
  6. * @Last modified by: bach
  7. * @Last modified time: 20-12-2017
  8. * @License: GPL-V3
  9. */
  10. // JS performance improvement http://archive.oreilly.com/pub/a/server-administration/excerpts/even-faster-websites/writing-efficient-javascript.html
  11. /**
  12. * depends on :
  13. * physics.js : http://jonobr1.com/Physics/#
  14. */
  15. (function($, Drupal, drupalSettings) {
  16. EdlpCorpus = function(){
  17. var _activated = true;
  18. var _$body = $('body');
  19. var _$container = _$body;
  20. var _$canvas = $('<canvas id="corpus-map">').appendTo(_$container);
  21. var _canvas = _$canvas[0];
  22. var _ctx = _canvas.getContext('2d');
  23. var _dpi = window.devicePixelRatio;
  24. var _scene_props = {
  25. width:window.innerWidth,
  26. height:window.innerHeight,
  27. // 'margin_top':90, // with red border on head
  28. 'margin_top':75, // without red border on head
  29. // 'margin_top':0,
  30. 'margin_right':0,
  31. 'margin_bottom':65,
  32. // 'margin_bottom':0,
  33. 'margin_left':0
  34. };
  35. var _evolution_zone = {
  36. left:_scene_props.width/4,
  37. right:_scene_props.width - _scene_props.width/4,
  38. center:_scene_props.width/2,
  39. };
  40. var _physics = new Physics();
  41. var _nodes = [];
  42. var _articles_nodes = [];
  43. var _no_articles_nodes = [];
  44. var _articles_filter_on = false;
  45. var _nodes_by_entries = {};
  46. var _nodes_by_nid = {};
  47. var _nodes_Nid_Id = {};
  48. var _nodes_centered = [];
  49. var _nodes_centered_attractions = [];
  50. var _loaded = false;
  51. var _playlist = [];
  52. var _p_velocity_factor = 0.5;
  53. var _mouse_in = true;
  54. var _m_pos = {x:0, y:0};
  55. var _node_hover_id = -1;
  56. var _node_opened_id = -1;
  57. var _$entrees_block = $('#block-edlpentreesblock');
  58. var _$entrees_block_termlinks = $('a.term-link', _$entrees_block);
  59. var _$articles_link;
  60. var _node_pop_up;
  61. // Colors depend on drupalSettings loaded by edlp_corpus.module
  62. var _settings = drupalSettings.edlp_corpus;
  63. var _ecolors = _settings.colors;
  64. // Physics
  65. var _attracter;
  66. var check_parts_colid_frq = 2;
  67. var check_parts_colid_tick = 1;
  68. // ____ _ __
  69. // / _/___ (_) /______
  70. // / // __ \/ / __/ ___/
  71. // _/ // / / / / /_(__ )
  72. // /___/_/ /_/_/\__/____/
  73. function init(){
  74. initCanvas();
  75. if(_activated){
  76. loadCorpus();
  77. }else{
  78. _$canvas.addClass('de-activated');
  79. }
  80. };
  81. // ___
  82. // / __|__ _ _ ___ ____ _ ___
  83. // | (__/ _` | ' \ V / _` (_-<
  84. // \___\__,_|_||_\_/\__,_/__/
  85. function initCanvas(){
  86. // resize the canvas to fill browser window dynamically
  87. window.addEventListener('resize', onResizeCanvas, false);
  88. onResizeCanvas();
  89. };
  90. function onResizeCanvas() {
  91. // _dpi = 2;
  92. _scene_props.width = window.innerWidth;
  93. _scene_props.height = window.innerHeight;
  94. _canvas.style.width = _scene_props.width+'px';
  95. _canvas.style.height = _scene_props.height+'px';
  96. _canvas.width = _scene_props.width*_dpi;
  97. _canvas.height = _scene_props.height*_dpi;
  98. _ctx.scale(_dpi, _dpi);
  99. moveEvolutionZone();
  100. if(_loaded){
  101. for (var i = 0; i < _nodes.length; i++) {
  102. _nodes[i].onResizeCanvas();
  103. }
  104. // move _attracter and _repulser to their right places again
  105. // moveEvolutionZone() will trigger resizePhysics()
  106. // resizePhysics();
  107. }
  108. };
  109. // ___
  110. // / __|___ _ _ _ __ _ _ ___
  111. // | (__/ _ \ '_| '_ \ || (_-<
  112. // \___\___/_| | .__/\_,_/__/
  113. // |_|
  114. function loadCorpus(){
  115. // console.log('drupalSettings',drupalSettings);
  116. // console.log('window.location', window.location);
  117. // var path = window.location.origin + drupalSettings.basepath + "edlp/corpus";
  118. var ajax_path = _settings.load_corpus_ajax_url;
  119. var path = window.location.origin + Drupal.url(ajax_path);
  120. $.getJSON(path, {})
  121. .done(function(data){
  122. onCorpusLoaded(data);
  123. })
  124. .fail(function(jqxhr, textStatus, error){
  125. onCorpusLoadError(jqxhr, textStatus, error);
  126. });
  127. };
  128. function onCorpusLoadError(jqxhr, textStatus, error){
  129. console.warn('corpus load failed', jqxhr.responseText);
  130. };
  131. function onCorpusLoaded(data){
  132. // console.log('corpus loaded : data', data);
  133. // console.log('first node', data.nodes[0]);
  134. // buildParticles(data.nodes);
  135. initPhysics();
  136. buildNodes(data.nodes);
  137. initArtilesLink();
  138. initNodePopup();
  139. initEvents();
  140. checkPreOpenedEntry();
  141. startAnime();
  142. _loaded = true;
  143. };
  144. // ___ _ _
  145. // | _ \ |_ _ _ __(_)__ ___
  146. // | _/ ' \ || (_-< / _(_-<
  147. // |_| |_||_\_, /__/_\__/__/
  148. // |__/
  149. function initPhysics(){
  150. _attracter = _physics.makeParticle(1000);
  151. _attracter.fixed = true;
  152. // move _attracter on window resize
  153. resizePhysics();
  154. };
  155. function resizePhysics(){
  156. // attracters
  157. if(typeof _attracter != 'undefined'){
  158. _attracter.position = {x:_evolution_zone.center, y:_scene_props.height/2};
  159. }
  160. };
  161. // _ _ _
  162. // | \| |___ __| |___ ___
  163. // | .` / _ \/ _` / -_|_-<
  164. // |_|\_\___/\__,_\___/__/
  165. function buildNodes(nodes){
  166. // console.log("buildNodes", nodes);
  167. var d;
  168. for (var i in nodes) {
  169. d = i < 1 ? true : false;
  170. // _nodes.push(new Node(i,nodes[i],d));
  171. new Node(i,nodes[i],d);
  172. _playlist.push({
  173. 'id':i,
  174. 'nid':nodes[i].nid,
  175. 'audio_url':nodes[i].audio_url
  176. });
  177. }
  178. };
  179. function Node(i,node,d){
  180. this.id = i;
  181. for(key in node)
  182. this[key] = node[key];
  183. // record the node in different lists
  184. _nodes.push(this);
  185. _nodes_by_nid[this.nid] = this;
  186. _nodes_Nid_Id[this.nid] = this.id;
  187. if(this.has_article == 1){
  188. _articles_nodes.push(this);
  189. }else{
  190. _no_articles_nodes.push(this);
  191. }
  192. for (var j = 0; j < this.entrees.length; j++) {
  193. if(typeof _nodes_by_entries[this.entrees[j]] == 'undefined')
  194. _nodes_by_entries[this.entrees[j]] = [];
  195. _nodes_by_entries[this.entrees[j]].push(this);
  196. }
  197. this.debug = d;
  198. this.mass = Math.max(1, this.entrees.length); //1;
  199. this.velocity_threshold = 0.01;
  200. // define radius regarding entries length
  201. switch(true){
  202. case this.entrees.length > 3:
  203. this.r = 8;//10;
  204. break;
  205. case this.entrees.length > 1 && this.entrees.length <= 3:
  206. this.r = 5;//7;
  207. break;
  208. default:
  209. this.r = 3;//4;
  210. break;
  211. }
  212. this.d = this.r*2;
  213. this.e_color = 'e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];
  214. // pre-rendering node virtual canvas
  215. this.canvas = document.createElement('canvas');
  216. this.canvas_ctx = this.canvas.getContext('2d');
  217. this.line_width = 1;
  218. this.w = this.r*2+this.line_width*2;
  219. this.w_2 = this.w/2;
  220. this.canvas.width = this.w;
  221. this.canvas.height = this.w;
  222. this.canvas_ctx.fillStyle = 'rgb(255,255,255)';
  223. this.canvas_ctx.lineWidth = this.line_width;
  224. this.wall_bouncing_elasticity = 0.75;
  225. // node states
  226. this.hover = false;
  227. this.opened = false;
  228. this.faded = false;
  229. this.center = false;
  230. this.aside = false;
  231. this.scrambling = false;
  232. // prototypes
  233. if (typeof Node.initialized == "undefined") {
  234. Node.prototype.init = function(){
  235. this.calcWallLimits();
  236. this.x = this.wall_limits.left + Math.random()*(this.wall_limits.right - this.wall_limits.left);
  237. this.y = this.wall_limits.top + Math.random()*(this.wall_limits.bottom - this.wall_limits.top);
  238. this.ori_pos = {x:this.x,y:this.y};
  239. // TODO: don't forget to move ori_pos on window resize
  240. //this.drawSprite();
  241. this.initPhysics();
  242. };
  243. // Node.prototype.drawSprite = function(){
  244. // _ctx.clearRect(0, 0, this.w, this.w);
  245. //
  246. // this.canvas_ctx.beginPath();
  247. // // white background
  248. // this.canvas_ctx.fillRect(0,0,this.w,this.w);
  249. //
  250. // this.canvas_ctx.globalAlpha = this.faded ? 0.15 : 1;
  251. //
  252. // if(this.opened){
  253. // // carre plein
  254. // // this.canvas_ctx.lineWidth = '1px';
  255. // // this.canvas_ctx.strokeStyle = 'rgb(255,0,0)';
  256. // // this.canvas_ctx.strokeRect(this.x - this.r-3,this.y - this.r-3,this.r*2+6,this.r*2+6);
  257. // // ou carre contour
  258. // this.canvas_ctx.save(); // save the normal context state (fill white)
  259. // this.canvas_ctx.fillStyle = _ecolors[this.e_color];
  260. // this.canvas_ctx.fillRect(this.line_width,this.line_width,this.d,this.d);
  261. // this.canvas_ctx.restore(); // restore the normal context state (fill white)
  262. // }
  263. // // else{
  264. // // // carre plein
  265. // // // this.canvas_ctx.fillStyle = _ecolors[this.e_color];
  266. // // // this.canvas_ctx.fillRect(this.x - this.r,this.y - this.r,this.d,this.d);
  267. // // // ou carre contour
  268. // // this.canvas_ctx.fillRect(this.line_width,this.line_width,this.d,this.d);
  269. // // }
  270. // this.canvas_ctx.strokeStyle = _ecolors[this.e_color];
  271. // this.canvas_ctx.strokeRect(this.line_width,this.line_width,this.d,this.d);
  272. // // this.canvas_ctx.globalAlpha = 1;
  273. // this.canvas_ctx.closePath();
  274. // };
  275. Node.prototype.initPhysics = function(){
  276. // particule
  277. this.p = _physics.makeParticle(this.mass, this.x, this.y);
  278. this.p.velocity = new Physics.Vector((Math.random()-0.5)*_p_velocity_factor, (Math.random()-0.5)*_p_velocity_factor);
  279. // origin position particule
  280. this.ori_p = _physics.makeParticle(1000, this.ori_pos.x, this.ori_pos.y);
  281. this.ori_p.fixed = true;
  282. // TODO: don't forget to move ori_p on window resize
  283. this.ori_p_attract = _physics.makeAttraction(this.ori_p, this.p, 1000, _scene_props.width*2);
  284. this.ori_p_attract.on = false;
  285. // attracter
  286. this.attract = _physics.makeAttraction(_attracter, this.p, 1000, _scene_props.width*2);
  287. this.attract.on = false;
  288. };
  289. Node.prototype.calcWallLimits = function(){
  290. this.wall_limits = {
  291. top: _scene_props.margin_top +this.r,
  292. right: _scene_props.width -_scene_props.margin_right -this.r,
  293. bottom: _scene_props.height -_scene_props.margin_bottom -this.r,
  294. left: _scene_props.margin_left +this.r
  295. }
  296. };
  297. Node.prototype.onResizeCanvas = function(){
  298. this.calcWallLimits();
  299. // TODO: scramble only if not aside or centered
  300. this.shuffleOriP();
  301. };
  302. Node.prototype.shuffleOriP = function(){
  303. this.ori_pos.x = this.wall_limits.left + Math.random()*(this.wall_limits.right - this.wall_limits.left);
  304. this.ori_pos.y = this.wall_limits.top + Math.random()*(this.wall_limits.bottom - this.wall_limits.top);
  305. this.scramble();
  306. };
  307. Node.prototype.onUpdate = function(){
  308. // this.p.velocity.multiplyScalar(0.99);
  309. if(this.hover || this.opened){
  310. this.p.fixed = true;
  311. }else{
  312. this.p.fixed = false;
  313. if(this.center)
  314. this.limitEvolutionZone();
  315. // if(!this.p.resting()){
  316. // this.checkVelocityThreshold();
  317. this.checkWallBouncing();
  318. this.updatePos();
  319. if(this.scrambling){
  320. this.checkOriPDist();
  321. }
  322. // }
  323. }
  324. if(_mouse_in && !this.aside && !this.faded)
  325. this.checkMouse();
  326. // this.move();
  327. this.redraw();
  328. };
  329. Node.prototype.checkVelocityThreshold = function(){
  330. if(!this.centered || !this.aside){
  331. if (Math.abs(this.p.velocity.x) < this.velocity_threshold
  332. && Math.abs(this.p.velocity.y) < this.velocity_threshold){
  333. this.p.velocity.multiplyScalar(0);
  334. // this.p.makeFixed();
  335. }
  336. }
  337. };
  338. Node.prototype.checkWallBouncing = function(){
  339. switch(true){
  340. case this.x < this.wall_limits.left && this.p.velocity.x < 0:
  341. this.p.position.x = this.wall_limits.left;
  342. this.p.velocity
  343. .multiplyScalarXY(-1, 1)
  344. .multiplyScalar(this.wall_bouncing_elasticity);
  345. break;
  346. case this.x > this.wall_limits.right && this.p.velocity.x > 0:
  347. this.p.position.x = this.wall_limits.right;
  348. this.p.velocity
  349. .multiplyScalarXY(-1, 1)
  350. .multiplyScalar(this.wall_bouncing_elasticity);
  351. break;
  352. case this.y < this.wall_limits.top && this.p.velocity.y < 0 :
  353. this.p.position.y = this.wall_limits.top;
  354. this.p.velocity
  355. .multiplyScalarXY(1,-1)
  356. .multiplyScalar(this.wall_bouncing_elasticity);
  357. break;
  358. case this.y > this.wall_limits.bottom && this.p.velocity.y > 0 :
  359. this.p.position.y = this.wall_limits.bottom;
  360. this.p.velocity
  361. .multiplyScalarXY(1,-1)
  362. .multiplyScalar(this.wall_bouncing_elasticity);
  363. break;
  364. }
  365. };
  366. Node.prototype.updatePos = function(){
  367. this.x = this.p.position.x;
  368. this.y = this.p.position.y;
  369. };
  370. Node.prototype.checkMouse = function(){
  371. if( _m_pos.x > this.x - this.r
  372. && _m_pos.x < this.x + this.r
  373. && _m_pos.y > this.y - this.r
  374. && _m_pos.y < this.y + this.r){
  375. if(_node_hover_id == -1 || _node_hover_id !== this.id){
  376. // console.log("Node hover", this.id);
  377. this.setHover();
  378. }
  379. }else{
  380. this.unsetHover();
  381. }
  382. };
  383. Node.prototype.setHover = function(){
  384. this.hover = true;
  385. _node_hover_id = this.id;
  386. _node_pop_up.setNode(this);
  387. };
  388. Node.prototype.unsetHover = function(){
  389. this.hover = false;
  390. if (_node_hover_id == this.id) {
  391. _node_hover_id = -1;
  392. _node_pop_up.removeNode();
  393. }
  394. };
  395. Node.prototype.open = function(){
  396. this.opened = true;
  397. _node_opened_id = this.id;
  398. //this.drawSprite();
  399. };
  400. Node.prototype.close = function(){
  401. this.opened = false;
  402. //this.drawSprite();
  403. };
  404. Node.prototype.fade = function(){
  405. this.faded = true;
  406. //this.drawSprite();
  407. };
  408. Node.prototype.unFade = function(){
  409. this.faded = false;
  410. //this.drawSprite();
  411. };
  412. Node.prototype.setCenteredOnEntree = function(tid){
  413. this.e_color = 'e_col_'+tid;
  414. this.setCentered();
  415. };
  416. Node.prototype.setCentered = function(){
  417. this.center = true;
  418. this.stopScrambling();
  419. this.unsetAside();
  420. this.attract.on = true;
  421. //this.drawSprite();
  422. }
  423. Node.prototype.unsetCentered = function(){
  424. this.center = false;
  425. this.attract.on = false;
  426. }
  427. Node.prototype.limitEvolutionZone = function(){
  428. // smouthly slow down node near center
  429. // if(this.id == 1)
  430. // console.log('this.p.velocity', this.p.velocity);
  431. this.dist_to_attracter = this.p.distanceTo(_attracter);
  432. if( this.dist_to_attracter < _scene_props.width/4){
  433. if( this.p.velocity.length() > 0.4 ){
  434. this.p.velocity.multiplyScalar(0.99); // 0.995
  435. }
  436. }
  437. // limit evolution zone
  438. // if( Math.abs(_attracter.position.x - this.x) > _scene_props.width/4
  439. // || Math.abs(_attracter.position.y - this.y) > _scene_props.height/4){
  440. if( this.x < _evolution_zone.left || this.x > _evolution_zone.right
  441. || Math.abs(_attracter.position.y - this.y) > _scene_props.height/4){
  442. this.attract.on = true;
  443. }else{
  444. this.attract.on = false;
  445. }
  446. }
  447. Node.prototype.setAside = function(){
  448. this.aside = true;
  449. // this.fade();
  450. this.stopScrambling();
  451. this.unsetCentered();
  452. this.ori_p.position.x = this.x < _scene_props.width /2 ? this.wall_limits.left : this.wall_limits.right;
  453. this.ori_p_attract.on = true;
  454. this.wall_bouncing_elasticity = 0.15;
  455. }
  456. Node.prototype.unsetAside = function(){
  457. // console.log('unsetAside');
  458. this.aside = false;
  459. this.ori_p_attract.on = false;
  460. this.ori_p.position.x = this.ori_pos.x;
  461. this.wall_bouncing_elasticity = 0.75;
  462. // this.unFade();
  463. }
  464. Node.prototype.resolveNormalPos = function(){
  465. // console.log("resolveNormalPos");
  466. switch(true){
  467. case this.center:
  468. this.unsetCentered();
  469. break;
  470. case this.aside:
  471. this.unsetAside();
  472. break;
  473. }
  474. };
  475. Node.prototype.scramble = function(){
  476. this.scrambling = true;
  477. this.unsetCentered();
  478. this.unsetAside();
  479. this.ori_p.position.x = this.ori_pos.x;
  480. this.ori_p.position.y = this.ori_pos.y;
  481. this.ori_p_attract.on = true;
  482. }
  483. Node.prototype.checkOriPDist = function(){
  484. if(this.p.distanceTo(this.ori_p) < 50){
  485. this.stopScrambling();
  486. }
  487. };
  488. Node.prototype.stopScrambling = function(){
  489. this.scrambling = false;
  490. this.ori_p_attract.on = false;
  491. // this.scramble_TL.on = false;
  492. // this.scramble_TR.on = false;
  493. // this.scramble_BR.on = false;
  494. // this.scramble_BL.on = false;
  495. // this.scramble_CR.on = false;
  496. // this.scramble_CL.on = false;
  497. }
  498. Node.prototype.move = function(){
  499. // just draw the virtual node canvas into the main scene canvas at the right position
  500. _ctx.drawImage(this.canvas, this.x-this.w_2, this.y-this.w_2);
  501. };
  502. Node.prototype.redraw = function(){
  503. _ctx.beginPath();
  504. // white background
  505. _ctx.fillStyle = 'rgb(255,255,255)';
  506. _ctx.fillRect(this.x-this.r,this.y-this.r,this.d,this.d);
  507. _ctx.globalAlpha = this.faded ? 0.15 : 1;
  508. if(this.opened){
  509. // carre plein
  510. // _ctx.lineWidth = '1px';
  511. // _ctx.strokeStyle = 'rgb(255,0,0)';
  512. // _ctx.strokeRect(this.x - this.r-3,this.y - this.r-3,this.r*2+6,this.r*2+6);
  513. // ou carre contour
  514. // _ctx.save(); // save the normal context state (fill white)
  515. _ctx.fillStyle = _ecolors[this.e_color];
  516. _ctx.fillRect(this.x-this.r,this.y-this.r,this.d,this.d);
  517. // _ctx.restore(); // restore the normal context state (fill white)
  518. }
  519. // else{
  520. // // carre plein
  521. // // _ctx.fillStyle = _ecolors[this.e_color];
  522. // // _ctx.fillRect(this.x - this.r,this.y - this.r,this.d,this.d);
  523. // // ou carre contour
  524. // _ctx.fillRect(this.line_width,this.line_width,this.d,this.d);
  525. // }
  526. _ctx.strokeStyle = _ecolors[this.e_color];
  527. _ctx.strokeRect(this.x-this.r,this.y-this.r,this.d,this.d);
  528. // _ctx.globalAlpha = 1;
  529. _ctx.closePath();
  530. };
  531. Node.initialized = true;
  532. }
  533. this.init();
  534. };
  535. // TODO: we may convert a lot of computation into a web worker
  536. // https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
  537. function checkParticulesCollisions(){
  538. // do not run particule collision every frames
  539. if(check_parts_colid_tick < check_parts_colid_frq){
  540. check_parts_colid_tick++;
  541. return;
  542. }
  543. check_parts_colid_tick = 1;
  544. // pre create vars to save memory;
  545. var na,nb,
  546. ma,mb,
  547. w,h,dx,dy,
  548. makeup,
  549. newVelX1, newVelY1, newVelX2, newVelY2,
  550. Smamb;
  551. // , angle;
  552. // colisions between _particules
  553. for (var n = 0, l = _nodes.length; n < l; n++) {
  554. na = _nodes[n];
  555. // avoid colliding for scrambling nodes
  556. // avoid colliding for aside nodes
  557. // avoid colliding for centered nodes
  558. if(na.scrambling || na.aside || na.center) continue;
  559. ma = na.p.mass;
  560. for (var q = n+1; q < l; q++) {
  561. nb = _nodes[q];
  562. // avoid impact between center and aside particules
  563. // if((na.center && nb.aside) || (na.aside && nb.center))
  564. // and between aside particules
  565. if(nb.aside)
  566. continue;
  567. // avoid impact between two centered particulses that comes to the center
  568. // if(na.center && nb.center){
  569. // if(Math.min(na.p.distanceTo(_attracter), nb.p.distanceTo(_attracter)) > 300){
  570. // if( Math.random()>0.3 ) continue;
  571. // }
  572. // }
  573. w = h = (na.r+nb.r);
  574. // if(!na.aside && !nb.aside){
  575. w = h += 4; // add a saftey zone around squares eccept for aside squares
  576. // }
  577. // if both dx and dy are inferior to w & h so squares are colliding (overlapping)
  578. // if( Math.abs(dx) <= w && Math.abs(dy) <= h){ console.log('colliding'); }
  579. // else not so skip
  580. // if( Math.abs(dx) > w || Math.abs(dy) > h) continue;
  581. dx = na.p.position.x - nb.p.position.x;
  582. if( Math.abs(dx) > w ) continue;
  583. dy = na.p.position.y - nb.p.position.y;
  584. if(Math.abs(dy) > h) continue
  585. mb = nb.p.mass;
  586. Smamb = ma+mb;
  587. if(Math.abs(dx) < Math.abs(dy)){ // vertical collision
  588. makeup = (h - Math.abs(dy))/2;
  589. if(dy > 0){ // a is upper than b
  590. na.p.position.y += makeup;
  591. nb.p.position.y -= makeup;
  592. }else{ // b is upper than a
  593. na.p.position.y -= makeup;
  594. nb.p.position.y += makeup;
  595. }
  596. // bounce
  597. // https://en.wikipedia.org/wiki/Elastic_collision#One-dimensional_Newtonian
  598. newVelY1 = (ma-mb)/Smamb*na.p.velocity.y+2*mb/Smamb*nb.p.velocity.y;
  599. newVelY2 = (mb-ma)/Smamb*nb.p.velocity.y+2*ma/Smamb*na.p.velocity.y;
  600. na.p.velocity.y = newVelY1;
  601. nb.p.velocity.y = newVelY2;
  602. }else{ // horizontal collision
  603. makeup = (w - Math.abs(dx))/2;
  604. if(dx > 0){ // a is at left of b
  605. na.p.position.x += makeup;
  606. nb.p.position.x -= makeup;
  607. }else{ // b is at left of a
  608. na.p.position.x -= makeup;
  609. nb.p.position.x += makeup;
  610. }
  611. // bounce
  612. // https://en.wikipedia.org/wiki/Elastic_collision#One-dimensional_Newtonian
  613. newVelX1 = (ma-mb)/Smamb*na.p.velocity.x+2*mb/Smamb*nb.p.velocity.x;
  614. newVelX2 = (mb-ma)/Smamb*nb.p.velocity.x+2*ma/Smamb*na.p.velocity.x;
  615. na.p.velocity.x = newVelX1;
  616. nb.p.velocity.x = newVelX2;
  617. }
  618. // slow down particule on impact
  619. // na.p.velocity.multiplyScalar(na.center && na.p.velocity.length() < 1 ? 1.1 : 0.90);
  620. // nb.p.velocity.multiplyScalar(nb.center && nb.p.velocity.length() < 1 ? 1.1 : 0.90);
  621. na.p.velocity.multiplyScalar(0.90);
  622. nb.p.velocity.multiplyScalar(0.90);
  623. }
  624. }
  625. };
  626. // show opened audio node
  627. function openNodeByNid(nid){
  628. // console.log('Corpus openNode()', nid);
  629. closeNode();
  630. if(typeof _nodes_Nid_Id[nid] != 'undefined'){
  631. // console.log('node exists');
  632. _node_opened_id = _nodes_Nid_Id[nid];
  633. _nodes[_nodes_Nid_Id[nid]].open();
  634. }
  635. }
  636. function closeNode(){
  637. if(_node_opened_id != -1){
  638. // if(typeof _nodes[_node_opened_id] !== 'undefined'){
  639. _nodes[_node_opened_id].close();
  640. // }
  641. _node_opened_id = -1;
  642. }
  643. }
  644. function createNodesRepulsions(){
  645. // how to delete all these attractions before creates new once
  646. //console.log('_nodes_centered', _nodes_centered);
  647. purgeNodesRepulsions();
  648. for (var n = 0; n < _nodes_centered.length; n++) {
  649. for (var q = n+1; q < _nodes_centered.length; q++) {
  650. _physics.makeAttraction(_nodes_centered[n].p, _nodes_centered[q].p, -0.4, 10);
  651. }
  652. }
  653. };
  654. function purgeNodesRepulsions(){
  655. // console.log('_physics.attractions.length', _physics.attractions.length);
  656. for (var a = _physics.attractions.length-1; a >= 0; a--) {
  657. // assuming that only nodes repulsions have constant < 1
  658. // and are all at the end of array
  659. if(Math.abs(_physics.attractions[a].constant) < 1){
  660. _physics.attractions.splice(a,1);
  661. }else{
  662. break;
  663. }
  664. }
  665. // console.log('_physics.attractions.length', _physics.attractions.length);
  666. };
  667. // ___ _ _ _ ____
  668. // | __|_ _____| |_ _| |_(_)___ _ _ |_ /___ _ _ ___
  669. // | _|\ V / _ \ | || | _| / _ \ ' \ / // _ \ ' \/ -_)
  670. // |___|\_/\___/_|\_,_|\__|_\___/_||_| /___\___/_||_\___|
  671. function moveEvolutionZone(l, r){
  672. var left = l || 0;
  673. var right = r || 0;
  674. _evolution_zone.left = Math.max(_scene_props.width/5, left+20);
  675. _evolution_zone.right = Math.min(_scene_props.width - _scene_props.width/5, _scene_props.width-right+20);
  676. _evolution_zone.center = _evolution_zone.left + (_evolution_zone.right - _evolution_zone.left)/2;
  677. // move _attracter to the center of the zone
  678. resizePhysics();
  679. }
  680. // ___ _ ___ _ _ _ _
  681. // | _ \__ _ _ _ __| |___ _ __ | _ \ |__ _ _ _| (_)__| |_
  682. // | / _` | ' \/ _` / _ \ ' \ | _/ / _` | || | | (_-< _|
  683. // |_|_\__,_|_||_\__,_\___/_|_|_| |_| |_\__,_|\_, |_|_/__/\__|
  684. // |__/
  685. function updateRandomPlaylist(p){
  686. _$canvas.trigger({
  687. type:'update-random-playlist',
  688. playlist:p
  689. })
  690. };
  691. // ___ _
  692. // | __|_ _| |_ _ _ ___ ___ ___
  693. // | _|| ' \ _| '_/ -_) -_|_-<
  694. // |___|_||_\__|_| \___\___/__/
  695. function toggleEntree(tid, bubbling){
  696. var $link = _$entrees_block_termlinks.filter('[tid="'+tid+'"]');
  697. var $li = $link.parents('li');
  698. var sys_path = $link.attr('data-drupal-link-system-path');
  699. var url = $link.attr('href');
  700. var title = $link.text();
  701. if(!$li.is('.opened')){
  702. _$entrees_block_termlinks.parents('li').removeClass('opened');
  703. $li.addClass('opened');
  704. $li.parents('.item-list').addClass('opened')
  705. filterEntree(tid);
  706. if(bubbling){
  707. _$body.trigger({
  708. 'type':'open_entree',
  709. 'tid':tid,
  710. 'url':url,
  711. 'sys_path':sys_path,
  712. 'title':title
  713. });
  714. }
  715. // bubbling is true only when event is a real click on entree link
  716. }else if(bubbling){
  717. $li.removeClass('opened');
  718. $li.parents('.item-list').removeClass('opened')
  719. scrambleCollection();
  720. _$body.trigger({'type':'close_entree', 'tid':tid});
  721. }
  722. };
  723. function filterEntree(t){
  724. shutDownArticles();
  725. _nodes_centered = [];
  726. for (var n = 0; n < _nodes.length; n++) {
  727. if(_nodes[n].entrees.indexOf(t) == -1){
  728. _nodes[n].setAside();
  729. }else{
  730. _nodes[n].setCenteredOnEntree(t);
  731. // record centered nodes for inter node repulsions
  732. _nodes_centered.push(_nodes[n]);
  733. }
  734. }
  735. updateRandomPlaylist(_nodes_centered);
  736. createNodesRepulsions();
  737. };
  738. function highlightEntries(){
  739. _$entrees_block_termlinks
  740. .parents('li').removeClass('highlighted')
  741. .parents('.item-list').removeClass('highlighted');
  742. var id = -1;
  743. if(_node_hover_id != -1){
  744. id = _node_hover_id;
  745. }else if(_node_opened_id != -1){
  746. id = _node_opened_id;
  747. }
  748. var entree;
  749. if(id != -1){
  750. for (var i = 0; i < _nodes[id].entrees.length; i++) {
  751. entree = _nodes[id].entrees[i];
  752. _$entrees_block_termlinks.filter(function(){
  753. return $(this).attr('tid') == entree;
  754. }).parents('li').addClass('highlighted')
  755. .parents('.item-list').addClass('highlighted');
  756. }
  757. }
  758. };
  759. // ___ _
  760. // / __| ___ __ _ _ _ __| |_
  761. // \__ \/ -_) _` | '_/ _| ' \
  762. // |___/\___\__,_|_| \__|_||_|
  763. // and ajax modal content filtering
  764. function filterByNids(nids){
  765. shutDownArticles();
  766. _nodes_centered = [];
  767. for (var n = 0; n < _nodes.length; n++) {
  768. if(nids.indexOf(_nodes[n].nid) == -1){
  769. _nodes[n].setAside();
  770. }else{
  771. _nodes[n].setCentered();
  772. // record centered nodes for inter node repulsions
  773. _nodes_centered.push(_nodes[n]);
  774. }
  775. }
  776. updateRandomPlaylist(_nodes_centered);
  777. createNodesRepulsions();
  778. };
  779. // ___ _ _ _
  780. // / __| __ _ _ __ _ _ __ | |__| (_)_ _ __ _
  781. // \__ \/ _| '_/ _` | ' \| '_ \ | | ' \/ _` |
  782. // |___/\__|_| \__,_|_|_|_|_.__/_|_|_||_\__, |
  783. // |___/
  784. // function resolveNormalPosAllNodes(){
  785. // console.log('resolveNormalPosAllNodes');
  786. // for (var i = 0; i < _nodes.length; i++) {
  787. // _nodes[i].resolveNormalPos();
  788. // }
  789. // };
  790. function scrambleCollection(){
  791. // console.log('scrambleCollection');
  792. for (var i = 0; i < _nodes.length; i++) {
  793. _nodes[i].scramble();
  794. }
  795. updateRandomPlaylist(_playlist);
  796. // setTimeout(stopScrambling, 2000);
  797. // stopScrambling();
  798. };
  799. function closeAllEntries(){
  800. _$entrees_block_termlinks.each(function(index, el) {
  801. if($(this).parents('li').is('.opened')){
  802. $(this).trigger('click');
  803. return false;
  804. }
  805. });
  806. };
  807. // _ _ _ _
  808. // /_\ _ _| |_(_)__| |___ ___
  809. // / _ \| '_| _| / _| / -_|_-<
  810. // /_/ \_\_| \__|_\__|_\___/__/
  811. function initArtilesLink(){
  812. // add "articles link to blockentrees"
  813. _$articles_link = $('<a>')
  814. .html('Articles')
  815. .attr("href", "#articles")
  816. .addClass('articles-link')
  817. .on('click', onCLickedOnArticles);
  818. $('.item-list ul',_$entrees_block).append(
  819. $('<li>').append(
  820. $('<span class="oblique-wrapper">').append(_$articles_link)
  821. )
  822. );
  823. };
  824. function onCLickedOnArticles(e){
  825. e.preventDefault();
  826. $(this).toggleClass('is-active');
  827. if($(this).is('.is-active')){
  828. activateArticlesFilter();
  829. closeAllEntries();
  830. }else{
  831. deactivateArticlesFilter();
  832. }
  833. // _$canvas.trigger({
  834. // 'type':'corpus-cliqued-on-articles'
  835. // });
  836. return false;
  837. };
  838. function activateArticlesFilter(){
  839. //console.log('activateArticlesFilter');
  840. _articles_filter_on = true;
  841. for (var i = 0; i < _no_articles_nodes.length; i++) {
  842. _no_articles_nodes[i].fade();
  843. }
  844. updateRandomPlaylist(_articles_nodes);
  845. if(typeof _paq !== 'undefined'){
  846. // trackEvent(category, action, [name], [value])
  847. _paq.push(['trackEvent', 'Corpus Articles', 'on']);
  848. }
  849. };
  850. function deactivateArticlesFilter(){
  851. //console.log('deactivateArticlesFilter');
  852. _articles_filter_on = false;
  853. for (var i = 0; i < _no_articles_nodes.length; i++) {
  854. _no_articles_nodes[i].unFade();
  855. }
  856. updateRandomPlaylist(_playlist);
  857. if(typeof _paq !== 'undefined'){
  858. // trackEvent(category, action, [name], [value])
  859. _paq.push(['trackEvent', 'Corpus Articles', 'off']);
  860. }
  861. };
  862. function shutDownArticles(){
  863. // shutdown articles if active
  864. if(_$articles_link.is('.is-active'))
  865. _$articles_link.trigger('click');
  866. };
  867. // ___ _
  868. // | __|_ _____ _ _| |_ ___
  869. // | _|\ V / -_) ' \ _(_-<
  870. // |___|\_/\___|_||_\__/__/
  871. function initEvents(){
  872. console.log('Corpus, initEvents');
  873. _$canvas
  874. .on('mousemove', function(event) {
  875. event.preventDefault();
  876. _m_pos.x = event.originalEvent.clientX;
  877. _m_pos.y = event.originalEvent.clientY;
  878. })
  879. .on('mouseenter', function(event){
  880. // console.log('onMouseIN');
  881. _mouse_in = true;
  882. })
  883. .on('mouseout', function(event){
  884. // console.log('onMouseOUT');
  885. _mouse_in = false;
  886. _node_pop_up.removeNode();
  887. })
  888. .on('click', function(event) {
  889. if(event.target.tagName != "A" && event.target.tagName != "INPUT"){
  890. // console.log("Corpus : click");
  891. event.preventDefault();
  892. if(_node_hover_id != -1){
  893. // console.log("corpus : click on node", _nodes[_node_hover_id]);
  894. var event = {
  895. 'type':'corpus-cliked-on-node',
  896. 'target_node':_nodes[_node_hover_id],
  897. 'article':_articles_filter_on
  898. };
  899. _$canvas.trigger(event);
  900. // instead of directly opening the doc, create an event listener (e.g. : audio played from random)
  901. // openNode(_node_hover_id);
  902. }else{
  903. // console.log('corpus : click on map');
  904. _$canvas.trigger('corpus-cliked-on-map');
  905. shutDownArticles();
  906. }
  907. }
  908. })
  909. .on('mouseover-audio-link', function(e){
  910. console.log("Corpus on mouseover-audio-link", e);
  911. // _node_hover_id = _nodes_Nid_Id[e.nid];
  912. // _node_pop_up.setNode(_nodes_by_nid[e.nid]);
  913. _nodes_by_nid[e.nid].setHover();
  914. })
  915. .on('mouseout-audio-link', function(e){
  916. console.log("Corpus on mouseover-audio-link", e);
  917. // _node_hover_id = -1;
  918. // _node_pop_up.removeNode();
  919. _nodes_by_nid[e.nid].unsetHover();
  920. })
  921. .on('audio-node-opened', function(e){
  922. // console.log('Corpus audio-node-opened', e);
  923. openNodeByNid(e.nid);
  924. })
  925. .on('audio-node-closed', function(e){
  926. closeNode();
  927. })
  928. .on('open-entree', function(e){
  929. toggleEntree(e.tid);
  930. })
  931. .on('close-all-entree', function(e){
  932. closeAllEntries();
  933. })
  934. .on('scramble-collection', function(e){
  935. console.log('scramble-collection', e);
  936. // resolveNormalPosAllNodes();
  937. scrambleCollection();
  938. });
  939. _$entrees_block_termlinks.on('click', function(event) {
  940. // console.log('_$entrees_block_termlinks click', this);
  941. event.preventDefault();
  942. toggleEntree($(this).attr('tid'), true);
  943. // var $link = $(this);
  944. // var tid = $link.attr('tid');
  945. // var $li = $link.parents('li');
  946. // var sys_path = $link.attr('data-drupal-link-system-path');
  947. // var url = $link.attr('href');
  948. // if(!$li.is('.opened')){
  949. // _$entrees_block_termlinks.parents('li').removeClass('opened');
  950. // $li.addClass('opened');
  951. // toggleEntree(tid);
  952. // _$body.trigger({'type':'open_entree', 'tid':tid, 'url':url, 'sys_path':sys_path});
  953. // }else{
  954. // $li.removeClass('opened');
  955. // scrambleCollection();
  956. // _$body.trigger({'type':'close_entree', 'tid':tid});
  957. // }
  958. return false;
  959. });
  960. _$body
  961. .on('chutier-action-done', function(e) {
  962. _nodes_by_nid[e.target_id].chutier_action = e.new_action;
  963. })
  964. .on('ajax-node-loaded-linked-documents', function(e){
  965. console.log("Edlp Corpus, ajax-node-loaded-linked-documents",e.nids);
  966. // filter map's nodes
  967. filterByNids(e.nids);
  968. })
  969. .on('search-results-loaded', function(e){
  970. //console.log("Edlp Corpus, search-results-loaded",e.results);
  971. // filter map's nodes
  972. filterByNids(e.results);
  973. })
  974. .on('search-closed', function(e){
  975. scrambleCollection();
  976. })
  977. .on('new-content-not-entree-ajax-loaded', function(e){
  978. // close all entries only if entry already opened
  979. // TODO: user the function close all entries ?
  980. // closeAllEntries(); not working, is closing also the ajax loaded content
  981. if(_$entrees_block_termlinks.parents('li.opened').length){
  982. _$entrees_block_termlinks
  983. .parents('li').removeClass('opened')
  984. .parents('.item-list').removeClass('opened');
  985. scrambleCollection();
  986. }
  987. })
  988. .on('visible-space-changed', function(e){
  989. // limits are absolute distance from each side (not positions from left)
  990. moveEvolutionZone(e.left_limit, e.right_limit);
  991. });
  992. };
  993. function checkPreOpenedEntry(){
  994. _$entrees_block.find('li.entree').each(function(index, el) {
  995. var $li = $(this);
  996. if($('a.is-active', $li).length){
  997. $li.addClass('opened')
  998. .parents('.item-list').addClass('opened');
  999. filterEntree($li.attr('tid'));
  1000. return false;
  1001. }
  1002. });
  1003. };
  1004. // _ _ _ ___ _ _
  1005. // | \| |___ __| |___| _ \___ _ __| | | |_ __
  1006. // | .` / _ \/ _` / -_) _/ _ \ '_ \ |_| | '_ \
  1007. // |_|\_\___/\__,_\___|_| \___/ .__/\___/| .__/
  1008. // |_| |_|
  1009. function initNodePopup(){
  1010. _node_pop_up = new NodePopUp();
  1011. };
  1012. function NodePopUp(){
  1013. this.visible = false;
  1014. this.node;
  1015. this.$dom = $('<div>')
  1016. .addClass('node-popup')
  1017. .attr('pos', 'top-right')
  1018. .appendTo('body');
  1019. this.$content = $('<div>').addClass('inner').appendTo(this.$dom);
  1020. if (typeof NodePopUp.initialized == "undefined") {
  1021. NodePopUp.prototype.setNode = function(n){
  1022. // console.log('NodePopUp setNode()');
  1023. this.node = n;
  1024. // positioning NodePopUp regarding node position
  1025. this.setPositioning();
  1026. // update NodePopUp content
  1027. this.setContent();
  1028. };
  1029. NodePopUp.prototype.setPositioning = function(){
  1030. switch(true){
  1031. case this.node.x > this.node.wall_limits.right-350 && this.node.y < this.node.wall_limits.top+200:
  1032. this.$dom.attr('pos', 'bottom-left');
  1033. break;
  1034. case this.node.x > this.node.wall_limits.right-350:
  1035. this.$dom.attr('pos', 'top-left');
  1036. break;
  1037. case this.node.y < this.node.wall_limits.top+200:
  1038. this.$dom.attr('pos', 'bottom-right');
  1039. break;
  1040. default:
  1041. this.$dom.attr('pos', 'top-right');
  1042. }
  1043. };
  1044. NodePopUp.prototype.setContent = function(){
  1045. // console.log(this.node);
  1046. this.$content.html('');
  1047. var $entrees = $('<div>').addClass('entrees');
  1048. for (var i = 0; i < this.node.entrees.length; i++) {
  1049. var tid = this.node.entrees[i];
  1050. $entrees.append($('<span>').addClass('entree').attr('tid', tid));
  1051. }
  1052. var $chutier_action = $('<span>').addClass('chutier-icon').attr('action', this.node.chutier_action);
  1053. this.$content
  1054. .append($entrees)
  1055. .append('<h2 class="title">'+this.node.title+'</h2>')
  1056. .append('<section class="description">'+this.node.description+'</section>')
  1057. .append($chutier_action);
  1058. };
  1059. NodePopUp.prototype.removeNode = function(){
  1060. // console.log('NodePopUp removeNode()');
  1061. this.node = false;
  1062. };
  1063. NodePopUp.prototype.draw = function(){
  1064. if(this.node){
  1065. this.$dom.css({
  1066. 'display':"block",
  1067. 'left':this.node.x+"px",
  1068. 'top':this.node.y+"px",
  1069. });
  1070. }else{
  1071. this.$dom.css({
  1072. 'display':"none",
  1073. });
  1074. }
  1075. };
  1076. NodePopUp.initialized = true;
  1077. }
  1078. }
  1079. // ___ _
  1080. // | _ \___ _ _ __| |___ _ _
  1081. // | / -_) ' \/ _` / -_) '_|
  1082. // |_|_\___|_||_\__,_\___|_|
  1083. function render(){
  1084. _ctx.clearRect(0, 0, _scene_props.width, _scene_props.height);
  1085. checkParticulesCollisions();
  1086. for (var i = 0; i < _nodes.length; i++) {
  1087. _nodes[i].onUpdate();
  1088. }
  1089. _node_pop_up.draw();
  1090. if(_node_hover_id != -1){
  1091. _canvas.style.cursor = 'pointer';
  1092. }else{
  1093. _canvas.style.cursor = 'auto';
  1094. }
  1095. // check for highlighted entries
  1096. highlightEntries();
  1097. };
  1098. // ___ _ _ _ _
  1099. // / __| |_ __ _ _ _| |_ /_\ _ _ (_)_ __ ___
  1100. // \__ \ _/ _` | '_| _|/ _ \| ' \| | ' \/ -_)
  1101. // |___/\__\__,_|_| \__/_/ \_\_||_|_|_|_|_\___|
  1102. function startAnime(){
  1103. _physics.onUpdate(render);
  1104. _physics.play()
  1105. $('body')
  1106. .attr('corpus', 'map-ready')
  1107. .trigger({
  1108. 'type':'corpus-map-ready',
  1109. 'playlist':_playlist
  1110. });
  1111. };
  1112. init();
  1113. }
  1114. $(document).ready(function($) {
  1115. if(drupalSettings.path.isFront && !edlp_mobile.device_is_mobile){
  1116. var edlpcorpus = new EdlpCorpus();
  1117. }
  1118. });
  1119. })(jQuery, Drupal, drupalSettings);