1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

use alameda

This commit is contained in:
Luke Pulverenti 2017-04-13 14:57:24 -04:00
parent 0275060f71
commit 3fd7c3e85c
14 changed files with 57 additions and 12 deletions

View file

@ -0,0 +1,45 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/requirejs/alameda
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
Copyright and related rights for sample code are waived via CC0. Sample
code is defined as all source code displayed within the prose of the
documentation.
CC0: http://creativecommons.org/publicdomain/zero/1.0/
====
Files located in the node_modules directory, and certain utilities used
to build or test the software in the tests and tests-requirejs directories, are
externally maintained libraries used by this software which have their own
licenses; we recommend you read them, as their terms may differ from the
terms above.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
define(["globalize"],function(globalize){"use strict";function parseISO8601Date(s,toLocal){var re=/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|([+-])(\d{2}):(\d{2}))?/,d=s.match(re);if(!d)throw"Couldn't parse ISO 8601 date string '"+s+"'";var a=[1,2,3,4,5,6,10,11];for(var i in a)d[a[i]]=parseInt(d[a[i]],10);d[7]=parseFloat(d[7]);var ms=Date.UTC(d[1],d[2]-1,d[3],d[4],d[5],d[6]);if(d[7]>0&&(ms+=Math.round(1e3*d[7])),"Z"!==d[8]&&d[10]){var offset=60*d[10]*60*1e3;d[11]&&(offset+=60*d[11]*1e3),"-"===d[9]?ms-=offset:ms+=offset}else toLocal===!1&&(ms+=6e4*(new Date).getTimezoneOffset());return new Date(ms)}function getDisplayRunningTime(ticks){var ticksPerHour=36e9,ticksPerMinute=6e8,ticksPerSecond=1e7,parts=[],hours=ticks/ticksPerHour;hours=Math.floor(hours),hours&&parts.push(hours),ticks-=hours*ticksPerHour;var minutes=ticks/ticksPerMinute;minutes=Math.floor(minutes),ticks-=minutes*ticksPerMinute,minutes<10&&hours&&(minutes="0"+minutes),parts.push(minutes);var seconds=ticks/ticksPerSecond;return seconds=Math.floor(seconds),seconds<10&&(seconds="0"+seconds),parts.push(seconds),parts.join(":")}function getCurrentLocale(){var locale=globalize.getCurrentLocale();return locale}function getOptionList(options){var list=[];for(var i in options)list.push({name:i,value:options[i]});return list}function toLocaleString(date,options){options=options||{};var currentLocale=getCurrentLocale();return currentLocale&&toLocaleTimeStringSupportsLocales?date.toLocaleString(currentLocale,options):date.toLocaleString()}function toLocaleDateString(date,options){options=options||{};var currentLocale=getCurrentLocale();if(currentLocale&&toLocaleTimeStringSupportsLocales)return date.toLocaleDateString(currentLocale,options);var optionList=getOptionList(options);if(1===optionList.length&&"weekday"===optionList[0].name){var weekday=[];return weekday[0]="Sun",weekday[1]="Mon",weekday[2]="Tue",weekday[3]="Wed",weekday[4]="Thu",weekday[5]="Fri",weekday[6]="Sat",weekday[date.getDay()]}return date.toLocaleDateString()}function toLocaleTimeString(date,options){options=options||{};var currentLocale=getCurrentLocale();return currentLocale&&toLocaleTimeStringSupportsLocales?date.toLocaleTimeString(currentLocale,options):date.toLocaleTimeString()}function getDisplayTime(date){if("string"===(typeof date).toString().toLowerCase())try{date=parseISO8601Date(date,!0)}catch(err){return date}if(toLocaleTimeStringSupportsLocales)return toLocaleTimeString(date,{hour:"numeric",minute:"2-digit"});var time=toLocaleTimeString(date),timeLower=time.toLowerCase();if(timeLower.indexOf("am")!==-1||timeLower.indexOf("pm")!==-1){time=timeLower;var hour=date.getHours()%12,suffix=date.getHours()>11?"pm":"am";hour||(hour=12);var minutes=date.getMinutes();minutes<10&&(minutes="0"+minutes),minutes=":"+minutes,time=hour+minutes+suffix}else{var timeParts=time.split(":");timeParts.length>2&&(timeParts.length-=1,time=timeParts.join(":"))}return time}function isRelativeDay(date,offsetInDays){var yesterday=new Date,day=yesterday.getDate()+offsetInDays;return yesterday.setDate(day),date.getFullYear()===yesterday.getFullYear()&&date.getMonth()===yesterday.getMonth()&&date.getDate()===day}var toLocaleTimeStringSupportsLocales=function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}return!1}();return{parseISO8601Date:parseISO8601Date,getDisplayRunningTime:getDisplayRunningTime,toLocaleDateString:toLocaleDateString,toLocaleString:toLocaleString,getDisplayTime:getDisplayTime,isRelativeDay:isRelativeDay}});
define(["globalize"],function(globalize){"use strict";function parseISO8601Date(s,toLocal){var re=/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|([+-])(\d{2}):(\d{2}))?/,d=s.match(re);if(!d)throw"Couldn't parse ISO 8601 date string '"+s+"'";var a=[1,2,3,4,5,6,10,11];for(var i in a)d[a[i]]=parseInt(d[a[i]],10);d[7]=parseFloat(d[7]);var ms=Date.UTC(d[1],d[2]-1,d[3],d[4],d[5],d[6]);if(d[7]>0&&(ms+=Math.round(1e3*d[7])),"Z"!==d[8]&&d[10]){var offset=60*d[10]*60*1e3;d[11]&&(offset+=60*d[11]*1e3),"-"===d[9]?ms-=offset:ms+=offset}else toLocal===!1&&(ms+=6e4*(new Date).getTimezoneOffset());return new Date(ms)}function getDisplayRunningTime(ticks){var ticksPerHour=36e9,ticksPerMinute=6e8,ticksPerSecond=1e7,parts=[],hours=ticks/ticksPerHour;hours=Math.floor(hours),hours&&parts.push(hours),ticks-=hours*ticksPerHour;var minutes=ticks/ticksPerMinute;minutes=Math.floor(minutes),ticks-=minutes*ticksPerMinute,minutes<10&&hours&&(minutes="0"+minutes),parts.push(minutes);var seconds=ticks/ticksPerSecond;return seconds=Math.floor(seconds),seconds<10&&(seconds="0"+seconds),parts.push(seconds),parts.join(":")}function getCurrentLocale(){var locale=globalize.getCurrentLocale();return locale}function getOptionList(options){var list=[];for(var i in options)list.push({name:i,value:options[i]});return list}function toLocaleString(date,options){if(!date)throw new Error("date cannot be null");if(options=options||{},toLocaleTimeStringSupportsLocales){var currentLocale=getCurrentLocale();if(currentLocale)return date.toLocaleString(currentLocale,options)}return date.toLocaleString()}function toLocaleDateString(date,options){if(!date)throw new Error("date cannot be null");if(options=options||{},toLocaleTimeStringSupportsLocales){var currentLocale=getCurrentLocale();if(currentLocale)return date.toLocaleDateString(currentLocale,options)}var optionList=getOptionList(options);if(1===optionList.length&&"weekday"===optionList[0].name){var weekday=[];return weekday[0]="Sun",weekday[1]="Mon",weekday[2]="Tue",weekday[3]="Wed",weekday[4]="Thu",weekday[5]="Fri",weekday[6]="Sat",weekday[date.getDay()]}return date.toLocaleDateString()}function toLocaleTimeString(date,options){if(!date)throw new Error("date cannot be null");if(options=options||{},toLocaleTimeStringSupportsLocales){var currentLocale=getCurrentLocale();if(currentLocale)return date.toLocaleTimeString(currentLocale,options)}return date.toLocaleTimeString()}function getDisplayTime(date){if(!date)throw new Error("date cannot be null");if("string"===(typeof date).toString().toLowerCase())try{date=parseISO8601Date(date,!0)}catch(err){return date}if(toLocaleTimeStringSupportsLocales)return toLocaleTimeString(date,{hour:"numeric",minute:"2-digit"});var time=toLocaleTimeString(date),timeLower=time.toLowerCase();if(timeLower.indexOf("am")!==-1||timeLower.indexOf("pm")!==-1){time=timeLower;var hour=date.getHours()%12,suffix=date.getHours()>11?"pm":"am";hour||(hour=12);var minutes=date.getMinutes();minutes<10&&(minutes="0"+minutes),minutes=":"+minutes,time=hour+minutes+suffix}else{var timeParts=time.split(":");timeParts.length>2&&(timeParts.length-=1,time=timeParts.join(":"))}return time}function isRelativeDay(date,offsetInDays){if(!date)throw new Error("date cannot be null");var yesterday=new Date,day=yesterday.getDate()+offsetInDays;return yesterday.setDate(day),date.getFullYear()===yesterday.getFullYear()&&date.getMonth()===yesterday.getMonth()&&date.getDate()===day}var toLocaleTimeStringSupportsLocales=function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}return!1}();return{parseISO8601Date:parseISO8601Date,getDisplayRunningTime:getDisplayRunningTime,toLocaleDateString:toLocaleDateString,toLocaleString:toLocaleString,getDisplayTime:getDisplayTime,isRelativeDay:isRelativeDay}});

View file

@ -1 +1 @@
define(["scroller","dom","layoutManager","inputManager","focusManager","registerElement"],function(scroller,dom,layoutManager,inputManager,focusManager){"use strict";function initCenterFocus(elem,scrollerInstance){dom.addEventListener(elem,"focus",function(e){var focused=focusManager.focusableParent(e.target);focused&&scrollerInstance.toCenter(focused)},{capture:!0,passive:!0})}function onInputCommand(e){var cmd=e.detail.command;"home"===cmd?(focusManager.focusFirst(this,"."+this.getAttribute("data-navcommands")),e.preventDefault(),e.stopPropagation()):"end"===cmd?(focusManager.focusLast(this,"."+this.getAttribute("data-navcommands")),e.preventDefault(),e.stopPropagation()):"pageup"===cmd?(focusManager.moveFocus(e.target,this,"."+this.getAttribute("data-navcommands"),-12),e.preventDefault(),e.stopPropagation()):"pagedown"===cmd&&(focusManager.moveFocus(e.target,this,"."+this.getAttribute("data-navcommands"),12),e.preventDefault(),e.stopPropagation())}function initHeadroom(elem){require(["headroom"],function(Headroom){var headroom=new Headroom([],{scroller:elem});headroom.init(),headroom.add(document.querySelector(".skinHeader")),elem.headroom=headroom})}var ScrollerProtoType=Object.create(HTMLDivElement.prototype);ScrollerProtoType.createdCallback=function(){this.classList.add("emby-scroller")},ScrollerProtoType.scrollToBeginning=function(){this.scroller&&this.scroller.slideTo(0,!0)},ScrollerProtoType.toStart=function(elem,immediate){this.scroller&&this.scroller.toStart(elem,immediate)},ScrollerProtoType.scrollToPosition=function(pos,immediate){this.scroller&&this.scroller.slideTo(pos,immediate)},ScrollerProtoType.getScrollPosition=function(){if(this.scroller)return this.scroller.getScrollPosition()},ScrollerProtoType.attachedCallback=function(){this.getAttribute("data-navcommands")&&inputManager.on(this,onInputCommand);var horizontal="false"!==this.getAttribute("data-horizontal"),slider=this.querySelector(".scrollSlider");horizontal&&(slider.style["white-space"]="nowrap");var bindHeader="true"===this.getAttribute("data-bindheader"),options={horizontal:horizontal,mouseDragging:1,mouseWheel:"false"!==this.getAttribute("data-mousewheel"),touchDragging:1,slidee:slider,scrollBy:200,speed:horizontal?300:270,elasticBounds:1,dragHandle:1,scrollWidth:5e6,autoImmediate:!0,skipSlideToWhenVisible:"true"===this.getAttribute("data-skipfocuswhenvisible"),dispatchScrollEvent:bindHeader||"true"===this.getAttribute("data-scrollevent")},self=this;setTimeout(function(){self.scroller=new scroller(self,options),self.scroller.init(),layoutManager.tv&&self.getAttribute("data-centerfocus")&&initCenterFocus(self,self.scroller),bindHeader&&initHeadroom(self)},0)},ScrollerProtoType.detachedCallback=function(){this.getAttribute("data-navcommands")&&inputManager.off(this,onInputCommand);var headroom=this.headroom;headroom&&(headroom.destroy(),this.headroom=null);var scrollerInstance=this.scroller;scrollerInstance&&(scrollerInstance.destroy(),this.scroller=null)},document.registerElement("emby-scroller",{prototype:ScrollerProtoType,extends:"div"})});
define(["scroller","dom","layoutManager","inputManager","focusManager","registerElement"],function(scroller,dom,layoutManager,inputManager,focusManager){"use strict";function initCenterFocus(elem,scrollerInstance){dom.addEventListener(elem,"focus",function(e){var focused=focusManager.focusableParent(e.target);focused&&scrollerInstance.toCenter(focused)},{capture:!0,passive:!0})}function onInputCommand(e){var cmd=e.detail.command;"home"===cmd?(focusManager.focusFirst(this,"."+this.getAttribute("data-navcommands")),e.preventDefault(),e.stopPropagation()):"end"===cmd?(focusManager.focusLast(this,"."+this.getAttribute("data-navcommands")),e.preventDefault(),e.stopPropagation()):"pageup"===cmd?(focusManager.moveFocus(e.target,this,"."+this.getAttribute("data-navcommands"),-12),e.preventDefault(),e.stopPropagation()):"pagedown"===cmd&&(focusManager.moveFocus(e.target,this,"."+this.getAttribute("data-navcommands"),12),e.preventDefault(),e.stopPropagation())}function initHeadroom(elem){require(["headroom"],function(Headroom){var headroom=new Headroom([],{scroller:elem});headroom.init(),headroom.add(document.querySelector(".skinHeader")),elem.headroom=headroom})}var ScrollerProtoType=Object.create(HTMLDivElement.prototype);ScrollerProtoType.createdCallback=function(){this.classList.add("emby-scroller")},ScrollerProtoType.scrollToBeginning=function(){this.scroller&&this.scroller.slideTo(0,!0)},ScrollerProtoType.toStart=function(elem,immediate){this.scroller&&this.scroller.toStart(elem,immediate)},ScrollerProtoType.scrollToPosition=function(pos,immediate){this.scroller&&this.scroller.slideTo(pos,immediate)},ScrollerProtoType.getScrollPosition=function(){if(this.scroller)return this.scroller.getScrollPosition()},ScrollerProtoType.attachedCallback=function(){this.getAttribute("data-navcommands")&&inputManager.on(this,onInputCommand);var horizontal="false"!==this.getAttribute("data-horizontal"),slider=this.querySelector(".scrollSlider");horizontal&&(slider.style["white-space"]="nowrap");var bindHeader="true"===this.getAttribute("data-bindheader"),options={horizontal:horizontal,mouseDragging:1,mouseWheel:"false"!==this.getAttribute("data-mousewheel"),touchDragging:1,slidee:slider,scrollBy:200,speed:horizontal?300:270,elasticBounds:1,dragHandle:1,scrollWidth:5e6,autoImmediate:!0,skipSlideToWhenVisible:"true"===this.getAttribute("data-skipfocuswhenvisible"),dispatchScrollEvent:bindHeader||"true"===this.getAttribute("data-scrollevent")},self=this;self.scroller=new scroller(self,options),self.scroller.init(),layoutManager.tv&&self.getAttribute("data-centerfocus")&&initCenterFocus(self,self.scroller),bindHeader&&initHeadroom(self)},ScrollerProtoType.detachedCallback=function(){this.getAttribute("data-navcommands")&&inputManager.off(this,onInputCommand);var headroom=this.headroom;headroom&&(headroom.destroy(),this.headroom=null);var scrollerInstance=this.scroller;scrollerInstance&&(scrollerInstance.destroy(),this.scroller=null)},document.registerElement("emby-scroller",{prototype:ScrollerProtoType,extends:"div"})});

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
define(["dom"],function(dom){"use strict";function loadImage(elem,url){return"IMG"!==elem.tagName?(elem.style.backgroundImage="url('"+url+"')",Promise.resolve()):loadImageIntoImg(elem,url)}function loadImageIntoImg(elem,url){return new Promise(function(resolve,reject){dom.addEventListener(elem,"load",resolve,{once:!0}),elem.setAttribute("src",url)})}return{loadImage:loadImage}});
define(["dom"],function(dom){"use strict";function loadImage(elem,url){return elem?"IMG"!==elem.tagName?(elem.style.backgroundImage="url('"+url+"')",Promise.resolve()):loadImageIntoImg(elem,url):Promise.reject("elem cannot be null")}function loadImageIntoImg(elem,url){return new Promise(function(resolve,reject){dom.addEventListener(elem,"load",resolve,{once:!0}),elem.setAttribute("src",url)})}return{loadImage:loadImage}});

View file

@ -1 +1 @@
define(["lazyLoader","imageFetcher","layoutManager","browser","appSettings","require","css!./style"],function(lazyLoader,imageFetcher,layoutManager,browser,appSettings,require){"use strict";function fillImage(elem,source,enableEffects){source||(source=elem.getAttribute("data-src")),source&&fillImageElement(elem,source,enableEffects)}function fillImageElement(elem,source,enableEffects){imageFetcher.loadImage(elem,source).then(function(){var fillingVibrant=fillVibrant(elem,source);!enableFade||layoutManager.tv||enableEffects===!1||fillingVibrant||fadeIn(elem),elem.removeAttribute("data-src")})}function fillVibrant(img,url,canvas,canvasContext){var vibrantElement=img.getAttribute("data-vibrant");return!!vibrantElement&&(window.Vibrant?(fillVibrantOnLoaded(img,url,vibrantElement,canvas,canvasContext),!0):(require(["vibrant"],function(){fillVibrantOnLoaded(img,url,vibrantElement,canvas,canvasContext)}),!0))}function fillVibrantOnLoaded(img,url,vibrantElement){vibrantElement=document.getElementById(vibrantElement),vibrantElement&&requestIdleCallback(function(){getVibrantInfoFromElement(img,url).then(function(vibrantInfo){var swatch=vibrantInfo.split("|");if(swatch.length){var index=0;vibrantElement.style.backgroundColor=swatch[index],vibrantElement.style.color=swatch[index+1]}})})}function getVibrantInfoFromElement(elem,url){return new Promise(function(resolve,reject){require(["vibrant"],function(){if("IMG"===elem.tagName)return void resolve(getVibrantInfo(elem,url));var img=new Image;img.onload=function(){resolve(getVibrantInfo(img,url))},img.src=url})})}function getSettingsKey(url){var parts=url.split("://");url=parts[parts.length-1],url=url.substring(url.indexOf("/")+1),url=url.split("?")[0];var cacheKey="vibrant31";return cacheKey+url}function getCachedVibrantInfo(url){return appSettings.get(getSettingsKey(url))}function getVibrantInfo(img,url){var value=getCachedVibrantInfo(url);if(value)return value;var vibrant=new Vibrant(img),swatches=vibrant.swatches();value="";var swatch=swatches.DarkVibrant;return value+=getSwatchString(swatch),appSettings.set(getSettingsKey(url),value),value}function getSwatchString(swatch){return swatch?swatch.getHex()+"|"+swatch.getBodyTextColor()+"|"+swatch.getTitleTextColor():"||"}function fadeIn(elem){var cssClass=layoutManager.tv?"lazy-image-fadein-fast":"lazy-image-fadein";elem.classList.add(cssClass)}function lazyChildren(elem){lazyLoader.lazyChildren(elem,fillImage)}function getPrimaryImageAspectRatio(items){for(var values=[],i=0,length=items.length;i<length;i++){var ratio=items[i].PrimaryImageAspectRatio||0;ratio&&(values[values.length]=ratio)}if(!values.length)return null;values.sort(function(a,b){return a-b});var result,half=Math.floor(values.length/2);result=values.length%2?values[half]:(values[half-1]+values[half])/2;var aspect2x3=2/3;if(Math.abs(aspect2x3-result)<=.15)return aspect2x3;var aspect16x9=16/9;if(Math.abs(aspect16x9-result)<=.2)return aspect16x9;if(Math.abs(1-result)<=.15)return 1;var aspect4x3=4/3;return Math.abs(aspect4x3-result)<=.15?aspect4x3:result}function fillImages(elems){for(var i=0,length=elems.length;i<length;i++){var elem=elems[0];fillImage(elem)}}var requestIdleCallback=window.requestIdleCallback||function(fn){fn()},self={},enableFade=!browser.slow;return self.fillImages=fillImages,self.lazyImage=fillImage,self.lazyChildren=lazyChildren,self.getPrimaryImageAspectRatio=getPrimaryImageAspectRatio,self.getCachedVibrantInfo=getCachedVibrantInfo,self.getVibrantInfoFromElement=getVibrantInfoFromElement,self});
define(["lazyLoader","imageFetcher","layoutManager","browser","appSettings","require","css!./style"],function(lazyLoader,imageFetcher,layoutManager,browser,appSettings,require){"use strict";function fillImage(elem,source,enableEffects){if(!elem)throw new Error("elem cannot be null");source||(source=elem.getAttribute("data-src")),source&&fillImageElement(elem,source,enableEffects)}function fillImageElement(elem,source,enableEffects){imageFetcher.loadImage(elem,source).then(function(){var fillingVibrant=fillVibrant(elem,source);!enableFade||layoutManager.tv||enableEffects===!1||fillingVibrant||fadeIn(elem),elem.removeAttribute("data-src")})}function fillVibrant(img,url,canvas,canvasContext){var vibrantElement=img.getAttribute("data-vibrant");return!!vibrantElement&&(window.Vibrant?(fillVibrantOnLoaded(img,url,vibrantElement,canvas,canvasContext),!0):(require(["vibrant"],function(){fillVibrantOnLoaded(img,url,vibrantElement,canvas,canvasContext)}),!0))}function fillVibrantOnLoaded(img,url,vibrantElement){vibrantElement=document.getElementById(vibrantElement),vibrantElement&&requestIdleCallback(function(){getVibrantInfoFromElement(img,url).then(function(vibrantInfo){var swatch=vibrantInfo.split("|");if(swatch.length){var index=0;vibrantElement.style.backgroundColor=swatch[index],vibrantElement.style.color=swatch[index+1]}})})}function getVibrantInfoFromElement(elem,url){return new Promise(function(resolve,reject){require(["vibrant"],function(){if("IMG"===elem.tagName)return void resolve(getVibrantInfo(elem,url));var img=new Image;img.onload=function(){resolve(getVibrantInfo(img,url))},img.src=url})})}function getSettingsKey(url){var parts=url.split("://");url=parts[parts.length-1],url=url.substring(url.indexOf("/")+1),url=url.split("?")[0];var cacheKey="vibrant31";return cacheKey+url}function getCachedVibrantInfo(url){return appSettings.get(getSettingsKey(url))}function getVibrantInfo(img,url){var value=getCachedVibrantInfo(url);if(value)return value;var vibrant=new Vibrant(img),swatches=vibrant.swatches();value="";var swatch=swatches.DarkVibrant;return value+=getSwatchString(swatch),appSettings.set(getSettingsKey(url),value),value}function getSwatchString(swatch){return swatch?swatch.getHex()+"|"+swatch.getBodyTextColor()+"|"+swatch.getTitleTextColor():"||"}function fadeIn(elem){var cssClass=layoutManager.tv?"lazy-image-fadein-fast":"lazy-image-fadein";elem.classList.add(cssClass)}function lazyChildren(elem){lazyLoader.lazyChildren(elem,fillImage)}function getPrimaryImageAspectRatio(items){for(var values=[],i=0,length=items.length;i<length;i++){var ratio=items[i].PrimaryImageAspectRatio||0;ratio&&(values[values.length]=ratio)}if(!values.length)return null;values.sort(function(a,b){return a-b});var result,half=Math.floor(values.length/2);result=values.length%2?values[half]:(values[half-1]+values[half])/2;var aspect2x3=2/3;if(Math.abs(aspect2x3-result)<=.15)return aspect2x3;var aspect16x9=16/9;if(Math.abs(aspect16x9-result)<=.2)return aspect16x9;if(Math.abs(1-result)<=.15)return 1;var aspect4x3=4/3;return Math.abs(aspect4x3-result)<=.15?aspect4x3:result}function fillImages(elems){for(var i=0,length=elems.length;i<length;i++){var elem=elems[0];fillImage(elem)}}var requestIdleCallback=window.requestIdleCallback||function(fn){fn()},self={},enableFade=!browser.slow;return self.fillImages=fillImages,self.lazyImage=fillImage,self.lazyChildren=lazyChildren,self.getPrimaryImageAspectRatio=getPrimaryImageAspectRatio,self.getCachedVibrantInfo=getCachedVibrantInfo,self.getVibrantInfoFromElement=getVibrantInfoFromElement,self});

View file

@ -1 +0,0 @@
define(["cryptojs-md5"],function(){"use strict";function createObjectStore(dataBase){dataBase.createObjectStore(imagesTableName,{keyPath:"id"}),db=dataBase}function revoke(url){}function loadImage(elem,url){return"IMG"!==elem.tagName?(elem.style.backgroundImage="url('"+url+"')",revoke(url),Promise.resolve(elem)):(elem.setAttribute("src",url),revoke(url),Promise.resolve(elem))}function getCacheKey(url){var index=url.indexOf("://");return index!==-1&&(url=url.substring(index+3),index=url.indexOf("/"),index!==-1&&(url=url.substring(index+1))),CryptoJS.MD5(url).toString()}function getFromDb(key){return new Promise(function(resolve,reject){var transaction=db.transaction(imagesTableName,"read"),request=transaction.objectStore(imagesTableName).get(key);request.onsuccess=function(event){var imgFile=event.target.result,URL=window.URL||window.webkitURL,imgURL=URL.createObjectURL(imgFile);resolve(imgURL)},request.onerror=reject})}function saveImageToDb(blob,key,resolve){var transaction=db.transaction(imagesTableName,"readwrite"),URL=(transaction.objectStore(imagesTableName).put({id:key,data:blob}),window.URL||window.webkitURL),imgURL=URL.createObjectURL(blob);resolve(imgURL)}function getImageUrl(originalUrl){var key=getCacheKey(originalUrl);return getFromDb(key).catch(function(){return new Promise(function(resolve,reject){var xhr=new XMLHttpRequest;xhr.open("GET",originalUrl,!0),xhr.responseType="blob",xhr.addEventListener("load",function(){200===xhr.status?saveImageToDb(xhr.response,key,resolve):reject()},!1),xhr.onerror=reject,xhr.send()})})}var db,indexedDB=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,dbVersion=1,imagesTableName="images",request=indexedDB.open("imagesDb2",dbVersion);return request.onupgradeneeded=function(){createObjectStore(request.result)},request.onsuccess=function(event){console.log("Success creating/accessing IndexedDB database");var localDb=request.result;if(localDb.onerror=function(event){console.log("Error creating/accessing IndexedDB database")},localDb.setVersion)if(localDb.version!==dbVersion){var setVersion=localDb.setVersion(dbVersion);setVersion.onsuccess=function(){createObjectStore(localDb)}}else db=localDb;else db=localDb},{loadImage:function(elem,url){return db?getImageUrl(url).then(function(localUrl){return loadImage(elem,localUrl)},function(){return loadImage(elem,url)}):loadImage(elem,url)}}});

View file

@ -1 +0,0 @@
define(["cryptojs-md5"],function(){"use strict";function loadImage(elem,url){return"IMG"!==elem.tagName?(elem.style.backgroundImage="url('"+url+"')",Promise.resolve(elem)):(elem.setAttribute("src",url),Promise.resolve(elem))}function createDir(rootDirEntry,folders,callback,errorCallback){"."!==folders[0]&&""!==folders[0]||(folders=folders.slice(1)),rootDirEntry.getDirectory(folders[0],{create:!0},function(dirEntry){folders.length>1?createDir(dirEntry,folders.slice(1),callback,errorCallback):callback(dirEntry)},errorCallback)}function toArray(list){return Array.prototype.slice.call(list||[],0)}function cleanCache(){var dirReader=imageCacheDirectoryEntry.createReader(),entries=[],onReadFail=function(){console.log("dirReader.readEntries failed")},readEntries=function(){dirReader.readEntries(function(results){results.length?(entries=entries.concat(toArray(results)),readEntries()):entries.forEach(cleanFile)},onReadFail)};readEntries()}function cleanFile(fileEntry){fileEntry.isFile&&fileEntry.file(function(file){getLastModified(file,fileEntry).then(function(lastModifiedDate){var elapsed=(new Date).getTime()-lastModifiedDate,maxElapsed=3456e6;if(elapsed>=maxElapsed){var fullPath=fileEntry.fullPath;console.log("deleting file: "+fullPath),fileEntry.remove(function(){console.log("File deleted: "+fullPath)},function(){console.log("Failed to delete file: "+fullPath)})}})})}function getLastModified(file,fileEntry){var lastModifiedDate=file.lastModified||file.lastModifiedDate||file.modificationTime;return lastModifiedDate?(lastModifiedDate.getTime&&(lastModifiedDate=lastModifiedDate.getTime()),Promise.resolve(lastModifiedDate)):new Promise(function(resolve,reject){fileEntry.getMetadata(function(metadata){var lastModifiedDate=metadata.lastModified||metadata.lastModifiedDate||metadata.modificationTime;lastModifiedDate&&lastModifiedDate.getTime&&(lastModifiedDate=lastModifiedDate.getTime()),resolve(lastModifiedDate)})})}function getCacheKey(url){var index=url.indexOf("://");return index!==-1&&(url=url.substring(index+3),index=url.indexOf("/"),index!==-1&&(url=url.substring(index+1))),CryptoJS.MD5(url).toString()}function downloadToFile(url,dir,filename,callback,errorCallback){console.log("Downloading "+url);var xhr=new XMLHttpRequest;xhr.open("GET",url,!0),xhr.responseType="arraybuffer",xhr.onload=function(e){200===this.status?writeData(dir,filename,this.getResponseHeader("Content-Type"),this.response,callback,errorCallback):errorCallback()},xhr.send()}function writeData(dir,filename,fileType,data,callback,errorCallback){dir.getFile(filename,{create:!0},function(fileEntry){fileEntry.createWriter(function(fileWriter){fileWriter.onwriteend=function(e){callback(fileEntry)},fileWriter.onerror=errorCallback;var blob=new Blob([data],{type:fileType});fileWriter.write(blob)},errorCallback)},errorCallback)}function getImageUrl(originalUrl){return new Promise(function(resolve,reject){originalUrl.indexOf("tag=")!==-1&&(originalUrl+="&accept=webp");var key=getCacheKey(originalUrl),fileEntryCallback=function(fileEntry){resolve(fileEntry.toURL())},errorCallback=function(e){console.log("Imagestore error: "+e.name),reject()};if(!fileSystem||!imageCacheDirectoryEntry)return void errorCallback("");var path="/"+imageCacheFolder+"/"+key;fileSystem.root.getFile(path,{create:!1},fileEntryCallback,function(){downloadToFile(originalUrl,imageCacheDirectoryEntry,key,fileEntryCallback,errorCallback)})})}var imageCacheDirectoryEntry,requestedBytes=1572864e3,imageCacheFolder="images";navigator.webkitPersistentStorage.requestQuota(requestedBytes,function(grantedBytes){var requestMethod=window.webkitRequestFileSystem||window.requestFileSystem;requestMethod(PERSISTENT,grantedBytes,function(fs){fileSystem=fs,createDir(fileSystem.root,imageCacheFolder.split("/"),function(dirEntry){imageCacheDirectoryEntry=dirEntry,setTimeout(cleanCache,6e4)})})});var fileSystem;return{loadImage:function(elem,url){return getImageUrl(url).then(function(localUrl){return loadImage(elem,localUrl)},function(){return loadImage(elem,url)})}}});

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
!function(){function loadRequire(){var src,script=document.createElement("script");src=self.Promise&&navigator.userAgent.toLowerCase().indexOf("os x")===-1?"./bower_components/alameda/alameda.js":"./bower_components/requirejs/require.js",self.dashboardVersion&&(src+="?v="+self.dashboardVersion),script.src=src,script.onload=loadApp,document.head.appendChild(script)}function loadApp(){var script=document.createElement("script"),src="./scripts/site.js";self.dashboardVersion&&(src+="?v="+self.dashboardVersion),script.src=src,document.head.appendChild(script)}loadRequire()}();

File diff suppressed because one or more lines are too long