jee.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. /*
  2. _ _
  3. |_|___ _ _ ___ ___ ___ ___| |_ ___ ___ ___ ___ ___ ___ ___
  4. | | -_| | | | -_|_ -| | -_| _| | -_| | . | .'| . | -_|_ -|
  5. _| |___|___|_|_|___|___| |___|_| |___|_|_|_ |__,|_ |___|___|
  6. |___| |___| |___|
  7. Bachir Soussi Chiadmi
  8. 2015
  9. */
  10. jQuery(document).ready(function($) {
  11. console.log('Hello Jee');
  12. var _debug = true,
  13. _avgDelay = 1,
  14. _lastDraw = new Date,
  15. _fps,
  16. _$nav_cursor;
  17. var _$body = $('body'),
  18. _$header = $("#header"),
  19. _$chapitres = $('.node-chapitre', '#main'),
  20. _chapitres_len = _$chapitres.length,
  21. _chapters = [],
  22. _$container = $('#main'),
  23. _container = {
  24. w:_$container.width(),
  25. h:_$container.height()
  26. },
  27. _center = {x:_container.w/2,y:_container.h/2},
  28. _nav_pos = {x:0, y:0},
  29. _mouse_down_pos = {x:0,y:0},
  30. _prev_mouse_pos = {x:0,y:0},
  31. _fps = 1000/12,
  32. _dragging = false, _timeout_dragging;
  33. var _bubbles = new Array(),
  34. _stars = new Array();
  35. function init(){
  36. if(_debug)
  37. initDebug();
  38. initChapters();
  39. launchNav();
  40. var $fullscreenBtn = $('<div>enter</div>').attr('id','fullscreen-btn').appendTo("#root");
  41. // Launch fullscreen for browsers that support it!
  42. $fullscreenBtn.on('click', function(e){
  43. // launchIntoFullscreen(document.documentElement); // the whole page
  44. launchIntoFullscreen(document.getElementById("root")); // any individual element
  45. });
  46. for (var i = 2; i > 0; i--) {
  47. _bubbles.push($('<div>').addClass('bubble bubble-'+i).prependTo(_$container));
  48. };
  49. for (var i = 20; i > 0; i--) {
  50. _stars.push(
  51. $('<div>')
  52. .addClass('star star-'+i)
  53. .css({
  54. left:randB(-400, _container.w+400),
  55. top:randB(-400, _container.h+400)
  56. })
  57. .prependTo(_$container)
  58. );
  59. };
  60. };
  61. function initDebug(){
  62. $('<p>').attr('id', 'fps').appendTo(_$container);
  63. _fps = document.getElementById('fps');
  64. requestAnimationFrame(displayFps);
  65. _$nav_cursor = $('<div id="nav-cursor"></div>').appendTo(_$container);
  66. moveDebugCursor();
  67. };
  68. function displayFps(){
  69. requestAnimationFrame(displayFps);
  70. var now = new Date;
  71. var delay = now - _lastDraw;
  72. _avgDelay += (delay - _avgDelay) / 10;
  73. _lastDraw = now;
  74. _fps.innerHTML = (1000/_avgDelay).toFixed(1) + " fps";
  75. };
  76. function moveDebugCursor(){
  77. _$nav_cursor.css({
  78. left:_nav_pos.x+_center.x+"px",
  79. top:_nav_pos.y+_center.y+"px"
  80. });
  81. };
  82. function initChapters(){
  83. // Place each chapters on the ellipse contained on the screen
  84. var base_a = Math.random() *360;
  85. _$chapitres.each(function(i, e) {
  86. // Lets create the chapter object and place him self
  87. _chapters.push(new Chapter(i, e, base_a));
  88. });
  89. };
  90. function launchNav(){
  91. $(document)
  92. /*
  93. ____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____
  94. | \| __| __| | |_ _| | _ | | __| | | __| | |_ _| __|
  95. | | | __|__ | -| | | | | | __| | __| | | __| | | | | | |__ |
  96. |____/|_____|_____|__|__| |_| |_____|__| |_____|\___/|_____|_|___| |_| |_____|
  97. */
  98. .bind('mousedown', function(e){
  99. console.log('mousedown');
  100. clearTimeout(_timeout_dragging);
  101. // set initial cursor pos
  102. _mouse_down_pos.x = e.clientX;
  103. _mouse_down_pos.y = e.clientY;
  104. updateNavPos(e.clientX, e.clientY, true);
  105. $(this).bind('mousemove', function(e){
  106. console.log('mousemove');
  107. updateNavPos(e.clientX, e.clientY, false);
  108. });
  109. // activate dragging if already activated
  110. if(!_dragging){
  111. _dragging = true;
  112. startMoveNav();
  113. }
  114. })
  115. .bind('mouseup', function(e){
  116. console.log('mouseup');
  117. stopMoveNav();
  118. $(this).unbind('mousemove');
  119. // close all preview
  120. if(Math.abs(e.clientX - _mouse_down_pos.x) < 2
  121. && Math.abs(e.clientY - _mouse_down_pos.y) < 2)
  122. for (var i = _chapitres_len - 1; i >= 0; i--)
  123. _chapters[i].closePreview().unMitigate();
  124. })
  125. /*
  126. _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____
  127. |_ _| | | | | | | | __| | | __| | |_ _| __|
  128. | | | | | | | --| | | __| | | __| | | | | | |__ |
  129. |_| |_____|_____|_____|__|__| |_____|\___/|_____|_|___| |_| |_____|
  130. */
  131. .bind('touchstart', function(e){
  132. console.log('touchstart');
  133. clearTimeout(_timeout_dragging);
  134. // set initial pos
  135. updateNavPos(e.originalEvent.touches[0].clientX, e.originalEvent.touches[0].clientY, true);
  136. // activate dragging if already activated
  137. if(!_dragging){
  138. _dragging = true;
  139. startMoveNav();
  140. }
  141. })
  142. .bind('touchmove', function(e){
  143. console.log('touchmove');
  144. updateNavPos(e.originalEvent.touches[0].clientX, e.originalEvent.touches[0].clientY, false);
  145. })
  146. .bind('touchend', function(e){
  147. console.log("touchend");
  148. stopMoveNav();
  149. });
  150. };
  151. function updateNavPos(x,y,init){
  152. if(!init){
  153. _nav_pos.x += x - _prev_mouse_pos.x;
  154. _nav_pos.y += y - _prev_mouse_pos.y;
  155. // constrain nav pos on container
  156. _nav_pos.x = _nav_pos.x < -_center.x*2
  157. ? -_center.x*2
  158. : _nav_pos.x > _center.x*2
  159. ? _center.x*2
  160. : _nav_pos.x;
  161. _nav_pos.y = _nav_pos.y < -_center.y*2
  162. ? -_center.y*2
  163. : _nav_pos.y > _center.y*2
  164. ? _center.y*2
  165. : _nav_pos.y;
  166. }
  167. _prev_mouse_pos.x = x;
  168. _prev_mouse_pos.y = y;
  169. // debuging cursor
  170. if(_debug)
  171. moveDebugCursor();
  172. };
  173. function startMoveNav(){
  174. window.requestAnimationFrame(moveNav);
  175. };
  176. function moveNav(){
  177. // console.log("moveNav");
  178. if(!_dragging) return;
  179. window.requestAnimationFrame(moveNav);
  180. // move chapters
  181. for (var i = _chapitres_len - 1; i >= 0; i--)
  182. _chapters[i].move();
  183. // move header
  184. _$header.css({
  185. transform:"translate3d("+(_nav_pos.x)*0.2+"px, "+(_nav_pos.y)*0.2+"px,0)"
  186. });
  187. // bubbles and stars dont move so smoothly on tablette ...
  188. // should keep it only on desktop
  189. // move bubbles
  190. // for (var i = _bubbles.length - 1; i >= 0; i--) {
  191. // _bubbles[i].css({
  192. // transform:"translate3d("+(_nav_pos.x)*0.4+"px, "+(_nav_pos.y)*0.4+"px,0)"
  193. // });
  194. // };
  195. // move stars
  196. // for (var i = _stars.length - 1; i >= 0; i--) {
  197. // _stars[i].css({
  198. // transform:"translate3d("+(_nav_pos.x)*-0.3+"px, "+(_nav_pos.y)*-0.3+"px,0)"
  199. // });
  200. // };
  201. };
  202. function stopMoveNav(){
  203. console.log('stopMoveNav');
  204. clearTimeout(_timeout_dragging);
  205. _timeout_dragging = setTimeout(function(){
  206. console.log("dragging stoped");
  207. _dragging = false;
  208. },3000);
  209. };
  210. function moveToChapter(chapter){
  211. // fake a mousdown by providing first pos as current pos
  212. _prev_mouse_pos.x = _nav_pos.x;
  213. _prev_mouse_pos.y = _nav_pos.y;
  214. // calculate the second pos of faked mousemove
  215. var xl = _center.x - chapter.pos.x - chapter.geom.w/2;
  216. var yl = 100 - chapter.pos.y;
  217. updateNavPos(xl, yl, false);
  218. startMoveNav();
  219. stopMoveNav();
  220. };
  221. /*
  222. ________ __
  223. / ____/ /_ ____ _____ / /____ _____
  224. / / / __ \/ __ `/ __ \/ __/ _ \/ ___/
  225. / /___/ / / / /_/ / /_/ / /_/ __/ /
  226. \____/_/ /_/\__,_/ .___/\__/\___/_/
  227. /_/
  228. */
  229. function Chapter(i, e, base_a){
  230. // $e.obj = this;
  231. this.i = i;
  232. this.e = e;
  233. this.$e = $(e);
  234. this.nid = this.$e.attr("id").match(/^node-(\d+)/)[1];
  235. this.geom = {
  236. base_a:base_a,
  237. a:0,
  238. r:0,
  239. w:this.$e.outerWidth(true),
  240. h:this.$e.outerHeight(true)
  241. }
  242. this.pos = {x:0,y:0};
  243. this.trans = {x:0, y:0,z:0};
  244. this.ease = randB(0.05, 0.3);
  245. //preview
  246. this.is_previewed = false;
  247. //mitigate
  248. this.is_mitigated = false;
  249. //parties
  250. this.$parties = $('.field-name-field-partie', e);
  251. this.parts_pos = {xs:new Array(), ys:new Array()};
  252. this.lines = new Array();
  253. this.linesAnimeStartTime = 0,
  254. this.linesAnimeDuration = 2000; // milli sec
  255. // prototypes
  256. if (typeof Chapter.initialized == "undefined") {
  257. Chapter.prototype.init = function(){
  258. this.setInitPos();
  259. this.drawLines();
  260. this.setEvents();
  261. };
  262. Chapter.prototype.setInitPos = function(){
  263. // distribute elements arround the center
  264. this.geom.a = (360/_chapitres_len*this.i+this.geom.base_a)*Math.PI/180;
  265. // console.log("Chapter :: setInitPos", this.$e);
  266. this.geom.c = Math.cos(this.geom.a);
  267. this.geom.s = Math.sin(this.geom.a);
  268. this.geom.abs_c = Math.abs(this.geom.c);
  269. this.geom.abs_s = Math.abs(this.geom.s);
  270. if (this.geom.abs_c * _container.h > this.geom.abs_s * _container.w) {
  271. // It crosses left or right side
  272. this.geom.r = (_center.x / this.geom.abs_c)*0.5;
  273. }else {
  274. // Top or bottom side
  275. this.geom.r = (_center.y / this.geom.abs_s)*0.5;
  276. }
  277. // change randomly radius
  278. if(this.i%2){
  279. this.geom.r = randB(this.geom.r*2, this.geom.r*3);
  280. }else{
  281. this.geom.r = randB(this.geom.r, this.geom.r*2);
  282. }
  283. this.pos.x = Math.round(_center.x+this.geom.r * this.geom.c) - this.geom.w/2;
  284. this.pos.y = Math.round(_center.y+this.geom.r * -this.geom.s) - this.geom.h/2;
  285. console.log('this', this);
  286. this.$e.css({
  287. left:this.pos.x,
  288. top:this.pos.y
  289. });
  290. };// setIniPos()
  291. Chapter.prototype.setEvents = function(){
  292. //http://technify.me/user-experience/javascript/jquery/trigger-custom-events-with-jquery/
  293. // click to preview chapter
  294. $('h2.node-title, .field-name-field-partie:first>.field-name-field-vignette', this.$e)
  295. .on('click', this, function(e){
  296. // e.stopImmediatePropagation();
  297. e.stopPropagation();
  298. e.preventDefault();
  299. e.data.preview(e);
  300. return false;
  301. });
  302. $('.links a', this.$e)
  303. .on('click', this, function(e){
  304. e.stopPropagation();
  305. e.preventDefault();
  306. e.data.loadNode();
  307. return false;
  308. });
  309. };
  310. Chapter.prototype.move = function(){
  311. this.trans.x += (_nav_pos.x - this.trans.x)*this.ease;
  312. this.trans.y += (_nav_pos.y - this.trans.y)*this.ease;
  313. // this.trans.z = Math.floor(Math.sqrt(
  314. // Math.pow(
  315. // _center.x-(this.pos.x+this.trans.x)
  316. // ,2
  317. // )
  318. // +
  319. // Math.pow(
  320. // _center.y-(this.pos.y+this.trans.y)
  321. // ,2
  322. // )
  323. // ));
  324. if(this.i === 0)
  325. console.log(this.i+" this.trans.z", this.trans.z);
  326. this.$e.css({
  327. transform:'translate3d('+this.trans.x+'px,'+this.trans.y+'px,0)'
  328. // scale:this.trans.z
  329. });
  330. };
  331. Chapter.prototype.preview = function(){
  332. // don't relaunch preview more that one time
  333. if(this.is_previewed) return;
  334. console.log('preview', this.i);
  335. this.unMitigate();
  336. this.is_previewed = true;
  337. // close other chapters
  338. for (var i = _chapitres_len - 1; i >= 0; i--)
  339. if(i !== this.i)
  340. _chapters[i].closePreview().mitigate();
  341. this.displayPreview();
  342. moveToChapter(this);
  343. };
  344. Chapter.prototype.displayPreview = function(e){
  345. // define randomly position of parties
  346. this.resetPartsPos();
  347. // apply new position to parties
  348. var that = this;
  349. this.$parties.each(function(i, e) {
  350. setTimeout(
  351. (function(i, e, xs, ys){
  352. return function(){
  353. $(e)
  354. .css({
  355. transform:"translate3d("+xs[i]+"px,"+ys[i]+"px,0)",
  356. });
  357. }
  358. }(i, e, that.parts_pos.xs, that.parts_pos.ys)),
  359. 10);
  360. }); // each $parties
  361. this.$e.addClass('previewed');
  362. requestAnimationFrame(this.animeLines.bind(this));
  363. };
  364. Chapter.prototype.resetPartsPos = function(){
  365. this.parts_pos = {xs:new Array(), ys:new Array()};
  366. for (var i = 0; i < 3; i++) {
  367. switch(i){
  368. case 0:
  369. this.parts_pos.xs.push(randB(-30,30)); this.parts_pos.ys.push(randB(90,110)); break;
  370. case 1:
  371. this.parts_pos.xs.push(randB(180,280)); this.parts_pos.ys.push(randB(250,350)); break;
  372. case 2:
  373. this.parts_pos.xs.push(randB(-280,-180)); this.parts_pos.ys.push(randB(430,530)); break;
  374. }
  375. };
  376. this.parts_pos.xs = shuffleArray(this.parts_pos.xs);
  377. this.parts_pos.ys = shuffleArray(this.parts_pos.ys);
  378. };
  379. Chapter.prototype.closePreview = function(){
  380. if(!this.is_previewed) return this;
  381. this.$e.removeClass('previewed')
  382. .find('.field-name-field-partie')
  383. .css({transform:"none"});
  384. requestAnimationFrame(this.animeLines.bind(this));
  385. this.is_previewed = false;
  386. return this;
  387. };
  388. Chapter.prototype.mitigate = function(){
  389. if(this.is_mitigated) return this;
  390. this.$e.addClass('mitigated');
  391. return this;
  392. };
  393. Chapter.prototype.unMitigate = function(){
  394. if(this.is_mitigated) return this;
  395. this.$e.removeClass('mitigated');
  396. return this;
  397. };
  398. Chapter.prototype.drawLines = function(){
  399. for (var i = 0; i < 2; i++) {
  400. this.lines.push({
  401. $line:$("<div>").addClass('line', 'line-'+i).prependTo(this.$parties[i])
  402. });
  403. };
  404. };
  405. Chapter.prototype.animeLines = function(timestamp){
  406. // console.log("anime line "+this.nid);
  407. // get the time on first anime launch
  408. if(this.linesAnimeStartTime === 0)
  409. this.linesAnimeStartTime = timestamp;
  410. // limit the animation time
  411. if(timestamp - this.linesAnimeStartTime < this.linesAnimeDuration){
  412. requestAnimationFrame(this.animeLines.bind(this));
  413. }else{
  414. this.linesAnimeStartTime = 0;
  415. }
  416. // get the lines length
  417. var l, a, pos1, pos2;
  418. for (var i = 0; i < this.lines.length; i++) {
  419. pos1 = this.$parties.eq(i).position();
  420. pos2 = this.$parties.eq(i+1).position();
  421. l = Math.sqrt(
  422. Math.pow(
  423. pos2.left - pos1.left
  424. ,2
  425. )
  426. +
  427. Math.pow(
  428. pos2.top - pos1.top
  429. ,2
  430. )
  431. );
  432. // get the rotation
  433. a = 180 / 3.14 * Math.acos((pos2.top - pos1.top) / l);
  434. if(pos2.left > pos1.left)
  435. a *= -1;
  436. // console.log("a = "+a);
  437. this.lines[i].$line.css({
  438. 'height':l,
  439. transform:"rotate3d(0,0,1,"+a+"deg)"
  440. });
  441. };
  442. };
  443. Chapter.prototype.loadNode = function(e){
  444. // console.log("Chapter :: open : nid", this.nid);
  445. $.getJSON(
  446. '/jee/chapter/'+this.nid,
  447. {},
  448. this.displayNode
  449. );
  450. };
  451. Chapter.prototype.displayNode = function(json, textstatus){
  452. console.log('Chapter :: displayNode : json', json);
  453. };
  454. Node.initialized = true;
  455. }
  456. this.init();
  457. };//Chapter
  458. /*
  459. __ __________ ____ __________ _____
  460. / / / / ____/ / / __ \/ ____/ __ \/ ___/
  461. / /_/ / __/ / / / /_/ / __/ / /_/ /\__ \
  462. / __ / /___/ /___/ ____/ /___/ _, _/___/ /
  463. /_/ /_/_____/_____/_/ /_____/_/ |_|/____/
  464. */
  465. function randB(min, max){
  466. return Math.random() * (max - min) + min;
  467. };
  468. //+ Jonas Raoni Soares Silva
  469. //@ http://jsfromhell.com/array/shuffle [v1.0]
  470. function shuffleArray(o){ //v1.0
  471. for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
  472. return o;
  473. };
  474. if (!Date.now) {
  475. Date.now = function now() {
  476. return new Date().getTime();
  477. };
  478. }
  479. /*
  480. _ _ __
  481. (_)___ (_) /_
  482. / / __ \/ / __/
  483. / / / / / / /_
  484. /_/_/ /_/_/\__/
  485. */
  486. init();
  487. });
  488. /*
  489. ____ __________ __ ___________________ ___ _ ________ ______ ______________ _ __ __________ ___ __ _________
  490. / __ \/ ____/ __ \/ / / / ____/ ___/_ __/ / | / | / / _/ |/ / |/_ __/ _/ __ \/ | / / / ____/ __ \/ | / |/ / ____/
  491. / /_/ / __/ / / / / / / / __/ \__ \ / / / /| | / |/ // // /|_/ / /| | / / / // / / / |/ / / /_ / /_/ / /| | / /|_/ / __/
  492. / _, _/ /___/ /_/ / /_/ / /___ ___/ // / / ___ |/ /| // // / / / ___ |/ / _/ // /_/ / /| / / __/ / _, _/ ___ |/ / / / /___
  493. /_/ |_/_____/\___\_\____/_____//____//_/ /_/ |_/_/ |_/___/_/ /_/_/ |_/_/ /___/\____/_/ |_/ /_/ /_/ |_/_/ |_/_/ /_/_____/
  494. */
  495. (function() {
  496. var lastTime = 0;
  497. var vendors = ['ms', 'moz', 'webkit', 'o'];
  498. for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
  499. window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
  500. window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
  501. || window[vendors[x]+'CancelRequestAnimationFrame'];
  502. }
  503. if (!window.requestAnimationFrame)
  504. window.requestAnimationFrame = function(callback, element) {
  505. var currTime = new Date().getTime();
  506. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  507. var id = window.setTimeout(function() { callback(currTime + timeToCall); },
  508. timeToCall);
  509. lastTime = currTime + timeToCall;
  510. return id;
  511. };
  512. if (!window.cancelAnimationFrame)
  513. window.cancelAnimationFrame = function(id) {
  514. clearTimeout(id);
  515. };
  516. }());
  517. /* ____ ____
  518. / __/_ __/ / / __________________ ___ ____
  519. / /_/ / / / / / / ___/ ___/ ___/ _ \/ _ \/ __ \
  520. / __/ /_/ / / / (__ ) /__/ / / __/ __/ / / /
  521. /_/ \__,_/_/_/ /____/\___/_/ \___/\___/_/ /_/
  522. */
  523. // http://davidwalsh.name/fullscreen
  524. // http://www.sitepoint.com/html5-full-screen-api/
  525. // Find the right method, call on correct element
  526. function launchIntoFullscreen(element) {
  527. if(element.requestFullscreen) {
  528. element.requestFullscreen();
  529. } else if(element.mozRequestFullScreen) {
  530. element.mozRequestFullScreen();
  531. } else if(element.webkitRequestFullscreen) {
  532. element.webkitRequestFullscreen();
  533. } else if(element.msRequestFullscreen) {
  534. element.msRequestFullscreen();
  535. }
  536. }
  537. // remove navbar
  538. // $(document).ready(function() {
  539. // if (navigator.userAgent.match(/Android/i)) {
  540. // window.scrollTo(0,0); // reset in case prev not scrolled
  541. // var nPageH = $(document).height();
  542. // var nViewH = window.outerHeight;
  543. // if (nViewH > nPageH) {
  544. // nViewH -= 250;
  545. // $('BODY').css('height',nViewH + 'px');
  546. // }
  547. // window.scrollTo(0,1);
  548. // }
  549. // });
  550. // OR
  551. // function hideAddressBar(){
  552. // if(document.documentElement.scrollHeight<window.outerHeight/window.devicePixelRatio)
  553. // document.documentElement.style.height=(window.outerHeight/window.devicePixelRatio)+'px';
  554. // setTimeout(window.scrollTo(1,1),0);
  555. // }
  556. // window.addEventListener("load",function(){hideAddressBar();});
  557. // window.addEventListener("orientationchange",function(){hideAddressBar();});
  558. // OR
  559. // function hideAddressBar() {
  560. // if(!window.location.hash) {
  561. // if(document.height < window.outerHeight)
  562. // document.body.style.height = (window.outerHeight + 50) + 'px';
  563. // setTimeout( function(){
  564. // window.scrollTo(0, 1);
  565. // document.body.style.height = 'auto';
  566. // }, 50 );
  567. // }
  568. // }
  569. // window.addEventListener("load",function(){hideAddressBar();});
  570. // window.addEventListener("orientationchange",function(){hideAddressBar();});
  571. // Drupal.behaviors.init_theme = function (context) {
  572. // // Growl-style system messages
  573. // $('#messages-and-help > div.messages:not(.processed)')
  574. // .addClass('processed')
  575. // .each(function() {
  576. // // If a message meets these criteria, we don't autoclose
  577. // // - contains a link
  578. // // - is an error or warning
  579. // // - contains a lenghthy amount of text
  580. // if ($('a', this).size() || $(this).is('.error') || $(this).is('.warning') || $(this).text().length > 100) {
  581. // $(this).prepend("<span class='close'>X</span>");
  582. // $('span.close', this).click(function() {
  583. // $(this).parent().slideUp('fast');
  584. // });
  585. // }
  586. // else {
  587. // // This essentially adds a 3 second pause before hiding the message.
  588. // $(this).animate({opacity:1}, 5000, 'linear', function() {
  589. // $(this).slideUp('fast');
  590. // });
  591. // }
  592. // });
  593. // };