mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Pre release commit
This commit is contained in:
parent
66c3307291
commit
935fed3aef
27 changed files with 37 additions and 7387 deletions
|
|
@ -4,7 +4,7 @@
|
|||
<name>RainLoop</name>
|
||||
<description>Simple, modern and fast web-based email client.</description>
|
||||
<version>0.0</version>
|
||||
<licence>CC BY-NC-SA 3.0</licence>
|
||||
<licence>AGPL 3.0</licence>
|
||||
<author>RainLoop Team</author>
|
||||
<require>6.0</require>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -1463,7 +1463,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
this.loginAndLogoutReload(false, true);
|
||||
this.logout();
|
||||
}
|
||||
|
||||
}, self));
|
||||
|
|
|
|||
|
|
@ -93,7 +93,10 @@ cfg.paths.less = {
|
|||
src: 'dev/Styles/@Main.less',
|
||||
watch: ['dev/Styles/*.less'],
|
||||
options: {
|
||||
paths: [path.join(__dirname, 'dev/Styles/'), path.join(__dirname, 'vendors/bootstrap/less/')]
|
||||
paths: [
|
||||
path.join(__dirname, 'dev', 'Styles'),
|
||||
path.join(__dirname, 'vendors', 'bootstrap', 'less')
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -152,10 +155,8 @@ cfg.paths.js = {
|
|||
src: [
|
||||
'vendors/modernizr.js',
|
||||
'vendors/underscore/1.6.0/underscore-min.js',
|
||||
'vendors/is.js/is.min.js',
|
||||
'vendors/jquery/jquery-1.11.2.min.js',
|
||||
'vendors/jquery-ui/js/jquery-ui-1.10.3.custom.min.js',
|
||||
// 'vendors/jquery-ui.touch-punch/jquery.ui.touch-punch.min.js',
|
||||
'vendors/jquery-cookie/jquery.cookie-1.4.0.min.js',
|
||||
'vendors/jquery-finger/jquery.finger.min.js',
|
||||
'vendors/jquery-mousewheel/jquery.mousewheel-3.1.4.min.js',
|
||||
|
|
@ -173,7 +174,6 @@ cfg.paths.js = {
|
|||
'vendors/routes/hasher.min.js',
|
||||
'vendors/routes/crossroads.min.js',
|
||||
'vendors/knockout/knockout-3.3.0.js',
|
||||
// 'vendors/knockout-punches/knockout.punches.min.js',
|
||||
'vendors/knockout-projections/knockout-projections-1.0.0.min.js',
|
||||
'vendors/knockout-sortable/knockout-sortable.min.js',
|
||||
'vendors/ssm/ssm.min.js',
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "RainLoop",
|
||||
"title": "RainLoop Webmail",
|
||||
"version": "1.9.0",
|
||||
"release": "315",
|
||||
"release": "322",
|
||||
"description": "Simple, modern & fast web-based email client",
|
||||
"homepage": "http://rainloop.net",
|
||||
"main": "gulpfile.js",
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
"plugins"
|
||||
],
|
||||
"readmeFilename": "README.md",
|
||||
"ownCloudPackageVersion": "3.3",
|
||||
"ownCloudPackageVersion": "4.0",
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2089,7 +2089,7 @@ class MailClient
|
|||
{
|
||||
$aUids = array();
|
||||
$iResultRootUid = 0;
|
||||
|
||||
|
||||
if (isset($mAllThreads[$iThreadUid]))
|
||||
{
|
||||
$iResultRootUid = $iThreadUid;
|
||||
|
|
@ -2457,7 +2457,6 @@ class MailClient
|
|||
$oFolderCollection->IsThreadsSupported = $this->IsThreadsSupported();
|
||||
}
|
||||
|
||||
|
||||
return $oFolderCollection;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4812,7 +4812,7 @@ class Actions
|
|||
public function DoChangePassword()
|
||||
{
|
||||
$mResult = false;
|
||||
|
||||
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
if ($oAccount)
|
||||
{
|
||||
|
|
@ -5075,12 +5075,6 @@ class Actions
|
|||
// \sleep(1);
|
||||
// throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::MailServerError);
|
||||
|
||||
$sRawKey = (string) $this->GetActionParam('RawKey', '');
|
||||
if (0 < \strlen($sRawKey))
|
||||
{
|
||||
$this->verifyCacheByKey($sRawKey);
|
||||
}
|
||||
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
$oFolderCollection = null;
|
||||
|
|
@ -5098,6 +5092,8 @@ class Actions
|
|||
|
||||
if ($oFolderCollection instanceof \MailSo\Mail\FolderCollection)
|
||||
{
|
||||
$oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
|
||||
|
||||
$aSystemFolders = array();
|
||||
|
||||
$this->recFoldersTypes($oAccount, $oFolderCollection, $aSystemFolders);
|
||||
|
|
@ -5106,6 +5102,7 @@ class Actions
|
|||
if ($this->Config()->Get('labs', 'autocreate_system_folders', true))
|
||||
{
|
||||
$bDoItAgain = false;
|
||||
|
||||
$sNamespace = $oFolderCollection->GetNamespace();
|
||||
$sParent = empty($sNamespace) ? '' : \substr($sNamespace, 0, -1);
|
||||
|
||||
|
|
@ -5113,23 +5110,28 @@ class Actions
|
|||
|
||||
$aList = array();
|
||||
$aMap = $this->systemFoldersNames($oAccount);
|
||||
if ('' === $this->GetActionParam('SentFolder', ''))
|
||||
|
||||
if ('' === $oSettingsLocal->GetConf('SentFolder', ''))
|
||||
{
|
||||
$aList[] = \MailSo\Imap\Enumerations\FolderType::SENT;
|
||||
}
|
||||
if ('' === $this->GetActionParam('DraftFolder', ''))
|
||||
|
||||
if ('' === $oSettingsLocal->GetConf('DraftFolder', ''))
|
||||
{
|
||||
$aList[] = \MailSo\Imap\Enumerations\FolderType::DRAFTS;
|
||||
}
|
||||
if ('' === $this->GetActionParam('SpamFolder', ''))
|
||||
|
||||
if ('' === $oSettingsLocal->GetConf('SpamFolder', ''))
|
||||
{
|
||||
$aList[] = \MailSo\Imap\Enumerations\FolderType::JUNK;
|
||||
}
|
||||
if ('' === $this->GetActionParam('TrashFolder', ''))
|
||||
|
||||
if ('' === $oSettingsLocal->GetConf('TrashFolder', ''))
|
||||
{
|
||||
$aList[] = \MailSo\Imap\Enumerations\FolderType::TRASH;
|
||||
}
|
||||
if ('' === $this->GetActionParam('ArchiveFolder', ''))
|
||||
|
||||
if ('' === $oSettingsLocal->GetConf('ArchiveFolder', ''))
|
||||
{
|
||||
$aList[] = \MailSo\Imap\Enumerations\FolderType::ALL;
|
||||
}
|
||||
|
|
@ -5204,8 +5206,6 @@ class Actions
|
|||
if ($oFolderCollection)
|
||||
{
|
||||
$oFolderCollection->FoldersHash = \md5(\implode("\x0", $this->recFoldersNames($oFolderCollection)));
|
||||
|
||||
$this->cacheByKey($sRawKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,152 +25,6 @@ class Social
|
|||
$this->oActions = $oActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $oItem
|
||||
* @param array $aPics
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
private function convertGoogleJsonContactToResponseContact($oItem, &$aPics)
|
||||
{
|
||||
$mResult = null;
|
||||
if (!empty($oItem['gd$email'][0]['address']))
|
||||
{
|
||||
$mEmail = \MailSo\Base\Utils::IdnToAscii($oItem['gd$email'][0]['address'], true);
|
||||
if (\is_array($oItem['gd$email']) && 1 < \count($oItem['gd$email']))
|
||||
{
|
||||
$mEmail = array();
|
||||
foreach ($oItem['gd$email'] as $oEmail)
|
||||
{
|
||||
if (!empty($oEmail['address']))
|
||||
{
|
||||
$mEmail[] = \MailSo\Base\Utils::IdnToAscii($oEmail['address'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sImg = '';
|
||||
if (!empty($oItem['link']) && \is_array($oItem['link']))
|
||||
{
|
||||
foreach ($oItem['link'] as $oLink)
|
||||
{
|
||||
if ($oLink && isset($oLink['type'], $oLink['href'], $oLink['rel']) &&
|
||||
'image/*' === $oLink['type'] && '#photo' === \substr($oLink['rel'], -6))
|
||||
{
|
||||
$sImg = $oLink['href'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mResult = array(
|
||||
'email' => $mEmail,
|
||||
'name' => !empty($oItem['title']['$t']) ? $oItem['title']['$t'] : ''
|
||||
);
|
||||
|
||||
if (0 < \strlen($sImg))
|
||||
{
|
||||
$sHash = \RainLoop\Utils::EncodeKeyValues(array(
|
||||
'url' => $sImg,
|
||||
'type' => 'google_access_token'
|
||||
));
|
||||
|
||||
$mData = array();
|
||||
if (isset($aPics[$sHash]))
|
||||
{
|
||||
$mData = $aPics[$sHash];
|
||||
if (!\is_array($mData))
|
||||
{
|
||||
$mData = array($mData);
|
||||
}
|
||||
}
|
||||
|
||||
if (\is_array($mEmail))
|
||||
{
|
||||
$mData = \array_merge($mData, $mEmail);
|
||||
$mData = \array_unique($mData);
|
||||
}
|
||||
else if (0 < \strlen($mEmail))
|
||||
{
|
||||
$mData[] = $mEmail;
|
||||
}
|
||||
|
||||
if (\is_array($mData))
|
||||
{
|
||||
if (1 === \count($mData) && !empty($mData[0]))
|
||||
{
|
||||
$aPics[$sHash] = $mData[0];
|
||||
}
|
||||
else if (1 < \count($mData))
|
||||
{
|
||||
$aPics[$sHash] = $mData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $mResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function GoogleUserContacts($oAccount)
|
||||
{
|
||||
$mResult = false;
|
||||
$oGoogle = $this->GoogleConnector();
|
||||
$aPics = array();
|
||||
|
||||
if ($oAccount && $oGoogle)
|
||||
{
|
||||
$sAccessToken = $this->GoogleAccessToken($oAccount, $oGoogle);
|
||||
if (!empty($sAccessToken))
|
||||
{
|
||||
$oGoogle->setAccessToken($sAccessToken);
|
||||
|
||||
$aResponse = $oGoogle->fetch('https://www.google.com/m8/feeds/contacts/default/full', array(
|
||||
'alt' => 'json'
|
||||
));
|
||||
|
||||
if (!empty($aResponse['result']['feed']['entry']) && \is_array($aResponse['result']['feed']['entry']))
|
||||
{
|
||||
$mResult = array();
|
||||
foreach ($aResponse['result']['feed']['entry'] as $oItem)
|
||||
{
|
||||
$aItem = $this->convertGoogleJsonContactToResponseContact($oItem, $aPics);
|
||||
if ($aItem)
|
||||
{
|
||||
if (\is_array($aItem['email']))
|
||||
{
|
||||
$aNewItem = $aItem;
|
||||
unset($aNewItem['email']);
|
||||
|
||||
foreach ($aItem['email'] as $sEmail)
|
||||
{
|
||||
$aNewItem['email'] = $sEmail;
|
||||
$mResult[] = $aNewItem;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mResult[] = $aItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->oActions->Logger()->Write('Empty Google Access Token', \MailSo\Log\Enumerations\Type::ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return false !== $mResult ? array(
|
||||
'List' => $mResult,
|
||||
'Pics' => $aPics
|
||||
) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -185,7 +39,7 @@ class Social
|
|||
if (!empty($sEncodedeData))
|
||||
{
|
||||
$aData = \RainLoop\Utils::DecodeKeyValues($sEncodedeData);
|
||||
if (\is_array($aData) && isset($aData['access_token'], $aData['id']))
|
||||
if (\is_array($aData) && !empty($aData['id']))
|
||||
{
|
||||
$this->oActions->StorageProvider()->Clear(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
||||
|
|
@ -332,15 +186,15 @@ class Social
|
|||
if (!empty($aAuthorizationResponse['result']['access_token']))
|
||||
{
|
||||
$oGoogle->setAccessToken($aAuthorizationResponse['result']['access_token']);
|
||||
$aUserinfoResponse = $oGoogle->fetch('https://www.googleapis.com/oauth2/v2/userinfo');
|
||||
$aUserInfoResponse = $oGoogle->fetch('https://www.googleapis.com/oauth2/v2/userinfo');
|
||||
|
||||
if (!empty($aUserinfoResponse['result']['id']))
|
||||
if (!empty($aUserInfoResponse['result']['id']))
|
||||
{
|
||||
if ($bLogin)
|
||||
{
|
||||
$sUserData = $this->oActions->StorageProvider()->Get(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
||||
$this->GoogleUserLoginStorageKey($oGoogle, $aUserinfoResponse['result']['id'])
|
||||
$this->GoogleUserLoginStorageKey($oGoogle, $aUserInfoResponse['result']['id'])
|
||||
);
|
||||
|
||||
$aUserData = \RainLoop\Utils::DecodeKeyValues($sUserData);
|
||||
|
|
@ -359,21 +213,28 @@ class Social
|
|||
if ($oAccount)
|
||||
{
|
||||
$aUserData = array(
|
||||
'ID' => $aUserInfoResponse['result']['id'],
|
||||
'Email' => $oAccount->Email(),
|
||||
'Password' => $oAccount->Password()
|
||||
);
|
||||
|
||||
$sSocialName = !empty($aUserinfoResponse['result']['name']) ? $aUserinfoResponse['result']['name'] : '';
|
||||
$sSocialName .= !empty($aUserinfoResponse['result']['email']) ? ' ('.$aUserinfoResponse['result']['email'].')' : '';
|
||||
$sSocialName = !empty($aUserInfoResponse['result']['name']) ? $aUserInfoResponse['result']['name'] : '';
|
||||
$sSocialName .= !empty($aUserInfoResponse['result']['email']) ? ' ('.$aUserInfoResponse['result']['email'].')' : '';
|
||||
$sSocialName = \trim($sSocialName);
|
||||
|
||||
$oSettings = $this->oActions->SettingsProvider()->Load($oAccount);
|
||||
|
||||
$oSettings->SetConf('GoogleAccessToken', \RainLoop\Utils::EncodeKeyValues(array(
|
||||
'id' => $aUserInfoResponse['result']['id']
|
||||
)));
|
||||
|
||||
$oSettings->SetConf('GoogleSocialName', $sSocialName);
|
||||
|
||||
$this->oActions->SettingsProvider()->Save($oAccount, $oSettings);
|
||||
|
||||
$this->oActions->StorageProvider()->Put(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
||||
$this->GoogleUserLoginStorageKey($oGoogle, $aUserinfoResponse['result']['id']),
|
||||
$this->GoogleUserLoginStorageKey($oGoogle, $aUserInfoResponse['result']['id']),
|
||||
\RainLoop\Utils::EncodeKeyValues($aUserData));
|
||||
|
||||
$iErrorCode = 0;
|
||||
|
|
@ -577,9 +438,7 @@ class Social
|
|||
|
||||
if (200 === $iCode && isset($oTwitter->response['response']))
|
||||
{
|
||||
$this->oActions->Logger()->WriteDump($oTwitter->response['response']);
|
||||
$aAccessToken = $oTwitter->extract_params($oTwitter->response['response']);
|
||||
$this->oActions->Logger()->WriteDump($aAccessToken);
|
||||
if ($aAccessToken && isset($aAccessToken['oauth_token']) && !empty($aAccessToken['user_id']))
|
||||
{
|
||||
$oTwitter->config['user_token'] = $aAccessToken['oauth_token'];
|
||||
|
|
|
|||
719
vendors/buzz/buzz.js
vendored
719
vendors/buzz/buzz.js
vendored
|
|
@ -1,719 +0,0 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
// Buzz, a Javascript HTML5 Audio library
|
||||
// v1.1.8 - Built 2015-01-12 11:08
|
||||
// Licensed under the MIT license.
|
||||
// http://buzz.jaysalvat.com/
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright (C) 2010-2015 Jay Salvat
|
||||
// http://jaysalvat.com/
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
(function(context, factory) {
|
||||
"use strict";
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
module.exports = factory();
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define([], factory);
|
||||
} else {
|
||||
context.buzz = factory();
|
||||
}
|
||||
})(this, function() {
|
||||
"use strict";
|
||||
var AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||
var buzz = {
|
||||
audioCtx: window.AudioContext ? new AudioContext() : null,
|
||||
defaults: {
|
||||
autoplay: false,
|
||||
duration: 5e3,
|
||||
formats: [],
|
||||
loop: false,
|
||||
placeholder: "--",
|
||||
preload: "metadata",
|
||||
volume: 80,
|
||||
webAudioApi: false,
|
||||
document: window.document
|
||||
},
|
||||
types: {
|
||||
mp3: "audio/mpeg",
|
||||
ogg: "audio/ogg",
|
||||
wav: "audio/wav",
|
||||
aac: "audio/aac",
|
||||
m4a: "audio/x-m4a"
|
||||
},
|
||||
sounds: [],
|
||||
el: document.createElement("audio"),
|
||||
sound: function(src, options) {
|
||||
options = options || {};
|
||||
var doc = options.document || buzz.defaults.document;
|
||||
var pid = 0, events = [], eventsOnce = {}, supported = buzz.isSupported();
|
||||
this.load = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound.load();
|
||||
return this;
|
||||
};
|
||||
this.play = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound.play();
|
||||
return this;
|
||||
};
|
||||
this.togglePlay = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
if (this.sound.paused) {
|
||||
this.sound.play();
|
||||
} else {
|
||||
this.sound.pause();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
this.pause = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound.pause();
|
||||
return this;
|
||||
};
|
||||
this.isPaused = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return this.sound.paused;
|
||||
};
|
||||
this.stop = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.setTime(0);
|
||||
this.sound.pause();
|
||||
return this;
|
||||
};
|
||||
this.isEnded = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return this.sound.ended;
|
||||
};
|
||||
this.loop = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound.loop = "loop";
|
||||
this.bind("ended.buzzloop", function() {
|
||||
this.currentTime = 0;
|
||||
this.play();
|
||||
});
|
||||
return this;
|
||||
};
|
||||
this.unloop = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound.removeAttribute("loop");
|
||||
this.unbind("ended.buzzloop");
|
||||
return this;
|
||||
};
|
||||
this.mute = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound.muted = true;
|
||||
return this;
|
||||
};
|
||||
this.unmute = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound.muted = false;
|
||||
return this;
|
||||
};
|
||||
this.toggleMute = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound.muted = !this.sound.muted;
|
||||
return this;
|
||||
};
|
||||
this.isMuted = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return this.sound.muted;
|
||||
};
|
||||
this.setVolume = function(volume) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
if (volume < 0) {
|
||||
volume = 0;
|
||||
}
|
||||
if (volume > 100) {
|
||||
volume = 100;
|
||||
}
|
||||
this.volume = volume;
|
||||
this.sound.volume = volume / 100;
|
||||
return this;
|
||||
};
|
||||
this.getVolume = function() {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
return this.volume;
|
||||
};
|
||||
this.increaseVolume = function(value) {
|
||||
return this.setVolume(this.volume + (value || 1));
|
||||
};
|
||||
this.decreaseVolume = function(value) {
|
||||
return this.setVolume(this.volume - (value || 1));
|
||||
};
|
||||
this.setTime = function(time) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
var set = true;
|
||||
this.whenReady(function() {
|
||||
if (set === true) {
|
||||
set = false;
|
||||
this.sound.currentTime = time;
|
||||
}
|
||||
});
|
||||
return this;
|
||||
};
|
||||
this.getTime = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
var time = Math.round(this.sound.currentTime * 100) / 100;
|
||||
return isNaN(time) ? buzz.defaults.placeholder : time;
|
||||
};
|
||||
this.setPercent = function(percent) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
return this.setTime(buzz.fromPercent(percent, this.sound.duration));
|
||||
};
|
||||
this.getPercent = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
var percent = Math.round(buzz.toPercent(this.sound.currentTime, this.sound.duration));
|
||||
return isNaN(percent) ? buzz.defaults.placeholder : percent;
|
||||
};
|
||||
this.setSpeed = function(duration) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound.playbackRate = duration;
|
||||
return this;
|
||||
};
|
||||
this.getSpeed = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return this.sound.playbackRate;
|
||||
};
|
||||
this.getDuration = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
var duration = Math.round(this.sound.duration * 100) / 100;
|
||||
return isNaN(duration) ? buzz.defaults.placeholder : duration;
|
||||
};
|
||||
this.getPlayed = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return timerangeToArray(this.sound.played);
|
||||
};
|
||||
this.getBuffered = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return timerangeToArray(this.sound.buffered);
|
||||
};
|
||||
this.getSeekable = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return timerangeToArray(this.sound.seekable);
|
||||
};
|
||||
this.getErrorCode = function() {
|
||||
if (supported && this.sound.error) {
|
||||
return this.sound.error.code;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
this.getErrorMessage = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
switch (this.getErrorCode()) {
|
||||
case 1:
|
||||
return "MEDIA_ERR_ABORTED";
|
||||
|
||||
case 2:
|
||||
return "MEDIA_ERR_NETWORK";
|
||||
|
||||
case 3:
|
||||
return "MEDIA_ERR_DECODE";
|
||||
|
||||
case 4:
|
||||
return "MEDIA_ERR_SRC_NOT_SUPPORTED";
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.getStateCode = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return this.sound.readyState;
|
||||
};
|
||||
this.getStateMessage = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
switch (this.getStateCode()) {
|
||||
case 0:
|
||||
return "HAVE_NOTHING";
|
||||
|
||||
case 1:
|
||||
return "HAVE_METADATA";
|
||||
|
||||
case 2:
|
||||
return "HAVE_CURRENT_DATA";
|
||||
|
||||
case 3:
|
||||
return "HAVE_FUTURE_DATA";
|
||||
|
||||
case 4:
|
||||
return "HAVE_ENOUGH_DATA";
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.getNetworkStateCode = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return this.sound.networkState;
|
||||
};
|
||||
this.getNetworkStateMessage = function() {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
switch (this.getNetworkStateCode()) {
|
||||
case 0:
|
||||
return "NETWORK_EMPTY";
|
||||
|
||||
case 1:
|
||||
return "NETWORK_IDLE";
|
||||
|
||||
case 2:
|
||||
return "NETWORK_LOADING";
|
||||
|
||||
case 3:
|
||||
return "NETWORK_NO_SOURCE";
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.set = function(key, value) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.sound[key] = value;
|
||||
return this;
|
||||
};
|
||||
this.get = function(key) {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
return key ? this.sound[key] : this.sound;
|
||||
};
|
||||
this.bind = function(types, func) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
types = types.split(" ");
|
||||
var self = this, efunc = function(e) {
|
||||
func.call(self, e);
|
||||
};
|
||||
for (var t = 0; t < types.length; t++) {
|
||||
var type = types[t], idx = type;
|
||||
type = idx.split(".")[0];
|
||||
events.push({
|
||||
idx: idx,
|
||||
func: efunc
|
||||
});
|
||||
this.sound.addEventListener(type, efunc, true);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
this.unbind = function(types) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
types = types.split(" ");
|
||||
for (var t = 0; t < types.length; t++) {
|
||||
var idx = types[t], type = idx.split(".")[0];
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
var namespace = events[i].idx.split(".");
|
||||
if (events[i].idx === idx || namespace[1] && namespace[1] === idx.replace(".", "")) {
|
||||
this.sound.removeEventListener(type, events[i].func, true);
|
||||
events.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
this.bindOnce = function(type, func) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
var self = this;
|
||||
eventsOnce[pid++] = false;
|
||||
this.bind(type + "." + pid, function() {
|
||||
if (!eventsOnce[pid]) {
|
||||
eventsOnce[pid] = true;
|
||||
func.call(self);
|
||||
}
|
||||
self.unbind(type + "." + pid);
|
||||
});
|
||||
return this;
|
||||
};
|
||||
this.trigger = function(types, detail) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
types = types.split(" ");
|
||||
for (var t = 0; t < types.length; t++) {
|
||||
var idx = types[t];
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
var eventType = events[i].idx.split(".");
|
||||
if (events[i].idx === idx || eventType[0] && eventType[0] === idx.replace(".", "")) {
|
||||
var evt = doc.createEvent("HTMLEvents");
|
||||
evt.initEvent(eventType[0], false, true);
|
||||
evt.originalEvent = detail;
|
||||
this.sound.dispatchEvent(evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
this.fadeTo = function(to, duration, callback) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
if (duration instanceof Function) {
|
||||
callback = duration;
|
||||
duration = buzz.defaults.duration;
|
||||
} else {
|
||||
duration = duration || buzz.defaults.duration;
|
||||
}
|
||||
var from = this.volume, delay = duration / Math.abs(from - to), self = this;
|
||||
this.play();
|
||||
function doFade() {
|
||||
setTimeout(function() {
|
||||
if (from < to && self.volume < to) {
|
||||
self.setVolume(self.volume += 1);
|
||||
doFade();
|
||||
} else if (from > to && self.volume > to) {
|
||||
self.setVolume(self.volume -= 1);
|
||||
doFade();
|
||||
} else if (callback instanceof Function) {
|
||||
callback.apply(self);
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
this.whenReady(function() {
|
||||
doFade();
|
||||
});
|
||||
return this;
|
||||
};
|
||||
this.fadeIn = function(duration, callback) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
return this.setVolume(0).fadeTo(100, duration, callback);
|
||||
};
|
||||
this.fadeOut = function(duration, callback) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
return this.fadeTo(0, duration, callback);
|
||||
};
|
||||
this.fadeWith = function(sound, duration) {
|
||||
if (!supported) {
|
||||
return this;
|
||||
}
|
||||
this.fadeOut(duration, function() {
|
||||
this.stop();
|
||||
});
|
||||
sound.play().fadeIn(duration);
|
||||
return this;
|
||||
};
|
||||
this.whenReady = function(func) {
|
||||
if (!supported) {
|
||||
return null;
|
||||
}
|
||||
var self = this;
|
||||
if (this.sound.readyState === 0) {
|
||||
this.bind("canplay.buzzwhenready", function() {
|
||||
func.call(self);
|
||||
});
|
||||
} else {
|
||||
func.call(self);
|
||||
}
|
||||
};
|
||||
this.addSource = function(src) {
|
||||
var self = this, source = doc.createElement("source");
|
||||
source.src = src;
|
||||
if (buzz.types[getExt(src)]) {
|
||||
source.type = buzz.types[getExt(src)];
|
||||
}
|
||||
this.sound.appendChild(source);
|
||||
source.addEventListener("error", function(e) {
|
||||
self.sound.networkState = 3;
|
||||
self.trigger("sourceerror", e);
|
||||
});
|
||||
return source;
|
||||
};
|
||||
function timerangeToArray(timeRange) {
|
||||
var array = [], length = timeRange.length - 1;
|
||||
for (var i = 0; i <= length; i++) {
|
||||
array.push({
|
||||
start: timeRange.start(i),
|
||||
end: timeRange.end(i)
|
||||
});
|
||||
}
|
||||
return array;
|
||||
}
|
||||
function getExt(filename) {
|
||||
return filename.split(".").pop();
|
||||
}
|
||||
if (supported && src) {
|
||||
for (var i in buzz.defaults) {
|
||||
if (buzz.defaults.hasOwnProperty(i)) {
|
||||
if (options[i] === undefined) {
|
||||
options[i] = buzz.defaults[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
this.sound = doc.createElement("audio");
|
||||
if (options.webAudioApi && buzz.audioCtx) {
|
||||
this.source = buzz.audioCtx.createMediaElementSource(this.sound);
|
||||
this.source.connect(buzz.audioCtx.destination);
|
||||
}
|
||||
if (src instanceof Array) {
|
||||
for (var j in src) {
|
||||
if (src.hasOwnProperty(j)) {
|
||||
this.addSource(src[j]);
|
||||
}
|
||||
}
|
||||
} else if (options.formats.length) {
|
||||
for (var k in options.formats) {
|
||||
if (options.formats.hasOwnProperty(k)) {
|
||||
this.addSource(src + "." + options.formats[k]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.addSource(src);
|
||||
}
|
||||
if (options.loop) {
|
||||
this.loop();
|
||||
}
|
||||
if (options.autoplay) {
|
||||
this.sound.autoplay = "autoplay";
|
||||
}
|
||||
if (options.preload === true) {
|
||||
this.sound.preload = "auto";
|
||||
} else if (options.preload === false) {
|
||||
this.sound.preload = "none";
|
||||
} else {
|
||||
this.sound.preload = options.preload;
|
||||
}
|
||||
this.setVolume(options.volume);
|
||||
buzz.sounds.push(this);
|
||||
}
|
||||
},
|
||||
group: function(sounds) {
|
||||
sounds = argsToArray(sounds, arguments);
|
||||
this.getSounds = function() {
|
||||
return sounds;
|
||||
};
|
||||
this.add = function(soundArray) {
|
||||
soundArray = argsToArray(soundArray, arguments);
|
||||
for (var a = 0; a < soundArray.length; a++) {
|
||||
sounds.push(soundArray[a]);
|
||||
}
|
||||
};
|
||||
this.remove = function(soundArray) {
|
||||
soundArray = argsToArray(soundArray, arguments);
|
||||
for (var a = 0; a < soundArray.length; a++) {
|
||||
for (var i = 0; i < sounds.length; i++) {
|
||||
if (sounds[i] === soundArray[a]) {
|
||||
sounds.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
this.load = function() {
|
||||
fn("load");
|
||||
return this;
|
||||
};
|
||||
this.play = function() {
|
||||
fn("play");
|
||||
return this;
|
||||
};
|
||||
this.togglePlay = function() {
|
||||
fn("togglePlay");
|
||||
return this;
|
||||
};
|
||||
this.pause = function(time) {
|
||||
fn("pause", time);
|
||||
return this;
|
||||
};
|
||||
this.stop = function() {
|
||||
fn("stop");
|
||||
return this;
|
||||
};
|
||||
this.mute = function() {
|
||||
fn("mute");
|
||||
return this;
|
||||
};
|
||||
this.unmute = function() {
|
||||
fn("unmute");
|
||||
return this;
|
||||
};
|
||||
this.toggleMute = function() {
|
||||
fn("toggleMute");
|
||||
return this;
|
||||
};
|
||||
this.setVolume = function(volume) {
|
||||
fn("setVolume", volume);
|
||||
return this;
|
||||
};
|
||||
this.increaseVolume = function(value) {
|
||||
fn("increaseVolume", value);
|
||||
return this;
|
||||
};
|
||||
this.decreaseVolume = function(value) {
|
||||
fn("decreaseVolume", value);
|
||||
return this;
|
||||
};
|
||||
this.loop = function() {
|
||||
fn("loop");
|
||||
return this;
|
||||
};
|
||||
this.unloop = function() {
|
||||
fn("unloop");
|
||||
return this;
|
||||
};
|
||||
this.setSpeed = function(speed) {
|
||||
fn("setSpeed", speed);
|
||||
return this;
|
||||
};
|
||||
this.setTime = function(time) {
|
||||
fn("setTime", time);
|
||||
return this;
|
||||
};
|
||||
this.set = function(key, value) {
|
||||
fn("set", key, value);
|
||||
return this;
|
||||
};
|
||||
this.bind = function(type, func) {
|
||||
fn("bind", type, func);
|
||||
return this;
|
||||
};
|
||||
this.unbind = function(type) {
|
||||
fn("unbind", type);
|
||||
return this;
|
||||
};
|
||||
this.bindOnce = function(type, func) {
|
||||
fn("bindOnce", type, func);
|
||||
return this;
|
||||
};
|
||||
this.trigger = function(type) {
|
||||
fn("trigger", type);
|
||||
return this;
|
||||
};
|
||||
this.fade = function(from, to, duration, callback) {
|
||||
fn("fade", from, to, duration, callback);
|
||||
return this;
|
||||
};
|
||||
this.fadeIn = function(duration, callback) {
|
||||
fn("fadeIn", duration, callback);
|
||||
return this;
|
||||
};
|
||||
this.fadeOut = function(duration, callback) {
|
||||
fn("fadeOut", duration, callback);
|
||||
return this;
|
||||
};
|
||||
function fn() {
|
||||
var args = argsToArray(null, arguments), func = args.shift();
|
||||
for (var i = 0; i < sounds.length; i++) {
|
||||
sounds[i][func].apply(sounds[i], args);
|
||||
}
|
||||
}
|
||||
function argsToArray(array, args) {
|
||||
return array instanceof Array ? array : Array.prototype.slice.call(args);
|
||||
}
|
||||
},
|
||||
all: function() {
|
||||
return new buzz.group(buzz.sounds);
|
||||
},
|
||||
isSupported: function() {
|
||||
return !!buzz.el.canPlayType;
|
||||
},
|
||||
isOGGSupported: function() {
|
||||
return !!buzz.el.canPlayType && buzz.el.canPlayType('audio/ogg; codecs="vorbis"');
|
||||
},
|
||||
isWAVSupported: function() {
|
||||
return !!buzz.el.canPlayType && buzz.el.canPlayType('audio/wav; codecs="1"');
|
||||
},
|
||||
isMP3Supported: function() {
|
||||
return !!buzz.el.canPlayType && buzz.el.canPlayType("audio/mpeg;");
|
||||
},
|
||||
isAACSupported: function() {
|
||||
return !!buzz.el.canPlayType && (buzz.el.canPlayType("audio/x-m4a;") || buzz.el.canPlayType("audio/aac;"));
|
||||
},
|
||||
toTimer: function(time, withHours) {
|
||||
var h, m, s;
|
||||
h = Math.floor(time / 3600);
|
||||
h = isNaN(h) ? "--" : h >= 10 ? h : "0" + h;
|
||||
m = withHours ? Math.floor(time / 60 % 60) : Math.floor(time / 60);
|
||||
m = isNaN(m) ? "--" : m >= 10 ? m : "0" + m;
|
||||
s = Math.floor(time % 60);
|
||||
s = isNaN(s) ? "--" : s >= 10 ? s : "0" + s;
|
||||
return withHours ? h + ":" + m + ":" + s : m + ":" + s;
|
||||
},
|
||||
fromTimer: function(time) {
|
||||
var splits = time.toString().split(":");
|
||||
if (splits && splits.length === 3) {
|
||||
time = parseInt(splits[0], 10) * 3600 + parseInt(splits[1], 10) * 60 + parseInt(splits[2], 10);
|
||||
}
|
||||
if (splits && splits.length === 2) {
|
||||
time = parseInt(splits[0], 10) * 60 + parseInt(splits[1], 10);
|
||||
}
|
||||
return time;
|
||||
},
|
||||
toPercent: function(value, total, decimal) {
|
||||
var r = Math.pow(10, decimal || 0);
|
||||
return Math.round(value * 100 / total * r) / r;
|
||||
},
|
||||
fromPercent: function(percent, total, decimal) {
|
||||
var r = Math.pow(10, decimal || 0);
|
||||
return Math.round(total / 100 * percent * r) / r;
|
||||
}
|
||||
};
|
||||
return buzz;
|
||||
});
|
||||
11
vendors/buzz/buzz.min.js
vendored
11
vendors/buzz/buzz.min.js
vendored
File diff suppressed because one or more lines are too long
21
vendors/is.js/LICENSE
vendored
21
vendors/is.js/LICENSE
vendored
|
|
@ -1,21 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2015 Aras Atasaygin
|
||||
|
||||
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.
|
||||
2327
vendors/is.js/README.md
vendored
2327
vendors/is.js/README.md
vendored
File diff suppressed because it is too large
Load diff
35
vendors/is.js/bower.json
vendored
35
vendors/is.js/bower.json
vendored
|
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
"name": "is_js",
|
||||
"main": "is.js",
|
||||
"version": "0.6.0",
|
||||
"homepage": "http://arasatasaygin.github.io/is.js/",
|
||||
"authors": [
|
||||
"arasatasaygin <arasatasaygin@gmail.com>"
|
||||
],
|
||||
"description": "micro check library",
|
||||
"moduleType": [
|
||||
"amd",
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"type",
|
||||
"presence",
|
||||
"regexp",
|
||||
"string",
|
||||
"arithmetic",
|
||||
"object",
|
||||
"array",
|
||||
"environment",
|
||||
"time",
|
||||
"configuration"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
818
vendors/is.js/is.js
vendored
818
vendors/is.js/is.js
vendored
|
|
@ -1,818 +0,0 @@
|
|||
// is.js 0.6.0
|
||||
// Author: Aras Atasaygin
|
||||
|
||||
// AMD with global, Node, or global
|
||||
;(function(root, factory) {
|
||||
if(typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['is'], function(is) {
|
||||
// Also create a global in case some scripts
|
||||
// that are loaded still are looking for
|
||||
// a global even when an AMD loader is in use.
|
||||
return (root.is = factory(is));
|
||||
});
|
||||
} else if(typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like enviroments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory(require('is_js'));
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.is = factory(root.is);
|
||||
}
|
||||
}(this, function(is) {
|
||||
|
||||
// Baseline
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
var root = this;
|
||||
var previousIs = root.is;
|
||||
|
||||
// define 'is' object and current version
|
||||
is = {};
|
||||
is.VERSION = '0.6.0';
|
||||
|
||||
// define interfaces
|
||||
is.not = {};
|
||||
is.all = {};
|
||||
is.any = {};
|
||||
|
||||
// cache some methods to call later on
|
||||
var toString = Object.prototype.toString;
|
||||
var arraySlice = Array.prototype.slice;
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
// helper function which reverses the sense of predicate result
|
||||
function not(func) {
|
||||
return function() {
|
||||
return !func.apply(null, arraySlice.call(arguments));
|
||||
};
|
||||
}
|
||||
|
||||
// helper function which call predicate function per parameter and return true if all pass
|
||||
function all(func) {
|
||||
return function() {
|
||||
var parameters = arraySlice.call(arguments);
|
||||
var length = parameters.length;
|
||||
if(length === 1 && is.array(parameters[0])) { // support array
|
||||
parameters = parameters[0];
|
||||
length = parameters.length;
|
||||
}
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (!func.call(null, parameters[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
// helper function which call predicate function per parameter and return true if any pass
|
||||
function any(func) {
|
||||
return function() {
|
||||
var parameters = arraySlice.call(arguments);
|
||||
var length = parameters.length;
|
||||
if(length === 1 && is.array(parameters[0])) { // support array
|
||||
parameters = parameters[0];
|
||||
length = parameters.length;
|
||||
}
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (func.call(null, parameters[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
// Type checks
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// is a given value Arguments?
|
||||
is.arguments = function(value) { // fallback check is for IE
|
||||
return is.not.null(value) && (toString.call(value) === '[object Arguments]' || (typeof value === 'object' && 'callee' in value));
|
||||
};
|
||||
|
||||
// is a given value Array?
|
||||
is.array = Array.isArray || function(value) { // check native isArray first
|
||||
return toString.call(value) === '[object Array]';
|
||||
};
|
||||
|
||||
// is a given value Boolean?
|
||||
is.boolean = function(value) {
|
||||
return value === true || value === false || toString.call(value) === '[object Boolean]';
|
||||
};
|
||||
|
||||
// is a given value Date Object?
|
||||
is.date = function(value) {
|
||||
return toString.call(value) === '[object Date]';
|
||||
};
|
||||
|
||||
// is a given value Error object?
|
||||
is.error = function(value) {
|
||||
return toString.call(value) === '[object Error]';
|
||||
};
|
||||
|
||||
// is a given value function?
|
||||
is.function = function(value) { // fallback check is for IE
|
||||
return toString.call(value) === '[object Function]' || typeof value === 'function';
|
||||
};
|
||||
|
||||
// is a given value NaN?
|
||||
is.nan = function(value) { // NaN is number :) Also it is the only value which does not equal itself
|
||||
return value !== value;
|
||||
};
|
||||
|
||||
// is a given value null?
|
||||
is.null = function(value) {
|
||||
return value === null || toString.call(value) === '[object Null]';
|
||||
};
|
||||
|
||||
// is a given value number?
|
||||
is.number = function(value) {
|
||||
return toString.call(value) === '[object Number]';
|
||||
};
|
||||
|
||||
// is a given value object?
|
||||
is.object = function(value) {
|
||||
var type = typeof value;
|
||||
return type === 'function' || type === 'object' && !!value;
|
||||
};
|
||||
|
||||
// is given value a pure JSON object?
|
||||
is.json = function(value) {
|
||||
return toString.call(value) === '[object Object]';
|
||||
};
|
||||
|
||||
// is a given value RegExp?
|
||||
is.regexp = function(value) {
|
||||
return toString.call(value) === '[object RegExp]';
|
||||
};
|
||||
|
||||
// are given values same type?
|
||||
// prevent NaN, Number same type check
|
||||
is.sameType = function(value1, value2) {
|
||||
if(is.nan(value1) || is.nan(value2)) {
|
||||
return is.nan(value1) === is.nan(value2);
|
||||
}
|
||||
return toString.call(value1) === toString.call(value2);
|
||||
};
|
||||
// sameType method does not support 'all' and 'any' interfaces
|
||||
is.sameType.api = ['not'];
|
||||
|
||||
// is a given value String?
|
||||
is.string = function(value) {
|
||||
return toString.call(value) === '[object String]';
|
||||
};
|
||||
|
||||
// is a given value Char?
|
||||
is.char = function(value) {
|
||||
return is.string(value) && value.length === 1;
|
||||
};
|
||||
|
||||
// is a given value undefined?
|
||||
is.undefined = function(value) {
|
||||
return value === void 0;
|
||||
};
|
||||
|
||||
// Presence checks
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
//is a given value empty? Objects, arrays, strings
|
||||
is.empty = function(value) {
|
||||
if(is.object(value)){
|
||||
var num = Object.getOwnPropertyNames(value).length;
|
||||
if(num === 0 || (num === 1 && is.array(value)) || (num === 2 && is.arguments(value))){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return value === '';
|
||||
}
|
||||
};
|
||||
|
||||
// is a given value existy?
|
||||
is.existy = function(value) {
|
||||
return value !== null && value !== undefined;
|
||||
};
|
||||
|
||||
// is a given value truthy?
|
||||
is.truthy = function(value) {
|
||||
return is.existy(value) && value !== false && is.not.nan(value) && value !== "" && value !== 0;
|
||||
};
|
||||
|
||||
// is a given value falsy?
|
||||
is.falsy = not(is.truthy);
|
||||
|
||||
// is a given value space?
|
||||
// horizantal tab: 9, line feed: 10, vertical tab: 11, form feed: 12, carriage return: 13, space: 32
|
||||
is.space = function(value) {
|
||||
if(is.char(value)) {
|
||||
var characterCode = value.charCodeAt(0);
|
||||
return (characterCode > 8 && characterCode < 14) || characterCode === 32;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Arithmetic checks
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// are given values equal? supports numbers, strings, regexps, booleans
|
||||
// TODO: Add object and array support
|
||||
is.equal = function(value1, value2) {
|
||||
// check 0 and -0 equity with Infinity and -Infinity
|
||||
if(is.all.number(value1, value2)) {
|
||||
return value1 === value2 && 1 / value1 === 1 / value2;
|
||||
}
|
||||
// check regexps as strings too
|
||||
if(is.all.string(value1, value2) || is.all.regexp(value1, value2)) {
|
||||
return '' + value1 === '' + value2;
|
||||
}
|
||||
if(is.all.boolean(value1, value2)) {
|
||||
return value1 === value2;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
// equal method does not support 'all' and 'any' interfaces
|
||||
is.equal.api = ['not'];
|
||||
|
||||
// is a given number even?
|
||||
is.even = function(numb) {
|
||||
return is.number(numb) && numb % 2 === 0;
|
||||
};
|
||||
|
||||
// is a given number odd?
|
||||
is.odd = function(numb) {
|
||||
return is.number(numb) && numb % 2 !== 0;
|
||||
};
|
||||
|
||||
// is a given number positive?
|
||||
is.positive = function(numb) {
|
||||
return is.number(numb) && numb > 0;
|
||||
};
|
||||
|
||||
// is a given number negative?
|
||||
is.negative = function(numb) {
|
||||
return is.number(numb) && numb < 0;
|
||||
};
|
||||
|
||||
// is a given number above minimum parameter?
|
||||
is.above = function(numb, min) {
|
||||
return is.all.number(numb, min) && numb > min;
|
||||
};
|
||||
// above method does not support 'all' and 'any' interfaces
|
||||
is.above.api = ['not'];
|
||||
|
||||
// is a given number above maximum parameter?
|
||||
is.under = function(numb, max) {
|
||||
return is.all.number(numb, max) && numb < max;
|
||||
};
|
||||
// least method does not support 'all' and 'any' interfaces
|
||||
is.under.api = ['not'];
|
||||
|
||||
// is a given number within minimum and maximum parameters?
|
||||
is.within = function(numb, min, max) {
|
||||
return is.all.number(numb, min, max) && numb > min && numb < max;
|
||||
};
|
||||
// within method does not support 'all' and 'any' interfaces
|
||||
is.within.api = ['not'];
|
||||
|
||||
// is a given number decimal?
|
||||
is.decimal = function(numb) {
|
||||
return is.number(numb) && numb % 1 !== 0;
|
||||
};
|
||||
|
||||
// is a given number integer?
|
||||
is.integer = function(numb) {
|
||||
return is.number(numb) && numb % 1 === 0;
|
||||
};
|
||||
|
||||
// is a given number finite?
|
||||
is.finite = isFinite || function(numb) {
|
||||
return numb !== Infinity && numb !== -Infinity && is.not.nan(numb);
|
||||
};
|
||||
|
||||
// is a given number infinite?
|
||||
is.infinite = not(is.finite);
|
||||
|
||||
// Regexp checks
|
||||
/* -------------------------------------------------------------------------- */
|
||||
// Steven Levithan, Jan Goyvaerts: Regular Expressions Cookbook
|
||||
// Scott Gonzalez: Email address validation
|
||||
|
||||
// eppPhone match extensible provisioning protocol format
|
||||
// nanpPhone match north american number plan format
|
||||
// dateString match m/d/yy and mm/dd/yyyy, allowing any combination of one or two digits for the day and month, and two or four digits for the year
|
||||
// time match hours, minutes, and seconds, 24-hour clock
|
||||
var regexps = {
|
||||
url: /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/,
|
||||
email: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,
|
||||
creditCard: /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/,
|
||||
alphaNumeric: /^[A-Za-z0-9]+$/,
|
||||
timeString: /^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$/,
|
||||
dateString: /^(1[0-2]|0?[1-9])\/(3[01]|[12][0-9]|0?[1-9])\/(?:[0-9]{2})?[0-9]{2}$/,
|
||||
usZipCode: /^[0-9]{5}(?:-[0-9]{4})?$/,
|
||||
caPostalCode: /^(?!.*[DFIOQU])[A-VXY][0-9][A-Z]\s?[0-9][A-Z][0-9]$/,
|
||||
ukPostCode: /^[A-Z]{1,2}[0-9RCHNQ][0-9A-Z]?\s?[0-9][ABD-HJLNP-UW-Z]{2}$|^[A-Z]{2}-?[0-9]{4}$/,
|
||||
nanpPhone: /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/,
|
||||
eppPhone: /^\+[0-9]{1,3}\.[0-9]{4,14}(?:x.+)?$/,
|
||||
socialSecurityNumber: /^(?!000|666)[0-8][0-9]{2}-(?!00)[0-9]{2}-(?!0000)[0-9]{4}$/,
|
||||
affirmative: /^(?:1|t(?:rue)?|y(?:es)?|ok(?:ay)?)$/,
|
||||
hexadecimal: /^[0-9a-fA-F]+$/,
|
||||
hexColor: /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,
|
||||
ipv4: /^(?:(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/,
|
||||
ipv6: /^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$|^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,
|
||||
ip: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$|^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/
|
||||
};
|
||||
|
||||
// create regexp checks methods from 'regexp' object
|
||||
for(var regexp in regexps) {
|
||||
if(regexps.hasOwnProperty(regexp)) {
|
||||
regexpCheck(regexp, regexps);
|
||||
}
|
||||
}
|
||||
|
||||
function regexpCheck(regexp, regexps) {
|
||||
is[regexp] = function(value) {
|
||||
return regexps[regexp].test(value);
|
||||
};
|
||||
}
|
||||
|
||||
// String checks
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// is a given string include parameter substring?
|
||||
is.include = String.prototype.includes || function(str, substr) {
|
||||
return str.indexOf(substr) > -1;
|
||||
};
|
||||
// include method does not support 'all' and 'any' interfaces
|
||||
is.include.api = ['not'];
|
||||
|
||||
// is a given string all uppercase?
|
||||
is.upperCase = function(str) {
|
||||
return is.string(str) && str === str.toUpperCase();
|
||||
};
|
||||
|
||||
// is a given string all lowercase?
|
||||
is.lowerCase = function(str) {
|
||||
return is.string(str) && str === str.toLowerCase();
|
||||
};
|
||||
|
||||
// is string start with a given startWith parameter?
|
||||
is.startWith = function(str, startWith) {
|
||||
return is.string(str) && str.indexOf(startWith) === 0;
|
||||
};
|
||||
// startWith method does not support 'all' and 'any' interfaces
|
||||
is.startWith.api = ['not'];
|
||||
|
||||
// is string end with a given endWith parameter?
|
||||
is.endWith = function(str, endWith) {
|
||||
return is.string(str) && str.indexOf(endWith) > -1 && str.indexOf(endWith) === str.length - endWith.length;
|
||||
};
|
||||
// endWith method does not support 'all' and 'any' interfaces
|
||||
is.endWith.api = ['not'];
|
||||
|
||||
// is a given string or sentence capitalized?
|
||||
is.capitalized = function(str) {
|
||||
if(is.not.string(str)) {
|
||||
return false;
|
||||
}
|
||||
var words = str.split(' ');
|
||||
var capitalized = [];
|
||||
for(var i = 0; i < words.length; i++) {
|
||||
capitalized.push(words[i][0] === words[i][0].toUpperCase());
|
||||
}
|
||||
return is.all.truthy.apply(null, capitalized);
|
||||
};
|
||||
|
||||
// is a given string palindrome?
|
||||
is.palindrome = function(str) {
|
||||
return is.string(str) && str == str.split('').reverse().join('');
|
||||
};
|
||||
|
||||
// Time checks
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
var days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
||||
var months = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
|
||||
|
||||
// is a given date indicate today?
|
||||
is.today = function(obj) {
|
||||
var now = new Date();
|
||||
var todayString = now.toDateString();
|
||||
return is.date(obj) && obj.toDateString() === todayString;
|
||||
};
|
||||
|
||||
// is a given date indicate yesterday?
|
||||
is.yesterday = function(obj) {
|
||||
var now = new Date();
|
||||
var yesterdayString = new Date(now.setDate(now.getDate() - 1)).toDateString();
|
||||
return is.date(obj) && obj.toDateString() === yesterdayString;
|
||||
};
|
||||
|
||||
// is a given date indicate tomorrow?
|
||||
is.tomorrow = function(obj) {
|
||||
var now = new Date();
|
||||
var tomorrowString = new Date(now.setDate(now.getDate() + 1)).toDateString();
|
||||
return is.date(obj) && obj.toDateString() === tomorrowString;
|
||||
};
|
||||
|
||||
// is a given date past?
|
||||
is.past = function(obj) {
|
||||
var now = new Date();
|
||||
return is.date(obj) && obj.getTime() < now.getTime();
|
||||
};
|
||||
|
||||
// is a given date future?
|
||||
is.future = not(is.past);
|
||||
|
||||
// is a given dates day equal given dayString parameter?
|
||||
is.day = function(obj, dayString) {
|
||||
return is.date(obj) && dayString.toLowerCase() === days[obj.getDay()];
|
||||
};
|
||||
// day method does not support 'all' and 'any' interfaces
|
||||
is.day.api = ['not'];
|
||||
|
||||
// is a given dates month equal given monthString parameter?
|
||||
is.month = function(obj, monthString) {
|
||||
return is.date(obj) && monthString.toLowerCase() === months[obj.getMonth()];
|
||||
};
|
||||
// month method does not support 'all' and 'any' interfaces
|
||||
is.month.api = ['not'];
|
||||
|
||||
// is a given dates year equal given year parameter?
|
||||
is.year = function(obj, year) {
|
||||
return is.date(obj) && is.number(year) && year === obj.getFullYear();
|
||||
};
|
||||
// year method does not support 'all' and 'any' interfaces
|
||||
is.year.api = ['not'];
|
||||
|
||||
// is the given year a leap year?
|
||||
is.leapYear = function(year) {
|
||||
return is.number(year) && ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0);
|
||||
};
|
||||
|
||||
// is a given date weekend?
|
||||
// 6: Saturday, 0: Sunday
|
||||
is.weekend = function(obj) {
|
||||
return is.date(obj) && (obj.getDay() === 6 || obj.getDay() === 0);
|
||||
};
|
||||
|
||||
// is a given date weekday?
|
||||
is.weekday = not(is.weekend);
|
||||
|
||||
// is date within given range?
|
||||
is.inDateRange = function(obj, startObj, endObj) {
|
||||
if(is.not.date(obj) || is.not.date(startObj) || is.not.date(endObj)) {
|
||||
return false;
|
||||
}
|
||||
var givenDate = obj.getTime();
|
||||
var start = startObj.getTime();
|
||||
var end = endObj.getTime();
|
||||
return givenDate > start && givenDate < end;
|
||||
};
|
||||
// inDateRange method does not support 'all' and 'any' interfaces
|
||||
is.inDateRange.api = ['not'];
|
||||
|
||||
// is a given date in last week range?
|
||||
is.inLastWeek = function(obj) {
|
||||
return is.inDateRange(obj, new Date(new Date().setDate(new Date().getDate() - 7)), new Date());
|
||||
};
|
||||
|
||||
// is a given date in last month range?
|
||||
is.inLastMonth = function(obj) {
|
||||
return is.inDateRange(obj, new Date(new Date().setMonth(new Date().getMonth() - 1)), new Date());
|
||||
};
|
||||
|
||||
// is a given date in last year range?
|
||||
is.inLastYear = function(obj) {
|
||||
return is.inDateRange(obj, new Date(new Date().setFullYear(new Date().getFullYear() - 1)), new Date());
|
||||
};
|
||||
|
||||
// is a given date in next week range?
|
||||
is.inNextWeek = function(obj) {
|
||||
return is.inDateRange(obj, new Date(), new Date(new Date().setDate(new Date().getDate() + 7)));
|
||||
};
|
||||
|
||||
// is a given date in next month range?
|
||||
is.inNextMonth = function(obj) {
|
||||
return is.inDateRange(obj, new Date(), new Date(new Date().setMonth(new Date().getMonth() + 1)));
|
||||
};
|
||||
|
||||
// is a given date in next year range?
|
||||
is.inNextYear = function(obj) {
|
||||
return is.inDateRange(obj, new Date(), new Date(new Date().setFullYear(new Date().getFullYear() + 1)));
|
||||
};
|
||||
|
||||
// is a given date in the parameter quarter?
|
||||
is.quarterOfYear = function(obj, quarterNumber) {
|
||||
return is.date(obj) && is.number(quarterNumber) && quarterNumber === Math.floor((obj.getMonth() + 3) / 3);
|
||||
};
|
||||
// quarterOfYear method does not support 'all' and 'any' interfaces
|
||||
is.quarterOfYear.api = ['not'];
|
||||
|
||||
// is a given date in daylight saving time?
|
||||
is.dayLightSavingTime = function(obj) {
|
||||
var january = new Date(obj.getFullYear(), 0, 1);
|
||||
var july = new Date(obj.getFullYear(), 6, 1);
|
||||
var stdTimezoneOffset = Math.max(january.getTimezoneOffset(), july.getTimezoneOffset());
|
||||
return obj.getTimezoneOffset() < stdTimezoneOffset;
|
||||
};
|
||||
|
||||
// Environment checks
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// check if library is used as a Node.js module
|
||||
if(typeof window !== 'undefined') {
|
||||
|
||||
// store navigator properties to use later
|
||||
var userAgent = 'navigator' in window && 'userAgent' in navigator && navigator.userAgent.toLowerCase() || '';
|
||||
var vendor = 'navigator' in window && 'vendor' in navigator && navigator.vendor.toLowerCase() || '';
|
||||
var appVersion = 'navigator' in window && 'appVersion' in navigator && navigator.appVersion.toLowerCase() || '';
|
||||
|
||||
// is current browser chrome?
|
||||
is.chrome = function() {
|
||||
return /chrome|chromium/i.test(userAgent) && /google inc/.test(vendor);
|
||||
};
|
||||
// chrome method does not support 'all' and 'any' interfaces
|
||||
is.chrome.api = ['not'];
|
||||
|
||||
// is current browser firefox?
|
||||
is.firefox = function() {
|
||||
return /firefox/i.test(userAgent);
|
||||
};
|
||||
// firefox method does not support 'all' and 'any' interfaces
|
||||
is.firefox.api = ['not'];
|
||||
|
||||
// is current browser internet explorer?
|
||||
// parameter is optional
|
||||
is.ie = function(version) {
|
||||
if(!version) {
|
||||
return /msie/i.test(userAgent) || "ActiveXObject" in window;
|
||||
}
|
||||
if(version >= 11) {
|
||||
return "ActiveXObject" in window;
|
||||
}
|
||||
return new RegExp('msie ' + version).test(userAgent);
|
||||
};
|
||||
// ie method does not support 'all' and 'any' interfaces
|
||||
is.ie.api = ['not'];
|
||||
|
||||
// is current browser opera?
|
||||
is.opera = function() {
|
||||
return /^Opera\//.test(userAgent) || // Opera 12 and older versions
|
||||
/\x20OPR\//.test(userAgent); // Opera 15+
|
||||
};
|
||||
// opera method does not support 'all' and 'any' interfaces
|
||||
is.opera.api = ['not'];
|
||||
|
||||
// is current browser safari?
|
||||
is.safari = function() {
|
||||
return /safari/i.test(userAgent) && /apple computer/i.test(vendor);
|
||||
};
|
||||
// safari method does not support 'all' and 'any' interfaces
|
||||
is.safari.api = ['not'];
|
||||
|
||||
// is current device ios?
|
||||
is.ios = function() {
|
||||
return is.iphone() || is.ipad() || is.ipod();
|
||||
};
|
||||
// ios method does not support 'all' and 'any' interfaces
|
||||
is.ios.api = ['not'];
|
||||
|
||||
// is current device iphone?
|
||||
is.iphone = function() {
|
||||
return /iphone/i.test(userAgent);
|
||||
};
|
||||
// iphone method does not support 'all' and 'any' interfaces
|
||||
is.iphone.api = ['not'];
|
||||
|
||||
// is current device ipad?
|
||||
is.ipad = function() {
|
||||
return /ipad/i.test(userAgent);
|
||||
};
|
||||
// ipad method does not support 'all' and 'any' interfaces
|
||||
is.ipad.api = ['not'];
|
||||
|
||||
// is current device ipod?
|
||||
is.ipod = function() {
|
||||
return /ipod/i.test(userAgent);
|
||||
};
|
||||
// ipod method does not support 'all' and 'any' interfaces
|
||||
is.ipod.api = ['not'];
|
||||
|
||||
// is current device android?
|
||||
is.android = function() {
|
||||
return /android/i.test(userAgent);
|
||||
};
|
||||
// android method does not support 'all' and 'any' interfaces
|
||||
is.android.api = ['not'];
|
||||
|
||||
// is current device android phone?
|
||||
is.androidPhone = function() {
|
||||
return /android/i.test(userAgent) && /mobile/i.test(userAgent);
|
||||
};
|
||||
// androidPhone method does not support 'all' and 'any' interfaces
|
||||
is.androidPhone.api = ['not'];
|
||||
|
||||
// is current device android tablet?
|
||||
is.androidTablet = function() {
|
||||
return /android/i.test(userAgent) && !/mobile/i.test(userAgent);
|
||||
};
|
||||
// androidTablet method does not support 'all' and 'any' interfaces
|
||||
is.androidTablet.api = ['not'];
|
||||
|
||||
// is current device blackberry?
|
||||
is.blackberry = function() {
|
||||
return /blackberry/i.test(userAgent);
|
||||
};
|
||||
// blackberry method does not support 'all' and 'any' interfaces
|
||||
is.blackberry.api = ['not'];
|
||||
|
||||
// is current device desktop?
|
||||
is.desktop = function() {
|
||||
return is.not.mobile() && is.not.tablet();
|
||||
};
|
||||
// desktop method does not support 'all' and 'any' interfaces
|
||||
is.desktop.api = ['not'];
|
||||
|
||||
// is current operating system linux?
|
||||
is.linux = function() {
|
||||
return /linux/i.test(appVersion);
|
||||
};
|
||||
// linux method does not support 'all' and 'any' interfaces
|
||||
is.linux.api = ['not'];
|
||||
|
||||
// is current operating system mac?
|
||||
is.mac = function() {
|
||||
return /mac/i.test(appVersion);
|
||||
};
|
||||
// mac method does not support 'all' and 'any' interfaces
|
||||
is.mac.api = ['not'];
|
||||
|
||||
// is current operating system windows?
|
||||
is.windows = function() {
|
||||
return /win/i.test(appVersion);
|
||||
};
|
||||
// windows method does not support 'all' and 'any' interfaces
|
||||
is.windows.api = ['not'];
|
||||
|
||||
// is current device windows phone?
|
||||
is.windowsPhone = function() {
|
||||
return is.windows() && /phone/i.test(userAgent);
|
||||
};
|
||||
// windowsPhone method does not support 'all' and 'any' interfaces
|
||||
is.windowsPhone.api = ['not'];
|
||||
|
||||
// is current device windows tablet?
|
||||
is.windowsTablet = function() {
|
||||
return is.windows() && is.not.windowsPhone() && /touch/i.test(userAgent);
|
||||
};
|
||||
// windowsTablet method does not support 'all' and 'any' interfaces
|
||||
is.windowsTablet.api = ['not'];
|
||||
|
||||
// is current device mobile?
|
||||
is.mobile = function() {
|
||||
return is.iphone() || is.ipod() || is.androidPhone() || is.blackberry() || is.windowsPhone();
|
||||
};
|
||||
// mobile method does not support 'all' and 'any' interfaces
|
||||
is.mobile.api = ['not'];
|
||||
|
||||
// is current device tablet?
|
||||
is.tablet = function() {
|
||||
return is.ipad() || is.androidTablet() || is.windowsTablet();
|
||||
};
|
||||
// tablet method does not support 'all' and 'any' interfaces
|
||||
is.tablet.api = ['not'];
|
||||
|
||||
// is current state online?
|
||||
is.online = function() {
|
||||
return navigator.onLine;
|
||||
};
|
||||
// online method does not support 'all' and 'any' interfaces
|
||||
is.online.api = ['not'];
|
||||
|
||||
// is current state offline?
|
||||
is.offline = not(is.online);
|
||||
// offline method does not support 'all' and 'any' interfaces
|
||||
is.offline.api = ['not'];
|
||||
}
|
||||
|
||||
// Object checks
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// has a given object got parameterized count property?
|
||||
is.propertyCount = function(obj, count) {
|
||||
if(!is.object(obj) || !is.number(count)) {
|
||||
return false;
|
||||
}
|
||||
if(Object.keys) {
|
||||
return Object.keys(obj).length === count;
|
||||
}
|
||||
var properties = [],
|
||||
property;
|
||||
for(property in obj) {
|
||||
if (hasOwnProperty.call(obj, property)) {
|
||||
properties.push(property);
|
||||
}
|
||||
}
|
||||
return properties.length === count;
|
||||
};
|
||||
// propertyCount method does not support 'all' and 'any' interfaces
|
||||
is.propertyCount.api = ['not'];
|
||||
|
||||
// is given object has parameterized property?
|
||||
is.propertyDefined = function(obj, property) {
|
||||
return is.object(obj) && is.string(property) && property in obj;
|
||||
};
|
||||
// propertyDefined method does not support 'all' and 'any' interfaces
|
||||
is.propertyDefined.api = ['not'];
|
||||
|
||||
// is a given object window?
|
||||
// setInterval method is only available for window object
|
||||
is.windowObject = function(obj) {
|
||||
return typeof obj === 'object' && 'setInterval' in obj;
|
||||
};
|
||||
|
||||
// is a given object a DOM node?
|
||||
is.domNode = function(obj) {
|
||||
return is.object(obj) && obj.nodeType > 0;
|
||||
};
|
||||
|
||||
// Array checks
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// is a given item in an array?
|
||||
is.inArray = function(val, arr){
|
||||
if(is.not.array(arr)) {
|
||||
return false;
|
||||
}
|
||||
for(var i = 0; i < arr.length; i++) {
|
||||
if (arr[i] === val) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
// inArray method does not support 'all' and 'any' interfaces
|
||||
is.inArray.api = ['not'];
|
||||
|
||||
// is a given array sorted?
|
||||
is.sorted = function(arr) {
|
||||
if(is.not.array(arr)) {
|
||||
return false;
|
||||
}
|
||||
for(var i = 0; i < arr.length; i++) {
|
||||
if(arr[i] > arr[i + 1]) return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// API
|
||||
// Set 'not', 'all' and 'any' interfaces to methods based on their api property
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
function setInterfaces() {
|
||||
var options = is;
|
||||
for(var option in options) {
|
||||
if(hasOwnProperty.call(options, option) && is.function(options[option])) {
|
||||
var interfaces = options[option].api || ['not', 'all', 'any'];
|
||||
for (var i = 0; i < interfaces.length; i++) {
|
||||
if(interfaces[i] === 'not') {
|
||||
is.not[option] = not(is[option]);
|
||||
}
|
||||
if(interfaces[i] === 'all') {
|
||||
is.all[option] = all(is[option]);
|
||||
}
|
||||
if(interfaces[i] === 'any') {
|
||||
is.any[option] = any(is[option]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setInterfaces();
|
||||
|
||||
// Configuration methods
|
||||
// Intentionally added after setInterfaces function
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// set optional regexps to methods if you think they suck
|
||||
is.setRegexp = function(regexp, regexpName) {
|
||||
for(var r in regexps) {
|
||||
if(hasOwnProperty.call(regexps, r) && (regexpName === r)) {
|
||||
regexps[r] = regexp;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// change namespace of library to prevent name collisions
|
||||
// var preferredName = is.setNamespace();
|
||||
// preferredName.odd(3);
|
||||
// => true
|
||||
is.setNamespace = function() {
|
||||
root.is = previousIs;
|
||||
return this;
|
||||
};
|
||||
|
||||
return is;
|
||||
}));
|
||||
1
vendors/is.js/is.min.js
vendored
1
vendors/is.js/is.min.js
vendored
File diff suppressed because one or more lines are too long
12
vendors/is.js/package.json
vendored
12
vendors/is.js/package.json
vendored
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"name": "is_js",
|
||||
"version": "0.6.0",
|
||||
"main": "is.js",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.5",
|
||||
"grunt-contrib-jshint": "~0.10.0",
|
||||
"grunt-contrib-uglify": "~0.5.0",
|
||||
"grunt-mocha-phantomjs": "0.6.0"
|
||||
}
|
||||
}
|
||||
20
vendors/jquery-magnific-popup/LICENSE
vendored
20
vendors/jquery-magnific-popup/LICENSE
vendored
|
|
@ -1,20 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Dmitry Semenov, http://dimsemenov.com
|
||||
|
||||
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.
|
||||
69
vendors/jquery-magnific-popup/README.md
vendored
69
vendors/jquery-magnific-popup/README.md
vendored
|
|
@ -1,69 +0,0 @@
|
|||
# Magnific Popup Repository
|
||||
|
||||
[](https://travis-ci.org/dimsemenov/Magnific-Popup)
|
||||
|
||||
Fast, light and responsive lightbox plugin, for jQuery and Zepto.js.
|
||||
|
||||
- [Documentation and getting started guide](http://dimsemenov.com/plugins/magnific-popup/documentation.html).
|
||||
- [Examples and plugin home page](http://dimsemenov.com/plugins/magnific-popup/).
|
||||
- More examples in [CodePen collection](http://codepen.io/collection/nLcqo).
|
||||
|
||||
Optionally, install via Bower: `bower install magnific-popup`.
|
||||
[Ruby gem](https://rubygems.org/gems/magnific-popup-rails), `gem install magnific-popup-rails`.
|
||||
|
||||
## Extensions
|
||||
|
||||
- WordPress plugin - [under development](http://dimsemenov.com/plugins/magnific-popup/wordpress.html).
|
||||
- [Drupal module](https://drupal.org/project/magnific_popup).
|
||||
- [Concrete5 add-on](https://github.com/cdowdy/concrete5-Magnific-Popup).
|
||||
- [Redaxo add-on](http://www.redaxo.org/de/download/addons/?addon_id=1131).
|
||||
- [Contao extension](https://github.com/fritzmg/contao-magnific-popup).
|
||||
|
||||
If you created an extension for some CMS, email me and I'll add it to this list.
|
||||
|
||||
## Location of stuff
|
||||
|
||||
- Generated popup JS and CSS files are in folder [dist/](https://github.com/dimsemenov/Magnific-Popup/tree/master/dist). (Online build tool is on [documentation page](http://dimsemenov.com/plugins/magnific-popup/documentation.html)).
|
||||
- Source files are in folder [src/](https://github.com/dimsemenov/Magnific-Popup/tree/master/src). They include [Sass CSS file](https://github.com/dimsemenov/Magnific-Popup/blob/master/src/css/main.scss) and js parts (edit them if you wish to submit commit).
|
||||
- Website (examples & documentation) is in folder [website/](https://github.com/dimsemenov/Magnific-Popup/tree/master/website).
|
||||
- Documentation page itself is in [website/documentation.md](https://github.com/dimsemenov/Magnific-Popup/blob/master/website/documentation.md) (contributions to it are very welcome).
|
||||
|
||||
|
||||
|
||||
## Using Magnific Popup?
|
||||
|
||||
If you used Magnific Popup in some interesting way, or on site of popular brand, I'd be very grateful if you <a href="mailto:diiiimaaaa@gmail.com?subject="Site that uses Magnific Popup"">shoot me</a> a link to it.
|
||||
|
||||
|
||||
## Build
|
||||
|
||||
To compile Magnific Popup by yourself, first of make sure that you have [Node.js](http://nodejs.org/), [Grunt.js](https://github.com/cowboy/grunt), [Ruby](http://www.ruby-lang.org/) and [Jekyll](https://github.com/mojombo/jekyll/) installed, then:
|
||||
|
||||
1) Copy repository
|
||||
|
||||
git clone https://github.com/dimsemenov/Magnific-Popup.git
|
||||
|
||||
2) Go inside Magnific Popup folder that you fetched and install Node dependencies
|
||||
|
||||
cd Magnific-Popup && npm install
|
||||
|
||||
3) Now simply run `grunt` to generate JS and CSS in folder `dist` and site in folder `_site/`.
|
||||
|
||||
grunt
|
||||
|
||||
Optionally:
|
||||
|
||||
- Run `grunt watch` to automatically rebuild script when you change files in `src/` or in `website/`.
|
||||
- If you don't have and don't want to install Jekyll, run `grunt nosite` to just build JS and CSS files related to popup in `dist/`.
|
||||
|
||||
|
||||
|
||||
## [Changelog](https://github.com/dimsemenov/Magnific-Popup/releases)
|
||||
|
||||
## License
|
||||
|
||||
Script is MIT licensed and free and will always be kept this way. But has a small restriction from me - please do not create public WordPress plugin based on it(or at least contact me before creating it), because I will make it and it'll be open source too ([want to get notified?](http://dimsemenov.com/subscribe.html)).
|
||||
|
||||
Created by [@dimsemenov](http://twitter.com/dimsemenov) & [contributors](https://github.com/dimsemenov/Magnific-Popup/contributors).
|
||||
|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
||||
17
vendors/jquery-magnific-popup/bower.json
vendored
17
vendors/jquery-magnific-popup/bower.json
vendored
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"name": "magnific-popup",
|
||||
"version": "0.9.9",
|
||||
"main": [
|
||||
"dist/jquery.magnific-popup.js",
|
||||
"dist/magnific-popup.css"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.8.0"
|
||||
},
|
||||
"ignore": [
|
||||
"node_modules/",
|
||||
"components/",
|
||||
"website/",
|
||||
"libs/"
|
||||
]
|
||||
}
|
||||
2048
vendors/jquery-magnific-popup/jquery.magnific-popup.js
vendored
2048
vendors/jquery-magnific-popup/jquery.magnific-popup.js
vendored
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -1,45 +0,0 @@
|
|||
|
||||
/* overlay at start */
|
||||
.mfp-fade.mfp-bg {
|
||||
opacity: 0;
|
||||
|
||||
-webkit-transition: all 0.2s ease-out;
|
||||
-moz-transition: all 0.2s ease-out;
|
||||
transition: all 0.2s ease-out;
|
||||
}
|
||||
/* overlay animate in */
|
||||
.mfp-fade.mfp-bg.mfp-ready {
|
||||
opacity: 0.8;
|
||||
}
|
||||
/* overlay animate out */
|
||||
.mfp-fade.mfp-bg.mfp-removing {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* content at start */
|
||||
.mfp-fade.mfp-wrap .mfp-content {
|
||||
opacity: 0;
|
||||
|
||||
-webkit-transition: all 0.15s ease-out;
|
||||
-moz-transition: all 0.15s ease-out;
|
||||
transition: all 0.15s ease-out;
|
||||
|
||||
-webkit-transform: translateX(-50px);
|
||||
-moz-transform: translateX(-50px);
|
||||
transform: translateX(-50px);
|
||||
}
|
||||
|
||||
/* content animate it */
|
||||
.mfp-fade.mfp-wrap.mfp-ready .mfp-content {
|
||||
opacity: 1;
|
||||
-webkit-transform: translateX(0);
|
||||
-moz-transform: translateX(0);
|
||||
transform: translateX(0);
|
||||
}
|
||||
/* content animate out */
|
||||
.mfp-fade.mfp-wrap.mfp-removing .mfp-content {
|
||||
opacity: 0;
|
||||
-webkit-transform: translateX(50px);
|
||||
-moz-transform: translateX(50px);
|
||||
transform: translateX(50px);
|
||||
}
|
||||
368
vendors/jquery-magnific-popup/magnific-popup.css
vendored
368
vendors/jquery-magnific-popup/magnific-popup.css
vendored
|
|
@ -1,368 +0,0 @@
|
|||
/* Magnific Popup CSS */
|
||||
.mfp-bg {
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1042;
|
||||
overflow: hidden;
|
||||
position: fixed;
|
||||
background: #0b0b0b;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80); }
|
||||
|
||||
.mfp-wrap {
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1043;
|
||||
position: fixed;
|
||||
outline: none !important;
|
||||
-webkit-backface-visibility: hidden; }
|
||||
|
||||
.mfp-container {
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
top: 0;
|
||||
padding: 0 8px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box; }
|
||||
|
||||
.mfp-container:before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
vertical-align: middle; }
|
||||
|
||||
.mfp-align-top .mfp-container:before {
|
||||
display: none; }
|
||||
|
||||
.mfp-content {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
margin: 0 auto;
|
||||
text-align: left;
|
||||
z-index: 1045; }
|
||||
|
||||
.mfp-inline-holder .mfp-content, .mfp-ajax-holder .mfp-content {
|
||||
width: 100%;
|
||||
cursor: auto; }
|
||||
|
||||
.mfp-ajax-cur {
|
||||
cursor: progress; }
|
||||
|
||||
.mfp-zoom-out-cur, .mfp-zoom-out-cur .mfp-image-holder .mfp-close {
|
||||
cursor: -moz-zoom-out;
|
||||
cursor: -webkit-zoom-out;
|
||||
cursor: zoom-out; }
|
||||
|
||||
.mfp-zoom {
|
||||
cursor: pointer;
|
||||
cursor: -webkit-zoom-in;
|
||||
cursor: -moz-zoom-in;
|
||||
cursor: zoom-in; }
|
||||
|
||||
.mfp-auto-cursor .mfp-content {
|
||||
cursor: auto; }
|
||||
|
||||
.mfp-close, .mfp-arrow, .mfp-preloader, .mfp-counter {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none; }
|
||||
|
||||
.mfp-loading.mfp-figure {
|
||||
display: none; }
|
||||
|
||||
.mfp-hide {
|
||||
display: none !important; }
|
||||
|
||||
.mfp-preloader {
|
||||
color: #cccccc;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: auto;
|
||||
text-align: center;
|
||||
margin-top: -0.8em;
|
||||
left: 8px;
|
||||
right: 8px;
|
||||
z-index: 1044; }
|
||||
.mfp-preloader a {
|
||||
color: #cccccc; }
|
||||
.mfp-preloader a:hover {
|
||||
color: white; }
|
||||
|
||||
.mfp-s-ready .mfp-preloader {
|
||||
display: none; }
|
||||
|
||||
.mfp-s-error .mfp-content {
|
||||
display: none; }
|
||||
|
||||
button.mfp-close, button.mfp-arrow {
|
||||
overflow: visible;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
-webkit-appearance: none;
|
||||
display: block;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
z-index: 1046;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none; }
|
||||
button::-moz-focus-inner {
|
||||
padding: 0;
|
||||
border: 0; }
|
||||
|
||||
.mfp-close {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
line-height: 44px;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
opacity: 0.65;
|
||||
filter: alpha(opacity=65);
|
||||
padding: 0 0 18px 10px;
|
||||
color: white;
|
||||
font-style: normal;
|
||||
font-size: 28px;
|
||||
font-family: Arial, Baskerville, monospace; }
|
||||
.mfp-close:hover, .mfp-close:focus {
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100); }
|
||||
.mfp-close:active {
|
||||
top: 1px; }
|
||||
|
||||
.mfp-close-btn-in .mfp-close {
|
||||
color: #333333; }
|
||||
|
||||
.mfp-image-holder .mfp-close, .mfp-iframe-holder .mfp-close {
|
||||
color: white;
|
||||
right: -6px;
|
||||
text-align: right;
|
||||
padding-right: 6px;
|
||||
width: 100%; }
|
||||
|
||||
.mfp-counter {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
color: #cccccc;
|
||||
font-size: 12px;
|
||||
line-height: 18px; }
|
||||
|
||||
.mfp-arrow {
|
||||
position: absolute;
|
||||
opacity: 0.65;
|
||||
filter: alpha(opacity=65);
|
||||
margin: 0;
|
||||
top: 50%;
|
||||
margin-top: -55px;
|
||||
padding: 0;
|
||||
width: 90px;
|
||||
height: 110px;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
|
||||
.mfp-arrow:active {
|
||||
margin-top: -54px; }
|
||||
.mfp-arrow:hover, .mfp-arrow:focus {
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100); }
|
||||
.mfp-arrow:before, .mfp-arrow:after, .mfp-arrow .mfp-b, .mfp-arrow .mfp-a {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
margin-top: 35px;
|
||||
margin-left: 35px;
|
||||
border: medium inset transparent; }
|
||||
.mfp-arrow:after, .mfp-arrow .mfp-a {
|
||||
border-top-width: 13px;
|
||||
border-bottom-width: 13px;
|
||||
top: 8px; }
|
||||
.mfp-arrow:before, .mfp-arrow .mfp-b {
|
||||
border-top-width: 21px;
|
||||
border-bottom-width: 21px;
|
||||
opacity: 0.7; }
|
||||
|
||||
.mfp-arrow-left {
|
||||
left: 0; }
|
||||
.mfp-arrow-left:after, .mfp-arrow-left .mfp-a {
|
||||
border-right: 17px solid white;
|
||||
margin-left: 31px; }
|
||||
.mfp-arrow-left:before, .mfp-arrow-left .mfp-b {
|
||||
margin-left: 25px;
|
||||
border-right: 27px solid #3f3f3f; }
|
||||
|
||||
.mfp-arrow-right {
|
||||
right: 0; }
|
||||
.mfp-arrow-right:after, .mfp-arrow-right .mfp-a {
|
||||
border-left: 17px solid white;
|
||||
margin-left: 39px; }
|
||||
.mfp-arrow-right:before, .mfp-arrow-right .mfp-b {
|
||||
border-left: 27px solid #3f3f3f; }
|
||||
|
||||
.mfp-iframe-holder {
|
||||
padding-top: 40px;
|
||||
padding-bottom: 40px; }
|
||||
.mfp-iframe-holder .mfp-content {
|
||||
line-height: 0;
|
||||
width: 100%;
|
||||
max-width: 900px; }
|
||||
.mfp-iframe-holder .mfp-close {
|
||||
top: -40px; }
|
||||
|
||||
.mfp-iframe-scaler {
|
||||
width: 100%;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
padding-top: 56.25%; }
|
||||
.mfp-iframe-scaler iframe {
|
||||
position: absolute;
|
||||
display: block;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
|
||||
background: black; }
|
||||
|
||||
/* Main image in popup */
|
||||
img.mfp-img {
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
line-height: 0;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
padding: 40px 0 40px;
|
||||
margin: 0 auto; }
|
||||
|
||||
/* The shadow behind the image */
|
||||
.mfp-figure {
|
||||
line-height: 0; }
|
||||
.mfp-figure:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 40px;
|
||||
bottom: 40px;
|
||||
display: block;
|
||||
right: 0;
|
||||
width: auto;
|
||||
height: auto;
|
||||
z-index: -1;
|
||||
box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
|
||||
background: #444444; }
|
||||
.mfp-figure small {
|
||||
color: #bdbdbd;
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
line-height: 14px; }
|
||||
.mfp-figure figure {
|
||||
margin: 0; }
|
||||
|
||||
.mfp-bottom-bar {
|
||||
margin-top: -36px;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
cursor: auto; }
|
||||
|
||||
.mfp-title {
|
||||
text-align: left;
|
||||
line-height: 18px;
|
||||
color: #f3f3f3;
|
||||
word-wrap: break-word;
|
||||
padding-right: 36px; }
|
||||
|
||||
.mfp-image-holder .mfp-content {
|
||||
max-width: 100%; }
|
||||
|
||||
.mfp-gallery .mfp-image-holder .mfp-figure {
|
||||
cursor: pointer; }
|
||||
|
||||
@media screen and (max-width: 800px) and (orientation: landscape), screen and (max-height: 300px) {
|
||||
/**
|
||||
* Remove all paddings around the image on small screen
|
||||
*/
|
||||
.mfp-img-mobile .mfp-image-holder {
|
||||
padding-left: 0;
|
||||
padding-right: 0; }
|
||||
.mfp-img-mobile img.mfp-img {
|
||||
padding: 0; }
|
||||
.mfp-img-mobile .mfp-figure:after {
|
||||
top: 0;
|
||||
bottom: 0; }
|
||||
.mfp-img-mobile .mfp-figure small {
|
||||
display: inline;
|
||||
margin-left: 5px; }
|
||||
.mfp-img-mobile .mfp-bottom-bar {
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
bottom: 0;
|
||||
margin: 0;
|
||||
top: auto;
|
||||
padding: 3px 5px;
|
||||
position: fixed;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box; }
|
||||
.mfp-img-mobile .mfp-bottom-bar:empty {
|
||||
padding: 0; }
|
||||
.mfp-img-mobile .mfp-counter {
|
||||
right: 5px;
|
||||
top: 3px; }
|
||||
.mfp-img-mobile .mfp-close {
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
position: fixed;
|
||||
text-align: center;
|
||||
padding: 0; } }
|
||||
|
||||
@media all and (max-width: 900px) {
|
||||
.mfp-arrow {
|
||||
-webkit-transform: scale(0.75);
|
||||
transform: scale(0.75); }
|
||||
.mfp-arrow-left {
|
||||
-webkit-transform-origin: 0;
|
||||
transform-origin: 0; }
|
||||
.mfp-arrow-right {
|
||||
-webkit-transform-origin: 100%;
|
||||
transform-origin: 100%; }
|
||||
.mfp-container {
|
||||
padding-left: 6px;
|
||||
padding-right: 6px; } }
|
||||
|
||||
.mfp-ie7 .mfp-img {
|
||||
padding: 0; }
|
||||
.mfp-ie7 .mfp-bottom-bar {
|
||||
width: 600px;
|
||||
left: 50%;
|
||||
margin-left: -300px;
|
||||
margin-top: 5px;
|
||||
padding-bottom: 5px; }
|
||||
.mfp-ie7 .mfp-container {
|
||||
padding: 0; }
|
||||
.mfp-ie7 .mfp-content {
|
||||
padding-top: 44px; }
|
||||
.mfp-ie7 .mfp-close {
|
||||
top: 0;
|
||||
right: 0;
|
||||
padding-top: 0; }
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"name": "magnific-popup",
|
||||
"title": "Magnific Popup",
|
||||
"description": "Fast, light, mobile-friendly and responsive lightbox and modal dialog plugin. Open inline HTML, ajax loaded content, image, form, iframe (YouTube video, Vimeo, Google Maps), photo gallery. Animation effects added with CSS3 transitions. For jQuery or Zepto.",
|
||||
"version": "0.9.9",
|
||||
"homepage": "http://dimsemenov.com/plugins/magnific-popup/",
|
||||
"demo": "http://dimsemenov.com/plugins/magnific-popup/",
|
||||
"docs": "http://dimsemenov.com/plugins/magnific-popup/documentation.html",
|
||||
"author": {
|
||||
"name": "Dmitry Semenov",
|
||||
"email": "diiiimaaaa@gmail.com",
|
||||
"url": "http://dimsemenov.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dimsemenov/Magnific-Popup.git"
|
||||
},
|
||||
"bugs": "https://github.com/dimsemenov/Magnific-Popup/issues",
|
||||
"dependencies": {
|
||||
"jquery": ">=1.7.2"
|
||||
},
|
||||
"keywords": ["lightbox","popup","modal","window","dialog","ui","gallery","slideshow","video","image","ajax","html5","animation","jquery","photo","responsive","mobile"],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://www.opensource.org/licenses/mit-license.php"
|
||||
}
|
||||
]
|
||||
}
|
||||
44
vendors/jquery-magnific-popup/package.json
vendored
44
vendors/jquery-magnific-popup/package.json
vendored
|
|
@ -1,44 +0,0 @@
|
|||
{
|
||||
"name": "magnific-popup",
|
||||
|
||||
"version": "0.9.9",
|
||||
"title": "Magnific Popup",
|
||||
"description": "Lightbox and modal dialog plugin. Can display inline HTML, iframes (YouTube video, Vimeo, Google Maps), or an image gallery. Animation effects are added with CSS3 transitions. For jQuery or Zepto.",
|
||||
"keywords": ["lightbox","popup","modal","window","dialog","gallery","jquery","photo","responsive","mobile"],
|
||||
"author": {
|
||||
"name": "Dmitry Semenov",
|
||||
"email": "diiiimaaaa@gmail.com",
|
||||
"web": "http://dimsemenov.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/dimsemenov/Magnific-Popup/issues"
|
||||
},
|
||||
"main": "dist/jquery.magnific-popup.js",
|
||||
"homepage": "http://dimsemenov.com/plugins/magnific-popup/",
|
||||
|
||||
|
||||
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt jshint"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt-contrib-jshint": "~0.1.1",
|
||||
"grunt-contrib-concat": "~0.1.2",
|
||||
"grunt-contrib-uglify": "~0.1.1",
|
||||
"grunt-contrib-watch": "~0.2.0",
|
||||
"grunt-contrib-clean": "~0.4.0",
|
||||
"grunt": "~0.4.0",
|
||||
"grunt-contrib-cssmin": "~0.4.1",
|
||||
"grunt-contrib-copy": "~0.4.0",
|
||||
"grunt-jekyll": "~0.3.9",
|
||||
"grunt-sass": "~0.6.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dimsemenov/Magnific-Popup.git"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/*!
|
||||
* jQuery UI Touch Punch 0.2.3
|
||||
*
|
||||
* Copyright 2011–2014, Dave Furfero
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*
|
||||
* Depends:
|
||||
* jquery.ui.widget.js
|
||||
* jquery.ui.mouse.js
|
||||
*/
|
||||
!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);
|
||||
589
vendors/knockout-punches/knockout.punches.js
vendored
589
vendors/knockout-punches/knockout.punches.js
vendored
|
|
@ -1,589 +0,0 @@
|
|||
/**
|
||||
* @license Knockout.Punches
|
||||
* Enhanced binding syntaxes for Knockout 3+
|
||||
* (c) Michael Best
|
||||
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
* Version 0.5.0
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['knockout'], factory);
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(ko);
|
||||
}
|
||||
}(function(ko) {
|
||||
|
||||
// Add a preprocess function to a binding handler.
|
||||
function addBindingPreprocessor(bindingKeyOrHandler, preprocessFn) {
|
||||
return chainPreprocessor(getOrCreateHandler(bindingKeyOrHandler), 'preprocess', preprocessFn);
|
||||
}
|
||||
|
||||
// These utility functions are separated out because they're also used by
|
||||
// preprocessBindingProperty
|
||||
|
||||
// Get the binding handler or create a new, empty one
|
||||
function getOrCreateHandler(bindingKeyOrHandler) {
|
||||
return typeof bindingKeyOrHandler === 'object' ? bindingKeyOrHandler :
|
||||
(ko.getBindingHandler(bindingKeyOrHandler) || (ko.bindingHandlers[bindingKeyOrHandler] = {}));
|
||||
}
|
||||
// Add a preprocess function
|
||||
function chainPreprocessor(obj, prop, fn) {
|
||||
if (obj[prop]) {
|
||||
// If the handler already has a preprocess function, chain the new
|
||||
// one after the existing one. If the previous function in the chain
|
||||
// returns a falsy value (to remove the binding), the chain ends. This
|
||||
// method allows each function to modify and return the binding value.
|
||||
var previousFn = obj[prop];
|
||||
obj[prop] = function(value, binding, addBinding) {
|
||||
value = previousFn.call(this, value, binding, addBinding);
|
||||
if (value)
|
||||
return fn.call(this, value, binding, addBinding);
|
||||
};
|
||||
} else {
|
||||
obj[prop] = fn;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Add a preprocessNode function to the binding provider. If a
|
||||
// function already exists, chain the new one after it. This calls
|
||||
// each function in the chain until one modifies the node. This
|
||||
// method allows only one function to modify the node.
|
||||
function addNodePreprocessor(preprocessFn) {
|
||||
var provider = ko.bindingProvider.instance;
|
||||
if (provider.preprocessNode) {
|
||||
var previousPreprocessFn = provider.preprocessNode;
|
||||
provider.preprocessNode = function(node) {
|
||||
var newNodes = previousPreprocessFn.call(this, node);
|
||||
if (!newNodes)
|
||||
newNodes = preprocessFn.call(this, node);
|
||||
return newNodes;
|
||||
};
|
||||
} else {
|
||||
provider.preprocessNode = preprocessFn;
|
||||
}
|
||||
}
|
||||
|
||||
function addBindingHandlerCreator(matchRegex, callbackFn) {
|
||||
var oldGetHandler = ko.getBindingHandler;
|
||||
ko.getBindingHandler = function(bindingKey) {
|
||||
var match;
|
||||
return oldGetHandler(bindingKey) || ((match = bindingKey.match(matchRegex)) && callbackFn(match, bindingKey));
|
||||
};
|
||||
}
|
||||
|
||||
// Create shortcuts to commonly used ko functions
|
||||
var ko_unwrap = ko.unwrap;
|
||||
|
||||
// Create "punches" object and export utility functions
|
||||
var ko_punches = ko.punches = {
|
||||
utils: {
|
||||
addBindingPreprocessor: addBindingPreprocessor,
|
||||
addNodePreprocessor: addNodePreprocessor,
|
||||
addBindingHandlerCreator: addBindingHandlerCreator,
|
||||
|
||||
// previous names retained for backwards compitibility
|
||||
setBindingPreprocessor: addBindingPreprocessor,
|
||||
setNodePreprocessor: addNodePreprocessor
|
||||
}
|
||||
};
|
||||
|
||||
ko_punches.enableAll = function () {
|
||||
// Enable interpolation markup
|
||||
enableInterpolationMarkup();
|
||||
enableAttributeInterpolationMarkup();
|
||||
|
||||
// Enable auto-namspacing of attr, css, event, and style
|
||||
enableAutoNamespacedSyntax('attr');
|
||||
enableAutoNamespacedSyntax('css');
|
||||
enableAutoNamespacedSyntax('event');
|
||||
enableAutoNamespacedSyntax('style');
|
||||
|
||||
// Enable filter syntax for text, html, and attr
|
||||
enableTextFilter('text');
|
||||
enableTextFilter('html');
|
||||
addDefaultNamespacedBindingPreprocessor('attr', filterPreprocessor);
|
||||
|
||||
// Enable wrapped callbacks for click, submit, event, optionsAfterRender, and template options
|
||||
enableWrappedCallback('click');
|
||||
enableWrappedCallback('submit');
|
||||
enableWrappedCallback('optionsAfterRender');
|
||||
addDefaultNamespacedBindingPreprocessor('event', wrappedCallbackPreprocessor);
|
||||
addBindingPropertyPreprocessor('template', 'beforeRemove', wrappedCallbackPreprocessor);
|
||||
addBindingPropertyPreprocessor('template', 'afterAdd', wrappedCallbackPreprocessor);
|
||||
addBindingPropertyPreprocessor('template', 'afterRender', wrappedCallbackPreprocessor);
|
||||
};
|
||||
// Convert input in the form of `expression | filter1 | filter2:arg1:arg2` to a function call format
|
||||
// with filters accessed as ko.filters.filter1, etc.
|
||||
function filterPreprocessor(input) {
|
||||
// Check if the input contains any | characters; if not, just return
|
||||
if (input.indexOf('|') === -1)
|
||||
return input;
|
||||
|
||||
// Split the input into tokens, in which | and : are individual tokens, quoted strings are ignored, and all tokens are space-trimmed
|
||||
var tokens = input.match(/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|\|\||[|:]|[^\s|:"'][^|:"']*[^\s|:"']|[^\s|:"']/g);
|
||||
if (tokens && tokens.length > 1) {
|
||||
// Append a line so that we don't need a separate code block to deal with the last item
|
||||
tokens.push('|');
|
||||
input = tokens[0];
|
||||
var lastToken, token, inFilters = false, nextIsFilter = false;
|
||||
for (var i = 1, token; token = tokens[i]; ++i) {
|
||||
if (token === '|') {
|
||||
if (inFilters) {
|
||||
if (lastToken === ':')
|
||||
input += "undefined";
|
||||
input += ')';
|
||||
}
|
||||
nextIsFilter = true;
|
||||
inFilters = true;
|
||||
} else {
|
||||
if (nextIsFilter) {
|
||||
input = "ko.filters['" + token + "'](" + input;
|
||||
} else if (inFilters && token === ':') {
|
||||
if (lastToken === ':')
|
||||
input += "undefined";
|
||||
input += ",";
|
||||
} else {
|
||||
input += token;
|
||||
}
|
||||
nextIsFilter = false;
|
||||
}
|
||||
lastToken = token;
|
||||
}
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
// Set the filter preprocessor for a specific binding
|
||||
function enableTextFilter(bindingKeyOrHandler) {
|
||||
addBindingPreprocessor(bindingKeyOrHandler, filterPreprocessor);
|
||||
}
|
||||
|
||||
var filters = {};
|
||||
|
||||
// Convert value to uppercase
|
||||
filters.uppercase = function(value) {
|
||||
return String.prototype.toUpperCase.call(ko_unwrap(value));
|
||||
};
|
||||
|
||||
// Convert value to lowercase
|
||||
filters.lowercase = function(value) {
|
||||
return String.prototype.toLowerCase.call(ko_unwrap(value));
|
||||
};
|
||||
|
||||
// Return default value if the input value is empty or null
|
||||
filters['default'] = function (value, defaultValue) {
|
||||
value = ko_unwrap(value);
|
||||
if (typeof value === "function") {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return trim(value) === '' ? defaultValue : value;
|
||||
}
|
||||
return value == null || value.length == 0 ? defaultValue : value;
|
||||
};
|
||||
|
||||
// Return the value with the search string replaced with the replacement string
|
||||
filters.replace = function(value, search, replace) {
|
||||
return String.prototype.replace.call(ko_unwrap(value), search, replace);
|
||||
};
|
||||
|
||||
filters.fit = function(value, length, replacement, trimWhere) {
|
||||
value = ko_unwrap(value);
|
||||
if (length && ('' + value).length > length) {
|
||||
replacement = '' + (replacement || '...');
|
||||
length = length - replacement.length;
|
||||
value = '' + value;
|
||||
switch (trimWhere) {
|
||||
case 'left':
|
||||
return replacement + value.slice(-length);
|
||||
case 'middle':
|
||||
var leftLen = Math.ceil(length / 2);
|
||||
return value.substr(0, leftLen) + replacement + value.slice(leftLen-length);
|
||||
default:
|
||||
return value.substr(0, length) + replacement;
|
||||
}
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
// Convert a model object to JSON
|
||||
filters.json = function(rootObject, space, replacer) { // replacer and space are optional
|
||||
return ko.toJSON(rootObject, replacer, space);
|
||||
};
|
||||
|
||||
// Format a number using the browser's toLocaleString
|
||||
filters.number = function(value) {
|
||||
return (+ko_unwrap(value)).toLocaleString();
|
||||
};
|
||||
|
||||
// Export the filters object for general access
|
||||
ko.filters = filters;
|
||||
|
||||
// Export the preprocessor functions
|
||||
ko_punches.textFilter = {
|
||||
preprocessor: filterPreprocessor,
|
||||
enableForBinding: enableTextFilter
|
||||
};
|
||||
// Support dynamically-created, namespaced bindings. The binding key syntax is
|
||||
// "namespace.binding". Within a certain namespace, we can dynamically create the
|
||||
// handler for any binding. This is particularly useful for bindings that work
|
||||
// the same way, but just set a different named value, such as for element
|
||||
// attributes or CSS classes.
|
||||
var namespacedBindingMatch = /([^\.]+)\.(.+)/, namespaceDivider = '.';
|
||||
addBindingHandlerCreator(namespacedBindingMatch, function (match, bindingKey) {
|
||||
var namespace = match[1],
|
||||
namespaceHandler = ko.bindingHandlers[namespace];
|
||||
if (namespaceHandler) {
|
||||
var bindingName = match[2],
|
||||
handlerFn = namespaceHandler.getNamespacedHandler || defaultGetNamespacedHandler,
|
||||
handler = handlerFn.call(namespaceHandler, bindingName, namespace, bindingKey);
|
||||
ko.bindingHandlers[bindingKey] = handler;
|
||||
return handler;
|
||||
}
|
||||
});
|
||||
|
||||
// Knockout's built-in bindings "attr", "event", "css" and "style" include the idea of
|
||||
// namespaces, representing it using a single binding that takes an object map of names
|
||||
// to values. This default handler translates a binding of "namespacedName: value"
|
||||
// to "namespace: {name: value}" to automatically support those built-in bindings.
|
||||
function defaultGetNamespacedHandler(name, namespace, namespacedName) {
|
||||
var handler = ko.utils.extend({}, this);
|
||||
function setHandlerFunction(funcName) {
|
||||
if (handler[funcName]) {
|
||||
handler[funcName] = function(element, valueAccessor) {
|
||||
function subValueAccessor() {
|
||||
var result = {};
|
||||
result[name] = valueAccessor();
|
||||
return result;
|
||||
}
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
args[1] = subValueAccessor;
|
||||
return ko.bindingHandlers[namespace][funcName].apply(this, args);
|
||||
};
|
||||
}
|
||||
}
|
||||
// Set new init and update functions that wrap the originals
|
||||
setHandlerFunction('init');
|
||||
setHandlerFunction('update');
|
||||
// Clear any preprocess function since preprocessing of the new binding would need to be different
|
||||
if (handler.preprocess)
|
||||
handler.preprocess = null;
|
||||
if (ko.virtualElements.allowedBindings[namespace])
|
||||
ko.virtualElements.allowedBindings[namespacedName] = true;
|
||||
return handler;
|
||||
}
|
||||
|
||||
// Adds a preprocess function for every generated namespace.x binding. This can
|
||||
// be called multiple times for the same binding, and the preprocess functions will
|
||||
// be chained. If the binding has a custom getNamespacedHandler method, make sure that
|
||||
// it's set before this function is used.
|
||||
function addDefaultNamespacedBindingPreprocessor(namespace, preprocessFn) {
|
||||
var handler = ko.getBindingHandler(namespace);
|
||||
if (handler) {
|
||||
var previousHandlerFn = handler.getNamespacedHandler || defaultGetNamespacedHandler;
|
||||
handler.getNamespacedHandler = function() {
|
||||
return addBindingPreprocessor(previousHandlerFn.apply(this, arguments), preprocessFn);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function autoNamespacedPreprocessor(value, binding, addBinding) {
|
||||
if (value.charAt(0) !== "{")
|
||||
return value;
|
||||
|
||||
// Handle two-level binding specified as "binding: {key: value}" by parsing inner
|
||||
// object and converting to "binding.key: value"
|
||||
var subBindings = ko.expressionRewriting.parseObjectLiteral(value);
|
||||
ko.utils.arrayForEach(subBindings, function(keyValue) {
|
||||
addBinding(binding + namespaceDivider + keyValue.key, keyValue.value);
|
||||
});
|
||||
}
|
||||
|
||||
// Set the namespaced preprocessor for a specific binding
|
||||
function enableAutoNamespacedSyntax(bindingKeyOrHandler) {
|
||||
addBindingPreprocessor(bindingKeyOrHandler, autoNamespacedPreprocessor);
|
||||
}
|
||||
|
||||
// Export the preprocessor functions
|
||||
ko_punches.namespacedBinding = {
|
||||
defaultGetHandler: defaultGetNamespacedHandler,
|
||||
setDefaultBindingPreprocessor: addDefaultNamespacedBindingPreprocessor, // for backwards compat.
|
||||
addDefaultBindingPreprocessor: addDefaultNamespacedBindingPreprocessor,
|
||||
preprocessor: autoNamespacedPreprocessor,
|
||||
enableForBinding: enableAutoNamespacedSyntax
|
||||
};
|
||||
// Wrap a callback function in an anonymous function so that it is called with the appropriate
|
||||
// "this" value.
|
||||
function wrappedCallbackPreprocessor(val) {
|
||||
// Matches either an isolated identifier or something ending with a property accessor
|
||||
if (/^([$_a-z][$\w]*|.+(\.\s*[$_a-z][$\w]*|\[.+\]))$/i.test(val)) {
|
||||
return 'function(_x,_y,_z){return(' + val + ')(_x,_y,_z);}';
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the wrappedCallback preprocessor for a specific binding
|
||||
function enableWrappedCallback(bindingKeyOrHandler) {
|
||||
addBindingPreprocessor(bindingKeyOrHandler, wrappedCallbackPreprocessor);
|
||||
}
|
||||
|
||||
// Export the preprocessor functions
|
||||
ko_punches.wrappedCallback = {
|
||||
preprocessor: wrappedCallbackPreprocessor,
|
||||
enableForBinding: enableWrappedCallback
|
||||
};
|
||||
// Attach a preprocess function to a specific property of a binding. This allows you to
|
||||
// preprocess binding "options" using the same preprocess functions that work for bindings.
|
||||
function addBindingPropertyPreprocessor(bindingKeyOrHandler, property, preprocessFn) {
|
||||
var handler = getOrCreateHandler(bindingKeyOrHandler);
|
||||
if (!handler._propertyPreprocessors) {
|
||||
// Initialize the binding preprocessor
|
||||
chainPreprocessor(handler, 'preprocess', propertyPreprocessor);
|
||||
handler._propertyPreprocessors = {};
|
||||
}
|
||||
// Add the property preprocess function
|
||||
chainPreprocessor(handler._propertyPreprocessors, property, preprocessFn);
|
||||
}
|
||||
|
||||
// In order to preprocess a binding property, we have to preprocess the binding itself.
|
||||
// This preprocess function splits up the binding value and runs each property's preprocess
|
||||
// function if it's set.
|
||||
function propertyPreprocessor(value, binding, addBinding) {
|
||||
if (value.charAt(0) !== "{")
|
||||
return value;
|
||||
|
||||
var subBindings = ko.expressionRewriting.parseObjectLiteral(value),
|
||||
resultStrings = [],
|
||||
propertyPreprocessors = this._propertyPreprocessors || {};
|
||||
ko.utils.arrayForEach(subBindings, function(keyValue) {
|
||||
var prop = keyValue.key, propVal = keyValue.value;
|
||||
if (propertyPreprocessors[prop]) {
|
||||
propVal = propertyPreprocessors[prop](propVal, prop, addBinding);
|
||||
}
|
||||
if (propVal) {
|
||||
resultStrings.push("'" + prop + "':" + propVal);
|
||||
}
|
||||
});
|
||||
return "{" + resultStrings.join(",") + "}";
|
||||
}
|
||||
|
||||
// Export the preprocessor functions
|
||||
ko_punches.preprocessBindingProperty = {
|
||||
setPreprocessor: addBindingPropertyPreprocessor, // for backwards compat.
|
||||
addPreprocessor: addBindingPropertyPreprocessor
|
||||
};
|
||||
// Wrap an expression in an anonymous function so that it is called when the event happens
|
||||
function makeExpressionCallbackPreprocessor(args) {
|
||||
return function expressionCallbackPreprocessor(val) {
|
||||
return 'function('+args+'){return(' + val + ');}';
|
||||
};
|
||||
}
|
||||
|
||||
var eventExpressionPreprocessor = makeExpressionCallbackPreprocessor("$data,$event");
|
||||
|
||||
// Set the expressionCallback preprocessor for a specific binding
|
||||
function enableExpressionCallback(bindingKeyOrHandler, args) {
|
||||
var args = Array.prototype.slice.call(arguments, 1).join();
|
||||
addBindingPreprocessor(bindingKeyOrHandler, makeExpressionCallbackPreprocessor(args));
|
||||
}
|
||||
|
||||
// Export the preprocessor functions
|
||||
ko_punches.expressionCallback = {
|
||||
makePreprocessor: makeExpressionCallbackPreprocessor,
|
||||
eventPreprocessor: eventExpressionPreprocessor,
|
||||
enableForBinding: enableExpressionCallback
|
||||
};
|
||||
|
||||
// Create an "on" namespace for events to use the expression method
|
||||
ko.bindingHandlers.on = {
|
||||
getNamespacedHandler: function(eventName) {
|
||||
var handler = ko.getBindingHandler('event' + namespaceDivider + eventName);
|
||||
return addBindingPreprocessor(handler, eventExpressionPreprocessor);
|
||||
}
|
||||
};
|
||||
// Performance comparison at http://jsperf.com/markup-interpolation-comparison
|
||||
function parseInterpolationMarkup(textToParse, outerTextCallback, expressionCallback) {
|
||||
function innerParse(text) {
|
||||
var innerMatch = text.match(/^([\s\S]*)}}([\s\S]*?)\{\{([\s\S]*)$/);
|
||||
if (innerMatch) {
|
||||
innerParse(innerMatch[1]);
|
||||
outerTextCallback(innerMatch[2]);
|
||||
expressionCallback(innerMatch[3]);
|
||||
} else {
|
||||
expressionCallback(text);
|
||||
}
|
||||
}
|
||||
var outerMatch = textToParse.match(/^([\s\S]*?)\{\{([\s\S]*)}}([\s\S]*)$/);
|
||||
if (outerMatch) {
|
||||
outerTextCallback(outerMatch[1]);
|
||||
innerParse(outerMatch[2]);
|
||||
outerTextCallback(outerMatch[3]);
|
||||
}
|
||||
}
|
||||
|
||||
function trim(string) {
|
||||
return string == null ? '' :
|
||||
string.trim ?
|
||||
string.trim() :
|
||||
string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, '');
|
||||
}
|
||||
|
||||
function interpolationMarkupPreprocessor(node) {
|
||||
// only needs to work with text nodes
|
||||
if (node.nodeType === 3 && node.nodeValue && node.nodeValue.indexOf('{{') !== -1 && (node.parentNode || {}).nodeName != "TEXTAREA") {
|
||||
var nodes = [];
|
||||
function addTextNode(text) {
|
||||
if (text)
|
||||
nodes.push(document.createTextNode(text));
|
||||
}
|
||||
function wrapExpr(expressionText) {
|
||||
if (expressionText)
|
||||
nodes.push.apply(nodes, ko_punches_interpolationMarkup.wrapExpression(expressionText, node));
|
||||
}
|
||||
parseInterpolationMarkup(node.nodeValue, addTextNode, wrapExpr)
|
||||
|
||||
if (nodes.length) {
|
||||
if (node.parentNode) {
|
||||
for (var i = 0, n = nodes.length, parent = node.parentNode; i < n; ++i) {
|
||||
parent.insertBefore(nodes[i], node);
|
||||
}
|
||||
parent.removeChild(node);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ko.virtualElements.allowedBindings.html) {
|
||||
// Virtual html binding
|
||||
// SO Question: http://stackoverflow.com/a/15348139
|
||||
var overridden = ko.bindingHandlers.html.update;
|
||||
ko.bindingHandlers.html.update = function (element, valueAccessor) {
|
||||
if (element.nodeType === 8) {
|
||||
var html = ko_unwrap(valueAccessor());
|
||||
if (html != null) {
|
||||
var parsedNodes = ko.utils.parseHtmlFragment('' + html);
|
||||
ko.virtualElements.setDomNodeChildren(element, parsedNodes);
|
||||
} else {
|
||||
ko.virtualElements.emptyNode(element);
|
||||
}
|
||||
} else {
|
||||
overridden(element, valueAccessor);
|
||||
}
|
||||
};
|
||||
ko.virtualElements.allowedBindings.html = true;
|
||||
}
|
||||
|
||||
function wrapExpression(expressionText, node) {
|
||||
var ownerDocument = node ? node.ownerDocument : document,
|
||||
closeComment = true,
|
||||
binding,
|
||||
firstChar = expressionText[0],
|
||||
lastChar = expressionText[expressionText.length - 1],
|
||||
result = [],
|
||||
matches;
|
||||
|
||||
if (firstChar === '#') {
|
||||
if (lastChar === '/') {
|
||||
binding = expressionText.slice(1, -1);
|
||||
} else {
|
||||
binding = expressionText.slice(1);
|
||||
closeComment = false;
|
||||
}
|
||||
if (matches = binding.match(/^([^,"'{}()\/:[\]\s]+)\s+([^\s:].*)/)) {
|
||||
binding = matches[1] + ':' + matches[2];
|
||||
}
|
||||
} else if (firstChar === '/') {
|
||||
// replace only with a closing comment
|
||||
} else if (firstChar === '{' && lastChar === '}') {
|
||||
binding = "html:" + trim(expressionText.slice(1, -1));
|
||||
} else {
|
||||
binding = "text:" + trim(expressionText);
|
||||
}
|
||||
|
||||
if (binding)
|
||||
result.push(ownerDocument.createComment("ko " + binding));
|
||||
if (closeComment)
|
||||
result.push(ownerDocument.createComment("/ko"));
|
||||
return result;
|
||||
};
|
||||
|
||||
function enableInterpolationMarkup() {
|
||||
addNodePreprocessor(interpolationMarkupPreprocessor);
|
||||
}
|
||||
|
||||
// Export the preprocessor functions
|
||||
var ko_punches_interpolationMarkup = ko_punches.interpolationMarkup = {
|
||||
preprocessor: interpolationMarkupPreprocessor,
|
||||
enable: enableInterpolationMarkup,
|
||||
wrapExpression: wrapExpression
|
||||
};
|
||||
|
||||
|
||||
var dataBind = 'data-bind';
|
||||
function attributeInterpolationMarkerPreprocessor(node) {
|
||||
if (node.nodeType === 1 && node.attributes.length) {
|
||||
var dataBindAttribute = node.getAttribute(dataBind);
|
||||
for (var attrs = ko.utils.arrayPushAll([], node.attributes), n = attrs.length, i = 0; i < n; ++i) {
|
||||
var attr = attrs[i];
|
||||
if (attr.specified && attr.name != dataBind && attr.value.indexOf('{{') !== -1) {
|
||||
var parts = [], attrValue = '';
|
||||
function addText(text) {
|
||||
if (text)
|
||||
parts.push('"' + text.replace(/"/g, '\\"') + '"');
|
||||
}
|
||||
function addExpr(expressionText) {
|
||||
if (expressionText) {
|
||||
attrValue = expressionText;
|
||||
parts.push('ko.unwrap(' + expressionText + ')');
|
||||
}
|
||||
}
|
||||
parseInterpolationMarkup(attr.value, addText, addExpr);
|
||||
|
||||
if (parts.length > 1) {
|
||||
attrValue = '""+' + parts.join('+');
|
||||
}
|
||||
|
||||
if (attrValue) {
|
||||
var attrName = attr.name.toLowerCase();
|
||||
var attrBinding = ko_punches_attributeInterpolationMarkup.attributeBinding(attrName, attrValue, node) || attributeBinding(attrName, attrValue, node);
|
||||
if (!dataBindAttribute) {
|
||||
dataBindAttribute = attrBinding
|
||||
} else {
|
||||
dataBindAttribute += ',' + attrBinding;
|
||||
}
|
||||
node.setAttribute(dataBind, dataBindAttribute);
|
||||
// Using removeAttribute instead of removeAttributeNode because IE clears the
|
||||
// class if you use removeAttributeNode to remove the id.
|
||||
node.removeAttribute(attr.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function attributeBinding(name, value, node) {
|
||||
if (ko.getBindingHandler(name)) {
|
||||
return name + ':' + value;
|
||||
} else {
|
||||
return 'attr.' + name + ':' + value;
|
||||
}
|
||||
}
|
||||
|
||||
function enableAttributeInterpolationMarkup() {
|
||||
addNodePreprocessor(attributeInterpolationMarkerPreprocessor);
|
||||
}
|
||||
|
||||
var ko_punches_attributeInterpolationMarkup = ko_punches.attributeInterpolationMarkup = {
|
||||
preprocessor: attributeInterpolationMarkerPreprocessor,
|
||||
enable: enableAttributeInterpolationMarkup,
|
||||
attributeBinding: attributeBinding
|
||||
};
|
||||
|
||||
return ko_punches;
|
||||
}));
|
||||
20
vendors/knockout-punches/knockout.punches.min.js
vendored
20
vendors/knockout-punches/knockout.punches.min.js
vendored
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
Knockout.Punches
|
||||
Enhanced binding syntaxes for Knockout 3+
|
||||
(c) Michael Best
|
||||
License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
Version 0.5.0
|
||||
*/
|
||||
(function(c){"function"===typeof define&&define.amd?define(["knockout"],c):c(ko)})(function(c){function k(a,b){return u(B(a),"preprocess",b)}function B(a){return"object"===typeof a?a:c.getBindingHandler(a)||(c.bindingHandlers[a]={})}function u(a,b,d){if(a[b]){var g=a[b];a[b]=function(a,b,c){if(a=g.call(this,a,b,c))return d.call(this,a,b,c)}}else a[b]=d;return a}function r(a){var b=c.bindingProvider.instance;if(b.preprocessNode){var d=b.preprocessNode;b.preprocessNode=function(b){var c=d.call(this,
|
||||
b);c||(c=a.call(this,b));return c}}else b.preprocessNode=a}function D(a,b){var d=c.getBindingHandler;c.getBindingHandler=function(g){var c;return d(g)||(c=g.match(a))&&b(c,g)}}function v(a){if(-1===a.indexOf("|"))return a;var b=a.match(/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|\|\||[|:]|[^\s|:"'][^|:"']*[^\s|:"']|[^\s|:"']/g);if(b&&1<b.length){b.push("|");a=b[0];for(var d,c,e=!1,f=!1,C=1;c=b[C];++C)"|"===c?(e&&(":"===d&&(a+="undefined"),a+=")"),e=f=!0):(f?a="ko.filters['"+c+"']("+a:e&&":"===c?(":"===d&&(a+=
|
||||
"undefined"),a+=","):a+=c,f=!1),d=c}return a}function w(a){k(a,v)}function x(a,b,d){function g(d){e[d]&&(e[d]=function(g,e){var h=Array.prototype.slice.call(arguments,0);h[1]=function(){var b={};b[a]=e();return b};return c.bindingHandlers[b][d].apply(this,h)})}var e=c.utils.extend({},this);g("init");g("update");e.preprocess&&(e.preprocess=null);c.virtualElements.allowedBindings[b]&&(c.virtualElements.allowedBindings[d]=!0);return e}function s(a,b){var d=c.getBindingHandler(a);if(d){var g=d.getNamespacedHandler||
|
||||
x;d.getNamespacedHandler=function(){return k(g.apply(this,arguments),b)}}}function E(a,b,d){if("{"!==a.charAt(0))return a;a=c.expressionRewriting.parseObjectLiteral(a);c.utils.arrayForEach(a,function(a){d(b+F+a.key,a.value)})}function p(a){k(a,E)}function m(a){return/^([$_a-z][$\w]*|.+(\.\s*[$_a-z][$\w]*|\[.+\]))$/i.test(a)?"function(_x,_y,_z){return("+a+")(_x,_y,_z);}":a}function t(a){k(a,m)}function q(a,b,d){a=B(a);a._propertyPreprocessors||(u(a,"preprocess",N),a._propertyPreprocessors={});u(a._propertyPreprocessors,
|
||||
b,d)}function N(a,b,d){if("{"!==a.charAt(0))return a;a=c.expressionRewriting.parseObjectLiteral(a);var g=[],e=this._propertyPreprocessors||{};c.utils.arrayForEach(a,function(a){var b=a.key;a=a.value;e[b]&&(a=e[b](a,b,d));a&&g.push("'"+b+"':"+a)});return"{"+g.join(",")+"}"}function y(a){return function(b){return"function("+a+"){return("+b+");}"}}function G(a,b,d){function c(a){var f=a.match(/^([\s\S]*)}}([\s\S]*?)\{\{([\s\S]*)$/);f?(c(f[1]),b(f[2]),d(f[3])):d(a)}if(a=a.match(/^([\s\S]*?)\{\{([\s\S]*)}}([\s\S]*)$/))b(a[1]),
|
||||
c(a[2]),b(a[3])}function z(a){return null==a?"":a.trim?a.trim():a.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")}function H(a){if(3===a.nodeType&&a.nodeValue&&-1!==a.nodeValue.indexOf("{{")&&"TEXTAREA"!=(a.parentNode||{}).nodeName){var b=[];G(a.nodeValue,function(a){a&&b.push(document.createTextNode(a))},function(d){d&&b.push.apply(b,O.wrapExpression(d,a))});if(b.length){if(a.parentNode){for(var d=0,c=b.length,e=a.parentNode;d<c;++d)e.insertBefore(b[d],a);e.removeChild(a)}return b}}}function I(){r(H)}
|
||||
function J(a){if(1===a.nodeType&&a.attributes.length)for(var b=a.getAttribute(A),d=c.utils.arrayPushAll([],a.attributes),g=d.length,e=0;e<g;++e){var f=d[e];if(f.specified&&f.name!=A&&-1!==f.value.indexOf("{{")){var h=[],n="";G(f.value,function(a){a&&h.push('"'+a.replace(/"/g,'\\"')+'"')},function(a){a&&(n=a,h.push("ko.unwrap("+a+")"))});1<h.length&&(n='""+'+h.join("+"));if(n){var k=f.name.toLowerCase(),k=P.attributeBinding(k,n,a)||K(k,n,a),b=b?b+(","+k):k;a.setAttribute(A,b);a.removeAttribute(f.name)}}}}
|
||||
function K(a,b,d){return c.getBindingHandler(a)?a+":"+b:"attr."+a+":"+b}function L(){r(J)}var l=c.unwrap,h=c.punches={utils:{addBindingPreprocessor:k,addNodePreprocessor:r,addBindingHandlerCreator:D,setBindingPreprocessor:k,setNodePreprocessor:r}};h.enableAll=function(){I();L();p("attr");p("css");p("event");p("style");w("text");w("html");s("attr",v);t("click");t("submit");t("optionsAfterRender");s("event",m);q("template","beforeRemove",m);q("template","afterAdd",m);q("template","afterRender",m)};
|
||||
c.filters={uppercase:function(a){return String.prototype.toUpperCase.call(l(a))},lowercase:function(a){return String.prototype.toLowerCase.call(l(a))},"default":function(a,b){a=l(a);return"function"===typeof a?a:"string"===typeof a?""===z(a)?b:a:null==a||0==a.length?b:a},replace:function(a,b,d){return String.prototype.replace.call(l(a),b,d)},fit:function(a,b,d,c){a=l(a);if(b&&(""+a).length>b)switch(d=""+(d||"..."),b-=d.length,a=""+a,c){case "left":return d+a.slice(-b);case "middle":return c=Math.ceil(b/
|
||||
2),a.substr(0,c)+d+a.slice(c-b);default:return a.substr(0,b)+d}else return a},json:function(a,b,d){return c.toJSON(a,d,b)},number:function(a){return(+l(a)).toLocaleString()}};h.textFilter={preprocessor:v,enableForBinding:w};var F=".";D(/([^\.]+)\.(.+)/,function(a,b){var d=a[1],g=c.bindingHandlers[d];if(g)return d=(g.getNamespacedHandler||x).call(g,a[2],d,b),c.bindingHandlers[b]=d});h.namespacedBinding={defaultGetHandler:x,setDefaultBindingPreprocessor:s,addDefaultBindingPreprocessor:s,preprocessor:E,
|
||||
enableForBinding:p};h.wrappedCallback={preprocessor:m,enableForBinding:t};h.preprocessBindingProperty={setPreprocessor:q,addPreprocessor:q};var M=y("$data,$event");h.expressionCallback={makePreprocessor:y,eventPreprocessor:M,enableForBinding:function(a,b){b=Array.prototype.slice.call(arguments,1).join();k(a,y(b))}};c.bindingHandlers.on={getNamespacedHandler:function(a){a=c.getBindingHandler("event"+F+a);return k(a,M)}};if(!c.virtualElements.allowedBindings.html){var Q=c.bindingHandlers.html.update;
|
||||
c.bindingHandlers.html.update=function(a,b){if(8===a.nodeType){var d=l(b());null!=d?(d=c.utils.parseHtmlFragment(""+d),c.virtualElements.setDomNodeChildren(a,d)):c.virtualElements.emptyNode(a)}else Q(a,b)};c.virtualElements.allowedBindings.html=!0}var O=h.interpolationMarkup={preprocessor:H,enable:I,wrapExpression:function(a,b){var d=b?b.ownerDocument:document,c=!0,e,f=a[0],h=a[a.length-1],k=[];if("#"===f){if("/"===h?e=a.slice(1,-1):(e=a.slice(1),c=!1),f=e.match(/^([^,"'{}()\/:[\]\s]+)\s+([^\s:].*)/))e=
|
||||
f[1]+":"+f[2]}else"/"!==f&&(e="{"===f&&"}"===h?"html:"+z(a.slice(1,-1)):"text:"+z(a));e&&k.push(d.createComment("ko "+e));c&&k.push(d.createComment("/ko"));return k}},A="data-bind",P=h.attributeInterpolationMarkup={preprocessor:J,enable:L,attributeBinding:K};return h});
|
||||
Loading…
Add table
Add a link
Reference in a new issue