/*
* Metro 4 Components Library v4.2.36 build 717 (https://metroui.org.ua)
* Copyright 2019 Sergey Pimenov
* Licensed under MIT
*/
(function( factory ) {
if ( typeof define === 'function' && define.amd ) {
define([ 'jquery' ], factory );
} else {
factory( jQuery );
}
}(function( jQuery ) {
// Source: js/metro.js
'use strict';
var $ = jQuery;
if (typeof jQuery === 'undefined') {
throw new Error('Metro 4 requires jQuery!');
}
if ('MutationObserver' in window === false) {
throw new Error('Metro 4 requires MutationObserver!');
}
var meta_init = $("meta[name='metro4:init']").attr("content");
var meta_locale = $("meta[name='metro4:locale']").attr("content");
var meta_week_start = $("meta[name='metro4:week_start']").attr("content");
var meta_date_format = $("meta[name='metro4:date_format']").attr("content");
var meta_date_format_input = $("meta[name='metro4:date_format_input']").attr("content");
var meta_animation_duration = $("meta[name='metro4:animation_duration']").attr("content");
var meta_callback_timeout = $("meta[name='metro4:callback_timeout']").attr("content");
var meta_timeout = $("meta[name='metro4:timeout']").attr("content");
var meta_scroll_multiple = $("meta[name='metro4:scroll_multiple']").attr("content");
var meta_cloak = $("meta[name='metro4:cloak']").attr("content"); //default or fade
var meta_cloak_duration = $("meta[name='metro4:cloak_duration']").attr("content"); //100
if (window.METRO_INIT === undefined) {
window.METRO_INIT = meta_init !== undefined ? JSON.parse(meta_init) : true;
}
if (window.METRO_DEBUG === undefined) {window.METRO_DEBUG = true;}
if (window.METRO_WEEK_START === undefined) {
window.METRO_WEEK_START = meta_week_start !== undefined ? parseInt(meta_week_start) : 0;
}
if (window.METRO_DATE_FORMAT === undefined) {
window.METRO_DATE_FORMAT = meta_date_format !== undefined ? meta_date_format : "%Y-%m-%d";
}
if (window.METRO_DATE_FORMAT_INPUT === undefined) {
window.METRO_DATE_FORMAT_INPUT = meta_date_format_input !== undefined ? meta_date_format_input : "%Y-%m-%d";
}
if (window.METRO_LOCALE === undefined) {
window.METRO_LOCALE = meta_locale !== undefined ? meta_locale : 'en-US';
}
if (window.METRO_ANIMATION_DURATION === undefined) {
window.METRO_ANIMATION_DURATION = meta_animation_duration !== undefined ? parseInt(meta_animation_duration) : 300;
}
if (window.METRO_CALLBACK_TIMEOUT === undefined) {
window.METRO_CALLBACK_TIMEOUT = meta_callback_timeout !== undefined ? parseInt(meta_callback_timeout) : 500;
}
if (window.METRO_TIMEOUT === undefined) {
window.METRO_TIMEOUT = meta_timeout !== undefined ? parseInt(meta_timeout) : 2000;
}
if (window.METRO_SCROLL_MULTIPLE === undefined) {
window.METRO_SCROLL_MULTIPLE = meta_scroll_multiple !== undefined ? parseInt(meta_scroll_multiple) : 20;
}
if (window.METRO_CLOAK_REMOVE === undefined) {
window.METRO_CLOAK_REMOVE = meta_cloak !== undefined ? (""+meta_cloak).toLowerCase() : "fade";
}
if (window.METRO_CLOAK_DURATION === undefined) {
window.METRO_CLOAK_DURATION = meta_cloak_duration !== undefined ? parseInt(meta_cloak_duration) : 500;
}
if (window.METRO_HOTKEYS_FILTER_CONTENT_EDITABLE === undefined) {window.METRO_HOTKEYS_FILTER_CONTENT_EDITABLE = true;}
if (window.METRO_HOTKEYS_FILTER_INPUT_ACCEPTING_ELEMENTS === undefined) {window.METRO_HOTKEYS_FILTER_INPUT_ACCEPTING_ELEMENTS = true;}
if (window.METRO_HOTKEYS_FILTER_TEXT_INPUTS === undefined) {window.METRO_HOTKEYS_FILTER_TEXT_INPUTS = true;}
if (window.METRO_HOTKEYS_BUBBLE_UP === undefined) {window.METRO_HOTKEYS_BUBBLE_UP = false;}
if (window.METRO_THROWS === undefined) {window.METRO_THROWS = true;}
window.METRO_MEDIA = [];
if ( typeof Object.create !== 'function' ) {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}
if (typeof Object.values !== 'function') {
Object.values = function(obj) {
return Object.keys(obj).map(function(e) {
return obj[e]
});
}
}
var isTouch = (('ontouchstart' in window) || (navigator.MaxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0));
var Metro = {
version: "4.2.36",
versionFull: "4.2.36.717 ",
isTouchable: isTouch,
fullScreenEnabled: document.fullscreenEnabled,
sheet: null,
controlsPosition: {
INSIDE: "inside",
OUTSIDE: "outside"
},
groupMode: {
ONE: "one",
MULTI: "multi"
},
aspectRatio: {
HD: "hd",
SD: "sd",
CINEMA: "cinema"
},
fullScreenMode: {
WINDOW: "window",
DESKTOP: "desktop"
},
position: {
TOP: "top",
BOTTOM: "bottom",
LEFT: "left",
RIGHT: "right",
TOP_RIGHT: "top-right",
TOP_LEFT: "top-left",
BOTTOM_LEFT: "bottom-left",
BOTTOM_RIGHT: "bottom-right",
LEFT_BOTTOM: "left-bottom",
LEFT_TOP: "left-top",
RIGHT_TOP: "right-top",
RIGHT_BOTTOM: "right-bottom"
},
popoverEvents: {
CLICK: "click",
HOVER: "hover",
FOCUS: "focus"
},
stepperView: {
SQUARE: "square",
CYCLE: "cycle",
DIAMOND: "diamond"
},
listView: {
LIST: "list",
CONTENT: "content",
ICONS: "icons",
ICONS_MEDIUM: "icons-medium",
ICONS_LARGE: "icons-large",
TILES: "tiles",
TABLE: "table"
},
events: {
click: 'click.metro',
start: isTouch ? 'touchstart.metro' : 'mousedown.metro',
stop: isTouch ? 'touchend.metro' : 'mouseup.metro',
move: isTouch ? 'touchmove.metro' : 'mousemove.metro',
enter: isTouch ? 'touchstart.metro' : 'mouseenter.metro',
leave: 'mouseleave.metro',
focus: 'focus.metro',
blur: 'blur.metro',
resize: 'resize.metro',
keyup: 'keyup.metro',
keydown: 'keydown.metro',
keypress: 'keypredd.metro',
dblclick: 'dblclick.metro',
input: 'input.metro',
change: 'change.metro',
cut: 'cut.metro',
paste: 'paste.metro',
scroll: 'scroll.metro',
scrollStart: 'scrollstart.metro',
scrollStop: 'scrollstop.metro',
mousewheel: 'mousewheel.metro',
inputchange: "change.metro input.metro propertychange.metro cut.metro paste.metro copy.metro",
dragstart: "dragstart.metro",
dragend: "dragend.metro",
dragenter: "dragenter.metro",
dragover: "dragover.metro",
dragleave: "dragleave.metro",
drop: 'drop.metro',
drag: 'drag.metro'
},
keyCode: {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
BREAK: 19,
CAPS: 20,
ESCAPE: 27,
SPACE: 32,
PAGEUP: 33,
PAGEDOWN: 34,
END: 35,
HOME: 36,
LEFT_ARROW: 37,
UP_ARROW: 38,
RIGHT_ARROW: 39,
DOWN_ARROW: 40,
COMMA: 188
},
media_queries: {
FS: "(min-width: 0px)",
XS: "(min-width: 360px)",
SM: "(min-width: 576px)",
MD: "(min-width: 768px)",
LG: "(min-width: 992px)",
XL: "(min-width: 1200px)",
XXL: "(min-width: 1452px)"
},
media_sizes: {
FS: 0,
XS: 360,
SM: 576,
LD: 640,
MD: 768,
LG: 992,
XL: 1200,
XXL: 1452
},
media_mode: {
FS: "fs",
XS: "xs",
SM: "sm",
MD: "md",
LG: "lg",
XL: "xl",
XXL: "xxl"
},
media_modes: ["fs","xs","sm","md","lg","xl","xxl"],
actions: {
REMOVE: 1,
HIDE: 2
},
hotkeys: [],
about: function(f){
console.log("Metro 4 - v" + (f === true ? this.versionFull : this.version));
},
aboutDlg: function(f){
alert("Metro 4 - v" + (f === true ? this.versionFull : this.version));
},
ver: function(f){
return (f === true ? this.versionFull : this.version);
},
observe: function(){
'use strict';
var observer, observerCallback;
var observerConfig = {
childList: true,
attributes: true,
subtree: true
};
observerCallback = function(mutations){
mutations.map(function(mutation){
if (mutation.type === 'attributes' && mutation.attributeName !== "data-role") {
var element = $(mutation.target);
var mc = element.data('metroComponent');
if (mc !== undefined) {
$.each(mc, function(){
'use strict';
var plug = element.data(this);
if (plug) plug.changeAttribute(mutation.attributeName);
});
}
} else
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
var i, obj, widgets = {}, plugins = {};
var nodes = mutation.addedNodes;
for(i = 0; i < nodes.length; i++) {
var node = mutation.addedNodes[i];
if (node.tagName === 'SCRIPT' || node.tagName === 'STYLE') {
continue ;
}
obj = $(mutation.addedNodes[i]);
plugins = obj.find("[data-role]");
if (obj.data('role') !== undefined) {
widgets = $.merge(plugins, obj);
} else {
widgets = plugins;
}
if (widgets.length) {
Metro.initWidgets(widgets);
}
}
} else {
//console.log(mutation);
}
});
};
observer = new MutationObserver(observerCallback);
observer.observe($("html")[0], observerConfig);
},
init: function(){
var widgets = $("[data-role]");
var hotkeys = $("[data-hotkey]");
var html = $("html");
if (isTouch === true) {
html.addClass("metro-touch-device");
} else {
html.addClass("metro-no-touch-device");
}
this.sheet = Utils.newCssSheet();
window.METRO_MEDIA = [];
$.each(Metro.media_queries, function(key, query){
if (Utils.media(query)) {
METRO_MEDIA.push(Metro.media_mode[key]);
}
});
this.observe();
this.initHotkeys(hotkeys);
this.initWidgets(widgets);
this.about(true);
if (METRO_CLOAK_REMOVE !== "fade") {
$(".m4-cloak").removeClass("m4-cloak");
} else {
$(".m4-cloak").animate({
opacity: 1
}, METRO_CLOAK_REMOVE, function(){
$(".m4-cloak").removeClass("m4-cloak");
})
}
return this;
},
initHotkeys: function(hotkeys){
$.each(hotkeys, function(){
'use strict';
var element = $(this);
var hotkey = element.data('hotkey') ? element.data('hotkey').toLowerCase() : false;
if (hotkey === false) {
return;
}
if (element.data('hotKeyBonded') === true ) {
return;
}
Metro.hotkeys.push(hotkey);
$(document).on(Metro.events.keyup, null, hotkey, function(e){
if (element === undefined) return;
if (element[0].tagName === 'A' &&
element.attr('href') !== undefined &&
element.attr('href').trim() !== '' &&
element.attr('href').trim() !== '#') {
document.location.href = element.attr('href');
} else {
element.click();
}
return METRO_HOTKEYS_BUBBLE_UP;
});
element.data('hotKeyBonded', true);
});
},
initWidgets: function(widgets) {
var that = this;
$.each(widgets, function () {
'use strict';
var $this = $(this), w = this;
var roles = $this.data('role').split(/\s*,\s*/);
roles.map(function (func) {
if ($.fn[func] !== undefined && $this.attr("data-role-"+func) === undefined) {
$.fn[func].call($this);
$this.attr("data-role-"+func, true);
var mc = $this.data('metroComponent');
if (mc === undefined) {
mc = [func];
} else {
mc.push(func);
}
$this.data('metroComponent', mc);
}
});
});
},
plugin: function(name, object){
'use strict';
$.fn[name] = function( options ) {
return this.each(function() {
$.data( this, name, Object.create(object).init(options, this ));
});
};
},
destroyPlugin: function(element, name){
var p, mc;
element = Utils.isJQueryObject(element) ? element[0] : element;
p = $(element).data(name);
if (!Utils.isValue(p)) {
throw new Error("Component can not be destroyed: the element is not a Metro 4 component.");
}
if (!Utils.isFunc(p['destroy'])) {
throw new Error("Component can not be destroyed: method destroy not found.");
}
p['destroy']();
mc = $(element).data("metroComponent");
Utils.arrayDelete(mc, name);
$(element).data("metroComponent", mc);
$.removeData(element, name);
$(element).removeAttr("data-role-"+name);
},
destroyPluginAll: function(element){
element = Utils.isJQueryObject(element) ? element[0] : element;
var mc = $(element).data("metroComponent");
if (mc !== undefined && mc.length > 0) $.each(mc, function(){
'use strict';
Metro.destroyPlugin(element, this);
});
},
initPlugin: function(element, name){
element = $(element);
try {
if ($.fn[name] !== undefined && element.attr("data-role-"+name) === undefined) {
$.fn[name].call(element);
element.attr("data-role-"+name, true);
var mc = element.data('metroComponent');
if (mc === undefined) {
mc = [name];
} else {
mc.push(name);
}
element.data('metroComponent', mc);
}
} catch (e) {
console.log(e.message, e.stack);
}
},
reinitPlugin: function(element, name){
this.destroyPlugin(element, name);
this.initPlugin(element, name);
},
reinitPluginAll: function(element){
var mc = $(element).data("metroComponent");
if (mc !== undefined && mc.length > 0) $.each(mc, function(){
'use strict';
Metro.reinitPlugin(element, this);
});
},
noop: function(){},
noop_true: function(){return true;},
noop_false: function(){return false;},
stop: function(e){
e.stopPropagation();
e.preventDefault();
},
requestFullScreen: function(element){
if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
} else {
element.requestFullscreen();
}
},
exitFullScreen: function(){
if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else {
document.exitFullscreen();
}
},
inFullScreen: function(){
var fsm = (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
return fsm !== undefined;
}
};
window['Metro'] = Metro;
$(window).on(Metro.events.resize, function(){
window.METRO_MEDIA = [];
$.each(Metro.media_queries, function(key, query){
if (Utils.media(query)) {
METRO_MEDIA.push(Metro.media_mode[key]);
}
});
});
// Source: js/utils/animation.js
var Animation = {
duration: METRO_ANIMATION_DURATION,
func: "swing",
switch: function(current, next){
current.hide();
next.css({top: 0, left: 0}).show();
},
slideUp: function(current, next, duration, func){
var h = current.parent().outerHeight(true);
if (duration === undefined) {duration = this.duration;}
if (func === undefined) {func = this.func;}
current.css("z-index", 1).animate({
top: -h,
opacity: 0
}, duration, func);
next.css({
top: h,
left: 0,
zIndex: 2
}).animate({
top: 0,
opacity: 1
}, duration, func);
},
slideDown: function(current, next, duration, func){
var h = current.parent().outerHeight(true);
if (duration === undefined) {duration = this.duration;}
if (func === undefined) {func = this.func;}
current.css("z-index", 1).animate({
top: h,
opacity: 0
}, duration, func);
next.css({
left: 0,
top: -h,
zIndex: 2
}).animate({
top: 0,
opacity: 1
}, duration, func);
},
slideLeft: function(current, next, duration, func){
var w = current.parent().outerWidth(true);
if (duration === undefined) {duration = this.duration;}
if (func === undefined) {func = this.func;}
current.css("z-index", 1).animate({
left: -w,
opacity: 0
}, duration, func);
next.css({
left: w,
zIndex: 2
}).animate({
left: 0,
opacity: 1
}, duration, func);
},
slideRight: function(current, next, duration, func){
var w = current.parent().outerWidth(true);
if (duration === undefined) {duration = this.duration;}
if (func === undefined) {func = this.func;}
current.css("z-index", 1).animate({
left: w,
opacity: 0
}, duration, func);
next.css({
left: -w,
zIndex: 2
}).animate({
left: 0,
opacity: 1
}, duration, func);
},
fade: function(current, next, duration){
if (duration === undefined) {duration = this.duration;}
current.animate({
opacity: 0
}, duration);
next.css({
top: 0,
left: 0
}).animate({
opacity: 1
}, duration);
}
};
Metro['animation'] = Animation;
// Source: js/utils/colors.js
function RGB(r, g, b){
this.r = r || 0;
this.g = g || 0;
this.g = b || 0;
}
function RGBA(r, g, b, a){
this.r = r || 0;
this.g = g || 0;
this.g = b || 0;
this.a = a || 1;
}
function HSV(h, s, v){
this.h = h || 0;
this.s = s || 0;
this.v = v || 0;
}
function HSL(h, s, l){
this.h = h || 0;
this.s = s || 0;
this.l = l || 0;
}
function HSLA(h, s, l, a){
this.h = h || 0;
this.s = s || 0;
this.l = l || 0;
this.a = a || 1;
}
function CMYK(c, m, y, k){
this.c = c || 0;
this.m = m || 0;
this.y = y || 0;
this.k = k || 0;
}
var Colors = {
TYPES: {
HEX: "hex",
RGB: "rgb",
RGBA: "rgba",
HSV: "hsv",
HSL: "hsl",
CMYK: "cmyk",
UNKNOWN: "unknown"
},
PALETTES: {
ALL: "colorList",
METRO: "colorListMetro",
STANDARD: "colorListStandard"
},
colorListMetro: {
lime: '#a4c400',
green: '#60a917',
emerald: '#008a00',
blue: '#00AFF0',
teal: '#00aba9',
cyan: '#1ba1e2',
cobalt: '#0050ef',
indigo: '#6a00ff',
violet: '#aa00ff',
pink: '#dc4fad',
magenta: '#d80073',
crimson: '#a20025',
red: '#CE352C',
orange: '#fa6800',
amber: '#f0a30a',
yellow: '#fff000',
brown: '#825a2c',
olive: '#6d8764',
steel: '#647687',
mauve: '#76608a',
taupe: '#87794e'
},
colorListStandard: {
aliceBlue: "#f0f8ff",
antiqueWhite: "#faebd7",
aqua: "#00ffff",
aquamarine: "#7fffd4",
azure: "#f0ffff",
beige: "#f5f5dc",
bisque: "#ffe4c4",
black: "#000000",
blanchedAlmond: "#ffebcd",
blue: "#0000ff",
blueViolet: "#8a2be2",
brown: "#a52a2a",
burlyWood: "#deb887",
cadetBlue: "#5f9ea0",
chartreuse: "#7fff00",
chocolate: "#d2691e",
coral: "#ff7f50",
cornflowerBlue: "#6495ed",
cornsilk: "#fff8dc",
crimson: "#dc143c",
cyan: "#00ffff",
darkBlue: "#00008b",
darkCyan: "#008b8b",
darkGoldenRod: "#b8860b",
darkGray: "#a9a9a9",
darkGreen: "#006400",
darkKhaki: "#bdb76b",
darkMagenta: "#8b008b",
darkOliveGreen: "#556b2f",
darkOrange: "#ff8c00",
darkOrchid: "#9932cc",
darkRed: "#8b0000",
darkSalmon: "#e9967a",
darkSeaGreen: "#8fbc8f",
darkSlateBlue: "#483d8b",
darkSlateGray: "#2f4f4f",
darkTurquoise: "#00ced1",
darkViolet: "#9400d3",
deepPink: "#ff1493",
deepSkyBlue: "#00bfff",
dimGray: "#696969",
dodgerBlue: "#1e90ff",
fireBrick: "#b22222",
floralWhite: "#fffaf0",
forestGreen: "#228b22",
fuchsia: "#ff00ff",
gainsboro: "#DCDCDC",
ghostWhite: "#F8F8FF",
gold: "#ffd700",
goldenRod: "#daa520",
gray: "#808080",
green: "#008000",
greenYellow: "#adff2f",
honeyDew: "#f0fff0",
hotPink: "#ff69b4",
indianRed: "#cd5c5c",
indigo: "#4b0082",
ivory: "#fffff0",
khaki: "#f0e68c",
lavender: "#e6e6fa",
lavenderBlush: "#fff0f5",
lawnGreen: "#7cfc00",
lemonChiffon: "#fffacd",
lightBlue: "#add8e6",
lightCoral: "#f08080",
lightCyan: "#e0ffff",
lightGoldenRodYellow: "#fafad2",
lightGray: "#d3d3d3",
lightGreen: "#90ee90",
lightPink: "#ffb6c1",
lightSalmon: "#ffa07a",
lightSeaGreen: "#20b2aa",
lightSkyBlue: "#87cefa",
lightSlateGray: "#778899",
lightSteelBlue: "#b0c4de",
lightYellow: "#ffffe0",
lime: "#00ff00",
limeGreen: "#32dc32",
linen: "#faf0e6",
magenta: "#ff00ff",
maroon: "#800000",
mediumAquaMarine: "#66cdaa",
mediumBlue: "#0000cd",
mediumOrchid: "#ba55d3",
mediumPurple: "#9370db",
mediumSeaGreen: "#3cb371",
mediumSlateBlue: "#7b68ee",
mediumSpringGreen: "#00fa9a",
mediumTurquoise: "#48d1cc",
mediumVioletRed: "#c71585",
midnightBlue: "#191970",
mintCream: "#f5fffa",
mistyRose: "#ffe4e1",
moccasin: "#ffe4b5",
navajoWhite: "#ffdead",
navy: "#000080",
oldLace: "#fdd5e6",
olive: "#808000",
oliveDrab: "#6b8e23",
orange: "#ffa500",
orangeRed: "#ff4500",
orchid: "#da70d6",
paleGoldenRod: "#eee8aa",
paleGreen: "#98fb98",
paleTurquoise: "#afeeee",
paleVioletRed: "#db7093",
papayaWhip: "#ffefd5",
peachPuff: "#ffdab9",
peru: "#cd853f",
pink: "#ffc0cb",
plum: "#dda0dd",
powderBlue: "#b0e0e6",
purple: "#800080",
rebeccaPurple: "#663399",
red: "#ff0000",
rosyBrown: "#bc8f8f",
royalBlue: "#4169e1",
saddleBrown: "#8b4513",
salmon: "#fa8072",
sandyBrown: "#f4a460",
seaGreen: "#2e8b57",
seaShell: "#fff5ee",
sienna: "#a0522d",
silver: "#c0c0c0",
slyBlue: "#87ceeb",
slateBlue: "#6a5acd",
slateGray: "#708090",
snow: "#fffafa",
springGreen: "#00ff7f",
steelBlue: "#4682b4",
tan: "#d2b48c",
teal: "#008080",
thistle: "#d8bfd8",
tomato: "#ff6347",
turquoise: "#40e0d0",
violet: "#ee82ee",
wheat: "#f5deb3",
white: "#ffffff",
whiteSmoke: "#f5f5f5",
yellow: "#ffff00",
yellowGreen: "#9acd32"
},
colorList: {},
options: {
angle: 30,
algorithm: 1,
step: .1,
distance: 5,
tint1: .8,
tint2: .4,
shade1: .6,
shade2: .3,
alpha: 1
},
init: function(){
this.colorList = $.extend( {}, this.colorListStandard, this.colorListMetro );
return this;
},
setup: function(options){
this.options = $.extend( {}, this.options, options );
},
color: function(name, palette){
palette = palette || this.PALETTES.ALL;
return this[palette][name] !== undefined ? this[palette][name] : false;
},
palette: function(palette){
palette = palette || this.PALETTES.ALL;
return Object.keys(this[palette]);
},
colors: function(palette){
var c = [];
palette = palette || this.PALETTES.ALL;
$.each(this[palette], function(){
c.push(this);
});
return c;
},
hex2rgb: function(hex){
var regex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace( regex, function( m, r, g, b ) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec( hex );
return result ? {
r: parseInt( result[1], 16 ),
g: parseInt( result[2], 16 ),
b: parseInt( result[3], 16 )
} : null;
},
rgb2hex: function(rgb){
return "#" +
(( 1 << 24 ) + ( rgb.r << 16 ) + ( rgb.g << 8 ) + rgb.b )
.toString( 16 ).slice( 1 );
},
rgb2hsv: function(rgb){
var hsv = new HSV();
var h, s, v;
var r = rgb.r / 255, g = rgb.g / 255, b = rgb.b / 255;
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var delta = max - min;
v = max;
if (max === 0) {
s = 0;
} else {
s = 1 - min / max;
}
if (max === min) {
h = 0;
} else if (max === r && g >= b) {
h = 60 * ( (g - b) / delta );
} else if (max === r && g < b) {
h = 60 * ( (g - b) / delta) + 360
} else if (max === g) {
h = 60 * ( (b - r) / delta) + 120
} else if (max === b) {
h = 60 * ( (r - g) / delta) + 240
} else {
h = 0;
}
hsv.h = h;
hsv.s = s;
hsv.v = v;
return hsv;
},
hsv2rgb: function(hsv){
var r, g, b;
var h = hsv.h, s = hsv.s * 100, v = hsv.v * 100;
var Hi = Math.floor(h / 60);
var Vmin = (100 - s) * v / 100;
var alpha = (v - Vmin) * ( (h % 60) / 60 );
var Vinc = Vmin + alpha;
var Vdec = v - alpha;
switch (Hi) {
case 0: r = v; g = Vinc; b = Vmin; break;
case 1: r = Vdec; g = v; b = Vmin; break;
case 2: r = Vmin; g = v; b = Vinc; break;
case 3: r = Vmin; g = Vdec; b = v; break;
case 4: r = Vinc; g = Vmin; b = v; break;
case 5: r = v; g = Vmin; b = Vdec; break;
}
return {
r: Math.round(r * 255 / 100),
g: Math.round(g * 255 / 100),
b: Math.round(b * 255 / 100)
}
},
hsv2hex: function(hsv){
return this.rgb2hex(this.hsv2rgb(hsv));
},
hex2hsv: function(hex){
return this.rgb2hsv(this.hex2rgb(hex));
},
rgb2cmyk: function(rgb){
var cmyk = new CMYK();
var r = rgb.r / 255;
var g = rgb.g / 255;
var b = rgb.b / 255;
cmyk.k = Math.min( 1 - r, 1 - g, 1 - b );
cmyk.c = ( 1 - r - cmyk.k ) / ( 1 - cmyk.k );
cmyk.m = ( 1 - g - cmyk.k ) / ( 1 - cmyk.k );
cmyk.y = ( 1 - b - cmyk.k ) / ( 1 - cmyk.k );
cmyk.c = Math.round( cmyk.c * 100 );
cmyk.m = Math.round( cmyk.m * 100 );
cmyk.y = Math.round( cmyk.y * 100 );
cmyk.k = Math.round( cmyk.k * 100 );
return cmyk;
},
cmyk2rgb: function(cmyk){
var rgb = new RGB();
var c = cmyk.c / 100;
var m = cmyk.m / 100;
var y = cmyk.y / 100;
var k = cmyk.k / 100;
rgb.r = 1 - Math.min( 1, c * ( 1 - k ) + k );
rgb.g = 1 - Math.min( 1, m * ( 1 - k ) + k );
rgb.b = 1 - Math.min( 1, y * ( 1 - k ) + k );
rgb.r = Math.round( rgb.r * 255 );
rgb.g = Math.round( rgb.g * 255 );
rgb.b = Math.round( rgb.b * 255 );
return rgb;
},
hsv2hsl: function(hsv){
var h, s, l;
h = hsv.h;
l = (2 - hsv.s) * hsv.v;
s = hsv.s * hsv.v;
s /= (l <= 1) ? l : 2 - l;
l /= 2;
return {h: h, s: s, l: l}
},
hsl2hsv: function(hsl){
var h, s, v, l;
h = hsl.h;
l = hsl.l * 2;
s = hsl.s * (l <= 1 ? l : 2 - l);
v = (l + s) / 2;
s = (2 * s) / (l + s);
return {h: h, s: s, l: v}
},
rgb2websafe: function(rgb){
return {
r: Math.round(rgb.r / 51) * 51,
g: Math.round(rgb.g / 51) * 51,
b: Math.round(rgb.b / 51) * 51
}
},
rgba2websafe: function(rgba){
return {
r: Math.round(rgba.r / 51) * 51,
g: Math.round(rgba.g / 51) * 51,
b: Math.round(rgba.b / 51) * 51,
a: rgba.a
}
},
hex2websafe: function(hex){
return this.rgb2hex(this.rgb2websafe(this.toRGB(hex)));
},
hsv2websafe: function(hsv){
return this.rgb2hsv(this.rgb2websafe(this.toRGB(hsv)));
},
hsl2websafe: function(hsl){
return this.hsv2hsl(this.rgb2hsv(this.rgb2websafe(this.toRGB(hsl))));
},
cmyk2websafe: function(cmyk){
return this.rgb2cmyk(this.rgb2websafe(this.cmyk2rgb(cmyk)));
},
websafe: function(color){
if (this.isHEX(color)) return this.hex2websafe(color);
if (this.isRGB(color)) return this.rgb2websafe(color);
if (this.isRGBA(color)) return this.rgba2websafe(color);
if (this.isHSV(color)) return this.hsv2websafe(color);
if (this.isHSL(color)) return this.hsl2websafe(color);
if (this.isCMYK(color)) return this.cmyk2websafe(color);
return color;
},
is: function(color){
if (this.isHEX(color)) return this.TYPES.HEX;
if (this.isRGB(color)) return this.TYPES.RGB;
if (this.isRGBA(color)) return this.TYPES.RGBA;
if (this.isHSV(color)) return this.TYPES.HSV;
if (this.isHSL(color)) return this.TYPES.HSL;
if (this.isCMYK(color)) return this.TYPES.CMYK;
return this.TYPES.UNKNOWN;
},
toRGB: function(color){
if (this.isHSV(color)) return this.hsv2rgb(color);
if (this.isHSL(color)) return this.hsv2rgb(this.hsl2hsv(color));
if (this.isRGB(color)) return color;
if (this.isHEX(color)) return this.hex2rgb(color);
if (this.isCMYK(color)) return this.cmyk2rgb(color);
throw new Error("Unknown color format!");
},
toRGBA: function(color, alpha){
var result = this.toRGB(color);
result.a = alpha || 1;
return result;
},
toHSV: function(color){
return this.rgb2hsv(this.toRGB(color));
},
toHSL: function(color){
return this.hsv2hsl(this.rgb2hsv(this.toRGB(color)));
},
toHSLA: function(color, alpha){
var hsla;
hsla = this.hsv2hsl(this.rgb2hsv(this.toRGB(color)));
hsla.a = alpha || this.options.alpha;
return hsla;
},
toHEX: function(color){
return this.rgb2hex(this.toRGB(color));
},
toCMYK: function(color){
return this.rgb2cmyk(this.toRGB(color));
},
toHexString: function(color){
return this.toHEX(color);
},
toHsvString: function(color){
var hsv = this.toHSV(color);
return "hsv("+[hsv.h, hsv.s, hsv.v].join(",")+")";
},
toHslString: function(color){
var hsl = this.toHSL(color);
return "hsl("+[Math.round(hsl.h), Math.round(hsl.s * 100) + "%" , Math.round(hsl.l * 100) + "%"].join(",")+")";
},
toHslaString: function(color){
var hsl = this.toHSLA(color);
return "hsl("+[Math.round(hsl.h), Math.round(hsl.s * 100) + "%" , Math.round(hsl.l * 100) + "%", hsl.a].join(",")+")";
},
toCmykString: function(color){
var cmyk = this.toCMYK(color);
return "cmyk("+[cmyk.c, cmyk.m, cmyk.y, cmyk.k].join(",")+")";
},
toRgbString: function(color){
var rgb = this.toRGB(color);
return "rgb("+[rgb.r, rgb.g, rgb.b].join(",")+")";
},
toRgbaString: function(color){
var rgb = this.toRGBA(color);
return "rgba("+[rgb.r, rgb.g, rgb.b, rgb.a].join(",")+")";
},
toString: function(color){
if (this.isHEX(color)) return this.toHexString(color);
if (this.isRGB(color)) return this.toRgbString(color);
if (this.isRGBA(color)) return this.toRgbaString(color);
if (this.isHSV(color)) return this.toHsvString(color);
if (this.isHSL(color)) return this.toHslString(color);
if (this.isHSLA(color)) return this.toHslaString(color);
if (this.isCMYK(color)) return this.toCmykString(color);
throw new Error("Unknown color format!");
},
grayscale: function(color, output){
output = output || "hex";
var rgb = this.toRGB(color);
var gray = Math.round(rgb.r * .2125 + rgb.g * .7154 + rgb.b * .0721);
var mono = {
r: gray,
g: gray,
b: gray
};
return this["rgb2"+output](mono);
},
darken: function(color, amount){
if (amount === undefined) {
amount = 10;
}
return this.lighten(color, -1 * Math.abs(amount));
},
lighten: function(color, amount){
var type, res, alpha = 1, ring = amount > 0;
var calc = function(_color, _amount){
var col = _color.slice(1);
var num = parseInt(col, 16);
var r = (num >> 16) + _amount;
if (r > 255) r = 255;
else if (r < 0) r = 0;
var b = ((num >> 8) & 0x00FF) + _amount;
if (b > 255) b = 255;
else if (b < 0) b = 0;
var g = (num & 0x0000FF) + _amount;
if (g > 255) g = 255;
else if (g < 0) g = 0;
res = "#" + (g | (b << 8) | (r << 16)).toString(16);
return res;
};
if (amount === undefined) {
amount = 10;
}
type = this.is(color);
if (type === this.TYPES.RGBA) {
alpha = color.a;
}
do {
res = calc(this.toHEX(color), amount);
ring ? amount-- : amount++;
} while (res.length < 7);
switch (type) {
case "rgb": return this.toRGB(res);
case "rgba": return this.toRGBA(res, alpha);
case "hsv": return this.toHSV(res);
case "hsl": return this.toHSL(res);
case "cmyk": return this.toCMYK(res);
default: return res;
}
},
isDark: function(color){
var rgb = this.toRGB(color);
var YIQ = (
( rgb.r * 299 ) +
( rgb.g * 587 ) +
( rgb.b * 114 )
) / 1000;
return ( YIQ < 128 )
},
isLight: function(hex){
return !this.isDark(hex);
},
isHSV: function(val){
return Utils.isObject(val) && "h" in val && "s" in val && "v" in val;
},
isHSL: function(val){
return Utils.isObject(val) && "h" in val && "s" in val && "l" in val;
},
isHSLA: function(val){
return Utils.isObject(val) && "h" in val && "s" in val && "l" in val && "a" in val;
},
isRGB: function(val){
return Utils.isObject(val) && "r" in val && "g" in val && "b" in val;
},
isRGBA: function(val){
return Utils.isObject(val) && "r" in val && "g" in val && "b" in val && "a" in val;
},
isCMYK: function(val){
return Utils.isObject(val) && "c" in val && "m" in val && "y" in val && "k" in val;
},
isHEX: function(val){
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(val);
},
isColor: function(color){
return this.isHEX(color) || this.isRGB(color) || this.isRGBA(color) || this.isHSV(color) || this.isHSL(color) || this.isCMYK(color);
},
hueShift: function(h, s){
h+=s;
while (h >= 360.0) h -= 360.0;
while (h < 0.0) h += 360.0;
return h;
},
getScheme: function(color, name, format, options){
this.options = $.extend( {}, this.options, options );
var i;
var scheme = [];
var hsv;
var that = this;
hsv = this.toHSV(color);
if (this.isHSV(hsv) === false) {
console.log("The value is a not supported color format!");
return false;
}
function convert(source, format) {
var result = [];
var o = that.options;
switch (format) {
case "hex": result = source.map(function(v){return Colors.toHEX(v);}); break;
case "rgb": result = source.map(function(v){return Colors.toRGB(v);}); break;
case "rgba": result = source.map(function(v){return Colors.toRGBA(v, o.alpha);}); break;
case "hsl": result = source.map(function(v){return Colors.toHSL(v);}); break;
case "cmyk": result = source.map(function(v){return Colors.toCMYK(v);}); break;
default: result = source;
}
return result;
}
function clamp( num, min, max ){
return Math.max( min, Math.min( num, max ));
}
function toRange(a, b, c){
return a < b ? b : ( a > c ? c : a);
}
var rgb, h = hsv.h, s = hsv.s, v = hsv.v;
var o = this.options;
switch (name) {
case "monochromatic":
case "mono":
if (o.algorithm === 1) {
rgb = this.hsv2rgb(hsv);
rgb.r = toRange(Math.round(rgb.r + (255 - rgb.r) * o.tint1), 0, 255);
rgb.g = toRange(Math.round(rgb.g + (255 - rgb.g) * o.tint1), 0, 255);
rgb.b = toRange(Math.round(rgb.b + (255 - rgb.b) * o.tint1), 0, 255);
scheme.push(this.rgb2hsv(rgb));
rgb = this.hsv2rgb(hsv);
rgb.r = toRange(Math.round(rgb.r + (255 - rgb.r) * o.tint2), 0, 255);
rgb.g = toRange(Math.round(rgb.g + (255 - rgb.g) * o.tint2), 0, 255);
rgb.b = toRange(Math.round(rgb.b + (255 - rgb.b) * o.tint2), 0, 255);
scheme.push(this.rgb2hsv(rgb));
scheme.push(hsv);
rgb = this.hsv2rgb(hsv);
rgb.r = toRange(Math.round(rgb.r * o.shade1), 0, 255);
rgb.g = toRange(Math.round(rgb.g * o.shade1), 0, 255);
rgb.b = toRange(Math.round(rgb.b * o.shade1), 0, 255);
scheme.push(this.rgb2hsv(rgb));
rgb = this.hsv2rgb(hsv);
rgb.r = toRange(Math.round(rgb.r * o.shade2), 0, 255);
rgb.g = toRange(Math.round(rgb.g * o.shade2), 0, 255);
rgb.b = toRange(Math.round(rgb.b * o.shade2), 0, 255);
scheme.push(this.rgb2hsv(rgb));
} else if (o.algorithm === 2) {
scheme.push(hsv);
for(i = 1; i <= o.distance; i++) {
v = clamp(v - o.step, 0, 1);
s = clamp(s - o.step, 0, 1);
scheme.push({h: h, s: s, v: v});
}
} else if (o.algorithm === 3) {
scheme.push(hsv);
for(i = 1; i <= o.distance; i++) {
v = clamp(v - o.step, 0, 1);
scheme.push({h: h, s: s, v: v});
}
} else {
v = clamp(hsv.v + o.step * 2, 0, 1);
scheme.push({h: h, s: s, v: v});
v = clamp(hsv.v + o.step, 0, 1);
scheme.push({h: h, s: s, v: v});
scheme.push(hsv); s = hsv.s; v = hsv.v;
v = clamp(hsv.v - o.step, 0, 1);
scheme.push({h: h, s: s, v: v});
v = clamp(hsv.v - o.step * 2, 0, 1);
scheme.push({h: h, s: s, v: v});
}
break;
case 'complementary':
case 'complement':
case 'comp':
scheme.push(hsv);
h = this.hueShift(hsv.h, 180.0);
scheme.push({h: h, s: s, v: v});
break;
case 'double-complementary':
case 'double-complement':
case 'double':
scheme.push(hsv);
console.log(h);
h = this.hueShift(h, 180.0);
scheme.push({h: h, s: s, v: v});
console.log(h);
h = this.hueShift(h, o.angle);
scheme.push({h: h, s: s, v: v});
console.log(h);
h = this.hueShift(h, 180.0);
scheme.push({h: h, s: s, v: v});
console.log(h);
break;
case 'analogous':
case 'analog':
h = this.hueShift(h, o.angle);
scheme.push({h: h, s: s, v: v});
scheme.push(hsv);
h = this.hueShift(hsv.h, 0.0 - o.angle);
scheme.push({h: h, s: s, v: v});
break;
case 'triadic':
case 'triad':
scheme.push(hsv);
for ( i = 1; i < 3; i++ ) {
h = this.hueShift(h, 120.0);
scheme.push({h: h, s: s, v: v});
}
break;
case 'tetradic':
case 'tetra':
scheme.push(hsv);
h = this.hueShift(hsv.h, 180.0);
scheme.push({h: h, s: s, v: v});
h = this.hueShift(hsv.h, -1 * o.angle);
scheme.push({h: h, s: s, v: v});
h = this.hueShift(h, 180.0);
scheme.push({h: h, s: s, v: v});
break;
case 'square':
scheme.push(hsv);
for ( i = 1; i < 4; i++ ) {
h = this.hueShift(h, 90.0);
scheme.push({h: h, s: s, v: v});
}
break;
case 'split-complementary':
case 'split-complement':
case 'split':
h = this.hueShift(h, 180.0 - o.angle);
scheme.push({h: h, s: s, v: v});
scheme.push(hsv);
h = this.hueShift(hsv.h, 180.0 + o.angle);
scheme.push({h: h, s: s, v: v});
break;
default: console.log("Unknown scheme name");
}
return convert(scheme, format);
}
};
Metro['colors'] = Colors.init();
// Source: js/utils/easing.js
$.easing['jswing'] = $.easing['swing'];
$.extend($.easing, {
def: 'easeOutQuad',
swing: function (x, t, b, c, d) {
//alert($.easing.default);
return $.easing[$.easing.def](x, t, b, c, d);
},
easeInQuad: function (x, t, b, c, d) {
return c * (t /= d) * t + b;
},
easeOutQuad: function (x, t, b, c, d) {
return -c * (t /= d) * (t - 2) + b;
},
easeInOutQuad: function (x, t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t + b;
return -c / 2 * ((--t) * (t - 2) - 1) + b;
},
easeInCubic: function (x, t, b, c, d) {
return c * (t /= d) * t * t + b;
},
easeOutCubic: function (x, t, b, c, d) {
return c * ((t = t / d - 1) * t * t + 1) + b;
},
easeInOutCubic: function (x, t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
return c / 2 * ((t -= 2) * t * t + 2) + b;
},
easeInQuart: function (x, t, b, c, d) {
return c * (t /= d) * t * t * t + b;
},
easeOutQuart: function (x, t, b, c, d) {
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
},
easeInOutQuart: function (x, t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
},
easeInQuint: function (x, t, b, c, d) {
return c * (t /= d) * t * t * t * t + b;
},
easeOutQuint: function (x, t, b, c, d) {
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
},
easeInOutQuint: function (x, t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
},
easeInSine: function (x, t, b, c, d) {
return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
},
easeOutSine: function (x, t, b, c, d) {
return c * Math.sin(t / d * (Math.PI / 2)) + b;
},
easeInOutSine: function (x, t, b, c, d) {
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
},
easeInExpo: function (x, t, b, c, d) {
return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
},
easeOutExpo: function (x, t, b, c, d) {
return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
if (t == 0) return b;
if (t == d) return b + c;
if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
easeInCirc: function (x, t, b, c, d) {
return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
},
easeOutCirc: function (x, t, b, c, d) {
return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
},
easeInOutCirc: function (x, t, b, c, d) {
if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
},
easeInElastic: function (x, t, b, c, d) {
var s = 1.70158;
var p = 0;
var a = c;
if (t == 0) return b;
if ((t /= d) == 1) return b + c;
if (!p) p = d * .3;
if (a < Math.abs(c)) {
a = c;
s = p / 4;
}
else s = p / (2 * Math.PI) * Math.asin(c / a);
return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
},
easeOutElastic: function (x, t, b, c, d) {
var s = 1.70158;
var p = 0;
var a = c;
if (t == 0) return b;
if ((t /= d) == 1) return b + c;
if (!p) p = d * .3;
if (a < Math.abs(c)) {
a = c;
s = p / 4;
}
else s = p / (2 * Math.PI) * Math.asin(c / a);
return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
},
easeInOutElastic: function (x, t, b, c, d) {
var s = 1.70158;
var p = 0;
var a = c;
if (t == 0) return b;
if ((t /= d / 2) == 2) return b + c;
if (!p) p = d * (.3 * 1.5);
if (a < Math.abs(c)) {
a = c;
s = p / 4;
}
else s = p / (2 * Math.PI) * Math.asin(c / a);
if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
},
easeInBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c * (t /= d) * t * ((s + 1) * t - s) + b;
},
easeOutBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
},
easeInOutBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
},
easeInBounce: function (x, t, b, c, d) {
return c - $.easing.easeOutBounce(x, d - t, 0, c, d) + b;
},
easeOutBounce: function (x, t, b, c, d) {
if ((t /= d) < (1 / 2.75)) {
return c * (7.5625 * t * t) + b;
} else if (t < (2 / 2.75)) {
return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
} else if (t < (2.5 / 2.75)) {
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
} else {
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
}
},
easeInOutBounce: function (x, t, b, c, d) {
if (t < d / 2) return $.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
return $.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
}
});
// Source: js/utils/export.js
var Export = {
init: function(){
return this;
},
options: {
csvDelimiter: "\t",
csvNewLine: "\r\n",
includeHeader: true
},
setup: function(options){
this.options = $.extend({}, this.options, options);
return this;
},
base64: function(data){
return window.btoa(unescape(encodeURIComponent(data)));
},
b64toBlob: function (b64Data, contentType, sliceSize) {
contentType = contentType || '';
sliceSize = sliceSize || 512;
var byteCharacters = window.atob(b64Data);
var byteArrays = [];
var offset;
for (offset = 0; offset < byteCharacters.length; offset += sliceSize) {
var slice = byteCharacters.slice(offset, offset + sliceSize);
var byteNumbers = new Array(slice.length);
var i;
for (i = 0; i < slice.length; i = i + 1) {
byteNumbers[i] = slice.charCodeAt(i);
}
var byteArray = new window.Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
return new Blob(byteArrays, {
type: contentType
});
},
tableToCSV: function(table, filename, options){
var that = this, o = this.options;
var body, head, data = "";
var i, j, row, cell;
o = $.extend({}, o, options);
if (Utils.isJQueryObject(table)) {
table = table[0];
}
if (Utils.bool(o.includeHeader)) {
head = table.querySelectorAll("thead")[0];
for(i = 0; i < head.rows.length; i++) {
row = head.rows[i];
for(j = 0; j < row.cells.length; j++){
cell = row.cells[j];
data += (j ? o.csvDelimiter : '') + cell.textContent.trim();
}
data += o.csvNewLine;
}
}
body = table.querySelectorAll("tbody")[0];
for(i = 0; i < body.rows.length; i++) {
row = body.rows[i];
for(j = 0; j < row.cells.length; j++){
cell = row.cells[j];
data += (j ? o.csvDelimiter : '') + cell.textContent.trim();
}
data += o.csvNewLine;
}
if (Utils.isValue(filename)) {
return this.createDownload(this.base64("\uFEFF" + data), 'application/csv', filename);
}
return data;
},
createDownload: function (data, contentType, filename) {
var blob, anchor, url;
anchor = document.createElement('a');
anchor.style.display = "none";
document.body.appendChild(anchor);
blob = this.b64toBlob(data, contentType);
url = window.URL.createObjectURL(blob);
anchor.href = url;
anchor.download = filename || Utils.elementId("download");
anchor.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(anchor);
return true;
}
};
Metro['export'] = Export.init();
// Source: js/utils/extensions.js
$.fn.extend({
toggleAttr: function(a, v){
return this.each(function(){
var el = $(this);
if (v !== undefined) {
el.attr(a, v);
} else {
if (el.attr(a) !== undefined) {
el.removeAttr(a);
} else {
el.attr(a, ""+a);
}
}
});
},
clearClasses: function(){
return this.each(function(){
this.className = "";
});
}
});
Array.prototype.shuffle = function () {
var currentIndex = this.length, temporaryValue, randomIndex;
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = this[currentIndex];
this[currentIndex] = this[randomIndex];
this[randomIndex] = temporaryValue;
}
return this;
};
Array.prototype.clone = function () {
return this.slice(0);
};
Array.prototype.unique = function () {
var a = this.concat();
for (var i = 0; i < a.length; ++i) {
for (var j = i + 1; j < a.length; ++j) {
if (a[i] === a[j])
a.splice(j--, 1);
}
}
return a;
};
if (!Array.from) {
Array.from = function(val) {
var i, a = [];
if (val.length === undefined && typeof val === "object") {
return Object.values(val);
}
if (val.length !== undefined) {
for(i = 0; i < val.length; i++) {
a.push(val[i]);
}
return a;
}
throw new Error("Value can not be converted to array");
};
}
if (typeof Array.contains !== "function") {
Array.prototype.contains = function(val, from){
return this.indexOf(val, from) > -1;
}
}
/**
* Number.prototype.format(n, x, s, c)
*
* @param n: length of decimal
* @param x: length of whole part
* @param s: sections delimiter
* @param c: decimal delimiter
*/
Number.prototype.format = function(n, x, s, c) {
var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')',
num = this.toFixed(Math.max(0, ~~n));
return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));
};
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
String.prototype.contains = function() {
return !!~String.prototype.indexOf.apply(this, arguments);
};
String.prototype.toDate = function(format, locale) {
var result;
var normalized, normalizedFormat, formatItems, dateItems, checkValue;
var monthIndex, dayIndex, yearIndex, hourIndex, minutesIndex, secondsIndex;
var year, month, day, hour, minute, second;
var parsedMonth;
locale = locale || "en-US";
var monthNameToNumber = function(month){
var d, months, index, i;
month = month.substr(0, 3);
if (
locale !== undefined
&& locale !== "en-US"
&& Locales !== undefined
&& Locales[locale] !== undefined
&& Locales[locale]['calendar'] !== undefined
&& Locales[locale]['calendar']['months'] !== undefined
) {
months = Locales[locale]['calendar']['months'];
for(i = 12; i < months.length; i++) {
if (months[i].toLowerCase() === month.toLowerCase()) {
index = i - 12;
break;
}
}
month = Locales["en-US"]['calendar']['months'][index];
}
d = Date.parse(month + " 1, 1972");
if(!isNaN(d)){
return new Date(d).getMonth() + 1;
}
return -1;
};
if (format === undefined || format === null || format === "") {
return new Date(this);
}
// normalized = this.replace(/[^a-zA-Z0-9%]/g, '-');
normalized = this.replace(/[\/,.:\s]/g, '-');
normalizedFormat= format.toLowerCase().replace(/[^a-zA-Z0-9%]/g, '-');
formatItems = normalizedFormat.split('-');
dateItems = normalized.split('-');
checkValue = normalized.replace(/\-/g,"");
if (checkValue.trim() === "") {
return "Invalid Date";
}
monthIndex = formatItems.indexOf("mm") > -1 ? formatItems.indexOf("mm") : formatItems.indexOf("%m");
dayIndex = formatItems.indexOf("dd") > -1 ? formatItems.indexOf("dd") : formatItems.indexOf("%d");
yearIndex = formatItems.indexOf("yyyy") > -1 ? formatItems.indexOf("yyyy") : formatItems.indexOf("yy") > -1 ? formatItems.indexOf("yy") : formatItems.indexOf("%y");
hourIndex = formatItems.indexOf("hh") > -1 ? formatItems.indexOf("hh") : formatItems.indexOf("%h");
minutesIndex = formatItems.indexOf("ii") > -1 ? formatItems.indexOf("ii") : formatItems.indexOf("mi") > -1 ? formatItems.indexOf("mi") : formatItems.indexOf("%i");
secondsIndex = formatItems.indexOf("ss") > -1 ? formatItems.indexOf("ss") : formatItems.indexOf("%s");
if (monthIndex > -1 && dateItems[monthIndex] !== "") {
if (isNaN(parseInt(dateItems[monthIndex]))) {
dateItems[monthIndex] = monthNameToNumber(dateItems[monthIndex]);
if (dateItems[monthIndex] === -1) {
return "Invalid Date";
}
} else {
parsedMonth = parseInt(dateItems[monthIndex]);
if (parsedMonth < 1 || parsedMonth > 12) {
return "Invalid Date";
}
}
} else {
return "Invalid Date";
}
year = yearIndex >-1 && dateItems[yearIndex] !== "" ? dateItems[yearIndex] : null;
month = monthIndex >-1 && dateItems[monthIndex] !== "" ? dateItems[monthIndex] : null;
day = dayIndex >-1 && dateItems[dayIndex] !== "" ? dateItems[dayIndex] : null;
hour = hourIndex >-1 && dateItems[hourIndex] !== "" ? dateItems[hourIndex] : null;
minute = minutesIndex>-1 && dateItems[minutesIndex] !== "" ? dateItems[minutesIndex] : null;
second = secondsIndex>-1 && dateItems[secondsIndex] !== "" ? dateItems[secondsIndex] : null;
result = new Date(year,month-1,day,hour,minute,second);
return result;
};
String.prototype.toArray = function(delimiter, type, format){
var str = this;
var a;
type = type || "string";
delimiter = delimiter || ",";
format = format === undefined || format === null ? false : format;
a = (""+str).split(delimiter);
return a.map(function(s){
var result;
switch (type) {
case "int":
case "integer": result = parseInt(s); break;
case "number":
case "float": result = parseFloat(s); break;
case "date": result = !format ? new Date(s) : s.toDate(format); break;
default: result = s.trim();
}
return result;
});
};
Date.prototype.getWeek = function (dowOffset) {
var nYear, nday, newYear, day, daynum, weeknum;
dowOffset = !Utils.isValue(dowOffset) ? METRO_WEEK_START : typeof dowOffset === 'number' ? parseInt(dowOffset) : 0;
newYear = new Date(this.getFullYear(),0,1);
day = newYear.getDay() - dowOffset;
day = (day >= 0 ? day : day + 7);
daynum = Math.floor((this.getTime() - newYear.getTime() -
(this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
if(day < 4) {
weeknum = Math.floor((daynum+day-1)/7) + 1;
if(weeknum > 52) {
nYear = new Date(this.getFullYear() + 1,0,1);
nday = nYear.getDay() - dowOffset;
nday = nday >= 0 ? nday : nday + 7;
weeknum = nday < 4 ? 1 : 53;
}
}
else {
weeknum = Math.floor((daynum+day-1)/7);
}
return weeknum;
};
Date.prototype.getYear = function(){
return this.getFullYear().toString().substr(-2);
};
Date.prototype.format = function(format, locale){
if (locale === undefined) {
locale = "en-US";
}
var cal = (Metro.locales !== undefined && Metro.locales[locale] !== undefined ? Metro.locales[locale] : Metro.locales["en-US"])['calendar'];
var date = this;
var nDay = date.getDay(),
nDate = date.getDate(),
nMonth = date.getMonth(),
nYear = date.getFullYear(),
nHour = date.getHours(),
aDays = cal['days'],
aMonths = cal['months'],
aDayCount = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
isLeapYear = function() {
return (nYear%4===0 && nYear%100!==0) || nYear%400===0;
},
getThursday = function() {
var target = new Date(date);
target.setDate(nDate - ((nDay+6)%7) + 3);
return target;
},
zeroPad = function(nNum, nPad) {
return ('' + (Math.pow(10, nPad) + nNum)).slice(1);
};
return format.replace(/(%[a-z])/gi, function(sMatch) {
return {
'%a': aDays[nDay].slice(0,3),
'%A': aDays[nDay],
'%b': aMonths[nMonth].slice(0,3),
'%B': aMonths[nMonth],
'%c': date.toUTCString(),
'%C': Math.floor(nYear/100),
'%d': zeroPad(nDate, 2),
'dd': zeroPad(nDate, 2),
'%e': nDate,
'%F': date.toISOString().slice(0,10),
'%G': getThursday().getFullYear(),
'%g': ('' + getThursday().getFullYear()).slice(2),
'%H': zeroPad(nHour, 2),
// 'HH': zeroPad(nHour, 2),
'%I': zeroPad((nHour+11)%12 + 1, 2),
'%j': zeroPad(aDayCount[nMonth] + nDate + ((nMonth>1 && isLeapYear()) ? 1 : 0), 3),
'%k': '' + nHour,
'%l': (nHour+11)%12 + 1,
'%m': zeroPad(nMonth + 1, 2),
// 'mm': zeroPad(nMonth + 1, 2),
'%M': zeroPad(date.getMinutes(), 2),
// 'MM': zeroPad(date.getMinutes(), 2),
'%p': (nHour<12) ? 'AM' : 'PM',
'%P': (nHour<12) ? 'am' : 'pm',
'%s': Math.round(date.getTime()/1000),
// 'ss': Math.round(date.getTime()/1000),
'%S': zeroPad(date.getSeconds(), 2),
// 'SS': zeroPad(date.getSeconds(), 2),
'%u': nDay || 7,
'%V': (function() {
var target = getThursday(),
n1stThu = target.valueOf();
target.setMonth(0, 1);
var nJan1 = target.getDay();
if (nJan1!==4) target.setMonth(0, 1 + ((4-nJan1)+7)%7);
return zeroPad(1 + Math.ceil((n1stThu-target)/604800000), 2);
})(),
'%w': '' + nDay,
'%x': date.toLocaleDateString(),
'%X': date.toLocaleTimeString(),
'%y': ('' + nYear).slice(2),
// 'yy': ('' + nYear).slice(2),
'%Y': nYear,
// 'YYYY': nYear,
'%z': date.toTimeString().replace(/.+GMT([+-]\d+).+/, '$1'),
'%Z': date.toTimeString().replace(/.+\((.+?)\)$/, '$1')
}[sMatch] || sMatch;
});
};
Date.prototype.addHours = function(n) {
this.setTime(this.getTime() + (n*60*60*1000));
return this;
};
Date.prototype.addDays = function(n) {
this.setDate(this.getDate() + (n));
return this;
};
Date.prototype.addMonths = function(n) {
this.setMonth(this.getMonth() + (n));
return this;
};
Date.prototype.addYears = function(n) {
this.setFullYear(this.getFullYear() + (n));
return this;
};
// Source: js/utils/hotkeys.js
var hotkeys = {
specialKeys: {
8: "backspace",
9: "tab",
10: "return",
13: "return",
16: "shift",
17: "ctrl",
18: "alt",
19: "pause",
20: "capslock",
27: "esc",
32: "space",
33: "pageup",
34: "pagedown",
35: "end",
36: "home",
37: "left",
38: "up",
39: "right",
40: "down",
45: "insert",
46: "del",
59: ";",
61: "=",
96: "0",
97: "1",
98: "2",
99: "3",
100: "4",
101: "5",
102: "6",
103: "7",
104: "8",
105: "9",
106: "*",
107: "+",
109: "-",
110: ".",
111: "/",
112: "f1",
113: "f2",
114: "f3",
115: "f4",
116: "f5",
117: "f6",
118: "f7",
119: "f8",
120: "f9",
121: "f10",
122: "f11",
123: "f12",
144: "numlock",
145: "scroll",
173: "-",
186: ";",
187: "=",
188: ",",
189: "-",
190: ".",
191: "/",
192: "`",
219: "[",
220: "\\",
221: "]",
222: "'"
},
shiftNums: {
"`": "~",
"1": "!",
"2": "@",
"3": "#",
"4": "$",
"5": "%",
"6": "^",
"7": "&",
"8": "*",
"9": "(",
"0": ")",
"-": "_",
"=": "+",
";": ": ",
"'": "\"",
",": "<",
".": ">",
"/": "?",
"\\": "|"
},
// excludes: button, checkbox, file, hidden, image, password, radio, reset, search, submit, url
textAcceptingInputTypes: [
"text", "password", "number", "email", "url", "range", "date", "month", "week", "time", "datetime",
"datetime-local", "search", "color", "tel"],
// default input types not to bind to unless bound directly
textInputTypes: /textarea|input|select/i,
options: {
filterInputAcceptingElements: METRO_HOTKEYS_FILTER_INPUT_ACCEPTING_ELEMENTS,
filterTextInputs: METRO_HOTKEYS_FILTER_TEXT_INPUTS,
filterContentEditable: METRO_HOTKEYS_FILTER_CONTENT_EDITABLE
},
keyHandler: function(handleObj){
if (typeof handleObj.data === "string") {
handleObj.data = {
keys: handleObj.data
};
}
// Only care when a possible input has been specified
if (!handleObj.data || !handleObj.data.keys || typeof handleObj.data.keys !== "string") {
return;
}
var origHandler = handleObj.handler,
keys = handleObj.data.keys.toLowerCase().split(" ");
handleObj.handler = function(event) {
// Don't fire in text-accepting inputs that we didn't directly bind to
if (this !== event.target &&
(hotkeys.options.filterInputAcceptingElements && hotkeys.textInputTypes.test(event.target.nodeName) ||
(hotkeys.options.filterContentEditable && $(event.target).attr('contenteditable')) ||
(hotkeys.options.filterTextInputs && $.inArray(event.target.type, hotkeys.textAcceptingInputTypes) > -1))
)
{
return;
}
var special = event.type !== "keypress" && hotkeys.specialKeys[event.which],
character = String.fromCharCode(event.which).toLowerCase(),
modif = "",
possible = {};
$.each(["alt", "ctrl", "shift"], function(index, specialKey) {
if (event[specialKey + 'Key'] && special !== specialKey) {
modif += specialKey + '+';
}
});
// metaKey is triggered off ctrlKey erronously
if (event.metaKey && !event.ctrlKey && special !== "meta") {
modif += "meta+";
}
if (event.metaKey && special !== "meta" && modif.indexOf("alt+ctrl+shift+") > -1) {
modif = modif.replace("alt+ctrl+shift+", "hyper+");
}
if (special) {
possible[modif + special] = true;
}
else {
possible[modif + character] = true;
possible[modif + hotkeys.shiftNums[character]] = true;
// "$" can be triggered as "Shift+4" or "Shift+$" or just "$"
if (modif === "shift+") {
possible[hotkeys.shiftNums[character]] = true;
}
}
for (var i = 0, l = keys.length; i < l; i++) {
if (possible[keys[i]]) {
return origHandler.apply(this, arguments);
}
}
};
}
};
$.each(["keydown", "keyup", "keypress"], function() {
$.event.special[this] = {
add: hotkeys.keyHandler
};
});
// Source: js/utils/i18n.js
var Locales = {
'en-US': {
"calendar": {
"months": [
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December",
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
],
"days": [
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa",
"Sun", "Mon", "Tus", "Wen", "Thu", "Fri", "Sat"
],
"time": {
"days": "DAYS",
"hours": "HOURS",
"minutes": "MINS",
"seconds": "SECS",
"month": "MON",
"day": "DAY",
"year": "YEAR"
}
},
"buttons": {
"ok": "OK",
"cancel": "Cancel",
"done": "Done",
"today": "Today",
"now": "Now",
"clear": "Clear",
"help": "Help",
"yes": "Yes",
"no": "No",
"random": "Random",
"save": "Save",
"reset": "Reset"
}
},
'cn-ZH': {
"calendar": {
"months": [
"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月",
"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
],
"days": [
"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六",
"日", "一", "二", "三", "四", "五", "六",
"周日", "周一", "周二", "周三", "周四", "周五", "周六"
],
"time": {
"days": "天",
"hours": "时",
"minutes": "分",
"seconds": "秒",
"month": "月",
"day": "日",
"year": "年"
}
},
"buttons": {
"ok": "确认",
"cancel": "取消",
"done": "完成",
"today": "今天",
"now": "现在",
"clear": "清除",
"help": "帮助",
"yes": "是",
"no": "否",
"random": "随机",
"save": "保存",
"reset": "重啟"
}
},
'de-DE': {
"calendar": {
"months": [
"Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember",
"Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"
],
"days": [
"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag",
"Sn", "Mn", "Di", "Mi", "Do", "Fr", "Sa",
"Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam"
],
"time": {
"days": "TAGE",
"hours": "UHR",
"minutes": "MIN",
"seconds": "SEK"
}
},
"buttons": {
"ok": "OK",
"cancel": "Abbrechen",
"done": "Fertig",
"today": "Heute",
"now": "Jetzt",
"clear": "Reinigen",
"help": "Hilfe",
"yes": "Ja",
"no": "Nein",
"random": "Zufällig",
"save": "Sparen",
"reset": "Zurücksetzen"
}
},
'hu-HU': {
"calendar": {
"months": [
'Január', 'Február', 'Március', 'Április', 'Május', 'Június', 'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December',
'Jan', 'Feb', 'Már', 'Ápr', 'Máj', 'Jún', 'Júl', 'Aug', 'Szep', 'Okt', 'Nov', 'Dec'
],
"days": [
'Vasárnap', 'Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat',
'V', 'H', 'K', 'Sz', 'Cs', 'P', 'Sz',
'Vas', 'Hét', 'Ke', 'Sze', 'Csü', 'Pén', 'Szom'
],
"time": {
"days": "NAP",
"hours": "ÓRA",
"minutes": "PERC",
"seconds": "MP"
}
},
"buttons": {
"ok": "OK",
"cancel": "Mégse",
"done": "Kész",
"today": "Ma",
"now": "Most",
"clear": "Törlés",
"help": "Segítség",
"yes": "Igen",
"no": "Nem",
"random": "Véletlen",
"save": "Mentés",
"reset": "Visszaállítás"
}
},
'ru-RU': {
"calendar": {
"months": [
"Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь",
"Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"
],
"days": [
"Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота",
"Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб",
"Вос", "Пон", "Вто", "Сре", "Чет", "Пят", "Суб"
],
"time": {
"days": "ДНИ",
"hours": "ЧАСЫ",
"minutes": "МИН",
"seconds": "СЕК"
}
},
"buttons": {
"ok": "ОК",
"cancel": "Отмена",
"done": "Готово",
"today": "Сегодня",
"now": "Сейчас",
"clear": "Очистить",
"help": "Помощь",
"yes": "Да",
"no": "Нет",
"random": "Случайно",
"save": "Сохранить",
"reset": "Сброс"
}
},
'uk-UA': {
"calendar": {
"months": [
"Січень", "Лютий", "Березень", "Квітень", "Травень", "Червень", "Липень", "Серпень", "Вересень", "Жовтень", "Листопад", "Грудень",
"Січ", "Лют", "Бер", "Кві", "Тра", "Чер", "Лип", "Сер", "Вер", "Жов", "Лис", "Гру"
],
"days": [
"Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П’ятниця", "Субота",
"Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб",
"Нед", "Пон", "Вiв", "Сер", "Чет", "Пят", "Суб"
],
"time": {
"days": "ДНІ",
"hours": "ГОД",
"minutes": "ХВИЛ",
"seconds": "СЕК"
}
},
"buttons": {
"ok": "ОК",
"cancel": "Відміна",
"done": "Готово",
"today": "Сьогодні",
"now": "Зараз",
"clear": "Очистити",
"help": "Допомога",
"yes": "Так",
"no": "Ні",
"random": "Випадково",
"save": "Зберегти",
"reset": "Скинути"
}
},
'es-MX': {
"calendar": {
"months": [
"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre",
"Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"
],
"days": [
"Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado",
"Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa",
"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
],
"time": {
"days": "DÍAS",
"hours": "HORAS",
"minutes": "MINS",
"seconds": "SEGS",
"month": "MES",
"day": "DÍA",
"year": "AÑO"
}
},
"buttons": {
"ok": "Aceptar",
"cancel": "Cancelar",
"done": "Hecho",
"today": "Hoy",
"now": "Ahora",
"clear": "Limpiar",
"help": "Ayuda",
"yes": "Si",
"no": "No",
"random": "Aleatorio",
"save": "Salvar",
"reset": "Reiniciar"
}
},
'fr-FR': {
"calendar": {
"months": [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre",
"Janv", "Févr", "Mars", "Avr", "Mai", "Juin", "Juil", "Août", "Sept", "Oct", "Nov", "Déc"
],
"days": [
"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi",
"De", "Du", "Ma", "Me", "Je", "Ve", "Sa",
"Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
],
"time": {
"days": "JOURS",
"hours": "HEURES",
"minutes": "MINS",
"seconds": "SECS",
"month": "MOIS",
"day": "JOUR",
"year": "ANNEE"
}
},
"buttons": {
"ok": "OK",
"cancel": "Annulé",
"done": "Fait",
"today": "Aujourd'hui",
"now": "Maintenant",
"clear": "Effacé",
"help": "Aide",
"yes": "Oui",
"no": "Non",
"random": "Aléatoire",
"save": "Sauvegarder",
"reset": "Réinitialiser"
}
},
'it-IT': {
"calendar": {
"months": [
"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre",
"Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"
],
"days": [
"Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato",
"Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa",
"Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
],
"time": {
"days": "GIORNI",
"hours": "ORE",
"minutes": "MIN",
"seconds": "SEC",
"month": "MESE",
"day": "GIORNO",
"year": "ANNO"
}
},
"buttons": {
"ok": "OK",
"cancel": "Annulla",
"done": "Fatto",
"today": "Oggi",
"now": "Adesso",
"clear": "Cancella",
"help": "Aiuto",
"yes": "Sì",
"no": "No",
"random": "Random",
"save": "Salvare",
"reset": "Reset"
}
}
};
Metro['locales'] = Locales;
// Source: js/utils/md5.js
var hexcase = 0;
/* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = "";
/* base-64 pad character. "=" for strict RFC compliance */
function hex_md5(s) {
return rstr2hex(rstr_md5(str2rstr_utf8(s)));
}
function b64_md5(s) {
return rstr2b64(rstr_md5(str2rstr_utf8(s)));
}
function any_md5(s, e) {
return rstr2any(rstr_md5(str2rstr_utf8(s)), e);
}
function hex_hmac_md5(k, d) {
return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
}
function b64_hmac_md5(k, d) {
return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
}
function any_hmac_md5(k, d, e) {
return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e);
}
/*
* Calculate the MD5 of a raw string
*/
function rstr_md5(s) {
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
}
/*
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
function rstr_hmac_md5(key, data) {
var bkey = rstr2binl(key);
if (bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
var ipad = new Array(16), opad = new Array(16);
for (var i = 0; i < 16; i++) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
}
/*
* Convert a raw string to a hex string
*/
function rstr2hex(input) {
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var output = "";
var x;
for (var i = 0; i < input.length; i++) {
x = input.charCodeAt(i);
output += hex_tab.charAt((x >>> 4) & 0x0F)
+ hex_tab.charAt(x & 0x0F);
}
return output;
}
/*
* Convert a raw string to a base-64 string
*/
function rstr2b64(input) {
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var output = "";
var len = input.length;
for (var i = 0; i < len; i += 3) {
var triplet = (input.charCodeAt(i) << 16)
| (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0)
| (i + 2 < len ? input.charCodeAt(i + 2) : 0);
for (var j = 0; j < 4; j++) {
if (i * 8 + j * 6 > input.length * 8) output += b64pad;
else output += tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
}
}
return output;
}
/*
* Convert a raw string to an arbitrary string encoding
*/
function rstr2any(input, encoding) {
var divisor = encoding.length;
var i, j, q, x, quotient;
/* Convert to an array of 16-bit big-endian values, forming the dividend */
var dividend = new Array(Math.ceil(input.length / 2));
for (i = 0; i < dividend.length; i++) {
dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
}
/*
* Repeatedly perform a long division. The binary array forms the dividend,
* the length of the encoding is the divisor. Once computed, the quotient
* forms the dividend for the next step. All remainders are stored for later
* use.
*/
var full_length = Math.ceil(input.length * 8 /
(Math.log(encoding.length) / Math.log(2)));
var remainders = new Array(full_length);
for (j = 0; j < full_length; j++) {
quotient = [];
x = 0;
for (i = 0; i < dividend.length; i++) {
x = (x << 16) + dividend[i];
q = Math.floor(x / divisor);
x -= q * divisor;
if (quotient.length > 0 || q > 0)
quotient[quotient.length] = q;
}
remainders[j] = x;
dividend = quotient;
}
/* Convert the remainders to the output string */
var output = "";
for (i = remainders.length - 1; i >= 0; i--)
output += encoding.charAt(remainders[i]);
return output;
}
/*
* Encode a string as utf-8.
* For efficiency, this assumes the input is valid utf-16.
*/
function str2rstr_utf8(input) {
var output = "";
var i = -1;
var x, y;
while (++i < input.length) {
/* Decode utf-16 surrogate pairs */
x = input.charCodeAt(i);
y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
if (0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) {
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
i++;
}
/* Encode output as utf-8 */
if (x <= 0x7F)
output += String.fromCharCode(x);
else if (x <= 0x7FF)
output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
0x80 | ( x & 0x3F));
else if (x <= 0xFFFF)
output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
0x80 | ((x >>> 6 ) & 0x3F),
0x80 | ( x & 0x3F));
else if (x <= 0x1FFFFF)
output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
0x80 | ((x >>> 12) & 0x3F),
0x80 | ((x >>> 6 ) & 0x3F),
0x80 | ( x & 0x3F));
}
return output;
}
/*
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binl(input) {
var i;
var output = new Array(input.length >> 2);
for (i = 0; i < output.length; i++)
output[i] = 0;
for (i = 0; i < input.length * 8; i += 8)
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
return output;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2rstr(input) {
var output = "";
for (var i = 0; i < input.length * 32; i += 8)
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
return output;
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl_md5(x, len) {
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for (var i = 0; i < x.length; i += 16) {
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i], 7, -680876936);
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i], 20, -373897302);
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5_hh(d, a, b, c, x[i], 11, -358537222);
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i], 6, -198630844);
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return [a, b, c, d];
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
// window.md5 = {
// hex: function(val){
// return hex_md5(val);
// },
//
// b64: function(val){
// return b64_md5(val);
// },
//
// any: function(s, e){
// return any_md5(s, e);
// },
//
// hex_hmac: function(k, d){
// return hex_hmac_md5(k, d);
// },
//
// b64_hmac: function(k, d){
// return b64_hmac_md5(k, d);
// },
//
// any_hmac: function(k, d, e){
// return any_hmac_md5(k, d, e);
// }
// };
//$.Metro['md5'] = hex_md5;
// Source: js/utils/mousewheel.js
var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
slice = Array.prototype.slice,
nullLowestDeltaTimeout, lowestDelta;
if ( $.event.fixHooks ) {
for ( var i = toFix.length; i; ) {
$.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
}
}
$.event.special.mousewheel = {
version: '3.1.12',
setup: function() {
if ( this.addEventListener ) {
for ( var i = toBind.length; i; ) {
this.addEventListener( toBind[--i], mousewheel_handler, false );
}
} else {
this.onmousewheel = mousewheel_handler;
}
// Store the line height and page height for this particular element
$.data(this, 'mousewheel-line-height', $.event.special.mousewheel.getLineHeight(this));
$.data(this, 'mousewheel-page-height', $.event.special.mousewheel.getPageHeight(this));
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i = toBind.length; i; ) {
this.removeEventListener( toBind[--i], mousewheel_handler, false );
}
} else {
this.onmousewheel = null;
}
// Clean up the data we added to the element
$.removeData(this, 'mousewheel-line-height');
$.removeData(this, 'mousewheel-page-height');
},
getLineHeight: function(elem) {
var $elem = $(elem),
$parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
if (!$parent.length) {
$parent = $('body');
}
return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
},
getPageHeight: function(elem) {
return $(elem).height();
},
settings: {
adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
normalizeOffset: true // calls getBoundingClientRect for each event
}
};
$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
},
unmousewheel: function(fn) {
return this.unbind('mousewheel', fn);
}
});
function mousewheel_handler(event) {
var orgEvent = event || window.event,
args = slice.call(arguments, 1),
delta = 0,
deltaX = 0,
deltaY = 0,
absDelta = 0,
offsetX = 0,
offsetY = 0;
event = $.event.fix(orgEvent);
event.type = 'mousewheel';
// Old school scrollwheel delta
if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaX = deltaY * -1;
deltaY = 0;
}
// Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
delta = deltaY === 0 ? deltaX : deltaY;
// New school wheel delta (wheel event)
if ( 'deltaY' in orgEvent ) {
deltaY = orgEvent.deltaY * -1;
delta = deltaY;
}
if ( 'deltaX' in orgEvent ) {
deltaX = orgEvent.deltaX;
if ( deltaY === 0 ) { delta = deltaX * -1; }
}
// No change actually happened, no reason to go any further
if ( deltaY === 0 && deltaX === 0 ) { return; }
// Need to convert lines and pages to pixels if we aren't already in pixels
// There are three delta modes:
// * deltaMode 0 is by pixels, nothing to do
// * deltaMode 1 is by lines
// * deltaMode 2 is by pages
if ( orgEvent.deltaMode === 1 ) {
var lineHeight = $.data(this, 'mousewheel-line-height');
delta *= lineHeight;
deltaY *= lineHeight;
deltaX *= lineHeight;
} else if ( orgEvent.deltaMode === 2 ) {
var pageHeight = $.data(this, 'mousewheel-page-height');
delta *= pageHeight;
deltaY *= pageHeight;
deltaX *= pageHeight;
}
// Store lowest absolute delta to normalize the delta values
absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
if ( !lowestDelta || absDelta < lowestDelta ) {
lowestDelta = absDelta;
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
lowestDelta /= 40;
}
}
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
// Divide all the things by 40!
delta /= 40;
deltaX /= 40;
deltaY /= 40;
}
// Get a whole, normalized value for the deltas
delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
// Normalise offsetX and offsetY properties
if ( $.event.special.mousewheel.settings.normalizeOffset && this.getBoundingClientRect ) {
var boundingRect = this.getBoundingClientRect();
offsetX = event.clientX - boundingRect.left;
offsetY = event.clientY - boundingRect.top;
}
// Add information to the event object
event.deltaX = deltaX;
event.deltaY = deltaY;
event.deltaFactor = lowestDelta;
event.offsetX = offsetX;
event.offsetY = offsetY;
// Go ahead and set deltaMode to 0 since we converted to pixels
// Although this is a little odd since we overwrite the deltaX/Y
// properties with normalized deltas.
event.deltaMode = 0;
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
// Clearout lowestDelta after sometime to better
// handle multiple device types that give different
// a different lowestDelta
// Ex: trackpad = 3 and mouse wheel = 120
if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
return ($.event.dispatch || $.event.handle).apply(this, args);
}
function nullLowestDelta() {
lowestDelta = null;
}
function shouldAdjustOldDeltas(orgEvent, absDelta) {
// If this is an older event and the delta is divisable by 120,
// then we are assuming that the browser is treating this as an
// older mouse wheel event and that we should divide the deltas
// by 40 to try and get a more usable deltaFactor.
// Side note, this actually impacts the reported scroll distance
// in older browsers and can cause scrolling to be slower than native.
// Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
return $.event.special.mousewheel.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
}
// Source: js/utils/scroll-events.js
var dispatch = $.event.dispatch || $.event.handle;
var special = jQuery.event.special,
uid1 = 'D' + (+new Date()),
uid2 = 'D' + (+new Date() + 1);
special.scrollstart = {
setup: function(data) {
var _data = $.extend({
latency: special.scrollstop.latency
}, data);
var timer,
handler = function(evt) {
var _self = this;
if (timer) {
clearTimeout(timer);
timer = null;
} else {
evt.type = 'scrollstart';
dispatch.apply(_self, arguments);
}
timer = setTimeout(function() {
timer = null;
}, _data.latency);
};
$(this).on('scroll', handler).data(uid1, handler);
},
teardown: function() {
$(this).off('scroll', $(this).data(uid1));
}
};
special.scrollstop = {
latency: 250,
setup: function(data) {
var _data = $.extend({
latency: special.scrollstop.latency
}, data);
var timer,
handler = function(evt) {
var _self = this,
_args = arguments;
if (timer) {
clearTimeout(timer);
timer = null;
}
timer = setTimeout(function() {
timer = null;
evt.type = 'scrollstop';
dispatch.apply(_self, _args);
}, _data.latency);
};
$(this).on('scroll', handler).data(uid2, handler);
},
teardown: function() {
$(this).off('scroll', $(this).data(uid2));
}
};
// Source: js/utils/storage.js
var Storage = function(type){
return new Storage.init(type);
};
Storage.prototype = {
setKey: function(key){
this.key = key
},
getKey: function(){
return this.key;
},
setItem: function(key, value){
this.storage.setItem(this.key + ":" + key, JSON.stringify(value));
},
getItem: function(key, default_value, reviver){
var result, value;
value = this.storage.getItem(this.key + ":" + key);
try {
result = JSON.parse(value, reviver);
} catch (e) {
result = null;
}
return Utils.nvl(result, default_value);
},
getItemPart: function(key, sub_key, default_value, reviver){
var i;
var val = this.getItem(key, default_value, reviver);
sub_key = sub_key.split("->");
for(i = 0; i < sub_key.length; i++) {
val = val[sub_key[i]];
}
return val;
},
delItem: function(key){
this.storage.removeItem(this.key + ":" + key)
},
size: function(unit){
var divider;
switch (unit) {
case 'm':
case 'M': {
divider = 1024 * 1024;
break;
}
case 'k':
case 'K': {
divider = 1024;
break;
}
default: divider = 1;
}
return JSON.stringify(this.storage).length / divider;
}
};
Storage.init = function(type){
this.key = "";
this.storage = type ? type : window.localStorage;
return this;
};
Storage.init.prototype = Storage.prototype;
Metro['storage'] = Storage(window.localStorage);
Metro['session'] = Storage(window.sessionStorage);
// Source: js/utils/tpl.js
var TemplateEngine = function(html, options) {
var re = /<%(.+?)%>/g,
reExp = /(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,
code = 'with(obj) { var r=[];\n',
cursor = 0,
result,
match;
var add = function(line, js) {
js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
(code += line !== '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
return add;
};
while(match = re.exec(html)) {
add(html.slice(cursor, match.index))(match[1], true);
cursor = match.index + match[0].length;
}
add(html.substr(cursor, html.length - cursor));
code = (code + 'return r.join(""); }').replace(/[\r\t\n]/g, ' ');
try { result = new Function('obj', code).apply(options, [options]); }
catch(err) { console.error("'" + err.message + "'", " in \n\nCode:\n", code, "\n"); }
return result;
};
Metro['template'] = TemplateEngine;
// Source: js/utils/utilities.js
var Utils = {
isUrl: function (val) {
return /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@\-\/]))?/.test(val);
},
isTag: function(val){
return /^<\/?[\w\s="/.':;#-\/\?]+>/gi.test(val);
},
isColor: function (val) {
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(val);
},
isEmbedObject: function(val){
var embed = ["iframe", "object", "embed", "video"];
var result = false;
$.each(embed, function(i, v){
'use strict';
if (typeof val === "string" && val.toLowerCase() === v) {
result = true;
} else if (val.nodeType !== undefined && val.tagName.toLowerCase() === v) {
result = true;
}
});
return result;
},
isVideoUrl: function(val){
return /youtu\.be|youtube|vimeo/gi.test(val);
},
isDate: function(val, format){
var result;
if (typeof val === "object" && Utils.isFunc(val['getMonth'])) {
return true;
}
if (Utils.isValue(format)) {
result = String(val).toDate(format);
} else {
result = String(new Date(val));
}
return result !== "Invalid Date";
},
isDateObject: function(v){
return typeof v === 'object' && v['getMonth'] !== undefined;
},
isInt: function(n){
return Number(n) === n && n % 1 === 0;
},
isFloat: function(n){
return Number(n) === n && n % 1 !== 0;
},
isTouchDevice: function() {
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
},
isFunc: function(f){
return Utils.isType(f, 'function');
},
isObject: function(o){
return Utils.isType(o, 'object')
},
isArray: function(a){
return Array.isArray(a);
},
isType: function(o, t){
if (o === undefined || o === null) {
return false;
}
if (typeof o === t) {
return o;
}
if (Utils.isTag(o) || Utils.isUrl(o)) {
return false;
}
if (typeof window[o] === t) {
return window[o];
}
if (typeof o === 'string' && o.indexOf(".") === -1) {
return false;
}
if (typeof o === 'string' && o.indexOf(" ") !== -1) {
return false;
}
if (typeof o === 'string' && o.indexOf("(") !== -1) {
return false;
}
if (typeof o === 'string' && o.indexOf("[") !== -1) {
return false;
}
if (typeof o === "number" && t.toLowerCase() !== "number") {
return false;
}
var ns = o.split(".");
var i, context = window;
for(i = 0; i < ns.length; i++) {
context = context[ns[i]];
}
return typeof context === t ? context : false;
},
isMetroObject: function(el, type){
var $el = $(el), el_obj = $el.data(type);
if ($el.length === 0) {
console.log(type + ' ' + el + ' not found!');
return false;
}
if (el_obj === undefined) {
console.log('Element not contain role '+ type +'! Please add attribute data-role="'+type+'" to element ' + el);
return false;
}
return true;
},
isJQueryObject: function(el){
return (typeof jQuery === "function" && el instanceof jQuery);
},
embedObject: function(val){
if (typeof val !== "string" ) {
val = Utils.isJQueryObject(val) ? val.html() : val.innerHTML;
}
return "
" + val + "
";
},
embedUrl: function(val){
if (val.indexOf("youtu.be") !== -1) {
val = "https://www.youtube.com/embed/" + val.split("/").pop();
}
return "";
},
secondsToTime: function(secs) {
var hours = Math.floor(secs / (60 * 60));
var divisor_for_minutes = secs % (60 * 60);
var minutes = Math.floor(divisor_for_minutes / 60);
var divisor_for_seconds = divisor_for_minutes % 60;
var seconds = Math.ceil(divisor_for_seconds);
return {
"h": hours,
"m": minutes,
"s": seconds
};
},
hex2rgba: function(hex, alpha){
var c;
alpha = isNaN(alpha) ? 1 : alpha;
if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
c= hex.substring(1).split('');
if(c.length=== 3){
c= [c[0], c[0], c[1], c[1], c[2], c[2]];
}
c= '0x'+c.join('');
return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+','+alpha+')';
}
throw new Error('Hex2rgba error. Bad Hex value');
},
random: function(from, to){
return Math.floor(Math.random()*(to-from+1)+from);
},
uniqueId: function () {
"use strict";
var d = new Date().getTime();
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
},
elementId: function(prefix){
return prefix+"-"+(new Date()).getTime()+Utils.random(1, 1000);
},
secondsToFormattedString: function(time){
var sec_num = parseInt(time, 10);
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10) {hours = "0"+hours;}
if (minutes < 10) {minutes = "0"+minutes;}
if (seconds < 10) {seconds = "0"+seconds;}
return [hours, minutes, seconds].join(":");
},
callback: function(f, args, context){
return Utils.exec(f, args, context);
},
func: function(f){
return new Function("a", f);
},
exec: function(f, args, context){
var result;
if (f === undefined || f === null) {return false;}
var func = Utils.isFunc(f);
if (func === false) {
func = Utils.func(f);
}
try {
result = func.apply(context, args);
} catch (err) {
result = null;
if (METRO_THROWS === true) {
throw err;
}
}
return result;
},
isOutsider: function(el) {
el = Utils.isJQueryObject(el) ? el : $(el);
var rect;
var clone = el.clone();
clone.removeAttr("data-role").css({
visibility: "hidden",
position: "absolute",
display: "block"
});
el.parent().append(clone);
rect = clone[0].getBoundingClientRect();
clone.remove();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
},
inViewport: function(el){
var rect = Utils.rect(el);
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
},
rect: function(el){
if (typeof jQuery === "function" && el instanceof jQuery) {
el = el[0];
}
return el.getBoundingClientRect();
},
getCursorPosition: function(el, e){
var a = Utils.rect(el);
return {
x: Utils.pageXY(e).x - a.left - window.pageXOffset,
y: Utils.pageXY(e).y - a.top - window.pageYOffset
};
},
getCursorPositionX: function(el, e){
return Utils.getCursorPosition(el, e).x;
},
getCursorPositionY: function(el, e){
return Utils.getCursorPosition(el, e).y;
},
objectLength: function(obj){
return Object.keys(obj).length;
},
percent: function(total, part, round_value){
if (total === 0) {
return 0;
}
var result = part * 100 / total;
return round_value === true ? Math.round(result) : Math.round(result * 100) / 100;
},
camelCase: function(str){
return str.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
},
dashedName: function(str){
return str.replace(/([A-Z])/g, function(u) { return "-" + u.toLowerCase(); });
},
objectShift: function(obj){
var min = 0;
$.each(obj, function(i){
if (min === 0) {
min = i;
} else {
if (min > i) {
min = i;
}
}
});
delete obj[min];
return obj;
},
objectDelete: function(obj, key){
if (obj[key] !== undefined) delete obj[key];
},
arrayDeleteByMultipleKeys: function(arr, keys){
keys.forEach(function(ind){
delete arr[ind];
});
return arr.filter(function(item){
return item !== undefined;
})
},
arrayDelete: function(arr, val){
arr.splice(arr.indexOf(val), 1);
},
arrayDeleteByKey: function(arr, key){
arr.splice(key, 1);
},
nvl: function(data, other){
return data === undefined || data === null ? other : data;
},
objectClone: function(obj){
var copy = {};
for(var key in obj) {
if (obj.hasOwnProperty(key)) {
copy[key] = obj[key];
}
}
return copy;
},
github: function(repo, callback){
var that = this;
$.ajax({
url: 'https://api.github.com/repos/' + repo,
dataType: 'jsonp'
})
.done(function(data){
that.callback(callback, [data.data]);
});
},
detectIE: function() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10 or older => return version number
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}
var trident = ua.indexOf('Trident/');
if (trident > 0) {
// IE 11 => return version number
var rv = ua.indexOf('rv:');
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
}
var edge = ua.indexOf('Edge/');
if (edge > 0) {
// Edge (IE 12+) => return version number
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
}
// other browser
return false;
},
detectChrome: function(){
return /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
},
md5: function(s){
return hex_md5(s);
},
encodeURI: function(str){
return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']');
},
pageHeight: function(){
var body = document.body,
html = document.documentElement;
return Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
},
cleanPreCode: function(selector){
var els = Array.prototype.slice.call(document.querySelectorAll(selector), 0);
els.forEach(function(el){
var txt = el.textContent
.replace(/^[\r\n]+/, "") // strip leading newline
.replace(/\s+$/g, "");
if (/^\S/gm.test(txt)) {
el.textContent = txt;
return;
}
var mat, str, re = /^[\t ]+/gm, len, min = 1e3;
while (mat = re.exec(txt)) {
len = mat[0].length;
if (len < min) {
min = len;
str = mat[0];
}
}
if (min === 1e3)
return;
el.textContent = txt.replace(new RegExp("^" + str, 'gm'), "");
});
},
coords: function(el){
if (Utils.isJQueryObject(el)) {
el = el[0];
}
var box = el.getBoundingClientRect();
return {
top: box.top + window.pageYOffset,
left: box.left + window.pageXOffset
};
},
positionXY: function(e, t){
switch (t) {
case 'client': return Utils.clientXY(e);
case 'screen': return Utils.screenXY(e);
case 'page': return Utils.pageXY(e);
default: return {x: 0, y: 0}
}
},
clientXY: function(e){
return {
x: e.changedTouches ? e.changedTouches[0].clientX : e.clientX,
y: e.changedTouches ? e.changedTouches[0].clientY : e.clientY
};
},
screenXY: function(e){
return {
x: e.changedTouches ? e.changedTouches[0].screenX : e.screenX,
y: e.changedTouches ? e.changedTouches[0].screenY : e.screenY
};
},
pageXY: function(e){
return {
x: e.changedTouches ? e.changedTouches[0].pageX : e.pageX,
y: e.changedTouches ? e.changedTouches[0].pageY : e.pageY
};
},
isRightMouse: function(e){
return "which" in e ? e.which === 3 : "button" in e ? e.button === 2 : undefined;
},
hiddenElementSize: function(el, includeMargin){
var clone = $(el).clone();
clone.removeAttr("data-role").css({
visibility: "hidden",
position: "absolute",
display: "block"
});
$("body").append(clone);
if (includeMargin === undefined) {
includeMargin = false;
}
var width = clone.outerWidth(includeMargin);
var height = clone.outerHeight(includeMargin);
clone.remove();
return {
width: width,
height: height
}
},
getStyle: function(el, pseudo){
if (Utils.isJQueryObject(el) === true) {
el = el[0];
}
return window.getComputedStyle(el, pseudo);
},
getStyleOne: function(el, property){
return Utils.getStyle(el).getPropertyValue(property);
},
getTransformMatrix: function(el, returnArray){
var computedMatrix = Utils.getStyleOne(el, "transform");
var a = computedMatrix
.replace("matrix(", '')
.slice(0, -1)
.split(',');
return returnArray !== true ? {
a: a[0],
b: a[1],
c: a[2],
d: a[3],
tx: a[4],
ty: a[5]
} : a;
},
computedRgbToHex: function(rgb){
var a = rgb.replace(/[^\d,]/g, '').split(',');
var result = "#", i;
for(i = 0; i < 3; i++) {
var h = parseInt(a[i]).toString(16);
result += h.length === 1 ? "0" + h : h;
}
return result;
},
computedRgbToRgba: function(rgb, alpha){
var a = rgb.replace(/[^\d,]/g, '').split(',');
if (alpha === undefined) {
alpha = 1;
}
a.push(alpha);
return "rgba("+a.join(",")+")";
},
computedRgbToArray: function(rgb){
return rgb.replace(/[^\d,]/g, '').split(',');
},
hexColorToArray: function(hex){
var c;
if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
c= hex.substring(1).split('');
if(c.length === 3){
c= [c[0], c[0], c[1], c[1], c[2], c[2]];
}
c= '0x'+c.join('');
return [(c>>16)&255, (c>>8)&255, c&255];
}
return [0,0,0];
},
hexColorToRgbA: function(hex, alpha){
var c;
if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
c= hex.substring(1).split('');
if(c.length === 3){
c= [c[0], c[0], c[1], c[1], c[2], c[2]];
}
c= '0x'+c.join('');
return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255, alpha ? alpha : 1].join(',')+')';
}
return 'rgba(0,0,0,1)';
},
getInlineStyles: function(el){
var styles = {};
if (Utils.isJQueryObject(el)) {
el = el[0];
}
for (var i = 0, l = el.style.length; i < l; i++) {
var s = el.style[i];
styles[s] = el.style[s];
}
return styles;
},
updateURIParameter: function(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
}
else {
return uri + separator + key + "=" + value;
}
},
getURIParameter: function(url, name){
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
},
getLocales: function(){
return Object.keys(Metro.locales);
},
addLocale: function(locale){
Metro.locales = $.extend( {}, Metro.locales, locale );
},
strToArray: function(str, delimiter, type, format){
var a;
if (!Utils.isValue(delimiter)) {
delimiter = ",";
}
if (!Utils.isValue(type)) {
type = "string";
}
a = (""+str).split(delimiter);
return a.map(function(s){
var result;
switch (type) {
case "int":
case "integer": result = parseInt(s); break;
case "number":
case "float": result = parseFloat(s); break;
case "date": result = !Utils.isValue(format) ? new Date(s) : s.toDate(format); break;
default: result = s.trim();
}
return result;
})
},
aspectRatioH: function(width, a){
if (a === "16/9") return width * 9 / 16;
if (a === "21/9") return width * 9 / 21;
if (a === "4/3") return width * 3 / 4;
},
aspectRatioW: function(height, a){
if (a === "16/9") return height * 16 / 9;
if (a === "21/9") return height * 21 / 9;
if (a === "4/3") return height * 4 / 3;
},
valueInObject: function(obj, value){
return Object.values(obj).indexOf(value) > -1;
},
keyInObject: function(){
return Object.keys(obj).indexOf(value) > -1;
},
inObject: function(obj, key, val){
return obj[key] !== undefined && obj[key] === val;
},
newCssSheet: function(media){
var style = document.createElement("style");
if (media !== undefined) {
style.setAttribute("media", media);
}
style.appendChild(document.createTextNode(""));
document.head.appendChild(style);
return style.sheet;
},
addCssRule: function(sheet, selector, rules, index){
if("insertRule" in sheet) {
sheet.insertRule(selector + "{" + rules + "}", index);
}
else if("addRule" in sheet) {
sheet.addRule(selector, rules, index);
}
},
media: function(query){
return window.matchMedia(query).matches
},
mediaModes: function(){
return METRO_MEDIA;
},
mediaExist: function(media){
return METRO_MEDIA.indexOf(media) > -1;
},
inMedia: function(media){
return METRO_MEDIA.indexOf(media) > -1 && METRO_MEDIA.indexOf(media) === METRO_MEDIA.length - 1;
},
isValue: function(val){
return val !== undefined && val !== null && val !== "";
},
isNull: function(val){
return val === undefined || val === null;
},
isNegative: function(val){
return parseFloat(val) < 0;
},
isPositive: function(val){
return parseFloat(val) > 0;
},
isZero: function(val){
return (parseFloat(val.toFixed(2))) === 0.00;
},
between: function(val, bottom, top, equals){
return equals === true ? val >= bottom && val <= top : val > bottom && val < top;
},
parseMoney: function(val){
return Number(parseFloat(val.replace(/[^0-9-.]/g, '')));
},
parseCard: function(val){
return val.replace(/[^0-9]/g, '');
},
parsePhone: function(val){
return Utils.parseCard(val);
},
isVisible: function(el){
if (Utils.isJQueryObject(el)) {
el = el[0];
}
return Utils.getStyleOne(el, "display") !== "none" && Utils.getStyleOne(el, "visibility") !== "hidden" && el.offsetParent !== null;
},
parseNumber: function(val, thousand, decimal){
return val.replace(new RegExp('\\'+thousand, "g"), "").replace(new RegExp('\\'+decimal, 'g'), ".");
},
nearest: function(val, precision, down){
val /= precision;
val = Math[down === true ? 'floor' : 'ceil'](val) * precision;
return val;
},
bool: function(value){
switch(value){
case true:
case "true":
case 1:
case "1":
case "on":
case "yes":
return true;
default:
return false;
}
},
copy: function(el){
var body = document.body, range, sel;
if (Utils.isJQueryObject(el)) {
el = el[0];
}
if (document.createRange && window.getSelection) {
range = document.createRange();
sel = window.getSelection();
sel.removeAllRanges();
try {
range.selectNodeContents(el);
sel.addRange(range);
} catch (e) {
range.selectNode(el);
sel.addRange(range);
}
} else if (body.createTextRange) {
range = body.createTextRange();
range.moveToElementText(el);
range.select();
}
document.execCommand("Copy");
if (window.getSelection) {
if (window.getSelection().empty) { // Chrome
window.getSelection().empty();
} else if (window.getSelection().removeAllRanges) { // Firefox
window.getSelection().removeAllRanges();
}
} else if (document.selection) { // IE?
document.selection.empty();
}
},
isLocalhost: function(){
return (location.hostname === "localhost" || location.hostname === "127.0.0.1" || location.hostname === "")
},
formData: function(form){
if (Utils.isNull(form)) {
return ;
}
if (Utils.isJQueryObject(form)) {
form = form[0];
}
if (!form || form.nodeName !== "FORM") {
return;
}
var i, j, q = {};
for (i = form.elements.length - 1; i >= 0; i = i - 1) {
if (form.elements[i].name === "") {
continue;
}
switch (form.elements[i].nodeName) {
case 'INPUT':
switch (form.elements[i].type) {
case 'text':
case 'hidden':
case 'password':
case 'button':
case 'reset':
case 'submit':
q[form.elements[i].name] = form.elements[i].value;
break;
case 'checkbox':
case 'radio':
if (form.elements[i].checked) {
q[form.elements[i].name] = form.elements[i].value;
}
break;
}
break;
case 'file':
break;
case 'TEXTAREA':
q[form.elements[i].name] = form.elements[i].value;
break;
case 'SELECT':
switch (form.elements[i].type) {
case 'select-one':
q[form.elements[i].name] = form.elements[i].value;
break;
case 'select-multiple':
q[form.elements[i].name] = [];
for (j = form.elements[i].options.length - 1; j >= 0; j = j - 1) {
if (form.elements[i].options[j].selected) {
q[form.elements[i].name].push(form.elements[i].options[j].value);
}
}
break;
}
break;
case 'BUTTON':
switch (form.elements[i].type) {
case 'reset':
case 'submit':
case 'button':
q[form.elements[i].name] = form.elements[i].value;
break;
}
break;
}
}
return q;
}
};
Metro['utils'] = Utils;
// Source: js/plugins/accordion.js
var Accordion = {
init: function( options, elem ) {
this.options = $.extend( {}, this.options, options );
this.elem = elem;
this.element = $(elem);
this._setOptionsFromDOM();
this._create();
Utils.exec(this.options.onAccordionCreate, [this.element]);
return this;
},
options: {
material: false,
duration: METRO_ANIMATION_DURATION,
oneFrame: true,
showActive: true,
activeFrameClass: "",
activeHeadingClass: "",
activeContentClass: "",
onFrameOpen: Metro.noop,
onFrameBeforeOpen: Metro.noop_true,
onFrameClose: Metro.noop,
onFrameBeforeClose: Metro.noop_true,
onAccordionCreate: Metro.noop
},
_setOptionsFromDOM: function(){
var that = this, element = this.element, o = this.options;
$.each(element.data(), function(key, value){
if (key in o) {
try {
o[key] = JSON.parse(value);
} catch (e) {
o[key] = value;
}
}
});
},
_create: function(){
var that = this, element = this.element, o = this.options;
var frames = element.children(".frame");
var active = element.children(".frame.active");
var frame_to_open;
element.addClass("accordion");
if (o.material === true) {
element.addClass("material");
}
if (active.length === 0) {
frame_to_open = frames[0];
} else {
frame_to_open = active[0];
}
this._hideAll();
if (o.showActive === true || o.oneFrame === true) {
this._openFrame(frame_to_open);
}
this._createEvents();
},
_createEvents: function(){
var that = this, element = this.element, o = this.options;
var active = element.children(".frame.active");
element.on(Metro.events.click, ".heading", function(){
var heading = $(this);
var frame = heading.parent();
if (heading.closest(".accordion")[0] !== element[0]) {
return false;
}
if (frame.hasClass("active")) {
if (active.length === 1 && o.oneFrame) {
} else {
that._closeFrame(frame);
}
} else {
that._openFrame(frame);
}
element.trigger("open", {frame: frame});
});
},
_openFrame: function(f){
var that = this, element = this.element, o = this.options;
var frames = element.children(".frame");
var frame = $(f);
if (Utils.exec(o.onFrameBeforeOpen, [frame], element[0]) === false) {
return false;
}
if (o.oneFrame === true) {
this._closeAll();
}
frame.addClass("active " + o.activeFrameClass);
frame.children(".heading").addClass(o.activeHeadingClass);
frame.children(".content").addClass(o.activeContentClass).slideDown(o.duration);
Utils.exec(o.onFrameOpen, [frame], element[0]);
},
_closeFrame: function(f){
var that = this, element = this.element, o = this.options;
var frame = $(f);
if (Utils.exec(o.onFrameBeforeClose, [frame], element[0]) === false) {
return ;
}
frame.removeClass("active " + o.activeFrameClass);
frame.children(".heading").removeClass(o.activeHeadingClass);
frame.children(".content").removeClass(o.activeContentClass).slideUp(o.duration);
Utils.callback(o.onFrameClose, [frame], element[0]);
},
_closeAll: function(){
var that = this, element = this.element, o = this.options;
var frames = element.children(".frame");
$.each(frames, function(){
that._closeFrame(this);
});
},
_hideAll: function(){
var that = this, element = this.element, o = this.options;
var frames = element.children(".frame");
$.each(frames, function(){
$(this).children(".content").hide(0);
});
},
_openAll: function(){
var that = this, element = this.element, o = this.options;
var frames = element.children(".frame");
$.each(frames, function(){
that._openFrame(this);
});
},
changeAttribute: function(attributeName){
},
destroy: function(){
this.element.off(Metro.events.click, ".heading");
}
};
Metro.plugin('accordion', Accordion);
// Source: js/plugins/activity.js
var Activity = {
init: function( options, elem ) {
this.options = $.extend( {}, this.options, options );
this.elem = elem;
this.element = $(elem);
this._setOptionsFromDOM();
this._create();
Utils.exec(this.options.onActivityCreate, [this.element]);
return this;
},
options: {
type: "ring",
style: "light",
size: 64,
radius: 20,
onActivityCreate: Metro.noop
},
_setOptionsFromDOM: function(){
var element = this.element, o = this.options;
$.each(element.data(), function(key, value){
if (key in o) {
try {
o[key] = JSON.parse(value);
} catch (e) {
o[key] = value;
}
}
});
},
_create: function(){
var element = this.element, o = this.options;
var i, wrap;
element
.html('')
.addClass(o.style + "-style")
.addClass("activity-" + o.type);
function _metro(){
for(i = 0; i < 5 ; i++) {
$("").addClass('circle').appendTo(element);
}
}
function _square(){
for(i = 0; i < 4 ; i++) {
$("").addClass('square').appendTo(element);
}
}
function _cycle(){
$("").addClass('cycle').appendTo(element);
}
function _ring(){
for(i = 0; i < 5 ; i++) {
wrap = $("").addClass('wrap').appendTo(element);
$("").addClass('circle').appendTo(wrap);
}
}
function _simple(){
$('').appendTo(element);
}
switch (o.type) {
case 'metro': _metro(); break;
case 'square': _square(); break;
case 'cycle': _cycle(); break;
case 'simple': _simple(); break;
default: _ring();
}
},
changeAttribute: function(attributeName){
},
destroy: function(){
var element = this.element, o = this.options;
element.html('')
.removeClass(o.style + "-style")
.removeClass("activity-" + o.type);
}
};
Metro.plugin('activity', Activity);
Metro['activity'] = {
open: function(options){
var activity = '';
var text = options.text ? ''+options.text+'
' : '';
return Metro.dialog.create({
content: activity + text,
defaultAction: false,
clsContent: "d-flex flex-column flex-justify-center flex-align-center bg-transparent no-shadow w-auto",
clsDialog: "no-border no-shadow bg-transparent global-dialog",
autoHide: options.autoHide ? options.autoHide : 0,
overlayClickClose: options.overlayClickClose === true,
overlayColor: options.overlayColor?options.overlayColor:'#000000',
overlayAlpha: options.overlayAlpha?options.overlayAlpha:.5,
clsOverlay: "global-overlay"
})
},
close: function(a){
Metro.dialog.close(a);
}
};
// Source: js/plugins/app-bar.js
var AppBar = {
init: function( options, elem ) {
this.options = $.extend( {}, this.options, options );
this.elem = elem;
this.element = $(elem);
this._setOptionsFromDOM();
this._create();
return this;
},
options: {
expand: false,
expandPoint: null,
duration: 100,
onAppBarCreate: Metro.noop
},
_setOptionsFromDOM: function(){
var that = this, element = this.element, o = this.options;
$.each(element.data(), function(key, value){
if (key in o) {
try {
o[key] = JSON.parse(value);
} catch (e) {
o[key] = value;
}
}
});
},
_create: function(){
var that = this, element = this.element, o = this.options;
this._createStructure();
this._createEvents();
Utils.exec(o.onAppBarCreate, [element]);
},
_createStructure: function(){
var that = this, element = this.element, o = this.options;
var id = Utils.elementId("app-bar");
var hamburger, menu;
element.addClass("app-bar");
hamburger = element.find(".hamburger");
if (hamburger.length === 0) {
hamburger = $("