1/* indigo_design_system v1.2.0 */ 2 /*global $*/ 3 4 // var indi = indi || {}; 5 // var projectNamespace = projectNamespace || 'indi'; 6 7 // indi.Button = function() { 8 // 'use strict'; 9 // var set_event_listeners = function() { 10 // $("body").on("click", `.${projectNamespace}-button`, function(e){ 11 // e.preventDefault(); 12 // $(this).text("CLICKED!"); 13 // }); 14 // }; 15 16 // var initialize = function initialize() { 17 // set_event_listeners(); 18 // }; 19 20 // var public_vars = { 21 // 'initialize': initialize 22 // }; 23 24 // return public_vars; 25 // }(); 26 // $(document).ready(function(){ 27 // 'use strict'; 28 // indi.Button.initialize(); 29 // }); 30 31/*global $*/ 32 33var DataTable = function() { 34 'use strict'; 35 36 $('.indi-data-table__column-heading--sort-link').click(function(){ 37 var $target = $(this).closest('.indi-data-table'); 38 if ($(this).hasClass('indi-data-table__column-heading--sort-link-is-active')) { 39 $(this).toggleClass('indi-data-table__column-heading--sort-link-is-descending'); 40 } else { 41 $target.find('.indi-data-table__column-heading--sort-link').removeClass('indi-data-table__column-heading--sort-link-is-active'); 42 $(this).addClass('indi-data-table__column-heading--sort-link-is-active'); 43 } 44 }); 45}; 46 47$(document).ready(function(){ 48 'use strict'; 49 DataTable = new DataTable(); 50}); 51 52/*global $*/ 53 54var Form = function() { 55 'use strict'; 56 57 $('.js-behavior-trigger-form-input-file').click(function(){ 58 $(this).prev('.js-object-form-input-file').trigger('click'); 59 }); 60 61 $(document).on('click', '.js-behavior-remove-file-upload', function(){ 62 var $target = $(this).closest('.js-object-file-upload'); 63 64 $target.fadeOut(function(){ 65 $(this).remove(); 66 }); 67 }); 68 69 //Demo behaviors for pages/form-file-upload.html 70 71 function simulateFileUpload($el){ 72 var $percentageBar = $el.find('.indi-form__percentage-indicator-bar'); 73 var $percentageAmount = $el.find('.indi-form__percentage-indicator'); 74 var $cellPercentage = $el.find('.indi-form__file-upload-cell--percentage'); 75 var $cellFile = $el.find('.indi-form__file-upload-cell:nth-child(2)'); 76 77 $el.addClass('indi-file-upload-simulation-running'); 78 $percentageBar.css({'width': '0%'}); 79 $cellPercentage.show(); 80 $cellFile.addClass('indi-form__file-upload-cell--file'); 81 82 $percentageBar.animate({'width': '100%'}, {
83 'duration': 20000, 84 'progress': function(animation, progress) { 85 $percentageAmount.attr('aria-valuenow', Math.round(progress * 100)); 86 }, 87 'complete': function() { 88 $cellPercentage.hide(); 89 $cellFile.removeClass('indi-form__file-upload-cell--file'); 90 $el.removeClass('indi-file-upload-simulation-running'); 91 if ($('.indi-file-upload-simulation-running').length === 0) { 92 $('.js-object-file-upload-message').addClass('indi-doc-display-none'); 93 $('.js-object-file-upload-demo-submit').removeClass('indi-button--disabled').prop("disabled", false); 94 } 95 } 96 }); 97 } 98 99 $('.js-behavior-form-input-file-demo').on('change', function(){ 100 var fileName = $('.js-object-form-input-file').val().split('\\').pop().replace(/\..+$/, ''); 101 var $masterItem = $('.js-object-file-upload-item-master'); 102 var $clonedItem = $masterItem.clone().addClass('js-object-file-upload-item-clone js-behavior-file-upload-demo-reset').removeClass('js-object-file-upload-item-master indi-doc-display-none'); 103 $clonedItem.find('.indi-file-object__cell--label').text(fileName).attr('title', fileName); 104 $clonedItem.appendTo('.js-object-file-upload-list'); 105 simulateFileUpload($clonedItem); 106 $('#file-upload-example-form')[0].reset(); 107 $('.js-object-trigger-form-input-file').text("Upload another file.").removeClass('indi-button--primary').addClass('indi-button--tertiary'); 108 $('.js-object-file-upload-cell').removeClass('indi-doc-display-none'); 109 $('.js-object-file-upload-message').removeClass('indi-doc-display-none'); 110 $('.js-object-file-upload-demo-submit').addClass('indi-button--disabled').prop("disabled", true); 111 }); 112 113 $(document).on('click', '.js-behavior-file-upload-demo-reset .js-behavior-remove-file-upload', function(){ 114 setTimeout(function(){ 115 if ($('.js-object-file-upload-item-clone').length >= 1 && $('.indi-file-upload-simulation-running').length === 0) { 116 $('.js-object-file-upload-message').addClass('indi-doc-display-none'); 117 $('.js-object-file-upload-demo-submit').removeClass('indi-button--disabled').prop("disabled", false); 118 } 119 120 if ($('.js-object-file-upload-item-clone').length === 0) { 121 $('.js-object-trigger-form-input-file').text("Choose File").removeClass('indi-button--tertiary').addClass('indi-button--primary'); 122 $('.js-object-file-upload-cell').addClass('indi-doc-display-none'); 123 $('.js-object-file-upload-message').addClass('indi-doc-display-none'); 124 $('.js-object-file-upload-demo-submit').addClass('indi-button--disabled').prop("disabled", true); 125 } 126 }, 550); 127 }); 128}; 129 130var datepicker = function() { 131 'use strict'; 132 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 133 $('.js-object-datepicker').attr("readonly", "true"); 134 } 135 var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
135November", "December"]; 136 $(".js-object-datepicker").on("click touchstart", function() { 137 // $("body").addClass("indi-form__datepicker-no-scroll"); 138 var id = $(this).attr("id"); 139 var currentdate; 140 if (this.value !== '' && isValidDate(this.value)) { 141 currentdate = new Date(this.value); 142 } else { 143 currentdate = new Date(); 144 } 145 buildCalendar(currentdate, id); 146 $(this).siblings(".indi-form__datepicker").addClass("indi-form__datepicker--is-open"); 147 }); 148 149 $(".js-object-datepicker").keyup(function() { 150 if (isValidDate(this.value)) { 151 var id = $(this).attr("id"); 152 buildCalendar(new Date($(this).val()), id); 153 $(this).siblings(".indi-form__datepicker").addClass("indi-form__datepicker--is-open"); 154 } 155 }); 156 157 $(document).on('click touchstart', function() { 158 $(".indi-form__datepicker").removeClass("indi-form__datepicker--is-open"); 159 $(".js-object-datepicker").blur(); 160 }); 161 162 $(".js-object-datepicker, .indi-form__datepicker-calender > thead, .indi-form__datepicker-head").on('click touchstart', function(e) { 163 $("#" + $(".js-object-datepicker").attr("id")).focus(); 164 e.stopPropagation(); 165 e.preventDefault(); 166 }); 167 168 function buildCalendar(date, id) { 169 $(".month").html(months[date.getMonth()]); 170 $(".year").html(date.getFullYear()); 171 var tbody = $(".indi-form__datepicker-calender>tbody ").html(""); 172 var firstdayofmonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay(); 173 var lastdayofmonth = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDay(); 174 var numDaysInMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate(); 175 var lastdateofpreviousmonth = new Date(date.getFullYear(), date.getMonth(), 0).getDate(); 176 var lastmonth = new Date(date.getFullYear(), date.getMonth() - 1); 177 var nextmonth = new Date(date.getFullYear(), date.getMonth() + 1); 178 179 // date from previous and current month 180 for (var i = 0, dt = 1; dt <= numDaysInMonth; i++) { 181 if (i % 7 === 0) { 182 tbody += "</tr><tr>"; 183 } 184 if (i >= firstdayofmonth) { 185 if (dt === parseInt($("#" + id).val().split("/")[1], 10) && $(".month").html() === months[$("#" + id).val().split("/")[0] - 1] && $(".year").html() === $("#" + id).val().split("/")[2]) { 186 tbody += "<td><button class ='js-behavior-set-current-month-dates indi-form__datepicker-previously-selected-date' aria-label=" + (date.getMonth() + 1) + "/" + dt + "/" + date.getFullYear() + ">" + dt + "</button></td>"; 187 } else { 188 tbody += "<td><button class='js-behavior-set-current-month-dates' aria-label=" + (date.getMonth() + 1) + "/" + dt + "/" + date.getFullYear() + ">" + dt + "</button></td>"; 189 } 190 dt++; 191 } else { 192 tbody += "<td><button class='indi-form__datepicker-previous-month-dates' aria-label=" + (lastmonth.getMonth() + 1) + "/" + (lastdateofpreviousmonth - (firstdayofmonth - (i + 1))) + "/" + lastmonth.getFullYear() + ">" + (lastdateofpreviousmonth - (firstdayofmonth - (i + 1))) + "</button></td>"; 193 } 194 } 195 // dates from next month 196 for (var j = 1; j <= (6 - lastdayofmonth); j++) { 197 tbody += "<td><button class='indi-form__datepicker-next-month-dates' aria-label=" + (nextmonth.getMonth() + 1) + "/" + j + "/" + nextmonth.getFullYear() + ">" + j + "</button></td>"; 198 } 199 200 $(".indi-form__datepicker-calender>tbody").html(tbody); 201 202 function selectDate(event) { 203 var day = $(this).html(); 204 var newdate = new Date($(".year").html(), months.indexOf($(".month").html()) + event.data.monthchange, day); 205 $("#" + id).val(''); 206 $("#" + id).val((newdate.getMonth() + 1) + "/" + newdate.getDate() + "/" + newdate.getFullYear()); 207 $("#" + id).blur(); 208 } 209 $(".indi-form__datepicker-calender>tbody td button.js-behavior-set-current-month-dates").on('click touchstart', { 'monthchange': 0 }, selectDate); 210 $(".indi-form__datepicker-calender>tbody td button.indi-form__datepicker-previous-month-dates").on('click touchstart', { 'monthchange': -1 }, selectDate); 211 $(".indi-form__datepicker-calender>tbody td button.indi-form__datepicker-next-month-dates").on('click touchstart', { 'monthchange': 1 }, selectDate); 212 } 213 //navigation for months 214 $(".indi-form__datepicker-head-previous").on('click touchstart', function() { 215 var id = $(this).parents(".indi-form__datepicker").siblings(".js-object-datepicker").attr("id"); 216 var date = new Date($(".year").html(), months.indexOf($(".month").html()) - 1); 217 buildCalendar(date, id); 218 }); 219 220 $(".indi-form__datepicker-head-next").on('click touchstart', function() { 221 var id = $(this).parents(".indi-form__datepicker").siblings(".js-object-datepicker").attr("id"); 222 var date = new Date($(".year").html(), months.indexOf($(".month").html()) + 1); 223 buildCalendar(date, id); 224 }); 225 226 function isValidDate(dateString) { 227 if (!/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(dateString)) { 228 return false;
229 } 230 231 var parts = dateString.split("/"); 232 var day = parseInt(parts[1], 10); 233 var month = parseInt(parts[0], 10); 234 var year = parseInt(parts[2], 10); 235 236 if (year < 1000 || year > 3000 || month === 0 || month > 12) { 237 return false; 238 } 239 240 var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 241 242 if (year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)) { 243 monthLength[1] = 29; 244 } 245 246 return day > 0 && day <= monthLength[month - 1]; 247 } 248}; 249 250$(document).ready(function(){ 251 'use strict'; 252 Form = new Form(); 253 datepicker(); 254 validations(); 255}); 256 257var validations = function(){ 258 'use strict'; 259$(".js-behavior-validate-email").focusout(function(){ 260 validateEmail($(this)); 261}); 262 263$(".js-behavior-validate-phone").focusout(function(){ 264 validatePhoneNo($(this)); 265}); 266 267function validateEmail(target) { 268 var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i); 269 if (pattern.test(target.val()) || target.val().length === 0) { 270 target.siblings(".indi-form__input-notification--has-error").addClass("indi-doc-display-none"); 271 target.removeClass("indi-form__input--has-error"); 272 } else { 273 target.addClass("indi-form__input--has-error"); 274 target.siblings(".indi-form__input-notification--has-error").html("Please Enter valid email"); 275 target.siblings(".indi-form__input-notification--has-error").removeClass("indi-doc-display-none"); 276 } 277} 278 279function validatePhoneNo(target){ 280 var pattern = new RegExp(/^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/); 281 if (pattern.test(target.val()) || target.val().length === 0) { 282 target.siblings(".indi-form__input-notification--has-error").addClass("indi-doc-display-none"); 283 target.removeClass("indi-form__input--has-error"); 284 } else { 285 target.addClass("indi-form__input--has-error"); 286 target.siblings(".indi-form__input-notification--has-error").html("Phone number is invalid"); 287 target.siblings(".indi-form__input-notification--has-error").removeClass("indi-doc-display-none"); 288 } 289} 290}; 291 292/*global $*/ 293 294var Loader = function() { 295 'use strict'; 296 297 $('.js-behavior-launch-loader-doc-example').click(function(){ 298 $('.js-object-loader-doc-example').addClass('indi-loader--overlay'); 299 }); 300 301 $('.js-object-loader-doc-example').click(function(){ 302 $(this).removeClass('indi-loader--overlay'); 303 }); 304}; 305 306$(document).ready(function(){ 307 'use strict'; 308 Loader = new Loader(); 309}); 310 311/*global $*/ 312$(document).ready(function() { 313 'use strict'; 314 $(".indi-modal-target").click(function() { 315 $(this).next().addClass("indi-modal--is-open"); 316 }); 317 $('.indi-modal__close, .indi-button--tertiary').on('click', function() { 318 $(".indi-modal").removeClass("indi-modal--is-open"); 319 }); 320 $(document).click(function(event) { 321 if ($(event.target).is(".indi-modal")) { 322 $(".indi-modal").removeClass("indi-modal--is-open"); 323 } 324 }); 325 $(document).keyup(function(e) { 326 if (e.keyCode === 27) { 327 $(".indi-modal").removeClass("indi-modal--is-open"); 328 } 329 }); 330}); 331 332/*global $*/ 333 334var SideNav = function() { 335 'use strict'; 336 337 function getParameterByName(name, url) { 338 if (!url) { 339 url = window.location.href; 340 } 341 name = name.replace(/[\[\]]/g, "\\$&"); 342 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), 343 results = regex.exec(url); 344 if (!results) { 345 return null; 346 } 347 if (!results[2]) { 348 return ''; 349 } 350 return decodeURIComponent(results[2].replace(/\+/g, " ")); 351 } 352 353 $('.js-behavior-side-nav-link').click(function(e){ 354 var currentScrollPos = $('.indi-doc-layout-frames__frame--left').scrollTop(); 355 var newLocation = $(this).attr('href'); 356 357 if (currentScrollPos > 0){ 358 e.preventDefault(); 359 window.location = newLocation + '?navpos=' + currentScrollPos; 360 } 361 }); 362 363 var currentPathname = window.location.pathname.substr(window.location.pathname.lastIndexOf('/') + 1); 364 365 $('.js-behavior-side-nav-link').each(function(i){ 366 var thisLink = $(this).attr('href').substr($(this).attr('href').lastIndexOf('/') + 1); 367 var navScrollPos = getParameterByName('navpos');
368 var viewportHeight = $(window).height(); 369 var thisOffset = $(this).offset(); 370 if (thisLink === currentPathname) { 371 $(this).addClass('indi-side-nav__label--link-is-active'); 372 373 if (navScrollPos) { 374 $('.indi-doc-layout-frames__frame--left').animate({ 375 'scrollTop': navScrollPos 376 }, 1); 377 } else if (thisOffset.top >= viewportHeight){ 378 $('.indi-doc-layout-frames__frame--left').animate({ 379 'scrollTop': thisOffset.top - viewportHeight / 2 380 }, 1); 381 } 382 } else if (currentPathname === "creating-forms.html") { 383 $('.indi-side-nav__label:contains("Forms")').addClass('indi-side-nav__label--link-is-active'); //Hack for Forms doc page tab. 384 } 385 }); 386}; 387 388$(document).ready(function(){ 389 'use strict'; 390 SideNav = new SideNav(); 391}); 392 393/*global $*/ 394$(document).ready(function() { 395 'use strict'; 396 $('body').on('click', 'button.indi-tab__label', function(event) { 397 $(this).closest('.indi-tab').find('.indi-tab__content-item').removeClass("indi-tab__content-item--active"); 398 $("#" + event.target.id + "-content").addClass("indi-tab__content-item--active"); 399 $(this).closest('.indi-tab').find('.indi-tab__label').removeClass("indi-tab__label--active"); 400 $(this).addClass("indi-tab__label--active"); 401 }); 402});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.