restore composer.json, add mysqli extension
This commit is contained in:
5
public/vendor/dashboard/app-assets/vendors/js/extensions/dataTables.checkboxes.min.js
vendored
Executable file
5
public/vendor/dashboard/app-assets/vendors/js/extensions/dataTables.checkboxes.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/vendor/dashboard/app-assets/vendors/js/extensions/dragula.min.js
vendored
Executable file
1
public/vendor/dashboard/app-assets/vendors/js/extensions/dragula.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/vendor/dashboard/app-assets/vendors/js/extensions/dropzone.min.js
vendored
Executable file
1
public/vendor/dashboard/app-assets/vendors/js/extensions/dropzone.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
6
public/vendor/dashboard/app-assets/vendors/js/extensions/gcal.js
vendored
Executable file
6
public/vendor/dashboard/app-assets/vendors/js/extensions/gcal.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/vendor/dashboard/app-assets/vendors/js/extensions/i18next.min.js
vendored
Executable file
1
public/vendor/dashboard/app-assets/vendors/js/extensions/i18next.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/vendor/dashboard/app-assets/vendors/js/extensions/i18nextBrowserLanguageDetector.min.js
vendored
Executable file
1
public/vendor/dashboard/app-assets/vendors/js/extensions/i18nextBrowserLanguageDetector.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/vendor/dashboard/app-assets/vendors/js/extensions/i18nextXHRBackend.min.js
vendored
Executable file
1
public/vendor/dashboard/app-assets/vendors/js/extensions/i18nextXHRBackend.min.js
vendored
Executable file
@@ -0,0 +1 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.i18nextXHRBackend=e()}(this,function(){"use strict";function t(t){return r.call(s.call(arguments,1),function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])}),t}function e(t,e){if(e&&"object"===(void 0===e?"undefined":l(e))){var n="",o=encodeURIComponent;for(var i in e)n+="&"+o(i)+"="+o(e[i]);if(!n)return t;t=t+(-1!==t.indexOf("?")?"&":"?")+n.slice(1)}return t}function n(t,n,o,i,a){i&&"object"===(void 0===i?"undefined":l(i))&&(a||(i._t=new Date),i=e("",i).slice(1)),n.queryStringParams&&(t=e(t,n.queryStringParams));try{var r;r=XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0"),r.open(i?"POST":"GET",t,1),n.crossDomain||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=!!n.withCredentials,i&&r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.overrideMimeType&&r.overrideMimeType("application/json");var s=n.customHeaders;if(s)for(var u in s)r.setRequestHeader(u,s[u]);r.onreadystatechange=function(){r.readyState>3&&o&&o(r.responseText,r)},r.send(i)}catch(t){console&&console.log(t)}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:JSON.parse,crossDomain:!1,ajax:n}}var a=[],r=a.forEach,s=a.slice,l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),c=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.init(t,n),this.type="backend"}return u(e,[{key:"init",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.services=e,this.options=t(n,this.options||{},i())}},{key:"readMulti",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(t,e));var i=this.services.interpolator.interpolate(o,{lng:t.join("+"),ns:e.join("+")});this.loadUrl(i,n)}},{key:"read",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([t],[e]));var i=this.services.interpolator.interpolate(o,{lng:t,ns:e});this.loadUrl(i,n)}},{key:"loadUrl",value:function(t,e){var n=this;this.options.ajax(t,this.options,function(o,i){if(i.status>=500&&i.status<600)return e("failed loading "+t,!0);if(i.status>=400&&i.status<500)return e("failed loading "+t,!1);var a=void 0,r=void 0;try{a=n.options.parse(o,t)}catch(e){r="failed parsing "+t+" to json"}if(r)return e(r,!1);e(null,a)})}},{key:"create",value:function(t,e,n,o){var i=this;"string"==typeof t&&(t=[t]);var a={};a[n]=o||"",t.forEach(function(t){var n=i.services.interpolator.interpolate(i.options.addPath,{lng:t,ns:e});i.options.ajax(n,i.options,function(t,e){},a)})}}]),e}();return c.type="backend",c});
|
||||
1
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery-i18next.min.js
vendored
Executable file
1
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery-i18next.min.js
vendored
Executable file
@@ -0,0 +1 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.jqueryI18next=e()}(this,function(){"use strict";function t(t,a){function i(n,a,i){function r(t,n){return f.parseDefaultValueFromContent?e({},t,{defaultValue:n}):t}if(0!==a.length){var o="text";if(0===a.indexOf("[")){var l=a.split("]");a=l[1],o=l[0].substr(1,l[0].length-1)}if(a.indexOf(";")===a.length-1&&(a=a.substr(0,a.length-2)),"html"===o)n.html(t.t(a,r(i,n.html())));else if("text"===o)n.text(t.t(a,r(i,n.text())));else if("prepend"===o)n.prepend(t.t(a,r(i,n.html())));else if("append"===o)n.append(t.t(a,r(i,n.html())));else if(0===o.indexOf("data-")){var s=o.substr("data-".length),d=t.t(a,r(i,n.data(s)));n.data(s,d),n.attr(o,d)}else n.attr(o,t.t(a,r(i,n.attr(o))))}}function r(t,n){var r=t.attr(f.selectorAttr);if(r||void 0===r||!1===r||(r=t.text()||t.val()),r){var o=t,l=t.data(f.targetAttr);if(l&&(o=t.find(l)||t),n||!0!==f.useOptionsAttr||(n=t.data(f.optionsAttr)),n=n||{},r.indexOf(";")>=0){var s=r.split(";");a.each(s,function(t,e){""!==e&&i(o,e.trim(),n)})}else i(o,r,n);if(!0===f.useOptionsAttr){var d={};d=e({clone:d},n),delete d.lng,t.data(f.optionsAttr,d)}}}function o(t){return this.each(function(){r(a(this),t),a(this).find("["+f.selectorAttr+"]").each(function(){r(a(this),t)})})}var f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};f=e({},n,f),a[f.tName]=t.t.bind(t),a[f.i18nName]=t,a.fn[f.handleName]=o}var e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},n={tName:"t",i18nName:"i18n",handleName:"localize",selectorAttr:"data-i18n",targetAttr:"i18n-target",optionsAttr:"i18n-options",useOptionsAttr:!1,parseDefaultValueFromContent:!0};return{init:t}});
|
||||
2
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.contextMenu.min.js
vendored
Executable file
2
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.contextMenu.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
8
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.mousewheel.min.js
vendored
Executable file
8
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.mousewheel.min.js
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
/*!
|
||||
* jQuery Mousewheel 3.1.13
|
||||
*
|
||||
* Copyright 2015 jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
|
||||
763
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.raty.js
vendored
Executable file
763
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.raty.js
vendored
Executable file
@@ -0,0 +1,763 @@
|
||||
/*!
|
||||
* jQuery Raty - A Star Rating Plugin
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* author: Washington Botelho
|
||||
* github: wbotelhos/raty
|
||||
* version: 2.9.0
|
||||
*
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
var methods = {
|
||||
init: function(options) {
|
||||
return this.each(function() {
|
||||
this.self = $(this);
|
||||
|
||||
methods.destroy.call(this.self);
|
||||
|
||||
this.opt = $.extend(true, {}, $.fn.raty.defaults, options, this.self.data());
|
||||
|
||||
methods._adjustCallback.call(this);
|
||||
methods._adjustNumber.call(this);
|
||||
methods._adjustHints.call(this);
|
||||
|
||||
this.opt.score = methods._adjustedScore.call(this, this.opt.score);
|
||||
|
||||
if (this.opt.starType !== 'img') {
|
||||
methods._adjustStarType.call(this);
|
||||
}
|
||||
|
||||
methods._adjustPath.call(this);
|
||||
methods._createStars.call(this);
|
||||
|
||||
if (this.opt.cancel) {
|
||||
methods._createCancel.call(this);
|
||||
}
|
||||
|
||||
if (this.opt.precision) {
|
||||
methods._adjustPrecision.call(this);
|
||||
}
|
||||
|
||||
methods._createScore.call(this);
|
||||
methods._apply.call(this, this.opt.score);
|
||||
methods._setTitle.call(this, this.opt.score);
|
||||
methods._target.call(this, this.opt.score);
|
||||
|
||||
if (this.opt.readOnly) {
|
||||
methods._lock.call(this);
|
||||
} else {
|
||||
this.style.cursor = 'pointer';
|
||||
|
||||
methods._binds.call(this);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_adjustCallback: function() {
|
||||
var options = ['number', 'readOnly', 'score', 'scoreName', 'target', 'path'];
|
||||
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
if (typeof this.opt[options[i]] === 'function') {
|
||||
this.opt[options[i]] = this.opt[options[i]].call(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_adjustedScore: function(score) {
|
||||
if (!score) {
|
||||
return score;
|
||||
}
|
||||
|
||||
return methods._between(score, 0, this.opt.number);
|
||||
},
|
||||
|
||||
_adjustHints: function() {
|
||||
if (!this.opt.hints) {
|
||||
this.opt.hints = [];
|
||||
}
|
||||
|
||||
if (!this.opt.halfShow && !this.opt.half) {
|
||||
return;
|
||||
}
|
||||
|
||||
var steps = this.opt.precision ? 10 : 2;
|
||||
|
||||
for (var i = 0; i < this.opt.number; i++) {
|
||||
var group = this.opt.hints[i];
|
||||
|
||||
if (Object.prototype.toString.call(group) !== '[object Array]') {
|
||||
group = [group];
|
||||
}
|
||||
|
||||
this.opt.hints[i] = [];
|
||||
|
||||
for (var j = 0; j < steps; j++) {
|
||||
var
|
||||
hint = group[j],
|
||||
last = group[group.length - 1];
|
||||
|
||||
if (last === undefined) {
|
||||
last = null;
|
||||
}
|
||||
|
||||
this.opt.hints[i][j] = hint === undefined ? last : hint;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_adjustNumber: function() {
|
||||
this.opt.number = methods._between(this.opt.number, 1, this.opt.numberMax);
|
||||
},
|
||||
|
||||
_adjustPath: function() {
|
||||
this.opt.path = this.opt.path || '';
|
||||
|
||||
if (this.opt.path && this.opt.path.charAt(this.opt.path.length - 1) !== '/') {
|
||||
this.opt.path += '/';
|
||||
}
|
||||
},
|
||||
|
||||
_adjustPrecision: function() {
|
||||
this.opt.half = true;
|
||||
},
|
||||
|
||||
_adjustStarType: function() {
|
||||
var replaces = ['cancelOff', 'cancelOn', 'starHalf', 'starOff', 'starOn'];
|
||||
|
||||
this.opt.path = '';
|
||||
|
||||
for (var i = 0; i < replaces.length; i++) {
|
||||
this.opt[replaces[i]] = this.opt[replaces[i]].replace('.', '-');
|
||||
}
|
||||
},
|
||||
|
||||
_apply: function(score) {
|
||||
methods._fill.call(this, score);
|
||||
|
||||
if (score) {
|
||||
if (score > 0) {
|
||||
this.score.val(score);
|
||||
}
|
||||
|
||||
methods._roundStars.call(this, score);
|
||||
}
|
||||
},
|
||||
|
||||
_between: function(value, min, max) {
|
||||
return Math.min(Math.max(parseFloat(value), min), max);
|
||||
},
|
||||
|
||||
_binds: function() {
|
||||
if (this.cancel) {
|
||||
methods._bindOverCancel.call(this);
|
||||
methods._bindClickCancel.call(this);
|
||||
methods._bindOutCancel.call(this);
|
||||
}
|
||||
|
||||
methods._bindOver.call(this);
|
||||
methods._bindClick.call(this);
|
||||
methods._bindOut.call(this);
|
||||
},
|
||||
|
||||
_bindClick: function() {
|
||||
var that = this;
|
||||
|
||||
that.stars.on('click.raty', function(evt) {
|
||||
var
|
||||
execute = true,
|
||||
score = (that.opt.half || that.opt.precision) ? that.self.data('score') : (this.alt || $(this).data('alt'));
|
||||
|
||||
if (that.opt.click) {
|
||||
execute = that.opt.click.call(that, +score, evt);
|
||||
}
|
||||
|
||||
if (execute || execute === undefined) {
|
||||
if (that.opt.half && !that.opt.precision) {
|
||||
score = methods._roundHalfScore.call(that, score);
|
||||
}
|
||||
|
||||
methods._apply.call(that, score);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_bindClickCancel: function() {
|
||||
var that = this;
|
||||
|
||||
that.cancel.on('click.raty', function(evt) {
|
||||
that.score.removeAttr('value');
|
||||
|
||||
if (that.opt.click) {
|
||||
that.opt.click.call(that, null, evt);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_bindOut: function() {
|
||||
var that = this;
|
||||
|
||||
that.self.on('mouseleave.raty', function(evt) {
|
||||
var score = +that.score.val() || undefined;
|
||||
|
||||
methods._apply.call(that, score);
|
||||
methods._target.call(that, score, evt);
|
||||
methods._resetTitle.call(that);
|
||||
|
||||
if (that.opt.mouseout) {
|
||||
that.opt.mouseout.call(that, score, evt);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_bindOutCancel: function() {
|
||||
var that = this;
|
||||
|
||||
that.cancel.on('mouseleave.raty', function(evt) {
|
||||
var icon = that.opt.cancelOff;
|
||||
|
||||
if (that.opt.starType !== 'img') {
|
||||
icon = that.opt.cancelClass + ' ' + icon;
|
||||
}
|
||||
|
||||
methods._setIcon.call(that, this, icon);
|
||||
|
||||
if (that.opt.mouseout) {
|
||||
var score = +that.score.val() || undefined;
|
||||
|
||||
that.opt.mouseout.call(that, score, evt);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_bindOver: function() {
|
||||
var
|
||||
that = this,
|
||||
action = that.opt.half ? 'mousemove.raty' : 'mouseover.raty';
|
||||
|
||||
that.stars.on(action, function(evt) {
|
||||
var score = methods._getScoreByPosition.call(that, evt, this);
|
||||
|
||||
methods._fill.call(that, score);
|
||||
|
||||
if (that.opt.half) {
|
||||
methods._roundStars.call(that, score, evt);
|
||||
methods._setTitle.call(that, score, evt);
|
||||
|
||||
that.self.data('score', score);
|
||||
}
|
||||
|
||||
methods._target.call(that, score, evt);
|
||||
|
||||
if (that.opt.mouseover) {
|
||||
that.opt.mouseover.call(that, score, evt);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_bindOverCancel: function() {
|
||||
var that = this;
|
||||
|
||||
that.cancel.on('mouseover.raty', function(evt) {
|
||||
var
|
||||
starOff = that.opt.path + that.opt.starOff,
|
||||
icon = that.opt.cancelOn;
|
||||
|
||||
if (that.opt.starType === 'img') {
|
||||
that.stars.attr('src', starOff);
|
||||
} else {
|
||||
icon = that.opt.cancelClass + ' ' + icon;
|
||||
|
||||
that.stars.attr('class', starOff);
|
||||
}
|
||||
|
||||
methods._setIcon.call(that, this, icon);
|
||||
methods._target.call(that, null, evt);
|
||||
|
||||
if (that.opt.mouseover) {
|
||||
that.opt.mouseover.call(that, null);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_buildScoreField: function() {
|
||||
return $('<input />', { name: this.opt.scoreName, type: 'hidden' }).appendTo(this);
|
||||
},
|
||||
|
||||
_createCancel: function() {
|
||||
var
|
||||
icon = this.opt.path + this.opt.cancelOff,
|
||||
cancel = $('<' + this.opt.starType + ' />', { title: this.opt.cancelHint, 'class': this.opt.cancelClass });
|
||||
|
||||
if (this.opt.starType === 'img') {
|
||||
cancel.attr({ src: icon, alt: 'x' });
|
||||
} else {
|
||||
// TODO: use $.data
|
||||
cancel.attr('data-alt', 'x').addClass(icon);
|
||||
}
|
||||
|
||||
if (this.opt.cancelPlace === 'left') {
|
||||
this.self.prepend(' ').prepend(cancel);
|
||||
} else {
|
||||
this.self.append(' ').append(cancel);
|
||||
}
|
||||
|
||||
this.cancel = cancel;
|
||||
},
|
||||
|
||||
_createScore: function() {
|
||||
var score = $(this.opt.targetScore);
|
||||
|
||||
this.score = score.length ? score : methods._buildScoreField.call(this);
|
||||
},
|
||||
|
||||
_createStars: function() {
|
||||
for (var i = 1; i <= this.opt.number; i++) {
|
||||
var
|
||||
name = methods._nameForIndex.call(this, i),
|
||||
attrs = { alt: i, src: this.opt.path + this.opt[name] };
|
||||
|
||||
if (this.opt.starType !== 'img') {
|
||||
attrs = { 'data-alt': i, 'class': attrs.src }; // TODO: use $.data.
|
||||
}
|
||||
|
||||
attrs.title = methods._getHint.call(this, i);
|
||||
|
||||
$('<' + this.opt.starType + ' />', attrs).appendTo(this);
|
||||
|
||||
if (this.opt.space) {
|
||||
this.self.append(i < this.opt.number ? ' ' : '');
|
||||
}
|
||||
}
|
||||
|
||||
this.stars = this.self.children(this.opt.starType);
|
||||
},
|
||||
|
||||
_error: function(message) {
|
||||
$(this).text(message);
|
||||
|
||||
$.error(message);
|
||||
},
|
||||
|
||||
_fill: function(score) {
|
||||
var hash = 0;
|
||||
|
||||
for (var i = 1; i <= this.stars.length; i++) {
|
||||
var
|
||||
icon,
|
||||
star = this.stars[i - 1],
|
||||
turnOn = methods._turnOn.call(this, i, score);
|
||||
|
||||
if (this.opt.iconRange && this.opt.iconRange.length > hash) {
|
||||
var irange = this.opt.iconRange[hash];
|
||||
|
||||
icon = methods._getRangeIcon.call(this, irange, turnOn);
|
||||
|
||||
if (i <= irange.range) {
|
||||
methods._setIcon.call(this, star, icon);
|
||||
}
|
||||
|
||||
if (i === irange.range) {
|
||||
hash++;
|
||||
}
|
||||
} else {
|
||||
icon = this.opt[turnOn ? 'starOn' : 'starOff'];
|
||||
|
||||
methods._setIcon.call(this, star, icon);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_getFirstDecimal: function(number) {
|
||||
var
|
||||
decimal = number.toString().split('.')[1],
|
||||
result = 0;
|
||||
|
||||
if (decimal) {
|
||||
result = parseInt(decimal.charAt(0), 10);
|
||||
|
||||
if (decimal.slice(1, 5) === '9999') {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_getRangeIcon: function(irange, turnOn) {
|
||||
return turnOn ? irange.on || this.opt.starOn : irange.off || this.opt.starOff;
|
||||
},
|
||||
|
||||
_getScoreByPosition: function(evt, icon) {
|
||||
var score = parseInt(icon.alt || icon.getAttribute('data-alt'), 10);
|
||||
|
||||
if (this.opt.half) {
|
||||
var
|
||||
size = methods._getWidth.call(this),
|
||||
percent = parseFloat((evt.pageX - $(icon).offset().left) / size);
|
||||
|
||||
score = score - 1 + percent;
|
||||
}
|
||||
|
||||
return score;
|
||||
},
|
||||
|
||||
_getHint: function(score, evt) {
|
||||
if (score !== 0 && !score) {
|
||||
return this.opt.noRatedMsg;
|
||||
}
|
||||
|
||||
var
|
||||
decimal = methods._getFirstDecimal.call(this, score),
|
||||
integer = Math.ceil(score),
|
||||
group = this.opt.hints[(integer || 1) - 1],
|
||||
hint = group,
|
||||
set = !evt || this.move;
|
||||
|
||||
if (this.opt.precision) {
|
||||
if (set) {
|
||||
decimal = decimal === 0 ? 9 : decimal - 1;
|
||||
}
|
||||
|
||||
hint = group[decimal];
|
||||
} else if (this.opt.halfShow || this.opt.half) {
|
||||
decimal = set && decimal === 0 ? 1 : decimal > 5 ? 1 : 0;
|
||||
|
||||
hint = group[decimal];
|
||||
}
|
||||
|
||||
return hint === '' ? '' : hint || score;
|
||||
},
|
||||
|
||||
_getWidth: function() {
|
||||
var width = this.stars[0].width || parseFloat(this.stars.eq(0).css('font-size'));
|
||||
|
||||
if (!width) {
|
||||
methods._error.call(this, 'Could not get the icon width!');
|
||||
}
|
||||
|
||||
return width;
|
||||
},
|
||||
|
||||
_lock: function() {
|
||||
var hint = methods._getHint.call(this, this.score.val());
|
||||
|
||||
this.style.cursor = '';
|
||||
this.title = hint;
|
||||
|
||||
this.score.prop('readonly', true);
|
||||
this.stars.prop('title', hint);
|
||||
|
||||
if (this.cancel) {
|
||||
this.cancel.hide();
|
||||
}
|
||||
|
||||
this.self.data('readonly', true);
|
||||
},
|
||||
|
||||
_nameForIndex: function(i) {
|
||||
return this.opt.score && this.opt.score >= i ? 'starOn' : 'starOff';
|
||||
},
|
||||
|
||||
_resetTitle: function() {
|
||||
for (var i = 0; i < this.opt.number; i++) {
|
||||
this.stars[i].title = methods._getHint.call(this, i + 1);
|
||||
}
|
||||
},
|
||||
|
||||
_roundHalfScore: function(score) {
|
||||
var
|
||||
integer = parseInt(score, 10),
|
||||
decimal = methods._getFirstDecimal.call(this, score);
|
||||
|
||||
if (decimal !== 0) {
|
||||
decimal = decimal > 5 ? 1 : 0.5;
|
||||
}
|
||||
|
||||
return integer + decimal;
|
||||
},
|
||||
|
||||
_roundStars: function(score, evt) {
|
||||
var
|
||||
decimal = (score % 1).toFixed(2),
|
||||
name ;
|
||||
|
||||
if (evt || this.move) {
|
||||
name = decimal > 0.5 ? 'starOn' : 'starHalf';
|
||||
} else if (decimal > this.opt.round.down) { // Up: [x.76 .. x.99]
|
||||
name = 'starOn';
|
||||
|
||||
if (this.opt.halfShow && decimal < this.opt.round.up) { // Half: [x.26 .. x.75]
|
||||
name = 'starHalf';
|
||||
} else if (decimal < this.opt.round.full) { // Down: [x.00 .. x.5]
|
||||
name = 'starOff';
|
||||
}
|
||||
}
|
||||
|
||||
if (name) {
|
||||
var
|
||||
icon = this.opt[name],
|
||||
star = this.stars[Math.ceil(score) - 1];
|
||||
|
||||
methods._setIcon.call(this, star, icon);
|
||||
} // Full down: [x.00 .. x.25]
|
||||
},
|
||||
|
||||
_setIcon: function(star, icon) {
|
||||
star[this.opt.starType === 'img' ? 'src' : 'className'] = this.opt.path + icon;
|
||||
},
|
||||
|
||||
_setTarget: function(target, score) {
|
||||
if (score) {
|
||||
score = this.opt.targetFormat.toString().replace('{score}', score);
|
||||
}
|
||||
|
||||
if (target.is(':input')) {
|
||||
target.val(score);
|
||||
} else {
|
||||
target.html(score);
|
||||
}
|
||||
},
|
||||
|
||||
_setTitle: function(score, evt) {
|
||||
if (score) {
|
||||
var
|
||||
integer = parseInt(Math.ceil(score), 10),
|
||||
star = this.stars[integer - 1];
|
||||
|
||||
star.title = methods._getHint.call(this, score, evt);
|
||||
}
|
||||
},
|
||||
|
||||
_target: function(score, evt) {
|
||||
if (this.opt.target) {
|
||||
var target = $(this.opt.target);
|
||||
|
||||
if (!target.length) {
|
||||
methods._error.call(this, 'Target selector invalid or missing!');
|
||||
}
|
||||
|
||||
var mouseover = evt && evt.type === 'mouseover';
|
||||
|
||||
if (score === undefined) {
|
||||
score = this.opt.targetText;
|
||||
} else if (score === null) {
|
||||
score = mouseover ? this.opt.cancelHint : this.opt.targetText;
|
||||
} else {
|
||||
if (this.opt.targetType === 'hint') {
|
||||
score = methods._getHint.call(this, score, evt);
|
||||
} else if (this.opt.precision) {
|
||||
score = parseFloat(score).toFixed(1);
|
||||
}
|
||||
|
||||
var mousemove = evt && evt.type === 'mousemove';
|
||||
|
||||
if (!mouseover && !mousemove && !this.opt.targetKeep) {
|
||||
score = this.opt.targetText;
|
||||
}
|
||||
}
|
||||
|
||||
methods._setTarget.call(this, target, score);
|
||||
}
|
||||
},
|
||||
|
||||
_turnOn: function(i, score) {
|
||||
return this.opt.single ? (i === score) : (i <= score);
|
||||
},
|
||||
|
||||
_unlock: function() {
|
||||
this.style.cursor = 'pointer';
|
||||
this.removeAttribute('title');
|
||||
|
||||
this.score.removeAttr('readonly');
|
||||
|
||||
this.self.data('readonly', false);
|
||||
|
||||
for (var i = 0; i < this.opt.number; i++) {
|
||||
this.stars[i].title = methods._getHint.call(this, i + 1);
|
||||
}
|
||||
|
||||
if (this.cancel) {
|
||||
this.cancel.css('display', '');
|
||||
}
|
||||
},
|
||||
|
||||
cancel: function(click) {
|
||||
return this.each(function() {
|
||||
var self = $(this);
|
||||
|
||||
if (self.data('readonly') !== true) {
|
||||
methods[click ? 'click' : 'score'].call(self, null);
|
||||
|
||||
this.score.removeAttr('value');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
click: function(score) {
|
||||
return this.each(function() {
|
||||
if ($(this).data('readonly') !== true) {
|
||||
score = methods._adjustedScore.call(this, score);
|
||||
|
||||
methods._apply.call(this, score);
|
||||
|
||||
if (this.opt.click) {
|
||||
this.opt.click.call(this, score, $.Event('click'));
|
||||
}
|
||||
|
||||
methods._target.call(this, score);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
return this.each(function() {
|
||||
var
|
||||
self = $(this),
|
||||
raw = self.data('raw');
|
||||
|
||||
if (raw) {
|
||||
self.off('.raty').empty().css({ cursor: raw.style.cursor }).removeData('readonly');
|
||||
} else {
|
||||
self.data('raw', self.clone()[0]);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getScore: function() {
|
||||
var
|
||||
score = [],
|
||||
value ;
|
||||
|
||||
this.each(function() {
|
||||
value = this.score.val();
|
||||
|
||||
score.push(value ? +value : undefined);
|
||||
});
|
||||
|
||||
return (score.length > 1) ? score : score[0];
|
||||
},
|
||||
|
||||
move: function(score) {
|
||||
return this.each(function() {
|
||||
var
|
||||
integer = parseInt(score, 10),
|
||||
decimal = methods._getFirstDecimal.call(this, score);
|
||||
|
||||
if (integer >= this.opt.number) {
|
||||
integer = this.opt.number - 1;
|
||||
decimal = 10;
|
||||
}
|
||||
|
||||
var
|
||||
width = methods._getWidth.call(this),
|
||||
steps = width / 10,
|
||||
star = $(this.stars[integer]),
|
||||
percent = star.offset().left + steps * decimal,
|
||||
evt = $.Event('mousemove', { pageX: percent });
|
||||
|
||||
this.move = true;
|
||||
|
||||
star.trigger(evt);
|
||||
|
||||
this.move = false;
|
||||
});
|
||||
},
|
||||
|
||||
readOnly: function(readonly) {
|
||||
return this.each(function() {
|
||||
var self = $(this);
|
||||
|
||||
if (self.data('readonly') !== readonly) {
|
||||
if (readonly) {
|
||||
self.off('.raty').children(this.opt.starType).off('.raty');
|
||||
|
||||
methods._lock.call(this);
|
||||
} else {
|
||||
methods._binds.call(this);
|
||||
methods._unlock.call(this);
|
||||
}
|
||||
|
||||
self.data('readonly', readonly);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
reload: function() {
|
||||
return methods.set.call(this, {});
|
||||
},
|
||||
|
||||
score: function() {
|
||||
var self = $(this);
|
||||
|
||||
return arguments.length ? methods.setScore.apply(self, arguments) : methods.getScore.call(self);
|
||||
},
|
||||
|
||||
set: function(options) {
|
||||
return this.each(function() {
|
||||
$(this).raty($.extend({}, this.opt, options));
|
||||
});
|
||||
},
|
||||
|
||||
setScore: function(score) {
|
||||
return this.each(function() {
|
||||
if ($(this).data('readonly') !== true) {
|
||||
score = methods._adjustedScore.call(this, score);
|
||||
|
||||
methods._apply.call(this, score);
|
||||
methods._target.call(this, score);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.raty = function(method) {
|
||||
if (methods[method]) {
|
||||
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
} else if (typeof method === 'object' || !method) {
|
||||
return methods.init.apply(this, arguments);
|
||||
} else {
|
||||
$.error('Method ' + method + ' does not exist!');
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.raty.defaults = {
|
||||
cancel: false,
|
||||
cancelClass: 'raty-cancel',
|
||||
cancelHint: 'Cancel this rating!',
|
||||
cancelOff: 'cancel-off.png',
|
||||
cancelOn: 'cancel-on.png',
|
||||
cancelPlace: 'left',
|
||||
click: undefined,
|
||||
half: false,
|
||||
halfShow: true,
|
||||
hints: ['bad', 'poor', 'regular', 'good', 'gorgeous'],
|
||||
iconRange: undefined,
|
||||
mouseout: undefined,
|
||||
mouseover: undefined,
|
||||
noRatedMsg: 'Not rated yet!',
|
||||
number: 5,
|
||||
numberMax: 20,
|
||||
path: undefined,
|
||||
precision: false,
|
||||
readOnly: false,
|
||||
round: { down: 0.25, full: 0.6, up: 0.76 },
|
||||
score: undefined,
|
||||
scoreName: 'score',
|
||||
single: false,
|
||||
space: true,
|
||||
starHalf: 'star-half.png',
|
||||
starOff: 'star-off.png',
|
||||
starOn: 'star-on.png',
|
||||
starType: 'img',
|
||||
target: undefined,
|
||||
targetFormat: '{score}',
|
||||
targetKeep: false,
|
||||
targetScore: undefined,
|
||||
targetText: '',
|
||||
targetType: 'hint'
|
||||
};
|
||||
})(jQuery);
|
||||
6
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.steps.min.js
vendored
Executable file
6
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.steps.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
6
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.ui.position.min.js
vendored
Executable file
6
public/vendor/dashboard/app-assets/vendors/js/extensions/jquery.ui.position.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
6
public/vendor/dashboard/app-assets/vendors/js/extensions/lang-all.js
vendored
Executable file
6
public/vendor/dashboard/app-assets/vendors/js/extensions/lang-all.js
vendored
Executable file
File diff suppressed because one or more lines are too long
6
public/vendor/dashboard/app-assets/vendors/js/extensions/locale-all.js
vendored
Executable file
6
public/vendor/dashboard/app-assets/vendors/js/extensions/locale-all.js
vendored
Executable file
File diff suppressed because one or more lines are too long
6
public/vendor/dashboard/app-assets/vendors/js/extensions/moment.min.js
vendored
Executable file
6
public/vendor/dashboard/app-assets/vendors/js/extensions/moment.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
2
public/vendor/dashboard/app-assets/vendors/js/extensions/nouislider.min.js
vendored
Executable file
2
public/vendor/dashboard/app-assets/vendors/js/extensions/nouislider.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
2
public/vendor/dashboard/app-assets/vendors/js/extensions/pace.min.js
vendored
Executable file
2
public/vendor/dashboard/app-assets/vendors/js/extensions/pace.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/vendor/dashboard/app-assets/vendors/js/extensions/polyfill.min.js
vendored
Executable file
1
public/vendor/dashboard/app-assets/vendors/js/extensions/polyfill.min.js
vendored
Executable file
@@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(e){var n=this.constructor;return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){return n.reject(t)})})}function n(){}function t(e){if(!(this instanceof t))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],u(e,this)}function o(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,t._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null!==t){var o;try{o=t(e._value)}catch(f){return void i(n.promise,f)}r(n.promise,o)}else(1===e._state?r:i)(n.promise,e._value)})):e._deferreds.push(n)}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var o=n.then;if(n instanceof t)return e._state=3,e._value=n,void f(e);if("function"==typeof o)return void u(function(e,n){return function(){e.apply(n,arguments)}}(o,n),e)}e._state=1,e._value=n,f(e)}catch(r){i(e,r)}}function i(e,n){e._state=2,e._value=n,f(e)}function f(e){2===e._state&&0===e._deferreds.length&&t._immediateFn(function(){e._handled||t._unhandledRejectionFn(e._value)});for(var n=0,r=e._deferreds.length;r>n;n++)o(e,e._deferreds[n]);e._deferreds=null}function u(e,n){var t=!1;try{e(function(e){t||(t=!0,r(n,e))},function(e){t||(t=!0,i(n,e))})}catch(o){if(t)return;t=!0,i(n,o)}}var c=setTimeout;t.prototype["catch"]=function(e){return this.then(null,e)},t.prototype.then=function(e,t){var r=new this.constructor(n);return o(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(e,t,r)),r},t.prototype["finally"]=e,t.all=function(e){return new t(function(n,t){function o(e,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(n){o(e,n)},t)}r[e]=f,0==--i&&n(r)}catch(c){t(c)}}if(!e||"undefined"==typeof e.length)throw new TypeError("Promise.all accepts an array");var r=Array.prototype.slice.call(e);if(0===r.length)return n([]);for(var i=r.length,f=0;r.length>f;f++)o(f,r[f])})},t.resolve=function(e){return e&&"object"==typeof e&&e.constructor===t?e:new t(function(n){n(e)})},t.reject=function(e){return new t(function(n,t){t(e)})},t.race=function(e){return new t(function(n,t){for(var o=0,r=e.length;r>o;o++)e[o].then(n,t)})},t._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){c(e,0)},t._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype["finally"]||(l.Promise.prototype["finally"]=e):l.Promise=t});
|
||||
2164
public/vendor/dashboard/app-assets/vendors/js/extensions/shepherd.min.js
vendored
Executable file
2164
public/vendor/dashboard/app-assets/vendors/js/extensions/shepherd.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
2
public/vendor/dashboard/app-assets/vendors/js/extensions/sweetalert2.all.min.js
vendored
Executable file
2
public/vendor/dashboard/app-assets/vendors/js/extensions/sweetalert2.all.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/vendor/dashboard/app-assets/vendors/js/extensions/tether.min.js
vendored
Executable file
1
public/vendor/dashboard/app-assets/vendors/js/extensions/tether.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
3
public/vendor/dashboard/app-assets/vendors/js/extensions/toastr.min.js
vendored
Executable file
3
public/vendor/dashboard/app-assets/vendors/js/extensions/toastr.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
59
public/vendor/dashboard/app-assets/vendors/js/extensions/transition.js
vendored
Executable file
59
public/vendor/dashboard/app-assets/vendors/js/extensions/transition.js
vendored
Executable file
@@ -0,0 +1,59 @@
|
||||
;(function(){
|
||||
/* ========================================================================
|
||||
* Bootstrap: transition.js v3.0.2
|
||||
* http://getbootstrap.com/javascript/#transitions
|
||||
* ========================================================================
|
||||
* Copyright 2013 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ======================================================================== */
|
||||
|
||||
|
||||
+function ($) { "use strict";
|
||||
|
||||
// CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
|
||||
// ============================================================
|
||||
|
||||
function transitionEnd() {
|
||||
var el = document.createElement('bootstrap')
|
||||
|
||||
var transEndEventNames = {
|
||||
'WebkitTransition' : 'webkitTransitionEnd'
|
||||
, 'MozTransition' : 'transitionend'
|
||||
, 'OTransition' : 'oTransitionEnd otransitionend'
|
||||
, 'transition' : 'transitionend'
|
||||
}
|
||||
|
||||
for (var name in transEndEventNames) {
|
||||
if (el.style[name] !== undefined) {
|
||||
return { end: transEndEventNames[name] }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// http://blog.alexmaccaw.com/css-transitions
|
||||
$.fn.emulateTransitionEnd = function (duration) {
|
||||
var called = false, $el = this
|
||||
$(this).one($.support.transition.end, function () { called = true })
|
||||
var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
|
||||
setTimeout(callback, duration)
|
||||
return this
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$.support.transition = transitionEnd()
|
||||
})
|
||||
|
||||
}(jQuery);
|
||||
|
||||
})();
|
||||
6
public/vendor/dashboard/app-assets/vendors/js/extensions/underscore-min.js
vendored
Executable file
6
public/vendor/dashboard/app-assets/vendors/js/extensions/underscore-min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/vendor/dashboard/app-assets/vendors/js/extensions/unslider-min.js
vendored
Executable file
1
public/vendor/dashboard/app-assets/vendors/js/extensions/unslider-min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
353
public/vendor/dashboard/app-assets/vendors/js/extensions/wNumb.js
vendored
Executable file
353
public/vendor/dashboard/app-assets/vendors/js/extensions/wNumb.js
vendored
Executable file
@@ -0,0 +1,353 @@
|
||||
(function (factory) {
|
||||
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define([], factory);
|
||||
|
||||
} else if ( typeof exports === 'object' ) {
|
||||
|
||||
// Node/CommonJS
|
||||
module.exports = factory();
|
||||
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
window.wNumb = factory();
|
||||
}
|
||||
|
||||
}(function(){
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
/** @const */ FormatOptions = [
|
||||
'decimals',
|
||||
'thousand',
|
||||
'mark',
|
||||
'prefix',
|
||||
'postfix',
|
||||
'encoder',
|
||||
'decoder',
|
||||
'negativeBefore',
|
||||
'negative',
|
||||
'edit',
|
||||
'undo'
|
||||
];
|
||||
|
||||
// General
|
||||
|
||||
// Reverse a string
|
||||
function strReverse ( a ) {
|
||||
return a.split('').reverse().join('');
|
||||
}
|
||||
|
||||
// Check if a string starts with a specified prefix.
|
||||
function strStartsWith ( input, match ) {
|
||||
return input.substring(0, match.length) === match;
|
||||
}
|
||||
|
||||
// Check is a string ends in a specified postfix.
|
||||
function strEndsWith ( input, match ) {
|
||||
return input.slice(-1 * match.length) === match;
|
||||
}
|
||||
|
||||
// Throw an error if formatting options are incompatible.
|
||||
function throwEqualError( F, a, b ) {
|
||||
if ( (F[a] || F[b]) && (F[a] === F[b]) ) {
|
||||
throw new Error(a);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a number is finite and not NaN
|
||||
function isValidNumber ( input ) {
|
||||
return typeof input === 'number' && isFinite( input );
|
||||
}
|
||||
|
||||
// Provide rounding-accurate toFixed method.
|
||||
function toFixed ( value, decimals ) {
|
||||
var scale = Math.pow(10, decimals);
|
||||
return ( Math.round(value * scale) / scale).toFixed( decimals );
|
||||
}
|
||||
|
||||
|
||||
// Formatting
|
||||
|
||||
// Accept a number as input, output formatted string.
|
||||
function formatTo ( decimals, thousand, mark, prefix, postfix, encoder, decoder, negativeBefore, negative, edit, undo, input ) {
|
||||
|
||||
var originalInput = input, inputIsNegative, inputPieces, inputBase, inputDecimals = '', output = '';
|
||||
|
||||
// Apply user encoder to the input.
|
||||
// Expected outcome: number.
|
||||
if ( encoder ) {
|
||||
input = encoder(input);
|
||||
}
|
||||
|
||||
// Stop if no valid number was provided, the number is infinite or NaN.
|
||||
if ( !isValidNumber(input) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Rounding away decimals might cause a value of -0
|
||||
// when using very small ranges. Remove those cases.
|
||||
if ( decimals !== false && parseFloat(input.toFixed(decimals)) === 0 ) {
|
||||
input = 0;
|
||||
}
|
||||
|
||||
// Formatting is done on absolute numbers,
|
||||
// decorated by an optional negative symbol.
|
||||
if ( input < 0 ) {
|
||||
inputIsNegative = true;
|
||||
input = Math.abs(input);
|
||||
}
|
||||
|
||||
// Reduce the number of decimals to the specified option.
|
||||
if ( decimals !== false ) {
|
||||
input = toFixed( input, decimals );
|
||||
}
|
||||
|
||||
// Transform the number into a string, so it can be split.
|
||||
input = input.toString();
|
||||
|
||||
// Break the number on the decimal separator.
|
||||
if ( input.indexOf('.') !== -1 ) {
|
||||
inputPieces = input.split('.');
|
||||
|
||||
inputBase = inputPieces[0];
|
||||
|
||||
if ( mark ) {
|
||||
inputDecimals = mark + inputPieces[1];
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// If it isn't split, the entire number will do.
|
||||
inputBase = input;
|
||||
}
|
||||
|
||||
// Group numbers in sets of three.
|
||||
if ( thousand ) {
|
||||
inputBase = strReverse(inputBase).match(/.{1,3}/g);
|
||||
inputBase = strReverse(inputBase.join( strReverse( thousand ) ));
|
||||
}
|
||||
|
||||
// If the number is negative, prefix with negation symbol.
|
||||
if ( inputIsNegative && negativeBefore ) {
|
||||
output += negativeBefore;
|
||||
}
|
||||
|
||||
// Prefix the number
|
||||
if ( prefix ) {
|
||||
output += prefix;
|
||||
}
|
||||
|
||||
// Normal negative option comes after the prefix. Defaults to '-'.
|
||||
if ( inputIsNegative && negative ) {
|
||||
output += negative;
|
||||
}
|
||||
|
||||
// Append the actual number.
|
||||
output += inputBase;
|
||||
output += inputDecimals;
|
||||
|
||||
// Apply the postfix.
|
||||
if ( postfix ) {
|
||||
output += postfix;
|
||||
}
|
||||
|
||||
// Run the output through a user-specified post-formatter.
|
||||
if ( edit ) {
|
||||
output = edit ( output, originalInput );
|
||||
}
|
||||
|
||||
// All done.
|
||||
return output;
|
||||
}
|
||||
|
||||
// Accept a sting as input, output decoded number.
|
||||
function formatFrom ( decimals, thousand, mark, prefix, postfix, encoder, decoder, negativeBefore, negative, edit, undo, input ) {
|
||||
|
||||
var originalInput = input, inputIsNegative, output = '';
|
||||
|
||||
// User defined pre-decoder. Result must be a non empty string.
|
||||
if ( undo ) {
|
||||
input = undo(input);
|
||||
}
|
||||
|
||||
// Test the input. Can't be empty.
|
||||
if ( !input || typeof input !== 'string' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the string starts with the negativeBefore value: remove it.
|
||||
// Remember is was there, the number is negative.
|
||||
if ( negativeBefore && strStartsWith(input, negativeBefore) ) {
|
||||
input = input.replace(negativeBefore, '');
|
||||
inputIsNegative = true;
|
||||
}
|
||||
|
||||
// Repeat the same procedure for the prefix.
|
||||
if ( prefix && strStartsWith(input, prefix) ) {
|
||||
input = input.replace(prefix, '');
|
||||
}
|
||||
|
||||
// And again for negative.
|
||||
if ( negative && strStartsWith(input, negative) ) {
|
||||
input = input.replace(negative, '');
|
||||
inputIsNegative = true;
|
||||
}
|
||||
|
||||
// Remove the postfix.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice
|
||||
if ( postfix && strEndsWith(input, postfix) ) {
|
||||
input = input.slice(0, -1 * postfix.length);
|
||||
}
|
||||
|
||||
// Remove the thousand grouping.
|
||||
if ( thousand ) {
|
||||
input = input.split(thousand).join('');
|
||||
}
|
||||
|
||||
// Set the decimal separator back to period.
|
||||
if ( mark ) {
|
||||
input = input.replace(mark, '.');
|
||||
}
|
||||
|
||||
// Prepend the negative symbol.
|
||||
if ( inputIsNegative ) {
|
||||
output += '-';
|
||||
}
|
||||
|
||||
// Add the number
|
||||
output += input;
|
||||
|
||||
// Trim all non-numeric characters (allow '.' and '-');
|
||||
output = output.replace(/[^0-9\.\-.]/g, '');
|
||||
|
||||
// The value contains no parse-able number.
|
||||
if ( output === '' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Covert to number.
|
||||
output = Number(output);
|
||||
|
||||
// Run the user-specified post-decoder.
|
||||
if ( decoder ) {
|
||||
output = decoder(output);
|
||||
}
|
||||
|
||||
// Check is the output is valid, otherwise: return false.
|
||||
if ( !isValidNumber(output) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
// Framework
|
||||
|
||||
// Validate formatting options
|
||||
function validate ( inputOptions ) {
|
||||
|
||||
var i, optionName, optionValue,
|
||||
filteredOptions = {};
|
||||
|
||||
for ( i = 0; i < FormatOptions.length; i+=1 ) {
|
||||
|
||||
optionName = FormatOptions[i];
|
||||
optionValue = inputOptions[optionName];
|
||||
|
||||
if ( optionValue === undefined ) {
|
||||
|
||||
// Only default if negativeBefore isn't set.
|
||||
if ( optionName === 'negative' && !filteredOptions.negativeBefore ) {
|
||||
filteredOptions[optionName] = '-';
|
||||
// Don't set a default for mark when 'thousand' is set.
|
||||
} else if ( optionName === 'mark' && filteredOptions.thousand !== '.' ) {
|
||||
filteredOptions[optionName] = '.';
|
||||
} else {
|
||||
filteredOptions[optionName] = false;
|
||||
}
|
||||
|
||||
// Floating points in JS are stable up to 7 decimals.
|
||||
} else if ( optionName === 'decimals' ) {
|
||||
if ( optionValue >= 0 && optionValue < 8 ) {
|
||||
filteredOptions[optionName] = optionValue;
|
||||
} else {
|
||||
throw new Error(optionName);
|
||||
}
|
||||
|
||||
// These options, when provided, must be functions.
|
||||
} else if ( optionName === 'encoder' || optionName === 'decoder' || optionName === 'edit' || optionName === 'undo' ) {
|
||||
if ( typeof optionValue === 'function' ) {
|
||||
filteredOptions[optionName] = optionValue;
|
||||
} else {
|
||||
throw new Error(optionName);
|
||||
}
|
||||
|
||||
// Other options are strings.
|
||||
} else {
|
||||
|
||||
if ( typeof optionValue === 'string' ) {
|
||||
filteredOptions[optionName] = optionValue;
|
||||
} else {
|
||||
throw new Error(optionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Some values can't be extracted from a
|
||||
// string if certain combinations are present.
|
||||
throwEqualError(filteredOptions, 'mark', 'thousand');
|
||||
throwEqualError(filteredOptions, 'prefix', 'negative');
|
||||
throwEqualError(filteredOptions, 'prefix', 'negativeBefore');
|
||||
|
||||
return filteredOptions;
|
||||
}
|
||||
|
||||
// Pass all options as function arguments
|
||||
function passAll ( options, method, input ) {
|
||||
var i, args = [];
|
||||
|
||||
// Add all options in order of FormatOptions
|
||||
for ( i = 0; i < FormatOptions.length; i+=1 ) {
|
||||
args.push(options[FormatOptions[i]]);
|
||||
}
|
||||
|
||||
// Append the input, then call the method, presenting all
|
||||
// options as arguments.
|
||||
args.push(input);
|
||||
return method.apply('', args);
|
||||
}
|
||||
|
||||
/** @constructor */
|
||||
function wNumb ( options ) {
|
||||
|
||||
if ( !(this instanceof wNumb) ) {
|
||||
return new wNumb ( options );
|
||||
}
|
||||
|
||||
if ( typeof options !== "object" ) {
|
||||
return;
|
||||
}
|
||||
|
||||
options = validate(options);
|
||||
|
||||
// Call 'formatTo' with proper arguments.
|
||||
this.to = function ( input ) {
|
||||
return passAll(options, formatTo, input);
|
||||
};
|
||||
|
||||
// Call 'formatFrom' with proper arguments.
|
||||
this.from = function ( input ) {
|
||||
return passAll(options, formatFrom, input);
|
||||
};
|
||||
}
|
||||
|
||||
/** @export */
|
||||
return wNumb;
|
||||
|
||||
}));
|
||||
Reference in New Issue
Block a user