canvas.js 28 KB

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