Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.23 KB | None | 0 0
  1. <!-- The output container contains raw code for copying/pasting -->
  2. <div id="output">
  3. <div class="style"></div>
  4. <div class="html"></div>
  5. <div class="script"></div>
  6. </div>
  7.  
  8. <!-- The preview container contains the same code, but rendered -->
  9. <div id="preview">
  10. <style id="listGenStyle"></style>
  11. <div id="listGenHTML"></div>
  12. <script id="listGenScript"></script>
  13. </div>
  14.  
  15. <table id="mblParentContainer">
  16. <tbody>
  17. <tr>
  18. <td>
  19. <div class="mblWrpr">
  20. <!-- I'm omitting the rest of the markup for the sake of saving space. But here would be the header, nav, mobile nav, slideshow, listing title, content boxes, footer -->
  21. </div>
  22. </td>
  23. </tr>
  24. </tbody>
  25. </table>
  26.  
  27. iq.show(iq.sel("#mblSlide img:first-child"));
  28. iq.show(iq.sel(".mblHide.one"));
  29. iq.sel(".mblNav ul li:first-child").style.background = "#000";
  30. iq.sel(".mblNav ul li:first-child .triangle").style.display = "block";
  31. iq.sel(".mblNav ul li:first-child").style.borderBottom = "2px solid #66e2e3";
  32. iq.sel(".mblNav ul li:first-child a").style.color = "#66e2e3";
  33. iq.sel(".mblNav ul li:first-child a").style.textTransform = "uppercase";
  34. iq.click("a", function(){
  35. if (iq.hasClass(iq.sel("#mblMobile"), "open") && this.parentNode.parentNode.getAttribute("class") === "mblMM") {
  36. iq.fadeOut(100, iq.sel(".mblFadeWrapper"));
  37. iq.fadeOut(100, iq.sel("#mblMobile"));
  38. iq.removeClass(iq.sel("#mblMobile"), "open");
  39. } else if (!iq.hasClass(iq.sel("#mblMobile"), "open") && this.parentNode.parentNode.getAttribute("class") === "mblMM") {
  40. iq.fadeIn(100, iq.sel("#mblMobile"));
  41. iq.fadeIn(100, iq.sel(".mblFadeWrapper"));
  42. iq.addClass(iq.sel("#mblMobile"), "open");
  43. }
  44. var cls = iq.map("a", "class");
  45. for (var i = 0; i < cls.length; i++) {
  46. if (this.getAttribute("class") === cls[i]) {
  47. iq.show(iq.sel(".mblHide." + cls[i]));
  48. iq.scrollWindow(".mblHide." + cls[i]);
  49. iq.sel("a."+cls[i]).style.color = "#66e2e3";
  50. iq.sel("a."+cls[i]).style.textTransform = "uppercase";
  51. iq.sel("a."+cls[i]).parentNode.style.background = "#000";
  52. iq.sel("a."+cls[i]).parentNode.style.borderBottom = "2px solid #66e2e3";
  53. iq.sel("a."+cls[i]).parentNode.children[1].style.display = "block";
  54. var toHide = iq.selAll(".mblHide:not(." + cls[i] + ")");
  55. var a = iq.selAll(".mblMainNav a:not(."+cls[i]+")");
  56. for (var j = 0; j < toHide.length; j++) {
  57. iq.hide(toHide[j]);
  58. for (var k = 0; k < a.length; k++) {
  59. a[k].style.color = "";
  60. a[k].style.textTransform = "";
  61. a[k].parentNode.style.background = "";
  62. a[k].parentNode.style.borderBottom = "";
  63. a[k].parentNode.children[1].style.display = "";
  64. }
  65. }
  66. }
  67. }
  68. });
  69. iq.click(".menu-trigger", function(){
  70. iq.addOrRemoveClass(iq.sel("#mblMobile"), "open");
  71. if (iq.hasClass(iq.sel("#mblMobile"), "open")) {
  72. iq.fadeIn(100, iq.sel(".mblFadeWrapper"));
  73. iq.fadeIn(100, iq.sel("#mblMobile"));
  74. } else {
  75. iq.fadeOut(100, iq.sel("#mblMobile"));
  76. iq.fadeOut(100, iq.sel(".mblFadeWrapper"));
  77. }
  78. });
  79. iq.click("#mblThumbs img", function(){
  80. var dn = iq.map("img", "data-name");
  81. for (var i = 0; i < dn.length; i++) {
  82. if (this.getAttribute('data-name') === dn[i]) {
  83. var outs = iq.selAll('#mblSlide img:not([data-name="' + dn[i] + '"])');
  84. for (var j = 0; j < outs.length; j++) {
  85. iq.fadeOut(100, outs[j]);
  86. }
  87. iq.fadeIn(200, iq.sel('#mblSlide img[data-name="' + dn[i] + '"]'));
  88. }
  89. }
  90. });
  91. var num = iq.sel(".mblHOne").nextElementSibling.innerHTML.replace(/.10/g, "");
  92. var stars = iq.selAll(".star");
  93. var arr = [];
  94. for (var i = 0; i < stars.length; i++) {
  95. arr.push(stars[i]);
  96. }
  97. arr.splice(0, num);
  98. for (var j = 0; j < arr.length; j++) {
  99. arr[j].style.color = "black";
  100. }
  101. var thumbs = iq.selAll("#mblThumbs img");
  102. for (var k = 0; k < thumbs.length; k++) {
  103. if (thumbs[k].getAttribute("src") === "") {
  104. thumbs[k].remove();
  105. }
  106. }
  107. var logo = iq.sel(".mblHdr img");
  108. if (logo.getAttribute("src") === "undefined") {
  109. iq.hide(logo);
  110. } else {
  111. iq.show(logo);
  112. }
  113. iq.click(".back-to-top", function(){
  114. iq.scrollWindow(".mblWrpr");
  115. });
  116.  
  117. $(document).ready(function(){
  118.  
  119. // We need the HTML template right away so we populate it
  120. // with variables declared in this script.
  121. // We'll grab the external CSS and JS after the HTML
  122. // template is fully populated.
  123. $('#listGenHTML').load('listGen.html');
  124. //***********************************************************************************
  125. // OUTPUT GENERATION FUNCTIONS
  126. //***********************************************************************************
  127.  
  128. // On form submit, populate code output container and preview container
  129. $('#form1').on('submit', function(e) {
  130.  
  131. e.preventDefault();
  132.  
  133. // Set the src attribute for the logo image if it exists
  134. var logoSrc = $('#company-logo .preview img').attr('src');
  135. if (logoSrc) {
  136. logoSrc = logoSrc.replace(//thumbnail/g, '');
  137. }
  138. $('.mblHdr img').attr('src', logoSrc);
  139.  
  140. // Grab values of menu item inputs and use them to populate
  141. // the main nav and mobile nav, as well as the corresponding description header
  142. var menu = [];
  143. $('.menuItems input').each(function(){
  144. menu.push($(this).val());
  145. });
  146.  
  147. for (var h = 0; h < menu.length; h++) {
  148. $('.mblMainNav li').eq(h).find('a').text(menu[h]);
  149. $('.mblMM li').eq(h).find('a').text(menu[h]);
  150. $('.mblDescHdr').eq(h).text(menu[h]);
  151. }
  152.  
  153.  
  154. // Grab the href and src attributes for uploaded images and their links
  155. // and use them to populate the slideshow
  156. var fullSizeSrc = [];
  157. var thumbSrc = [];
  158. var total = $('#slide-upload tr').length;
  159. for (var i =1; i <= total; i++){
  160. var fss = $('#slide-upload tr:nth-child('+i+') td:first a').attr('href');
  161. var ts = fss.replace(//thumbnail/g, '');
  162. fullSizeSrc.push(fss);
  163. thumbSrc.push(ts);
  164. }
  165.  
  166. for (var j = 0; j < fullSizeSrc.length; j++) {
  167. $('#mblSlide a').eq(j).attr('href', fullSizeSrc[j]);
  168. $('#mblSlide a').eq(j).find('img').attr('src', fullSizeSrc[j]);
  169. }
  170.  
  171. for (var k = 0; k < thumbSrc.length; k++) {
  172. $('#mblThumbs img').eq(k).attr('src', thumbSrc[k]);
  173. }
  174.  
  175. // Get the values entered in the item description textareas
  176. // and populate the description boxes
  177. var itemDesc = [];
  178. $('.desc-boxes textarea').each(function(){
  179. itemDesc.push($(this).val());
  180. });
  181.  
  182. for (var l = 0; l < itemDesc.length; l++) {
  183. $('.mblParaDesc').eq(l).text(itemDesc[l]);
  184. }
  185.  
  186. // Get the value of the Item Title input field and populate the item title header
  187. var itemTitle = $('.itemTitle').val();
  188. $('.mblHOne').text(itemTitle);
  189.  
  190. // Get the value of the Item Rating input field and populate the item rating
  191. var itemRating = $('.itemRating').val();
  192. $('.rating').text(itemRating+'/10');
  193.  
  194. // Get the script and insert as HTML into the proper script tag in #preview
  195. $('#listGenScript').load('listGen.js');
  196.  
  197. // Get the stylesheet and insert as CSS into the proper style tag in #preview
  198. $('#listGenStyle').load('listGen.css', function(){
  199. // Populate code container with raw code
  200. $('#output .style').text('<style>' + $('#listGenStyle').html() + '</style>');
  201. $('#output .html').text($('#listGenHTML').html());
  202. $('#output .script').text('<script>' + $('#listGenScript').html() + '</script>');
  203.  
  204. // Now we can show the preview container and UI buttons
  205. $('#preview').fadeIn();
  206. $('.continue-editing, .get-code, #form-clear').fadeIn();
  207. });
  208. });
  209.  
  210. // Close the preview but keep all the input values and storage
  211. $('.continue-editing').click(function(){
  212. $('.continue-editing, .get-code, #form-clear').fadeOut();
  213. $('#output').fadeOut().empty();
  214. $('#preview').fadeOut();
  215.  
  216. });
  217.  
  218. // Same as above, but clear form and storage
  219. $('#form-clear').click(function(){
  220. document.forms.form1.reset();
  221. $('button[data-type="DELETE"]').each(function(){
  222. $(this).click();
  223. });
  224. $('#output').fadeOut().empty();
  225. $('#preview').fadeOut().empty();
  226. $('.continue-editing, .get-code, #form-clear').fadeOut();
  227. window.location.reload();
  228. });
  229.  
  230. // View the code block output
  231. $('.get-code').click(function(){
  232. $('#output').toggle();
  233. });
  234. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement