mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
1 line
59 KiB
Plaintext
1 line
59 KiB
Plaintext
{"version":3,"sources":["script.js"],"names":["generatePDF","invoice","javascript","force","cb","refreshTimer","clearTimeout","setTimeout","calculateAmounts","pdfDoc","GetPdfMake","getDataUrl","copyObject","orig","JSON","parse","stringify","processVariables","str","variables","i","length","variable","regexp","RegExp","matches","match","j","offset","split","parseInt","replace","getDatePart","part","getMonth","getQuarter","getYear","today","Date","months","month","year","getFullYear","quarter","Math","floor","isStorageSupported","window","e","isValidEmailAddress","emailAddress","pattern","test","enableHoverClick","$combobox","$entityId","url","setAsLink","$input","enable","css","setComboboxValue","id","name","find","val","combobox","addClass","removeClass","convertDataURIToBinary","dataURI","base64Index","indexOf","BASE64_MARKER","base64","substring","base64DecToArr","getContactDisplayName","contact","first_name","last_name","email","getClientDisplayName","client","contacts","populateInvoiceComboboxes","clientId","invoiceId","clientMap","invoiceMap","invoicesForClientMap","$clientSelect","$","invoices","hasOwnProperty","public_id","push","clients","append","Option","clientName","on","preventDefault","$invoiceCombobox","remove","end","list","invoice_number","invoice_status","formatMoneyInvoice","amount","balance","$invoiceSelect","$clientCombobox","parseFloat","toFixed","trigger","formatAddress","city","state","zip","swap","concatStrings","concatStr","data","arguments","string","total","hasTaxes","taxes","has_product_key","invoice_design_id","invoice_items","item","lineTotal","roundToTwo","NINJA","cost","qty","taxRate1","taxName1","taxRate2","taxName2","product_key","tax_name1","tax_rate1","tax_name2","tax_rate2","discount","is_amount_discount","taxAmount1","key","rate","taxAmount2","subtotal_amount","custom_value1","custom_taxes1","custom_value2","custom_taxes2","total_amount","discount_amount","tax_amount1","tax_amount2","item_taxes","partial","balance_amount","objectEquals","x","y","Function","toString","undefined","valueOf","Object","p","keys","every","b64ToUint6","nChr","sBase64","nBlocksSize","nMod3","nMod4","sB64Enc","nInLen","nOutLen","ceil","taBytes","Uint8Array","nUint24","nOutIdx","nInIdx","charCodeAt","uint6ToB64","nUint6","base64EncArr","aBytes","nLen","nIdx","String","fromCharCode","substr","UTF8ArrToStr","nPart","sView","strToUTF8Arr","sDOMStr","nStrLen","nArrLen","nMapIdx","nChrIdx","hexToR","h","cutHex","hexToG","hexToB","charAt","setDocHexColor","doc","hex","r","g","b","setTextColor","setDocHexFill","setFillColor","setDocHexDraw","setDrawColor","toggleDatePicker","field","datepicker","num","round","roundToFour","truncate","endsWith","suffix","secondsToTime","secs","hours","divisor_for_minutes","minutes","divisor_for_seconds","seconds","obj","m","s","twoDigits","value","toSnakeCase","$1","toLowerCase","snakeToCamel","toUpperCase","getDescendantProp","desc","arr","shift","doubleDollarSign","actionListHandler","closest","mouseover","this","show","hide","mouseout","$dropdown","hasClass","loadImages","selector","each","index","src","attr","prettyJson","json","cls","searchData","fuzzy","q","options","fuse","Fuse","search","substrRegex","escapeRegExp","isOpera","opera","navigator","userAgent","isFirefox","InstallTrigger","isSafari","prototype","call","HTMLElement","isEdge","isChrome","chrome","isChromium","isChrome48","isIE","document","documentMode","fn","dataTableExt","extend","oStdClasses","sWrapper","oApi","fnPagingInfo","oSettings","iStart","_iDisplayStart","iEnd","fnDisplayEnd","iLength","_iDisplayLength","iTotal","fnRecordsTotal","iFilteredTotal","fnRecordsDisplay","iPage","iTotalPages","oPagination","bootstrap","fnInit","nPaging","fnDraw","fnClickHandler","oLanguage","oPaginate","_fnPageChange","action","els","bind","fnUpdate","ien","sClass","iListLength","oPaging","oInstance","an","aanFeatures","iHalf","filter","insertBefore","text","DataTable","TableTools","classes","container","buttons","normal","disabled","collection","print","info","select","row","DEFAULTS","oTags","button","liner","ajaxSetup","headers","X-CSRF-TOKEN","ko","bindingHandlers","dropdown","init","element","valueAccessor","allBindingsAccessor","dropdownOptions","utils","unwrapObservable","update","registerEventHandler","datePicker","change","placeholder","underlyingObservable","applyBindingsToNode","tooltip","local","domNodeDisposal","addDisposeCallback","placement","typeahead","viewModel","bindingContext","$element","allBindings","highlight","minLength","display","limit","source","items","datum","CONSTS","INVOICE_STATUS_DRAFT","INVOICE_STATUS_SENT","INVOICE_STATUS_VIEWED","INVOICE_STATUS_APPROVED","INVOICE_STATUS_PARTIAL","INVOICE_STATUS_PAID","defaults","autoclose","todayHighlight","alert","nativeAlert","message","console"],"mappings":"AAYA,QAAAA,aAAAC,EAAAC,EAAAC,EAAAC,GACA,GAAAH,GAAAC,EAAA,CAIA,IAAAC,EASA,MANAE,eACAC,aAAAD,mBAEAA,aAAAE,WAAA,WACAP,YAAAC,EAAAC,GAAA,EAAAE,IACA,KAPAC,cAAA,KAWAJ,EAAAO,iBAAAP,EACA,IAAAQ,GAAAC,WAAAT,EAAAC,EAAAE,EAMA,OAJAA,IACAK,EAAAE,WAAAP,GAGAK,GAGA,QAAAG,YAAAC,GACA,QAAAA,GACAC,KAAAC,MAAAD,KAAAE,UAAAH,IAIA,QAAAI,kBAAAC,GACA,IAAAA,EAAA,MAAA,EAEA,KAAA,GADAC,IAAA,QAAA,UAAA,QACAC,EAAA,EAAAA,EAAAD,EAAAE,OAAAD,IAAA,CACA,GAAAE,GAAAH,EAAAC,GACAG,EAAA,GAAAC,QAAA,IAAAF,EAAA,cAAA,KACAG,EAAAP,EAAAQ,MAAAH,EACA,IAAAE,EAGA,IAAA,GAAAE,GAAA,EAAAA,EAAAF,EAAAJ,OAAAM,IAAA,CACA,GAAAD,GAAAD,EAAAE,GACAC,EAAA,CACAF,GAAAG,MAAA,KAAAR,OAAA,EACAO,EAAAF,EAAAG,MAAA,KAAA,GACAH,EAAAG,MAAA,KAAAR,OAAA,IACAO,EAAAE,SAAAJ,EAAAG,MAAA,KAAA,QAEAX,EAAAA,EAAAa,QAAAL,EAAAM,YAAAV,EAAAM,KAIA,MAAAV,GAGA,QAAAc,aAAAC,EAAAL,GAKA,MAJAA,GAAAE,SAAAF,GACAA,IACAA,EAAA,GAEA,SAAAK,EACAC,SAAAN,GACA,WAAAK,EACAE,WAAAP,GACA,QAAAK,EACAG,QAAAR,GADA,OAKA,QAAAM,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mB,GAAAH,WACAK,WAAA,EACAC,UAAA,IAGA5U,KAAA,OACA6U,QAAAH,EAAAlP,IACAsP,MAAA,GACAC,OAAAzH,WAAAoH,EAAAM,MAAAN,EAAAlP,OACAlD,GAAA,mBAAA,SAAA8Q,EAAA6B,EAAAjV,GACA,GAAAyL,GAAA4H,GACA5H,GAAAwJ,MAIAvB,OAAA,SAAAN,EAAAC,GACA,GAAA5H,GAAAuH,GAAAQ,MAAAC,iBAAAJ,IACA5H,IACA5J,EAAAuR,GAAAkB,UAAA,MAAA7I,KA0HA,IAAAyJ,UACAA,QAAAC,qBAAA,EACAD,OAAAE,oBAAA,EACAF,OAAAG,sBAAA,EACAH,OAAAI,wBAAA,EACAJ,OAAAK,uBAAA,EACAL,OAAAM,oBAAA,EAEA3T,EAAAoN,GAAA1E,WAAAkL,SAAAC,WAAA,EACA7T,EAAAoN,GAAA1E,WAAAkL,SAAAE,gBAAA,EAkLA3W,OAAA4W,MAAA,WACA,GAAAC,GAAA7W,OAAA4W,KACA,OAAA,UAAAE,GACA9W,OAAA4W,MAAAC,EACAC,GAAA,IAAAA,EAAArV,QAAA,sBACAsV,OACAF,EAAAC","file":"script.js","sourcesContent":["// http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser\nvar isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;\nvar isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+\nvar isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;\nvar isEdge = navigator.userAgent.indexOf('Edge/') >= 0;\nvar isChrome = !!window.chrome && !isOpera && !isEdge; // Chrome 1+\nvar isChromium = isChrome && navigator.userAgent.indexOf('Chromium') >= 0;\n// https://code.google.com/p/chromium/issues/detail?id=574648\nvar isChrome48 = isChrome && navigator.userAgent.indexOf('Chrome/48') >= 0;\nvar isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6\n\nvar refreshTimer;\nfunction generatePDF(invoice, javascript, force, cb) {\n if (!invoice || !javascript) {\n return;\n }\n //console.log('== generatePDF - force: %s', force);\n if (force) {\n refreshTimer = null;\n } else {\n if (refreshTimer) {\n clearTimeout(refreshTimer);\n }\n refreshTimer = setTimeout(function() {\n generatePDF(invoice, javascript, true, cb);\n }, 500);\n return;\n }\n\n invoice = calculateAmounts(invoice);\n var pdfDoc = GetPdfMake(invoice, javascript, cb);\n\n if (cb) {\n pdfDoc.getDataUrl(cb);\n }\n\n return pdfDoc;\n}\n\nfunction copyObject(orig) {\n if (!orig) return false;\n return JSON.parse(JSON.stringify(orig));\n}\n\n/* Handle converting variables in the invoices (ie, MONTH+1) */\nfunction processVariables(str) {\n if (!str) return '';\n var variables = ['MONTH','QUARTER','YEAR'];\n for (var i=0; i<variables.length; i++) {\n var variable = variables[i];\n var regexp = new RegExp(':' + variable + '[+-]?[\\\\d]*', 'g');\n var matches = str.match(regexp);\n if (!matches) {\n continue;\n }\n for (var j=0; j<matches.length; j++) {\n var match = matches[j];\n var offset = 0;\n if (match.split('+').length > 1) {\n offset = match.split('+')[1];\n } else if (match.split('-').length > 1) {\n offset = parseInt(match.split('-')[1]) * -1;\n }\n str = str.replace(match, getDatePart(variable, offset));\n }\n }\n\n return str;\n}\n\nfunction getDatePart(part, offset) {\n offset = parseInt(offset);\n if (!offset) {\n offset = 0;\n }\n if (part == 'MONTH') {\n return getMonth(offset);\n } else if (part == 'QUARTER') {\n return getQuarter(offset);\n } else if (part == 'YEAR') {\n return getYear(offset);\n }\n}\n\nfunction getMonth(offset) {\n var today = new Date();\n var months = [ \"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n \"July\", \"August\", \"September\", \"October\", \"November\", \"December\" ];\n var month = today.getMonth();\n month = parseInt(month) + offset;\n month = month % 12;\n if (month < 0) {\n month += 12;\n }\n return months[month];\n}\n\nfunction getYear(offset) {\n var today = new Date();\n var year = today.getFullYear();\n return parseInt(year) + offset;\n}\n\nfunction getQuarter(offset) {\n var today = new Date();\n var quarter = Math.floor((today.getMonth() + 3) / 3);\n quarter += offset;\n quarter = quarter % 4;\n if (quarter == 0) {\n quarter = 4;\n }\n return 'Q' + quarter;\n}\n\n\n/* Default class modification */\nif ($.fn.dataTableExt) {\n $.extend( $.fn.dataTableExt.oStdClasses, {\n \"sWrapper\": \"dataTables_wrapper form-inline\"\n } );\n\n\n /* API method to get paging information */\n $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )\n {\n return {\n \"iStart\": oSettings._iDisplayStart,\n \"iEnd\": oSettings.fnDisplayEnd(),\n \"iLength\": oSettings._iDisplayLength,\n \"iTotal\": oSettings.fnRecordsTotal(),\n \"iFilteredTotal\": oSettings.fnRecordsDisplay(),\n \"iPage\": oSettings._iDisplayLength === -1 ?\n 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),\n \"iTotalPages\": oSettings._iDisplayLength === -1 ?\n 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )\n };\n };\n\n\n /* Bootstrap style pagination control */\n $.extend( $.fn.dataTableExt.oPagination, {\n \"bootstrap\": {\n \"fnInit\": function( oSettings, nPaging, fnDraw ) {\n var oLang = oSettings.oLanguage.oPaginate;\n var fnClickHandler = function ( e ) {\n e.preventDefault();\n if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {\n fnDraw( oSettings );\n }\n };\n\n $(nPaging).addClass('pagination').append(\n '<ul class=\"pagination\">'+\n '<li class=\"prev disabled\"><a href=\"#\">«</a></li>'+\n '<li class=\"next disabled\"><a href=\"#\">»</a></li>'+\n '</ul>'\n );\n var els = $('a', nPaging);\n $(els[0]).bind( 'click.DT', { action: \"previous\" }, fnClickHandler );\n $(els[1]).bind( 'click.DT', { action: \"next\" }, fnClickHandler );\n },\n\n \"fnUpdate\": function ( oSettings, fnDraw ) {\n var iListLength = 5;\n var oPaging = oSettings.oInstance.fnPagingInfo();\n var an = oSettings.aanFeatures.p;\n var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);\n\n if ( oPaging.iTotalPages < iListLength) {\n iStart = 1;\n iEnd = oPaging.iTotalPages;\n }\n else if ( oPaging.iPage <= iHalf ) {\n iStart = 1;\n iEnd = iListLength;\n } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {\n iStart = oPaging.iTotalPages - iListLength + 1;\n iEnd = oPaging.iTotalPages;\n } else {\n iStart = oPaging.iPage - iHalf + 1;\n iEnd = iStart + iListLength - 1;\n }\n\n for ( i=0, ien=an.length ; i<ien ; i++ ) {\n // Remove the middle elements\n $('li:gt(0)', an[i]).filter(':not(:last)').remove();\n\n // Add the new list items and their event handlers\n for ( j=iStart ; j<=iEnd ; j++ ) {\n sClass = (j==oPaging.iPage+1) ? 'class=\"active\"' : '';\n $('<li '+sClass+'><a href=\"#\">'+j+'</a></li>')\n .insertBefore( $('li:last', an[i])[0] )\n .bind('click', function (e) {\n e.preventDefault();\n oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;\n fnDraw( oSettings );\n } );\n }\n\n // Add / remove disabled classes from the static elements\n if ( oPaging.iPage === 0 ) {\n $('li:first', an[i]).addClass('disabled');\n } else {\n $('li:first', an[i]).removeClass('disabled');\n }\n\n if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {\n $('li:last', an[i]).addClass('disabled');\n } else {\n $('li:last', an[i]).removeClass('disabled');\n }\n }\n }\n }\n } );\n}\n\n/*\n * TableTools Bootstrap compatibility\n * Required TableTools 2.1+\n */\nif ( $.fn.DataTable.TableTools ) {\n // Set the classes that TableTools uses to something suitable for Bootstrap\n $.extend( true, $.fn.DataTable.TableTools.classes, {\n \"container\": \"DTTT btn-group\",\n \"buttons\": {\n \"normal\": \"btn\",\n \"disabled\": \"disabled\"\n },\n \"collection\": {\n \"container\": \"DTTT_dropdown dropdown-menu\",\n \"buttons\": {\n \"normal\": \"\",\n \"disabled\": \"disabled\"\n }\n },\n \"print\": {\n \"info\": \"DTTT_print_info modal\"\n },\n \"select\": {\n \"row\": \"active\"\n }\n } );\n\n // Have the collection use a bootstrap compatible dropdown\n $.extend( true, $.fn.DataTable.TableTools.DEFAULTS.oTags, {\n \"collection\": {\n \"container\": \"ul\",\n \"button\": \"li\",\n \"liner\": \"a\"\n }\n } );\n}\n\n\nfunction isStorageSupported() {\n try {\n return 'localStorage' in window && window['localStorage'] !== null;\n } catch (e) {\n return false;\n }\n}\n\nfunction isValidEmailAddress(emailAddress) {\n var pattern = new RegExp(/^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?$/i);\n return pattern.test(emailAddress);\n};\n\n$(function() {\n $.ajaxSetup({\n headers: {\n 'X-CSRF-TOKEN': $('meta[name=\"csrf-token\"]').attr('content')\n }\n });\n});\n\n\nfunction enableHoverClick($combobox, $entityId, url) {\n /*\n $combobox.mouseleave(function() {\n $combobox.css('text-decoration','none');\n }).on('mouseenter', function(e) {\n setAsLink($combobox, $combobox.closest('.combobox-container').hasClass('combobox-selected'));\n }).on('focusout mouseleave', function(e) {\n setAsLink($combobox, false);\n }).on('click', function() {\n var clientId = $entityId.val();\n if ($(combobox).closest('.combobox-container').hasClass('combobox-selected')) {\n if (parseInt(clientId) > 0) {\n window.open(url + '/' + clientId, '_blank');\n } else {\n $('#myModal').modal('show');\n }\n };\n });\n */\n}\n\nfunction setAsLink($input, enable) {\n if (enable) {\n $input.css('text-decoration','underline');\n $input.css('cursor','pointer');\n } else {\n $input.css('text-decoration','none');\n $input.css('cursor','text');\n }\n}\n\nfunction setComboboxValue($combobox, id, name) {\n $combobox.find('input').val(id);\n $combobox.find('input.form-control').val(name);\n if (id && name) {\n $combobox.find('select').combobox('setSelected');\n $combobox.find('.combobox-container').addClass('combobox-selected');\n } else {\n $combobox.find('.combobox-container').removeClass('combobox-selected');\n }\n}\n\n\nvar BASE64_MARKER = ';base64,';\nfunction convertDataURIToBinary(dataURI) {\n var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;\n var base64 = dataURI.substring(base64Index);\n return base64DecToArr(base64);\n}\n\nif (window.ko) {\n ko.bindingHandlers.dropdown = {\n init: function (element, valueAccessor, allBindingsAccessor) {\n var options = allBindingsAccessor().dropdownOptions|| {};\n var value = ko.utils.unwrapObservable(valueAccessor());\n var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;\n if (id) $(element).val(id);\n //console.log(\"combo-init: %s\", id);\n $(element).combobox(options);\n\n /*\n ko.utils.registerEventHandler(element, \"change\", function () {\n console.log(\"change: %s\", $(element).val());\n //var\n valueAccessor($(element).val());\n //$(element).combobox('refresh');\n });\n */\n },\n update: function (element, valueAccessor) {\n var value = ko.utils.unwrapObservable(valueAccessor());\n var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;\n //console.log(\"combo-update: %s\", id);\n if (id) {\n $(element).val(id);\n $(element).combobox('refresh');\n } else {\n $(element).combobox('clearTarget');\n $(element).combobox('clearElement');\n }\n }\n };\n\n ko.bindingHandlers.combobox = {\n init: function (element, valueAccessor, allBindingsAccessor) {\n var options = allBindingsAccessor().dropdownOptions|| {};\n var value = ko.utils.unwrapObservable(valueAccessor());\n var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;\n if (id) $(element).val(id);\n $(element).combobox(options);\n\n ko.utils.registerEventHandler(element, \"change\", function () {\n var value = valueAccessor();\n value($(element).val());\n });\n },\n update: function (element, valueAccessor) {\n var value = ko.utils.unwrapObservable(valueAccessor());\n var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;\n if (id) {\n $(element).val(id);\n $(element).combobox('refresh');\n } else {\n $(element).combobox('clearTarget');\n $(element).combobox('clearElement');\n }\n }\n };\n\n ko.bindingHandlers.datePicker = {\n init: function (element, valueAccessor, allBindingsAccessor) {\n var value = ko.utils.unwrapObservable(valueAccessor());\n if (value) $(element).datepicker('update', value);\n $(element).change(function() {\n var value = valueAccessor();\n value($(element).val());\n })\n },\n update: function (element, valueAccessor) {\n var value = ko.utils.unwrapObservable(valueAccessor());\n if (value) $(element).datepicker('update', value);\n }\n };\n\n ko.bindingHandlers.placeholder = {\n init: function (element, valueAccessor, allBindingsAccessor) {\n var underlyingObservable = valueAccessor();\n ko.applyBindingsToNode(element, { attr: { placeholder: underlyingObservable } } );\n }\n };\n\n ko.bindingHandlers.tooltip = {\n init: function(element, valueAccessor) {\n var local = ko.utils.unwrapObservable(valueAccessor()),\n options = {};\n\n ko.utils.extend(options, ko.bindingHandlers.tooltip.options);\n ko.utils.extend(options, local);\n\n $(element).tooltip(options);\n\n ko.utils.domNodeDisposal.addDisposeCallback(element, function() {\n $(element).tooltip(\"destroy\");\n });\n },\n options: {\n placement: \"bottom\",\n trigger: \"hover\"\n }\n };\n\n ko.bindingHandlers.typeahead = {\n init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {\n var $element = $(element);\n var allBindings = allBindingsAccessor();\n\n $element.typeahead({\n highlight: true,\n minLength: 0,\n },\n {\n name: 'data',\n display: allBindings.key,\n limit: 50,\n source: searchData(allBindings.items, allBindings.key)\n }).on('typeahead:change', function(element, datum, name) {\n var value = valueAccessor();\n value(datum);\n });\n },\n\n update: function (element, valueAccessor) {\n var value = ko.utils.unwrapObservable(valueAccessor());\n if (value) {\n $(element).typeahead('val', value);\n }\n }\n };\n}\n\nfunction getContactDisplayName(contact)\n{\n if (contact.first_name || contact.last_name) {\n return (contact.first_name || '') + ' ' + (contact.last_name || '');\n } else {\n return contact.email;\n }\n}\n\nfunction getClientDisplayName(client)\n{\n var contact = client.contacts ? client.contacts[0] : false;\n if (client.name) {\n return client.name;\n } else if (contact) {\n return getContactDisplayName(contact);\n }\n return '';\n}\n\nfunction populateInvoiceComboboxes(clientId, invoiceId) {\n var clientMap = {};\n var invoiceMap = {};\n var invoicesForClientMap = {};\n var $clientSelect = $('select#client');\n\n for (var i=0; i<invoices.length; i++) {\n var invoice = invoices[i];\n var client = invoice.client;\n\n if (!invoicesForClientMap.hasOwnProperty(client.public_id)) {\n invoicesForClientMap[client.public_id] = [];\n }\n\n invoicesForClientMap[client.public_id].push(invoice);\n invoiceMap[invoice.public_id] = invoice;\n }\n\n for (var i=0; i<clients.length; i++) {\n var client = clients[i];\n clientMap[client.public_id] = client;\n }\n\n $clientSelect.append(new Option('', ''));\n for (var i=0; i<clients.length; i++) {\n var client = clients[i];\n var clientName = getClientDisplayName(client);\n if (!clientName) {\n continue;\n }\n $clientSelect.append(new Option(clientName, client.public_id));\n }\n\n if (clientId) {\n $clientSelect.val(clientId);\n }\n\n $clientSelect.combobox();\n $clientSelect.on('change', function(e) {\n var clientId = $('input[name=client]').val();\n var invoiceId = $('input[name=invoice]').val();\n var invoice = invoiceMap[invoiceId];\n if (invoice && invoice.client.public_id == clientId) {\n e.preventDefault();\n return;\n }\n setComboboxValue($('.invoice-select'), '', '');\n $invoiceCombobox = $('select#invoice');\n $invoiceCombobox.find('option').remove().end().combobox('refresh');\n $invoiceCombobox.append(new Option('', ''));\n var list = clientId ? (invoicesForClientMap.hasOwnProperty(clientId) ? invoicesForClientMap[clientId] : []) : invoices;\n for (var i=0; i<list.length; i++) {\n var invoice = list[i];\n var client = clientMap[invoice.client.public_id];\n if (!client || !getClientDisplayName(client)) continue; // client is deleted/archived\n $invoiceCombobox.append(new Option(invoice.invoice_number + ' - ' + invoice.invoice_status.name + ' - ' +\n getClientDisplayName(client) + ' - ' + formatMoneyInvoice(invoice.amount, invoice) + ' | ' +\n formatMoneyInvoice(invoice.balance, invoice), invoice.public_id));\n }\n $('select#invoice').combobox('refresh');\n });\n\n var $invoiceSelect = $('select#invoice').on('change', function(e) {\n $clientCombobox = $('select#client');\n var invoiceId = $('input[name=invoice]').val();\n if (invoiceId) {\n var invoice = invoiceMap[invoiceId];\n var client = clientMap[invoice.client.public_id];\n invoice.client = client;\n setComboboxValue($('.client-select'), client.public_id, getClientDisplayName(client));\n if (!parseFloat($('#amount').val())) {\n $('#amount').val(parseFloat(invoice.balance).toFixed(2));\n }\n }\n });\n\n $invoiceSelect.combobox();\n\n if (invoiceId) {\n var invoice = invoiceMap[invoiceId];\n var client = clientMap[invoice.client.public_id];\n invoice.client = client;\n setComboboxValue($('.invoice-select'), invoice.public_id, (invoice.invoice_number + ' - ' +\n invoice.invoice_status.name + ' - ' + getClientDisplayName(client) + ' - ' +\n formatMoneyInvoice(invoice.amount, invoice) + ' | ' + formatMoneyInvoice(invoice.balance, invoice)));\n $invoiceSelect.trigger('change');\n } else if (clientId) {\n var client = clientMap[clientId];\n setComboboxValue($('.client-select'), client.public_id, getClientDisplayName(client));\n $clientSelect.trigger('change');\n } else {\n $clientSelect.trigger('change');\n }\n}\n\n\nvar CONSTS = {};\nCONSTS.INVOICE_STATUS_DRAFT = 1;\nCONSTS.INVOICE_STATUS_SENT = 2;\nCONSTS.INVOICE_STATUS_VIEWED = 3;\nCONSTS.INVOICE_STATUS_APPROVED = 4;\nCONSTS.INVOICE_STATUS_PARTIAL = 5;\nCONSTS.INVOICE_STATUS_PAID = 6;\n\n$.fn.datepicker.defaults.autoclose = true;\n$.fn.datepicker.defaults.todayHighlight = true;\n\nfunction formatAddress(city, state, zip, swap) {\n var str = '';\n if (swap) {\n str += zip ? zip + ' ' : '';\n str += city ? city : '';\n str += (city && state) ? ', ' : (city ? ' ' : '');\n str += state;\n } else {\n str += city ? city : '';\n str += (city && state) ? ', ' : (state ? ' ' : '');\n str += state + ' ' + zip;\n }\n return str;\n}\n\nfunction concatStrings() {\n var concatStr = '';\n var data = [];\n for (var i=0; i<arguments.length; i++) {\n var string = arguments[i];\n if (string) {\n data.push(string);\n }\n }\n for (var i=0; i<data.length; i++) {\n concatStr += data[i];\n if (i == 0 && data.length > 1) {\n concatStr += ', ';\n } else if (i < data.length -1) {\n concatStr += ' ';\n }\n }\n return data.length ? concatStr : \"\";\n}\n\nfunction calculateAmounts(invoice) {\n var total = 0;\n var hasTaxes = false;\n var taxes = {};\n invoice.has_product_key = false;\n\n // Bold designs currently breaks w/o the product column\n if (invoice.invoice_design_id == 2) {\n invoice.has_product_key = true;\n }\n\n // sum line item\n for (var i=0; i<invoice.invoice_items.length; i++) {\n var item = invoice.invoice_items[i];\n var lineTotal = roundToTwo(NINJA.parseFloat(item.cost)) * roundToTwo(NINJA.parseFloat(item.qty));\n lineTotal = roundToTwo(lineTotal);\n if (lineTotal) {\n total += lineTotal;\n }\n }\n\n for (var i=0; i<invoice.invoice_items.length; i++) {\n var item = invoice.invoice_items[i];\n var taxRate1 = 0;\n var taxName1 = '';\n var taxRate2 = 0;\n var taxName2 = '';\n\n if (item.product_key) {\n invoice.has_product_key = true;\n } else if (invoice.invoice_items.length == 1 && !item.qty) {\n invoice.has_product_key = true;\n }\n\n if (item.tax_name1) {\n taxRate1 = parseFloat(item.tax_rate1);\n taxName1 = item.tax_name1;\n }\n\n if (item.tax_name2) {\n taxRate2 = parseFloat(item.tax_rate2);\n taxName2 = item.tax_name2;\n }\n\n // calculate line item tax\n var lineTotal = roundToTwo(NINJA.parseFloat(item.cost)) * roundToTwo(NINJA.parseFloat(item.qty));\n if (invoice.discount != 0) {\n if (parseInt(invoice.is_amount_discount)) {\n lineTotal -= roundToTwo((lineTotal/total) * invoice.discount);\n } else {\n lineTotal -= roundToTwo(lineTotal * (invoice.discount/100));\n }\n }\n\n var taxAmount1 = roundToTwo(lineTotal * taxRate1 / 100);\n if (taxName1) {\n var key = taxName1 + taxRate1;\n if (taxes.hasOwnProperty(key)) {\n taxes[key].amount += taxAmount1;\n } else {\n taxes[key] = {name: taxName1, rate:taxRate1, amount:taxAmount1};\n }\n }\n\n var taxAmount2 = roundToTwo(lineTotal * taxRate2 / 100);\n if (taxName2) {\n var key = taxName2 + taxRate2;\n if (taxes.hasOwnProperty(key)) {\n taxes[key].amount += taxAmount2;\n } else {\n taxes[key] = {name: taxName2, rate:taxRate2, amount:taxAmount2};\n }\n }\n\n if (item.tax_name1 || item.tax_name2) {\n hasTaxes = true;\n }\n }\n\n invoice.subtotal_amount = total;\n\n var discount = 0;\n if (invoice.discount != 0) {\n if (parseInt(invoice.is_amount_discount)) {\n discount = roundToTwo(invoice.discount);\n } else {\n discount = roundToTwo(total * (invoice.discount/100));\n }\n total -= discount;\n }\n\n // custom fields with taxes\n if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {\n total += roundToTwo(invoice.custom_value1);\n }\n if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {\n total += roundToTwo(invoice.custom_value2);\n }\n\n taxRate1 = 0;\n taxRate2 = 0;\n if (invoice.tax_rate1 && parseFloat(invoice.tax_rate1)) {\n taxRate1 = parseFloat(invoice.tax_rate1);\n }\n if (invoice.tax_rate2 && parseFloat(invoice.tax_rate2)) {\n taxRate2 = parseFloat(invoice.tax_rate2);\n }\n taxAmount1 = roundToTwo(total * (taxRate1/100));\n taxAmount2 = roundToTwo(total * (taxRate2/100));\n total = total + taxAmount1 + taxAmount2;\n\n for (var key in taxes) {\n if (taxes.hasOwnProperty(key)) {\n total += taxes[key].amount;\n }\n }\n\n // custom fields w/o with taxes\n if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {\n total += roundToTwo(invoice.custom_value1);\n }\n if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {\n total += roundToTwo(invoice.custom_value2);\n }\n\n invoice.total_amount = roundToTwo(roundToTwo(total) - (roundToTwo(invoice.amount) - roundToTwo(invoice.balance)));\n invoice.discount_amount = discount;\n invoice.tax_amount1 = taxAmount1;\n invoice.tax_amount2 = taxAmount2;\n invoice.item_taxes = taxes;\n\n if (NINJA.parseFloat(invoice.partial)) {\n invoice.balance_amount = roundToTwo(invoice.partial);\n } else {\n invoice.balance_amount = invoice.total_amount;\n }\n\n return invoice;\n}\n\n// http://stackoverflow.com/questions/11941876/correctly-suppressing-warnings-in-datatables\nwindow.alert = (function() {\n var nativeAlert = window.alert;\n return function(message) {\n window.alert = nativeAlert;\n message && message.indexOf(\"DataTables warning\") === 0 ?\n console.error(message) :\n nativeAlert(message);\n }\n})();\n\n\n// http://stackoverflow.com/questions/1068834/object-comparison-in-javascript\nfunction objectEquals(x, y) {\n // if both are function\n if (x instanceof Function) {\n if (y instanceof Function) {\n return x.toString() === y.toString();\n }\n return false;\n }\n if (x === null || x === undefined || y === null || y === undefined) { return x === y; }\n if (x === y || x.valueOf() === y.valueOf()) { return true; }\n\n // if one of them is date, they must had equal valueOf\n if (x instanceof Date) { return false; }\n if (y instanceof Date) { return false; }\n\n // if they are not function or strictly equal, they both need to be Objects\n if (!(x instanceof Object)) { return false; }\n if (!(y instanceof Object)) { return false; }\n\n var p = Object.keys(x);\n return Object.keys(y).every(function (i) { return p.indexOf(i) !== -1; }) ?\n p.every(function (i) { return objectEquals(x[i], y[i]); }) : false;\n}\n\n\n\n/*\\\n|*|\n|*| Base64 / binary data / UTF-8 strings utilities\n|*|\n|*| https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding\n|*|\n\\*/\n\n/* Array of bytes to base64 string decoding */\n\nfunction b64ToUint6 (nChr) {\n\n return nChr > 64 && nChr < 91 ?\n nChr - 65\n : nChr > 96 && nChr < 123 ?\n nChr - 71\n : nChr > 47 && nChr < 58 ?\n nChr + 4\n : nChr === 43 ?\n 62\n : nChr === 47 ?\n 63\n :\n 0;\n\n}\n\nfunction base64DecToArr (sBase64, nBlocksSize) {\n\n var\n sB64Enc = sBase64.replace(/[^A-Za-z0-9\\+\\/]/g, \"\"), nInLen = sB64Enc.length,\n nOutLen = nBlocksSize ? Math.ceil((nInLen * 3 + 1 >> 2) / nBlocksSize) * nBlocksSize : nInLen * 3 + 1 >> 2, taBytes = new Uint8Array(nOutLen);\n\n for (var nMod3, nMod4, nUint24 = 0, nOutIdx = 0, nInIdx = 0; nInIdx < nInLen; nInIdx++) {\n nMod4 = nInIdx & 3;\n nUint24 |= b64ToUint6(sB64Enc.charCodeAt(nInIdx)) << 18 - 6 * nMod4;\n if (nMod4 === 3 || nInLen - nInIdx === 1) {\n for (nMod3 = 0; nMod3 < 3 && nOutIdx < nOutLen; nMod3++, nOutIdx++) {\n taBytes[nOutIdx] = nUint24 >>> (16 >>> nMod3 & 24) & 255;\n }\n nUint24 = 0;\n\n }\n }\n\n return taBytes;\n}\n\n/* Base64 string to array encoding */\n\nfunction uint6ToB64 (nUint6) {\n\n return nUint6 < 26 ?\n nUint6 + 65\n : nUint6 < 52 ?\n nUint6 + 71\n : nUint6 < 62 ?\n nUint6 - 4\n : nUint6 === 62 ?\n 43\n : nUint6 === 63 ?\n 47\n :\n 65;\n\n}\n\nfunction base64EncArr (aBytes) {\n\n var nMod3 = 2, sB64Enc = \"\";\n\n for (var nLen = aBytes.length, nUint24 = 0, nIdx = 0; nIdx < nLen; nIdx++) {\n nMod3 = nIdx % 3;\n if (nIdx > 0 && (nIdx * 4 / 3) % 76 === 0) { sB64Enc += \"\\r\\n\"; }\n nUint24 |= aBytes[nIdx] << (16 >>> nMod3 & 24);\n if (nMod3 === 2 || aBytes.length - nIdx === 1) {\n sB64Enc += String.fromCharCode(uint6ToB64(nUint24 >>> 18 & 63), uint6ToB64(nUint24 >>> 12 & 63), uint6ToB64(nUint24 >>> 6 & 63), uint6ToB64(nUint24 & 63));\n nUint24 = 0;\n }\n }\n\n return sB64Enc.substr(0, sB64Enc.length - 2 + nMod3) + (nMod3 === 2 ? '' : nMod3 === 1 ? '=' : '==');\n\n}\n\n/* UTF-8 array to DOMString and vice versa */\n\nfunction UTF8ArrToStr (aBytes) {\n\n var sView = \"\";\n\n for (var nPart, nLen = aBytes.length, nIdx = 0; nIdx < nLen; nIdx++) {\n nPart = aBytes[nIdx];\n sView += String.fromCharCode(\n nPart > 251 && nPart < 254 && nIdx + 5 < nLen ? /* six bytes */\n /* (nPart - 252 << 32) is not possible in ECMAScript! So...: */\n (nPart - 252) * 1073741824 + (aBytes[++nIdx] - 128 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128\n : nPart > 247 && nPart < 252 && nIdx + 4 < nLen ? /* five bytes */\n (nPart - 248 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128\n : nPart > 239 && nPart < 248 && nIdx + 3 < nLen ? /* four bytes */\n (nPart - 240 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128\n : nPart > 223 && nPart < 240 && nIdx + 2 < nLen ? /* three bytes */\n (nPart - 224 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128\n : nPart > 191 && nPart < 224 && nIdx + 1 < nLen ? /* two bytes */\n (nPart - 192 << 6) + aBytes[++nIdx] - 128\n : /* nPart < 127 ? */ /* one byte */\n nPart\n );\n }\n\n return sView;\n\n}\n\nfunction strToUTF8Arr (sDOMStr) {\n\n var aBytes, nChr, nStrLen = sDOMStr.length, nArrLen = 0;\n\n /* mapping... */\n\n for (var nMapIdx = 0; nMapIdx < nStrLen; nMapIdx++) {\n nChr = sDOMStr.charCodeAt(nMapIdx);\n nArrLen += nChr < 0x80 ? 1 : nChr < 0x800 ? 2 : nChr < 0x10000 ? 3 : nChr < 0x200000 ? 4 : nChr < 0x4000000 ? 5 : 6;\n }\n\n aBytes = new Uint8Array(nArrLen);\n\n /* transcription... */\n\n for (var nIdx = 0, nChrIdx = 0; nIdx < nArrLen; nChrIdx++) {\n nChr = sDOMStr.charCodeAt(nChrIdx);\n if (nChr < 128) {\n /* one byte */\n aBytes[nIdx++] = nChr;\n } else if (nChr < 0x800) {\n /* two bytes */\n aBytes[nIdx++] = 192 + (nChr >>> 6);\n aBytes[nIdx++] = 128 + (nChr & 63);\n } else if (nChr < 0x10000) {\n /* three bytes */\n aBytes[nIdx++] = 224 + (nChr >>> 12);\n aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);\n aBytes[nIdx++] = 128 + (nChr & 63);\n } else if (nChr < 0x200000) {\n /* four bytes */\n aBytes[nIdx++] = 240 + (nChr >>> 18);\n aBytes[nIdx++] = 128 + (nChr >>> 12 & 63);\n aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);\n aBytes[nIdx++] = 128 + (nChr & 63);\n } else if (nChr < 0x4000000) {\n /* five bytes */\n aBytes[nIdx++] = 248 + (nChr >>> 24);\n aBytes[nIdx++] = 128 + (nChr >>> 18 & 63);\n aBytes[nIdx++] = 128 + (nChr >>> 12 & 63);\n aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);\n aBytes[nIdx++] = 128 + (nChr & 63);\n } else /* if (nChr <= 0x7fffffff) */ {\n /* six bytes */\n aBytes[nIdx++] = 252 + /* (nChr >>> 32) is not possible in ECMAScript! So...: */ (nChr / 1073741824);\n aBytes[nIdx++] = 128 + (nChr >>> 24 & 63);\n aBytes[nIdx++] = 128 + (nChr >>> 18 & 63);\n aBytes[nIdx++] = 128 + (nChr >>> 12 & 63);\n aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);\n aBytes[nIdx++] = 128 + (nChr & 63);\n }\n }\n\n return aBytes;\n\n}\n\n\n\nfunction hexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}\nfunction hexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}\nfunction hexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}\nfunction cutHex(h) {return (h.charAt(0)==\"#\") ? h.substring(1,7):h}\nfunction setDocHexColor(doc, hex) {\n var r = hexToR(hex);\n var g = hexToG(hex);\n var b = hexToB(hex);\n return doc.setTextColor(r, g, b);\n}\nfunction setDocHexFill(doc, hex) {\n var r = hexToR(hex);\n var g = hexToG(hex);\n var b = hexToB(hex);\n return doc.setFillColor(r, g, b);\n}\nfunction setDocHexDraw(doc, hex) {\n var r = hexToR(hex);\n var g = hexToG(hex);\n var b = hexToB(hex);\n return doc.setDrawColor(r, g, b);\n}\n\nfunction toggleDatePicker(field) {\n $('#'+field).datepicker('show');\n}\n\nfunction roundToTwo(num, toString) {\n var val = +(Math.round(num + \"e+2\") + \"e-2\");\n return toString ? val.toFixed(2) : (val || 0);\n}\n\nfunction roundToFour(num, toString) {\n var val = +(Math.round(num + \"e+4\") + \"e-4\");\n return toString ? val.toFixed(4) : (val || 0);\n}\n\nfunction truncate(str, length) {\n return (str && str.length > length) ? (str.substr(0, length-1) + '...') : str;\n}\n\n// http://stackoverflow.com/questions/280634/endswith-in-javascript\nfunction endsWith(str, suffix) {\n return str.indexOf(suffix, str.length - suffix.length) !== -1;\n}\n\n// http://codeaid.net/javascript/convert-seconds-to-hours-minutes-and-seconds-%28javascript%29\nfunction secondsToTime(secs)\n{\n secs = Math.round(secs);\n var hours = Math.floor(secs / (60 * 60));\n\n var divisor_for_minutes = secs % (60 * 60);\n var minutes = Math.floor(divisor_for_minutes / 60);\n\n var divisor_for_seconds = divisor_for_minutes % 60;\n var seconds = Math.ceil(divisor_for_seconds);\n\n var obj = {\n \"h\": hours,\n \"m\": minutes,\n \"s\": seconds\n };\n return obj;\n}\n\nfunction twoDigits(value) {\n if (value < 10) {\n return '0' + value;\n }\n return value;\n}\n\nfunction toSnakeCase(str) {\n if (!str) return '';\n return str.replace(/([A-Z])/g, function($1){return \"_\"+$1.toLowerCase();});\n}\n\n// https://coderwall.com/p/iprsng/convert-snake-case-to-camelcase\nfunction snakeToCamel(s){\n return s.replace(/_([a-z])/g, function (g) { return g[1].toUpperCase(); });\n}\n\nfunction getDescendantProp(obj, desc) {\n var arr = desc.split(\".\");\n while(arr.length && (obj = obj[arr.shift()]));\n return obj;\n}\n\nfunction doubleDollarSign(str) {\n if (!str) return '';\n if (!str.replace) return str;\n return str.replace(/\\$/g, '\\$\\$\\$');\n}\n\nfunction truncate(string, length){\n if (string.length > length) {\n return string.substring(0, length) + '...';\n } else {\n return string;\n }\n};\n\n// Show/hide the 'Select' option in the datalists\nfunction actionListHandler() {\n $('tbody tr .tr-action').closest('tr').mouseover(function() {\n $(this).closest('tr').find('.tr-action').show();\n $(this).closest('tr').find('.tr-status').hide();\n }).mouseout(function() {\n $dropdown = $(this).closest('tr').find('.tr-action');\n if (!$dropdown.hasClass('open')) {\n $dropdown.hide();\n $(this).closest('tr').find('.tr-status').show();\n }\n });\n}\n\nfunction loadImages(selector) {\n $(selector + ' img').each(function(index, item) {\n var src = $(item).attr('data-src');\n $(item).attr('src', src);\n $(item).attr('data-src', src);\n });\n}\n\n// http://stackoverflow.com/questions/4810841/how-can-i-pretty-print-json-using-javascript\nfunction prettyJson(json) {\n if (typeof json != 'string') {\n json = JSON.stringify(json, undefined, 2);\n }\n json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n return json.replace(/(\"(\\\\u[a-zA-Z0-9]{4}|\\\\[^u]|[^\\\\\"])*\"(\\s*:)?|\\b(true|false|null)\\b|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)/g, function (match) {\n var cls = 'number';\n if (/^\"/.test(match)) {\n if (/:$/.test(match)) {\n cls = 'key';\n } else {\n cls = 'string';\n }\n } else if (/true|false/.test(match)) {\n cls = 'boolean';\n } else if (/null/.test(match)) {\n cls = 'null';\n }\n match = snakeToCamel(match);\n return '<span class=\"' + cls + '\">' + match + '</span>';\n });\n}\n\nfunction searchData(data, key, fuzzy) {\n return function findMatches(q, cb) {\n var matches, substringRegex;\n if (fuzzy) {\n var options = {\n keys: [key],\n }\n var fuse = new Fuse(data, options);\n matches = fuse.search(q);\n } else {\n matches = [];\n substrRegex = new RegExp(escapeRegExp(q), 'i');\n $.each(data, function(i, obj) {\n if (substrRegex.test(obj[key])) {\n matches.push(obj);\n }\n });\n }\n cb(matches);\n }\n};\n\nfunction escapeRegExp(str) {\n return str.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\");\n}\n"],"sourceRoot":"/source/"} |