materio_flag.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. // @codekit-prepend "gui.js"
  2. // @koala-prepend "gui.js"
  3. (function($) {
  4. MaterioFlag = function(){
  5. var _isLoadingList = false ;
  6. /**
  7. * init()
  8. */
  9. function init(){
  10. //trace('MaterioFlag :: init MaterioFlag');
  11. buildBlocks();
  12. $(document)
  13. .bind('flagGlobalAfterLinkUpdate', onFlaging)
  14. .bind('resultscompleted resultschanged previewloaded', onResultsUpdated)
  15. .bind('init-scroller-pager', onInitScrollerPager)
  16. .bind('load-scroller-pager', onLoadScrollerPager)
  17. .bind('view-mode-changed', onViewModeChanged)
  18. .bind('history-state-change', onHistoryStateChange);
  19. // ajaxifyLinks();
  20. // trigger updated event for direct html loading
  21. if(isList()){
  22. setTimeout(function(){
  23. triggerContentChanged();
  24. }, 10);
  25. }
  26. };
  27. function onFlaging(event){
  28. //trace('MaterioFlag :: onFlaging', event);
  29. refreshBlocks();
  30. };
  31. function onResultsUpdated(event){
  32. //trace('MaterioFlag :: onResultsUpdated', event);
  33. ajaxifyLinks(event.container);
  34. };
  35. function buildBlocks(activename){
  36. //trace('MaterioFlag :: buildBlocks | activename', activename);
  37. if($('#block-materio-flag-materio-flag-mybookmarks').length){
  38. var type = 'bookmarks';
  39. var block = '#block-materio-flag-materio-flag-mybookmarks';
  40. }else if($('#block-materio-flag-materio-flag-mylists').length){
  41. var type = 'lists';
  42. var block = '#block-materio-flag-materio-flag-mylists';
  43. }
  44. switch(type){
  45. case 'bookmarks':
  46. var name = type;
  47. $('h2 .listname', block).attr('name', name).bind('click', onClickShowPreview);
  48. $('<i class="fi-x"></i>').appendTo($('h2', block)).attr('name', name).bind('click', onClickClosePreview);
  49. // $('<span class="preview"><i class="icon-eye-open"></i></span>').appendTo($('h2', block)).bind('click', onClickShowPreview);
  50. // if(!readCookie('materiobookmarkspreviewopened')){
  51. // showPreview('bookmarks', block);
  52. // }else{
  53. // }
  54. break;
  55. case 'lists':
  56. // nav block
  57. $('a.open-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav').each(function(index){
  58. //trace('nav block a.open-list this', this);
  59. $this = $(this)
  60. .bind('click', onClickOpenLink)
  61. .addClass('ajax-processed');
  62. var name = $this.attr('class').match(/flag_lists_[^_]+_[0-9]+/);
  63. // trace('MaterioFlag :: name', name);
  64. $('<span class="preview"><i class="fi-eye"></i></span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
  65. });
  66. $('a.edit-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav')
  67. .bind('click', onCLickEditList)
  68. .addClass('ajax-processed');
  69. $('a.flag-lists-create:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav')
  70. .bind('click', onClickCreatLink)
  71. .addClass('ajax-processed');
  72. // preview block
  73. $('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
  74. var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/);
  75. $('<i class="fi-x"></i>').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview);
  76. $('a.open-list', this).bind('click', onClickOpenLink);
  77. }).addClass('ajax-processed');
  78. break;
  79. }
  80. // trigger refresh block event for enabling lazyload images
  81. setTimeout(function(){
  82. $.event.trigger({
  83. type : 'my'+type+'-block-builded',
  84. block : block,
  85. name : name
  86. });
  87. },10);
  88. // trace('MaterioFlag :: activename', activename);
  89. if(activename == undefined)
  90. activename = readCookie('materiomyflaglistsopened');
  91. // trace('MaterioFlag :: activename', activename);
  92. if(activename)
  93. showPreview(activename, block);
  94. };
  95. function refreshBlocks(name){
  96. //trace('MaterioFlag :: refreshBlocks | name', name);
  97. if($('#block-materio-flag-materio-flag-mybookmarks').length){
  98. var type = 'bookmarks';
  99. }else if($('#block-materio-flag-materio-flag-mylists').length){
  100. var type = 'lists';
  101. }
  102. if(type != undefined){
  103. var id = '#block-materio-flag-materio-flag-my'+type;
  104. var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
  105. $.getJSON(url, function(json){
  106. // trace('MaterioFlag :: block refreshed '+type, json);
  107. $(id).replaceWith(json.block);
  108. $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);
  109. buildBlocks(name);
  110. $.event.trigger({
  111. type : 'my'+type+'-block-updated',
  112. listname : name
  113. });
  114. });
  115. }
  116. };
  117. function ajaxifyLinks(container){
  118. //trace('MaterioFlag :: ajaxifyLinks', container);
  119. container = ((container != null) ? container : 'body');
  120. // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
  121. if (typeof Drupal.flagLink != 'undefined')
  122. Drupal.flagLink(container);
  123. if(isList()){
  124. var fid = $('.materio-flags-list', '#content').attr('fid');
  125. $('li.unflag-action.fid-'+fid+' a:not(.ajax-processed), li.flag-bookmarks a.unflag-action:not(.ajax-processed)')
  126. .bind('click', onUnflagList)
  127. .addClass('ajax-processed');
  128. }
  129. $('a.flag-lists-create:not(.ajax-processed)', container)
  130. .bind('click', onClickCreatLink)
  131. .addClass('ajax-processed');
  132. };
  133. /**
  134. * show hide preview
  135. */
  136. function onClickShowPreview(event){
  137. //trace('MaterioFlag :: onClickShowPreview', event);
  138. showPreview($(this).attr('name'), $(this).parent('.block').attr('id'));
  139. };
  140. function showPreview(name, block){
  141. //trace('MaterioFlag :: showPreview', name);
  142. $('section.'+name, block).addClass('active')
  143. .siblings('section').removeClass('active');
  144. createCookie('materiomyflaglistsopened', name, 1);
  145. $.event.trigger('init-layout');
  146. };
  147. function onClickClosePreview(event){
  148. //trace('MaterioFlag :: onClickClosePreview', event);
  149. eraseCookie('materiomyflaglistsopened');
  150. if($(this).attr('name') == 'bookmarks'){
  151. $(this).parents('.block').find('section.bookmarks').removeClass('active');
  152. }else{
  153. $(this).parents('section.flag-list').removeClass('active');
  154. }
  155. $.event.trigger('init-layout');
  156. };
  157. /**
  158. * onClickOpenLink
  159. */
  160. function onClickOpenLink(event){
  161. event.preventDefault();
  162. var $link = $(event.currentTarget);
  163. var fid = $link.attr('href').match(/lists\/([0-9]+)$/);
  164. // trace('MaterioFlag :: type', type);
  165. loadList(fid[1]);
  166. return false;
  167. };
  168. function loadList(fid){
  169. //trace('MaterioFlag :: loadList | fid', fid);
  170. var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid;
  171. $.event.trigger('loading-content');
  172. $.getJSON(url, {'current_path':document.location.href},function(json){
  173. //trace('MaterioFlag :: json', json);
  174. if(json.redirect){
  175. window.location = json.redirect;
  176. }else{
  177. changeContent(json);
  178. }
  179. });
  180. };
  181. function changeContent(json){
  182. if(json.rendered){
  183. $('.inner-content','#content').html(json.rendered);
  184. $.event.trigger('loaded-content');
  185. // no need of ajaxifylinks because it's triggered with resultschanged
  186. // ajaxifyLinks('#content');
  187. var path = Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path;
  188. $.event.trigger({
  189. type : 'new-history-page',
  190. path : path,
  191. title : json.title,
  192. content : json.rendered
  193. });
  194. // TODO: change language links for folders
  195. // for (language in Drupal.settings.materio_search_api_ajax.languages) {
  196. // var l = Drupal.settings.materio_search_api_ajax.languages[language];
  197. // $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys)
  198. // };
  199. triggerContentChanged();
  200. }else{
  201. //trace('MaterioFlag :: no results');
  202. }
  203. };
  204. function triggerContentChanged(){
  205. $.event.trigger({
  206. type: 'resultschanged',
  207. container : '#content .flaglist-items'
  208. });
  209. };
  210. /**
  211. * onClickCreatLink(event)
  212. */
  213. function onClickCreatLink(event){
  214. //trace('MaterioFlag :: onClickCreatLink | event', event);
  215. event.preventDefault();
  216. var $link = $(event.currentTarget);
  217. var type = $link.attr('href').match(/[^\/]*$/);
  218. // trace('MaterioFlag :: type', type);
  219. var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/createlist/form/'+type[0];
  220. $.getJSON(url, function(json){
  221. //trace('MaterioFlag :: creat list : json', json);
  222. showCreateListForm(json, $link);
  223. });
  224. return false;
  225. };
  226. function showCreateListForm(json, $link){
  227. //trace('MaterioFlag :: showCreateListForm | json', json);
  228. // google analytics
  229. $.event.trigger({
  230. type:"record-stat",
  231. categorie:"flagLists",
  232. action: 'show create form'
  233. });
  234. var $modal = $('<div id="modal" class="modal"/>').appendTo('body');
  235. $modal
  236. .css({
  237. position:'absolute',
  238. top:'40%', left:'50%',
  239. marginLeft:'-150px', width:'300px',
  240. zIndex:"99999"
  241. })
  242. .append(json.rendered_form)
  243. .find('input[type="submit"]', '#materio-flag-create-list-form').bind('click', function(event) {
  244. event.preventDefault();
  245. switch($(this).attr('name')){
  246. case 'cancel':
  247. //trace('MaterioFlag :: cancel',event);
  248. $(this).parents('#modal').remove();
  249. // google analytics
  250. $.event.trigger({
  251. type:"record-stat",
  252. categorie:"flagLists",
  253. action: 'cancel create form'
  254. });
  255. break;
  256. case 'create':
  257. //trace('MaterioFlag :: create',event);
  258. var title = $(this).parents('form').find('input[name*="flag-lists-name"]').val();
  259. var type = $(this).parents('form').find('input[name*="type"]').val();
  260. // google analytics
  261. $.event.trigger({
  262. type : "record-stat",
  263. categorie : "flagLists",
  264. action : "submit create form",
  265. label : 'title : '+title
  266. });
  267. createList($modal, type, title, $link);
  268. break;
  269. }
  270. return false;
  271. })
  272. .parents('form').find('input[type="text"]').focus();
  273. // TODO: esc keypressed close the form
  274. };
  275. function createList($modal, type, title, $link){
  276. //trace('materioflag :: createList | title', title);
  277. $('.flag-lists-create').addClass('loading');
  278. var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'flag-lists/add/'+type+'/js';
  279. $.getJSON(url, {name:title}, function(data) {
  280. if (data.error) {
  281. //trace(data.error);
  282. }
  283. else {
  284. // select.append('<option value="'+data.flag.fid+'">'+data.flag.title+'</option>');
  285. // $('input.name', $(this)).val('');
  286. // dialog.dialog('close');
  287. //trace('MaterioFlag :: created list : data', data);
  288. if($link.attr('nid') && $link.attr('token')){
  289. flagEntityWithList(data.flag.name, $link.attr('nid'), $link.attr('token'));
  290. }else{
  291. refreshBlocks(data.flag.name);
  292. refreshNodeLinks();
  293. }
  294. $modal.remove();
  295. }
  296. });
  297. };
  298. function flagEntityWithList(name, nid, token){
  299. //trace('MaterioFlag :: flagEntityWithList | name', name);
  300. // var ret;
  301. // Send POST request
  302. $.ajax({
  303. type: 'POST',
  304. url: Drupal.settings.basePath+Drupal.settings.pathPrefix+'flag-lists/flag/'+name+'/'+nid,
  305. data: { js: true, token: token },
  306. dataType: 'json',
  307. success: function (data2) {
  308. //trace('MaterioFlag :: node taged with newly created list : data2', data2)
  309. if (data2.status) {
  310. // google analytics
  311. $.event.trigger({
  312. type : "record-stat",
  313. categorie : 'FlagLists',
  314. action : 'node flaged',
  315. label : 'nid : '+nid+' | flag : '+name
  316. });
  317. refreshBlocks(name);
  318. refreshNodeLinks();
  319. }else {
  320. // Failure.
  321. alert(data2.errorMessage);
  322. }
  323. },
  324. error: function (xmlhttp) {
  325. alert('An HTTP error '+ xmlhttp.status +' occurred.\n'+ element.href);
  326. }
  327. });
  328. };
  329. function refreshNodeLinks(){
  330. //trace('MaterioFlag :: refreshNodeLinks');
  331. var nids = new Array();
  332. $('.flag-lists-entity-links')
  333. // .addClass('loading')
  334. .parents('.node')
  335. .each(function(index) {
  336. nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]);
  337. });
  338. // trace('MaterioFlag :: nids', nids);
  339. var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks';
  340. $.getJSON(url, {nids:nids.join(";")}, function(data) {
  341. // trace('MaterioFlag :: data', data);
  342. for(nid in data.links){
  343. // trace('MaterioFlag :: nid', nid);
  344. // trace('MaterioFlag :: data.links[nid]', data.links[nid]);
  345. $('.node-'+nid+' .flag-lists-entity-links').replaceWith(data.links[nid]);
  346. // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
  347. // if (typeof Drupal.flagLink != 'undefined')
  348. // Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links'));
  349. // TODO: sortir ajaxifyLinks de la boucle, je pense que ça prend trop de ressources
  350. ajaxifyLinks('.node-'+nid+' .flag-lists-entity-links');
  351. }
  352. });
  353. $.event.trigger({
  354. type : 'materioflag-nodelinks-updated',
  355. nids : nids
  356. });
  357. };
  358. /**
  359. * onCLickEditList(event)
  360. */
  361. function onCLickEditList(event){
  362. //trace('MaterioFlag :: onCLickEditList | event', event);
  363. // TODO: empécher le double formulaire
  364. event.preventDefault();
  365. var $link = $(event.currentTarget);
  366. var lid = $link.attr('href').match(/[^\/]*$/);
  367. var type = 'materiau'; // this is cheap
  368. var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
  369. $.getJSON(url, function(json){
  370. //trace('MaterioFlag :: editlist : json', json);
  371. showEditListForm(json, $link);
  372. });
  373. return false;
  374. };
  375. function showEditListForm(json, $link){
  376. //trace('MaterioFlag :: showEditListForm | json', json);
  377. // google analytics
  378. $.event.trigger({
  379. type:"record-stat",
  380. categorie:"flagLists",
  381. action: 'show edit form'
  382. });
  383. var $modal = $('<div id="modal" class="modal"/>').appendTo('body');
  384. $modal
  385. .css({
  386. position:'absolute',
  387. top:'40%', left:'50%',
  388. marginLeft:'-150px', width:'300px',
  389. zIndex:"99999"
  390. })
  391. .append(json.rendered_form)
  392. .find('input[type="submit"]', '#materio-flag-edit-list-form').bind('click', function(event) {
  393. event.preventDefault();
  394. var $form = $(this).parents('form');
  395. var title = $form.find('input[name*="flag-lists-title"]').val();
  396. var fid = $form.find('input[name*="fid"]').val();
  397. var name = $form.find('input[name*="name"]').val();
  398. switch($(this).attr('name')){
  399. case 'cancel':
  400. //trace('MaterioFlag :: cancel',event);
  401. $(this).parents('#modal').remove();
  402. // google analytics
  403. var action = 'cancel edit form';
  404. break;
  405. case 'save':
  406. //trace('MaterioFlag :: create',event);
  407. // google analytics
  408. var action = "submit edit form";
  409. saveList($modal, fid, name, title);
  410. break;
  411. case 'delete':
  412. //trace('MaterioFlag :: delete',event);
  413. if(confirm('Do you realy want to delete your '+title+' folder ?')){
  414. var action = "submit delete form";
  415. deleteList($modal, fid);
  416. }else{
  417. var action = "cancel delete form";
  418. }
  419. break;
  420. }
  421. // google analytics
  422. $.event.trigger({
  423. type:"record-stat",
  424. categorie:"flagLists",
  425. action: action
  426. });
  427. return false;
  428. })
  429. .parents('form').find('input[type="text"]').focus();
  430. // TODO: esc keypressed close the form
  431. };
  432. function saveList($modal, fid, name, title){
  433. //trace('MaterioFlag :: saveList | fid : '+fid+'| name', name);
  434. $('.flag-lists-link.fid-'+fid).addClass('loading');
  435. var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlist/'+fid+'/'+name+'/'+title;
  436. $.getJSON(url, function(data) {
  437. if (data.error) {
  438. // trace(data.error);
  439. if(data.message)
  440. alert(data.message);
  441. }
  442. else {
  443. //trace('MaterioFlag :: saved list : data', data);
  444. $.event.trigger({
  445. type : 'list-edited',
  446. name : data.listname,
  447. title : data.title,
  448. });
  449. refreshBlocks();
  450. refreshNodeLinks();
  451. $modal.remove();
  452. }
  453. });
  454. };
  455. function deleteList($modal, fid){
  456. //trace('MaterioFlag :: deletelist | fid', fid);
  457. $('.flag-lists-link.fid-'+fid).hide();
  458. var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/deletelist/'+fid;
  459. $.getJSON(url, function(data) {
  460. if (data.error) {
  461. // trace(data.error);
  462. if(data.message)
  463. alert(data.message);
  464. }
  465. else {
  466. //trace('MaterioFlag :: deleted list : data', data);
  467. refreshBlocks();
  468. refreshNodeLinks();
  469. // TODO: if the deleted list was the current displayed list ??
  470. $modal.remove();
  471. }
  472. });
  473. };
  474. /**
  475. * onUnflagList()
  476. */
  477. function onUnflagList(event){
  478. //trace('onUnflagList', event);
  479. $(this).parents('article.node').addClass('removed');
  480. };
  481. /**
  482. *
  483. */
  484. function onInitScrollerPager(event){
  485. // trace('MaterioFlag :: MaterioFlag :: onInitScrollerPager');
  486. if (isList()){
  487. // trace('MaterioFlag :: event.pager', event);
  488. event.pager.hide();
  489. }
  490. };
  491. function onLoadScrollerPager(event){
  492. if (isList())
  493. loadNextListPage(event.href);
  494. };
  495. function loadNextListPage(href){
  496. // trace('MaterioFlag :: loadNextListPage', href);
  497. if(!_isLoadingList){
  498. var fid = href.match(/lists\/([^\/|\?]+)/);
  499. var page = href.match(/\?page=([0-9]+)/);
  500. var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid[1]+'/'+page[1];
  501. // trace('MaterioFlag :: url', url);
  502. loadNextPage(url, $('.materio-flags-list', '#content'), '.flaglist-items');
  503. }
  504. };
  505. function loadNextPage(url, $container, target){
  506. //trace('MaterioFlag :: loadNextPage');
  507. _isLoadingList = true;
  508. $container.addClass('loading');
  509. $.getJSON(url, function(json){
  510. //trace('json', json);
  511. _isLoadingList = false;
  512. $container.removeClass('loading');
  513. addNextpage(json, target);
  514. });
  515. };
  516. function addNextpage(json, container_class){
  517. var $newcontent = $(json.rendered),
  518. $newitems = $(container_class, $newcontent).children('article').addClass('just-added'),
  519. $newpager = $('ul.pager', $newcontent);
  520. $(container_class, '#content').append($newitems);
  521. $('ul.pager', '#content').replaceWith($newpager.hide());
  522. // TODO: animation, this should be on theme side
  523. $(container_class, '#content').children('.just-added').each(function(i){
  524. // $(this).delay(5000*i).removeClass('just-added');
  525. var $this = $(this);
  526. setTimeout(function(){
  527. $this.removeClass('just-added');
  528. }, 150*i);
  529. });
  530. $.event.trigger({
  531. type : 'resultscompleted',
  532. container : $(container_class, '#content')
  533. });
  534. };
  535. function onViewModeChanged(event){
  536. if (isList())
  537. loadList(getFid());
  538. };
  539. /**
  540. * history
  541. */
  542. function onHistoryStateChange(event){
  543. if(isList())
  544. triggerContentChanged();
  545. };
  546. /**
  547. * Helpers
  548. */
  549. function getFid(){
  550. return $('.materio-flags-list', '#content').attr('fid');;
  551. };
  552. function isList(){
  553. return $('.materio-flags-list', '#content').length;
  554. };
  555. /**
  556. * cookies
  557. */
  558. function createCookie(name,value,days) {
  559. if (days) {
  560. var date = new Date();
  561. date.setTime(date.getTime()+(days*24*60*60*1000));
  562. var expires = "; expires="+date.toGMTString();
  563. }
  564. else var expires = "";
  565. document.cookie = name+"="+value+expires+"; path=/";
  566. }
  567. function readCookie(name) {
  568. var nameEQ = name + "=";
  569. var ca = document.cookie.split(';');
  570. for(var i=0;i < ca.length;i++) {
  571. var c = ca[i];
  572. while (c.charAt(0)==' ') c = c.substring(1,c.length);
  573. if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  574. }
  575. return null;
  576. }
  577. function eraseCookie(name) {
  578. createCookie(name,"",-1);
  579. }
  580. init();
  581. };
  582. $(document).ready(function() {
  583. var materioflag = new MaterioFlag();
  584. });
  585. })(jQuery);