canvas.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /* Contains all the Javascript logic of the canvas and its main features: save, export and share */
  2. $(function() {
  3. /*This piece of code is for making the column-count and column-gap CSS to work in Firefox*/
  4. document.getElementById("8-5-col-layout").style.MozColumnCount =
  5. "5";
  6. document.getElementById("4-col-layout").style.MozColumnCount =
  7. "4"; // end of Firefox fix
  8. /* Prevent pressing ENTER on Project Title from submitting the form */
  9. $('.proj_title').keydown(function(event){
  10. if(event.keyCode == 13) {
  11. event.preventDefault();
  12. return false;
  13. }
  14. });
  15. /*================================
  16. Serialize Form to JSON
  17. ================================*/
  18. $.fn.serializeObject = function() {
  19. var o = {};
  20. var a = this.serializeArray();
  21. $.each(a, function() {
  22. if (o[this.name]) {
  23. if (!o[this.name].push) {
  24. o[this.name] = [o[this.name]];
  25. }
  26. o[this.name].push(this.value || '');
  27. } else {
  28. o[this.name] = this.value || '';
  29. }
  30. });
  31. return o;
  32. }; // end of $.fn.serializeObject ...
  33. /*=====================================
  34. Getting the current date
  35. =====================================*/
  36. var fullDate = new Date();
  37. var twoDigitMonth = fullDate.getMonth() + "";
  38. if (twoDigitMonth.length == 1) twoDigitMonth = "0" + twoDigitMonth;
  39. var twoDigitDate = fullDate.getDate() + "";
  40. if (twoDigitDate.length == 1) twoDigitDate = "0" + twoDigitDate;
  41. var currentDate = fullDate.getFullYear() + "-" + twoDigitMonth + "-" +
  42. twoDigitDate;
  43. // set the currebt date in the date input field
  44. $('.proj_date').val(currentDate);
  45. /*========================================
  46. USER LOGS OUT (dropdown menu)
  47. ==========================================*/
  48. $('.user-profile').on('click', '#logout', function() {
  49. var url = 'php/logout.php';
  50. $.post(url, function(data, status) {
  51. if (data == 200) {
  52. $('.user-profile').hide();
  53. window.location.href="https://www.ethicscanvas.org";
  54. }
  55. });
  56. });
  57. /*========================================
  58. When the page loads, Import the chosen canvas if the user has picked one from the dashbord,
  59. otherwise load an empty canvas
  60. ==========================================*/
  61. // if a canvas is chosen by the user to be loaded
  62. if (current_canvas_id !== '') {
  63. var url = 'json/' + current_canvas_id + '.json';
  64. // var url= 'json/test_canvas.json';
  65. // get the saved ISON object in the sendJSON.text file
  66. $.getJSON(url, function(returnedObj) {
  67. //Display the json data in the html
  68. var itemListHTML = '';
  69. //iterate through the object
  70. $.each(returnedObj, function(key, value) {
  71. /* project name and tem field*/
  72. if (key === 'field_00[]') {
  73. $('.form-header').find('input.proj_title').val(value[
  74. 0]);
  75. $('.form-header').find('input.proj_date').val(value[1]);
  76. } // end of if(key === 'field_00[]')
  77. else if (key !== 'new_item') {
  78. if ($.type(value) === "array") {
  79. $.each(value, function(i, itm) {
  80. /** FIX DUPLICATIONs in the canvas when importing
  81. /* Importing will override the canvas content
  82. clear the canvas by giving en emty content to the ul list (remove previous list items) */
  83. $('.canvas-form').find('.card').filter('.' +
  84. key.substr(0, 8)).find('ul.item_list').html(
  85. '');
  86. /* Create a list item with each value item
  87. and give it text area with the name attribute as the "key" (right field name) */
  88. itemListHTML +=
  89. '<li class="added_item"><span class="handle glyphicon glyphicon-th"></span><textarea maxlength="100" class="expandable" rows="3" data-limit-rows="true" data-autoresize name="' +
  90. key + '">' + itm +
  91. '</textarea><span class="remove glyphicon glyphicon-remove-circle"></span></li>';
  92. }); //end of $.each(value ...
  93. } // end of if($.type(value)==="array")
  94. else { // a single value string
  95. itemListHTML +=
  96. '<li class="added_item"><span class="handle glyphicon glyphicon-th"></span><textarea maxlength="100" class="expandable" rows="3" data-limit-rows="true" data-autoresize name="' +
  97. key + '">' + value +
  98. '</textarea><span class="remove glyphicon glyphicon-remove-circle"></span></li>';
  99. }
  100. /* Append the created list items/textatreas to the right field based on the "key"*/
  101. /* the str.substr(start,length)
  102. is used to remove the [] from the end of the "key"name (for each field. also the name attributes accociated with each fiels) so that we can select the right class (right field) and append the created lists to the right field
  103. so field names/key/name attribute will tuen into class names: ex: field_1[] becomes field_1
  104. */
  105. // find the field by its class names besed on the current key name
  106. // append the created list of item values to that right field
  107. $('.canvas-form').find('.card').filter('.' + key.substr(
  108. 0, 8)).find('ul.item_list').append(itemListHTML);
  109. /*$('form').find('.card').filter('.field_1').find('ul.item_list').append(itemListHTML); */
  110. /* !! Empty the item list after each count of "key" so that the previous item lists from the other fields (associated with the previous key) don't get added up to the item list of other fields */
  111. itemListHTML = '';
  112. } //end of if(key !== ...
  113. }); //end of $.each(returnedObj...
  114. }); // end of $.getJSON
  115. /*--- fix the heights after importing ---*/
  116. fixHeights();
  117. /*--------------------------------*/
  118. }
  119. /*=======================================
  120. Toggle the introduction text in fields
  121. =======================================*/
  122. //$(selector).toggle(speed,easing,callback)
  123. $('.card').on('click', '.intro-toggle', function() {
  124. var $TogglingText = $($(this).closest('.card').find('.intro'));
  125. var $Toggler = $($(this).closest('.card').find('.intro-toggle'));
  126. $TogglingText.toggle('slow', function() {
  127. /*Do this when toggling: */
  128. // the boolean .is(':visible') of the current toggle state
  129. if ($TogglingText.is(':visible')) {
  130. // change the text of the toggle
  131. $Toggler.find('.intro-toggle-text').text('Hide description');
  132. // change the icon of the toggle
  133. $Toggler.find('.intro-toggle-icon').switchClass(
  134. "glyphicon-plus-sign", "glyphicon-minus-sign", 1000,
  135. "easeInOutQuad");
  136. } else {
  137. $Toggler.find('.intro-toggle-text').text('Show description');
  138. $Toggler.find('.intro-toggle-icon').switchClass(
  139. "glyphicon-minus-sign", "glyphicon-plus-sign", 1000,
  140. "easeInOutQuad");
  141. }
  142. }); //end of toggle
  143. }); //end of click
  144. /*================================
  145. Auto expand user input textareas
  146. ================================*/
  147. /*Works for textareas already exsting in the html when the page loads -> User input*/
  148. $.each(jQuery('textarea[data-autoresize]'), function() {
  149. var offset = this.offsetHeight - this.clientHeight;
  150. var resizeTextarea = function(el) {
  151. $(el).css('height', 'auto').css('height', el.scrollHeight +
  152. offset);
  153. };
  154. $(this).on('keyup input', function() {
  155. resizeTextarea(this);
  156. }).removeAttr('data-autoresize');
  157. });
  158. /*===========================================
  159. Limiting the number of lines in textareas
  160. ===========================================*/
  161. // <textarea data-limit-rows="true" cols="60" rows="8"></textarea>
  162. $('.card').on('keypress', 'textarea[data-limit-rows=true]', function(
  163. event) {
  164. var textarea = $(this),
  165. text = textarea.val(),
  166. /* match() -> Searches a string for a match against a regular expression, and returns the matches, as an Array object.*/
  167. numberOfLines = (text.match(/\n/g) || []).length + 1,
  168. maxRows = parseInt(textarea.attr('rows'));
  169. // if the number of lines have reached the max rows
  170. if (numberOfLines === maxRows) {
  171. return false;
  172. }
  173. });
  174. /*================================
  175. Handling user input, ADD items
  176. A. Add button
  177. B. Clicking enter
  178. ================================*/
  179. /*------------------------------
  180. add new idea slide effect
  181. ------------------------------*/
  182. /* When clicking on "add a new idea", Slide down and show the input field for adding a new item (from the begining,it is set to display:hidden with CSS).If clicked again, slide it up. After that, set the textarea in automatic focus*/
  183. $('.card').on('click', 'a.add-idea', function(event) {
  184. // stop the default behavior of the link (jumping back to the start of the page)
  185. event.preventDefault();
  186. //set the textarea automatically in focus
  187. $(this).closest('.card').find('.user-input').slideToggle("slow",
  188. function() {
  189. //When the toggle animation is complete:
  190. // set the text area in focus
  191. $(this).closest('.card').find('.new_item').val('');
  192. $(this).closest('.card').find('.chars').text(maxLength);
  193. $(this).closest('.card').find('.new_item').focus();
  194. });
  195. });
  196. /*----------------------------------------
  197. Limiting the number of characters to type
  198. ------------------------------------------*/
  199. var maxLength = 100;
  200. $('.card').on('keyup', '.new_item', function() {
  201. var length = $(this).val().length;
  202. length = maxLength - length;
  203. //show the characters remaining only on this field
  204. $(this).closest('.user-input').find('.chars').text(length);
  205. });
  206. /*-------------------------------
  207. A. When we click the add btn to
  208. add the item to the list
  209. ---------------------------------- */
  210. //event deligation to handle the present and future elements that are dynamically added
  211. $('.card').on('click', '.add_btn', function() {
  212. var new_item = $(this).closest('.card').find('.new_item').val();
  213. var new_item_height = $(this).closest('.card').find('.new_item').height();
  214. //number of items are in the list
  215. var fieldItemCount = $(this).closest('.card').find('ul.item_list').find(
  216. 'li').length;
  217. // new item added, increment the number of items
  218. fieldItemCount++;
  219. //add the input value as a textarea item
  220. /* create a name attribute in the "field_nr[]" format to be able to tag each new item with the right field attr name (based on the field they are added to). This is to format the json file for each group of dynamically added items. We get the name attribute directly from the id attribute of the ul list in each card (the one we pressed the add button in) */
  221. // if the new item input exist (is not empty), add the item
  222. if (new_item) {
  223. var field_attr = $(this).closest('.card').find('ul.item_list').attr(
  224. 'id') + '[]';
  225. /*The height of the newly added item = the height of the add new idea textarea*/
  226. $(this).closest('.card').find('ul.item_list').append(
  227. '<li class="added_item"><span class="handle glyphicon glyphicon-th"></span><textarea maxlength="100" class="expandable" rows="3" data-limit-rows="true" data-autoresize name="' +
  228. field_attr + '">' +
  229. new_item +
  230. '</textarea><span class="remove glyphicon glyphicon-remove-circle"></span></li>'
  231. );
  232. // Fix the heights only after a new item is added
  233. // fixHeights();
  234. } // end of if(new_item){
  235. //clear the new item the text area value
  236. $(this).closest('.card').find('.new_item').val('');
  237. /* When clicking on "add idea", hide the input field for adding a new item (slideUp() doesn't work nicely here)*/
  238. $(this).closest('.card').find('.user-input').hide("fast", function() {
  239. // Animation complete.
  240. });
  241. });
  242. /*----------------------------------------
  243. B. Clicking enter in the add idea textarea,
  244. will add the new item to the card
  245. -------------------------------------------*/
  246. //<textarea data-limit-rows="true" ></textarea>
  247. $('.card').on('keypress', 'textarea[data-limit-rows=true]', function(
  248. event) {
  249. var textarea = $(this);
  250. var text = textarea.val();
  251. /* The jQuery event.which -->
  252. Returns which keyboard key was pressed: */
  253. // if the enter is pressed, event.which === 13
  254. if (event.which === 13) {
  255. var new_item = $(this).closest('.card').find('.new_item').val();
  256. var new_item_height = $(this).closest('.card').find('.new_item').height();
  257. //number of items are in the list
  258. var fieldItemCount = $(this).closest('.card').find('ul.item_list')
  259. .find(
  260. 'li').length;
  261. // new item added, increment the number of items
  262. fieldItemCount++;
  263. //add the input value as a textarea item
  264. /* create a name attribute in the "field_nr[]" format to be able to tag each new item with the right field attr name (based on the field they are added to). This is to format the json file for each group of dynamically added items. We get the name attribute directly from the id attribute of the ul list in each card (the one we pressed the add button in) */
  265. // if the new item input exist (is not empty), add the item
  266. if (new_item) {
  267. var field_attr = $(this).closest('.card').find('ul.item_list').attr(
  268. 'id') + '[]';
  269. /*The height of the newly added item = the height of the add new idea textarea*/
  270. $(this).closest('.card').find('ul.item_list').append(
  271. '<li class="added_item"><span class="handle glyphicon glyphicon-th"></span><textarea maxlength="100" class="expandable" rows="3" data-limit-rows="true" data-autoresize name="' + field_attr + '">' + new_item + '</textarea><span class="remove glyphicon glyphicon-remove-circle"></span></li>');
  272. // Fix the heights only after a new item is added
  273. // fixHeights();
  274. } // end of if(new_item){
  275. //clear the new item the text area value
  276. $(this).closest('.card').find('.new_item').val('');
  277. /* When clicking on "add idea", hide the input field for adding a new item (slideUp() doesn't work nicely here)*/
  278. $(this).closest('.card').find('.user-input').hide("fast",
  279. function() {
  280. // Animation complete.
  281. });
  282. }
  283. });
  284. /*================================
  285. Deleting items
  286. ================================*/
  287. // when the cross beside the textarea is clicked (span.remove)
  288. // remove that list item
  289. $('.card').on('click', 'span.remove', function() {
  290. $(this).closest('li').remove();
  291. });
  292. /*================================
  293. Sortable field items
  294. ================================*/
  295. //make items sortable in their fields and between fields
  296. $('.sortable').sortable({
  297. connectWith: '.connectedList',
  298. placeholder: "sort-placeholder",
  299. // revert: true
  300. zIndex: 300 //or greater than any other relative/absolute/fixed elements and droppables
  301. });
  302. /*================================
  303. Sorting and Dragging events
  304. ================================*/
  305. /*sortstart
  306. sortover
  307. sortstop*/
  308. /**
  309. every textarea in a item needs to get the right name attribute once they have been dropped in another field (so it ends up in the right place in the json file)
  310. **/
  311. /*Dragging starts*/
  312. $(".sortable").on("sortstart", function(event, ui) {
  313. // WHEN WE SORT CARDS, $(this) ---> the "begining" ul with the class of .sortable
  314. });
  315. /*Dragging ends: item dropped*/
  316. $(".sortable").on("sortstop", function(event, ui) {
  317. // get the id of the field ul (to set the name attribute of textareas)
  318. // # mouseleave is the right event for when we release and leave a card mouseup doesn't work properly in this case
  319. $('.card').on('mouseleave', 'li', function() {
  320. //$(selector).attr(attribute,value)
  321. var fieldAttr = $(this).closest('ul.item_list').attr('id');
  322. $(this).find('textarea').attr('name', fieldAttr + '[]');
  323. });
  324. }); // end of $(".sortable").on("sortstop"...
  325. /* ===============================================
  326. SAVING THE CANVAS:
  327. CLICK ON #EXPORT JSON# form button
  328. ================================================*/
  329. /*---------------------------------------------------
  330. When the user clicks on the SAVE CANVAS button
  331. ---------------------------------------------------*/
  332. $('.canvas-form').on('click', '.json_exp', function() {
  333. /* ---------------------------------------------
  334. A: saving the canvas
  335. as a registered user
  336. ----------------------------------------------*/
  337. // php variables are retieved in the header of the canvas index.php as js variables -->
  338. var name_save_canvas = $('.form-header').find('.proj_title').val();
  339. var date_save_canvas = $('.form-header').find('.proj_date').val();
  340. var save_canvas_obj = {
  341. 'email_save_canvas': email_save_canvas,
  342. 'name_save_canvas': name_save_canvas,
  343. 'date_save_canvas': date_save_canvas
  344. };
  345. var save_canvas = $.param(save_canvas_obj);
  346. /* Post the JSON stringified object to the php file
  347. (the php script will save it in a .json file )*/
  348. var save_reg_url = "php/save-canvas.php";
  349. $.post(save_reg_url, {
  350. save_canvas: save_canvas
  351. }, function(data, status) {
  352. //the returned data is successful, is the $canvas_id
  353. var canvas_id = data;
  354. // send this canvas_id with the next ajax requestedto the php/canvas.php file and use it as the name of the json file to be saved
  355. // Give the user feedback that the canvas is saved
  356. if (data !== 400 || data !== 401) {
  357. if ($('.imp-exp-btn ').find(".save-canvas-feedback") !== null) {
  358. $('.imp-exp-btn ').find(".save-canvas-feedback").remove();
  359. }
  360. $('.canvas-form').find('.imp-exp-btn ').append('<div class="save-canvas-feedback"><p><span class="glyphicon glyphicon-ok" aria-hidden="true"></span>Your canvas is saved in your dashbord</p></div>');
  361. // remove the canvas is saves message as soon as user changes the canvas
  362. $('.canvas-form').on("change keyup", 'textarea', function() {
  363. $('.imp-exp-btn ').find(".save-canvas-feedback").remove();
  364. });
  365. } else {
  366. $('.canvas-form').find('.imp-exp-btn ').append('<div class="save-canvas-feedback-fail"><p>Oh! We could not save your canvas. Please try again or contact us at hello@ethicscanvas.org</p></div>');
  367. }
  368. //For the second AJAX request:
  369. /*#########################################################*/
  370. /*----------------------------------------
  371. B: Exporing the form data json to a file
  372. and save it on the server
  373. ----------------------------------------*/
  374. // $('#result').text(JSON.stringify($('.canvas-form').serializeObject()));
  375. //Make the JSON object into a JSON string
  376. var JSONstrObj = JSON.stringify($('.canvas-form').serializeObject());
  377. var url = "php/canvas.php";
  378. /* Post the JSON stringified object to the php file
  379. (the php script will save it in a .json file )*/
  380. //also, send the canvas_id and use it for naming the file
  381. $.post(url, {
  382. JSONstrObj: JSONstrObj,
  383. canvas_id: canvas_id
  384. }, function(data, status) {
  385. console.log(
  386. 'Response from php when sending the form json object: \n' +
  387. 'data:' + data + '\n status: ' + status);
  388. }).fail(function(jqXHR) {
  389. console.log("Error " + jqXHR.status + ' ' + jqXHR.statustext);
  390. });
  391. /*########################################################*/
  392. }).fail(function(jqXHR) {
  393. console.log("Error " + jqXHR.status + ' ' + jqXHR.statustext);
  394. });
  395. /*Prevent the card item list from reseting itself after clicking
  396. on the export button (submission). Because the type of the button is submit */
  397. return false;
  398. }); // end of handling the click on EXPORT button
  399. /*===========================================
  400. HANDLING CLICK ON : Share This Canvas BUTTON
  401. ===========================================*/
  402. $('.canvas-form').on('click', '.share_canvas', function() {
  403. $('.share_canvas_email').slideDown(1000, function() {
  404. // SAVE THE PDF AS file
  405. $.post('mpdf/canvas-pdf-save.php', function(data, status) {
  406. }); // save pdf as file
  407. }); // end of slide down animation
  408. }); // end of click on share_canvas button
  409. $('.canvas-form').on('click', '.share_canvas_send', function() {
  410. var share_email = $('.share_canvas_email').find('input').serialize();
  411. /*This sends a serialized array share_email to the php file.
  412. exapmple: the value of this array will be: share-canvas-email=eternalflame.f%40gmail.com
  413. */
  414. $.post('php/share-canvas.php', {
  415. share_email: share_email
  416. }, function(data, status) {
  417. if (data == 200) { // canvas successfully shared
  418. $('.canvas-form').find('.imp-exp-btn ').append('<div class="save-canvas-feedback"><p><span class="glyphicon glyphicon-ok" aria-hidden="true"></span>Your canvas has been shared by email</p></div>')
  419. }
  420. else {
  421. $('.canvas-form').find('.imp-exp-btn ').append('<div class="save-canvas-feedback"><p><span class="glyphicon glyphicon-ok" aria-hidden="true"></span>Your canvas could not be shared by email</p></div>')
  422. }
  423. }); // end of post email
  424. // slide up the .share_canvas_email area
  425. $('.share_canvas_email').slideUp(); // end of slide up animation
  426. }); // end of click on "send"
  427. /*===========================================
  428. Controlling the height of divs dynamically
  429. ===========================================*/
  430. //Call this function after adding a new item and importing
  431. // $( window ).width(); ->Returns width of browser viewport
  432. function fixHeights() {
  433. // --------------------------------------------------
  434. // Returns width of browser viewport
  435. var screenSize = $(window).width();
  436. //the longest card of the group 1 .masonry-layout8-5
  437. var longest_1 = $('.masonry-layout8-5').height();
  438. //the longest card of the group 2 .masonry-layout8-5
  439. var longest_2 = $('.masonry-layout4').height();
  440. /* --- 5 COL Range ---- */
  441. if (screenSize >= 1139) {
  442. // inforcing a fixed height ".height(longest_1/2)" will create some layout issues when we try to add new items the add item area will go outside the box and the heights don't increase naturally
  443. // card group1:
  444. // $('.field_05,.field_11, .field_07').css('min-height', longest_1 -
  445. // longest_1 * 5 / 100);
  446. // $('.field_06,.field_08, .field_12').css('min-height', longest_1 +
  447. // longest_1 * 5 / 100);
  448. // $('.field_01, .field_02').css('min-height', longest_1 * 2 +
  449. // longest_1 * 1 / 100);
  450. // // card group 2
  451. // $('.field_03, .field_09, .field_10, .field_04').css('min-height',
  452. // longest_2 * 2 - longest_2 * 20 / 100);
  453. $('.field_05,.field_11, .field_07').css('min-height', longest_1 -
  454. longest_1 * 20 / 100);
  455. $('.field_06,.field_08, .field_12').css('min-height', longest_1 -
  456. longest_1 * 20 / 100);
  457. $('.field_01, .field_02').css('min-height', longest_1 + longest_1 * 40 / 100);
  458. // card group 2
  459. $('.field_03, .field_09, .field_10, .field_04').css('min-height',
  460. longest_2 - longest_2 * 10 / 100);
  461. }
  462. /* 4 COL Range */
  463. else if (screenSize >= 977 && screenSize <= 1138) {
  464. // card group1:
  465. // row 1
  466. $('.field_01,.field_06, .field_12,.field_08 ').css('min-height',
  467. longest_1 + longest_2 * 20 / 100);
  468. // row 2
  469. $('.field_05,.field_11, .field_07,.field_02 ').css('min-height',
  470. longest_1 + longest_2 * 20 / 100);
  471. // card group 2
  472. // row 3
  473. $('.field_03, .field_09, .field_10, .field_04').css('min-height',
  474. longest_2 * 2 - longest_2 * 20 / 100);
  475. } else if (screenSize >= 920 && screenSize <= 976) {
  476. // card group1:
  477. // row 1
  478. $('.field_01,.field_06, .field_12,.field_08 ').css('min-height',
  479. longest_1 + longest_2 * 20 / 100);
  480. // row 2
  481. $('.field_05,.field_11, .field_07,.field_02 ').css('min-height',
  482. longest_1 + longest_2 * 20 / 100);
  483. // card group 2
  484. // row 3
  485. $('.field_03, .field_09, .field_10, .field_04').css('min-height',
  486. longest_2 * 2 - longest_2 * 20 / 100);
  487. } else if (screenSize >= 485 && screenSize <= 919) {
  488. // else if (500 <= screenSize < 920) {
  489. // card group1:
  490. $('.field_01,.field_06, .field_12,.field_08 ').css('min-height',
  491. longest_1 * 80 / 100);
  492. $('.field_05,.field_11, .field_07,.field_02 ').css('min-height',
  493. longest_1 * 80 / 100);
  494. // card group 2
  495. $('.field_03, .field_09, .field_10, .field_04').css('min-height',
  496. longest_2 * 80 / 100);
  497. /* --- 1 COL Range ---- */
  498. } else {
  499. // card group1:
  500. // card group1:
  501. $('.field_01,.field_06, .field_12,.field_08 ').css('min-height',
  502. longest_1 * 20 / 100);
  503. $('.field_05,.field_11, .field_07,.field_02 ').css('min-height',
  504. longest_1 * 20 / 100);
  505. // card group 2
  506. $('.field_03, .field_09, .field_10, .field_04').css('min-height',
  507. longest_2 * 20 / 100);
  508. }
  509. } // end of fixHeights()
  510. }); // end of jQuery code