diff --git a/app.config b/app.config new file mode 100644 index 0000000000..8c2c664cdb --- /dev/null +++ b/app.config @@ -0,0 +1,30 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dashboard-ui/advancedserversettings.html b/dashboard-ui/advancedserversettings.html index ca6b67699f..af0d734972 100644 --- a/dashboard-ui/advancedserversettings.html +++ b/dashboard-ui/advancedserversettings.html @@ -18,11 +18,6 @@
    -
  • - - -
    This name will be used to identify this server. If left blank, the computer name will be used.
    -
  • diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index 5d12dd51a2..967e31fb83 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -1204,16 +1204,16 @@ a.itemTag:hover { width: 250px; } -.ui-panel-dismiss-open.ui-panel-dismiss-position-right[data-panelid=playerSelectionPanel] { - right: 250px; -} + .playerSelectionPanel + .ui-panel-dismiss { + right: 250px; + } @media all and (min-width: 600px) { .playerSelectionPanel { width: 300px; } - .ui-panel-dismiss-open.ui-panel-dismiss-position-right[data-panelid=playerSelectionPanel] { - right: 300px; - } -} \ No newline at end of file + .playerSelectionPanel + .ui-panel-dismiss { + right: 300px; + } +} diff --git a/dashboard-ui/css/posteritem.css b/dashboard-ui/css/posteritem.css index 9861a98a7b..5367c2ba2e 100644 --- a/dashboard-ui/css/posteritem.css +++ b/dashboard-ui/css/posteritem.css @@ -161,6 +161,14 @@ height: 144px; } +.bannerPosterItem { + width: 280px; +} + + .bannerPosterItem .posterItemImage { + height: 51.8px; + } + .posterItemProgress .itemProgressBar { height: 10px; width: 100%; @@ -263,6 +271,14 @@ .smallBackdropPosterItem .posterItemImage { height: 113.625px; } + + .bannerPosterItem { + width: 300px; + } + + .bannerPosterItem .posterItemImage { + height: 55.5px; + } } @media all and (min-width: 750px) { @@ -274,6 +290,14 @@ .portraitPosterItem .posterItemImage { height: 177px; } + + .bannerPosterItem { + width: 330px; + } + + .bannerPosterItem .posterItemImage { + height: 61.05px; + } } @media all and (min-width: 1000px) { @@ -301,6 +325,14 @@ .storeReviewCount { display: inline; } + + .bannerPosterItem { + width: 500px; + } + + .bannerPosterItem .posterItemImage { + height: 92.5px; + } } @media all and (min-width: 1440px) { @@ -320,4 +352,4 @@ .backdropPosterItem .posterItemImage { height: 167.625px; } -} \ No newline at end of file +} diff --git a/dashboard-ui/css/search.css b/dashboard-ui/css/search.css index 147a96cdab..00fe0ac8e6 100644 --- a/dashboard-ui/css/search.css +++ b/dashboard-ui/css/search.css @@ -2,18 +2,18 @@ width: 250px; } -.ui-panel-dismiss-open.ui-panel-dismiss-position-right[data-panelid=searchPanel] { - right: 250px; -} + .searchPanel + .ui-panel-dismiss { + right: 250px; + } @media all and (min-width: 600px) { .searchPanel { width: 300px; } - .ui-panel-dismiss-open.ui-panel-dismiss-position-right[data-panelid=searchPanel] { - right: 300px; - } + .searchPanel + .ui-panel-dismiss { + right: 300px; + } } .searchHints { diff --git a/dashboard-ui/dashboard.html b/dashboard-ui/dashboard.html index 447d6d35a9..3f1f80402c 100644 --- a/dashboard-ui/dashboard.html +++ b/dashboard-ui/dashboard.html @@ -11,6 +11,7 @@ @@ -122,4 +123,4 @@ - \ No newline at end of file + diff --git a/dashboard-ui/dashboardgeneral.html b/dashboard-ui/dashboardgeneral.html new file mode 100644 index 0000000000..2038311ef3 --- /dev/null +++ b/dashboard-ui/dashboardgeneral.html @@ -0,0 +1,56 @@ + + + + Dashboard + + +
    + +
    +
    + +
    + Home + General + Info +
    + + + +
      +
    • + + +
      This name will be used to identify this server. If left blank, the computer name will be used.
      +
    • +
    • + + +
      Translating Media Browser is an ongoing project. Read about how you can contribute.
      +
    • +
    +
      +
    • + + +
    • + +
    + + +
    +
    + + + + +
    + + diff --git a/dashboard-ui/dashboardinfopage.html b/dashboard-ui/dashboardinfopage.html index 14dd7e3441..71e3f1e2f7 100644 --- a/dashboard-ui/dashboardinfopage.html +++ b/dashboard-ui/dashboardinfopage.html @@ -12,6 +12,7 @@ diff --git a/dashboard-ui/scripts/advancedserversettings.js b/dashboard-ui/scripts/advancedserversettings.js index a73b124f5b..0cccc9eccd 100644 --- a/dashboard-ui/scripts/advancedserversettings.js +++ b/dashboard-ui/scripts/advancedserversettings.js @@ -14,7 +14,6 @@ $('#txtPortNumber', page).val(config.HttpServerPortNumber); $('#txtDdns', page).val(config.WanDdns || ''); - $('#txtServerName', page).val(config.ServerName || ''); $('#chkEnableUpnp', page).checked(config.EnableUPnP).checkboxradio('refresh'); @@ -53,7 +52,6 @@ config.EnableUPnP = $('#chkEnableUpnp', form).checked(); config.WanDdns = $('#txtDdns', form).val(); - config.ServerName = $('#txtServerName', form).val(); ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); }); diff --git a/dashboard-ui/scripts/dashboardgeneral.js b/dashboard-ui/scripts/dashboardgeneral.js new file mode 100644 index 0000000000..84058a5138 --- /dev/null +++ b/dashboard-ui/scripts/dashboardgeneral.js @@ -0,0 +1,55 @@ +(function ($, document, window) { + + function loadPage(page, config, languageOptions) { + + $('#txtServerName', page).val(config.ServerName || ''); + + $('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) { + + return ''; + + })).val(config.UICulture).selectmenu('refresh'); + + Dashboard.hideLoadingMsg(); + } + + $(document).on('pageshow', "#dashboardGeneralPage", function () { + + Dashboard.showLoadingMsg(); + + var page = this; + + var promise1 = ApiClient.getServerConfiguration(); + + var promise2 = $.getJSON(ApiClient.getUrl("Localization/Options")); + + $.when(promise1, promise2).done(function (response1, response2) { + + loadPage(page, response1[0], response2[0]); + + }); + + }); + + window.DashboardGeneralPage = { + + onSubmit: function () { + Dashboard.showLoadingMsg(); + + var form = this; + + ApiClient.getServerConfiguration().done(function (config) { + + config.ServerName = $('#txtServerName', form).val(); + config.UICulture = $('#selectLocalizationLanguage', form).val(); + + ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + }); + + // Disable default form submission + return false; + } + + }; + +})(jQuery, document, window); diff --git a/dashboard-ui/scripts/extensions.js b/dashboard-ui/scripts/extensions.js index 1772df5a11..da81f7ea1f 100644 --- a/dashboard-ui/scripts/extensions.js +++ b/dashboard-ui/scripts/extensions.js @@ -1,5 +1,5 @@ function IsStorageEnabled() { - + if (!window.localStorage) { return false; } @@ -36,7 +36,7 @@ $.fn.checked = function (value) { } }; -$.fn.buttonEnabled = function(enabled) { +$.fn.buttonEnabled = function (enabled) { return enabled ? this.attr('disabled', '').removeAttr('disabled') : this.attr('disabled', 'disabled'); }; @@ -132,8 +132,8 @@ var WebNotifications = { } } }, - - supported: function() { + + supported: function () { return window.Notification || window.webkitNotifications; } }; @@ -460,4 +460,20 @@ function ticks_to_human(str) { }; }); -})(); \ No newline at end of file +})(); + +(function (window) { + + // Mimic Globalize api + // https://github.com/jquery/globalize + // Maybe later switch to it + + window.Globalize = { + translate: function (key) { + + return window.localizationGlossary[key] || key; + + } + }; + +})(window); \ No newline at end of file diff --git a/dashboard-ui/scripts/itemdetailpage.js b/dashboard-ui/scripts/itemdetailpage.js index 50b0ec2a27..a8b379c945 100644 --- a/dashboard-ui/scripts/itemdetailpage.js +++ b/dashboard-ui/scripts/itemdetailpage.js @@ -103,8 +103,6 @@ $('#missingIndicator', page).hide(); } - $(".autoNumeric").autoNumeric('init'); - setPeopleHeader(page, item); if (ApiClient.isWebSocketOpen()) { diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 9a29a6507a..93d74e1cf3 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -508,6 +508,15 @@ tag: item.ImageTags.Thumb }); + } + else if (options.preferBanner && item.ImageTags && item.ImageTags.Banner) { + + imgUrl = ApiClient.getImageUrl(item.Id, { + type: "Banner", + maxwidth: 1200, + tag: item.ImageTags.Banner + }); + } else if (options.preferThumb && item.SeriesThumbImageTag) { @@ -1683,7 +1692,7 @@ renderBudget: function (elem, item) { if (item.Budget) { - elem.show().html('Budget:  $' + item.Budget + ''); + elem.show().html('Budget:  $' + item.Budget + ''); } else { elem.hide(); } @@ -1692,7 +1701,7 @@ renderRevenue: function (elem, item) { if (item.Revenue) { - elem.show().html('Revenue:  $' + item.Revenue + ''); + elem.show().html('Revenue:  $' + item.Revenue + ''); } else { elem.hide(); } diff --git a/dashboard-ui/scripts/tvshows.js b/dashboard-ui/scripts/tvshows.js index 12cfa73aa4..da8f0fb630 100644 --- a/dashboard-ui/scripts/tvshows.js +++ b/dashboard-ui/scripts/tvshows.js @@ -39,6 +39,16 @@ $('.itemsContainer', page).removeClass('timelineItemsContainer'); } + else if (view == "Banner") { + + html = LibraryBrowser.getPosterViewHtml({ + items: result.Items, + shape: "banner", + preferBanner: true, + context: 'tv' + }); + $('.itemsContainer', page).removeClass('timelineItemsContainer'); + } else if (view == "Poster") { html = LibraryBrowser.getPosterViewHtml({ diff --git a/dashboard-ui/scripts/useredit.js b/dashboard-ui/scripts/useredit.js index 5db0bc314b..cef7aeac24 100644 --- a/dashboard-ui/scripts/useredit.js +++ b/dashboard-ui/scripts/useredit.js @@ -12,7 +12,7 @@ $('#featureAccessFields', page).show(); } - Dashboard.setPageTitle(user.Name || "Add User"); + Dashboard.setPageTitle(user.Name || Globalize.translate("AddUser")); $('#txtUserName', page).val(user.Name); @@ -40,7 +40,7 @@ Dashboard.validateCurrentUser(page); if (userId) { - Dashboard.alert("Settings saved."); + Dashboard.alert(Globalize.translate("SettingsSaved")); } else { Dashboard.navigate("userprofiles.html"); } diff --git a/dashboard-ui/scripts/userimagepage.js b/dashboard-ui/scripts/userimagepage.js index 868f164764..f3b6196f79 100644 --- a/dashboard-ui/scripts/userimagepage.js +++ b/dashboard-ui/scripts/userimagepage.js @@ -53,15 +53,15 @@ switch (evt.target.error.code) { case evt.target.error.NOT_FOUND_ERR: - Dashboard.showError('File Not Found!'); + Dashboard.showError(Globalize.translate("FileNotFound")); break; case evt.target.error.NOT_READABLE_ERR: - Dashboard.showError('File is not readable'); + Dashboard.showError(Globalize.translate("FileReadError")); break; case evt.target.error.ABORT_ERR: break; // noop default: - Dashboard.showError('An error occurred reading this file.'); + Dashboard.showError(Globalize.translate("FileReadError")); }; } @@ -73,7 +73,7 @@ function onFileReaderAbort(evt) { Dashboard.hideLoadingMsg(); - Dashboard.showError('File read cancelled'); + Dashboard.showError(Globalize.translate("FileReadCancelled")); } function setFiles(page, files) { @@ -156,7 +156,7 @@ self.deleteImage = function () { - Dashboard.confirm("Are you sure you wish to delete the image?", "Delete Image", function (result) { + Dashboard.confirm(Globalize.translate("DeleteImageConfirmation"), Globalize.translate("DeleteImage"), function (result) { if (result) { diff --git a/dashboard-ui/scripts/userparentalcontrol.js b/dashboard-ui/scripts/userparentalcontrol.js index 55a2883a6e..4887361ada 100644 --- a/dashboard-ui/scripts/userparentalcontrol.js +++ b/dashboard-ui/scripts/userparentalcontrol.js @@ -134,7 +134,7 @@ Dashboard.validateCurrentUser(page); - Dashboard.alert("Settings saved."); + Dashboard.alert(Globalize.translate("SettingsSaved")); } function saveUser(user, page) { diff --git a/dashboard-ui/scripts/userpassword.js b/dashboard-ui/scripts/userpassword.js index 01e5a32427..e659d26add 100644 --- a/dashboard-ui/scripts/userpassword.js +++ b/dashboard-ui/scripts/userpassword.js @@ -15,7 +15,7 @@ } else { $('#btnResetPassword', page).hide(); $('#fldCurrentPassword', page).hide(); - $('.formheader', page).html('Create Password').show(); + $('.formheader', page).html(Globalize.translate("CreatePassword")).show(); } }); @@ -36,7 +36,7 @@ Dashboard.hideLoadingMsg(); - Dashboard.alert("Password saved."); + Dashboard.alert(Globalize.translate("PasswordSaved")); loadUser(page); }); @@ -53,7 +53,7 @@ if ($('#txtNewPassword', page).val() != $('#txtNewPasswordConfirm', page).val()) { - Dashboard.showError("Password and password confirmation must match."); + Dashboard.showError(Globalize.translate("PasswordMatchError")); return false; } @@ -68,11 +68,11 @@ self.resetPassword = function () { - var msg = "Are you sure you wish to reset the password?"; + var msg = Globalize.translate("PasswordResetConfirmation"); var page = $.mobile.activePage; - Dashboard.confirm(msg, "Password Reset", function (result) { + Dashboard.confirm(msg, Globalize.translate("PasswordResetHeader"), function (result) { if (result) { var userId = getParameterByName("userId"); @@ -84,10 +84,10 @@ Dashboard.hideLoadingMsg(); Dashboard.alert({ - message: "The password has been reset.", - title: "Password Reset" + message: Globalize.translate("PasswordResetComplete"), + title: Globalize.translate("PasswordResetHeader") }); - + loadUser(page); }); diff --git a/dashboard-ui/scripts/userprofilespage.js b/dashboard-ui/scripts/userprofilespage.js index da6f80d9f2..854b7437c1 100644 --- a/dashboard-ui/scripts/userprofilespage.js +++ b/dashboard-ui/scripts/userprofilespage.js @@ -14,7 +14,7 @@ var html = ""; - html += '
  • Users

  • '; + html += '
  • ' + Globalize.translate("Users") + '

  • '; for (var i = 0, length = users.length; i < length; i++) { @@ -41,15 +41,15 @@ html += ""; html += "

    "; - if (user.Configuration.HasPassword) html += 'Password'; - if (user.Configuration.IsAdministrator) html += 'Administrator'; + if (user.Configuration.HasPassword) html += '' + Globalize.translate('; + if (user.Configuration.IsAdministrator) html += '' + Globalize.translate('; html += "

    "; html += ""; - html += "Delete"; + html += "" + Globalize.translate("Delete") + ""; html += ""; } @@ -64,9 +64,9 @@ var page = $.mobile.activePage; var name = link.getAttribute('data-username'); - var msg = "Are you sure you wish to delete " + name + "?"; + var msg = Globalize.translate("DeleteUserConfirmation").replace('{0}', name); - Dashboard.confirm(msg, "Delete User", function (result) { + Dashboard.confirm(msg, Globalize.translate("DeleteUser"), function (result) { if (result) { Dashboard.showLoadingMsg(); diff --git a/dashboard-ui/scripts/usersettings.js b/dashboard-ui/scripts/usersettings.js index be20a3da53..1b4a595c48 100644 --- a/dashboard-ui/scripts/usersettings.js +++ b/dashboard-ui/scripts/usersettings.js @@ -29,7 +29,7 @@ Dashboard.validateCurrentUser(page); if (userId) { - Dashboard.alert("Settings saved."); + Dashboard.alert(Globalize.translate("SettingsSaved")); } else { Dashboard.navigate("userprofiles.html"); } diff --git a/dashboard-ui/thirdparty/autonumeric/autoNumeric.js b/dashboard-ui/thirdparty/autonumeric/autoNumeric.js deleted file mode 100644 index b57495f68f..0000000000 --- a/dashboard-ui/thirdparty/autonumeric/autoNumeric.js +++ /dev/null @@ -1,1250 +0,0 @@ -/** -* autoNumeric.js -* @author: Bob Knothe -* @author: Sokolov Yura aka funny_falcon -* @version: 1.9.18 - 2013-12-03 GMT 9:00 PM -* -* Created by Robert J. Knothe on 2010-10-25. Please report any bugs to https://github.com/BobKnothe/autoNumeric -* Created by Sokolov Yura on 2010-11-07 -* -* Copyright (c) 2011 Robert J. Knothe http://www.decorplanit.com/plugin/ -* -* The MIT License (http://www.opensource.org/licenses/mit-license.php) -* -* Permission is hereby granted, free of charge, to any person -* obtaining a copy of this software and associated documentation -* files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, -* copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following -* conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -*/ -(function ($) { - "use strict"; - /*jslint browser: true*/ - /*global jQuery: false*/ - /* Cross browser routine for getting selected range/cursor position - */ - function getElementSelection(that) { - var position = {}; - if (that.selectionStart === undefined) { - that.focus(); - var select = document.selection.createRange(); - position.length = select.text.length; - select.moveStart('character', -that.value.length); - position.end = select.text.length; - position.start = position.end - position.length; - } else { - position.start = that.selectionStart; - position.end = that.selectionEnd; - position.length = position.end - position.start; - } - return position; - } - /** - * Cross browser routine for setting selected range/cursor position - */ - function setElementSelection(that, start, end) { - if (that.selectionStart === undefined) { - that.focus(); - var r = that.createTextRange(); - r.collapse(true); - r.moveEnd('character', end); - r.moveStart('character', start); - r.select(); - } else { - that.selectionStart = start; - that.selectionEnd = end; - } - } - /** - * run callbacks in parameters if any - * any parameter could be a callback: - * - a function, which invoked with jQuery element, parameters and this parameter name and returns parameter value - * - a name of function, attached to $(selector).autoNumeric.functionName(){} - which was called previously - */ - function runCallbacks($this, settings) { - /** - * loops through the settings object (option array) to find the following - * k = option name example k=aNum - * val = option value example val=0123456789 - */ - $.each(settings, function (k, val) { - if (typeof val === 'function') { - settings[k] = val($this, settings, k); - } else if (typeof $this.autoNumeric[val] === 'function') { - /** - * calls the attached function from the html5 data example: data-a-sign="functionName" - */ - settings[k] = $this.autoNumeric[val]($this, settings, k); - } - }); - } - function convertKeyToNumber(settings, key) { - if (typeof (settings[key]) === 'string') { - settings[key] *= 1; - } - } - /** - * Preparing user defined options for further usage - * merge them with defaults appropriately - */ - function autoCode($this, settings) { - runCallbacks($this, settings); - settings.oEvent = null; - settings.tagList = ['B', 'CAPTION', 'CITE', 'CODE', 'DD', 'DEL', 'DIV', 'DFN', 'DT', 'EM', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'INS', 'KDB', 'LABEL', 'LI', 'OUTPUT', 'P', 'Q', 'S', 'SAMPLE', 'SPAN', 'STRONG', 'TD', 'TH', 'U', 'VAR']; - var vmax = settings.vMax.toString().split('.'), - vmin = (!settings.vMin && settings.vMin !== 0) ? [] : settings.vMin.toString().split('.'); - convertKeyToNumber(settings, 'vMax'); - convertKeyToNumber(settings, 'vMin'); - convertKeyToNumber(settings, 'mDec'); /** set mDec if not defained by user */ - settings.allowLeading = true; - settings.aNeg = settings.vMin < 0 ? '-' : ''; - vmax[0] = vmax[0].replace('-', ''); - vmin[0] = vmin[0].replace('-', ''); - settings.mInt = Math.max(vmax[0].length, vmin[0].length, 1); - if (settings.mDec === null) { - var vmaxLength = 0, - vminLength = 0; - if (vmax[1]) { - vmaxLength = vmax[1].length; - } - if (vmin[1]) { - vminLength = vmin[1].length; - } - settings.mDec = Math.max(vmaxLength, vminLength); - } /** set alternative decimal separator key */ - if (settings.altDec === null && settings.mDec > 0) { - if (settings.aDec === '.' && settings.aSep !== ',') { - settings.altDec = ','; - } else if (settings.aDec === ',' && settings.aSep !== '.') { - settings.altDec = '.'; - } - } - /** cache regexps for autoStrip */ - var aNegReg = settings.aNeg ? '([-\\' + settings.aNeg + ']?)' : '(-?)'; - settings.aNegRegAutoStrip = aNegReg; - settings.skipFirstAutoStrip = new RegExp(aNegReg + '[^-' + (settings.aNeg ? '\\' + settings.aNeg : '') + '\\' + settings.aDec + '\\d]' + '.*?(\\d|\\' + settings.aDec + '\\d)'); - settings.skipLastAutoStrip = new RegExp('(\\d\\' + settings.aDec + '?)[^\\' + settings.aDec + '\\d]\\D*$'); - var allowed = '-' + settings.aNum + '\\' + settings.aDec; - settings.allowedAutoStrip = new RegExp('[^' + allowed + ']', 'gi'); - settings.numRegAutoStrip = new RegExp(aNegReg + '(?:\\' + settings.aDec + '?(\\d+\\' + settings.aDec + '\\d+)|(\\d*(?:\\' + settings.aDec + '\\d*)?))'); - return settings; - } - /** - * strip all unwanted characters and leave only a number alert - */ - function autoStrip(s, settings, strip_zero) { - if (settings.aSign) { /** remove currency sign */ - while (s.indexOf(settings.aSign) > -1) { - s = s.replace(settings.aSign, ''); - } - } - s = s.replace(settings.skipFirstAutoStrip, '$1$2'); /** first replace anything before digits */ - s = s.replace(settings.skipLastAutoStrip, '$1'); /** then replace anything after digits */ - s = s.replace(settings.allowedAutoStrip, ''); /** then remove any uninterested characters */ - if (settings.altDec) { - s = s.replace(settings.altDec, settings.aDec); - } /** get only number string */ - var m = s.match(settings.numRegAutoStrip); - s = m ? [m[1], m[2], m[3]].join('') : ''; - if ((settings.lZero === 'allow' || settings.lZero === 'keep') && strip_zero !== 'strip') { - var parts = [], - nSign = ''; - parts = s.split(settings.aDec); - if (parts[0].indexOf('-') !== -1) { - nSign = '-'; - parts[0] = parts[0].replace('-', ''); - } - if (parts[0].length > settings.mInt && parts[0].charAt(0) === '0') { /** strip leading zero if need */ - parts[0] = parts[0].slice(1); - } - s = nSign + parts.join(settings.aDec); - } - if ((strip_zero && settings.lZero === 'deny') || (strip_zero && settings.lZero === 'allow' && settings.allowLeading === false)) { - var strip_reg = '^' + settings.aNegRegAutoStrip + '0*(\\d' + (strip_zero === 'leading' ? ')' : '|$)'); - strip_reg = new RegExp(strip_reg); - s = s.replace(strip_reg, '$1$2'); - } - return s; - } - /** - * places or removes brackets on negative values - */ - function negativeBracket(s, nBracket, oEvent) { /** oEvent = settings.oEvent */ - nBracket = nBracket.split(','); - if (oEvent === 'set' || oEvent === 'focusout') { - s = s.replace('-', ''); - s = nBracket[0] + s + nBracket[1]; - } else if ((oEvent === 'get' || oEvent === 'focusin' || oEvent === 'pageLoad') && s.charAt(0) === nBracket[0]) { - s = s.replace(nBracket[0], '-'); - s = s.replace(nBracket[1], ''); - } - return s; - } - /** - * truncate decimal part of a number - */ - function truncateDecimal(s, aDec, mDec) { - if (aDec && mDec) { - var parts = s.split(aDec); - /** truncate decimal part to satisfying length - * cause we would round it anyway */ - if (parts[1] && parts[1].length > mDec) { - if (mDec > 0) { - parts[1] = parts[1].substring(0, mDec); - s = parts.join(aDec); - } else { - s = parts[0]; - } - } - } - return s; - } - /** - * prepare number string to be converted to real number - */ - function fixNumber(s, aDec, aNeg) { - if (aDec && aDec !== '.') { - s = s.replace(aDec, '.'); - } - if (aNeg && aNeg !== '-') { - s = s.replace(aNeg, '-'); - } - if (!s.match(/\d/)) { - s += '0'; - } - return s; - } - /** - * function to handle numbers less than 0 that are stored in Exponential notation ex: .0000001 stored as 1e-7 - */ - function checkValue(value, settings) { - var decimal = value.indexOf('.'), - checkSmall = +value; - if (decimal !== -1) { - if (checkSmall < 0.000001 && checkSmall > -1) { - value = +value; - if (value < 0.000001 && value > 0) { - value = (value + 10).toString(); - value = value.substring(1); - } - if (value < 0 && value > -1) { - value = (value - 10).toString(); - value = '-' + value.substring(2); - } - value = value.toString(); - } else { - var parts = value.split('.'); - if (parts[1] !== undefined) { - if (+parts[1] === 0) { - value = parts[0]; - } else { - parts[1] = parts[1].replace(/0*$/, ''); - value = parts.join('.'); - } - } - } - } - return (settings.lZero === 'keep') ? value : value.replace(/^0*(\d)/, '$1'); - } - /** - * prepare real number to be converted to our format - */ - function presentNumber(s, aDec, aNeg) { - if (aNeg && aNeg !== '-') { - s = s.replace('-', aNeg); - } - if (aDec && aDec !== '.') { - s = s.replace('.', aDec); - } - return s; - } - /** - * checking that number satisfy format conditions - * and lays between settings.vMin and settings.vMax - * and the string length does not exceed the digits in settings.vMin and settings.vMax - */ - function autoCheck(s, settings) { - s = autoStrip(s, settings); - s = truncateDecimal(s, settings.aDec, settings.mDec); - s = fixNumber(s, settings.aDec, settings.aNeg); - var value = +s; - if (settings.oEvent === 'set' && (value < settings.vMin || value > settings.vMax)) { - $.error("The value (" + value + ") from the 'set' method falls outside of the vMin / vMax range"); - } - return value >= settings.vMin && value <= settings.vMax; - } - /** - * private function to check for empty value - */ - function checkEmpty(iv, settings, signOnEmpty) { - if (iv === '' || iv === settings.aNeg) { - if (settings.wEmpty === 'zero') { - return iv + '0'; - } - if (settings.wEmpty === 'sign' || signOnEmpty) { - return iv + settings.aSign; - } - return iv; - } - return null; - } - /** - * private function that formats our number - */ - function autoGroup(iv, settings) { - iv = autoStrip(iv, settings); - var testNeg = iv.replace(',', '.'), - empty = checkEmpty(iv, settings, true); - if (empty !== null) { - return empty; - } - var digitalGroup = ''; - if (settings.dGroup === 2) { - digitalGroup = /(\d)((\d)(\d{2}?)+)$/; - } else if (settings.dGroup === 4) { - digitalGroup = /(\d)((\d{4}?)+)$/; - } else { - digitalGroup = /(\d)((\d{3}?)+)$/; - } /** splits the string at the decimal string */ - var ivSplit = iv.split(settings.aDec); - if (settings.altDec && ivSplit.length === 1) { - ivSplit = iv.split(settings.altDec); - } /** assigns the whole number to the a varibale (s) */ - var s = ivSplit[0]; - if (settings.aSep) { - while (digitalGroup.test(s)) { /** re-inserts the thousand sepparator via a regualer expression */ - s = s.replace(digitalGroup, '$1' + settings.aSep + '$2'); - } - } - if (settings.mDec !== 0 && ivSplit.length > 1) { - if (ivSplit[1].length > settings.mDec) { - ivSplit[1] = ivSplit[1].substring(0, settings.mDec); - } /** joins the whole number with the deciaml value */ - iv = s + settings.aDec + ivSplit[1]; - } else { /** if whole numbers only */ - iv = s; - } - if (settings.aSign) { - var has_aNeg = iv.indexOf(settings.aNeg) !== -1; - iv = iv.replace(settings.aNeg, ''); - iv = settings.pSign === 'p' ? settings.aSign + iv : iv + settings.aSign; - if (has_aNeg) { - iv = settings.aNeg + iv; - } - } - if (settings.oEvent === 'set' && testNeg < 0 && settings.nBracket !== null) { /** removes the negative sign and places brackets */ - iv = negativeBracket(iv, settings.nBracket, settings.oEvent); - } - return iv; - } - /** - * round number after setting by pasting or $().autoNumericSet() - * private function for round the number - * please note this handled as text - JavaScript math function can return inaccurate values - * also this offers multiple rounding methods that are not easily accomplished in JavaScript - */ - function autoRound(iv, settings) { /** value to string */ - iv = (iv === '') ? '0' : iv.toString(); - convertKeyToNumber(settings, 'mDec'); /** set mDec to number needed when mDec set by 'update method */ - var ivRounded = '', - i = 0, - nSign = '', - rDec = (typeof (settings.aPad) === 'boolean' || settings.aPad === null) ? (settings.aPad ? settings.mDec : 0) : +settings.aPad; - var truncateZeros = function (ivRounded) { /** truncate not needed zeros */ - var regex = rDec === 0 ? (/(\.[1-9]*)0*$/) : rDec === 1 ? (/(\.\d[1-9]*)0*$/) : new RegExp('(\\.\\d{' + rDec + '}[1-9]*)0*$'); - ivRounded = ivRounded.replace(regex, '$1'); /** If there are no decimal places, we don't need a decimal point at the end */ - if (rDec === 0) { - ivRounded = ivRounded.replace(/\.$/, ''); - } - return ivRounded; - }; - if (iv.charAt(0) === '-') { /** Checks if the iv (input Value)is a negative value */ - nSign = '-'; /** removes the negative sign will be added back later if required */ - iv = iv.replace('-', ''); - } /** prepend a zero if first character is not a digit (then it is likely to be a dot)*/ - if (!iv.match(/^\d/)) { - iv = '0' + iv; - } /** determines if the value is zero - if zero no negative sign */ - if (nSign === '-' && +iv === 0) { - nSign = ''; - } - if ((+iv > 0 && settings.lZero !== 'keep') || (iv.length > 0 && settings.lZero === 'allow')) { /** trims leading zero's if needed */ - iv = iv.replace(/^0*(\d)/, '$1'); - } - var dPos = iv.lastIndexOf('.'), /** virtual decimal position */ - vdPos = dPos === -1 ? iv.length - 1 : dPos, /** checks decimal places to determine if rounding is required */ - cDec = (iv.length - 1) - vdPos; /** check if no rounding is required */ - if (cDec <= settings.mDec) { - ivRounded = iv; /** check if we need to pad with zeros */ - if (cDec < rDec) { - if (dPos === -1) { - ivRounded += '.'; - } - while (cDec < rDec) { - var zeros = '000000'.substring(0, rDec - cDec); - ivRounded += zeros; - cDec += zeros.length; - } - } else if (cDec > rDec) { - ivRounded = truncateZeros(ivRounded); - } else if (cDec === 0 && rDec === 0) { - ivRounded = ivRounded.replace(/\.$/, ''); - } - return nSign + ivRounded; - } /** rounded length of the string after rounding */ - var rLength = dPos + settings.mDec, /** test round */ - tRound = +iv.charAt(rLength + 1), - ivArray = iv.substring(0, rLength + 1).split(''), - odd = (iv.charAt(rLength) === '.') ? (iv.charAt(rLength - 1) % 2) : (iv.charAt(rLength) % 2); - if ((tRound > 4 && settings.mRound === 'S') || (tRound > 4 && settings.mRound === 'A' && nSign === '') || (tRound > 5 && settings.mRound === 'A' && nSign === '-') || (tRound > 5 && settings.mRound === 's') || (tRound > 5 && settings.mRound === 'a' && nSign === '') || (tRound > 4 && settings.mRound === 'a' && nSign === '-') || (tRound > 5 && settings.mRound === 'B') || (tRound === 5 && settings.mRound === 'B' && odd === 1) || (tRound > 0 && settings.mRound === 'C' && nSign === '') || (tRound > 0 && settings.mRound === 'F' && nSign === '-') || (tRound > 0 && settings.mRound === 'U')) { - /** Round up the last digit if required, and continue until no more 9's are found */ - for (i = (ivArray.length - 1) ; i >= 0; i -= 1) { - if (ivArray[i] !== '.') { - ivArray[i] = +ivArray[i] + 1; - if (ivArray[i] < 10) { - break; - } - if (i > 0) { - ivArray[i] = '0'; - } - } - } - } /** Reconstruct the string, converting any 10's to 0's */ - ivArray = ivArray.slice(0, rLength + 1); - ivRounded = truncateZeros(ivArray.join('')); /** return rounded value */ - return (+ivRounded === 0) ? ivRounded : nSign + ivRounded; - } - /** - * Holder object for field properties - */ - function AutoNumericHolder(that, settings) { - this.settings = settings; - this.that = that; - this.$that = $(that); - this.formatted = false; - this.settingsClone = autoCode(this.$that, this.settings); - this.value = that.value; - } - AutoNumericHolder.prototype = { - init: function (e) { - this.value = this.that.value; - this.settingsClone = autoCode(this.$that, this.settings); - this.ctrlKey = e.ctrlKey; - this.cmdKey = e.metaKey; - this.shiftKey = e.shiftKey; - this.selection = getElementSelection(this.that); /** keypress event overwrites meaningful value of e.keyCode */ - if (e.type === 'keydown' || e.type === 'keyup') { - this.kdCode = e.keyCode; - } - this.which = e.which; - this.processed = false; - this.formatted = false; - }, - setSelection: function (start, end, setReal) { - start = Math.max(start, 0); - end = Math.min(end, this.that.value.length); - this.selection = { - start: start, - end: end, - length: end - start - }; - if (setReal === undefined || setReal) { - setElementSelection(this.that, start, end); - } - }, - setPosition: function (pos, setReal) { - this.setSelection(pos, pos, setReal); - }, - getBeforeAfter: function () { - var value = this.value, - left = value.substring(0, this.selection.start), - right = value.substring(this.selection.end, value.length); - return [left, right]; - }, - getBeforeAfterStriped: function () { - var parts = this.getBeforeAfter(); - parts[0] = autoStrip(parts[0], this.settingsClone); - parts[1] = autoStrip(parts[1], this.settingsClone); - return parts; - }, - /** - * strip parts from excess characters and leading zeroes - */ - normalizeParts: function (left, right) { - var settingsClone = this.settingsClone; - right = autoStrip(right, settingsClone); /** if right is not empty and first character is not aDec, */ - /** we could strip all zeros, otherwise only leading */ - var strip = right.match(/^\d/) ? true : 'leading'; - left = autoStrip(left, settingsClone, strip); /** prevents multiple leading zeros from being entered */ - if ((left === '' || left === settingsClone.aNeg) && settingsClone.lZero === 'deny') { - if (right > '') { - right = right.replace(/^0*(\d)/, '$1'); - } - } - var new_value = left + right; /** insert zero if has leading dot */ - if (settingsClone.aDec) { - var m = new_value.match(new RegExp('^' + settingsClone.aNegRegAutoStrip + '\\' + settingsClone.aDec)); - if (m) { - left = left.replace(m[1], m[1] + '0'); - new_value = left + right; - } - } /** insert zero if number is empty and io.wEmpty == 'zero' */ - if (settingsClone.wEmpty === 'zero' && (new_value === settingsClone.aNeg || new_value === '')) { - left += '0'; - } - return [left, right]; - }, - /** - * set part of number to value keeping position of cursor - */ - setValueParts: function (left, right) { - var settingsClone = this.settingsClone, - parts = this.normalizeParts(left, right), - new_value = parts.join(''), - position = parts[0].length; - if (autoCheck(new_value, settingsClone)) { - new_value = truncateDecimal(new_value, settingsClone.aDec, settingsClone.mDec); - if (position > new_value.length) { - position = new_value.length; - } - this.value = new_value; - this.setPosition(position, false); - return true; - } - return false; - }, - /** - * helper function for expandSelectionOnSign - * returns sign position of a formatted value - */ - signPosition: function () { - var settingsClone = this.settingsClone, - aSign = settingsClone.aSign, - that = this.that; - if (aSign) { - var aSignLen = aSign.length; - if (settingsClone.pSign === 'p') { - var hasNeg = settingsClone.aNeg && that.value && that.value.charAt(0) === settingsClone.aNeg; - return hasNeg ? [1, aSignLen + 1] : [0, aSignLen]; - } - var valueLen = that.value.length; - return [valueLen - aSignLen, valueLen]; - } - return [1000, -1]; - }, - /** - * expands selection to cover whole sign - * prevents partial deletion/copying/overwriting of a sign - */ - expandSelectionOnSign: function (setReal) { - var sign_position = this.signPosition(), - selection = this.selection; - if (selection.start < sign_position[1] && selection.end > sign_position[0]) { /** if selection catches something except sign and catches only space from sign */ - if ((selection.start < sign_position[0] || selection.end > sign_position[1]) && this.value.substring(Math.max(selection.start, sign_position[0]), Math.min(selection.end, sign_position[1])).match(/^\s*$/)) { /** then select without empty space */ - if (selection.start < sign_position[0]) { - this.setSelection(selection.start, sign_position[0], setReal); - } else { - this.setSelection(sign_position[1], selection.end, setReal); - } - } else { /** else select with whole sign */ - this.setSelection(Math.min(selection.start, sign_position[0]), Math.max(selection.end, sign_position[1]), setReal); - } - } - }, - /** - * try to strip pasted value to digits - */ - checkPaste: function () { - if (this.valuePartsBeforePaste !== undefined) { - var parts = this.getBeforeAfter(), - oldParts = this.valuePartsBeforePaste; - delete this.valuePartsBeforePaste; /** try to strip pasted value first */ - parts[0] = parts[0].substr(0, oldParts[0].length) + autoStrip(parts[0].substr(oldParts[0].length), this.settingsClone); - if (!this.setValueParts(parts[0], parts[1])) { - this.value = oldParts.join(''); - this.setPosition(oldParts[0].length, false); - } - } - }, - /** - * process pasting, cursor moving and skipping of not interesting keys - * if returns true, futher processing is not performed - */ - skipAllways: function (e) { - var kdCode = this.kdCode, - which = this.which, - ctrlKey = this.ctrlKey, - cmdKey = this.cmdKey, - shiftKey = this.shiftKey; /** catch the ctrl up on ctrl-v */ - if (((ctrlKey || cmdKey) && e.type === 'keyup' && this.valuePartsBeforePaste !== undefined) || (shiftKey && kdCode === 45)) { - this.checkPaste(); - return false; - } - /** codes are taken from http://www.cambiaresearch.com/c4/702b8cd1-e5b0-42e6-83ac-25f0306e3e25/Javascript-Char-Codes-Key-Codes.aspx - * skip Fx keys, windows keys, other special keys - */ - if ((kdCode >= 112 && kdCode <= 123) || (kdCode >= 91 && kdCode <= 93) || (kdCode >= 9 && kdCode <= 31) || (kdCode < 8 && (which === 0 || which === kdCode)) || kdCode === 144 || kdCode === 145 || kdCode === 45) { - return true; - } - if ((ctrlKey || cmdKey) && kdCode === 65) { /** if select all (a=65)*/ - return true; - } - if ((ctrlKey || cmdKey) && (kdCode === 67 || kdCode === 86 || kdCode === 88)) { /** if copy (c=67) paste (v=86) or cut (x=88) */ - if (e.type === 'keydown') { - this.expandSelectionOnSign(); - } - if (kdCode === 86 || kdCode === 45) { /** try to prevent wrong paste */ - if (e.type === 'keydown' || e.type === 'keypress') { - if (this.valuePartsBeforePaste === undefined) { - this.valuePartsBeforePaste = this.getBeforeAfter(); - } - } else { - this.checkPaste(); - } - } - return e.type === 'keydown' || e.type === 'keypress' || kdCode === 67; - } - if (ctrlKey || cmdKey) { - return true; - } - if (kdCode === 37 || kdCode === 39) { /** jump over thousand separator */ - var aSep = this.settingsClone.aSep, - start = this.selection.start, - value = this.that.value; - if (e.type === 'keydown' && aSep && !this.shiftKey) { - if (kdCode === 37 && value.charAt(start - 2) === aSep) { - this.setPosition(start - 1); - } else if (kdCode === 39 && value.charAt(start + 1) === aSep) { - this.setPosition(start + 1); - } - } - return true; - } - if (kdCode >= 34 && kdCode <= 40) { - return true; - } - return false; - }, - /** - * process deletion of characters - * returns true if processing performed - */ - processAllways: function () { - var parts; /** process backspace or delete */ - if (this.kdCode === 8 || this.kdCode === 46) { - if (!this.selection.length) { - parts = this.getBeforeAfterStriped(); - if (this.kdCode === 8) { - parts[0] = parts[0].substring(0, parts[0].length - 1); - } else { - parts[1] = parts[1].substring(1, parts[1].length); - } - this.setValueParts(parts[0], parts[1]); - } else { - this.expandSelectionOnSign(false); - parts = this.getBeforeAfterStriped(); - this.setValueParts(parts[0], parts[1]); - } - return true; - } - return false; - }, - /** - * process insertion of characters - * returns true if processing performed - */ - processKeypress: function () { - var settingsClone = this.settingsClone, - cCode = String.fromCharCode(this.which), - parts = this.getBeforeAfterStriped(), - left = parts[0], - right = parts[1]; /** start rules when the decimal character key is pressed */ - /** always use numeric pad dot to insert decimal separator */ - if (cCode === settingsClone.aDec || (settingsClone.altDec && cCode === settingsClone.altDec) || ((cCode === '.' || cCode === ',') && this.kdCode === 110)) { /** do not allow decimal character if no decimal part allowed */ - if (!settingsClone.mDec || !settingsClone.aDec) { - return true; - } /** do not allow decimal character before aNeg character */ - if (settingsClone.aNeg && right.indexOf(settingsClone.aNeg) > -1) { - return true; - } /** do not allow decimal character if other decimal character present */ - if (left.indexOf(settingsClone.aDec) > -1) { - return true; - } - if (right.indexOf(settingsClone.aDec) > 0) { - return true; - } - if (right.indexOf(settingsClone.aDec) === 0) { - right = right.substr(1); - } - this.setValueParts(left + settingsClone.aDec, right); - return true; - } /** start rule on negative sign */ - - if (cCode === '-' || cCode === '+') { /** prevent minus if not allowed */ - if (!settingsClone.aNeg) { - return true; - } /** caret is always after minus */ - if (left === '' && right.indexOf(settingsClone.aNeg) > -1) { - left = settingsClone.aNeg; - right = right.substring(1, right.length); - } /** change sign of number, remove part if should */ - if (left.charAt(0) === settingsClone.aNeg) { - left = left.substring(1, left.length); - } else { - left = (cCode === '-') ? settingsClone.aNeg + left : left; - } - this.setValueParts(left, right); - return true; - } /** digits */ - if (cCode >= '0' && cCode <= '9') { /** if try to insert digit before minus */ - if (settingsClone.aNeg && left === '' && right.indexOf(settingsClone.aNeg) > -1) { - left = settingsClone.aNeg; - right = right.substring(1, right.length); - } - if (settingsClone.vMax <= 0 && settingsClone.vMin < settingsClone.vMax && this.value.indexOf(settingsClone.aNeg) === -1 && cCode !== '0') { - left = settingsClone.aNeg + left; - } - this.setValueParts(left + cCode, right); - return true; - } /** prevent any other character */ - return true; - }, - /** - * formatting of just processed value with keeping of cursor position - */ - formatQuick: function () { - var settingsClone = this.settingsClone, - parts = this.getBeforeAfterStriped(), - leftLength = this.value; - if ((settingsClone.aSep === '' || (settingsClone.aSep !== '' && leftLength.indexOf(settingsClone.aSep) === -1)) && (settingsClone.aSign === '' || (settingsClone.aSign !== '' && leftLength.indexOf(settingsClone.aSign) === -1))) { - var subParts = [], - nSign = ''; - subParts = leftLength.split(settingsClone.aDec); - if (subParts[0].indexOf('-') > -1) { - nSign = '-'; - subParts[0] = subParts[0].replace('-', ''); - parts[0] = parts[0].replace('-', ''); - } - if (subParts[0].length > settingsClone.mInt && parts[0].charAt(0) === '0') { /** strip leading zero if need */ - parts[0] = parts[0].slice(1); - } - parts[0] = nSign + parts[0]; - } - var value = autoGroup(this.value, this.settingsClone), - position = value.length; - if (value) { - /** prepare regexp which searches for cursor position from unformatted left part */ - var left_ar = parts[0].split(''), - i = 0; - for (i; i < left_ar.length; i += 1) { /** thanks Peter Kovari */ - if (!left_ar[i].match('\\d')) { - left_ar[i] = '\\' + left_ar[i]; - } - } - var leftReg = new RegExp('^.*?' + left_ar.join('.*?')); - /** search cursor position in formatted value */ - var newLeft = value.match(leftReg); - if (newLeft) { - position = newLeft[0].length; - /** if we are just before sign which is in prefix position */ - if (((position === 0 && value.charAt(0) !== settingsClone.aNeg) || (position === 1 && value.charAt(0) === settingsClone.aNeg)) && settingsClone.aSign && settingsClone.pSign === 'p') { - /** place carret after prefix sign */ - position = this.settingsClone.aSign.length + (value.charAt(0) === '-' ? 1 : 0); - } - } else if (settingsClone.aSign && settingsClone.pSign === 's') { - /** if we could not find a place for cursor and have a sign as a suffix */ - /** place carret before suffix currency sign */ - position -= settingsClone.aSign.length; - } - } - this.that.value = value; - this.setPosition(position); - this.formatted = true; - } - }; - /** thanks to Anthony & Evan C */ - function autoGet(obj) { - if (typeof obj === 'string') { - obj = obj.replace(/\[/g, "\\[").replace(/\]/g, "\\]"); - obj = '#' + obj.replace(/(:|\.)/g, '\\$1'); - /** obj = '#' + obj.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1'); */ - /** possible modification to replace the above 2 lines */ - } - return $(obj); - } - - function getHolder($that, settings, update) { - var data = $that.data('autoNumeric'); - if (!data) { - data = {}; - $that.data('autoNumeric', data); - } - var holder = data.holder; - if ((holder === undefined && settings) || update) { - holder = new AutoNumericHolder($that.get(0), settings); - data.holder = holder; - } - return holder; - } - var methods = { - init: function (options) { - return this.each(function () { - var $this = $(this), - settings = $this.data('autoNumeric'), /** attempt to grab 'autoNumeric' settings, if they don't exist returns "undefined". */ - tagData = $this.data(); /** attempt to grab HTML5 data, if they don't exist we'll get "undefined".*/ - if (typeof settings !== 'object') { /** If we couldn't grab settings, create them from defaults and passed options. */ - var defaults = { - /** allowed numeric values - * please do not modify - */ - aNum: '0123456789', - /** allowed thousand separator characters - * comma = ',' - * period "full stop" = '.' - * apostrophe is escaped = '\'' - * space = ' ' - * none = '' - * NOTE: do not use numeric characters - */ - aSep: ',', - /** digital grouping for the thousand separator used in Format - * dGroup: '2', results in 99,99,99,999 common in India for values less than 1 billion and greater than -1 billion - * dGroup: '3', results in 999,999,999 default - * dGroup: '4', results in 9999,9999,9999 used in some Asian countries - */ - dGroup: '3', - /** allowed decimal separator characters - * period "full stop" = '.' - * comma = ',' - */ - aDec: '.', - /** allow to declare alternative decimal separator which is automatically replaced by aDec - * developed for countries the use a comma ',' as the decimal character - * and have keyboards\numeric pads that have a period 'full stop' as the decimal characters (Spain is an example) - */ - altDec: null, - /** allowed currency symbol - * Must be in quotes aSign: '$', a space is allowed aSign: '$ ' - */ - aSign: '', - /** placement of currency sign - * for prefix pSign: 'p', - * for suffix pSign: 's', - */ - pSign: 'p', - /** maximum possible value - * value must be enclosed in quotes and use the period for the decimal point - * value must be larger than vMin - */ - vMax: '9999999999999.99', - /** minimum possible value - * value must be enclosed in quotes and use the period for the decimal point - * value must be smaller than vMax - */ - vMin: '0.00', - /** max number of decimal places = used to override decimal places set by the vMin & vMax values - * value must be enclosed in quotes example mDec: '3', - * This can also set the value via a call back function mDec: 'css:# - */ - mDec: null, - /** method used for rounding - * mRound: 'S', Round-Half-Up Symmetric (default) - * mRound: 'A', Round-Half-Up Asymmetric - * mRound: 's', Round-Half-Down Symmetric (lower case s) - * mRound: 'a', Round-Half-Down Asymmetric (lower case a) - * mRound: 'B', Round-Half-Even "Bankers Rounding" - * mRound: 'U', Round Up "Round-Away-From-Zero" - * mRound: 'D', Round Down "Round-Toward-Zero" - same as truncate - * mRound: 'C', Round to Ceiling "Toward Positive Infinity" - * mRound: 'F', Round to Floor "Toward Negative Infinity" - */ - mRound: 'S', - /** controls decimal padding - * aPad: true - always Pad decimals with zeros - * aPad: false - does not pad with zeros. - * aPad: `some number` - pad decimals with zero to number different from mDec - * thanks to Jonas Johansson for the suggestion - */ - aPad: true, - /** places brackets on negative value -$ 999.99 to (999.99) - * visible only when the field does NOT have focus the left and right symbols should be enclosed in quotes and seperated by a comma - * nBracket: null, nBracket: '(,)', nBracket: '[,]', nBracket: '<,>' or nBracket: '{,}' - */ - nBracket: null, - /** Displayed on empty string - * wEmpty: 'empty', - input can be blank - * wEmpty: 'zero', - displays zero - * wEmpty: 'sign', - displays the currency sign - */ - wEmpty: 'empty', - /** controls leading zero behavior - * lZero: 'allow', - allows leading zeros to be entered. Zeros will be truncated when entering additional digits. On focusout zeros will be deleted. - * lZero: 'deny', - allows only one leading zero on values less than one - * lZero: 'keep', - allows leading zeros to be entered. on fousout zeros will be retained. - */ - lZero: 'allow', - /** determine if the default value will be formatted on page ready. - * true = automatically formats the default value on page ready - * false = will not format the default value - */ - aForm: true, - /** future use */ - onSomeEvent: function () { } - }; - settings = $.extend({}, defaults, tagData, options); /** Merge defaults, tagData and options */ - if (settings.aDec === settings.aSep) { - $.error("autoNumeric will not function properly when the decimal character aDec: '" + settings.aDec + "' and thousand separator aSep: '" + settings.aSep + "' are the same character"); - return this; - } - $this.data('autoNumeric', settings); /** Save our new settings */ - } else { - return this; - } - settings.lastSetValue = ''; - settings.runOnce = false; - var holder = getHolder($this, settings); - if ($.inArray($this.prop('tagName'), settings.tagList) === -1 && $this.prop('tagName') !== 'INPUT') { - $.error("The <" + $this.prop('tagName') + "> is not supported by autoNumeric()"); - return this; - } - if (settings.runOnce === false && settings.aForm) {/** routine to format default value on page load */ - if ($this.is('input[type=text], input[type=hidden], input:not([type])')) { - var setValue = true; - if ($this[0].value === '' && settings.wEmpty === 'empty') { - $this[0].value = ''; - setValue = false; - } - if ($this[0].value === '' && settings.wEmpty === 'sign') { - $this[0].value = settings.aSign; - setValue = false; - } - if (setValue) { - $this.autoNumeric('set', $this.val()); - } - } - if ($.inArray($this.prop('tagName'), settings.tagList) !== -1 && $this.text() !== '') { - $this.autoNumeric('set', $this.text()); - } - } - settings.runOnce = true; - if ($this.is('input[type=text], input[type=hidden], input:not([type])')) { /**added hidden type */ - $this.on('keydown.autoNumeric', function (e) { - holder = getHolder($this); - if (holder.settings.aDec === holder.settings.aSep) { - $.error("autoNumeric will not function properly when the decimal character aDec: '" + holder.settings.aDec + "' and thousand separator aSep: '" + holder.settings.aSep + "' are the same character"); - return this; - } - if (holder.that.readOnly) { - holder.processed = true; - return true; - } - /** The below streamed code / comment allows the "enter" keydown to throw a change() event */ - /** if (e.keyCode === 13 && holder.inVal !== $this.val()){ - $this.change(); - holder.inVal = $this.val(); - }*/ - holder.init(e); - holder.settings.oEvent = 'keydown'; - if (holder.skipAllways(e)) { - holder.processed = true; - return true; - } - if (holder.processAllways()) { - holder.processed = true; - holder.formatQuick(); - e.preventDefault(); - return false; - } - holder.formatted = false; - return true; - }); - $this.on('keypress.autoNumeric', function (e) { - var holder = getHolder($this), - processed = holder.processed; - holder.init(e); - holder.settings.oEvent = 'keypress'; - if (holder.skipAllways(e)) { - return true; - } - if (processed) { - e.preventDefault(); - return false; - } - if (holder.processAllways() || holder.processKeypress()) { - holder.formatQuick(); - e.preventDefault(); - return false; - } - holder.formatted = false; - }); - $this.on('keyup.autoNumeric', function (e) { - var holder = getHolder($this); - holder.init(e); - holder.settings.oEvent = 'keyup'; - var skip = holder.skipAllways(e); - holder.kdCode = 0; - delete holder.valuePartsBeforePaste; - if ($this[0].value === holder.settings.aSign) { /** added to properly place the caret when only the currency is present */ - if (holder.settings.pSign === 's') { - setElementSelection(this, 0, 0); - } else { - setElementSelection(this, holder.settings.aSign.length, holder.settings.aSign.length); - } - } - if (skip) { - return true; - } - if (this.value === '') { - return true; - } - if (!holder.formatted) { - holder.formatQuick(); - } - }); - $this.on('focusin.autoNumeric', function () { - var holder = getHolder($this); - holder.settingsClone.oEvent = 'focusin'; - if (holder.settingsClone.nBracket !== null) { - var checkVal = $this.val(); - $this.val(negativeBracket(checkVal, holder.settingsClone.nBracket, holder.settingsClone.oEvent)); - } - holder.inVal = $this.val(); - var onempty = checkEmpty(holder.inVal, holder.settingsClone, true); - if (onempty !== null) { - $this.val(onempty); - if (holder.settings.pSign === 's') { - setElementSelection(this, 0, 0); - } else { - setElementSelection(this, holder.settings.aSign.length, holder.settings.aSign.length); - } - } - }); - $this.on('focusout.autoNumeric', function () { - var holder = getHolder($this), - settingsClone = holder.settingsClone, - value = $this.val(), - origValue = value; - holder.settingsClone.oEvent = 'focusout'; - var strip_zero = ''; /** added to control leading zero */ - if (settingsClone.lZero === 'allow') { /** added to control leading zero */ - settingsClone.allowLeading = false; - strip_zero = 'leading'; - } - if (value !== '') { - value = autoStrip(value, settingsClone, strip_zero); - if (checkEmpty(value, settingsClone) === null && autoCheck(value, settingsClone, $this[0])) { - value = fixNumber(value, settingsClone.aDec, settingsClone.aNeg); - value = autoRound(value, settingsClone); - value = presentNumber(value, settingsClone.aDec, settingsClone.aNeg); - } else { - value = ''; - } - } - var groupedValue = checkEmpty(value, settingsClone, false); - if (groupedValue === null) { - groupedValue = autoGroup(value, settingsClone); - } - if (groupedValue !== origValue) { - $this.val(groupedValue); - } - if (groupedValue !== holder.inVal) { - $this.change(); - delete holder.inVal; - } - if (settingsClone.nBracket !== null && $this.autoNumeric('get') < 0) { - holder.settingsClone.oEvent = 'focusout'; - $this.val(negativeBracket($this.val(), settingsClone.nBracket, settingsClone.oEvent)); - } - }); - } - }); - }, - /** method to remove settings and stop autoNumeric() */ - destroy: function () { - return $(this).each(function () { - var $this = $(this); - $this.off('.autoNumeric'); - $this.removeData('autoNumeric'); - }); - }, - /** method to update settings - can call as many times */ - update: function (options) { - return $(this).each(function () { - var $this = autoGet($(this)), - settings = $this.data('autoNumeric'); - if (typeof settings !== 'object') { - $.error("You must initialize autoNumeric('init', {options}) prior to calling the 'update' method"); - return this; - } - var strip = $this.autoNumeric('get'); - settings = $.extend(settings, options); - getHolder($this, settings, true); - if (settings.aDec === settings.aSep) { - $.error("autoNumeric will not function properly when the decimal character aDec: '" + settings.aDec + "' and thousand separator aSep: '" + settings.aSep + "' are the same character"); - return this; - } - $this.data('autoNumeric', settings); - if ($this.val() !== '' || $this.text() !== '') { - return $this.autoNumeric('set', strip); - } - return; - }); - }, - /** returns a formatted strings for "input:text" fields Uses jQuery's .val() method*/ - set: function (valueIn) { - return $(this).each(function () { - var $this = autoGet($(this)), - settings = $this.data('autoNumeric'), - value = valueIn.toString(), - testValue = valueIn.toString(); - if (typeof settings !== 'object') { - $.error("You must initialize autoNumeric('init', {options}) prior to calling the 'set' method"); - return this; - } - /** allows locale decimal separator to be a comma */ - if ((testValue === $this.attr('value') || testValue === $this.text()) && settings.runOnce === false) { - value = value.replace(',', '.'); - } - /** routine to handle page re-load from back button */ - if (testValue !== $this.attr('value') && $this.prop('tagName') === 'INPUT' && settings.runOnce === false) { - value = autoStrip(value, settings); - } - /** returns a empty string if the value being 'set' contains non-numeric characters and or more than decimal point (full stop) and will not be formatted */ - if (!$.isNumeric(+value)) { - return ''; - } - value = checkValue(value, settings); - settings.oEvent = 'set'; - settings.lastSetValue = value; /** saves the unrounded value from the set method - $('selector').data('autoNumeric').lastSetValue; - helpful when you need to change the rounding accuracy*/ - value.toString(); - if (value !== '') { - value = autoRound(value, settings); - } - value = presentNumber(value, settings.aDec, settings.aNeg); - if (!autoCheck(value, settings)) { - value = autoRound('', settings); - } - value = autoGroup(value, settings); - if ($this.is('input[type=text], input[type=hidden], input:not([type])')) { /**added hidden type */ - return $this.val(value); - } - if ($.inArray($this.prop('tagName'), settings.tagList) !== -1) { - return $this.text(value); - } - $.error("The <" + $this.prop('tagName') + "> is not supported by autoNumeric()"); - return false; - }); - }, - /** method to get the unformatted value from a specific input field, returns a numeric value */ - get: function () { - var $this = autoGet($(this)), - settings = $this.data('autoNumeric'); - if (typeof settings !== 'object') { - $.error("You must initialize autoNumeric('init', {options}) prior to calling the 'get' method"); - return this; - } - settings.oEvent = 'get'; - var getValue = ''; - /** determine the element type then use .eq(0) selector to grab the value of the first element in selector */ - if ($this.is('input[type=text], input[type=hidden], input:not([type])')) { /**added hidden type */ - getValue = $this.eq(0).val(); - } else if ($.inArray($this.prop('tagName'), settings.tagList) !== -1) { - getValue = $this.eq(0).text(); - } else { - $.error("The <" + $this.prop('tagName') + "> is not supported by autoNumeric()"); - return false; - } - if ((getValue === '' && settings.wEmpty === 'empty') || (getValue === settings.aSign && (settings.wEmpty === 'sign' || settings.wEmpty === 'empty'))) { - return ''; - } - if (settings.nBracket !== null && getValue !== '') { - getValue = negativeBracket(getValue, settings.nBracket, settings.oEvent); - } - if (settings.runOnce || settings.aForm === false) { - getValue = autoStrip(getValue, settings); - } - getValue = fixNumber(getValue, settings.aDec, settings.aNeg); - if (+getValue === 0 && settings.lZero !== 'keep') { - getValue = '0'; - } - if (settings.lZero === 'keep') { - return getValue; - } - getValue = checkValue(getValue, settings); - return getValue; /** returned Numeric String */ - }, - /** method to get the unformatted value from multiple fields */ - getString: function () { - var isAutoNumeric = false, - $this = autoGet($(this)), - str = $this.serialize(), - parts = str.split('&'), - i = 0; - for (i; i < parts.length; i += 1) { - var miniParts = parts[i].split('='); - var settings = $('*[name="' + decodeURIComponent(miniParts[0]) + '"]').data('autoNumeric'); - if (typeof settings === 'object') { - if (miniParts[1] !== null && $('*[name="' + decodeURIComponent(miniParts[0]) + '"]').data('autoNumeric') !== undefined) { - miniParts[1] = $('input[name="' + decodeURIComponent(miniParts[0]) + '"]').autoNumeric('get'); - parts[i] = miniParts.join('='); - isAutoNumeric = true; - } - } - } - if (isAutoNumeric === true) { - return parts.join('&'); - } - $.error("You must initialize autoNumeric('init', {options}) prior to calling the 'getString' method"); - return this; - }, - /** method to get the unformatted value from multiple fields */ - getArray: function () { - var isAutoNumeric = false, - $this = autoGet($(this)), - formFields = $this.serializeArray(); - $.each(formFields, function (i, field) { - var settings = $('*[name="' + decodeURIComponent(field.name) + '"]').data('autoNumeric'); - if (typeof settings === 'object') { - if (field.value !== '' && $('*[name="' + decodeURIComponent(field.name) + '"]').data('autoNumeric') !== undefined) { - field.value = $('input[name="' + decodeURIComponent(field.name) + '"]').autoNumeric('get').toString(); - } - isAutoNumeric = true; - } - }); - if (isAutoNumeric === true) { - return formFields; - } - $.error("You must initialize autoNumeric('init', {options}) prior to calling the 'getArray' method"); - return this; - }, - /** returns the settings object for those who need to look under the hood */ - getSettings: function () { - var $this = autoGet($(this)); - return $this.eq(0).data('autoNumeric'); - } - }; - $.fn.autoNumeric = function (method) { - if (methods[method]) { - return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } - if (typeof method === 'object' || !method) { - return methods.init.apply(this, arguments); - } - $.error('Method "' + method + '" is not supported by autoNumeric()'); - }; -}(jQuery)); \ No newline at end of file diff --git a/dashboard-ui/thirdparty/autonumeric/autoNumeric.min.js b/dashboard-ui/thirdparty/autonumeric/autoNumeric.min.js deleted file mode 100644 index 2c812deb5e..0000000000 --- a/dashboard-ui/thirdparty/autonumeric/autoNumeric.min.js +++ /dev/null @@ -1,109 +0,0 @@ -(function (f) { - function m(b, a, c) { void 0 === b.selectionStart ? (b.focus(), b = b.createTextRange(), b.collapse(!0), b.moveEnd("character", c), b.moveStart("character", a), b.select()) : (b.selectionStart = a, b.selectionEnd = c) } function C(b, a) { f.each(a, function (c, d) { "function" === typeof d ? a[c] = d(b, a, c) : "function" === typeof b.autoNumeric[d] && (a[c] = b.autoNumeric[d](b, a, c)) }) } function p(b, a) { "string" === typeof b[a] && (b[a] *= 1) } function x(b, a) { - C(b, a); a.oEvent = null; a.tagList = "B CAPTION CITE CODE DD DEL DIV DFN DT EM H1 H2 H3 H4 H5 H6 INS KDB LABEL LI OUTPUT P Q S SAMPLE SPAN STRONG TD TH U VAR".split(" "); - var c = a.vMax.toString().split("."), d = a.vMin || 0 === a.vMin ? a.vMin.toString().split(".") : []; p(a, "vMax"); p(a, "vMin"); p(a, "mDec"); a.allowLeading = !0; a.aNeg = 0 > a.vMin ? "-" : ""; c[0] = c[0].replace("-", ""); d[0] = d[0].replace("-", ""); a.mInt = Math.max(c[0].length, d[0].length, 1); if (null === a.mDec) { var e = 0, g = 0; c[1] && (e = c[1].length); d[1] && (g = d[1].length); a.mDec = Math.max(e, g) } null === a.altDec && 0 < a.mDec && ("." === a.aDec && "," !== a.aSep ? a.altDec = "," : "," === a.aDec && "." !== a.aSep && (a.altDec = ".")); c = a.aNeg ? "([-\\" + a.aNeg + "]?)" : "(-?)"; - a.aNegRegAutoStrip = c; a.skipFirstAutoStrip = RegExp(c + "[^-" + (a.aNeg ? "\\" + a.aNeg : "") + "\\" + a.aDec + "\\d].*?(\\d|\\" + a.aDec + "\\d)"); a.skipLastAutoStrip = RegExp("(\\d\\" + a.aDec + "?)[^\\" + a.aDec + "\\d]\\D*$"); a.allowedAutoStrip = RegExp("[^" + ("-" + a.aNum + "\\" + a.aDec) + "]", "gi"); a.numRegAutoStrip = RegExp(c + "(?:\\" + a.aDec + "?(\\d+\\" + a.aDec + "\\d+)|(\\d*(?:\\" + a.aDec + "\\d*)?))"); return a - } function h(b, a, c) { - if (a.aSign) for (; -1 < b.indexOf(a.aSign) ;) b = b.replace(a.aSign, ""); b = b.replace(a.skipFirstAutoStrip, "$1$2"); b = b.replace(a.skipLastAutoStrip, - "$1"); b = b.replace(a.allowedAutoStrip, ""); a.altDec && (b = b.replace(a.altDec, a.aDec)); b = (b = b.match(a.numRegAutoStrip)) ? [b[1], b[2], b[3]].join("") : ""; if (("allow" === a.lZero || "keep" === a.lZero) && "strip" !== c) { var d = [], e = "", d = b.split(a.aDec); -1 !== d[0].indexOf("-") && (e = "-", d[0] = d[0].replace("-", "")); d[0].length > a.mInt && "0" === d[0].charAt(0) && (d[0] = d[0].slice(1)); b = e + d.join(a.aDec) } if (c && "deny" === a.lZero || c && "allow" === a.lZero && !1 === a.allowLeading) a = "^" + a.aNegRegAutoStrip + "0*(\\d" + ("leading" === c ? ")" : "|$)"), a = RegExp(a), - b = b.replace(a, "$1$2"); return b - } function q(b, a, c) { a = a.split(","); "set" === c || "focusout" === c ? (b = b.replace("-", ""), b = a[0] + b + a[1]) : "get" !== c && "focusin" !== c && "pageLoad" !== c || b.charAt(0) !== a[0] || (b = b.replace(a[0], "-"), b = b.replace(a[1], "")); return b } function y(b, a, c) { if (a && c) { var d = b.split(a); d[1] && d[1].length > c && (0 < c ? (d[1] = d[1].substring(0, c), b = d.join(a)) : b = d[0]) } return b } function s(b, a, c) { a && "." !== a && (b = b.replace(a, ".")); c && "-" !== c && (b = b.replace(c, "-")); b.match(/\d/) || (b += "0"); return b } function z(b, a) { - var c = - b.indexOf("."), d = +b; -1 !== c && (1E-6 > d && -1 < d ? (b = +b, 1E-6 > b && 0 < b && (b = (b + 10).toString(), b = b.substring(1)), 0 > b && -1 < b && (b = (b - 10).toString(), b = "-" + b.substring(2)), b = b.toString()) : (c = b.split("."), void 0 !== c[1] && (0 === +c[1] ? b = c[0] : (c[1] = c[1].replace(/0*$/, ""), b = c.join("."))))); return "keep" === a.lZero ? b : b.replace(/^0*(\d)/, "$1") - } function A(b, a, c) { c && "-" !== c && (b = b.replace("-", c)); a && "." !== a && (b = b.replace(".", a)); return b } function t(b, a) { - b = h(b, a); b = y(b, a.aDec, a.mDec); b = s(b, a.aDec, a.aNeg); var c = +b; "set" === a.oEvent && - (c < a.vMin || c > a.vMax) && f.error("The value (" + c + ") from the 'set' method falls outside of the vMin / vMax range"); return c >= a.vMin && c <= a.vMax - } function r(b, a, c) { return "" === b || b === a.aNeg ? "zero" === a.wEmpty ? b + "0" : "sign" === a.wEmpty || c ? b + a.aSign : b : null } function u(b, a) { - b = h(b, a); var c = b.replace(",", "."), d = r(b, a, !0); if (null !== d) return d; var d = "", d = 2 === a.dGroup ? /(\d)((\d)(\d{2}?)+)$/ : 4 === a.dGroup ? /(\d)((\d{4}?)+)$/ : /(\d)((\d{3}?)+)$/, e = b.split(a.aDec); a.altDec && 1 === e.length && (e = b.split(a.altDec)); var g = e[0]; - if (a.aSep) for (; d.test(g) ;) g = g.replace(d, "$1" + a.aSep + "$2"); 0 !== a.mDec && 1 < e.length ? (e[1].length > a.mDec && (e[1] = e[1].substring(0, a.mDec)), b = g + a.aDec + e[1]) : b = g; a.aSign && (d = -1 !== b.indexOf(a.aNeg), b = b.replace(a.aNeg, ""), b = "p" === a.pSign ? a.aSign + b : b + a.aSign, d && (b = a.aNeg + b)); "set" === a.oEvent && 0 > c && null !== a.nBracket && (b = q(b, a.nBracket, a.oEvent)); return b - } function v(b, a) { - b = "" === b ? "0" : b.toString(); p(a, "mDec"); var c = "", d = 0, e = "", g = "boolean" === typeof a.aPad || null === a.aPad ? a.aPad ? a.mDec : 0 : +a.aPad, n = function (a) { - a = - a.replace(0 === g ? /(\.[1-9]*)0*$/ : 1 === g ? /(\.\d[1-9]*)0*$/ : RegExp("(\\.\\d{" + g + "}[1-9]*)0*$"), "$1"); 0 === g && (a = a.replace(/\.$/, "")); return a - }; "-" === b.charAt(0) && (e = "-", b = b.replace("-", "")); b.match(/^\d/) || (b = "0" + b); "-" === e && 0 === +b && (e = ""); if (0 < +b && "keep" !== a.lZero || 0 < b.length && "allow" === a.lZero) b = b.replace(/^0*(\d)/, "$1"); var d = b.lastIndexOf("."), f = b.length - 1 - (-1 === d ? b.length - 1 : d); if (f <= a.mDec) { - c = b; if (f < g) for (-1 === d && (c += ".") ; f < g;) n = "000000".substring(0, g - f), c += n, f += n.length; else f > g ? c = n(c) : 0 === f && 0 === - g && (c = c.replace(/\.$/, "")); return e + c - } var c = d + a.mDec, d = +b.charAt(c + 1), f = b.substring(0, c + 1).split(""), h = "." === b.charAt(c) ? b.charAt(c - 1) % 2 : b.charAt(c) % 2; if (4 < d && "S" === a.mRound || 4 < d && "A" === a.mRound && "" === e || 5 < d && "A" === a.mRound && "-" === e || 5 < d && "s" === a.mRound || 5 < d && "a" === a.mRound && "" === e || 4 < d && "a" === a.mRound && "-" === e || 5 < d && "B" === a.mRound || 5 === d && "B" === a.mRound && 1 === h || 0 < d && "C" === a.mRound && "" === e || 0 < d && "F" === a.mRound && "-" === e || 0 < d && "U" === a.mRound) for (d = f.length - 1; 0 <= d; d -= 1) if ("." !== f[d]) { - f[d] = +f[d] + 1; if (10 > - f[d]) break; 0 < d && (f[d] = "0") - } f = f.slice(0, c + 1); c = n(f.join("")); return 0 === +c ? c : e + c - } function B(b, a) { this.settings = a; this.that = b; this.$that = f(b); this.formatted = !1; this.settingsClone = x(this.$that, this.settings); this.value = b.value } function l(b) { "string" === typeof b && (b = b.replace(/\[/g, "\\[").replace(/\]/g, "\\]"), b = "#" + b.replace(/(:|\.)/g, "\\$1")); return f(b) } function k(b, a, c) { var d = b.data("autoNumeric"); d || (d = {}, b.data("autoNumeric", d)); var e = d.holder; if (void 0 === e && a || c) e = new B(b.get(0), a), d.holder = e; return e } - B.prototype = { - init: function (b) { - this.value = this.that.value; this.settingsClone = x(this.$that, this.settings); this.ctrlKey = b.ctrlKey; this.cmdKey = b.metaKey; this.shiftKey = b.shiftKey; var a = this.that, c = {}; if (void 0 === a.selectionStart) { a.focus(); var d = document.selection.createRange(); c.length = d.text.length; d.moveStart("character", -a.value.length); c.end = d.text.length; c.start = c.end - c.length } else c.start = a.selectionStart, c.end = a.selectionEnd, c.length = c.end - c.start; this.selection = c; if ("keydown" === b.type || "keyup" === - b.type) this.kdCode = b.keyCode; this.which = b.which; this.formatted = this.processed = !1 - }, setSelection: function (b, a, c) { b = Math.max(b, 0); a = Math.min(a, this.that.value.length); this.selection = { start: b, end: a, length: a - b }; (void 0 === c || c) && m(this.that, b, a) }, setPosition: function (b, a) { this.setSelection(b, b, a) }, getBeforeAfter: function () { var b = this.value, a = b.substring(0, this.selection.start), b = b.substring(this.selection.end, b.length); return [a, b] }, getBeforeAfterStriped: function () { - var b = this.getBeforeAfter(); b[0] = h(b[0], - this.settingsClone); b[1] = h(b[1], this.settingsClone); return b - }, normalizeParts: function (b, a) { var c = this.settingsClone; a = h(a, c); var d = a.match(/^\d/) ? !0 : "leading"; b = h(b, c, d); "" !== b && b !== c.aNeg || "deny" !== c.lZero || "" < a && (a = a.replace(/^0*(\d)/, "$1")); d = b + a; if (c.aDec) { var e = d.match(RegExp("^" + c.aNegRegAutoStrip + "\\" + c.aDec)); e && (b = b.replace(e[1], e[1] + "0"), d = b + a) } "zero" !== c.wEmpty || d !== c.aNeg && "" !== d || (b += "0"); return [b, a] }, setValueParts: function (b, a) { - var c = this.settingsClone, d = this.normalizeParts(b, a), e = d.join(""), - d = d[0].length; return t(e, c) ? (e = y(e, c.aDec, c.mDec), d > e.length && (d = e.length), this.value = e, this.setPosition(d, !1), !0) : !1 - }, signPosition: function () { var b = this.settingsClone, a = b.aSign, c = this.that; if (a) { a = a.length; if ("p" === b.pSign) return b.aNeg && c.value && c.value.charAt(0) === b.aNeg ? [1, a + 1] : [0, a]; b = c.value.length; return [b - a, b] } return [1E3, -1] }, expandSelectionOnSign: function (b) { - var a = this.signPosition(), c = this.selection; c.start < a[1] && c.end > a[0] && ((c.start < a[0] || c.end > a[1]) && this.value.substring(Math.max(c.start, - a[0]), Math.min(c.end, a[1])).match(/^\s*$/) ? c.start < a[0] ? this.setSelection(c.start, a[0], b) : this.setSelection(a[1], c.end, b) : this.setSelection(Math.min(c.start, a[0]), Math.max(c.end, a[1]), b)) - }, checkPaste: function () { - if (void 0 !== this.valuePartsBeforePaste) { - var b = this.getBeforeAfter(), a = this.valuePartsBeforePaste; delete this.valuePartsBeforePaste; b[0] = b[0].substr(0, a[0].length) + h(b[0].substr(a[0].length), this.settingsClone); this.setValueParts(b[0], b[1]) || (this.value = a.join(""), this.setPosition(a[0].length, - !1)) - } - }, skipAllways: function (b) { - var a = this.kdCode, c = this.which, d = this.ctrlKey, e = this.cmdKey, f = this.shiftKey; if ((d || e) && "keyup" === b.type && void 0 !== this.valuePartsBeforePaste || f && 45 === a) return this.checkPaste(), !1; if (112 <= a && 123 >= a || 91 <= a && 93 >= a || 9 <= a && 31 >= a || 8 > a && (0 === c || c === a) || 144 === a || 145 === a || 45 === a || (d || e) && 65 === a) return !0; if ((d || e) && (67 === a || 86 === a || 88 === a)) { - "keydown" === b.type && this.expandSelectionOnSign(); if (86 === a || 45 === a) "keydown" === b.type || "keypress" === b.type ? void 0 === this.valuePartsBeforePaste && - (this.valuePartsBeforePaste = this.getBeforeAfter()) : this.checkPaste(); return "keydown" === b.type || "keypress" === b.type || 67 === a - } return d || e ? !0 : 37 === a || 39 === a ? (c = this.settingsClone.aSep, d = this.selection.start, e = this.that.value, "keydown" === b.type && c && !this.shiftKey && (37 === a && e.charAt(d - 2) === c ? this.setPosition(d - 1) : 39 === a && e.charAt(d + 1) === c && this.setPosition(d + 1)), !0) : 34 <= a && 40 >= a ? !0 : !1 - }, processAllways: function () { - var b; return 8 === this.kdCode || 46 === this.kdCode ? (this.selection.length ? (this.expandSelectionOnSign(!1), - b = this.getBeforeAfterStriped()) : (b = this.getBeforeAfterStriped(), 8 === this.kdCode ? b[0] = b[0].substring(0, b[0].length - 1) : b[1] = b[1].substring(1, b[1].length)), this.setValueParts(b[0], b[1]), !0) : !1 - }, processKeypress: function () { - var b = this.settingsClone, a = String.fromCharCode(this.which), c = this.getBeforeAfterStriped(), d = c[0], c = c[1]; if (a === b.aDec || b.altDec && a === b.altDec || ("." === a || "," === a) && 110 === this.kdCode) { - if (!b.mDec || !b.aDec || b.aNeg && -1 < c.indexOf(b.aNeg) || -1 < d.indexOf(b.aDec) || 0 < c.indexOf(b.aDec)) return !0; - 0 === c.indexOf(b.aDec) && (c = c.substr(1)); this.setValueParts(d + b.aDec, c); return !0 - } if ("-" === a || "+" === a) { if (!b.aNeg) return !0; "" === d && -1 < c.indexOf(b.aNeg) && (d = b.aNeg, c = c.substring(1, c.length)); d = d.charAt(0) === b.aNeg ? d.substring(1, d.length) : "-" === a ? b.aNeg + d : d; this.setValueParts(d, c); return !0 } "0" <= a && "9" >= a && (b.aNeg && "" === d && -1 < c.indexOf(b.aNeg) && (d = b.aNeg, c = c.substring(1, c.length)), 0 >= b.vMax && b.vMin < b.vMax && -1 === this.value.indexOf(b.aNeg) && "0" !== a && (d = b.aNeg + d), this.setValueParts(d + a, c)); return !0 - }, formatQuick: function () { - var b = - this.settingsClone, a = this.getBeforeAfterStriped(), c = this.value; if (("" === b.aSep || "" !== b.aSep && -1 === c.indexOf(b.aSep)) && ("" === b.aSign || "" !== b.aSign && -1 === c.indexOf(b.aSign))) { var d = [], e = "", d = c.split(b.aDec); -1 < d[0].indexOf("-") && (e = "-", d[0] = d[0].replace("-", ""), a[0] = a[0].replace("-", "")); d[0].length > b.mInt && "0" === a[0].charAt(0) && (a[0] = a[0].slice(1)); a[0] = e + a[0] } c = u(this.value, this.settingsClone); d = c.length; if (c) { - a = a[0].split(""); e = 0; for (e; e < a.length; e += 1) a[e].match("\\d") || (a[e] = "\\" + a[e]); a = RegExp("^.*?" + - a.join(".*?")); (a = c.match(a)) ? (d = a[0].length, (0 === d && c.charAt(0) !== b.aNeg || 1 === d && c.charAt(0) === b.aNeg) && b.aSign && "p" === b.pSign && (d = this.settingsClone.aSign.length + ("-" === c.charAt(0) ? 1 : 0))) : b.aSign && "s" === b.pSign && (d -= b.aSign.length) - } this.that.value = c; this.setPosition(d); this.formatted = !0 - } - }; var w = { - init: function (b) { - return this.each(function () { - var a = f(this), c = a.data("autoNumeric"), d = a.data(); if ("object" !== typeof c) { - c = f.extend({}, { - aNum: "0123456789", aSep: ",", dGroup: "3", aDec: ".", altDec: null, aSign: "", pSign: "p", - vMax: "9999999999999.99", vMin: "0.00", mDec: null, mRound: "S", aPad: !0, nBracket: null, wEmpty: "empty", lZero: "allow", aForm: !0, onSomeEvent: function () { } - }, d, b); if (c.aDec === c.aSep) return f.error("autoNumeric will not function properly when the decimal character aDec: '" + c.aDec + "' and thousand separator aSep: '" + c.aSep + "' are the same character"), this; a.data("autoNumeric", c) - } else return this; c.lastSetValue = ""; c.runOnce = !1; var e = k(a, c); if (-1 === f.inArray(a.prop("tagName"), c.tagList) && "INPUT" !== a.prop("tagName")) return f.error("The <" + - a.prop("tagName") + "> is not supported by autoNumeric()"), this; !1 === c.runOnce && c.aForm && (a.is("input[type=text], input[type=hidden], input:not([type])") && (d = !0, "" === a[0].value && "empty" === c.wEmpty && (a[0].value = "", d = !1), "" === a[0].value && "sign" === c.wEmpty && (a[0].value = c.aSign, d = !1), d && a.autoNumeric("set", a.val())), -1 !== f.inArray(a.prop("tagName"), c.tagList) && "" !== a.text() && a.autoNumeric("set", a.text())); c.runOnce = !0; a.is("input[type=text], input[type=hidden], input:not([type])") && (a.on("keydown.autoNumeric", - function (b) { e = k(a); if (e.settings.aDec === e.settings.aSep) return f.error("autoNumeric will not function properly when the decimal character aDec: '" + e.settings.aDec + "' and thousand separator aSep: '" + e.settings.aSep + "' are the same character"), this; if (e.that.readOnly) return e.processed = !0; e.init(b); e.settings.oEvent = "keydown"; if (e.skipAllways(b)) return e.processed = !0; if (e.processAllways()) return e.processed = !0, e.formatQuick(), b.preventDefault(), !1; e.formatted = !1; return !0 }), a.on("keypress.autoNumeric", - function (b) { var c = k(a), d = c.processed; c.init(b); c.settings.oEvent = "keypress"; if (c.skipAllways(b)) return !0; if (d) return b.preventDefault(), !1; if (c.processAllways() || c.processKeypress()) return c.formatQuick(), b.preventDefault(), !1; c.formatted = !1 }), a.on("keyup.autoNumeric", function (b) { - var c = k(a); c.init(b); c.settings.oEvent = "keyup"; b = c.skipAllways(b); c.kdCode = 0; delete c.valuePartsBeforePaste; a[0].value === c.settings.aSign && ("s" === c.settings.pSign ? m(this, 0, 0) : m(this, c.settings.aSign.length, c.settings.aSign.length)); - if (b || "" === this.value) return !0; c.formatted || c.formatQuick() - }), a.on("focusin.autoNumeric", function () { var b = k(a); b.settingsClone.oEvent = "focusin"; if (null !== b.settingsClone.nBracket) { var c = a.val(); a.val(q(c, b.settingsClone.nBracket, b.settingsClone.oEvent)) } b.inVal = a.val(); c = r(b.inVal, b.settingsClone, !0); null !== c && (a.val(c), "s" === b.settings.pSign ? m(this, 0, 0) : m(this, b.settings.aSign.length, b.settings.aSign.length)) }), a.on("focusout.autoNumeric", function () { - var b = k(a), c = b.settingsClone, d = a.val(), e = d; b.settingsClone.oEvent = - "focusout"; var f = ""; "allow" === c.lZero && (c.allowLeading = !1, f = "leading"); "" !== d && (d = h(d, c, f), null === r(d, c) && t(d, c, a[0]) ? (d = s(d, c.aDec, c.aNeg), d = v(d, c), d = A(d, c.aDec, c.aNeg)) : d = ""); f = r(d, c, !1); null === f && (f = u(d, c)); f !== e && a.val(f); f !== b.inVal && (a.change(), delete b.inVal); null !== c.nBracket && 0 > a.autoNumeric("get") && (b.settingsClone.oEvent = "focusout", a.val(q(a.val(), c.nBracket, c.oEvent))) - })) - }) - }, destroy: function () { return f(this).each(function () { var b = f(this); b.off(".autoNumeric"); b.removeData("autoNumeric") }) }, - update: function (b) { - return f(this).each(function () { - var a = l(f(this)), c = a.data("autoNumeric"); if ("object" !== typeof c) return f.error("You must initialize autoNumeric('init', {options}) prior to calling the 'update' method"), this; var d = a.autoNumeric("get"), c = f.extend(c, b); k(a, c, !0); if (c.aDec === c.aSep) return f.error("autoNumeric will not function properly when the decimal character aDec: '" + c.aDec + "' and thousand separator aSep: '" + c.aSep + "' are the same character"), this; a.data("autoNumeric", c); if ("" !== - a.val() || "" !== a.text()) return a.autoNumeric("set", d) - }) - }, set: function (b) { - return f(this).each(function () { - var a = l(f(this)), c = a.data("autoNumeric"), d = b.toString(), e = b.toString(); if ("object" !== typeof c) return f.error("You must initialize autoNumeric('init', {options}) prior to calling the 'set' method"), this; e !== a.attr("value") && e !== a.text() || !1 !== c.runOnce || (d = d.replace(",", ".")); e !== a.attr("value") && "INPUT" === a.prop("tagName") && !1 === c.runOnce && (d = h(d, c)); if (!f.isNumeric(+d)) return ""; d = z(d, c); c.oEvent = - "set"; c.lastSetValue = d; d.toString(); "" !== d && (d = v(d, c)); d = A(d, c.aDec, c.aNeg); t(d, c) || (d = v("", c)); d = u(d, c); if (a.is("input[type=text], input[type=hidden], input:not([type])")) return a.val(d); if (-1 !== f.inArray(a.prop("tagName"), c.tagList)) return a.text(d); f.error("The <" + a.prop("tagName") + "> is not supported by autoNumeric()"); return !1 - }) - }, get: function () { - var b = l(f(this)), a = b.data("autoNumeric"); if ("object" !== typeof a) return f.error("You must initialize autoNumeric('init', {options}) prior to calling the 'get' method"), - this; a.oEvent = "get"; var c = ""; if (b.is("input[type=text], input[type=hidden], input:not([type])")) c = b.eq(0).val(); else if (-1 !== f.inArray(b.prop("tagName"), a.tagList)) c = b.eq(0).text(); else return f.error("The <" + b.prop("tagName") + "> is not supported by autoNumeric()"), !1; if ("" === c && "empty" === a.wEmpty || c === a.aSign && ("sign" === a.wEmpty || "empty" === a.wEmpty)) return ""; null !== a.nBracket && "" !== c && (c = q(c, a.nBracket, a.oEvent)); if (a.runOnce || !1 === a.aForm) c = h(c, a); c = s(c, a.aDec, a.aNeg); 0 === +c && "keep" !== a.lZero && - (c = "0"); return "keep" === a.lZero ? c : c = z(c, a) - }, getString: function () { - var b = !1, a = l(f(this)).serialize().split("&"), c = 0; for (c; c < a.length; c += 1) { var d = a[c].split("="); "object" === typeof f('*[name="' + decodeURIComponent(d[0]) + '"]').data("autoNumeric") && null !== d[1] && void 0 !== f('*[name="' + decodeURIComponent(d[0]) + '"]').data("autoNumeric") && (d[1] = f('input[name="' + decodeURIComponent(d[0]) + '"]').autoNumeric("get"), a[c] = d.join("="), b = !0) } if (!0 === b) return a.join("&"); f.error("You must initialize autoNumeric('init', {options}) prior to calling the 'getString' method"); - return this - }, getArray: function () { var b = !1, a = l(f(this)).serializeArray(); f.each(a, function (a, d) { "object" === typeof f('*[name="' + decodeURIComponent(d.name) + '"]').data("autoNumeric") && ("" !== d.value && void 0 !== f('*[name="' + decodeURIComponent(d.name) + '"]').data("autoNumeric") && (d.value = f('input[name="' + decodeURIComponent(d.name) + '"]').autoNumeric("get").toString()), b = !0) }); if (!0 === b) return a; f.error("You must initialize autoNumeric('init', {options}) prior to calling the 'getArray' method"); return this }, - getSettings: function () { return l(f(this)).eq(0).data("autoNumeric") } - }; f.fn.autoNumeric = function (b) { if (w[b]) return w[b].apply(this, Array.prototype.slice.call(arguments, 1)); if ("object" === typeof b || !b) return w.init.apply(this, arguments); f.error('Method "' + b + '" is not supported by autoNumeric()') } -})(jQuery); \ No newline at end of file diff --git a/dashboard-ui/tvshows.html b/dashboard-ui/tvshows.html index 363a6e897e..723480957e 100644 --- a/dashboard-ui/tvshows.html +++ b/dashboard-ui/tvshows.html @@ -24,6 +24,7 @@ diff --git a/dashboard-ui/wizardfinish.html b/dashboard-ui/wizardfinish.html index 81d2d74304..dee75dee5c 100644 --- a/dashboard-ui/wizardfinish.html +++ b/dashboard-ui/wizardfinish.html @@ -10,7 +10,7 @@

    - You're Done!

    + ${LabelYoureDone}

    That's all we need for now. Media Browser has begun collecting information about your media library. Check out some of our apps, and then click Finish to view the Dashboard.

    @@ -36,8 +36,8 @@

    - - + +
    diff --git a/dashboard-ui/wizardsettings.html b/dashboard-ui/wizardsettings.html index e17d128fe3..649357567e 100644 --- a/dashboard-ui/wizardsettings.html +++ b/dashboard-ui/wizardsettings.html @@ -21,7 +21,7 @@
    - +
    Saving artwork and metadata directly into media folders will put them in a place where they can be easily edited.
    diff --git a/dashboard-ui/wizarduser.html b/dashboard-ui/wizarduser.html index 609a21c36c..7fd2c27005 100644 --- a/dashboard-ui/wizarduser.html +++ b/dashboard-ui/wizarduser.html @@ -26,8 +26,8 @@
- - + +
diff --git a/packages.config b/packages.config index a874d5f6f9..b867f7a92c 100644 --- a/packages.config +++ b/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file