diff --git a/404.html b/404.html new file mode 100644 index 0000000..99ff94f --- /dev/null +++ b/404.html @@ -0,0 +1,26 @@ + + + + + + +404 + + + + +

404,您请求的文件不存在!

+ + diff --git a/api.php b/api.php new file mode 100644 index 0000000..75c56b5 --- /dev/null +++ b/api.php @@ -0,0 +1,825 @@ +model('reply'); +load()->model('attachment'); +load()->app('common'); +load()->classs('wesession'); +$hash = $_GPC['hash']; +if (!empty($hash)) { + $id = pdo_fetchcolumn("SELECT acid FROM " . tablename('account') . " WHERE hash = :hash", array(':hash' => $hash)); +} +if (!empty($_GPC['appid'])) { + $appid = ltrim($_GPC['appid'], '/'); + if ($appid == 'wx570bc396a51b8ff8') { + $_W['account'] = array( + 'type' => '3', + 'key' => 'wx570bc396a51b8ff8', + 'level' => 4, + 'token' => 'platformtestaccount' + ); + } else { + $id = pdo_fetchcolumn("SELECT acid FROM " . tablename('account_wechats') . " WHERE `key` = :appid", array(':appid' => $appid)); + if (empty($id)) { + $id = table('account_wxapp')->where('key', $appid)->getcolumn('acid'); + } + } +} +if (empty($id)) { + $id = intval($_GPC['id']); +} +if (!empty($id)) { + $uniacid = pdo_getcolumn('account', array('acid' => $id), 'uniacid'); + $_W['account'] = $_W['uniaccount'] = uni_fetch($uniacid); +} +if (empty($_W['account'])) { + exit('initial error hash or id'); +} +if (empty($_W['account']['token'])) { + exit('initial missing token'); +} +$_W['debug'] = intval($_GPC['debug']); +$_W['acid'] = $_W['account']['acid']; +$_W['uniacid'] = $_W['account']['uniacid']; +$_W['account']['groupid'] = $_W['uniaccount']['groupid']; +$_W['account']['qrcode'] = $_W['attachurl'] . 'qrcode_' . $_W['acid'] . '.jpg?time=' . $_W['timestamp']; +$_W['account']['avatar'] = $_W['attachurl'] . 'headimg_' . $_W['acid'] . '.jpg?time=' . $_W['timestamp']; +$_W['attachurl'] = attachment_set_attach_url(); + +//register_shutdown_function('visit_update_today', 'app', 'we7_api'); + +$engine = new WeEngine(); +if (!empty($_W['setting']['copyright']['status'])) { + $engine->died('抱歉,站点已关闭,关闭原因:' . $_W['setting']['copyright']['reason']); +} +if (!empty($_W['uniaccount']['endtime']) && TIMESTAMP > $_W['uniaccount']['endtime'] && !in_array($_W['uniaccount']['endtime'], array(USER_ENDTIME_GROUP_EMPTY_TYPE, USER_ENDTIME_GROUP_UNLIMIT_TYPE))) { + $engine->died('抱歉,您的公众号已过期,请及时联系管理员'); +} + +if ($_W['isajax'] && $_W['ispost'] && $_GPC['flag'] == 1) { + $engine->encrypt(); +} +if ($_W['isajax'] && $_W['ispost'] && $_GPC['flag'] == 2) { + $engine->decrypt(); +} +$_W['isajax'] = false; +$engine->start(); + + +class WeEngine +{ + + private $account = null; + + private $modules = array(); + + public $keyword = array(); + + public $message = array(); + + + public function __construct() + { + global $_W; + $this->account = WeAccount::create($_W['account']); + if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') { + $this->modules = ['weliam_smartcity']; + $this->modules[] = 'cover'; + $this->modules[] = 'default'; + $this->modules[] = 'reply'; + } + } + + + public function encrypt() + { + global $_W; + if (empty($this->account)) { + exit('Miss Account.'); + } + $timestamp = TIMESTAMP; + $nonce = random(5); + $token = $_W['account']['token']; + $signkey = array($token, TIMESTAMP, $nonce); + sort($signkey, SORT_STRING); + $signString = implode($signkey); + $signString = sha1($signString); + + $_GET['timestamp'] = $timestamp; + $_GET['nonce'] = $nonce; + $_GET['signature'] = $signString; + $postStr = file_get_contents('php://input'); + if (!empty($_W['account']['encodingaeskey']) && strlen($_W['account']['encodingaeskey']) == 43 && !empty($_W['account']['key']) && $_W['setting']['development'] != 1) { + $data = $this->account->encryptMsg($postStr); + $array = array('encrypt_type' => 'aes', 'timestamp' => $timestamp, 'nonce' => $nonce, 'signature' => $signString, 'msg_signature' => $data[0], 'msg' => $data[1]); + } else { + $data = array('', ''); + $array = array('encrypt_type' => '', 'timestamp' => $timestamp, 'nonce' => $nonce, 'signature' => $signString, 'msg_signature' => $data[0], 'msg' => $data[1]); + } + exit(json_encode($array)); + } + + + public function decrypt() + { + global $_W; + if (empty($this->account)) { + exit('Miss Account.'); + } + $postStr = file_get_contents('php://input'); + if (!empty($_W['account']['encodingaeskey']) && strlen($_W['account']['encodingaeskey']) == 43 && !empty($_W['account']['key']) && $_W['setting']['development'] != 1) { + $resp = $this->account->local_decryptMsg($postStr); + } else { + $resp = $postStr; + } + exit($resp); + } + + + public function start() + { + global $_W; + if (empty($this->account)) { + exit('Miss Account.'); + } + if (!$this->account->checkSign()) { + exit('Check Sign Fail.'); + } + if (strtolower($_SERVER['REQUEST_METHOD']) == 'get') { + $row = array(); + $row['isconnect'] = 1; + pdo_update('account', $row, array('uniacid' => $_W['uniacid'])); + cache_delete(cache_system_key('uniaccount', array('uniacid' => $_W['uniacid']))); + exit(htmlspecialchars($_GET['echostr'])); + } + if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') { + $postStr = file_get_contents('php://input'); + if (!empty($_GET['encrypt_type']) && $_GET['encrypt_type'] == 'aes') { + $postStr = $this->account->decryptMsg($postStr); + } + WeUtility::logging('trace', $postStr); + $message = $this->account->parse($postStr); + + $this->message = $message; + if (empty($message)) { + WeUtility::logging('waring', 'Request Failed'); + exit('Request Failed'); + } + if (in_array($message['event'], array('weapp_audit_success', 'weapp_audit_fail', 'weapp_audit_delay'))) { + $this->weapp_audit(); + exit('success'); + } + $_W['openid'] = $message['from']; + $_W['fans'] = array('from_user' => $_W['openid']); + $this->booking($message); + if ($message['event'] == 'unsubscribe') { + $this->receive(array(), array(), array()); + exit(); + } + $sessionid = md5($message['from'] . $message['to'] . $_W['uniacid']); + session_id($sessionid); + WeSession::start($_W['uniacid'], $_W['openid']); + + $_SESSION['openid'] = $_W['openid']; + $pars = $this->analyze($message); + $pars[] = array( + 'message' => $message, + 'module' => 'default', + 'rule' => '-1', + ); + $hitParam['rule'] = -2; + $hitParam['module'] = ''; + $hitParam['message'] = $message; + + $hitKeyword = array(); + $response = array(); + foreach ($pars as $par) { + if (empty($par['module'])) { + continue; + } + $par['message'] = $message; + $response = $this->process($par); + if ($this->isValidResponse($response)) { + $hitParam = $par; + if (!empty($par['keyword'])) { + $hitKeyword = $par['keyword']; + } + break; + } + } + $response_debug = $response; + $pars_debug = $pars; + if ($hitParam['module'] == 'default' && is_array($response) && is_array($response['params'])) { + foreach ($response['params'] as $par) { + if (empty($par['module'])) { + continue; + } + $response = $this->process($par); + if ($this->isValidResponse($response)) { + $hitParam = $par; + if (!empty($par['keyword'])) { + $hitKeyword = $par['keyword']; + } + break; + } + } + } + WeUtility::logging('params', var_export($hitParam, true)); + WeUtility::logging('response', $response); + $resp = $this->account->response($response); + if (!empty($_GET['encrypt_type']) && $_GET['encrypt_type'] == 'aes') { + $resp = $this->account->encryptMsg($resp); + $resp = $this->account->xmlDetract($resp); + } + if ($resp !== 'success') { + $mapping = array( + '[from]' => $this->message['from'], + '[to]' => $this->message['to'], + '[rule]' => $this->params['rule'] + ); + $resp = str_replace(array_keys($mapping), array_values($mapping), $resp); + } + + $reply_times_info = (array)$_SESSION['__reply_times']; + if ($reply_times_info['content'] == $message['content']) { + $new_times = intval($reply_times_info['times']) + 1; + } else { + $new_times = 1; + } + $_SESSION['__reply_times'] = array('content' => $message['content'], 'date' => date('Y-m-d'), 'times' => $new_times); + ob_start(); + echo $resp; + ob_start(); + $this->receive($hitParam, $hitKeyword, $response); + ob_end_clean(); + exit(); + } + WeUtility::logging('waring', 'Request Failed'); + exit('Request Failed'); + } + + private function isValidResponse($response) + { + if ($response === 'success') { + return true; + } + if (is_array($response)) { + if ($response['type'] == 'text' && !empty($response['content'])) { + return true; + } + if ($response['type'] == 'news' && !empty($response['items'])) { + return true; + } + if (!in_array($response['type'], array('text', 'news', 'image'))) { + return true; + } + } + return false; + } + + + private function booking($message) + { + global $_W; + if ($message['event'] == 'unsubscribe' || $message['event'] == 'subscribe') { + $todaystat = pdo_get('stat_fans', array('date' => date('Ymd'), 'uniacid' => $_W['uniacid'])); + if ($message['event'] == 'unsubscribe') { + if (empty($todaystat)) { + $updatestat = array( + 'new' => 0, + 'uniacid' => $_W['uniacid'], + 'cancel' => 1, + 'cumulate' => 0, + 'date' => date('Ymd'), + ); + pdo_insert('stat_fans', $updatestat); + } else { + $updatestat = array( + 'cancel' => $todaystat['cancel'] + 1, + ); + pdo_update('stat_fans', $updatestat, array('id' => $todaystat['id'])); + } + } elseif ($message['event'] == 'subscribe') { + if (empty($todaystat)) { + $updatestat = array( + 'new' => 1, + 'uniacid' => $_W['uniacid'], + 'cancel' => 0, + 'cumulate' => 0, + 'date' => date('Ymd'), + ); + pdo_insert('stat_fans', $updatestat); + } else { + $updatestat = array( + 'new' => $todaystat['new'] + 1, + ); + pdo_update('stat_fans', $updatestat, array('id' => $todaystat['id'])); + } + } + } + + load()->model('mc'); + $setting = uni_setting($_W['uniacid'], array('passport')); + $fans = mc_fansinfo($message['from']); + $default_groupid = cache_load(cache_system_key('defaultgroupid', array('uniacid' => $_W['uniacid']))); + if (empty($default_groupid)) { + $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid'])); + cache_write(cache_system_key('defaultgroupid', array('uniacid' => $_W['uniacid'])), $default_groupid); + } + if (!empty($fans)) { + if ($message['event'] == 'unsubscribe') { + cache_build_memberinfo($fans['uid']); + pdo_update('mc_mapping_fans', array('follow' => 0, 'unfollowtime' => TIMESTAMP), array('fanid' => $fans['fanid'])); + pdo_delete('mc_fans_tag_mapping', array('fanid' => $fans['fanid'])); + } elseif ($message['event'] != 'ShakearoundUserShake' && $message['type'] != 'trace') { + $rec = array(); + if (empty($fans['follow'])) { + $rec['follow'] = 1; + $rec['followtime'] = $message['time']; + } + $member = array(); + if (!empty($fans['uid'])) { + $member = mc_fetch($fans['uid']); + } + if (empty($member)) { + if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) { + $data = array( + 'uniacid' => $_W['uniacid'], + 'email' => md5($message['from']) . '@we7.cc', + 'salt' => random(8), + 'groupid' => $default_groupid, + 'createtime' => TIMESTAMP, + ); + $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']); + pdo_insert('mc_members', $data); + $rec['uid'] = pdo_insertid(); + } + } + if (!empty($rec)) { + pdo_update('mc_mapping_fans', $rec, array('openid' => $message['from'])); + } + } + } else { + if ($message['event'] == 'subscribe' || $message['type'] == 'text' || $message['type'] == 'image') { + load()->model('mc'); + $force_init_member = false; + if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) { + $force_init_member = true; + } + mc_init_fans_info($message['from'], $force_init_member); + } + } + } + + private function receive($par, $keyword, $response) + { + global $_W; + fastcgi_finish_request(); + + $subscribe = cache_load(cache_system_key('module_receive_enable')); + if (empty($subscribe)) { + $subscribe = cache_build_module_subscribe_type(); + } + $modules = uni_modules(); + $obj = WeUtility::createModuleReceiver('core'); + $obj->message = $this->message; + $obj->params = $par; + $obj->response = $response; + $obj->keyword = $keyword; + $obj->module = 'core'; + $obj->uniacid = $_W['uniacid']; + $obj->acid = $_W['acid']; + if (method_exists($obj, 'receive')) { + @$obj->receive(); + } + load()->func('communication'); + if ((empty($subscribe[$this->message['type']]) || $this->message['type'] == 'event') && !empty($this->message['event'])) { + $subscribe[$this->message['type']] = $subscribe[strtolower($this->message['event'])]; + } + if (!empty($subscribe[$this->message['type']])) { + foreach ($subscribe[$this->message['type']] as $modulename) { + if (!in_array($modulename, array_keys($modules))) { + continue; + } + $params = array( + 'i' => $GLOBALS['uniacid'], + 'modulename' => $modulename, + 'request' => json_encode($par), + 'response' => json_encode($response), + 'message' => json_encode($this->message), + ); + $response = ihttp_request(wurl('utility/subscribe/receive'), $params, array(), 10); + if (is_error($response) || $response['code'] != 200) { + $response = ihttp_request($_W['siteroot'] . 'web/' . wurl('utility/subscribe/receive'), $params, array(), 10); + } + } + } + } + + + private function analyze(&$message) + { + global $_W; + $params = array(); + if (in_array($message['type'], array('event', 'qr'))) { + $params = call_user_func_array(array($this, 'analyze' . $message['type']), array(&$message)); + if (!empty($params)) { + return (array)$params; + } + } + if (!empty($_SESSION['__contextmodule']) && in_array($_SESSION['__contextmodule'], $this->modules)) { + if ($_SESSION['__contextexpire'] > TIMESTAMP) { + $params[] = array( + 'message' => $message, + 'module' => $_SESSION['__contextmodule'], + 'rule' => $_SESSION['__contextrule'], + 'priority' => $_SESSION['__contextpriority'], + 'context' => true + ); + return $params; + } else { + unset($_SESSION); + session_destroy(); + } + } + + $reply_times_info = (array)$_SESSION['__reply_times']; + if (!empty($_W['account']['setting']) && !empty($reply_times_info) && intval($_W['account']['setting']['reply_setting']) > 0 && strtotime($reply_times_info['date']) >= strtotime(date('Y-m-d')) && $reply_times_info['times'] >= $_W['account']['setting']['reply_setting'] && $reply_times_info['content'] == $message['content']) { + exit('success'); + } + + if (method_exists($this, 'analyze' . $message['type'])) { + $temp = call_user_func_array(array($this, 'analyze' . $message['type']), array(&$message)); + if (!empty($temp) && is_array($temp)) { + $params += $temp; + } + } else { + $params += $this->handler($message['type']); + } + return $params; + } + + private function analyzeSubscribe(&$message) + { + global $_W; + $params = array(); + $message['type'] = 'text'; + $message['redirection'] = true; + if (!empty($message['scene'])) { + $message['source'] = 'qr'; + $sceneid = trim($message['scene']); + if (is_numeric($sceneid)) { + $scene_condition = " `qrcid` = :sceneid"; + } else { + $scene_condition = " `scene_str` = :sceneid"; + } + $condition = array(':sceneid' => $sceneid, ':uniacid' => $_W['uniacid']); + $qr = pdo_fetch("SELECT `id`, `keyword` FROM " . tablename('qrcode') . " WHERE {$scene_condition} AND `uniacid` = :uniacid", $condition); + if (!empty($qr)) { + $message['content'] = $qr['keyword']; + if (!empty($qr['type']) && $qr['type'] == 'scene') { + $message['msgtype'] = 'text'; + } + $params += $this->analyzeText($message); + return $params; + } + } + $message['source'] = 'subscribe'; + $setting = uni_setting($_W['uniacid'], array('welcome')); + if (!empty($setting['welcome'])) { + $message['content'] = $setting['welcome']; + $params += $this->analyzeText($message); + } + + return $params; + } + + private function analyzeQR(&$message) + { + global $_W; + $params = array(); + $default_message = $message; + $message['type'] = 'text'; + $message['redirection'] = true; + if (!empty($message['scene'])) { + $message['source'] = 'qr'; + $sceneid = trim($message['scene']); + if (is_numeric($sceneid)) { + $scene_condition = " `qrcid` = :sceneid"; + } else { + $scene_condition = " `scene_str` = :sceneid"; + } + $condition_params = array(':sceneid' => $sceneid, ':uniacid' => $_W['uniacid']); + $qr = pdo_fetch("SELECT `id`, `keyword` FROM " . tablename('qrcode') . " WHERE {$scene_condition} AND `uniacid` = :uniacid AND `type` = 'scene'", $condition_params); + + } + if (empty($qr) && !empty($message['ticket'])) { + $message['source'] = 'qr'; + $ticket = trim($message['ticket']); + if (!empty($ticket)) { + $qr = pdo_fetchall("SELECT `id`, `keyword` FROM " . tablename('qrcode') . " WHERE `uniacid` = :uniacid AND ticket = :ticket", array(':uniacid' => $_W['uniacid'], ':ticket' => $ticket)); + if (!empty($qr)) { + if (count($qr) != 1) { + $qr = array(); + } else { + $qr = $qr[0]; + } + } + } + } + if (!empty($qr)) { + $message['content'] = $qr['keyword']; + if (!empty($qr['type']) && $qr['type'] == 'scene') { + $message['msgtype'] = 'text'; + } + $params += $this->analyzeText($message); + } + if (empty($qr)) { + $params = $this->handler($default_message['type']); + if (!empty($params)) { + $message = $default_message; + return $params; + } + } + if (empty($params)) { + $params = $this->handler($message['type']); + } + return $params; + } + + public function analyzeText(&$message, $order = 0) + { + global $_W; + + $pars = array(); + + $order = intval($order); + if (!isset($message['content'])) { + return $pars; + } + $cachekey = cache_system_key('keyword', array('content' => md5($message['content']), 'uniacid' => $_W['uniacid'])); + $keyword_cache = cache_load($cachekey); + if (!empty($keyword_cache) && $keyword_cache['expire'] > TIMESTAMP) { + foreach ($keyword_cache['data'] as $key => &$value) { + $value['message'] = $message; + } + unset($value); + return $keyword_cache['data']; + } + $condition = << 0) { + $condition .= " AND `displayorder` > :order"; + $params[':order'] = $order; + } + + $keywords = reply_keywords_search($condition, $params); + if (empty($keywords)) { + return $pars; + } + + $system_module_reply = true; + foreach ($keywords as $keyword) { + if (!in_array($keyword['module'], array('defalut', 'cover', 'reply'))) { + $system_module_reply = false; + } + $params = array( + 'message' => $message, + 'module' => $keyword['module'], + 'rule' => $keyword['rid'], + 'priority' => $keyword['displayorder'], + 'keyword' => $keyword, + 'reply_type' => $keyword['reply_type'] + ); + $pars[] = $params; + } + if (!empty($system_module_reply)) { + $cache = array( + 'data' => $pars, + 'expire' => TIMESTAMP + 5 * 60, + ); + cache_write($cachekey, $cache); + } + return $pars; + } + + private function analyzeEvent(&$message) + { + $event = strtolower($message['event']); + if ($event == 'subscribe') { + return $this->analyzeSubscribe($message); + } + if ($event == 'click') { + $message['content'] = strval($message['eventkey']); + return $this->analyzeClick($message); + } + if (in_array($event, array('pic_photo_or_album', 'pic_weixin', 'pic_sysphoto'))) { + pdo_delete('menu_event', array('createtime <' => $GLOBALS['_W']['timestamp'] - 100, 'openid' => $message['from']), 'OR'); + if (!empty($message['sendpicsinfo']['count'])) { + foreach ($message['sendpicsinfo']['piclist'] as $item) { + pdo_insert('menu_event', array( + 'uniacid' => $GLOBALS['_W']['uniacid'], + 'keyword' => $message['eventkey'], + 'type' => $message['event'], + 'picmd5' => $item, + 'openid' => $message['from'], + 'createtime' => TIMESTAMP, + )); + } + } else { + pdo_insert('menu_event', array( + 'uniacid' => $GLOBALS['_W']['uniacid'], + 'keyword' => $message['eventkey'], + 'type' => $message['event'], + 'picmd5' => $item, + 'openid' => $message['from'], + 'createtime' => TIMESTAMP, + )); + } + $message['content'] = strval($message['eventkey']); + $message['source'] = $message['event']; + return $this->analyzeText($message); + } + if (!empty($message['eventkey'])) { + $message['content'] = strval($message['eventkey']); + $message['type'] = 'text'; + $message['redirection'] = true; + $message['source'] = $message['event']; + return $this->analyzeText($message); + } + return $this->handler($message['event']); + } + + private function analyzeClick(&$message) + { + if (!empty($message['content']) || $message['content'] !== '') { + $message['type'] = 'text'; + $message['redirection'] = true; + $message['source'] = 'click'; + return $this->analyzeText($message); + } + + return array(); + } + + private function analyzeImage(&$message) + { + load()->func('communication'); + if (!empty($message['picurl'])) { + $response = ihttp_get($message['picurl']); + if (!empty($response)) { + $md5 = md5($response['content']); + $event = pdo_get('menu_event', array('picmd5' => $md5), array('keyword', 'type')); + if (!empty($event['keyword'])) { + pdo_delete('menu_event', array('picmd5' => $md5)); + } else { + $event = pdo_get('menu_event', array('openid' => $message['from']), array('keyword', 'type')); + } + if (!empty($event)) { + $message['content'] = $event['keyword']; + $message['eventkey'] = $event['keyword']; + $message['type'] = 'text'; + $message['event'] = $event['type']; + $message['redirection'] = true; + $message['source'] = $event['type']; + return $this->analyzeText($message); + } + } + return $this->handler('image'); + } + } + + private function analyzeVoice(&$message) + { + $params = $this->handler('voice'); + if (empty($params) && !empty($message['recognition'])) { + $message['type'] = 'text'; + $message['redirection'] = true; + $message['source'] = 'voice'; + $message['content'] = $message['recognition']; + return $this->analyzeText($message); + } else { + return $params; + } + } + + + private function handler($type) + { + if (empty($type)) { + return array(); + } + global $_W; + $params = array(); + $setting = uni_setting($_W['uniacid'], array('default_message')); + $default_message = $setting['default_message']; + if (is_array($default_message) && !empty($default_message[$type]['type'])) { + if ($default_message[$type]['type'] == 'keyword') { + $message = $this->message; + $message['type'] = 'text'; + $message['redirection'] = true; + $message['source'] = $type; + $message['content'] = $default_message[$type]['keyword']; + return $this->analyzeText($message); + } else { + $params[] = array( + 'message' => $this->message, + 'module' => is_array($default_message[$type]) ? $default_message[$type]['module'] : $default_message[$type], + 'rule' => '-1', + ); + return $params; + } + } + return array(); + } + + + private function process($param) + { + global $_W; + if (empty($param['module']) || !in_array($param['module'], $this->modules)) { + return false; + } + if ($param['module'] == 'reply') { + $processor = WeUtility::createModuleProcessor('core'); + } else { + $processor = WeUtility::createModuleProcessor($param['module']); + } + $processor->message = $param['message']; + $processor->rule = $param['rule']; + $processor->reply_type = $param['reply_type']; + $processor->priority = intval($param['priority']); + $processor->inContext = $param['context'] === true; + $response = $processor->respond(); + if (empty($response)) { + return false; + } + + return $response; + } + + + public function died($content = '') + { + global $_W, $engine; + if (empty($content)) { + exit(''); + } + $response['FromUserName'] = $engine->message['to']; + $response['ToUserName'] = $engine->message['from']; + $response['MsgType'] = 'text'; + $response['Content'] = htmlspecialchars_decode($content); + $response['CreateTime'] = TIMESTAMP; + $response['FuncFlag'] = 0; + $xml = array2xml($response); + if (!empty($_GET['encrypt_type']) && $_GET['encrypt_type'] == 'aes') { + $resp = $engine->account->encryptMsg($xml); + $resp = $engine->account->xmlDetract($resp); + } else { + $resp = $xml; + } + exit($resp); + } + + public function weapp_audit() + { + $wxapp_register_version_table = table('wxapp_register_version'); + $wxapp_register_version = $wxapp_register_version_table->getWithAccountWxappOriginal($this->message['to']); + if (empty($wxapp_register_version)) { + return false; + } + switch ($this->message['event']) { + case 'weapp_audit_success': + $data = array('status' => WXAPP_REGISTER_VERSION_STATUS_CHECKSUCCESS, 'reason' => ''); + break; + case 'weapp_audit_fail': + $data = array('status' => WXAPP_REGISTER_VERSION_STATUS_CHECKFAIL, 'reason' => $this->message['reason']); + break; + default: + $data = array(); + break; + } + if ($data) { + $wxapp_register_version_table->where('id', $wxapp_register_version['id'])->fill($data)->save(); + } + return true; + } +} \ No newline at end of file diff --git a/framework/library/phpexcel/PHPExcel/Autoloader.php b/framework/library/phpexcel/PHPExcel/Autoloader.php new file mode 100644 index 0000000..25aa38d --- /dev/null +++ b/framework/library/phpexcel/PHPExcel/Autoloader.php @@ -0,0 +1,85 @@ +_horizontal = NULL; + $this->_vertical = NULL; + $this->_textRotation = NULL; + } + } + + /** + * Get the shared style component for the currently active cell in currently active sheet. + * Only used for style supervisor + * + * @return PHPExcel_Style_Alignment + */ + public function getSharedComponent() + { + return $this->_parent->getSharedComponent()->getAlignment(); + } + + /** + * Build style array from subcomponents + * + * @param array $array + * @return array + */ + public function getStyleArray($array) + { + return array('alignment' => $array); + } + + /** + * Apply styles from array + * + * + * $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray( + * array( + * 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, + * 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, + * 'rotation' => 0, + * 'wrap' => TRUE + * ) + * ); + * + * + * @param array $pStyles Array containing style information + * @throws PHPExcel_Exception + * @return PHPExcel_Style_Alignment + */ + public function applyFromArray($pStyles = NULL) { + if (is_array($pStyles)) { + if ($this->_isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells()) + ->applyFromArray($this->getStyleArray($pStyles)); + } else { + if (isset($pStyles['horizontal'])) { + $this->setHorizontal($pStyles['horizontal']); + } + if (isset($pStyles['vertical'])) { + $this->setVertical($pStyles['vertical']); + } + if (isset($pStyles['rotation'])) { + $this->setTextRotation($pStyles['rotation']); + } + if (isset($pStyles['wrap'])) { + $this->setWrapText($pStyles['wrap']); + } + if (isset($pStyles['shrinkToFit'])) { + $this->setShrinkToFit($pStyles['shrinkToFit']); + } + if (isset($pStyles['indent'])) { + $this->setIndent($pStyles['indent']); + } + } + } else { + throw new PHPExcel_Exception("Invalid style array passed."); + } + return $this; + } + + /** + * Get Horizontal + * + * @return string + */ + public function getHorizontal() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getHorizontal(); + } + return $this->_horizontal; + } + + /** + * Set Horizontal + * + * @param string $pValue + * @return PHPExcel_Style_Alignment + */ + public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) { + if ($pValue == '') { + $pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; + } + + if ($this->_isSupervisor) { + $styleArray = $this->getStyleArray(array('horizontal' => $pValue)); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } + else { + $this->_horizontal = $pValue; + } + return $this; + } + + /** + * Get Vertical + * + * @return string + */ + public function getVertical() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getVertical(); + } + return $this->_vertical; + } + + /** + * Set Vertical + * + * @param string $pValue + * @return PHPExcel_Style_Alignment + */ + public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM) { + if ($pValue == '') { + $pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; + } + + if ($this->_isSupervisor) { + $styleArray = $this->getStyleArray(array('vertical' => $pValue)); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_vertical = $pValue; + } + return $this; + } + + /** + * Get TextRotation + * + * @return int + */ + public function getTextRotation() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getTextRotation(); + } + return $this->_textRotation; + } + + /** + * Set TextRotation + * + * @param int $pValue + * @throws PHPExcel_Exception + * @return PHPExcel_Style_Alignment + */ + public function setTextRotation($pValue = 0) { + // Excel2007 value 255 => PHPExcel value -165 + if ($pValue == 255) { + $pValue = -165; + } + + // Set rotation + if ( ($pValue >= -90 && $pValue <= 90) || $pValue == -165 ) { + if ($this->_isSupervisor) { + $styleArray = $this->getStyleArray(array('rotation' => $pValue)); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_textRotation = $pValue; + } + } else { + throw new PHPExcel_Exception("Text rotation should be a value between -90 and 90."); + } + + return $this; + } + + /** + * Get Wrap Text + * + * @return boolean + */ + public function getWrapText() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getWrapText(); + } + return $this->_wrapText; + } + + /** + * Set Wrap Text + * + * @param boolean $pValue + * @return PHPExcel_Style_Alignment + */ + public function setWrapText($pValue = FALSE) { + if ($pValue == '') { + $pValue = FALSE; + } + if ($this->_isSupervisor) { + $styleArray = $this->getStyleArray(array('wrap' => $pValue)); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_wrapText = $pValue; + } + return $this; + } + + /** + * Get Shrink to fit + * + * @return boolean + */ + public function getShrinkToFit() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getShrinkToFit(); + } + return $this->_shrinkToFit; + } + + /** + * Set Shrink to fit + * + * @param boolean $pValue + * @return PHPExcel_Style_Alignment + */ + public function setShrinkToFit($pValue = FALSE) { + if ($pValue == '') { + $pValue = FALSE; + } + if ($this->_isSupervisor) { + $styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue)); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_shrinkToFit = $pValue; + } + return $this; + } + + /** + * Get indent + * + * @return int + */ + public function getIndent() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getIndent(); + } + return $this->_indent; + } + + /** + * Set indent + * + * @param int $pValue + * @return PHPExcel_Style_Alignment + */ + public function setIndent($pValue = 0) { + if ($pValue > 0) { + if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && + $this->getHorizontal() != self::HORIZONTAL_LEFT && + $this->getHorizontal() != self::HORIZONTAL_RIGHT) { + $pValue = 0; // indent not supported + } + } + if ($this->_isSupervisor) { + $styleArray = $this->getStyleArray(array('indent' => $pValue)); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_indent = $pValue; + } + return $this; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getHashCode(); + } + return md5( + $this->_horizontal + . $this->_vertical + . $this->_textRotation + . ($this->_wrapText ? 't' : 'f') + . ($this->_shrinkToFit ? 't' : 'f') + . $this->_indent + . __CLASS__ + ); + } + +} diff --git a/framework/library/phpexcel/PHPExcel/Style/Border.php b/framework/library/phpexcel/PHPExcel/Style/Border.php new file mode 100644 index 0000000..cadfdc5 --- /dev/null +++ b/framework/library/phpexcel/PHPExcel/Style/Border.php @@ -0,0 +1,294 @@ +_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor); + + // bind parent if we are a supervisor + if ($isSupervisor) { + $this->_color->bindParent($this, '_color'); + } + } + + /** + * Bind parent. Only used for supervisor + * + * @param PHPExcel_Style_Borders $parent + * @param string $parentPropertyName + * @return PHPExcel_Style_Border + */ + public function bindParent($parent, $parentPropertyName=NULL) + { + $this->_parent = $parent; + $this->_parentPropertyName = $parentPropertyName; + return $this; + } + + /** + * Get the shared style component for the currently active cell in currently active sheet. + * Only used for style supervisor + * + * @return PHPExcel_Style_Border + * @throws PHPExcel_Exception + */ + public function getSharedComponent() + { + switch ($this->_parentPropertyName) { + case '_allBorders': + case '_horizontal': + case '_inside': + case '_outline': + case '_vertical': + throw new PHPExcel_Exception('Cannot get shared component for a pseudo-border.'); + break; + case '_bottom': + return $this->_parent->getSharedComponent()->getBottom(); break; + case '_diagonal': + return $this->_parent->getSharedComponent()->getDiagonal(); break; + case '_left': + return $this->_parent->getSharedComponent()->getLeft(); break; + case '_right': + return $this->_parent->getSharedComponent()->getRight(); break; + case '_top': + return $this->_parent->getSharedComponent()->getTop(); break; + + } + } + + /** + * Build style array from subcomponents + * + * @param array $array + * @return array + */ + public function getStyleArray($array) + { + switch ($this->_parentPropertyName) { + case '_allBorders': + $key = 'allborders'; break; + case '_bottom': + $key = 'bottom'; break; + case '_diagonal': + $key = 'diagonal'; break; + case '_horizontal': + $key = 'horizontal'; break; + case '_inside': + $key = 'inside'; break; + case '_left': + $key = 'left'; break; + case '_outline': + $key = 'outline'; break; + case '_right': + $key = 'right'; break; + case '_top': + $key = 'top'; break; + case '_vertical': + $key = 'vertical'; break; + } + return $this->_parent->getStyleArray(array($key => $array)); + } + + /** + * Apply styles from array + * + * + * $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray( + * array( + * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ) + * ); + * + * + * @param array $pStyles Array containing style information + * @throws PHPExcel_Exception + * @return PHPExcel_Style_Border + */ + public function applyFromArray($pStyles = null) { + if (is_array($pStyles)) { + if ($this->_isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); + } else { + if (isset($pStyles['style'])) { + $this->setBorderStyle($pStyles['style']); + } + if (isset($pStyles['color'])) { + $this->getColor()->applyFromArray($pStyles['color']); + } + } + } else { + throw new PHPExcel_Exception("Invalid style array passed."); + } + return $this; + } + + /** + * Get Border style + * + * @return string + */ + public function getBorderStyle() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getBorderStyle(); + } + return $this->_borderStyle; + } + + /** + * Set Border style + * + * @param string|boolean $pValue + * When passing a boolean, FALSE equates PHPExcel_Style_Border::BORDER_NONE + * and TRUE to PHPExcel_Style_Border::BORDER_MEDIUM + * @return PHPExcel_Style_Border + */ + public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) { + + if (empty($pValue)) { + $pValue = PHPExcel_Style_Border::BORDER_NONE; + } elseif(is_bool($pValue) && $pValue) { + $pValue = PHPExcel_Style_Border::BORDER_MEDIUM; + } + if ($this->_isSupervisor) { + $styleArray = $this->getStyleArray(array('style' => $pValue)); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_borderStyle = $pValue; + } + return $this; + } + + /** + * Get Border Color + * + * @return PHPExcel_Style_Color + */ + public function getColor() { + return $this->_color; + } + + /** + * Set Border Color + * + * @param PHPExcel_Style_Color $pValue + * @throws PHPExcel_Exception + * @return PHPExcel_Style_Border + */ + public function setColor(PHPExcel_Style_Color $pValue = null) { + // make sure parameter is a real color and not a supervisor + $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; + + if ($this->_isSupervisor) { + $styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB())); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_color = $color; + } + return $this; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getHashCode(); + } + return md5( + $this->_borderStyle + . $this->_color->getHashCode() + . __CLASS__ + ); + } + +} diff --git a/framework/library/phpexcel/PHPExcel/Style/Borders.php b/framework/library/phpexcel/PHPExcel/Style/Borders.php new file mode 100644 index 0000000..ce25ad8 --- /dev/null +++ b/framework/library/phpexcel/PHPExcel/Style/Borders.php @@ -0,0 +1,424 @@ +_left = new PHPExcel_Style_Border($isSupervisor, $isConditional); + $this->_right = new PHPExcel_Style_Border($isSupervisor, $isConditional); + $this->_top = new PHPExcel_Style_Border($isSupervisor, $isConditional); + $this->_bottom = new PHPExcel_Style_Border($isSupervisor, $isConditional); + $this->_diagonal = new PHPExcel_Style_Border($isSupervisor, $isConditional); + $this->_diagonalDirection = PHPExcel_Style_Borders::DIAGONAL_NONE; + + // Specially for supervisor + if ($isSupervisor) { + // Initialize pseudo-borders + $this->_allBorders = new PHPExcel_Style_Border(TRUE); + $this->_outline = new PHPExcel_Style_Border(TRUE); + $this->_inside = new PHPExcel_Style_Border(TRUE); + $this->_vertical = new PHPExcel_Style_Border(TRUE); + $this->_horizontal = new PHPExcel_Style_Border(TRUE); + + // bind parent if we are a supervisor + $this->_left->bindParent($this, '_left'); + $this->_right->bindParent($this, '_right'); + $this->_top->bindParent($this, '_top'); + $this->_bottom->bindParent($this, '_bottom'); + $this->_diagonal->bindParent($this, '_diagonal'); + $this->_allBorders->bindParent($this, '_allBorders'); + $this->_outline->bindParent($this, '_outline'); + $this->_inside->bindParent($this, '_inside'); + $this->_vertical->bindParent($this, '_vertical'); + $this->_horizontal->bindParent($this, '_horizontal'); + } + } + + /** + * Get the shared style component for the currently active cell in currently active sheet. + * Only used for style supervisor + * + * @return PHPExcel_Style_Borders + */ + public function getSharedComponent() + { + return $this->_parent->getSharedComponent()->getBorders(); + } + + /** + * Build style array from subcomponents + * + * @param array $array + * @return array + */ + public function getStyleArray($array) + { + return array('borders' => $array); + } + + /** + * Apply styles from array + * + * + * $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( + * array( + * 'bottom' => array( + * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ), + * 'top' => array( + * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ) + * ) + * ); + * + * + * $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( + * array( + * 'allborders' => array( + * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ) + * ) + * ); + * + * + * @param array $pStyles Array containing style information + * @throws PHPExcel_Exception + * @return PHPExcel_Style_Borders + */ + public function applyFromArray($pStyles = null) { + if (is_array($pStyles)) { + if ($this->_isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); + } else { + if (array_key_exists('left', $pStyles)) { + $this->getLeft()->applyFromArray($pStyles['left']); + } + if (array_key_exists('right', $pStyles)) { + $this->getRight()->applyFromArray($pStyles['right']); + } + if (array_key_exists('top', $pStyles)) { + $this->getTop()->applyFromArray($pStyles['top']); + } + if (array_key_exists('bottom', $pStyles)) { + $this->getBottom()->applyFromArray($pStyles['bottom']); + } + if (array_key_exists('diagonal', $pStyles)) { + $this->getDiagonal()->applyFromArray($pStyles['diagonal']); + } + if (array_key_exists('diagonaldirection', $pStyles)) { + $this->setDiagonalDirection($pStyles['diagonaldirection']); + } + if (array_key_exists('allborders', $pStyles)) { + $this->getLeft()->applyFromArray($pStyles['allborders']); + $this->getRight()->applyFromArray($pStyles['allborders']); + $this->getTop()->applyFromArray($pStyles['allborders']); + $this->getBottom()->applyFromArray($pStyles['allborders']); + } + } + } else { + throw new PHPExcel_Exception("Invalid style array passed."); + } + return $this; + } + + /** + * Get Left + * + * @return PHPExcel_Style_Border + */ + public function getLeft() { + return $this->_left; + } + + /** + * Get Right + * + * @return PHPExcel_Style_Border + */ + public function getRight() { + return $this->_right; + } + + /** + * Get Top + * + * @return PHPExcel_Style_Border + */ + public function getTop() { + return $this->_top; + } + + /** + * Get Bottom + * + * @return PHPExcel_Style_Border + */ + public function getBottom() { + return $this->_bottom; + } + + /** + * Get Diagonal + * + * @return PHPExcel_Style_Border + */ + public function getDiagonal() { + return $this->_diagonal; + } + + /** + * Get AllBorders (pseudo-border). Only applies to supervisor. + * + * @return PHPExcel_Style_Border + * @throws PHPExcel_Exception + */ + public function getAllBorders() { + if (!$this->_isSupervisor) { + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); + } + return $this->_allBorders; + } + + /** + * Get Outline (pseudo-border). Only applies to supervisor. + * + * @return boolean + * @throws PHPExcel_Exception + */ + public function getOutline() { + if (!$this->_isSupervisor) { + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); + } + return $this->_outline; + } + + /** + * Get Inside (pseudo-border). Only applies to supervisor. + * + * @return boolean + * @throws PHPExcel_Exception + */ + public function getInside() { + if (!$this->_isSupervisor) { + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); + } + return $this->_inside; + } + + /** + * Get Vertical (pseudo-border). Only applies to supervisor. + * + * @return PHPExcel_Style_Border + * @throws PHPExcel_Exception + */ + public function getVertical() { + if (!$this->_isSupervisor) { + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); + } + return $this->_vertical; + } + + /** + * Get Horizontal (pseudo-border). Only applies to supervisor. + * + * @return PHPExcel_Style_Border + * @throws PHPExcel_Exception + */ + public function getHorizontal() { + if (!$this->_isSupervisor) { + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); + } + return $this->_horizontal; + } + + /** + * Get DiagonalDirection + * + * @return int + */ + public function getDiagonalDirection() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getDiagonalDirection(); + } + return $this->_diagonalDirection; + } + + /** + * Set DiagonalDirection + * + * @param int $pValue + * @return PHPExcel_Style_Borders + */ + public function setDiagonalDirection($pValue = PHPExcel_Style_Borders::DIAGONAL_NONE) { + if ($pValue == '') { + $pValue = PHPExcel_Style_Borders::DIAGONAL_NONE; + } + if ($this->_isSupervisor) { + $styleArray = $this->getStyleArray(array('diagonaldirection' => $pValue)); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_diagonalDirection = $pValue; + } + return $this; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getHashcode(); + } + return md5( + $this->getLeft()->getHashCode() + . $this->getRight()->getHashCode() + . $this->getTop()->getHashCode() + . $this->getBottom()->getHashCode() + . $this->getDiagonal()->getHashCode() + . $this->getDiagonalDirection() + . __CLASS__ + ); + } + +} diff --git a/framework/library/phpexcel/PHPExcel/Worksheet/AutoFilter.php b/framework/library/phpexcel/PHPExcel/Worksheet/AutoFilter.php new file mode 100644 index 0000000..5d253fb --- /dev/null +++ b/framework/library/phpexcel/PHPExcel/Worksheet/AutoFilter.php @@ -0,0 +1,858 @@ +_range = $pRange; + $this->_workSheet = $pSheet; + } + + /** + * Get AutoFilter Parent Worksheet + * + * @return PHPExcel_Worksheet + */ + public function getParent() { + return $this->_workSheet; + } + + /** + * Set AutoFilter Parent Worksheet + * + * @param PHPExcel_Worksheet $pSheet + * @return PHPExcel_Worksheet_AutoFilter + */ + public function setParent(PHPExcel_Worksheet $pSheet = NULL) { + $this->_workSheet = $pSheet; + + return $this; + } + + /** + * Get AutoFilter Range + * + * @return string + */ + public function getRange() { + return $this->_range; + } + + /** + * Set AutoFilter Range + * + * @param string $pRange Cell range (i.e. A1:E10) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet_AutoFilter + */ + public function setRange($pRange = '') { + // Uppercase coordinate + $cellAddress = explode('!',strtoupper($pRange)); + if (count($cellAddress) > 1) { + list($worksheet,$pRange) = $cellAddress; + } + + if (strpos($pRange,':') !== FALSE) { + $this->_range = $pRange; + } elseif(empty($pRange)) { + $this->_range = ''; + } else { + throw new PHPExcel_Exception('Autofilter must be set on a range of cells.'); + } + + if (empty($pRange)) { + // Discard all column rules + $this->_columns = array(); + } else { + // Discard any column rules that are no longer valid within this range + list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); + foreach($this->_columns as $key => $value) { + $colIndex = PHPExcel_Cell::columnIndexFromString($key); + if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) { + unset($this->_columns[$key]); + } + } + } + + return $this; + } + + /** + * Get all AutoFilter Columns + * + * @throws PHPExcel_Exception + * @return array of PHPExcel_Worksheet_AutoFilter_Column + */ + public function getColumns() { + return $this->_columns; + } + + /** + * Validate that the specified column is in the AutoFilter range + * + * @param string $column Column name (e.g. A) + * @throws PHPExcel_Exception + * @return integer The column offset within the autofilter range + */ + public function testColumnInRange($column) { + if (empty($this->_range)) { + throw new PHPExcel_Exception("No autofilter range is defined."); + } + + $columnIndex = PHPExcel_Cell::columnIndexFromString($column); + list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); + if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) { + throw new PHPExcel_Exception("Column is outside of current autofilter range."); + } + + return $columnIndex - $rangeStart[0]; + } + + /** + * Get a specified AutoFilter Column Offset within the defined AutoFilter range + * + * @param string $pColumn Column name (e.g. A) + * @throws PHPExcel_Exception + * @return integer The offset of the specified column within the autofilter range + */ + public function getColumnOffset($pColumn) { + return $this->testColumnInRange($pColumn); + } + + /** + * Get a specified AutoFilter Column + * + * @param string $pColumn Column name (e.g. A) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet_AutoFilter_Column + */ + public function getColumn($pColumn) { + $this->testColumnInRange($pColumn); + + if (!isset($this->_columns[$pColumn])) { + $this->_columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this); + } + + return $this->_columns[$pColumn]; + } + + /** + * Get a specified AutoFilter Column by it's offset + * + * @param integer $pColumnOffset Column offset within range (starting from 0) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet_AutoFilter_Column + */ + public function getColumnByOffset($pColumnOffset = 0) { + list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); + $pColumn = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1); + + return $this->getColumn($pColumn); + } + + /** + * Set AutoFilter + * + * @param PHPExcel_Worksheet_AutoFilter_Column|string $pColumn + * A simple string containing a Column ID like 'A' is permitted + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet_AutoFilter + */ + public function setColumn($pColumn) + { + if ((is_string($pColumn)) && (!empty($pColumn))) { + $column = $pColumn; + } elseif(is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) { + $column = $pColumn->getColumnIndex(); + } else { + throw new PHPExcel_Exception("Column is not within the autofilter range."); + } + $this->testColumnInRange($column); + + if (is_string($pColumn)) { + $this->_columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this); + } elseif(is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) { + $pColumn->setParent($this); + $this->_columns[$column] = $pColumn; + } + ksort($this->_columns); + + return $this; + } + + /** + * Clear a specified AutoFilter Column + * + * @param string $pColumn Column name (e.g. A) + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet_AutoFilter + */ + public function clearColumn($pColumn) { + $this->testColumnInRange($pColumn); + + if (isset($this->_columns[$pColumn])) { + unset($this->_columns[$pColumn]); + } + + return $this; + } + + /** + * Shift an AutoFilter Column Rule to a different column + * + * Note: This method bypasses validation of the destination column to ensure it is within this AutoFilter range. + * Nor does it verify whether any column rule already exists at $toColumn, but will simply overrideany existing value. + * Use with caution. + * + * @param string $fromColumn Column name (e.g. A) + * @param string $toColumn Column name (e.g. B) + * @return PHPExcel_Worksheet_AutoFilter + */ + public function shiftColumn($fromColumn=NULL,$toColumn=NULL) { + $fromColumn = strtoupper($fromColumn); + $toColumn = strtoupper($toColumn); + + if (($fromColumn !== NULL) && (isset($this->_columns[$fromColumn])) && ($toColumn !== NULL)) { + $this->_columns[$fromColumn]->setParent(); + $this->_columns[$fromColumn]->setColumnIndex($toColumn); + $this->_columns[$toColumn] = $this->_columns[$fromColumn]; + $this->_columns[$toColumn]->setParent($this); + unset($this->_columns[$fromColumn]); + + ksort($this->_columns); + } + + return $this; + } + + + /** + * Test if cell value is in the defined set of values + * + * @param mixed $cellValue + * @param mixed[] $dataSet + * @return boolean + */ + private static function _filterTestInSimpleDataSet($cellValue,$dataSet) + { + $dataSetValues = $dataSet['filterValues']; + $blanks = $dataSet['blanks']; + if (($cellValue == '') || ($cellValue === NULL)) { + return $blanks; + } + return in_array($cellValue,$dataSetValues); + } + + /** + * Test if cell value is in the defined set of Excel date values + * + * @param mixed $cellValue + * @param mixed[] $dataSet + * @return boolean + */ + private static function _filterTestInDateGroupSet($cellValue,$dataSet) + { + $dateSet = $dataSet['filterValues']; + $blanks = $dataSet['blanks']; + if (($cellValue == '') || ($cellValue === NULL)) { + return $blanks; + } + + if (is_numeric($cellValue)) { + $dateValue = PHPExcel_Shared_Date::ExcelToPHP($cellValue); + if ($cellValue < 1) { + // Just the time part + $dtVal = date('His',$dateValue); + $dateSet = $dateSet['time']; + } elseif($cellValue == floor($cellValue)) { + // Just the date part + $dtVal = date('Ymd',$dateValue); + $dateSet = $dateSet['date']; + } else { + // date and time parts + $dtVal = date('YmdHis',$dateValue); + $dateSet = $dateSet['dateTime']; + } + foreach($dateSet as $dateValue) { + // Use of substr to extract value at the appropriate group level + if (substr($dtVal,0,strlen($dateValue)) == $dateValue) + return TRUE; + } + } + + return FALSE; + } + + /** + * Test if cell value is within a set of values defined by a ruleset + * + * @param mixed $cellValue + * @param mixed[] $ruleSet + * @return boolean + */ + private static function _filterTestInCustomDataSet($cellValue, $ruleSet) + { + $dataSet = $ruleSet['filterRules']; + $join = $ruleSet['join']; + $customRuleForBlanks = isset($ruleSet['customRuleForBlanks']) ? $ruleSet['customRuleForBlanks'] : FALSE; + + if (!$customRuleForBlanks) { + // Blank cells are always ignored, so return a FALSE + if (($cellValue == '') || ($cellValue === NULL)) { + return FALSE; + } + } + $returnVal = ($join == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND); + foreach($dataSet as $rule) { + if (is_numeric($rule['value'])) { + // Numeric values are tested using the appropriate operator + switch ($rule['operator']) { + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL : + $retVal = ($cellValue == $rule['value']); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL : + $retVal = ($cellValue != $rule['value']); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN : + $retVal = ($cellValue > $rule['value']); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL : + $retVal = ($cellValue >= $rule['value']); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN : + $retVal = ($cellValue < $rule['value']); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL : + $retVal = ($cellValue <= $rule['value']); + break; + } + } elseif($rule['value'] == '') { + switch ($rule['operator']) { + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL : + $retVal = (($cellValue == '') || ($cellValue === NULL)); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL : + $retVal = (($cellValue != '') && ($cellValue !== NULL)); + break; + default : + $retVal = TRUE; + break; + } + } else { + // String values are always tested for equality, factoring in for wildcards (hence a regexp test) + $retVal = preg_match('/^'.$rule['value'].'$/i',$cellValue); + } + // If there are multiple conditions, then we need to test both using the appropriate join operator + switch ($join) { + case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR : + $returnVal = $returnVal || $retVal; + // Break as soon as we have a TRUE match for OR joins, + // to avoid unnecessary additional code execution + if ($returnVal) + return $returnVal; + break; + case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND : + $returnVal = $returnVal && $retVal; + break; + } + } + + return $returnVal; + } + + /** + * Test if cell date value is matches a set of values defined by a set of months + * + * @param mixed $cellValue + * @param mixed[] $monthSet + * @return boolean + */ + private static function _filterTestInPeriodDateSet($cellValue, $monthSet) + { + // Blank cells are always ignored, so return a FALSE + if (($cellValue == '') || ($cellValue === NULL)) { + return FALSE; + } + + if (is_numeric($cellValue)) { + $dateValue = date('m',PHPExcel_Shared_Date::ExcelToPHP($cellValue)); + if (in_array($dateValue,$monthSet)) { + return TRUE; + } + } + + return FALSE; + } + + /** + * Search/Replace arrays to convert Excel wildcard syntax to a regexp syntax for preg_matching + * + * @var array + */ + private static $_fromReplace = array('\*', '\?', '~~', '~.*', '~.?'); + private static $_toReplace = array('.*', '.', '~', '\*', '\?'); + + + /** + * Convert a dynamic rule daterange to a custom filter range expression for ease of calculation + * + * @param string $dynamicRuleType + * @param PHPExcel_Worksheet_AutoFilter_Column &$filterColumn + * @return mixed[] + */ + private function _dynamicFilterDateRange($dynamicRuleType, &$filterColumn) + { + $rDateType = PHPExcel_Calculation_Functions::getReturnDateType(); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); + $val = $maxVal = NULL; + + $ruleValues = array(); + $baseDate = PHPExcel_Calculation_DateTime::DATENOW(); + // Calculate start/end dates for the required date range based on current date + switch ($dynamicRuleType) { + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK : + $baseDate = strtotime('-7 days',$baseDate); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK : + $baseDate = strtotime('-7 days',$baseDate); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH : + $baseDate = strtotime('-1 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH : + $baseDate = strtotime('+1 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER : + $baseDate = strtotime('-3 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER : + $baseDate = strtotime('+3 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR : + $baseDate = strtotime('-1 year',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR : + $baseDate = strtotime('+1 year',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); + break; + } + + switch ($dynamicRuleType) { + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW : + $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day',$baseDate)); + $val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE : + $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day',$baseDate)); + $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y',$baseDate))); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR : + $maxVal = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,31,12,date('Y',$baseDate))); + ++$maxVal; + $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y',$baseDate))); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER : + $thisMonth = date('m',$baseDate); + $thisQuarter = floor(--$thisMonth / 3); + $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t',$baseDate),(1+$thisQuarter)*3,date('Y',$baseDate))); + ++$maxVal; + $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1+$thisQuarter*3,date('Y',$baseDate))); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH : + $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t',$baseDate),date('m',$baseDate),date('Y',$baseDate))); + ++$maxVal; + $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK : + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK : + $dayOfWeek = date('w',$baseDate); + $val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate) - $dayOfWeek; + $maxVal = $val + 7; + break; + } + + switch ($dynamicRuleType) { + // Adjust Today dates for Yesterday and Tomorrow + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY : + --$maxVal; + --$val; + break; + case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW : + ++$maxVal; + ++$val; + break; + } + + // Set the filter column rule attributes ready for writing + $filterColumn->setAttributes(array( 'val' => $val, + 'maxVal' => $maxVal + ) + ); + + // Set the rules for identifying rows for hide/show + $ruleValues[] = array( 'operator' => PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL, + 'value' => $val + ); + $ruleValues[] = array( 'operator' => PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN, + 'value' => $maxVal + ); + PHPExcel_Calculation_Functions::setReturnDateType($rDateType); + + return array( + 'method' => '_filterTestInCustomDataSet', + 'arguments' => array( 'filterRules' => $ruleValues, + 'join' => PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND + ) + ); + } + + private function _calculateTopTenValue($columnID,$startRow,$endRow,$ruleType,$ruleValue) { + $range = $columnID.$startRow.':'.$columnID.$endRow; + $dataValues = PHPExcel_Calculation_Functions::flattenArray( + $this->_workSheet->rangeToArray($range,NULL,TRUE,FALSE) + ); + + $dataValues = array_filter($dataValues); + if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) { + rsort($dataValues); + } else { + sort($dataValues); + } + + return array_pop(array_slice($dataValues,0,$ruleValue)); + } + + /** + * Apply the AutoFilter rules to the AutoFilter Range + * + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet_AutoFilter + */ + public function showHideRows() + { + list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); + + // The heading row should always be visible +// echo 'AutoFilter Heading Row ',$rangeStart[1],' is always SHOWN',PHP_EOL; + $this->_workSheet->getRowDimension($rangeStart[1])->setVisible(TRUE); + + $columnFilterTests = array(); + foreach($this->_columns as $columnID => $filterColumn) { + $rules = $filterColumn->getRules(); + switch ($filterColumn->getFilterType()) { + case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER : + $ruleValues = array(); + // Build a list of the filter value selections + foreach($rules as $rule) { + $ruleType = $rule->getRuleType(); + $ruleValues[] = $rule->getValue(); + } + // Test if we want to include blanks in our filter criteria + $blanks = FALSE; + $ruleDataSet = array_filter($ruleValues); + if (count($ruleValues) != count($ruleDataSet)) + $blanks = TRUE; + if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER) { + // Filter on absolute values + $columnFilterTests[$columnID] = array( + 'method' => '_filterTestInSimpleDataSet', + 'arguments' => array( 'filterValues' => $ruleDataSet, + 'blanks' => $blanks + ) + ); + } else { + // Filter on date group values + $arguments = array(); + foreach($ruleDataSet as $ruleValue) { + $date = $time = ''; + if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) && + ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')) + $date .= sprintf('%04d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]); + if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) && + ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')) + $date .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]); + if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) && + ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')) + $date .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]); + if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) && + ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')) + $time .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]); + if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) && + ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')) + $time .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]); + if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) && + ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')) + $time .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]); + $dateTime = $date . $time; + $arguments['date'][] = $date; + $arguments['time'][] = $time; + $arguments['dateTime'][] = $dateTime; + } + // Remove empty elements + $arguments['date'] = array_filter($arguments['date']); + $arguments['time'] = array_filter($arguments['time']); + $arguments['dateTime'] = array_filter($arguments['dateTime']); + $columnFilterTests[$columnID] = array( + 'method' => '_filterTestInDateGroupSet', + 'arguments' => array( 'filterValues' => $arguments, + 'blanks' => $blanks + ) + ); + } + break; + case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER : + $customRuleForBlanks = FALSE; + $ruleValues = array(); + // Build a list of the filter value selections + foreach($rules as $rule) { + $ruleType = $rule->getRuleType(); + $ruleValue = $rule->getValue(); + if (!is_numeric($ruleValue)) { + // Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards + $ruleValue = preg_quote($ruleValue); + $ruleValue = str_replace(self::$_fromReplace,self::$_toReplace,$ruleValue); + if (trim($ruleValue) == '') { + $customRuleForBlanks = TRUE; + $ruleValue = trim($ruleValue); + } + } + $ruleValues[] = array( 'operator' => $rule->getOperator(), + 'value' => $ruleValue + ); + } + $join = $filterColumn->getJoin(); + $columnFilterTests[$columnID] = array( + 'method' => '_filterTestInCustomDataSet', + 'arguments' => array( 'filterRules' => $ruleValues, + 'join' => $join, + 'customRuleForBlanks' => $customRuleForBlanks + ) + ); + break; + case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER : + $ruleValues = array(); + foreach($rules as $rule) { + // We should only ever have one Dynamic Filter Rule anyway + $dynamicRuleType = $rule->getGrouping(); + if (($dynamicRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) || + ($dynamicRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE)) { + // Number (Average) based + // Calculate the average + $averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')'; + $average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula,NULL,$this->_workSheet->getCell('A1')); + // Set above/below rule based on greaterThan or LessTan + $operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) + ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN + : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN; + $ruleValues[] = array( 'operator' => $operator, + 'value' => $average + ); + $columnFilterTests[$columnID] = array( + 'method' => '_filterTestInCustomDataSet', + 'arguments' => array( 'filterRules' => $ruleValues, + 'join' => PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR + ) + ); + } else { + // Date based + if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') { + // Month or Quarter + sscanf($dynamicRuleType,'%[A-Z]%d', $periodType, $period); + if ($periodType == 'M') { + $ruleValues = array($period); + } else { + --$period; + $periodEnd = (1+$period)*3; + $periodStart = 1+$period*3; + $ruleValues = range($periodStart,periodEnd); + } + $columnFilterTests[$columnID] = array( + 'method' => '_filterTestInPeriodDateSet', + 'arguments' => $ruleValues + ); + $filterColumn->setAttributes(array()); + } else { + // Date Range + $columnFilterTests[$columnID] = $this->_dynamicFilterDateRange($dynamicRuleType, $filterColumn); + break; + } + } + } + break; + case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER : + $ruleValues = array(); + $dataRowCount = $rangeEnd[1] - $rangeStart[1]; + foreach($rules as $rule) { + // We should only ever have one Dynamic Filter Rule anyway + $toptenRuleType = $rule->getGrouping(); + $ruleValue = $rule->getValue(); + $ruleOperator = $rule->getOperator(); + } + if ($ruleOperator === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) { + $ruleValue = floor($ruleValue * ($dataRowCount / 100)); + } + if ($ruleValue < 1) $ruleValue = 1; + if ($ruleValue > 500) $ruleValue = 500; + + $maxVal = $this->_calculateTopTenValue($columnID,$rangeStart[1]+1,$rangeEnd[1],$toptenRuleType,$ruleValue); + + $operator = ($toptenRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) + ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL + : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL; + $ruleValues[] = array( 'operator' => $operator, + 'value' => $maxVal + ); + $columnFilterTests[$columnID] = array( + 'method' => '_filterTestInCustomDataSet', + 'arguments' => array( 'filterRules' => $ruleValues, + 'join' => PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR + ) + ); + $filterColumn->setAttributes( + array('maxVal' => $maxVal) + ); + break; + } + } + +// echo 'Column Filter Test CRITERIA',PHP_EOL; +// var_dump($columnFilterTests); +// + // Execute the column tests for each row in the autoFilter range to determine show/hide, + for ($row = $rangeStart[1]+1; $row <= $rangeEnd[1]; ++$row) { +// echo 'Testing Row = ',$row,PHP_EOL; + $result = TRUE; + foreach($columnFilterTests as $columnID => $columnFilterTest) { +// echo 'Testing cell ',$columnID.$row,PHP_EOL; + $cellValue = $this->_workSheet->getCell($columnID.$row)->getCalculatedValue(); +// echo 'Value is ',$cellValue,PHP_EOL; + // Execute the filter test + $result = $result && + call_user_func_array( + array('PHPExcel_Worksheet_AutoFilter',$columnFilterTest['method']), + array( + $cellValue, + $columnFilterTest['arguments'] + ) + ); +// echo (($result) ? 'VALID' : 'INVALID'),PHP_EOL; + // If filter test has resulted in FALSE, exit the loop straightaway rather than running any more tests + if (!$result) + break; + } + // Set show/hide for the row based on the result of the autoFilter result +// echo (($result) ? 'SHOW' : 'HIDE'),PHP_EOL; + $this->_workSheet->getRowDimension($row)->setVisible($result); + } + + return $this; + } + + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + if ($key == '_workSheet') { + // Detach from worksheet + $this->{$key} = NULL; + } else { + $this->{$key} = clone $value; + } + } elseif ((is_array($value)) && ($key == '_columns')) { + // The columns array of PHPExcel_Worksheet_AutoFilter objects + $this->{$key} = array(); + foreach ($value as $k => $v) { + $this->{$key}[$k] = clone $v; + // attach the new cloned Column to this new cloned Autofilter object + $this->{$key}[$k]->setParent($this); + } + } else { + $this->{$key} = $value; + } + } + } + + /** + * toString method replicates previous behavior by returning the range if object is + * referenced as a property of its parent. + */ + public function __toString() { + return (string) $this->_range; + } + +} diff --git a/framework/library/phpexcel/PHPExcel/Worksheet/BaseDrawing.php b/framework/library/phpexcel/PHPExcel/Worksheet/BaseDrawing.php new file mode 100644 index 0000000..dc598ab --- /dev/null +++ b/framework/library/phpexcel/PHPExcel/Worksheet/BaseDrawing.php @@ -0,0 +1,485 @@ +_name = ''; + $this->_description = ''; + $this->_worksheet = null; + $this->_coordinates = 'A1'; + $this->_offsetX = 0; + $this->_offsetY = 0; + $this->_width = 0; + $this->_height = 0; + $this->_resizeProportional = true; + $this->_rotation = 0; + $this->_shadow = new PHPExcel_Worksheet_Drawing_Shadow(); + + // Set image index + self::$_imageCounter++; + $this->_imageIndex = self::$_imageCounter; + } + + /** + * Get image index + * + * @return int + */ + public function getImageIndex() { + return $this->_imageIndex; + } + + /** + * Get Name + * + * @return string + */ + public function getName() { + return $this->_name; + } + + /** + * Set Name + * + * @param string $pValue + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setName($pValue = '') { + $this->_name = $pValue; + return $this; + } + + /** + * Get Description + * + * @return string + */ + public function getDescription() { + return $this->_description; + } + + /** + * Set Description + * + * @param string $pValue + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setDescription($pValue = '') { + $this->_description = $pValue; + return $this; + } + + /** + * Get Worksheet + * + * @return PHPExcel_Worksheet + */ + public function getWorksheet() { + return $this->_worksheet; + } + + /** + * Set Worksheet + * + * @param PHPExcel_Worksheet $pValue + * @param bool $pOverrideOld If a Worksheet has already been assigned, overwrite it and remove image from old Worksheet? + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setWorksheet(PHPExcel_Worksheet $pValue = null, $pOverrideOld = false) { + if (is_null($this->_worksheet)) { + // Add drawing to PHPExcel_Worksheet + $this->_worksheet = $pValue; + $this->_worksheet->getCell($this->_coordinates); + $this->_worksheet->getDrawingCollection()->append($this); + } else { + if ($pOverrideOld) { + // Remove drawing from old PHPExcel_Worksheet + $iterator = $this->_worksheet->getDrawingCollection()->getIterator(); + + while ($iterator->valid()) { + if ($iterator->current()->getHashCode() == $this->getHashCode()) { + $this->_worksheet->getDrawingCollection()->offsetUnset( $iterator->key() ); + $this->_worksheet = null; + break; + } + } + + // Set new PHPExcel_Worksheet + $this->setWorksheet($pValue); + } else { + throw new PHPExcel_Exception("A PHPExcel_Worksheet has already been assigned. Drawings can only exist on one PHPExcel_Worksheet."); + } + } + return $this; + } + + /** + * Get Coordinates + * + * @return string + */ + public function getCoordinates() { + return $this->_coordinates; + } + + /** + * Set Coordinates + * + * @param string $pValue + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setCoordinates($pValue = 'A1') { + $this->_coordinates = $pValue; + return $this; + } + + /** + * Get OffsetX + * + * @return int + */ + public function getOffsetX() { + return $this->_offsetX; + } + + /** + * Set OffsetX + * + * @param int $pValue + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setOffsetX($pValue = 0) { + $this->_offsetX = $pValue; + return $this; + } + + /** + * Get OffsetY + * + * @return int + */ + public function getOffsetY() { + return $this->_offsetY; + } + + /** + * Set OffsetY + * + * @param int $pValue + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setOffsetY($pValue = 0) { + $this->_offsetY = $pValue; + return $this; + } + + /** + * Get Width + * + * @return int + */ + public function getWidth() { + return $this->_width; + } + + /** + * Set Width + * + * @param int $pValue + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setWidth($pValue = 0) { + // Resize proportional? + if ($this->_resizeProportional && $pValue != 0) { + $ratio = $this->_height / $this->_width; + $this->_height = round($ratio * $pValue); + } + + // Set width + $this->_width = $pValue; + + return $this; + } + + /** + * Get Height + * + * @return int + */ + public function getHeight() { + return $this->_height; + } + + /** + * Set Height + * + * @param int $pValue + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setHeight($pValue = 0) { + // Resize proportional? + if ($this->_resizeProportional && $pValue != 0) { + $ratio = $this->_width / $this->_height; + $this->_width = round($ratio * $pValue); + } + + // Set height + $this->_height = $pValue; + + return $this; + } + + /** + * Set width and height with proportional resize + * Example: + * + * $objDrawing->setResizeProportional(true); + * $objDrawing->setWidthAndHeight(160,120); + * + * + * @author Vincent@luo MSN:kele_100@hotmail.com + * @param int $width + * @param int $height + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setWidthAndHeight($width = 0, $height = 0) { + $xratio = $width / $this->_width; + $yratio = $height / $this->_height; + if ($this->_resizeProportional && !($width == 0 || $height == 0)) { + if (($xratio * $this->_height) < $height) { + $this->_height = ceil($xratio * $this->_height); + $this->_width = $width; + } else { + $this->_width = ceil($yratio * $this->_width); + $this->_height = $height; + } + } + return $this; + } + + /** + * Get ResizeProportional + * + * @return boolean + */ + public function getResizeProportional() { + return $this->_resizeProportional; + } + + /** + * Set ResizeProportional + * + * @param boolean $pValue + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setResizeProportional($pValue = true) { + $this->_resizeProportional = $pValue; + return $this; + } + + /** + * Get Rotation + * + * @return int + */ + public function getRotation() { + return $this->_rotation; + } + + /** + * Set Rotation + * + * @param int $pValue + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setRotation($pValue = 0) { + $this->_rotation = $pValue; + return $this; + } + + /** + * Get Shadow + * + * @return PHPExcel_Worksheet_Drawing_Shadow + */ + public function getShadow() { + return $this->_shadow; + } + + /** + * Set Shadow + * + * @param PHPExcel_Worksheet_Drawing_Shadow $pValue + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet_BaseDrawing + */ + public function setShadow(PHPExcel_Worksheet_Drawing_Shadow $pValue = null) { + $this->_shadow = $pValue; + return $this; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_name + . $this->_description + . $this->_worksheet->getHashCode() + . $this->_coordinates + . $this->_offsetX + . $this->_offsetY + . $this->_width + . $this->_height + . $this->_rotation + . $this->_shadow->getHashCode() + . __CLASS__ + ); + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } +} diff --git a/framework/library/phpexcel/PHPExcel/Writer/Abstract.php b/framework/library/phpexcel/PHPExcel/Writer/Abstract.php new file mode 100644 index 0000000..ec19aa0 --- /dev/null +++ b/framework/library/phpexcel/PHPExcel/Writer/Abstract.php @@ -0,0 +1,158 @@ +_includeCharts; + } + + /** + * Set write charts in workbook + * Set to true, to advise the Writer to include any charts that exist in the PHPExcel object. + * Set to false (the default) to ignore charts. + * + * @param boolean $pValue + * @return PHPExcel_Writer_IWriter + */ + public function setIncludeCharts($pValue = FALSE) { + $this->_includeCharts = (boolean) $pValue; + return $this; + } + + /** + * Get Pre-Calculate Formulas flag + * If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, + * so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet + * viewer when opening the file + * If false, then formulae are not calculated on save. This is faster for saving in PHPExcel, but slower + * when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself + * + * @return boolean + */ + public function getPreCalculateFormulas() { + return $this->_preCalculateFormulas; + } + + /** + * Set Pre-Calculate Formulas + * Set to true (the default) to advise the Writer to calculate all formulae on save + * Set to false to prevent precalculation of formulae on save. + * + * @param boolean $pValue Pre-Calculate Formulas? + * @return PHPExcel_Writer_IWriter + */ + public function setPreCalculateFormulas($pValue = TRUE) { + $this->_preCalculateFormulas = (boolean) $pValue; + return $this; + } + + /** + * Get use disk caching where possible? + * + * @return boolean + */ + public function getUseDiskCaching() { + return $this->_useDiskCaching; + } + + /** + * Set use disk caching where possible? + * + * @param boolean $pValue + * @param string $pDirectory Disk caching directory + * @throws PHPExcel_Writer_Exception when directory does not exist + * @return PHPExcel_Writer_Excel2007 + */ + public function setUseDiskCaching($pValue = FALSE, $pDirectory = NULL) { + $this->_useDiskCaching = $pValue; + + if ($pDirectory !== NULL) { + if (is_dir($pDirectory)) { + $this->_diskCachingDirectory = $pDirectory; + } else { + throw new PHPExcel_Writer_Exception("Directory does not exist: $pDirectory"); + } + } + return $this; + } + + /** + * Get disk caching directory + * + * @return string + */ + public function getDiskCachingDirectory() { + return $this->_diskCachingDirectory; + } +} diff --git a/framework/library/phpexcel/PHPExcel/Writer/Excel5/BIFFwriter.php b/framework/library/phpexcel/PHPExcel/Writer/Excel5/BIFFwriter.php new file mode 100644 index 0000000..02a06ad --- /dev/null +++ b/framework/library/phpexcel/PHPExcel/Writer/Excel5/BIFFwriter.php @@ -0,0 +1,255 @@ + +// * +// * The majority of this is _NOT_ my code. I simply ported it from the +// * PERL Spreadsheet::WriteExcel module. +// * +// * The author of the Spreadsheet::WriteExcel module is John McNamara +// * +// * +// * I _DO_ maintain this code, and John McNamara has nothing to do with the +// * porting of this code to PHP. Any questions directly related to this +// * class library should be directed to me. +// * +// * License Information: +// * +// * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets +// * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com +// * +// * This library is free software; you can redistribute it and/or +// * modify it under the terms of the GNU Lesser General Public +// * License as published by the Free Software Foundation; either +// * version 2.1 of the License, or (at your option) any later version. +// * +// * This library is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// * Lesser General Public License for more details. +// * +// * You should have received a copy of the GNU Lesser General Public +// * License along with this library; if not, write to the Free Software +// * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// */ + + +/** + * PHPExcel_Writer_Excel5_BIFFwriter + * + * @category PHPExcel + * @package PHPExcel_Writer_Excel5 + * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) + */ +class PHPExcel_Writer_Excel5_BIFFwriter +{ + /** + * The byte order of this architecture. 0 => little endian, 1 => big endian + * @var integer + */ + private static $_byte_order; + + /** + * The string containing the data of the BIFF stream + * @var string + */ + public $_data; + + /** + * The size of the data in bytes. Should be the same as strlen($this->_data) + * @var integer + */ + public $_datasize; + + /** + * The maximum length for a BIFF record (excluding record header and length field). See _addContinue() + * @var integer + * @see _addContinue() + */ + public $_limit = 8224; + + /** + * Constructor + */ + public function __construct() + { + $this->_data = ''; + $this->_datasize = 0; +// $this->_limit = 8224; + } + + /** + * Determine the byte order and store it as class data to avoid + * recalculating it for each call to new(). + * + * @return int + */ + public static function getByteOrder() + { + if (!isset(self::$_byte_order)) { + // Check if "pack" gives the required IEEE 64bit float + $teststr = pack("d", 1.2345); + $number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F); + if ($number == $teststr) { + $byte_order = 0; // Little Endian + } elseif ($number == strrev($teststr)){ + $byte_order = 1; // Big Endian + } else { + // Give up. I'll fix this in a later version. + throw new PHPExcel_Writer_Exception("Required floating point format not supported on this platform."); + } + self::$_byte_order = $byte_order; + } + + return self::$_byte_order; + } + + /** + * General storage function + * + * @param string $data binary data to append + * @access private + */ + function _append($data) + { + if (strlen($data) - 4 > $this->_limit) { + $data = $this->_addContinue($data); + } + $this->_data .= $data; + $this->_datasize += strlen($data); + } + + /** + * General storage function like _append, but returns string instead of modifying $this->_data + * + * @param string $data binary data to write + * @return string + */ + public function writeData($data) + { + if (strlen($data) - 4 > $this->_limit) { + $data = $this->_addContinue($data); + } + $this->_datasize += strlen($data); + + return $data; + } + + /** + * Writes Excel BOF record to indicate the beginning of a stream or + * sub-stream in the BIFF file. + * + * @param integer $type Type of BIFF file to write: 0x0005 Workbook, + * 0x0010 Worksheet. + * @access private + */ + function _storeBof($type) + { + $record = 0x0809; // Record identifier (BIFF5-BIFF8) + $length = 0x0010; + + // by inspection of real files, MS Office Excel 2007 writes the following + $unknown = pack("VV", 0x000100D1, 0x00000406); + + $build = 0x0DBB; // Excel 97 + $year = 0x07CC; // Excel 97 + + $version = 0x0600; // BIFF8 + + $header = pack("vv", $record, $length); + $data = pack("vvvv", $version, $type, $build, $year); + $this->_append($header . $data . $unknown); + } + + /** + * Writes Excel EOF record to indicate the end of a BIFF stream. + * + * @access private + */ + function _storeEof() + { + $record = 0x000A; // Record identifier + $length = 0x0000; // Number of bytes to follow + + $header = pack("vv", $record, $length); + $this->_append($header); + } + + /** + * Writes Excel EOF record to indicate the end of a BIFF stream. + * + * @access private + */ + public function writeEof() + { + $record = 0x000A; // Record identifier + $length = 0x0000; // Number of bytes to follow + $header = pack("vv", $record, $length); + return $this->writeData($header); + } + + /** + * Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In + * Excel 97 the limit is 8228 bytes. Records that are longer than these limits + * must be split up into CONTINUE blocks. + * + * This function takes a long BIFF record and inserts CONTINUE records as + * necessary. + * + * @param string $data The original binary data to be written + * @return string A very convenient string of continue blocks + * @access private + */ + function _addContinue($data) + { + $limit = $this->_limit; + $record = 0x003C; // Record identifier + + // The first 2080/8224 bytes remain intact. However, we have to change + // the length field of the record. + $tmp = substr($data, 0, 2) . pack("v", $limit) . substr($data, 4, $limit); + + $header = pack("vv", $record, $limit); // Headers for continue records + + // Retrieve chunks of 2080/8224 bytes +4 for the header. + $data_length = strlen($data); + for ($i = $limit + 4; $i < ($data_length - $limit); $i += $limit) { + $tmp .= $header; + $tmp .= substr($data, $i, $limit); + } + + // Retrieve the last chunk of data + $header = pack("vv", $record, strlen($data) - $i); + $tmp .= $header; + $tmp .= substr($data, $i, strlen($data) - $i); + + return $tmp; + } + +} diff --git a/web/common/bootstrap.sys.inc.php b/web/common/bootstrap.sys.inc.php new file mode 100644 index 0000000..9037d34 --- /dev/null +++ b/web/common/bootstrap.sys.inc.php @@ -0,0 +1,44 @@ +web('common'); +load()->web('template'); +load()->func('file'); +load()->func('tpl'); +load()->model('cloud'); +load()->model('user'); +load()->model('permission'); +load()->model('attachment'); +load()->classs('oauth2/oauth2client'); +load()->model('switch'); +load()->model('system'); + +$_W['token'] = token(); +$session = json_decode(authcode($_GPC['__session']), true); +if (is_array($session)) { + $user = user_single(array('uid' => $session['uid'])); + if (is_array($user) && $session['hash'] === $user['hash']) { + $_W['uid'] = $user['uid']; + $_W['username'] = $user['username']; + $user['currentvisit'] = $user['lastvisit']; + $user['currentip'] = $user['lastip']; + $user['lastvisit'] = $session['lastvisit']; + $user['lastip'] = $session['lastip']; + $_W['user'] = $user; + $_W['isfounder'] = user_is_founder($_W['uid']); + $_W['isadmin'] = user_is_founder($_W['uid'], true); + } else { + isetcookie('__session', false, -100); + } + unset($user); +} +unset($session); +$_W['uniacid'] = intval(igetcookie('__uniacid')); + +if (!empty($_W['uid'])) { + $_W['highest_role'] = permission_account_user_role($_W['uid']); + $_W['role'] = permission_account_user_role($_W['uid'], $_W['uniacid']); +} + +$_W['template'] = 'default'; +$_W['attachurl'] = attachment_set_attach_url(); diff --git a/web/resource/components/area/Area.xml b/web/resource/components/area/Area.xml new file mode 100644 index 0000000..22b6223 --- /dev/null +++ b/web/resource/components/area/Area.xml @@ -0,0 +1,3929 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/web/resource/components/chart/angular-chart.js b/web/resource/components/chart/angular-chart.js new file mode 100644 index 0000000..ad9fa0c --- /dev/null +++ b/web/resource/components/chart/angular-chart.js @@ -0,0 +1,391 @@ +(function (factory) { + 'use strict'; + if (typeof exports === 'object') { + // Node/CommonJS + module.exports = factory( + typeof angular !== 'undefined' ? angular : require('angular'), + typeof Chart !== 'undefined' ? Chart : require('chart.js')); + } else if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['chart'], factory); + } else { + // Browser globals + if (typeof angular === 'undefined') { + throw new Error('AngularJS framework needs to be included, see https://angularjs.org/'); + } else if (typeof Chart === 'undefined') { + throw new Error('Chart.js library needs to be included, see http://jtblin.github.io/angular-chart.js/'); + } + factory(angular, Chart); + } +}(function (Chart) { + 'use strict'; + + Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>'; + Chart.defaults.global.tooltips.mode = 'label'; + Chart.defaults.global.elements.line.borderWidth = 2; + Chart.defaults.global.elements.rectangle.borderWidth = 2; + Chart.defaults.global.legend.display = false; + Chart.defaults.global.colors = [ + '#97BBCD', // blue + '#DCDCDC', // light grey + '#F7464A', // red + '#46BFBD', // green + '#FDB45C', // yellow + '#949FB1', // grey + '#4D5360' // dark grey + ]; + + var useExcanvas = typeof window.G_vmlCanvasManager === 'object' && + window.G_vmlCanvasManager !== null && + typeof window.G_vmlCanvasManager.initElement === 'function'; + + if (useExcanvas) Chart.defaults.global.animation = false; + + return angular.module('chart.js', []) + .provider('ChartJs', ChartJsProvider) + .factory('ChartJsFactory', ['ChartJs', '$timeout', ChartJsFactory]) + .directive('chartBase', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory(); }]) + .directive('chartLine', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('line'); }]) + .directive('chartBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('bar'); }]) + .directive('chartHorizontalBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('horizontalBar'); }]) + .directive('chartRadar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('radar'); }]) + .directive('chartDoughnut', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('doughnut'); }]) + .directive('chartPie', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('pie'); }]) + .directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('polarArea'); }]) + .directive('chartBubble', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('bubble'); }]) + .name; + + /** + * Wrapper for chart.js + * Allows configuring chart js using the provider + * + * angular.module('myModule', ['chart.js']).config(function(ChartJsProvider) { + * ChartJsProvider.setOptions({ responsive: false }); + * ChartJsProvider.setOptions('Line', { responsive: true }); + * }))) + */ + function ChartJsProvider () { + var options = { responsive: true }; + var ChartJs = { + Chart: Chart, + getOptions: function (type) { + var typeOptions = type && options[type] || {}; + return angular.extend({}, options, typeOptions); + } + }; + + /** + * Allow to set global options during configuration + */ + this.setOptions = function (type, customOptions) { + // If no type was specified set option for the global object + if (! customOptions) { + customOptions = type; + options = angular.merge(options, customOptions); + } else { + // Set options for the specific chart + options[type] = angular.merge(options[type] || {}, customOptions); + } + + angular.merge(ChartJs.Chart.defaults, options); + }; + + this.$get = function () { + return ChartJs; + }; + } + + function ChartJsFactory (ChartJs, $timeout) { + return function chart (type) { + return { + restrict: 'CA', + scope: { + chartGetColor: '=?', + chartType: '=', + chartData: '=?', + chartLabels: '=?', + chartOptions: '=?', + chartSeries: '=?', + chartColors: '=?', + chartClick: '=?', + chartHover: '=?', + chartDatasetOverride: '=?' + }, + link: function (scope, elem/*, attrs */) { + if (useExcanvas) window.G_vmlCanvasManager.initElement(elem[0]); + + // Order of setting "watch" matter + scope.$watch('chartData', watchData, true); + scope.$watch('chartSeries', watchOther, true); + scope.$watch('chartLabels', watchOther, true); + scope.$watch('chartOptions', watchOther, true); + scope.$watch('chartColors', watchOther, true); + scope.$watch('chartDatasetOverride', watchOther, true); + scope.$watch('chartType', watchType, false); + + scope.$on('$destroy', function () { + destroyChart(scope); + }); + + scope.$on('$resize', function () { + if (scope.chart) scope.chart.resize(); + }); + + function watchData (newVal, oldVal) { + if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) { + destroyChart(scope); + return; + } + var chartType = type || scope.chartType; + if (! chartType) return; + + if (scope.chart && canUpdateChart(newVal, oldVal)) + return updateChart(newVal, scope); + + createChart(chartType, scope, elem); + } + + function watchOther (newVal, oldVal) { + if (isEmpty(newVal)) return; + if (angular.equals(newVal, oldVal)) return; + var chartType = type || scope.chartType; + if (! chartType) return; + + // chart.update() doesn't work for series and labels + // so we have to re-create the chart entirely + createChart(chartType, scope, elem); + } + + function watchType (newVal, oldVal) { + if (isEmpty(newVal)) return; + if (angular.equals(newVal, oldVal)) return; + createChart(newVal, scope, elem); + } + } + }; + }; + + function createChart (type, scope, elem) { + var options = getChartOptions(type, scope); + if (! hasData(scope) || ! canDisplay(type, scope, elem, options)) return; + + var cvs = elem[0]; + var ctx = cvs.getContext('2d'); + + scope.chartGetColor = getChartColorFn(scope); + var data = getChartData(type, scope); + // Destroy old chart if it exists to avoid ghost charts issue + // https://github.com/jtblin/angular-chart.js/issues/187 + destroyChart(scope); + + scope.chart = new ChartJs.Chart(ctx, { + type: type, + data: data, + options: options + }); + scope.$emit('chart-create', scope.chart); + bindEvents(cvs, scope); + } + + function canUpdateChart (newVal, oldVal) { + if (newVal && oldVal && newVal.length && oldVal.length) { + return Array.isArray(newVal[0]) ? + newVal.length === oldVal.length && newVal.every(function (element, index) { + return element.length === oldVal[index].length; }) : + oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false; + } + return false; + } + + function sum (carry, val) { + return carry + val; + } + + function getEventHandler (scope, action, triggerOnlyOnChange) { + var lastState = { + point: void 0, + points: void 0 + }; + return function (evt) { + var atEvent = scope.chart.getElementAtEvent || scope.chart.getPointAtEvent; + var atEvents = scope.chart.getElementsAtEvent || scope.chart.getPointsAtEvent; + if (atEvents) { + var points = atEvents.call(scope.chart, evt); + var point = atEvent ? atEvent.call(scope.chart, evt)[0] : void 0; + + if (triggerOnlyOnChange === false || + (! angular.equals(lastState.points, points) && ! angular.equals(lastState.point, point)) + ) { + lastState.point = point; + lastState.points = points; + scope[action](points, evt, point); + } + } + }; + } + + function getColors (type, scope) { + var colors = angular.copy(scope.chartColors || + ChartJs.getOptions(type).chartColors || + Chart.defaults.global.colors + ); + var notEnoughColors = colors.length < scope.chartData.length; + while (colors.length < scope.chartData.length) { + colors.push(scope.chartGetColor()); + } + // mutate colors in this case as we don't want + // the colors to change on each refresh + if (notEnoughColors) scope.chartColors = colors; + return colors.map(convertColor); + } + + function convertColor (color) { + // Allows RGB and RGBA colors to be input as a string: e.g.: "rgb(159,204,0)", "rgba(159,204,0, 0.5)" + if (typeof color === 'string' && color[0] === 'r') return getColor(rgbStringToRgb(color)); + // Allows hex colors to be input as a string. + if (typeof color === 'string' && color[0] === '#') return getColor(hexToRgb(color.substr(1))); + // Allows colors to be input as an object, bypassing getColor() entirely + if (typeof color === 'object' && color !== null) return color; + return getRandomColor(); + } + + function getRandomColor () { + var color = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)]; + return getColor(color); + } + + function getColor (color) { + var alpha = color[3] || 1; + color = color.slice(0, 3); + return { + backgroundColor: rgba(color, 0.2), + pointBackgroundColor: rgba(color, alpha), + pointHoverBackgroundColor: rgba(color, 0.8), + borderColor: rgba(color, alpha), + pointBorderColor: '#fff', + pointHoverBorderColor: rgba(color, alpha) + }; + } + + function getRandomInt (min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } + + function rgba (color, alpha) { + // rgba not supported by IE8 + return useExcanvas ? 'rgb(' + color.join(',') + ')' : 'rgba(' + color.concat(alpha).join(',') + ')'; + } + + // Credit: http://stackoverflow.com/a/11508164/1190235 + function hexToRgb (hex) { + var bigint = parseInt(hex, 16), + r = (bigint >> 16) & 255, + g = (bigint >> 8) & 255, + b = bigint & 255; + + return [r, g, b]; + } + + function rgbStringToRgb (color) { + var match = color.match(/^rgba?\(([\d,.]+)\)$/); + if (! match) throw new Error('Cannot parse rgb value'); + color = match[1].split(','); + return color.map(Number); + } + + function hasData (scope) { + return scope.chartData && scope.chartData.length; + } + + function getChartColorFn (scope) { + return typeof scope.chartGetColor === 'function' ? scope.chartGetColor : getRandomColor; + } + + function getChartData (type, scope) { + var colors = getColors(type, scope); + return Array.isArray(scope.chartData[0]) ? + getDataSets(scope.chartLabels, scope.chartData, scope.chartSeries || [], colors, scope.chartDatasetOverride) : + getData(scope.chartLabels, scope.chartData, colors, scope.chartDatasetOverride); + } + + function getDataSets (labels, data, series, colors, datasetOverride) { + return { + labels: labels, + datasets: data.map(function (item, i) { + var dataset = angular.extend({}, colors[i], { + label: series[i], + data: item + }); + if (datasetOverride && datasetOverride.length >= i) { + angular.merge(dataset, datasetOverride[i]); + } + return dataset; + }) + }; + } + + function getData (labels, data, colors, datasetOverride) { + var dataset = { + labels: labels, + datasets: [{ + data: data, + backgroundColor: colors.map(function (color) { + return color.pointBackgroundColor; + }), + hoverBackgroundColor: colors.map(function (color) { + return color.backgroundColor; + }) + }] + }; + if (datasetOverride) { + angular.merge(dataset.datasets[0], datasetOverride); + } + return dataset; + } + + function getChartOptions (type, scope) { + return angular.extend({}, ChartJs.getOptions(type), scope.chartOptions); + } + + function bindEvents (cvs, scope) { + cvs.onclick = scope.chartClick ? getEventHandler(scope, 'chartClick', false) : angular.noop; + cvs.onmousemove = scope.chartHover ? getEventHandler(scope, 'chartHover', true) : angular.noop; + } + + function updateChart (values, scope) { + if (Array.isArray(scope.chartData[0])) { + scope.chart.data.datasets.forEach(function (dataset, i) { + dataset.data = values[i]; + }); + } else { + scope.chart.data.datasets[0].data = values; + } + + scope.chart.update(); + scope.$emit('chart-update', scope.chart); + } + + function isEmpty (value) { + return ! value || + (Array.isArray(value) && ! value.length) || + (typeof value === 'object' && ! Object.keys(value).length); + } + + function canDisplay (type, scope, elem, options) { + // TODO: check parent? + if (options.responsive && elem[0].clientHeight === 0) { + $timeout(function () { + createChart(type, scope, elem); + }, 50, false); + return false; + } + return true; + } + + function destroyChart(scope) { + if(! scope.chart) return; + scope.chart.destroy(); + scope.$emit('chart-destroy', scope.chart); + } + } +})); diff --git a/web/resource/components/kindeditor/plugins/anchor/anchor.js b/web/resource/components/kindeditor/plugins/anchor/anchor.js new file mode 100644 index 0000000..55ab894 --- /dev/null +++ b/web/resource/components/kindeditor/plugins/anchor/anchor.js @@ -0,0 +1,46 @@ +/******************************************************************************* +* KindEditor - WYSIWYG HTML Editor for Internet +* Copyright (C) 2006-2011 kindsoft.net +* +* @author Roddy +* @site http://www.kindsoft.net/ +* @licence http://www.kindsoft.net/license.php +*******************************************************************************/ + +KindEditor.plugin('anchor', function(K) { + var self = this, name = 'anchor', lang = self.lang(name + '.'); + self.plugin.anchor = { + edit : function() { + var html = ['
', + '
', + '', + '', + '
', + '
'].join(''); + var dialog = self.createDialog({ + name : name, + width : 300, + title : self.lang(name), + body : html, + yesBtn : { + name : self.lang('yes'), + click : function(e) { + self.insertHtml('').hideDialog().focus(); + } + } + }); + var div = dialog.div, + nameBox = K('input[name="name"]', div); + var img = self.plugin.getSelectedAnchor(); + if (img) { + nameBox.val(unescape(img.attr('data-ke-name'))); + } + nameBox[0].focus(); + nameBox[0].select(); + }, + 'delete' : function() { + self.plugin.getSelectedAnchor().remove(); + } + }; + self.clickToolbar(name, self.plugin.anchor.edit); +}); diff --git a/web/resource/components/kindeditor/plugins/autoheight/autoheight.js b/web/resource/components/kindeditor/plugins/autoheight/autoheight.js new file mode 100644 index 0000000..546578b --- /dev/null +++ b/web/resource/components/kindeditor/plugins/autoheight/autoheight.js @@ -0,0 +1,54 @@ +/******************************************************************************* +* KindEditor - WYSIWYG HTML Editor for Internet +* Copyright (C) 2006-2011 kindsoft.net +* +* @author Roddy +* @site http://www.kindsoft.net/ +* @licence http://www.kindsoft.net/license.php +*******************************************************************************/ + +KindEditor.plugin('autoheight', function(K) { + var self = this; + + if (!self.autoHeightMode) { + return; + } + + var minHeight; + + function hideScroll() { + var edit = self.edit; + var body = edit.doc.body; + edit.iframe[0].scroll = 'no'; + body.style.overflowY = 'hidden'; + } + + function resetHeight() { + var edit = self.edit; + var body = edit.doc.body; + edit.iframe.height(minHeight); + self.resize(null, Math.max((K.IE ? body.scrollHeight : body.offsetHeight) + 76, minHeight)); + } + + function init() { + minHeight = K.removeUnit(self.height); + + self.edit.afterChange(resetHeight); + hideScroll(); + resetHeight(); + } + + if (self.isCreated) { + init(); + } else { + self.afterCreate(init); + } +}); + +/* +* 如何实现真正的自动高度? +* 修改编辑器高度之后,再次获取body内容高度时,最小值只会是当前iframe的设置高度,这样就导致高度只增不减。 +* 所以每次获取body内容高度之前,先将iframe的高度重置为最小高度,这样就能获取body的实际高度。 +* 由此就实现了真正的自动高度 +* 测试:chrome、firefox、IE9、IE8 +* */ diff --git a/web/resource/components/kindeditor/plugins/baidumap/baidumap.js b/web/resource/components/kindeditor/plugins/baidumap/baidumap.js new file mode 100644 index 0000000..12751c4 --- /dev/null +++ b/web/resource/components/kindeditor/plugins/baidumap/baidumap.js @@ -0,0 +1,93 @@ +/******************************************************************************* +* KindEditor - WYSIWYG HTML Editor for Internet +* Copyright (C) 2006-2011 kindsoft.net +* +* @author Roddy +* @site http://www.kindsoft.net/ +* @licence http://www.kindsoft.net/license.php +*******************************************************************************/ + +// Baidu Maps: http://dev.baidu.com/wiki/map/index.php?title=%E9%A6%96%E9%A1%B5 + +KindEditor.plugin('baidumap', function(K) { + var self = this, name = 'baidumap', lang = self.lang(name + '.'); + var mapWidth = K.undef(self.mapWidth, 558); + var mapHeight = K.undef(self.mapHeight, 360); + self.clickToolbar(name, function() { + var html = ['
', + '
', + // left start + '
', + lang.address + ' ', + '', + '', + '', + '
', + // right start + '
', + ' ', + '
', + '
', + '
', + '
', + '
'].join(''); + var dialog = self.createDialog({ + name : name, + width : mapWidth + 42, + title : self.lang(name), + body : html, + yesBtn : { + name : self.lang('yes'), + click : function(e) { + var map = win.map; + var centerObj = map.getCenter(); + var center = centerObj.lng + ',' + centerObj.lat; + var zoom = map.getZoom(); + var url = [checkbox[0].checked ? self.pluginsPath + 'baidumap/index.html' : 'http://api.map.baidu.com/staticimage', + '?center=' + encodeURIComponent(center), + '&zoom=' + encodeURIComponent(zoom), + '&width=' + mapWidth, + '&height=' + mapHeight, + '&markers=' + encodeURIComponent(center), + '&markerStyles=' + encodeURIComponent('l,A')].join(''); + if (checkbox[0].checked) { + self.insertHtml(''); + } else { + self.exec('insertimage', url); + } + self.hideDialog().focus(); + } + }, + beforeRemove : function() { + searchBtn.remove(); + if (doc) { + doc.write(''); + } + iframe.remove(); + } + }); + var div = dialog.div, + addressBox = K('[name="address"]', div), + searchBtn = K('[name="searchBtn"]', div), + checkbox = K('[name="insertDynamicMap"]', dialog.div), + win, doc; + var iframe = K(''); + function ready() { + win = iframe[0].contentWindow; + doc = K.iframeDoc(iframe); + } + iframe.bind('load', function() { + iframe.unbind('load'); + if (K.IE) { + ready(); + } else { + setTimeout(ready, 0); + } + }); + K('.ke-map', div).replaceWith(iframe); + // search map + searchBtn.click(function() { + win.search(addressBox.val()); + }); + }); +}); diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/100.gif b/web/resource/components/kindeditor/plugins/emoticons/images/100.gif new file mode 100644 index 0000000..92ad35d Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/100.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/101.gif b/web/resource/components/kindeditor/plugins/emoticons/images/101.gif new file mode 100644 index 0000000..1f27663 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/101.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/102.gif b/web/resource/components/kindeditor/plugins/emoticons/images/102.gif new file mode 100644 index 0000000..748ded1 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/102.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/103.gif b/web/resource/components/kindeditor/plugins/emoticons/images/103.gif new file mode 100644 index 0000000..be9eaa0 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/103.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/104.gif b/web/resource/components/kindeditor/plugins/emoticons/images/104.gif new file mode 100644 index 0000000..d7c2066 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/104.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/105.gif b/web/resource/components/kindeditor/plugins/emoticons/images/105.gif new file mode 100644 index 0000000..2f353ca Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/105.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/106.gif b/web/resource/components/kindeditor/plugins/emoticons/images/106.gif new file mode 100644 index 0000000..5193534 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/106.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/107.gif b/web/resource/components/kindeditor/plugins/emoticons/images/107.gif new file mode 100644 index 0000000..70d38d3 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/107.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/108.gif b/web/resource/components/kindeditor/plugins/emoticons/images/108.gif new file mode 100644 index 0000000..749d500 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/108.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/109.gif b/web/resource/components/kindeditor/plugins/emoticons/images/109.gif new file mode 100644 index 0000000..6f57d56 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/109.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/110.gif b/web/resource/components/kindeditor/plugins/emoticons/images/110.gif new file mode 100644 index 0000000..e253abc Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/110.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/111.gif b/web/resource/components/kindeditor/plugins/emoticons/images/111.gif new file mode 100644 index 0000000..0c56723 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/111.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/112.gif b/web/resource/components/kindeditor/plugins/emoticons/images/112.gif new file mode 100644 index 0000000..c8ddce8 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/112.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/113.gif b/web/resource/components/kindeditor/plugins/emoticons/images/113.gif new file mode 100644 index 0000000..2727104 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/113.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/114.gif b/web/resource/components/kindeditor/plugins/emoticons/images/114.gif new file mode 100644 index 0000000..53918e2 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/114.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/115.gif b/web/resource/components/kindeditor/plugins/emoticons/images/115.gif new file mode 100644 index 0000000..4db3369 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/115.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/116.gif b/web/resource/components/kindeditor/plugins/emoticons/images/116.gif new file mode 100644 index 0000000..57326bd Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/116.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/117.gif b/web/resource/components/kindeditor/plugins/emoticons/images/117.gif new file mode 100644 index 0000000..14611b6 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/117.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/118.gif b/web/resource/components/kindeditor/plugins/emoticons/images/118.gif new file mode 100644 index 0000000..8c25500 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/118.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/119.gif b/web/resource/components/kindeditor/plugins/emoticons/images/119.gif new file mode 100644 index 0000000..65bb468 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/119.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/120.gif b/web/resource/components/kindeditor/plugins/emoticons/images/120.gif new file mode 100644 index 0000000..5ce77c0 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/120.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/121.gif b/web/resource/components/kindeditor/plugins/emoticons/images/121.gif new file mode 100644 index 0000000..a021aba Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/121.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/122.gif b/web/resource/components/kindeditor/plugins/emoticons/images/122.gif new file mode 100644 index 0000000..9a79e11 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/122.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/123.gif b/web/resource/components/kindeditor/plugins/emoticons/images/123.gif new file mode 100644 index 0000000..b9480be Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/123.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/124.gif b/web/resource/components/kindeditor/plugins/emoticons/images/124.gif new file mode 100644 index 0000000..7fed477 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/124.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/125.gif b/web/resource/components/kindeditor/plugins/emoticons/images/125.gif new file mode 100644 index 0000000..e2c3c11 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/125.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/126.gif b/web/resource/components/kindeditor/plugins/emoticons/images/126.gif new file mode 100644 index 0000000..24105c9 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/126.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/127.gif b/web/resource/components/kindeditor/plugins/emoticons/images/127.gif new file mode 100644 index 0000000..0cead36 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/127.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/128.gif b/web/resource/components/kindeditor/plugins/emoticons/images/128.gif new file mode 100644 index 0000000..3185861 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/128.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/129.gif b/web/resource/components/kindeditor/plugins/emoticons/images/129.gif new file mode 100644 index 0000000..ffd7c6b Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/129.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/130.gif b/web/resource/components/kindeditor/plugins/emoticons/images/130.gif new file mode 100644 index 0000000..d828e3d Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/130.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/131.gif b/web/resource/components/kindeditor/plugins/emoticons/images/131.gif new file mode 100644 index 0000000..dcb096f Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/131.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/132.gif b/web/resource/components/kindeditor/plugins/emoticons/images/132.gif new file mode 100644 index 0000000..1b272a6 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/132.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/133.gif b/web/resource/components/kindeditor/plugins/emoticons/images/133.gif new file mode 100644 index 0000000..0d0e864 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/133.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/134.gif b/web/resource/components/kindeditor/plugins/emoticons/images/134.gif new file mode 100644 index 0000000..cf48356 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/134.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/91.gif b/web/resource/components/kindeditor/plugins/emoticons/images/91.gif new file mode 100644 index 0000000..608d0ad Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/91.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/92.gif b/web/resource/components/kindeditor/plugins/emoticons/images/92.gif new file mode 100644 index 0000000..b909e16 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/92.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/93.gif b/web/resource/components/kindeditor/plugins/emoticons/images/93.gif new file mode 100644 index 0000000..7f71a8c Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/93.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/94.gif b/web/resource/components/kindeditor/plugins/emoticons/images/94.gif new file mode 100644 index 0000000..4f26d7d Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/94.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/95.gif b/web/resource/components/kindeditor/plugins/emoticons/images/95.gif new file mode 100644 index 0000000..5ef6d38 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/95.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/96.gif b/web/resource/components/kindeditor/plugins/emoticons/images/96.gif new file mode 100644 index 0000000..2b709e1 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/96.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/97.gif b/web/resource/components/kindeditor/plugins/emoticons/images/97.gif new file mode 100644 index 0000000..cf29be8 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/97.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/98.gif b/web/resource/components/kindeditor/plugins/emoticons/images/98.gif new file mode 100644 index 0000000..c70e7d3 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/98.gif differ diff --git a/web/resource/components/kindeditor/plugins/emoticons/images/99.gif b/web/resource/components/kindeditor/plugins/emoticons/images/99.gif new file mode 100644 index 0000000..05c1863 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/emoticons/images/99.gif differ diff --git a/web/resource/components/kindeditor/plugins/image/images/align_left.gif b/web/resource/components/kindeditor/plugins/image/images/align_left.gif new file mode 100644 index 0000000..ab17f56 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/image/images/align_left.gif differ diff --git a/web/resource/components/kindeditor/plugins/image/images/align_right.gif b/web/resource/components/kindeditor/plugins/image/images/align_right.gif new file mode 100644 index 0000000..e8ebe6a Binary files /dev/null and b/web/resource/components/kindeditor/plugins/image/images/align_right.gif differ diff --git a/web/resource/components/kindeditor/plugins/image/images/align_top.gif b/web/resource/components/kindeditor/plugins/image/images/align_top.gif new file mode 100644 index 0000000..d8826a5 Binary files /dev/null and b/web/resource/components/kindeditor/plugins/image/images/align_top.gif differ diff --git a/web/resource/components/kindeditor/themes/common/anchor.gif b/web/resource/components/kindeditor/themes/common/anchor.gif new file mode 100644 index 0000000..61145ea Binary files /dev/null and b/web/resource/components/kindeditor/themes/common/anchor.gif differ diff --git a/web/resource/components/kindeditor/themes/common/blank.gif b/web/resource/components/kindeditor/themes/common/blank.gif new file mode 100644 index 0000000..5bfd67a Binary files /dev/null and b/web/resource/components/kindeditor/themes/common/blank.gif differ diff --git a/web/resource/components/kindeditor/themes/default/background.png b/web/resource/components/kindeditor/themes/default/background.png new file mode 100644 index 0000000..bbfb056 Binary files /dev/null and b/web/resource/components/kindeditor/themes/default/background.png differ diff --git a/web/resource/components/switch/bootstrap-switch.min.css b/web/resource/components/switch/bootstrap-switch.min.css new file mode 100644 index 0000000..827fcec --- /dev/null +++ b/web/resource/components/switch/bootstrap-switch.min.css @@ -0,0 +1 @@ +.bootstrap-switch{display:inline-block;cursor:pointer;border-radius:4px;border:1px solid #ccc;position:relative;text-align:left;overflow:hidden;line-height:8px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;min-width:100px;-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.bootstrap-switch.bootstrap-switch-mini{min-width:71px}.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-label{padding-bottom:4px;padding-top:4px;font-size:10px;line-height:9px}.bootstrap-switch.bootstrap-switch-small{min-width:79px}.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-label{padding-bottom:3px;padding-top:3px;font-size:12px;line-height:18px}.bootstrap-switch.bootstrap-switch-large{min-width:120px}.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label{padding-bottom:9px;padding-top:9px;font-size:16px;line-height:normal}.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container{-webkit-transition:margin-left .5s;transition:margin-left .5s}.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-container{margin-left:0}.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label{border-bottom-right-radius:3px;border-top-right-radius:3px}.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-container{margin-left:-50%}.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label{border-bottom-left-radius:3px;border-top-left-radius:3px}.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-container{margin-left:-25%}.bootstrap-switch.bootstrap-switch-disabled,.bootstrap-switch.bootstrap-switch-indeterminate,.bootstrap-switch.bootstrap-switch-readonly{opacity:.5;filter:alpha(opacity=50);cursor:default!important}.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label{cursor:default!important}.bootstrap-switch.bootstrap-switch-focused{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.bootstrap-switch .bootstrap-switch-container{display:inline-block;width:150%;top:0;border-radius:4px;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.bootstrap-switch .bootstrap-switch-handle-off,.bootstrap-switch .bootstrap-switch-handle-on,.bootstrap-switch .bootstrap-switch-label{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;cursor:pointer;display:inline-block!important;height:100%;padding-bottom:4px;padding-top:4px;font-size:14px;line-height:20px}.bootstrap-switch .bootstrap-switch-handle-off,.bootstrap-switch .bootstrap-switch-handle-on{text-align:center;z-index:1;width:33.33333333%}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary{color:#fff;background:#428bca}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info{color:#fff;background:#5bc0de}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success{color:#fff;background:#5cb85c}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-warning,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-warning{background:#f0ad4e;color:#fff}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger{color:#fff;background:#d9534f}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-default{color:#000;background:#eee}.bootstrap-switch .bootstrap-switch-handle-on{border-bottom-left-radius:3px;border-top-left-radius:3px}.bootstrap-switch .bootstrap-switch-handle-off{border-bottom-right-radius:3px;border-top-right-radius:3px}.bootstrap-switch .bootstrap-switch-label{text-align:center;margin-top:-1px;margin-bottom:-1px;z-index:100;width:33.33333333%;color:#333;background:#fff}.bootstrap-switch input[type=checkbox],.bootstrap-switch input[type=radio]{position:absolute!important;top:0;left:0;opacity:0;filter:alpha(opacity=0);z-index:-1} \ No newline at end of file diff --git a/web/resource/components/switch/bootstrap-switch.min.js b/web/resource/components/switch/bootstrap-switch.min.js new file mode 100644 index 0000000..aaa07c4 --- /dev/null +++ b/web/resource/components/switch/bootstrap-switch.min.js @@ -0,0 +1,22 @@ +/* ======================================================================== + * bootstrap-switch - v3.0.1 + * http://www.bootstrap-switch.org + * ======================================================================== + * Copyright 2012-2013 Mattia Larentis + * + * ======================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== + */ + +(function(){var t=[].slice;!function(e,s){"use strict";var o;return o=function(){function t(t,s){null==s&&(s={}),this.$element=e(t),this.options=e.extend({},e.fn.bootstrapSwitch.defaults,s,{state:this.$element.is(":checked"),size:this.$element.data("size"),animate:this.$element.data("animate"),disabled:this.$element.is(":disabled"),readonly:this.$element.is("[readonly]"),indeterminate:this.$element.data("indeterminate"),onColor:this.$element.data("on-color"),offColor:this.$element.data("off-color"),onText:this.$element.data("on-text"),offText:this.$element.data("off-text"),labelText:this.$element.data("label-text"),baseClass:this.$element.data("base-class"),wrapperClass:this.$element.data("wrapper-class")}),this.$wrapper=e("
",{"class":function(t){return function(){var e;return e=[""+t.options.baseClass].concat(t._getClasses(t.options.wrapperClass)),e.push(t.options.state?""+t.options.baseClass+"-on":""+t.options.baseClass+"-off"),null!=t.options.size&&e.push(""+t.options.baseClass+"-"+t.options.size),t.options.animate&&e.push(""+t.options.baseClass+"-animate"),t.options.disabled&&e.push(""+t.options.baseClass+"-disabled"),t.options.readonly&&e.push(""+t.options.baseClass+"-readonly"),t.options.indeterminate&&e.push(""+t.options.baseClass+"-indeterminate"),t.$element.attr("id")&&e.push(""+t.options.baseClass+"-id-"+t.$element.attr("id")),e.join(" ")}}(this)()}),this.$container=e("
",{"class":""+this.options.baseClass+"-container"}),this.$on=e("",{html:this.options.onText,"class":""+this.options.baseClass+"-handle-on "+this.options.baseClass+"-"+this.options.onColor}),this.$off=e("",{html:this.options.offText,"class":""+this.options.baseClass+"-handle-off "+this.options.baseClass+"-"+this.options.offColor}),this.$label=e("
')).attr({class:"modal-backdrop","ng-style":"{'z-index': 1040 + (index && 1 || 0) + index*10}","uib-modal-animation-class":"fade","modal-in-class":"in"}),t.backdropClass&&d.addClass(t.backdropClass),t.animation&&d.attr("modal-animation","true"),u(d)(f),l.enter(d,i),c.isScrollable(i)&&(m=c.scrollbarPadding(i)).heightOverflow&&m.scrollbarWidth&&i.css({paddingRight:m.right+"px"})),$=y?parseInt(y.value.modalDomEl.attr("index"),10)+1:0;var r=angular.element('
');r.attr({class:"modal","template-url":t.windowTemplateUrl,"window-top-class":t.windowTopClass,role:"dialog",size:t.size,index:$,animate:"animate","ng-style":"{'z-index': 1050 + index*10, display: 'block'}",tabindex:-1,"uib-modal-animation-class":"fade","modal-in-class":"in"}).html(t.content),t.windowClass&&r.addClass(t.windowClass),t.animation&&r.attr("modal-animation","true"),i.addClass(a),l.enter(u(r)(t.scope),i),g.top().value.modalDomEl=r,g.top().value.modalOpener=n},v.close=function(e,t){var n=g.get(e);return n&&D(n,t,!0)?(n.value.modalScope.$$uibDestructionScheduled=!0,n.value.deferred.resolve(t),a(e,n.value.modalOpener),!0):!n},v.dismiss=function(e,t){var n=g.get(e);return n&&D(n,t,!1)?(n.value.modalScope.$$uibDestructionScheduled=!0,n.value.deferred.reject(t),a(e,n.value.modalOpener),!0):!n},v.dismissAll=function(e){for(var t=this.getTop();t&&this.dismiss(t.key,e);)t=this.getTop()},v.getTop=function(){return g.top()},v.modalRendered=function(e){var t=g.get(e);t&&t.value.renderDeferred.resolve()},v.focusFirstFocusableElement=function(e){return 0a.totalPages?a.selectPage(a.totalPages):n.ngModelCtrl.$render()},a.$on("$destroy",function(){for(;n._watchers.length;)n._watchers.shift()()})}}}]),angular.module("ui.bootstrap.pager",["ui.bootstrap.paging","ui.bootstrap.tabindex"]).controller("UibPagerController",["$scope","$attrs","uibPaging","uibPagerConfig",function(e,t,n,a){e.align=angular.isDefined(t.align)?e.$parent.$eval(t.align):a.align,n.create(this,e,t)}]).constant("uibPagerConfig",{itemsPerPage:10,previousText:"« Previous",nextText:"Next »",align:!0}).directive("uibPager",["uibPagerConfig",function(r){return{scope:{totalItems:"=",previousText:"@",nextText:"@",ngDisabled:"="},require:["uibPager","?ngModel"],restrict:"A",controller:"UibPagerController",controllerAs:"pager",templateUrl:function(e,t){return t.templateUrl||"uib/template/pager/pager.html"},link:function(e,t,n,a){t.addClass("pager");var i=a[0],o=a[1];o&&i.init(o,r)}}}]),angular.module("ui.bootstrap.pagination",["ui.bootstrap.paging","ui.bootstrap.tabindex"]).controller("UibPaginationController",["$scope","$attrs","$parse","uibPaging","uibPaginationConfig",function(t,n,e,a,i){var o=this,m=angular.isDefined(n.maxSize)?t.$parent.$eval(n.maxSize):i.maxSize,h=angular.isDefined(n.rotate)?t.$parent.$eval(n.rotate):i.rotate,g=angular.isDefined(n.forceEllipses)?t.$parent.$eval(n.forceEllipses):i.forceEllipses,b=angular.isDefined(n.boundaryLinkNumbers)?t.$parent.$eval(n.boundaryLinkNumbers):i.boundaryLinkNumbers,v=angular.isDefined(n.pageLabel)?function(e){return t.$parent.$eval(n.pageLabel,{$page:e})}:angular.identity;function $(e,t,n){return{number:e,text:t,active:n}}t.boundaryLinks=angular.isDefined(n.boundaryLinks)?t.$parent.$eval(n.boundaryLinks):i.boundaryLinks,t.directionLinks=angular.isDefined(n.directionLinks)?t.$parent.$eval(n.directionLinks):i.directionLinks,a.create(this,t,n),n.maxSize&&o._watchers.push(t.$parent.$watch(e(n.maxSize),function(e){m=parseInt(e,10),o.render()}));var r=this.render;this.render=function(){r(),0
';return{compile:function(e,t){var H=o(i);return function(a,o,i,e){var r,t,n,l,s,u,p,c=!!angular.isDefined(q.appendToBody)&&q.appendToBody,d=Y(void 0),f=angular.isDefined(i[V+"Enable"]),m=a.$new(!0),h=!1,g=!!angular.isDefined(i[V+"IsOpen"])&&B(i[V+"IsOpen"]),b=!!q.useContentExp&&B(i[R]),v=[],$=function(){r&&r.html()&&(u||(u=L(function(){var e=z.positionElements(o,r,m.placement,c),n=angular.isDefined(r.offsetHeight)?r.offsetHeight:r.prop("offsetHeight"),a=c?z.offset(o):z.position(o);r.css({top:e.top+"px",left:e.left+"px"});var i=e.placement.split("-");r.hasClass(i[0])||(r.removeClass(p.split("-")[0]),r.addClass(i[0])),r.hasClass(q.placementClassPrefix+e.placement)||(r.removeClass(q.placementClassPrefix+p),r.addClass(q.placementClassPrefix+e.placement)),L(function(){var e=angular.isDefined(r.offsetHeight)?r.offsetHeight:r.prop("offsetHeight"),t=z.adjustTop(i,a,n,e);t&&r.css(t)},0,!1),r.hasClass("uib-position-measure")?(z.positionArrow(r,e.placement),r.removeClass("uib-position-measure")):p!==e.placement&&z.positionArrow(r,e.placement),p=e.placement,u=null},0,!1)))};function y(){m.isOpen?k():w()}function w(){f&&!a.$eval(i[V+"Enable"])||(M(),function(){m.title=i[V+"Title"],m.content=b?b(a):i[R];m.popupClass=i[V+"Class"],m.placement=angular.isDefined(i[V+"Placement"])?i[V+"Placement"]:q.placement;var e=z.parsePlacement(m.placement);p=e[1]?e[0]+"-"+e[1]:e[0];var t=parseInt(i[V+"PopupDelay"],10),n=parseInt(i[V+"PopupCloseDelay"],10);m.popupDelay=isNaN(t)?q.popupDelay:t,m.popupCloseDelay=isNaN(n)?q.popupCloseDelay:n}(),m.popupDelay?l||(l=L(D,m.popupDelay,!1)):D())}function k(){x(),m.popupCloseDelay?s||(s=L(C,m.popupCloseDelay,!1)):C()}function D(){if(x(),M(),!m.content)return angular.noop;!function(){if(r)return;t=m.$new(),r=H(t,function(e){c?W.find("body").append(e):o.after(e)}),function(){v.length=0,b?(v.push(a.$watch(b,function(e){!(m.content=e)&&m.isOpen&&C()})),v.push(t.$watch(function(){h||(h=!0,t.$$postDigest(function(){h=!1,m&&m.isOpen&&$()}))}))):v.push(i.$observe(R,function(e){!(m.content=e)&&m.isOpen?C():$()}));v.push(i.$observe(V+"Title",function(e){m.title=e,m.isOpen&&$()})),v.push(i.$observe(V+"Placement",function(e){m.placement=e||q.placement,m.isOpen&&$()}))}()}(),m.$evalAsync(function(){O(m.isOpen=!0),$()})}function x(){l&&(L.cancel(l),l=null),u&&(L.cancel(u),u=null)}function C(){m&&m.$evalAsync(function(){m&&(O(m.isOpen=!1),m.animation?n||(n=L(T,150,!1)):T())})}function M(){s&&(L.cancel(s),s=null),n&&(L.cancel(n),n=null)}function T(){x(),M(),v.length&&(angular.forEach(v,function(e){e()}),v.length=0),r&&(r.remove(),r=null),t&&(t.$destroy(),t=null)}function O(e){g&&angular.isFunction(g.assign)&&g.assign(a,e)}function P(e){m&&m.isOpen&&r&&(o[0].contains(e.target)||r[0].contains(e.target)||k())}m.origScope=a,m.isOpen=!1,j.add(m,{close:C}),m.contentExp=function(){return m.content},i.$observe("disabled",function(e){e&&x(),e&&m.isOpen&&C()}),g&&a.$watch(g,function(e){m&&!e===m.isOpen&&y()});function S(){d.show.forEach(function(e){"outsideClick"===e?o.off("click",y):(o.off(e,w),o.off(e,y))}),d.hide.forEach(function(e){"outsideClick"===e?W.off("click",P):o.off(e,k)})}var E,I,A;E=[],I=[],A=a.$eval(i[V+"Trigger"]),S(),"none"!==(d=angular.isObject(A)?(Object.keys(A).forEach(function(e){E.push(e),I.push(A[e])}),{show:E,hide:I}):Y(A)).show&&d.show.forEach(function(e,t){"outsideClick"===e?(o.on("click",y),W.on("click",P)):e===d.hide[t]?o.on(e,y):e&&(o.on(e,w),o.on(d.hide[t],k)),o.on("keypress",function(e){27===e.which&&k()})});var U,N=a.$eval(i[V+"Animation"]);m.animation=angular.isDefined(N)?!!N:q.animation;var F=V+"AppendToBody";U=F in i&&void 0===i[F]||a.$eval(i[F]),c=angular.isDefined(U)?U:c,a.$on("$destroy",function(){S(),T(),j.remove(m),m=null})}}}}}]}).directive("uibTooltipTemplateTransclude",["$animate","$sce","$compile","$templateRequest",function(c,a,d,f){return{link:function(e,o,t){function r(){n&&(n.remove(),n=null),l&&(l.$destroy(),l=null),s&&(c.leave(s).then(function(){n=null}),n=s,s=null)}var l,n,s,u=e.$eval(t.tooltipTemplateTranscludeScope),p=0;e.$watch(a.parseAsResourceUrl(t.uibTooltipTemplateTransclude),function(a){var i=++p;a?(f(a,!0).then(function(e){if(i===p){var t=u.$new(),n=d(e)(t,function(e){r(),c.enter(e,o)});s=n,(l=t).$emit("$includeContentLoaded",a)}},function(){i===p&&(r(),e.$emit("$includeContentError",a))}),e.$emit("$includeContentRequested",a)):r()}),e.$on("$destroy",r)}}}]).directive("uibTooltipClasses",["$uibPosition",function(i){return{restrict:"A",link:function(e,t,n){if(e.placement){var a=i.parsePlacement(e.placement);t.addClass(a[0])}e.popupClass&&t.addClass(e.popupClass),e.animation&&t.addClass(n.tooltipAnimationClass)}}}]).directive("uibTooltipPopup",function(){return{restrict:"A",scope:{content:"@"},templateUrl:"uib/template/tooltip/tooltip-popup.html"}}).directive("uibTooltip",["$uibTooltip",function(e){return e("uibTooltip","tooltip","mouseenter")}]).directive("uibTooltipTemplatePopup",function(){return{restrict:"A",scope:{contentExp:"&",originScope:"&"},templateUrl:"uib/template/tooltip/tooltip-template-popup.html"}}).directive("uibTooltipTemplate",["$uibTooltip",function(e){return e("uibTooltipTemplate","tooltip","mouseenter",{useContentExp:!0})}]).directive("uibTooltipHtmlPopup",function(){return{restrict:"A",scope:{contentExp:"&"},templateUrl:"uib/template/tooltip/tooltip-html-popup.html"}}).directive("uibTooltipHtml",["$uibTooltip",function(e){return e("uibTooltipHtml","tooltip","mouseenter",{useContentExp:!0})}]),angular.module("ui.bootstrap.popover",["ui.bootstrap.tooltip"]).directive("uibPopoverTemplatePopup",function(){return{restrict:"A",scope:{uibTitle:"@",contentExp:"&",originScope:"&"},templateUrl:"uib/template/popover/popover-template.html"}}).directive("uibPopoverTemplate",["$uibTooltip",function(e){return e("uibPopoverTemplate","popover","click",{useContentExp:!0})}]).directive("uibPopoverHtmlPopup",function(){return{restrict:"A",scope:{contentExp:"&",uibTitle:"@"},templateUrl:"uib/template/popover/popover-html.html"}}).directive("uibPopoverHtml",["$uibTooltip",function(e){return e("uibPopoverHtml","popover","click",{useContentExp:!0})}]).directive("uibPopoverPopup",function(){return{restrict:"A",scope:{uibTitle:"@",content:"@"},templateUrl:"uib/template/popover/popover.html"}}).directive("uibPopover",["$uibTooltip",function(e){return e("uibPopover","popover","click")}]),angular.module("ui.bootstrap.progressbar",[]).constant("uibProgressConfig",{animate:!0,max:100}).controller("UibProgressController",["$scope","$attrs","uibProgressConfig",function(e,t,n){var a=this,i=angular.isDefined(t.animate)?e.$parent.$eval(t.animate):n.animate;function o(){return angular.isDefined(e.maxParam)?e.maxParam:n.max}this.bars=[],e.max=o(),this.addBar=function(t,e,n){i||e.css({transition:"none"}),this.bars.push(t),t.max=o(),t.title=n&&angular.isDefined(n.title)?n.title:"progressbar",t.$watch("value",function(e){t.recalculatePercentage()}),t.recalculatePercentage=function(){var e=a.bars.reduce(function(e,t){return t.percent=+(100*t.value/t.max).toFixed(2),e+t.percent},0);100=this.titles.length?e+1:this.titles[e]},a.rate=function(e){if(!a.readonly&&0<=e&&e<=a.range.length){var t=n.enableReset&&r.$viewValue===e?0:e;r.$setViewValue(t),r.$render()}},a.enter=function(e){a.readonly||(a.value=e),a.onHover({value:e})},a.reset=function(){a.value=r.$viewValue,a.onLeave()},a.onKeydown=function(e){/(37|38|39|40)/.test(e.which)&&(e.preventDefault(),e.stopPropagation(),a.rate(a.value+(38===e.which||39===e.which?1:-1)))},this.render=function(){a.value=r.$viewValue,a.title=n.getTitle(a.value-1)}}]).directive("uibRating",function(){return{require:["uibRating","ngModel"],restrict:"A",scope:{readonly:"=?readOnly",onHover:"&",onLeave:"&"},controller:"UibRatingController",templateUrl:"uib/template/rating/rating.html",link:function(e,t,n,a){var i=a[0],o=a[1];i.init(o)}}}),angular.module("ui.bootstrap.tabs",[]).controller("UibTabsetController",["$scope",function(e){var o,r,l=this;function s(e){for(var t=0;tt.index?1:e.indexm:g||C(i,-720)")).css("position","relative"),s.after(R),(V=s.clone()).attr("placeholder",""),V.attr("tabindex","-1"),V.val(""),V.css({position:"absolute",top:"0px",left:"0px","border-color":"transparent","box-shadow":"none",opacity:1,background:"none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255)",color:"#999"}),s.css({position:"relative","vertical-align":"top","background-color":"transparent"}),V.attr("id")&&V.removeAttr("id"),R.append(V),V.after(s));var Y=angular.element("
");Y.attr({id:q,matches:"matches",active:"activeIdx",select:"select(activeIdx, evt)","move-in-progress":"moveInProgress",query:"query",position:"position","assign-is-open":"assignIsOpen(isOpen)",debounce:"debounceUpdate"}),angular.isDefined(o.typeaheadTemplateUrl)&&Y.attr("template-url",o.typeaheadTemplateUrl),angular.isDefined(o.typeaheadPopupTemplateUrl)&&Y.attr("popup-template-url",o.typeaheadPopupTemplateUrl);function L(){F.matches=[],F.activeIdx=-1,s.attr("aria-expanded",!1),I&&V.val("")}function W(e){return q+"-option-"+e}F.$watch("activeIdx",function(e){e<0?s.removeAttr("aria-activedescendant"):s.attr("aria-activedescendant",W(e))});function z(i,o){var r={$viewValue:i};w(l,!0),C(l,!1),t.when(N.source(l,r)).then(function(e){var t=i===f.$viewValue;if(t&&$)if(e&&0t&&e)&&e.toUpperCase()===F.matches[t].label.toUpperCase()}(i,0)&&(angular.isNumber(F.debounceUpdate)||angular.isObject(F.debounceUpdate)?p(function(){F.select(0,o)},angular.isNumber(F.debounceUpdate)?F.debounceUpdate:F.debounceUpdate.default):F.select(0,o)),I){var a=F.matches[0].label;angular.isString(i)&&0=g?0/g.test(e)}(e)&&a.warn("Unsafe use of typeahead please use ngSanitize"),e=t?(""+e).replace(new RegExp(function(e){return e.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}(t),"gi"),"$&"):e,i||(e=n.trustAsHtml(e)),e}}]),angular.module("uib/template/accordion/accordion-group.html",[]).run(["$templateCache",function(e){e.put("uib/template/accordion/accordion-group.html",'
\n
\n
\n
\n')}]),angular.module("uib/template/accordion/accordion.html",[]).run(["$templateCache",function(e){e.put("uib/template/accordion/accordion.html",'
')}]),angular.module("uib/template/alert/alert.html",[]).run(["$templateCache",function(e){e.put("uib/template/alert/alert.html",'\n
\n')}]),angular.module("uib/template/carousel/carousel.html",[]).run(["$templateCache",function(e){e.put("uib/template/carousel/carousel.html",'\n\n \n previous\n\n\n \n next\n\n\n')}]),angular.module("uib/template/carousel/slide.html",[]).run(["$templateCache",function(e){e.put("uib/template/carousel/slide.html",'
\n')}]),angular.module("uib/template/datepicker/datepicker.html",[]).run(["$templateCache",function(e){e.put("uib/template/datepicker/datepicker.html",'
\n
\n
\n
\n
\n')}]),angular.module("uib/template/datepicker/day.html",[]).run(["$templateCache",function(e){e.put("uib/template/datepicker/day.html",'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
{{::label.abbr}}
{{ weekNumbers[$index] }}\n \n
\n')}]),angular.module("uib/template/datepicker/month.html",[]).run(["$templateCache",function(e){e.put("uib/template/datepicker/month.html",'\n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n')}]),angular.module("uib/template/datepicker/year.html",[]).run(["$templateCache",function(e){e.put("uib/template/datepicker/year.html",'\n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n')}]),angular.module("uib/template/datepickerPopup/popup.html",[]).run(["$templateCache",function(e){e.put("uib/template/datepickerPopup/popup.html",'\n')}]),angular.module("uib/template/modal/window.html",[]).run(["$templateCache",function(e){e.put("uib/template/modal/window.html","
\n")}]),angular.module("uib/template/pager/pager.html",[]).run(["$templateCache",function(e){e.put("uib/template/pager/pager.html",'
  • {{::getText(\'previous\')}}
  • \n
  • {{::getText(\'next\')}}
  • \n')}]),angular.module("uib/template/pagination/pagination.html",[]).run(["$templateCache",function(e){e.put("uib/template/pagination/pagination.html",'
  • {{::getText(\'first\')}}
  • \n
  • {{::getText(\'previous\')}}
  • \n
  • {{page.text}}
  • \n
  • {{::getText(\'next\')}}
  • \n
  • {{::getText(\'last\')}}
  • \n')}]),angular.module("uib/template/tooltip/tooltip-html-popup.html",[]).run(["$templateCache",function(e){e.put("uib/template/tooltip/tooltip-html-popup.html",'
    \n
    \n')}]),angular.module("uib/template/tooltip/tooltip-popup.html",[]).run(["$templateCache",function(e){e.put("uib/template/tooltip/tooltip-popup.html",'
    \n
    \n')}]),angular.module("uib/template/tooltip/tooltip-template-popup.html",[]).run(["$templateCache",function(e){e.put("uib/template/tooltip/tooltip-template-popup.html",'
    \n
    \n')}]),angular.module("uib/template/popover/popover-html.html",[]).run(["$templateCache",function(e){e.put("uib/template/popover/popover-html.html",'
    \n\n
    \n

    \n
    \n
    \n')}]),angular.module("uib/template/popover/popover-template.html",[]).run(["$templateCache",function(e){e.put("uib/template/popover/popover-template.html",'
    \n\n
    \n

    \n
    \n
    \n')}]),angular.module("uib/template/popover/popover.html",[]).run(["$templateCache",function(e){e.put("uib/template/popover/popover.html",'
    \n\n
    \n

    \n
    \n
    \n')}]),angular.module("uib/template/progressbar/bar.html",[]).run(["$templateCache",function(e){e.put("uib/template/progressbar/bar.html",'
    \n')}]),angular.module("uib/template/progressbar/progress.html",[]).run(["$templateCache",function(e){e.put("uib/template/progressbar/progress.html",'
    ')}]),angular.module("uib/template/progressbar/progressbar.html",[]).run(["$templateCache",function(e){e.put("uib/template/progressbar/progressbar.html",'
    \n
    \n
    \n')}]),angular.module("uib/template/rating/rating.html",[]).run(["$templateCache",function(e){e.put("uib/template/rating/rating.html",'\n ({{ $index < value ? \'*\' : \' \' }})\n \n\n')}]),angular.module("uib/template/tabs/tab.html",[]).run(["$templateCache",function(e){e.put("uib/template/tabs/tab.html",'\n')}]),angular.module("uib/template/tabs/tabset.html",[]).run(["$templateCache",function(e){e.put("uib/template/tabs/tabset.html",'
    \n \n
    \n
    \n
    \n
    \n
    \n')}]),angular.module("uib/template/timepicker/timepicker.html",[]).run(["$templateCache",function(e){e.put("uib/template/timepicker/timepicker.html",'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
      
    \n \n :\n \n :\n \n
      
    \n')}]),angular.module("uib/template/typeahead/typeahead-match.html",[]).run(["$templateCache",function(e){e.put("uib/template/typeahead/typeahead-match.html",'\n')}]),angular.module("uib/template/typeahead/typeahead-popup.html",[]).run(["$templateCache",function(e){e.put("uib/template/typeahead/typeahead-popup.html",'\n')}]),angular.module("ui.bootstrap.carousel").run(function(){angular.$$csp().noInlineStyle||angular.$$uibCarouselCss||angular.element(document).find("head").prepend(''),angular.$$uibCarouselCss=!0}),angular.module("ui.bootstrap.datepicker").run(function(){angular.$$csp().noInlineStyle||angular.$$uibDatepickerCss||angular.element(document).find("head").prepend(''),angular.$$uibDatepickerCss=!0}),angular.module("ui.bootstrap.position").run(function(){angular.$$csp().noInlineStyle||angular.$$uibPositionCss||angular.element(document).find("head").prepend(''),angular.$$uibPositionCss=!0}),angular.module("ui.bootstrap.datepickerPopup").run(function(){angular.$$csp().noInlineStyle||angular.$$uibDatepickerpopupCss||angular.element(document).find("head").prepend(''),angular.$$uibDatepickerpopupCss=!0}),angular.module("ui.bootstrap.tooltip").run(function(){angular.$$csp().noInlineStyle||angular.$$uibTooltipCss||angular.element(document).find("head").prepend(''),angular.$$uibTooltipCss=!0}),angular.module("ui.bootstrap.timepicker").run(function(){angular.$$csp().noInlineStyle||angular.$$uibTimepickerCss||angular.element(document).find("head").prepend(''),angular.$$uibTimepickerCss=!0}),angular.module("ui.bootstrap.typeahead").run(function(){angular.$$csp().noInlineStyle||angular.$$uibTypeaheadCss||angular.element(document).find("head").prepend(''),angular.$$uibTypeaheadCss=!0}); \ No newline at end of file diff --git a/web/resource/js/lib/angular-clipboard.js b/web/resource/js/lib/angular-clipboard.js new file mode 100644 index 0000000..3001ed6 --- /dev/null +++ b/web/resource/js/lib/angular-clipboard.js @@ -0,0 +1 @@ +!function(e,o){"function"==typeof define&&define.amd?define(["angular"],o):"object"==typeof module&&module.exports?module.exports=o(require("angular")):e.angularClipboard=o(e.angular)}(this,function(r){return r.module("angular-clipboard",[]).factory("clipboard",["$document","$window",function(n,r){return{copyText:function(e,o){var t=function(e){var o=n[0].createElement("textarea");return o.style.position="absolute",o.textContent=e,o.style.left="-10000px",o.style.top=(r.pageYOffset||n[0].documentElement.scrollTop)+"px",o}(e);n[0].body.appendChild(t),function(e){try{n[0].body.style.webkitUserSelect="initial";var o=n[0].getSelection();if(o.removeAllRanges(),e.select(),!n[0].execCommand("copy"))throw"failure copy";o.removeAllRanges()}finally{n[0].body.style.webkitUserSelect=""}}(t),n[0].body.removeChild(t)},supported:"queryCommandSupported"in n[0]&&n[0].queryCommandSupported("copy")}}]).directive("clipboard",["clipboard",function(n){return{restrict:"A",scope:{onCopied:"&",onError:"&",text:"=",supported:"=?"},link:function(o,t){o.supported=n.supported,t.on("click",function(e){try{n.copyText(o.text,t[0]),r.isFunction(o.onCopied)&&o.$evalAsync(o.onCopied())}catch(e){r.isFunction(o.onError)&&o.$evalAsync(o.onError({err:e}))}})}}}])}); \ No newline at end of file diff --git a/web/resource/js/lib/angular-hotkeys.js b/web/resource/js/lib/angular-hotkeys.js new file mode 100644 index 0000000..ca0f4c6 --- /dev/null +++ b/web/resource/js/lib/angular-hotkeys.js @@ -0,0 +1 @@ +!function(){"use strict";angular.module("cfp.hotkeys",[]).provider("hotkeys",["$injector",function(e){this.includeCheatSheet=!0,this.useNgRoute=e.has("ngViewDirective"),this.templateTitle="Keyboard Shortcuts:",this.templateHeader=null,this.templateFooter=null,this.template='',this.cheatSheetHotkey="?",this.cheatSheetDescription="Show / hide this help menu",this.$get=["$rootElement","$rootScope","$compile","$window","$document",function(e,r,t,i,n){var o=!0;function a(e){var t={command:"⌘",shift:"⇧",left:"←",right:"→",up:"↑",down:"↓",return:"⏎",backspace:"⌫"};e=e.split("+");for(var n=0;n":".","?":"/","|":"\\"},s={option:"alt",command:"meta",return:"enter",escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},t=1;t<20;++t)r[111+t]="f"+t;for(t=0;t<=9;++t)r[t+96]=t;function g(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent("on"+t,n)}function v(e){if("keypress"!=e.type)return r[e.which]?r[e.which]:n[e.which]?n[e.which]:String.fromCharCode(e.which).toLowerCase();var t=String.fromCharCode(e.which);return e.shiftKey||(t=t.toLowerCase()),t}function b(e){return"shift"==e||"ctrl"==e||"alt"==e||"meta"==e}function c(e,t,n){return n||(n=function(){if(!o)for(var e in o={},r)95/g,">")}function w(e,a){var t=!1,o=m.bind(e,e.push);return{start:function(i,e){i=m.lowercase(i),!t&&h[i]&&(t=i),t||!0!==p[i]||(o("<"),o(i),m.forEach(e,function(e,t){var n=m.lowercase(t),r="img"===i&&"src"===n||"background"===n;!0!==v[n]||!0===f[n]&&!a(e,r)||(o(" "),o(t),o('="'),o(k(e)),o('"'))}),o(">"))},end:function(e){e=m.lowercase(e),t||!0!==p[e]||!0===r[e]||(o("")),e==t&&(t=!1)},chars:function(e){t||o(k(e))}}}function C(e){if(e.nodeType===s.Node.ELEMENT_NODE)for(var t=e.attributes,n=0,r=t.length;n"\u201d\u2019]/i,h=/^mailto:/i,p=m.$$minErr("linky"),f=m.isString;return function(e,r,i){if(null==e||""===e)return e;if(!f(e))throw p("notstring","Expected string but received: {0}",e);for(var t,n,a,o=e,s=[];t=o.match(u);)n=t[0],t[2]||t[4]||(n=(t[3]?"http://":"mailto:")+n),a=t.index,l(o.substr(0,a)),c(n,t[0].replace(h,"")),o=o.substring(a+t[0].length);return l(o),d(s.join(""));function l(e){var t,n;e&&s.push((t=e,w(n=[],m.noop).chars(t),n.join("")))}function c(e,t){var n;if(s.push("'),l(t),s.push("")}}}])}(window,window.angular); \ No newline at end of file diff --git a/web/resource/js/lib/angular-scroll.js b/web/resource/js/lib/angular-scroll.js new file mode 100644 index 0000000..26957ed --- /dev/null +++ b/web/resource/js/lib/angular-scroll.js @@ -0,0 +1 @@ +var mod;(mod=angular.module("infinite-scroll",[])).directive("infiniteScroll",["$rootScope","$window","$timeout",function(f,a,i){return{link:function(e,t,l){var o,n,r,c;return a=angular.element(a),r=0,null!=l.infiniteScrollDistance&&e.$watch(l.infiniteScrollDistance,function(i){return r=parseInt(i,10)}),o=!(c=!0),null!=l.infiniteScrollDisabled&&e.$watch(l.infiniteScrollDisabled,function(i){if((c=!i)&&o)return o=!1,n()}),n=function(){var i,n;return n=a.height()+a.scrollTop(),(i=t.offset().top+t.height()-n<=a.height()*r)&&c?f.$$phase?e.$eval(l.infiniteScroll):e.$apply(l.infiniteScroll):i?o=!0:void 0},a.on("scroll",n),e.$on("$destroy",function(){return a.off("scroll",n)}),i(function(){return l.infiniteScrollImmediateCheck?e.$eval(l.infiniteScrollImmediateCheck)?n():void 0:n()},0)}}}]); \ No newline at end of file diff --git a/web/resource/js/lib/angular-touch.js b/web/resource/js/lib/angular-touch.js new file mode 100644 index 0000000..0d1e2e0 --- /dev/null +++ b/web/resource/js/lib/angular-touch.js @@ -0,0 +1 @@ +!function(e,D){"use strict";var n=D.module("ngTouch",[]);function t(n,t){var o=!1,c=!1;this.ngClickOverrideEnabled=function(e){return D.isDefined(e)?(e&&!c&&(c=!0,i.$$moduleName="ngTouch",t.directive("ngClick",i),n.decorator("ngClickDirective",["$delegate",function(e){if(o)e.shift();else for(var n=e.length-1;0<=n;){if("ngTouch"===e[n].$$moduleName){e.splice(n,1);break}n--}return e}])),o=e,this):o},this.$get=function(){return{ngClickOverrideEnabled:function(){return o}}}}n.provider("$touch",t),t.$inject=["$provide","$compileProvider"],n.factory("$swipe",[function(){var c={mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},touch:{start:"touchstart",move:"touchmove",end:"touchend",cancel:"touchcancel"}};function s(e){var n=e.originalEvent||e,t=n.touches&&n.touches.length?n.touches:[n],o=n.changedTouches&&n.changedTouches[0]||t[0];return{x:o.clientX,y:o.clientY}}function l(e,t){var o=[];return D.forEach(e,function(e){var n=c[e][t];n&&o.push(n)}),o.join(" ")}return{bind:function(e,t,n){var o,c,i,r,u=!1;n=n||["mouse","touch"],e.on(l(n,"start"),function(e){i=s(e),u=!0,c=o=0,r=i,t.start&&t.start(i,e)});var a=l(n,"cancel");a&&e.on(a,function(e){u=!1,t.cancel&&t.cancel(e)}),e.on(l(n,"move"),function(e){if(u&&i){var n=s(e);if(o+=Math.abs(n.x-r.x),c+=Math.abs(n.y-r.y),r=n,!(o<10&&c<10))return or)){var n=e.touches&&e.touches.length?e.touches:[e],t=n[0].clientX,o=n[0].clientY;t<1&&o<1||i&&i[0]===t&&i[1]===o||(i&&(i=null),"label"===function(e){return D.lowercase(e.nodeName||e[0]&&e[0].nodeName)}(e.target)&&(i=[t,o]),$(m,t,o)||(e.stopPropagation(),e.preventDefault(),e.target&&e.target.blur&&e.target.blur()))}}function k(e){var n=e.touches&&e.touches.length?e.touches:[e],t=n[0].clientX,o=n[0].clientY;m.push(t,o),c(function(){for(var e=0;e").append(e).html();try{return e[0].nodeType===Ne?q(t):t.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/,function(e,t){return"<"+q(t)})}catch(e){return q(t)}}function K(e){try{return decodeURIComponent(e)}catch(e){}}function X(e){var i={};return le((e||"").split("&"),function(e){var t,n,r;e&&(n=e=e.replace(/\+/g,"%20"),-1!==(t=e.indexOf("="))&&(n=e.substring(0,t),r=e.substring(t+1)),H(n=K(n))&&(r=!H(r)||K(r),R.call(i,n)?$e(i[n])?i[n].push(r):i[n]=[i[n],r]:i[n]=r))}),i}function Q(e){var n=[];return le(e,function(e,t){$e(e)?le(e,function(e){n.push(te(t,!0)+(!0===e?"":"="+te(e,!0)))}):n.push(te(t,!0)+(!0===e?"":"="+te(e,!0)))}),n.length?n.join("&"):""}function ee(e){return te(e,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function te(e,t){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%3B/gi,";").replace(/%20/g,t?"%20":"+")}var ne=["ng-","data-ng-","ng:","x-ng-"];function re(n,r,i){function t(){if((n=ce(n)).injector()){var e=n[0]===_.document?"document":Ee(n);throw c("btstrpd","App already bootstrapped with this element '{0}'",e.replace(//,">"))}(r=r||[]).unshift(["$provide",function(e){e.value("$rootElement",n)}]),i.debugInfoEnabled&&r.push(["$compileProvider",function(e){e.debugInfoEnabled(!0)}]),r.unshift("ng");var t=Pt(r,i.strictDi);return t.invoke(["$rootScope","$rootElement","$compile","$injector",function(e,t,n,r){e.$apply(function(){t.data("$injector",r),n(t)(e)})}]),t}pe(i)||(i={}),i=fe({strictDi:!1},i);var e=/^NG_ENABLE_DEBUG_INFO!/,o=/^NG_DEFER_BOOTSTRAP!/;if(_&&e.test(_.name)&&(i.debugInfoEnabled=!0,_.name=_.name.replace(e,"")),_&&!o.test(_.name))return t();_.name=_.name.replace(o,""),E.resumeBootstrap=function(e){return le(e,function(e){r.push(e)}),t()},ve(E.resumeDeferredBootstrap)&&E.resumeDeferredBootstrap()}var ie=/[A-Z]/g;function Ae(e,n){return n=n||"_",e.replace(ie,function(e,t){return(t?n:"")+e.toLowerCase()})}var oe=!1;function ke(e,t,n){if(!e)throw c("areq","Argument '{0}' is {1}",t||"?",n||"required");return e}function ae(e,t,n){return n&&$e(e)&&(e=e[e.length-1]),ke(ve(e),t,"not a function, got "+(e&&"object"==typeof e?e.constructor.name||"Object":typeof e)),e}function se(e,t){if("hasOwnProperty"===e)throw c("badname","hasOwnProperty is not a valid {0} name",t)}function ue(e,t,n){if(!t)return e;for(var r,i=t.split("."),o=e,a=i.length,s=0;s(?:<\/\1>|)$/,We=/<|&#?\w+;/,Ge=/<([\w:-]+)/,Je=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,Ye={option:[1,'"],thead:[1,"","
    "],col:[2,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],_default:[0,"",""]};function Ze(e){return!We.test(e)}function Ke(e){var t=e.nodeType;return t===Te||!t||t===je}function Xe(e,t){var n,r,i,o,a=t.createDocumentFragment(),s=[];if(Ze(e))s.push(t.createTextNode(e));else{for(n=n||a.appendChild(t.createElement("div")),r=(Ge.exec(e)||["",""])[1].toLowerCase(),i=Ye[r]||Ye._default,n.innerHTML=i[1]+e.replace(Je,"<$1>")+i[2],o=i[0];o--;)n=n.lastChild;s=W(s,n.childNodes),(n=a.firstChild).textContent=""}return a.textContent="",a.innerHTML="",le(s,function(e){a.appendChild(e)}),a}function Qe(e,t){var n=e.parentNode;n&&n.replaceChild(t,e),t.appendChild(e)}Ye.optgroup=Ye.option,Ye.tbody=Ye.tfoot=Ye.colgroup=Ye.caption=Ye.thead,Ye.th=Ye.td;var et=_.Node.prototype.contains||function(e){return!!(16&this.compareDocumentPosition(e))};function tt(e){if(e instanceof tt)return e;var t,n,r,i;if(de(e)&&(e=ye(e),t=!0),!(this instanceof tt)){if(t&&"<"!=e.charAt(0))throw He("nosel","Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element");return new tt(e)}ft(this,t?(n=e,r=r||_.document,(i=ze.exec(n))?[r.createElement(i[1])]:(i=Xe(n,r))?i.childNodes:[]):e)}function nt(e){return e.cloneNode(!0)}function rt(e,t){if(t||ot(e),e.querySelectorAll)for(var n=e.querySelectorAll("*"),r=0,i=n.length;r/,Mt=/^[^\(]*\(\s*([^\)]*)\)/m,Tt=/,/,Nt=/^\s*(_?)(\S+?)\1\s*$/,Vt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,jt=d("$injector");function It(e){return Function.prototype.toString.call(e)+" "}function Dt(e){var t=It(e).replace(Vt,"");return t.match(Ot)||t.match(Mt)}function Pt(e,c){c=!0===c;var i={},a="Provider",s=[],o=new At([],!0),l={$provide:{provider:h(p),factory:h(d),service:h(function(e,t){return d(e,["$injector",function(e){return e.instantiate(t)}])}),value:h(function(e,t){return d(e,A(t),!1)}),constant:h(function(e,t){se(e,"constant"),l[e]=t,n[e]=t}),decorator:function(e,t){var n=u.get(e+a),r=n.$get;n.$get=function(){var e=f.invoke(r,n);return f.invoke(t,null,{$delegate:e})}}}},u=l.$injector=$(l,function(e,t){throw E.isString(t)&&s.push(t),jt("unpr","Unknown provider: {0}",s.join(" <- "))}),n={},t=$(n,function(e,t){var n=u.get(e+a,t);return f.invoke(n.$get,n,void 0,e)}),f=t;l["$injector"+a]={$get:A(t)};var r=function n(e){ke(he(e)||$e(e),"modulesToLoad","not an array");var r,i=[];return le(e,function(e){if(!o.get(e)){o.put(e,!0);try{de(e)?(r=v(e),i=i.concat(n(r.requires)).concat(r._runBlocks),t(r._invokeQueue),t(r._configBlocks)):ve(e)?i.push(u.invoke(e)):$e(e)?i.push(u.invoke(e)):ae(e,"module")}catch(t){throw $e(e)&&(e=e[e.length-1]),t.message&&t.stack&&-1==t.stack.indexOf(t.message)&&(t=t.message+"\n"+t.stack),jt("modulerr","Failed to instantiate module {0} due to:\n{1}",e,t.stack||t.message||t)}}function t(e){var t,n;for(t=0,n=e.length;t";var r=b.firstChild.attributes,i=r[0];r.removeNamedItem(i.name),i.value=n,e.attributes.setNamedItem(i)}(this.$$element[0],r,t));var v=this.$$observers;v&&le(v[s],function(e){try{e(t)}catch(e){B(e)}})},$observe:function(e,t){var n=this,r=n.$$observers||(n.$$observers=Me()),i=r[e]||(r[e]=[]);return i.push(t),o.$evalAsync(function(){i.$$inter||!n.hasOwnProperty(e)||he(n[e])||t(n[e])}),function(){we(i,t)}}};var n=C.startSymbol(),u=C.endSymbol(),G="{{"==n&&"}}"==u?x:function(e){return e.replace(/\{\{/g,n).replace(/}}/g,u)},E=/^ngAttr[A-Z]/,A=/^(.+)Start$/;return J.$$addBindingInfo=c?function(e,t){var n=e.data("$binding")||[];$e(t)?n=n.concat(t):n.push(t),e.data("$binding",n)}:L,J.$$addBindingClass=c?function(e){O(e,"ng-binding")}:L,J.$$addScopeInfo=c?function(e,t,n,r){var i=n?r?"$isolateScopeNoTemplate":"$isolateScope":"$scope";e.data(i,t)}:L,J.$$addScopeClass=c?function(e,t){O(e,t?"ng-isolate-scope":"ng-scope")}:L,J.$$createComment=function(e,t){var n="";return c&&(n=" "+(e||"")+": ",t&&(n+=t+" ")),_.document.createComment(n)},J;function J(c,e,t,n,l){c instanceof ce||(c=ce(c));for(var r=/\S+/,i=0,o=c.length;i").append(c).html())):t?vt.clone.call(c):c,a)for(var u in a)r.data("$"+u+"Controller",a[u].instance);return J.$$addScopeInfo(r,e),t&&t(r,e),f&&f(e,r,r,o),r}}function M(e,p,t,n,r,i){for(var o,a,s,u,c,l,d,$=[],f=0;fo.priority)break;if((c=o.scope)&&(o.templateUrl||(pe(c)?(re("new/isolated scope",k||E,o,d),k=o):re("new/isolated scope",k,o,d)),E=E||o),a=o.name,!m&&(o.replace&&(o.templateUrl||o.template)||o.transclude&&!o.$$tlb)){for(var V,j=y+1;V=e[j++];)if(V.transclude&&!V.$$tlb||V.replace&&(V.templateUrl||V.template)){g=!0;break}m=!0}if(!o.templateUrl&&o.controller&&(c=o.controller,A=A||Me(),re("'"+a+"' controller",A[a],o,d),A[a]=o),c=o.transclude)if(h=!0,o.$$tlb||(re("transclusion",f,o,d),f=o),"element"==c)M=!0,l=o.priority,s=d,d=x.$$element=ce(J.$$createComment(a,x[a])),w=d[0],oe(n,Se(s),w),s[0].$$parentNode=s[0].parentNode,v=X(g,s,t,l,$&&$.name,{nonTlbTranscludeDirective:f});else{var I=Me();if(s=ce(nt(w)).contents(),pe(c)){s=[];var D=Me(),P=Me();for(var _ in le(c,function(e,t){var n="?"===e.charAt(0);e=n?e.substring(1):e,D[e]=t,I[t]=null,P[t]=n}),le(d.contents(),function(e){var t=D[rn(be(e))];t?(P[t]=!0,I[t]=I[t]||[],I[t].push(e)):s.push(e)}),le(P,function(e,t){if(!e)throw Xt("reqslot","Required transclusion slot `{0}` was not filled.",t)}),I)I[_]&&(I[_]=X(g,I[_],t))}d.empty(),(v=X(g,s,t,void 0,void 0,{needsNewScope:o.$$isolateScope||o.$$newScope})).$$slots=I}if(o.template)if(p=!0,re("template",O,o,d),c=ve((O=o).template)?o.template(d,x):o.template,c=G(c),o.replace){if($=o,s=Ze(c)?[]:an(ie(o.templateNamespace,ye(c))),w=s[0],1!=s.length||w.nodeType!==Te)throw Xt("tplrt","Template for directive '{0}' must have exactly one root element. {1}",a,"");oe(n,d,w);var R={$attr:{}},q=Y(w,[],R),F=e.splice(y+1,e.length-(y+1));(k||E)&&ee(q,k,E),e=e.concat(q).concat(F),te(x,R),b=e.length}else d.html(c);if(o.templateUrl)p=!0,re("template",O,o,d),(O=o).replace&&($=o),H=ne(e.splice(y,e.length-y),d,x,n,h&&v,S,C,{controllerDirectives:A,newScopeDirective:E!==o&&E,newIsolateScopeDirective:k,templateDirective:O,nonTlbTranscludeDirective:f}),b=e.length;else if(o.compile)try{u=o.compile(d,x,v);var U=o.$$originalDirective||o;ve(u)?L(null,Ce(U,u),T,N):u&&L(Ce(U,u.pre),Ce(U,u.post),T,N)}catch(e){B(e,Ee(d))}o.terminal&&(H.terminal=!0,l=Math.max(l,o.priority))}return H.scope=E&&!0===E.scope,H.transcludeOnThisElement=h,H.templateOnThisElement=p,H.transclude=v,i.hasElementTranscludeDirective=M,H;function L(e,t,n,r){e&&(n&&(e=K(e,n,r)),e.require=o.require,e.directiveName=a,k!==o&&!o.$$isolateScope||(e=ae(e,{isolateScope:!0})),S.push(e)),t&&(n&&(t=K(t,n,r)),t.require=o.require,t.directiveName=a,k!==o&&!o.$$isolateScope||(t=ae(t,{isolateScope:!0})),C.push(t))}function H(e,t,n,r,a){var i,o,s,u,c,l,f,h,p,d;for(var $ in w===n?h=(p=x).$$element:p=new W(h=ce(n),x),c=t,k?u=t.$new(!0):E&&(c=t.$parent),a&&((f=function(e,t,n,r){var i;if(me(e)||(r=n,n=t,t=e,e=void 0),M&&(i=l),n||(n=M?h.parent():h),!r)return a(e,t,i,n,b);var o=a.$$slots[r];if(o)return o(e,t,i,n,b);if(he(o))throw Xt("noslot",'No parent directive that requires a transclusion with slot name "{0}". Element: {1}',r,Ee(h))}).$$boundTransclude=a,f.isSlotFilled=function(e){return!!a.$$slots[e]}),A&&(l=function(e,t,n,r,i,o,a){var s=Me();for(var u in r){var c=r[u],l={$scope:c===a||c.$$isolateScope?i:o,$element:e,$attrs:t,$transclude:n},f=c.controller;"@"==f&&(f=t[c.name]);var h=z(f,l,!0,c.controllerAs);s[c.name]=h,e.data("$"+c.name+"Controller",h.instance)}return s}(h,p,f,A,u,t,k)),k&&(J.$$addScopeInfo(h,u,!0,!(O&&(O===k||O===k.$$originalDirective))),J.$$addScopeClass(h,!0),u.$$isolateBindings=k.$$isolateBindings,(d=ue(t,p,u,u.$$isolateBindings,k)).removeWatches&&u.$on("$destroy",d.removeWatches)),l){var v=A[$],m=l[$],g=v.$$bindings.bindToController;m.identifier&&g?m.bindingInfo=ue(c,p,m.instance,g,v):m.bindingInfo={};var y=m();y!==m.instance&&(m.instance=y,h.data("$"+v.name+"Controller",y),m.bindingInfo.removeWatches&&m.bindingInfo.removeWatches(),m.bindingInfo=ue(c,p,m.instance,g,v))}for(le(A,function(e,t){var n=e.require;e.bindToController&&!$e(n)&&pe(n)&&fe(l[t].instance,Q(t,n,h,l))}),le(l,function(e){var t=e.instance;ve(t.$onChanges)&&t.$onChanges(e.bindingInfo.initialChanges),ve(t.$onInit)&&t.$onInit(),ve(t.$onDestroy)&&c.$on("$destroy",function(){t.$onDestroy()})}),i=0,o=S.length;iu.priority)&&-1!=u.restrict.indexOf(n)){if(o&&(u=U(u,{$$start:o,$$end:a})),!u.$$bindings){var h=u.$$bindings=v(u,u.name);pe(h.isolateScope)&&(u.$$isolateBindings=h.isolateScope)}e.push(u),s=u}}catch(e){B(e)}return s}function V(e){if(d.hasOwnProperty(e))for(var t=p.get(e+$),n=0,r=t.length;n"+t+"",n.childNodes[0].childNodes;default:return t}}function I(e,t,o,a,s){var u=function(e,t){if("srcdoc"==t)return r.HTML;var n=be(e);return"xlinkHref"==t||"form"==n&&"action"==t||"img"!=n&&("src"==t||"ngSrc"==t)?r.RESOURCE_URL:void 0}(e,a);s=l[a]||s;var c=C(o,!0,u,s);if(c){if("multiple"===a&&"select"===be(e))throw Xt("selmulti","Binding to the 'multiple' attribute is not supported. Element: {0}",Ee(e));t.push({priority:100,compile:function(){return{pre:function(e,t,n){var r=n.$$observers||(n.$$observers=Me());if(f.test(a))throw Xt("nodomevents","Interpolations for HTML DOM event attributes are disallowed. Please use the ng- versions (such as ng-click instead of onclick) instead.");var i=n[a];i!==o&&(c=i&&C(i,!0,u,s),o=i),c&&(n[a]=c(e),(r[a]||(r[a]=[])).$$inter=!0,(n.$$observers&&n.$$observers[a].$$scope||e).$watch(c,function(e,t){"class"===a&&e!=t?n.$updateClass(e,t):n.$set(a,e)}))}}}})}}function oe(e,t,n){var r,i,o=t[0],a=t.length,s=o.parentNode;if(e)for(r=0,i=e.length;r tag to be present!");n=(r=l).substring(0,r.indexOf("/",r.indexOf("//")+2))+(c||"/"),e=t.history?zn:Gn}else n=Hn(l),e=Wn;var f,h=(f=n).substr(0,Hn(f).lastIndexOf("/")+1);(u=new e(n,h,"#"+m)).$$parseLinkUrl(l,l),u.$$state=s.state();var p=/^\s*(javascript|mailto):/i;function d(e,t,n){var r=u.url(),i=u.$$state;try{s.url(e,t,n),u.$$state=s.state()}catch(e){throw u.url(r),u.$$state=i,e}}i.on("click",function(e){if(g.rewriteLinks&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&2!=e.which&&2!=e.button){for(var t=ce(e.target);"a"!==be(t[0]);)if(t[0]===i[0]||!(t=t.parent())[0])return;var n=t.prop("href"),r=t.attr("href")||t.attr("xlink:href");pe(n)&&"[object SVGAnimatedString]"===n.toString()&&(n=Wr(n.animVal).href),p.test(n)||!n||t.attr("target")||e.isDefaultPrevented()||u.$$parseLinkUrl(n,r)&&(e.preventDefault(),u.absUrl()!=s.url()&&(a.$apply(),o.angular["ff-684208-preventDefault"]=!0))}}),Bn(u.absUrl())!=Bn(l)&&s.url(u.absUrl(),!0);var $=!0;return s.onUrlChange(function(r,i){he(Ln(h,r))?o.location.href=r:(a.$evalAsync(function(){var e,t=u.absUrl(),n=u.$$state;r=Bn(r),u.$$parse(r),u.$$state=i,e=a.$broadcast("$locationChangeStart",r,t,i,n).defaultPrevented,u.absUrl()===r&&(e?(u.$$parse(t),d(t,!1,u.$$state=n)):($=!1,v(t,n)))}),a.$$phase||a.$digest())}),a.$watch(function(){var n=Bn(s.url()),e=Bn(u.absUrl()),r=s.state(),i=u.$$replace,o=n!==e||u.$$html5&&t.history&&r!==u.$$state;($||o)&&($=!1,a.$evalAsync(function(){var e=u.absUrl(),t=a.$broadcast("$locationChangeStart",e,n,u.$$state,r).defaultPrevented;u.absUrl()===e&&(t?(u.$$parse(n),u.$$state=r):(o&&d(e,i,r===u.$$state?null:u.$$state),v(n,r)))})),u.$$replace=!1}),u;function v(e,t){a.$broadcast("$locationChangeSuccess",u.absUrl(),e,u.$$state,t)}}]}function Xn(){var n=!0,r=this;this.debugEnabled=function(e){return H(e)?(n=e,this):n},this.$get=["$window",function(i){return{log:t("log"),info:t("info"),warn:t("warn"),error:t("error"),debug:(e=t("debug"),function(){n&&e.apply(r,arguments)})};var e;function t(e){var t=i.console||{},r=t[e]||t.log||L,n=!1;try{n=!!r.apply}catch(e){}return n?function(){var n=[];return le(arguments,function(e){var t;n.push(((t=e)instanceof Error&&(t.stack?t=t.message&&-1===t.stack.indexOf(t.message)?"Error: "+t.message+"\n"+t.stack:t.stack:t.sourceURL&&(t=t.message+"\n"+t.sourceURL+":"+t.line)),t))}),r.apply(t,n)}:function(e,t){r(e,null==t?"":t)}}}]}le([Gn,Wn,zn],function(t){t.prototype=Object.create(Jn),t.prototype.state=function(e){if(!arguments.length)return this.$$state;if(t!==zn||!this.$$html5)throw _n("nostate","History API state support is available only in HTML5 mode and only in browsers supporting HTML5 History API");return this.$$state=he(e)?null:e,this}});var Qn=d("$parse");function er(e,t){if("__defineGetter__"===e||"__defineSetter__"===e||"__lookupGetter__"===e||"__lookupSetter__"===e||"__proto__"===e)throw Qn("isecfld","Attempting to access a disallowed field in Angular expressions! Expression: {0}",t);return e}function tr(e){return e+""}function nr(e,t){if(e){if(e.constructor===e)throw Qn("isecfn","Referencing Function in Angular expressions is disallowed! Expression: {0}",t);if(e.window===e)throw Qn("isecwindow","Referencing the Window in Angular expressions is disallowed! Expression: {0}",t);if(e.children&&(e.nodeName||e.prop&&e.attr&&e.find))throw Qn("isecdom","Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}",t);if(e===Object)throw Qn("isecobj","Referencing Object in Angular expressions is disallowed! Expression: {0}",t)}return e}var rr=Function.prototype.call,ir=Function.prototype.apply,or=Function.prototype.bind;function ar(e,t){if(e){if(e.constructor===e)throw Qn("isecfn","Referencing Function in Angular expressions is disallowed! Expression: {0}",t);if(e===rr||e===ir||e===or)throw Qn("isecff","Referencing call, apply or bind in Angular expressions is disallowed! Expression: {0}",t)}}function sr(e,t){if(e&&(e===(0).constructor||e===(!1).constructor||e==="".constructor||e==={}.constructor||e===[].constructor||e===Function.constructor))throw Qn("isecaf","Assigning to a constructor is disallowed! Expression: {0}",t)}var ur=Me();le("+ - * / % === !== == != < > <= >= && || ! = |".split(" "),function(e){ur[e]=!0});function cr(e){this.options=e}var lr={n:"\n",f:"\f",r:"\r",t:"\t",v:"\v","'":"'",'"':'"'};cr.prototype={constructor:cr,lex:function(e){for(this.text=e,this.index=0,this.tokens=[];this.index","<=",">=");)t={type:fr.BinaryExpression,operator:e.text,left:t,right:this.additive()};return t},additive:function(){for(var e,t=this.multiplicative();e=this.expect("+","-");)t={type:fr.BinaryExpression,operator:e.text,left:t,right:this.multiplicative()};return t},multiplicative:function(){for(var e,t=this.unary();e=this.expect("*","/","%");)t={type:fr.BinaryExpression,operator:e.text,left:t,right:this.unary()};return t},unary:function(){var e;return(e=this.expect("+","-","!"))?{type:fr.UnaryExpression,operator:e.text,prefix:!0,argument:this.unary()}:this.primary()},primary:function(){var e,t;for(this.expect("(")?(e=this.filterChain(),this.consume(")")):this.expect("[")?e=this.arrayDeclaration():this.expect("{")?e=this.object():this.selfReferential.hasOwnProperty(this.peek().text)?e=D(this.selfReferential[this.consume().text]):this.options.literals.hasOwnProperty(this.peek().text)?e={type:fr.Literal,value:this.options.literals[this.consume().text]}:this.peek().identifier?e=this.identifier():this.peek().constant?e=this.constant():this.throwError("not a primary expression",this.peek());t=this.expect("(","[",".");)"("===t.text?(e={type:fr.CallExpression,callee:e,arguments:this.parseArguments()},this.consume(")")):"["===t.text?(e={type:fr.MemberExpression,object:e,property:this.expression(),computed:!0},this.consume("]")):"."===t.text?e={type:fr.MemberExpression,object:e,property:this.identifier(),computed:!1}:this.throwError("IMPOSSIBLE");return e},filter:function(e){for(var t=[e],n={type:fr.CallExpression,callee:this.identifier(),arguments:t,filter:!0};this.expect(":");)t.push(this.expression());return n},parseArguments:function(){var e=[];if(")"!==this.peekToken().text)for(;e.push(this.expression()),this.expect(","););return e},identifier:function(){var e=this.consume();return e.identifier||this.throwError("is not a valid identifier",e),{type:fr.Identifier,name:e.text}},constant:function(){return{type:fr.Literal,value:this.consume().value}},arrayDeclaration:function(){var e=[];if("]"!==this.peekToken().text)do{if(this.peek("]"))break;e.push(this.expression())}while(this.expect(","));return this.consume("]"),{type:fr.ArrayExpression,elements:e}},object:function(){var e,t=[];if("}"!==this.peekToken().text)do{if(this.peek("}"))break;e={type:fr.Property,kind:"init"},this.peek().constant?(e.key=this.constant(),e.computed=!1,this.consume(":"),e.value=this.expression()):this.peek().identifier?(e.key=this.identifier(),e.computed=!1,this.peek(":")?(this.consume(":"),e.value=this.expression()):e.value=e.key):this.peek("[")?(this.consume("["),e.key=this.expression(),this.consume("]"),e.computed=!0,this.consume(":"),e.value=this.expression()):this.throwError("invalid key",this.peek()),t.push(e)}while(this.expect(","));return this.consume("}"),{type:fr.ObjectExpression,properties:t}},throwError:function(e,t){throw Qn("syntax","Syntax Error: Token '{0}' {1} at column {2} of the expression [{3}] starting at [{4}].",t.text,e,t.index+1,this.text,this.text.substring(t.index))},consume:function(e){if(0===this.tokens.length)throw Qn("ueoe","Unexpected end of expression: {0}",this.text);var t=this.expect(e);return t||this.throwError("is unexpected, expecting ["+e+"]",this.peek()),t},peekToken:function(){if(0===this.tokens.length)throw Qn("ueoe","Unexpected end of expression: {0}",this.text);return this.tokens[0]},peek:function(e,t,n,r){return this.peekAhead(0,e,t,n,r)},peekAhead:function(e,t,n,r,i){if(this.tokens.length>e){var o=this.tokens[e],a=o.text;if(a===t||a===n||a===r||a===i||!t&&!n&&!r&&!i)return o}return!1},expect:function(e,t,n,r){var i=this.peek(e,t,n,r);return!!i&&(this.tokens.shift(),i)},selfReferential:{this:{type:fr.ThisExpression},$locals:{type:fr.LocalsExpression}}},wr.prototype={compile:function(e,t){var i=this,n=this.astBuilder.ast(e);this.state={nextId:0,filters:{},expensiveChecks:t,fn:{vars:[],body:[],own:{}},assign:{vars:[],body:[],own:{}},inputs:[]},$r(n,i.$filter);var r,o="";if(this.stage="assign",r=gr(n)){this.state.computing="assign";var a=this.nextId();this.recurse(r,a),this.return_(a),o="fn.assign="+this.generateFunction("assign","s,v,l")}var s=vr(n.body);i.stage="inputs",le(s,function(e,t){var n="fn"+t;i.state[n]={vars:[],body:[],own:{}},i.state.computing=n;var r=i.nextId();i.recurse(e,r),i.return_(r),i.state.inputs.push(n),e.watchId=t}),this.state.computing="fn",this.stage="main",this.recurse(n);var u='"'+this.USE+" "+this.STRICT+'";\n'+this.filterPrefix()+"var fn="+this.generateFunction("fn","s,l,a,i")+o+this.watchFns()+"return fn;",c=new Function("$filter","ensureSafeMemberName","ensureSafeObject","ensureSafeFunction","getStringValue","ensureSafeAssignContext","ifDefined","plus","text",u)(this.$filter,er,nr,ar,tr,sr,hr,pr,e);return this.state=this.stage=void 0,c.literal=yr(n),c.constant=br(n),c},USE:"use",STRICT:"strict",watchFns:function(){var t=[],e=this.state.inputs,n=this;return le(e,function(e){t.push("var "+e+"="+n.generateFunction(e,"s"))}),e.length&&t.push("fn.inputs=["+e.join(",")+"];"),t.join("")},generateFunction:function(e,t){return"function("+t+"){"+this.varsPrefix(e)+this.body(e)+"};"},filterPrefix:function(){var n=[],r=this;return le(this.state.filters,function(e,t){n.push(e+"=$filter("+r.escape(t)+")")}),n.length?"var "+n.join(",")+";":""},varsPrefix:function(e){return this.state[e].vars.length?"var "+this.state[e].vars.join(",")+";":""},body:function(e){return this.state[e].body.join("")},recurse:function(n,t,e,r,i,o){var a,s,u,c,l,f=this;if(r=r||L,!o&&H(n.watchId))return t=t||this.nextId(),void this.if_("i",this.lazyAssign(t,this.computedMember("i",n.watchId)),this.lazyRecurse(n,t,e,r,i,!0));switch(n.type){case fr.Program:le(n.body,function(e,t){f.recurse(e.expression,void 0,void 0,function(e){s=e}),t!==n.body.length-1?f.current().body.push(s,";"):f.return_(s)});break;case fr.Literal:c=this.escape(n.value),this.assign(t,c),r(c);break;case fr.UnaryExpression:this.recurse(n.argument,void 0,void 0,function(e){s=e}),c=n.operator+"("+this.ifDefined(s,0)+")",this.assign(t,c),r(c);break;case fr.BinaryExpression:this.recurse(n.left,void 0,void 0,function(e){a=e}),this.recurse(n.right,void 0,void 0,function(e){s=e}),c="+"===n.operator?this.plus(a,s):"-"===n.operator?this.ifDefined(a,0)+n.operator+this.ifDefined(s,0):"("+a+")"+n.operator+"("+s+")",this.assign(t,c),r(c);break;case fr.LogicalExpression:t=t||this.nextId(),f.recurse(n.left,t),f.if_("&&"===n.operator?t:f.not(t),f.lazyRecurse(n.right,t)),r(t);break;case fr.ConditionalExpression:t=t||this.nextId(),f.recurse(n.test,t),f.if_(t,f.lazyRecurse(n.alternate,t),f.lazyRecurse(n.consequent,t)),r(t);break;case fr.Identifier:t=t||this.nextId(),e&&(e.context="inputs"===f.stage?"s":this.assign(this.nextId(),this.getHasOwnProperty("l",n.name)+"?l:s"),e.computed=!1,e.name=n.name),er(n.name),f.if_("inputs"===f.stage||f.not(f.getHasOwnProperty("l",n.name)),function(){f.if_("inputs"===f.stage||"s",function(){i&&1!==i&&f.if_(f.not(f.nonComputedMember("s",n.name)),f.lazyAssign(f.nonComputedMember("s",n.name),"{}")),f.assign(t,f.nonComputedMember("s",n.name))})},t&&f.lazyAssign(t,f.nonComputedMember("l",n.name))),(f.state.expensiveChecks||Cr(n.name))&&f.addEnsureSafeObject(t),r(t);break;case fr.MemberExpression:a=e&&(e.context=this.nextId())||this.nextId(),t=t||this.nextId(),f.recurse(n.object,a,void 0,function(){f.if_(f.notNull(a),function(){i&&1!==i&&f.addEnsureSafeAssignContext(a),n.computed?(s=f.nextId(),f.recurse(n.property,s),f.getStringValue(s),f.addEnsureSafeMemberName(s),i&&1!==i&&f.if_(f.not(f.computedMember(a,s)),f.lazyAssign(f.computedMember(a,s),"{}")),c=f.ensureSafeObject(f.computedMember(a,s)),f.assign(t,c),e&&(e.computed=!0,e.name=s)):(er(n.property.name),i&&1!==i&&f.if_(f.not(f.nonComputedMember(a,n.property.name)),f.lazyAssign(f.nonComputedMember(a,n.property.name),"{}")),c=f.nonComputedMember(a,n.property.name),(f.state.expensiveChecks||Cr(n.property.name))&&(c=f.ensureSafeObject(c)),f.assign(t,c),e&&(e.computed=!1,e.name=n.property.name))},function(){f.assign(t,"undefined")}),r(t)},!!i);break;case fr.CallExpression:t=t||this.nextId(),n.filter?(s=f.filter(n.callee.name),u=[],le(n.arguments,function(e){var t=f.nextId();f.recurse(e,t),u.push(t)}),c=s+"("+u.join(",")+")",f.assign(t,c),r(t)):(s=f.nextId(),a={},u=[],f.recurse(n.callee,s,a,function(){f.if_(f.notNull(s),function(){f.addEnsureSafeFunction(s),le(n.arguments,function(e){f.recurse(e,f.nextId(),void 0,function(e){u.push(f.ensureSafeObject(e))})}),c=a.name?(f.state.expensiveChecks||f.addEnsureSafeObject(a.context),f.member(a.context,a.name,a.computed)+"("+u.join(",")+")"):s+"("+u.join(",")+")",c=f.ensureSafeObject(c),f.assign(t,c)},function(){f.assign(t,"undefined")}),r(t)}));break;case fr.AssignmentExpression:if(s=this.nextId(),a={},!mr(n.left))throw Qn("lval","Trying to assign a value to a non l-value");this.recurse(n.left,void 0,a,function(){f.if_(f.notNull(a.context),function(){f.recurse(n.right,s),f.addEnsureSafeObject(f.member(a.context,a.name,a.computed)),f.addEnsureSafeAssignContext(a.context),c=f.member(a.context,a.name,a.computed)+n.operator+s,f.assign(t,c),r(t||c)})},1);break;case fr.ArrayExpression:u=[],le(n.elements,function(e){f.recurse(e,f.nextId(),void 0,function(e){u.push(e)})}),c="["+u.join(",")+"]",this.assign(t,c),r(c);break;case fr.ObjectExpression:l=!(u=[]),le(n.properties,function(e){e.computed&&(l=!0)}),l?(t=t||this.nextId(),this.assign(t,"{}"),le(n.properties,function(e){e.computed?(a=f.nextId(),f.recurse(e.key,a)):a=e.key.type===fr.Identifier?e.key.name:""+e.key.value,s=f.nextId(),f.recurse(e.value,s),f.assign(f.member(t,a,e.computed),s)})):(le(n.properties,function(t){f.recurse(t.value,n.constant?void 0:f.nextId(),void 0,function(e){u.push(f.escape(t.key.type===fr.Identifier?t.key.name:""+t.key.value)+":"+e)})}),c="{"+u.join(",")+"}",this.assign(t,c)),r(t||c);break;case fr.ThisExpression:this.assign(t,"s"),r("s");break;case fr.LocalsExpression:this.assign(t,"l"),r("l");break;case fr.NGValueParameter:this.assign(t,"v"),r("v")}},getHasOwnProperty:function(e,t){var n=e+"."+t,r=this.current().own;return r.hasOwnProperty(n)||(r[n]=this.nextId(!1,e+"&&("+this.escape(t)+" in "+e+")")),r[n]},assign:function(e,t){if(e)return this.current().body.push(e,"=",t,";"),e},filter:function(e){return this.state.filters.hasOwnProperty(e)||(this.state.filters[e]=this.nextId(!0)),this.state.filters[e]},ifDefined:function(e,t){return"ifDefined("+e+","+this.escape(t)+")"},plus:function(e,t){return"plus("+e+","+t+")"},return_:function(e){this.current().body.push("return ",e,";")},if_:function(e,t,n){if(!0===e)t();else{var r=this.current().body;r.push("if(",e,"){"),t(),r.push("}"),n&&(r.push("else{"),n(),r.push("}"))}},not:function(e){return"!("+e+")"},notNull:function(e){return e+"!=null"},nonComputedMember:function(e,t){return/[$_a-zA-Z][$_a-zA-Z0-9]*/.test(t)?e+"."+t:e+'["'+t.replace(/[^$_a-zA-Z0-9]/g,this.stringEscapeFn)+'"]'},computedMember:function(e,t){return e+"["+t+"]"},member:function(e,t,n){return n?this.computedMember(e,t):this.nonComputedMember(e,t)},addEnsureSafeObject:function(e){this.current().body.push(this.ensureSafeObject(e),";")},addEnsureSafeMemberName:function(e){this.current().body.push(this.ensureSafeMemberName(e),";")},addEnsureSafeFunction:function(e){this.current().body.push(this.ensureSafeFunction(e),";")},addEnsureSafeAssignContext:function(e){this.current().body.push(this.ensureSafeAssignContext(e),";")},ensureSafeObject:function(e){return"ensureSafeObject("+e+",text)"},ensureSafeMemberName:function(e){return"ensureSafeMemberName("+e+",text)"},ensureSafeFunction:function(e){return"ensureSafeFunction("+e+",text)"},getStringValue:function(e){this.assign(e,"getStringValue("+e+")")},ensureSafeAssignContext:function(e){return"ensureSafeAssignContext("+e+",text)"},lazyRecurse:function(e,t,n,r,i,o){var a=this;return function(){a.recurse(e,t,n,r,i,o)}},lazyAssign:function(e,t){var n=this;return function(){n.assign(e,t)}},stringEscapeRegex:/[^ a-zA-Z0-9]/g,stringEscapeFn:function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)},escape:function(e){if(de(e))return"'"+e.replace(this.stringEscapeRegex,this.stringEscapeFn)+"'";if(w(e))return e.toString();if(!0===e)return"true";if(!1===e)return"false";if(null===e)return"null";if(void 0===e)return"undefined";throw Qn("esc","IMPOSSIBLE")},nextId:function(e,t){var n="v"+this.state.nextId++;return e||this.current().vars.push(n+(t?"="+t:"")),n},current:function(){return this.state[this.state.computing]}},xr.prototype={compile:function(e,t){var n,r,i=this,o=this.astBuilder.ast(e);this.expression=e,this.expensiveChecks=t,$r(o,i.$filter),(n=gr(o))&&(r=this.recurse(n));var a,s=vr(o.body);s&&(a=[],le(s,function(e,t){var n=i.recurse(e);e.input=n,a.push(n),e.watchId=t}));var u=[];le(o.body,function(e){u.push(i.recurse(e.expression))});var c=0===o.body.length?L:1===o.body.length?u[0]:function(t,n){var r;return le(u,function(e){r=e(t,n)}),r};return r&&(c.assign=function(e,t,n){return r(e,n,t)}),a&&(c.inputs=a),c.literal=yr(o),c.constant=br(o),c},recurse:function(e,u,t){var a,c,l,f=this;if(e.input)return this.inputs(e.input,e.watchId);switch(e.type){case fr.Literal:return this.value(e.value,u);case fr.UnaryExpression:return c=this.recurse(e.argument),this["unary"+e.operator](c,u);case fr.BinaryExpression:case fr.LogicalExpression:return a=this.recurse(e.left),c=this.recurse(e.right),this["binary"+e.operator](a,c,u);case fr.ConditionalExpression:return this["ternary?:"](this.recurse(e.test),this.recurse(e.alternate),this.recurse(e.consequent),u);case fr.Identifier:return er(e.name,f.expression),f.identifier(e.name,f.expensiveChecks||Cr(e.name),u,t,f.expression);case fr.MemberExpression:return a=this.recurse(e.object,!1,!!t),e.computed||(er(e.property.name,f.expression),c=e.property.name),e.computed&&(c=this.recurse(e.property)),e.computed?this.computedMember(a,c,u,t,f.expression):this.nonComputedMember(a,c,f.expensiveChecks,u,t,f.expression);case fr.CallExpression:return l=[],le(e.arguments,function(e){l.push(f.recurse(e))}),e.filter&&(c=this.$filter(e.callee.name)),e.filter||(c=this.recurse(e.callee,!0)),e.filter?function(e,t,n,r){for(var i=[],o=0;o":function(o,a,s){return function(e,t,n,r){var i=o(e,t,n,r)>a(e,t,n,r);return s?{value:i}:i}},"binary<=":function(o,a,s){return function(e,t,n,r){var i=o(e,t,n,r)<=a(e,t,n,r);return s?{value:i}:i}},"binary>=":function(o,a,s){return function(e,t,n,r){var i=o(e,t,n,r)>=a(e,t,n,r);return s?{value:i}:i}},"binary&&":function(o,a,s){return function(e,t,n,r){var i=o(e,t,n,r)&&a(e,t,n,r);return s?{value:i}:i}},"binary||":function(o,a,s){return function(e,t,n,r){var i=o(e,t,n,r)||a(e,t,n,r);return s?{value:i}:i}},"ternary?:":function(o,a,s,u){return function(e,t,n,r){var i=o(e,t,n,r)?a(e,t,n,r):s(e,t,n,r);return u?{value:i}:i}},value:function(e,t){return function(){return t?{context:void 0,name:void 0,value:e}:e}},identifier:function(a,s,u,c,l){return function(e,t,n,r){var i=t&&a in t?t:e;c&&1!==c&&i&&!i[a]&&(i[a]={});var o=i?i[a]:void 0;return s&&nr(o,l),u?{context:i,name:a,value:o}:o}},computedMember:function(s,u,c,l,f){return function(e,t,n,r){var i,o,a=s(e,t,n,r);return null!=a&&(er(i=tr(i=u(e,t,n,r)),f),l&&1!==l&&(sr(a),a&&!a[i]&&(a[i]={})),nr(o=a[i],f)),c?{context:a,name:i,value:o}:o}},nonComputedMember:function(a,s,u,c,l,f){return function(e,t,n,r){var i=a(e,t,n,r);l&&1!==l&&(sr(i),i&&!i[s]&&(i[s]={}));var o=null!=i?i[s]:void 0;return(u||Cr(s))&&nr(o,f),c?{context:i,name:s,value:o}:o}},inputs:function(i,o){return function(e,t,n,r){return r?r[o]:i(e,t,n)}}};function Sr(e,t,n){this.lexer=e,this.$filter=t,this.options=n,this.ast=new fr(e,n),this.astCompiler=n.csp?new xr(this.ast,t):new wr(this.ast,t)}function Cr(e){return"constructor"==e}Sr.prototype={constructor:Sr,parse:function(e){return this.astCompiler.compile(e,this.options.expensiveChecks)}};var Er=Object.prototype.valueOf;function Ar(e){return ve(e.valueOf)?e.valueOf():Er.call(e)}function kr(){var n,r,y=Me(),b=Me(),i={true:!0,false:!1,null:null,undefined:void 0};this.addLiteral=function(e,t){i[e]=t},this.setIdentifierFns=function(e,t){return n=e,r=t,this},this.$get=["$filter",function(c){var e=B().noUnsafeEval,l={csp:e,expensiveChecks:!1,literals:D(i),isIdentifierStart:ve(n)&&n,isIdentifierContinue:ve(r)&&r},f={csp:e,expensiveChecks:!0,literals:D(i),isIdentifierStart:ve(n)&&n,isIdentifierContinue:ve(r)&&r},h=!1;return t.$$runningExpensiveChecks=function(){return h},t;function t(e,t,n){var r,i,o;switch(n=n||h,typeof e){case"string":e=e.trim();var a=n?b:y;if(!(r=a[o=e])){":"===e.charAt(0)&&":"===e.charAt(1)&&(i=!0,e=e.substring(2));var s=n?f:l,u=new cr(s);(r=new Sr(u,c,s).parse(e)).constant?r.$$watchDelegate=m:i?r.$$watchDelegate=r.literal?v:$:r.inputs&&(r.$$watchDelegate=d),n&&(r=function e(o){if(!o)return o;n.$$watchDelegate=o.$$watchDelegate,n.assign=e(o.assign),n.constant=o.constant,n.literal=o.literal;for(var t=0;o.inputs&&t to the top of your HTML document. See http://docs.angularjs.org/api/ng.$sce for more information.");var i=P(Dr);i.isEnabled=function(){return t},i.trustAs=e.trustAs,i.getTrusted=e.getTrusted,i.valueOf=e.valueOf,t||(i.trustAs=i.getTrusted=function(e,t){return t},i.valueOf=x),i.parseAs=function(t,e){var n=r(e);return n.literal&&n.constant?n:r(e,function(e){return i.getTrusted(t,e)})};var o=i.parseAs,a=i.getTrusted,s=i.trustAs;return le(Dr,function(t,e){var n=q(e);i[Be("parse_as_"+n)]=function(e){return o(t,e)},i[Be("get_trusted_"+n)]=function(e){return a(t,e)},i[Be("trust_as_"+n)]=function(e){return s(t,e)}}),i}]}function qr(){this.$get=["$window","$document",function(e,t){var n,r,i={},o=!(e.chrome&&e.chrome.app&&e.chrome.app.runtime)&&e.history&&e.history.pushState,a=g((/android (\d+)/.exec(q((e.navigator||{}).userAgent))||[])[1]),s=/Boxee/i.test((e.navigator||{}).userAgent),u=t[0]||{},c=/^(Moz|webkit|ms)(?=[A-Z])/,l=u.body&&u.body.style,f=!1,h=!1;if(l){for(var p in l)if(r=c.exec(p)){n=(n=r[0])[0].toUpperCase()+n.substr(1);break}n||(n="WebkitOpacity"in l&&"webkit"),f=!!("transition"in l||n+"Transition"in l),h=!!("animation"in l||n+"Animation"in l),!a||f&&h||(f=de(l.webkitTransition),h=de(l.webkitAnimation))}return{history:!(!o||a<4||s),hasEvent:function(e){if("input"===e&&F<=11)return!1;if(he(i[e])){var t=u.createElement("div");i[e]="on"+e in t}return i[e]},csp:B(),vendorPrefix:n,transitions:f,animations:h,android:a}}]}var Fr=d("$compile");function Ur(){var u;this.httpOptions=function(e){return e?(u=e,this):u},this.$get=["$templateCache","$http","$q","$sce",function(r,i,o,a){function s(t,n){s.totalPendingRequests++,de(t)&&!he(r.get(t))||(t=a.getTrustedResourceUrl(t));var e=i.defaults&&i.defaults.transformResponse;return $e(e)?e=e.filter(function(e){return e!==Cn}):e===Cn&&(e=null),i.get(t,fe({cache:r,transformResponse:e},u)).finally(function(){s.totalPendingRequests--}).then(function(e){return r.put(t,e.data),e.data},function(e){if(n)return o.reject(e);throw Fr("tpload","Failed to load template: {0} (HTTP status: {1} {2})",t,e.status,e.statusText)})}return s.totalPendingRequests=0,s}]}function Lr(){this.$get=["$rootScope","$browser","$location",function(t,n,r){return{findBindings:function(e,n,r){var t=e.getElementsByClassName("ng-binding"),i=[];return le(t,function(t){var e=E.element(t).data("$binding");e&&le(e,function(e){r?new RegExp("(^|\\s)"+V(n)+"(\\s|\\||$)").test(e)&&i.push(t):-1!=e.indexOf(n)&&i.push(t)})}),i},findModels:function(e,t,n){for(var r=["ng-","data-ng-","ng\\:"],i=0;i=t.lgSize&&d.unshift(l.splice(-t.lgSize,l.length).join(""));l.length>t.gSize;)d.unshift(l.splice(-t.gSize,l.length).join(""));l.length&&d.unshift(l.join("")),c=d.join(n),p.length&&(c+=r+p.join("")),h&&(c+="e+"+h)}return e<0&&!s?t.negPre+c+t.negSuf:t.posPre+c+t.posSuf}function si(e,t,n,r){var i="";for((e<0||r&&e<=0)&&(r?e=1-e:(e=-e,i="-")),e=""+e;e.length=u},n.$observe("min",function(e){u=h(e),r.$validate()})),(H(n.max)||n.ngMax)&&(r.$validators.max=function(e){return!f(e)||he(c)||$(e)<=c},n.$observe("max",function(e){c=h(e),r.$validate()}))}}function Gi(e,n,t,r){var i=n[0];(r.$$hasNativeValidators=pe(i.validity))&&r.$parsers.push(function(e){var t=n.prop(f)||{};return t.badInput||t.typeMismatch?void 0:e})}function Ji(e,t,n,r,i){var o;if(H(r)){if(!(o=e(r)).constant)throw Ao("constexpr","Expected constant expression for `{0}`, but saw `{1}`.",n,r);return o(t)}return i}function Yi(){return{restrict:"A",priority:100,compile:function(e,t){return Ki.test(t.ngValue)?function(e,t,n){n.$set("value",e.$eval(n.ngValue))}:function(e,t,n){e.$watch(n.ngValue,function(e){n.$set("value",e)})}}}}var Zi=["$browser","$sniffer","$filter","$parse",function(i,o,a,s){return{restrict:"E",require:["?ngModel"],link:{pre:function(e,t,n,r){r[0]&&(Li[q(n.type)]||Li.text)(e,t,n,r[0],o,i,a,s)}}}}],Ki=/^(true|false|\d+)$/,Xi=["$compile",function(r){return{restrict:"AC",compile:function(e){return r.$$addBindingClass(e),function(e,t,n){r.$$addBindingInfo(t,n.ngBind),t=t[0],e.$watch(n.ngBind,function(e){t.textContent=he(e)?"":e})}}}}],Qi=["$interpolate","$compile",function(i,o){return{compile:function(e){return o.$$addBindingClass(e),function(e,t,n){var r=i(t.attr(n.$attr.ngBindTemplate));o.$$addBindingInfo(t,r.expressions),t=t[0],n.$observe("ngBindTemplate",function(e){t.textContent=he(e)?"":e})}}}}],eo=["$sce","$parse","$compile",function(o,n,a){return{restrict:"A",compile:function(e,t){var r=n(t.ngBindHtml),i=n(t.ngBindHtml,function(e){return o.valueOf(e)});return a.$$addBindingClass(e),function(t,n,e){a.$$addBindingInfo(n,e.ngBindHtml),t.$watch(i,function(){var e=r(t);n.html(o.getTrustedHtml(e)||"")})}}}}],to=A({restrict:"A",require:"ngModel",link:function(e,t,n,r){r.$viewChangeListeners.push(function(){e.$eval(n.ngChange)})}});function no(d,$){return d="ngClass"+d,["$animate",function(f){return{restrict:"AC",link:function(a,s,o){var u;function c(e){var t=l(e,1);o.$addClass(t)}function l(e,t){var n=s.data("$classCounts")||Me(),r=[];return le(e,function(e){(0=i}}}}}var ta,na,ra,ia,oa=["$element","$scope",function(n,e){var a=this,i=new At;a.ngModelCtrl=Yo,a.unknownOption=ce(_.document.createElement("option")),a.renderUnknownOption=function(e){var t="? "+Et(e)+" ?";a.unknownOption.val(t),n.prepend(a.unknownOption),n.val(t)},e.$on("$destroy",function(){a.renderUnknownOption=L}),a.removeUnknownOption=function(){a.unknownOption.parent()&&a.unknownOption.remove()},a.readValue=function(){return a.removeUnknownOption(),n.val()},a.writeValue=function(e){a.hasOption(e)?(a.removeUnknownOption(),n.val(e),""===e&&a.emptyOption.prop("selected",!0)):null==e&&a.emptyOption?(a.removeUnknownOption(),n.val("")):a.renderUnknownOption(e)},a.addOption=function(e,t){if(t[0].nodeType!==Ve){se(e,'"option value"'),""===e&&(a.emptyOption=t);var n=i.get(e)||0;i.put(e,n+1),a.ngModelCtrl.$render(),(r=t)[0].hasAttribute("selected")&&(r[0].selected=!0)}var r},a.removeOption=function(e){var t=i.get(e);t&&(1===t?(i.remove(e),""===e&&(a.emptyOption=void 0)):i.put(e,t-1))},a.hasOption=function(e){return!!i.get(e)},a.registerOption=function(e,n,r,t,i){var o;t?r.$observe("value",function(e){H(o)&&a.removeOption(o),o=e,a.addOption(e,n)}):i?e.$watch(i,function(e,t){r.$set("value",e),t!==e&&a.removeOption(t),a.addOption(e,n)}):a.addOption(r.value,n),n.on("$destroy",function(){a.removeOption(r.value),a.ngModelCtrl.$render()})}}],aa=["$interpolate",function(n){return{restrict:"E",priority:100,compile:function(e,t){if(H(t.value))var a=n(t.value,!0);else{var s=n(e.text(),!0);s||t.$set("value",e.text())}return function(e,t,n){var r="$selectController",i=t.parent(),o=i.data(r)||i.parent().data(r);o&&o.registerOption(e,t,n,a,s)}}}}],sa=A({restrict:"E",terminal:!1});function ua(e,t,n){return e[t]||(e[t]=n())}_.angular.bootstrap?_.console&&console.log("WARNING: Tried to load angular more than once."):(function(){var i;if(!oe){var e=z();(a=he(e)?_.jQuery:e?_[e]:void 0)&&a.fn.on?(fe((ce=a).fn,{scope:vt.scope,isolateScope:vt.isolateScope,controller:vt.controller,injector:vt.injector,inheritedData:vt.inheritedData}),i=a.cleanData,a.cleanData=function(e){for(var t,n,r=0;null!=(n=e[r]);r++)(t=a._data(n,"events"))&&t.$destroy&&a(n).triggerHandler("$destroy");i(e)}):ce=tt,E.element=ce,oe=!0}}(),fe(E,{bootstrap:re,copy:D,extend:fe,merge:function(e){return $(e,s.call(arguments,1),!0)},equals:xe,element:ce,forEach:le,injector:Pt,noop:L,bind:Ce,toJson:G,fromJson:J,identity:x,isUndefined:he,isDefined:H,isString:de,isFunction:ve,isObject:pe,isNumber:w,isElement:j,isArray:$e,version:{full:"1.5.6",major:1,minor:5,dot:6,codeName:"arrow-stringification"},isDate:C,lowercase:q,uppercase:l,callbacks:{counter:0},getTestability:function(e){var t=E.element(e).injector();if(!t)throw c("test","no injector found for element argument to getTestability");return t.get("$$testability")},$$minErr:d,$$csp:B,reloadWithDebugInfo:function(){_.name="NG_ENABLE_DEBUG_INFO!"+_.name,_.location.reload()}}),ta=_,na=d("$injector"),ra=d("ng"),(ia=ua(ta,"angular",Object)).$$minErr=ia.$$minErr||d,(v=ua(ia,"module",function(){var e={};return function(s,u,c){return function(){if("hasOwnProperty"===s)throw ra("badname","hasOwnProperty is not a valid {0} name","module")}(),u&&e.hasOwnProperty(s)&&(e[s]=null),ua(e,s,function(){if(!u)throw na("nomod","Module '{0}' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.",s);var i=[],e=[],t=[],n=r("$injector","invoke","push",e),o={_invokeQueue:i,_configBlocks:e,_runBlocks:t,requires:u,name:s,provider:a("$provide","provider"),factory:a("$provide","factory"),service:a("$provide","service"),value:r("$provide","value"),constant:r("$provide","constant","unshift"),decorator:a("$provide","decorator"),animation:a("$animateProvider","register"),filter:a("$filterProvider","register"),controller:a("$controllerProvider","register"),directive:a("$compileProvider","directive"),component:a("$compileProvider","component"),config:n,run:function(e){return t.push(e),this}};return c&&n(c),o;function r(e,t,n,r){return r||(r=i),function(){return r[n||"push"]([e,t,arguments]),o}}function a(n,r){return function(e,t){return t&&ve(t)&&(t.$$moduleName=s),i.push([n,r,arguments]),o}}})}}))("ng",["ngLocale"],["$provide",function(e){e.provider({$$sanitizeUri:jr}),e.provider("$compile",en).directive({a:Si,input:Zi,textarea:Zi,form:Mi,script:Jo,select:Zo,style:sa,option:aa,ngBind:Xi,ngBindHtml:eo,ngBindTemplate:Qi,ngClass:ro,ngClassEven:oo,ngClassOdd:io,ngCloak:ao,ngController:so,ngForm:Ti,ngHide:Uo,ngIf:ho,ngInclude:po,ngInit:vo,ngNonBindable:Vo,ngPluralize:Po,ngRepeat:_o,ngShow:Fo,ngStyle:Lo,ngSwitch:Ho,ngSwitchWhen:Bo,ngSwitchDefault:zo,ngOptions:Do,ngTransclude:Go,ngModel:Oo,ngList:lo,ngChange:to,pattern:Xo,ngPattern:Xo,required:Ko,ngRequired:Ko,minlength:ea,ngMinlength:ea,maxlength:Qo,ngMaxlength:Qo,ngValue:Yi,ngModelOptions:fo}).directive({ngInclude:$o}).directive(Ci).directive(uo),e.provider({$anchorScroll:_t,$animate:Gt,$animateCss:Wt,$$animateJs:Lt,$$animateQueue:Ht,$$AnimateRunner:zt,$$animateAsyncRun:Bt,$browser:Yt,$cacheFactory:Zt,$controller:ln,$document:fn,$exceptionHandler:hn,$filter:Kr,$$forceReflow:pn,$interpolate:jn,$interval:In,$http:Mn,$httpParamSerializer:xn,$httpParamSerializerJQLike:Sn,$httpBackend:Nn,$xhrFactory:Tn,$location:Kn,$log:Xn,$parse:kr,$rootScope:Vr,$q:Or,$$q:Mr,$sce:Rr,$sceDelegate:_r,$sniffer:qr,$templateCache:Kt,$templateRequest:Ur,$$testability:Lr,$timeout:Hr,$window:Jr,$$rAF:Nr,$$jqLite:Ct,$$HashMap:kt,$$cookieReader:Zr})}]),E.module("ngLocale",[],["$provide",function(e){e.value("$locale",{DATETIME_FORMATS:{AMPMS:["AM","PM"],DAY:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ERANAMES:["Before Christ","Anno Domini"],ERAS:["BC","AD"],FIRSTDAYOFWEEK:6,MONTH:["January","February","March","April","May","June","July","August","September","October","November","December"],SHORTDAY:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],SHORTMONTH:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],STANDALONEMONTH:["January","February","March","April","May","June","July","August","September","October","November","December"],WEEKENDRANGE:[5,6],fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y",medium:"MMM d, y h:mm:ss a",mediumDate:"MMM d, y",mediumTime:"h:mm:ss a",short:"M/d/yy h:mm a",shortDate:"M/d/yy",shortTime:"h:mm a"},NUMBER_FORMATS:{CURRENCY_SYM:"$",DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{gSize:3,lgSize:3,maxFrac:3,minFrac:0,minInt:1,negPre:"-",negSuf:"",posPre:"",posSuf:""},{gSize:3,lgSize:3,maxFrac:2,minFrac:2,minInt:1,negPre:"-¤",negSuf:"",posPre:"¤",posSuf:""}]},id:"en-us",localeID:"en_US",pluralCat:function(e,o){var t=0|e,n=function(e){var t,n,r=o;void 0===r&&(r=Math.min((t=e,-1==(n=(t+="").indexOf("."))?0:t.length-n-1),3));var i=Math.pow(10,r);return{v:r,f:(e*i|0)%i}}(e);return 1==t&&0==n.v?"one":"other"}})}]),ce(_.document).ready(function(){!function(r,e){var i,o,t={};le(ne,function(e){var t=e+"app";!i&&r.hasAttribute&&r.hasAttribute(t)&&(o=(i=r).getAttribute(t))}),le(ne,function(e){var t,n=e+"app";!i&&(t=r.querySelector("["+n.replace(":","\\:")+"]"))&&(o=(i=t).getAttribute(n))}),i&&(t.strictDi=null!==function(e){var t,n,r=ne.length;for(n=0;n@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}'); \ No newline at end of file diff --git a/web/resource/js/lib/biz.js b/web/resource/js/lib/biz.js new file mode 100644 index 0000000..0d54757 --- /dev/null +++ b/web/resource/js/lib/biz.js @@ -0,0 +1 @@ +define([],function(){var e={user:{}};return e.user.browser=function(e,r,n){var o="visible";n&&n.mode&&(o=n.mode);var i="0";$.isArray(e)&&0取消',{containerName:"user-browser-dialog"});a.modal("show"),a.on("shown.bs.modal",function(){window.aMember.pIndex=1,window.aMember.query()}),a.find(".modal-footer .btn-primary").click(function(){var e=[],n=$(".user-browser .btn-primary");00&&this.options.badge){this.$elementFilestyle.find("label").append(' '+files.length+"")}this.$elementFilestyle.find(".group-span-filestyle").removeClass("input-group-btn")}}else{return this.options.input}}},size:function(value){if(value!==undefined){var btn=this.$elementFilestyle.find("label"),input=this.$elementFilestyle.find("input");btn.removeClass("btn-lg btn-sm");input.removeClass("input-lg input-sm");if(value!="nr"){btn.addClass("btn-"+value);input.addClass("input-"+value)}}else{return this.options.size}},placeholder:function(value){if(value!==undefined){this.options.placeholder=value;this.$elementFilestyle.find("input").attr("placeholder",value)}else{return this.options.placeholder}},buttonText:function(value){if(value!==undefined){this.options.buttonText=value;this.$elementFilestyle.find("label .buttonText").html(this.options.buttonText)}else{return this.options.buttonText}},buttonName:function(value){if(value!==undefined){this.options.buttonName=value;this.$elementFilestyle.find("label").attr({"class":"btn "+this.options.buttonName})}else{return this.options.buttonName}},iconName:function(value){if(value!==undefined){this.$elementFilestyle.find(".icon-span-filestyle").attr({"class":"icon-span-filestyle "+this.options.iconName})}else{return this.options.iconName}},htmlIcon:function(){if(this.options.icon){return' '}else{return""}},htmlInput:function(){if(this.options.input){return' '}else{return""}},pushNameFiles:function(){var content="",files=[];if(this.$element[0].files===undefined){files[0]={name:this.$element[0]&&this.$element[0].value}}else{files=this.$element[0].files}for(var i=0;i";html=_self.options.buttonBefore?btn+_self.htmlInput():_self.htmlInput()+btn;_self.$elementFilestyle=$('
    '+html+"
    ");_self.$elementFilestyle.find(".group-span-filestyle").attr("tabindex","0").keypress(function(e){if(e.keyCode===13||e.charCode===32){_self.$elementFilestyle.find("label").click();return false}});_self.$element.css({position:"absolute",clip:"rect(0px 0px 0px 0px)"}).attr("tabindex","-1").after(_self.$elementFilestyle);if(_self.options.disabled){_self.$element.attr("disabled","true")}_self.$element.change(function(){var files=_self.pushNameFiles();if(_self.options.input==false&&_self.options.badge){if(_self.$elementFilestyle.find(".badge").length==0){_self.$elementFilestyle.find("label").append(' '+files.length+"")}else{if(files.length==0){_self.$elementFilestyle.find(".badge").remove()}else{_self.$elementFilestyle.find(".badge").html(files.length)}}}else{_self.$elementFilestyle.find(".badge").remove()}});if(window.navigator.userAgent.search(/firefox/i)>-1){_self.$elementFilestyle.find("label").click(function(){_self.$element.click();return false})}}};var old=$.fn.filestyle;$.fn.filestyle=function(option,value){var get="",element=this.each(function(){if($(this).attr("type")==="file"){var $this=$(this),data=$this.data("filestyle"),options=$.extend({},$.fn.filestyle.defaults,option,typeof option==="object"&&option);if(!data){$this.data("filestyle",(data=new Filestyle(this,options)));data.constructor()}if(typeof option==="string"){get=data[option](value)}}});if(typeof get!==undefined){return get}else{return element}};$.fn.filestyle.defaults={buttonText:"Choose file",iconName:"glyphicon glyphicon-folder-open",buttonName:"btn-default",size:"nr",input:true,badge:true,icon:true,buttonBefore:false,disabled:false,placeholder:""};$.fn.filestyle.noConflict=function(){$.fn.filestyle=old;return this};$(function(){$(".filestyle").each(function(){var $this=$(this),options={input:$this.attr("data-input")==="false"?false:true,icon:$this.attr("data-icon")==="false"?false:true,buttonBefore:$this.attr("data-buttonBefore")==="true"?true:false,disabled:$this.attr("data-disabled")==="true"?true:false,size:$this.attr("data-size"),buttonText:$this.attr("data-buttonText"),buttonName:$this.attr("data-buttonName"),iconName:$this.attr("data-iconName"),badge:$this.attr("data-badge")==="false"?false:true,placeholder:$this.attr("data-placeholder")};$this.filestyle(options)})})})(window.jQuery); \ No newline at end of file diff --git a/web/resource/js/lib/bootstrap-select.js b/web/resource/js/lib/bootstrap-select.js new file mode 100644 index 0000000..403f26b --- /dev/null +++ b/web/resource/js/lib/bootstrap-select.js @@ -0,0 +1,3061 @@ +/*! + * Bootstrap-select v1.13.9 (https://developer.snapappointments.com/bootstrap-select) + * + * Copyright 2012-2019 SnapAppointments, LLC + * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) + */ + +(function (root, factory) { + if (root === undefined && window !== undefined) root = window; + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module unless amdModuleId is set + define(["jquery"], function (a0) { + return (factory(a0)); + }); + } else if (typeof module === 'object' && module.exports) { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(require("jquery")); + } else { + factory(root["jQuery"]); + } +}(this, function (jQuery) { + +(function ($) { + 'use strict'; + + var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']; + + var uriAttrs = [ + 'background', + 'cite', + 'href', + 'itemtype', + 'longdesc', + 'poster', + 'src', + 'xlink:href' + ]; + + var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; + + var DefaultWhitelist = { + // Global attributes allowed on any supplied element below. + '*': ['class', 'dir', 'id', 'lang', 'role', 'tabindex', 'style', ARIA_ATTRIBUTE_PATTERN], + a: ['target', 'href', 'title', 'rel'], + area: [], + b: [], + br: [], + col: [], + code: [], + div: [], + em: [], + hr: [], + h1: [], + h2: [], + h3: [], + h4: [], + h5: [], + h6: [], + i: [], + img: ['src', 'alt', 'title', 'width', 'height'], + li: [], + ol: [], + p: [], + pre: [], + s: [], + small: [], + span: [], + sub: [], + sup: [], + strong: [], + u: [], + ul: [] + } + + /** + * A pattern that recognizes a commonly useful subset of URLs that are safe. + * + * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts + */ + var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi; + + /** + * A pattern that matches safe data URLs. Only matches image, video and audio types. + * + * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts + */ + var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i; + + function allowedAttribute (attr, allowedAttributeList) { + var attrName = attr.nodeName.toLowerCase() + + if ($.inArray(attrName, allowedAttributeList) !== -1) { + if ($.inArray(attrName, uriAttrs) !== -1) { + return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) + } + + return true + } + + var regExp = $(allowedAttributeList).filter(function (index, value) { + return value instanceof RegExp + }) + + // Check if a regular expression validates the attribute. + for (var i = 0, l = regExp.length; i < l; i++) { + if (attrName.match(regExp[i])) { + return true + } + } + + return false + } + + function sanitizeHtml (unsafeElements, whiteList, sanitizeFn) { + if (sanitizeFn && typeof sanitizeFn === 'function') { + return sanitizeFn(unsafeElements); + } + + var whitelistKeys = Object.keys(whiteList); + + for (var i = 0, len = unsafeElements.length; i < len; i++) { + var elements = unsafeElements[i].querySelectorAll('*'); + + for (var j = 0, len2 = elements.length; j < len2; j++) { + var el = elements[j]; + var elName = el.nodeName.toLowerCase(); + + if (whitelistKeys.indexOf(elName) === -1) { + el.parentNode.removeChild(el); + + continue; + } + + var attributeList = [].slice.call(el.attributes); + var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []); + + for (var k = 0, len3 = attributeList.length; k < len3; k++) { + var attr = attributeList[k]; + + if (!allowedAttribute(attr, whitelistedAttributes)) { + el.removeAttribute(attr.nodeName); + } + } + } + } + } + + // Polyfill for browsers with no classList support + // Remove in v2 + if (!('classList' in document.createElement('_'))) { + (function (view) { + if (!('Element' in view)) return; + + var classListProp = 'classList', + protoProp = 'prototype', + elemCtrProto = view.Element[protoProp], + objCtr = Object, + classListGetter = function () { + var $elem = $(this); + + return { + add: function (classes) { + classes = Array.prototype.slice.call(arguments).join(' '); + return $elem.addClass(classes); + }, + remove: function (classes) { + classes = Array.prototype.slice.call(arguments).join(' '); + return $elem.removeClass(classes); + }, + toggle: function (classes, force) { + return $elem.toggleClass(classes, force); + }, + contains: function (classes) { + return $elem.hasClass(classes); + } + } + }; + + if (objCtr.defineProperty) { + var classListPropDesc = { + get: classListGetter, + enumerable: true, + configurable: true + }; + try { + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } catch (ex) { // IE 8 doesn't support enumerable:true + // adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36 + // modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected + if (ex.number === undefined || ex.number === -0x7FF5EC54) { + classListPropDesc.enumerable = false; + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } + } + } else if (objCtr[protoProp].__defineGetter__) { + elemCtrProto.__defineGetter__(classListProp, classListGetter); + } + }(window)); + } + + var testElement = document.createElement('_'); + + testElement.classList.add('c1', 'c2'); + + if (!testElement.classList.contains('c2')) { + var _add = DOMTokenList.prototype.add, + _remove = DOMTokenList.prototype.remove; + + DOMTokenList.prototype.add = function () { + Array.prototype.forEach.call(arguments, _add.bind(this)); + } + + DOMTokenList.prototype.remove = function () { + Array.prototype.forEach.call(arguments, _remove.bind(this)); + } + } + + testElement.classList.toggle('c3', false); + + // Polyfill for IE 10 and Firefox <24, where classList.toggle does not + // support the second argument. + if (testElement.classList.contains('c3')) { + var _toggle = DOMTokenList.prototype.toggle; + + DOMTokenList.prototype.toggle = function (token, force) { + if (1 in arguments && !this.contains(token) === !force) { + return force; + } else { + return _toggle.call(this, token); + } + }; + } + + testElement = null; + + // shallow array comparison + function isEqual (array1, array2) { + return array1.length === array2.length && array1.every(function (element, index) { + return element === array2[index]; + }); + }; + + // + if (!String.prototype.startsWith) { + (function () { + 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` + var defineProperty = (function () { + // IE 8 only supports `Object.defineProperty` on DOM elements + try { + var object = {}; + var $defineProperty = Object.defineProperty; + var result = $defineProperty(object, object, object) && $defineProperty; + } catch (error) { + } + return result; + }()); + var toString = {}.toString; + var startsWith = function (search) { + if (this == null) { + throw new TypeError(); + } + var string = String(this); + if (search && toString.call(search) == '[object RegExp]') { + throw new TypeError(); + } + var stringLength = string.length; + var searchString = String(search); + var searchLength = searchString.length; + var position = arguments.length > 1 ? arguments[1] : undefined; + // `ToInteger` + var pos = position ? Number(position) : 0; + if (pos != pos) { // better `isNaN` + pos = 0; + } + var start = Math.min(Math.max(pos, 0), stringLength); + // Avoid the `indexOf` call if no match is possible + if (searchLength + start > stringLength) { + return false; + } + var index = -1; + while (++index < searchLength) { + if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) { + return false; + } + } + return true; + }; + if (defineProperty) { + defineProperty(String.prototype, 'startsWith', { + 'value': startsWith, + 'configurable': true, + 'writable': true + }); + } else { + String.prototype.startsWith = startsWith; + } + }()); + } + + if (!Object.keys) { + Object.keys = function ( + o, // object + k, // key + r // result array + ) { + // initialize object and result + r = []; + // iterate over object keys + for (k in o) { + // fill result array with non-prototypical keys + r.hasOwnProperty.call(o, k) && r.push(k); + } + // return result + return r; + }; + } + + if (HTMLSelectElement && !HTMLSelectElement.prototype.hasOwnProperty('selectedOptions')) { + Object.defineProperty(HTMLSelectElement.prototype, 'selectedOptions', { + get: function () { + return this.querySelectorAll(':checked'); + } + }); + } + + // much faster than $.val() + function getSelectValues (select) { + var result = []; + var options = select.selectedOptions; + var opt; + + if (select.multiple) { + for (var i = 0, len = options.length; i < len; i++) { + opt = options[i]; + + result.push(opt.value || opt.text); + } + } else { + result = select.value; + } + + return result; + } + + // set data-selected on select element if the value has been programmatically selected + // prior to initialization of bootstrap-select + // * consider removing or replacing an alternative method * + var valHooks = { + useDefault: false, + _set: $.valHooks.select.set + }; + + $.valHooks.select.set = function (elem, value) { + if (value && !valHooks.useDefault) $(elem).data('selected', true); + + return valHooks._set.apply(this, arguments); + }; + + var changedArguments = null; + + var EventIsSupported = (function () { + try { + new Event('change'); + return true; + } catch (e) { + return false; + } + })(); + + $.fn.triggerNative = function (eventName) { + var el = this[0], + event; + + if (el.dispatchEvent) { // for modern browsers & IE9+ + if (EventIsSupported) { + // For modern browsers + event = new Event(eventName, { + bubbles: true + }); + } else { + // For IE since it doesn't support Event constructor + event = document.createEvent('Event'); + event.initEvent(eventName, true, false); + } + + el.dispatchEvent(event); + } else if (el.fireEvent) { // for IE8 + event = document.createEventObject(); + event.eventType = eventName; + el.fireEvent('on' + eventName, event); + } else { + // fall back to jQuery.trigger + this.trigger(eventName); + } + }; + // + + function stringSearch (li, searchString, method, normalize) { + var stringTypes = [ + 'display', + 'subtext', + 'tokens' + ], + searchSuccess = false; + + for (var i = 0; i < stringTypes.length; i++) { + var stringType = stringTypes[i], + string = li[stringType]; + + if (string) { + string = string.toString(); + + // Strip HTML tags. This isn't perfect, but it's much faster than any other method + if (stringType === 'display') { + string = string.replace(/<[^>]+>/g, ''); + } + + if (normalize) string = normalizeToBase(string); + string = string.toUpperCase(); + + if (method === 'contains') { + searchSuccess = string.indexOf(searchString) >= 0; + } else { + searchSuccess = string.startsWith(searchString); + } + + if (searchSuccess) break; + } + } + + return searchSuccess; + } + + function toInteger (value) { + return parseInt(value, 10) || 0; + } + + // Borrowed from Lodash (_.deburr) + /** Used to map Latin Unicode letters to basic Latin letters. */ + var deburredLetters = { + // Latin-1 Supplement block. + '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', + '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', + '\xc7': 'C', '\xe7': 'c', + '\xd0': 'D', '\xf0': 'd', + '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', + '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', + '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', + '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', + '\xd1': 'N', '\xf1': 'n', + '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', + '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', + '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', + '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', + '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', + '\xc6': 'Ae', '\xe6': 'ae', + '\xde': 'Th', '\xfe': 'th', + '\xdf': 'ss', + // Latin Extended-A block. + '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', + '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', + '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', + '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', + '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', + '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', + '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', + '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', + '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', + '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', + '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', + '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', + '\u0134': 'J', '\u0135': 'j', + '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', + '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', + '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', + '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', + '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', + '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', + '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', + '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', + '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', + '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', + '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', + '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', + '\u0163': 't', '\u0165': 't', '\u0167': 't', + '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', + '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', + '\u0174': 'W', '\u0175': 'w', + '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', + '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', + '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', + '\u0132': 'IJ', '\u0133': 'ij', + '\u0152': 'Oe', '\u0153': 'oe', + '\u0149': "'n", '\u017f': 's' + }; + + /** Used to match Latin Unicode letters (excluding mathematical operators). */ + var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; + + /** Used to compose unicode character classes. */ + var rsComboMarksRange = '\\u0300-\\u036f', + reComboHalfMarksRange = '\\ufe20-\\ufe2f', + rsComboSymbolsRange = '\\u20d0-\\u20ff', + rsComboMarksExtendedRange = '\\u1ab0-\\u1aff', + rsComboMarksSupplementRange = '\\u1dc0-\\u1dff', + rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange; + + /** Used to compose unicode capture groups. */ + var rsCombo = '[' + rsComboRange + ']'; + + /** + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ + var reComboMark = RegExp(rsCombo, 'g'); + + function deburrLetter (key) { + return deburredLetters[key]; + }; + + function normalizeToBase (string) { + string = string.toString(); + return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); + } + + // List of HTML entities for escaping. + var escapeMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`' + }; + + // Functions for escaping and unescaping strings to/from HTML interpolation. + var createEscaper = function (map) { + var escaper = function (match) { + return map[match]; + }; + // Regexes for identifying a key that needs to be escaped. + var source = '(?:' + Object.keys(map).join('|') + ')'; + var testRegexp = RegExp(source); + var replaceRegexp = RegExp(source, 'g'); + return function (string) { + string = string == null ? '' : '' + string; + return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; + }; + }; + + var htmlEscape = createEscaper(escapeMap); + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var keyCodeMap = { + 32: ' ', + 48: '0', + 49: '1', + 50: '2', + 51: '3', + 52: '4', + 53: '5', + 54: '6', + 55: '7', + 56: '8', + 57: '9', + 59: ';', + 65: 'A', + 66: 'B', + 67: 'C', + 68: 'D', + 69: 'E', + 70: 'F', + 71: 'G', + 72: 'H', + 73: 'I', + 74: 'J', + 75: 'K', + 76: 'L', + 77: 'M', + 78: 'N', + 79: 'O', + 80: 'P', + 81: 'Q', + 82: 'R', + 83: 'S', + 84: 'T', + 85: 'U', + 86: 'V', + 87: 'W', + 88: 'X', + 89: 'Y', + 90: 'Z', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9' + }; + + var keyCodes = { + ESCAPE: 27, // KeyboardEvent.which value for Escape (Esc) key + ENTER: 13, // KeyboardEvent.which value for Enter key + SPACE: 32, // KeyboardEvent.which value for space key + TAB: 9, // KeyboardEvent.which value for tab key + ARROW_UP: 38, // KeyboardEvent.which value for up arrow key + ARROW_DOWN: 40 // KeyboardEvent.which value for down arrow key + } + + var version = { + success: false, + major: '3' + }; + + try { + version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.'); + version.major = version.full[0]; + version.success = true; + } catch (err) { + // do nothing + } + + var selectId = 0; + + var EVENT_KEY = '.bs.select'; + + var classNames = { + DISABLED: 'disabled', + DIVIDER: 'divider', + SHOW: 'open', + DROPUP: 'dropup', + MENU: 'dropdown-menu', + MENURIGHT: 'dropdown-menu-right', + MENULEFT: 'dropdown-menu-left', + // to-do: replace with more advanced template/customization options + BUTTONCLASS: 'btn-default', + POPOVERHEADER: 'popover-title', + ICONBASE: 'glyphicon', + TICKICON: 'glyphicon-ok' + } + + var Selector = { + MENU: '.' + classNames.MENU + } + + var elementTemplates = { + span: document.createElement('span'), + i: document.createElement('i'), + subtext: document.createElement('small'), + a: document.createElement('a'), + li: document.createElement('li'), + whitespace: document.createTextNode('\u00A0'), + fragment: document.createDocumentFragment() + } + + elementTemplates.a.setAttribute('role', 'option'); + elementTemplates.subtext.className = 'text-muted'; + + elementTemplates.text = elementTemplates.span.cloneNode(false); + elementTemplates.text.className = 'text'; + + elementTemplates.checkMark = elementTemplates.span.cloneNode(false); + + var REGEXP_ARROW = new RegExp(keyCodes.ARROW_UP + '|' + keyCodes.ARROW_DOWN); + var REGEXP_TAB_OR_ESCAPE = new RegExp('^' + keyCodes.TAB + '$|' + keyCodes.ESCAPE); + + var generateOption = { + li: function (content, classes, optgroup) { + var li = elementTemplates.li.cloneNode(false); + + if (content) { + if (content.nodeType === 1 || content.nodeType === 11) { + li.appendChild(content); + } else { + li.innerHTML = content; + } + } + + if (typeof classes !== 'undefined' && classes !== '') li.className = classes; + if (typeof optgroup !== 'undefined' && optgroup !== null) li.classList.add('optgroup-' + optgroup); + + return li; + }, + + a: function (text, classes, inline) { + var a = elementTemplates.a.cloneNode(true); + + if (text) { + if (text.nodeType === 11) { + a.appendChild(text); + } else { + a.insertAdjacentHTML('beforeend', text); + } + } + + if (typeof classes !== 'undefined' && classes !== '') a.className = classes; + if (version.major === '4') a.classList.add('dropdown-item'); + if (inline) a.setAttribute('style', inline); + + return a; + }, + + text: function (options, useFragment) { + var textElement = elementTemplates.text.cloneNode(false), + subtextElement, + iconElement; + + if (options.content) { + textElement.innerHTML = options.content; + } else { + textElement.textContent = options.text; + + if (options.icon) { + var whitespace = elementTemplates.whitespace.cloneNode(false); + + // need to use for icons in the button to prevent a breaking change + // note: switch to span in next major release + iconElement = (useFragment === true ? elementTemplates.i : elementTemplates.span).cloneNode(false); + iconElement.className = options.iconBase + ' ' + options.icon; + + elementTemplates.fragment.appendChild(iconElement); + elementTemplates.fragment.appendChild(whitespace); + } + + if (options.subtext) { + subtextElement = elementTemplates.subtext.cloneNode(false); + subtextElement.textContent = options.subtext; + textElement.appendChild(subtextElement); + } + } + + if (useFragment === true) { + while (textElement.childNodes.length > 0) { + elementTemplates.fragment.appendChild(textElement.childNodes[0]); + } + } else { + elementTemplates.fragment.appendChild(textElement); + } + + return elementTemplates.fragment; + }, + + label: function (options) { + var textElement = elementTemplates.text.cloneNode(false), + subtextElement, + iconElement; + + textElement.innerHTML = options.label; + + if (options.icon) { + var whitespace = elementTemplates.whitespace.cloneNode(false); + + iconElement = elementTemplates.span.cloneNode(false); + iconElement.className = options.iconBase + ' ' + options.icon; + + elementTemplates.fragment.appendChild(iconElement); + elementTemplates.fragment.appendChild(whitespace); + } + + if (options.subtext) { + subtextElement = elementTemplates.subtext.cloneNode(false); + subtextElement.textContent = options.subtext; + textElement.appendChild(subtextElement); + } + + elementTemplates.fragment.appendChild(textElement); + + return elementTemplates.fragment; + } + } + + var Selectpicker = function (element, options) { + var that = this; + + // bootstrap-select has been initialized - revert valHooks.select.set back to its original function + if (!valHooks.useDefault) { + $.valHooks.select.set = valHooks._set; + valHooks.useDefault = true; + } + + this.$element = $(element); + this.$newElement = null; + this.$button = null; + this.$menu = null; + this.options = options; + this.selectpicker = { + main: {}, + current: {}, // current changes if a search is in progress + search: {}, + view: {}, + keydown: { + keyHistory: '', + resetKeyHistory: { + start: function () { + return setTimeout(function () { + that.selectpicker.keydown.keyHistory = ''; + }, 800); + } + } + } + }; + // If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a + // data-attribute) + if (this.options.title === null) { + this.options.title = this.$element.attr('title'); + } + + // Format window padding + var winPad = this.options.windowPadding; + if (typeof winPad === 'number') { + this.options.windowPadding = [winPad, winPad, winPad, winPad]; + } + + // Expose public methods + this.val = Selectpicker.prototype.val; + this.render = Selectpicker.prototype.render; + this.refresh = Selectpicker.prototype.refresh; + this.setStyle = Selectpicker.prototype.setStyle; + this.selectAll = Selectpicker.prototype.selectAll; + this.deselectAll = Selectpicker.prototype.deselectAll; + this.destroy = Selectpicker.prototype.destroy; + this.remove = Selectpicker.prototype.remove; + this.show = Selectpicker.prototype.show; + this.hide = Selectpicker.prototype.hide; + + this.init(); + }; + + Selectpicker.VERSION = '1.13.9'; + + // part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both. + Selectpicker.DEFAULTS = { + noneSelectedText: 'Nothing selected', + noneResultsText: 'No results matched {0}', + countSelectedText: function (numSelected, numTotal) { + return (numSelected == 1) ? '{0} item selected' : '{0} items selected'; + }, + maxOptionsText: function (numAll, numGroup) { + return [ + (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)', + (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)' + ]; + }, + selectAllText: 'Select All', + deselectAllText: 'Deselect All', + doneButton: false, + doneButtonText: 'Close', + multipleSeparator: ', ', + styleBase: 'btn', + style: classNames.BUTTONCLASS, + size: 'auto', + title: null, + selectedTextFormat: 'values', + width: false, + container: false, + hideDisabled: false, + showSubtext: false, + showIcon: true, + showContent: true, + dropupAuto: true, + header: false, + liveSearch: false, + liveSearchPlaceholder: null, + liveSearchNormalize: false, + liveSearchStyle: 'contains', + actionsBox: false, + iconBase: classNames.ICONBASE, + tickIcon: classNames.TICKICON, + showTick: false, + template: { + caret: '' + }, + maxOptions: false, + mobile: false, + selectOnTab: false, + dropdownAlignRight: false, + windowPadding: 0, + virtualScroll: 600, + display: false, + sanitize: true, + sanitizeFn: null, + whiteList: DefaultWhitelist + }; + + Selectpicker.prototype = { + + constructor: Selectpicker, + + init: function () { + var that = this, + id = this.$element.attr('id'); + + this.selectId = selectId++; + + this.$element[0].classList.add('bs-select-hidden'); + + this.multiple = this.$element.prop('multiple'); + this.autofocus = this.$element.prop('autofocus'); + this.options.showTick = this.$element[0].classList.contains('show-tick'); + + this.$newElement = this.createDropdown(); + this.$element + .after(this.$newElement) + .prependTo(this.$newElement); + + this.$button = this.$newElement.children('button'); + this.$menu = this.$newElement.children(Selector.MENU); + this.$menuInner = this.$menu.children('.inner'); + this.$searchbox = this.$menu.find('input'); + + this.$element[0].classList.remove('bs-select-hidden'); + + if (this.options.dropdownAlignRight === true) this.$menu[0].classList.add(classNames.MENURIGHT); + + if (typeof id !== 'undefined') { + this.$button.attr('data-id', id); + } + + this.checkDisabled(); + this.clickListener(); + if (this.options.liveSearch) this.liveSearchListener(); + this.setStyle(); + this.render(); + this.setWidth(); + if (this.options.container) { + this.selectPosition(); + } else { + this.$element.on('hide' + EVENT_KEY, function () { + if (that.isVirtual()) { + // empty menu on close + var menuInner = that.$menuInner[0], + emptyMenu = menuInner.firstChild.cloneNode(false); + + // replace the existing UL with an empty one - this is faster than $.empty() or innerHTML = '' + menuInner.replaceChild(emptyMenu, menuInner.firstChild); + menuInner.scrollTop = 0; + } + }); + } + this.$menu.data('this', this); + this.$newElement.data('this', this); + if (this.options.mobile) this.mobile(); + + this.$newElement.on({ + 'hide.bs.dropdown': function (e) { + that.$menuInner.attr('aria-expanded', false); + that.$element.trigger('hide' + EVENT_KEY, e); + }, + 'hidden.bs.dropdown': function (e) { + that.$element.trigger('hidden' + EVENT_KEY, e); + }, + 'show.bs.dropdown': function (e) { + that.$menuInner.attr('aria-expanded', true); + that.$element.trigger('show' + EVENT_KEY, e); + }, + 'shown.bs.dropdown': function (e) { + that.$element.trigger('shown' + EVENT_KEY, e); + } + }); + + if (that.$element[0].hasAttribute('required')) { + this.$element.on('invalid' + EVENT_KEY, function () { + that.$button[0].classList.add('bs-invalid'); + + that.$element + .on('shown' + EVENT_KEY + '.invalid', function () { + that.$element + .val(that.$element.val()) // set the value to hide the validation message in Chrome when menu is opened + .off('shown' + EVENT_KEY + '.invalid'); + }) + .on('rendered' + EVENT_KEY, function () { + // if select is no longer invalid, remove the bs-invalid class + if (this.validity.valid) that.$button[0].classList.remove('bs-invalid'); + that.$element.off('rendered' + EVENT_KEY); + }); + + that.$button.on('blur' + EVENT_KEY, function () { + that.$element.trigger('focus').trigger('blur'); + that.$button.off('blur' + EVENT_KEY); + }); + }); + } + + setTimeout(function () { + that.createLi(); + that.$element.trigger('loaded' + EVENT_KEY); + }); + }, + + createDropdown: function () { + // Options + // If we are multiple or showTick option is set, then add the show-tick class + var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '', + inputGroup = '', + autofocus = this.autofocus ? ' autofocus' : ''; + + if (version.major < 4 && this.$element.parent().hasClass('input-group')) { + inputGroup = ' input-group-btn'; + } + + // Elements + var drop, + header = '', + searchbox = '', + actionsbox = '', + donebutton = ''; + + if (this.options.header) { + header = + '
    ' + + '' + + this.options.header + + '
    '; + } + + if (this.options.liveSearch) { + searchbox = + ''; + } + + if (this.multiple && this.options.actionsBox) { + actionsbox = + '
    ' + + '
    ' + + '' + + '' + + '
    ' + + '
    '; + } + + if (this.multiple && this.options.doneButton) { + donebutton = + '
    ' + + '
    ' + + '' + + '
    ' + + '
    '; + } + + drop = + ''; + + return $(drop); + }, + + setPositionData: function () { + this.selectpicker.view.canHighlight = []; + + for (var i = 0; i < this.selectpicker.current.data.length; i++) { + var li = this.selectpicker.current.data[i], + canHighlight = true; + + if (li.type === 'divider') { + canHighlight = false; + li.height = this.sizeInfo.dividerHeight; + } else if (li.type === 'optgroup-label') { + canHighlight = false; + li.height = this.sizeInfo.dropdownHeaderHeight; + } else { + li.height = this.sizeInfo.liHeight; + } + + if (li.disabled) canHighlight = false; + + this.selectpicker.view.canHighlight.push(canHighlight); + + li.position = (i === 0 ? 0 : this.selectpicker.current.data[i - 1].position) + li.height; + } + }, + + isVirtual: function () { + return (this.options.virtualScroll !== false) && (this.selectpicker.main.elements.length >= this.options.virtualScroll) || this.options.virtualScroll === true; + }, + + createView: function (isSearching, scrollTop) { + scrollTop = scrollTop || 0; + + var that = this; + + this.selectpicker.current = isSearching ? this.selectpicker.search : this.selectpicker.main; + + var active = []; + var selected; + var prevActive; + + this.setPositionData(); + + scroll(scrollTop, true); + + this.$menuInner.off('scroll.createView').on('scroll.createView', function (e, updateValue) { + if (!that.noScroll) scroll(this.scrollTop, updateValue); + that.noScroll = false; + }); + + function scroll (scrollTop, init) { + var size = that.selectpicker.current.elements.length, + chunks = [], + chunkSize, + chunkCount, + firstChunk, + lastChunk, + currentChunk, + prevPositions, + positionIsDifferent, + previousElements, + menuIsDifferent = true, + isVirtual = that.isVirtual(); + + that.selectpicker.view.scrollTop = scrollTop; + + if (isVirtual === true) { + // if an option that is encountered that is wider than the current menu width, update the menu width accordingly + if (that.sizeInfo.hasScrollBar && that.$menu[0].offsetWidth > that.sizeInfo.totalMenuWidth) { + that.sizeInfo.menuWidth = that.$menu[0].offsetWidth; + that.sizeInfo.totalMenuWidth = that.sizeInfo.menuWidth + that.sizeInfo.scrollBarWidth; + that.$menu.css('min-width', that.sizeInfo.menuWidth); + } + } + + chunkSize = Math.ceil(that.sizeInfo.menuInnerHeight / that.sizeInfo.liHeight * 1.5); // number of options in a chunk + chunkCount = Math.round(size / chunkSize) || 1; // number of chunks + + for (var i = 0; i < chunkCount; i++) { + var endOfChunk = (i + 1) * chunkSize; + + if (i === chunkCount - 1) { + endOfChunk = size; + } + + chunks[i] = [ + (i) * chunkSize + (!i ? 0 : 1), + endOfChunk + ]; + + if (!size) break; + + if (currentChunk === undefined && scrollTop <= that.selectpicker.current.data[endOfChunk - 1].position - that.sizeInfo.menuInnerHeight) { + currentChunk = i; + } + } + + if (currentChunk === undefined) currentChunk = 0; + + prevPositions = [that.selectpicker.view.position0, that.selectpicker.view.position1]; + + // always display previous, current, and next chunks + firstChunk = Math.max(0, currentChunk - 1); + lastChunk = Math.min(chunkCount - 1, currentChunk + 1); + + that.selectpicker.view.position0 = isVirtual === false ? 0 : (Math.max(0, chunks[firstChunk][0]) || 0); + that.selectpicker.view.position1 = isVirtual === false ? size : (Math.min(size, chunks[lastChunk][1]) || 0); + + positionIsDifferent = prevPositions[0] !== that.selectpicker.view.position0 || prevPositions[1] !== that.selectpicker.view.position1; + + if (that.activeIndex !== undefined) { + prevActive = that.selectpicker.main.elements[that.prevActiveIndex]; + active = that.selectpicker.main.elements[that.activeIndex]; + selected = that.selectpicker.main.elements[that.selectedIndex]; + + if (init) { + if (that.activeIndex !== that.selectedIndex && active && active.length) { + active.classList.remove('active'); + if (active.firstChild) active.firstChild.classList.remove('active'); + } + that.activeIndex = undefined; + } + + if (that.activeIndex && that.activeIndex !== that.selectedIndex && selected && selected.length) { + selected.classList.remove('active'); + if (selected.firstChild) selected.firstChild.classList.remove('active'); + } + } + + if (that.prevActiveIndex !== undefined && that.prevActiveIndex !== that.activeIndex && that.prevActiveIndex !== that.selectedIndex && prevActive && prevActive.length) { + prevActive.classList.remove('active'); + if (prevActive.firstChild) prevActive.firstChild.classList.remove('active'); + } + + if (init || positionIsDifferent) { + previousElements = that.selectpicker.view.visibleElements ? that.selectpicker.view.visibleElements.slice() : []; + + if (isVirtual === false) { + that.selectpicker.view.visibleElements = that.selectpicker.current.elements; + } else { + that.selectpicker.view.visibleElements = that.selectpicker.current.elements.slice(that.selectpicker.view.position0, that.selectpicker.view.position1); + } + + that.setOptionStatus(); + + // if searching, check to make sure the list has actually been updated before updating DOM + // this prevents unnecessary repaints + if (isSearching || (isVirtual === false && init)) menuIsDifferent = !isEqual(previousElements, that.selectpicker.view.visibleElements); + + // if virtual scroll is disabled and not searching, + // menu should never need to be updated more than once + if ((init || isVirtual === true) && menuIsDifferent) { + var menuInner = that.$menuInner[0], + menuFragment = document.createDocumentFragment(), + emptyMenu = menuInner.firstChild.cloneNode(false), + marginTop, + marginBottom, + elements = that.selectpicker.view.visibleElements, + toSanitize = []; + + // replace the existing UL with an empty one - this is faster than $.empty() + menuInner.replaceChild(emptyMenu, menuInner.firstChild); + + for (var i = 0, visibleElementsLen = elements.length; i < visibleElementsLen; i++) { + var element = elements[i], + elText, + elementData; + + if (that.options.sanitize) { + elText = element.lastChild; + + if (elText) { + elementData = that.selectpicker.current.data[i + that.selectpicker.view.position0]; + + if (elementData && elementData.content && !elementData.sanitized) { + toSanitize.push(elText); + elementData.sanitized = true; + } + } + } + + menuFragment.appendChild(element); + } + + if (that.options.sanitize && toSanitize.length) { + sanitizeHtml(toSanitize, that.options.whiteList, that.options.sanitizeFn); + } + + if (isVirtual === true) { + marginTop = (that.selectpicker.view.position0 === 0 ? 0 : that.selectpicker.current.data[that.selectpicker.view.position0 - 1].position); + marginBottom = (that.selectpicker.view.position1 > size - 1 ? 0 : that.selectpicker.current.data[size - 1].position - that.selectpicker.current.data[that.selectpicker.view.position1 - 1].position); + + menuInner.firstChild.style.marginTop = marginTop + 'px'; + menuInner.firstChild.style.marginBottom = marginBottom + 'px'; + } + + menuInner.firstChild.appendChild(menuFragment); + } + } + + that.prevActiveIndex = that.activeIndex; + + if (!that.options.liveSearch) { + that.$menuInner.trigger('focus'); + } else if (isSearching && init) { + var index = 0, + newActive; + + if (!that.selectpicker.view.canHighlight[index]) { + index = 1 + that.selectpicker.view.canHighlight.slice(1).indexOf(true); + } + + newActive = that.selectpicker.view.visibleElements[index]; + + if (that.selectpicker.view.currentActive) { + that.selectpicker.view.currentActive.classList.remove('active'); + if (that.selectpicker.view.currentActive.firstChild) that.selectpicker.view.currentActive.firstChild.classList.remove('active'); + } + + if (newActive) { + newActive.classList.add('active'); + if (newActive.firstChild) newActive.firstChild.classList.add('active'); + } + + that.activeIndex = (that.selectpicker.current.data[index] || {}).index; + } + } + + $(window) + .off('resize' + EVENT_KEY + '.' + this.selectId + '.createView') + .on('resize' + EVENT_KEY + '.' + this.selectId + '.createView', function () { + var isActive = that.$newElement.hasClass(classNames.SHOW); + + if (isActive) scroll(that.$menuInner[0].scrollTop); + }); + }, + + setPlaceholder: function () { + var updateIndex = false; + + if (this.options.title && !this.multiple) { + if (!this.selectpicker.view.titleOption) this.selectpicker.view.titleOption = document.createElement('option'); + + // this option doesn't create a new
  • element, but does add a new option at the start, + // so startIndex should increase to prevent having to check every option for the bs-title-option class + updateIndex = true; + + var element = this.$element[0], + isSelected = false, + titleNotAppended = !this.selectpicker.view.titleOption.parentNode; + + if (titleNotAppended) { + // Use native JS to prepend option (faster) + this.selectpicker.view.titleOption.className = 'bs-title-option'; + this.selectpicker.view.titleOption.value = ''; + + // Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option. + // the selected item may have been changed by user or programmatically before the bootstrap select plugin runs, + // if so, the select will have the data-selected attribute + var $opt = $(element.options[element.selectedIndex]); + isSelected = $opt.attr('selected') === undefined && this.$element.data('selected') === undefined; + } + + if (titleNotAppended || this.selectpicker.view.titleOption.index !== 0) { + element.insertBefore(this.selectpicker.view.titleOption, element.firstChild); + } + + // Set selected *after* appending to select, + // otherwise the option doesn't get selected in IE + // set using selectedIndex, as setting the selected attr to true here doesn't work in IE11 + if (isSelected) element.selectedIndex = 0; + } + + return updateIndex; + }, + + createLi: function () { + var that = this, + iconBase = this.options.iconBase, + optionSelector = ':not([hidden]):not([data-hidden="true"])', + mainElements = [], + mainData = [], + widestOptionLength = 0, + optID = 0, + startIndex = this.setPlaceholder() ? 1 : 0; // append the titleOption if necessary and skip the first option in the loop + + if (this.options.hideDisabled) optionSelector += ':not(:disabled)'; + + if ((that.options.showTick || that.multiple) && !elementTemplates.checkMark.parentNode) { + elementTemplates.checkMark.className = iconBase + ' ' + that.options.tickIcon + ' check-mark'; + elementTemplates.a.appendChild(elementTemplates.checkMark); + } + + var selectOptions = this.$element[0].querySelectorAll('select > *' + optionSelector); + + function addDivider (config) { + var previousData = mainData[mainData.length - 1]; + + // ensure optgroup doesn't create back-to-back dividers + if ( + previousData && + previousData.type === 'divider' && + (previousData.optID || config.optID) + ) { + return; + } + + config = config || {}; + config.type = 'divider'; + + mainElements.push( + generateOption.li( + false, + classNames.DIVIDER, + (config.optID ? config.optID + 'div' : undefined) + ) + ); + + mainData.push(config); + } + + function addOption (option, config) { + config = config || {}; + + config.divider = option.getAttribute('data-divider') === 'true'; + + if (config.divider) { + addDivider({ + optID: config.optID + }); + } else { + var liIndex = mainData.length, + cssText = option.style.cssText, + inlineStyle = cssText ? htmlEscape(cssText) : '', + optionClass = (option.className || '') + (config.optgroupClass || ''); + + if (config.optID) optionClass = 'opt ' + optionClass; + + config.text = option.textContent; + + config.content = option.getAttribute('data-content'); + config.tokens = option.getAttribute('data-tokens'); + config.subtext = option.getAttribute('data-subtext'); + config.icon = option.getAttribute('data-icon'); + config.iconBase = iconBase; + + var textElement = generateOption.text(config); + + mainElements.push( + generateOption.li( + generateOption.a( + textElement, + optionClass, + inlineStyle + ), + '', + config.optID + ) + ); + + option.liIndex = liIndex; + + config.display = config.content || config.text; + config.type = 'option'; + config.index = liIndex; + config.option = option; + config.disabled = config.disabled || option.disabled; + + mainData.push(config); + + var combinedLength = 0; + + // count the number of characters in the option - not perfect, but should work in most cases + if (config.display) combinedLength += config.display.length; + if (config.subtext) combinedLength += config.subtext.length; + // if there is an icon, ensure this option's width is checked + if (config.icon) combinedLength += 1; + + if (combinedLength > widestOptionLength) { + widestOptionLength = combinedLength; + + // guess which option is the widest + // use this when calculating menu width + // not perfect, but it's fast, and the width will be updating accordingly when scrolling + that.selectpicker.view.widestOption = mainElements[mainElements.length - 1]; + } + } + } + + function addOptgroup (index, selectOptions) { + var optgroup = selectOptions[index], + previous = selectOptions[index - 1], + next = selectOptions[index + 1], + options = optgroup.querySelectorAll('option' + optionSelector); + + if (!options.length) return; + + var config = { + label: htmlEscape(optgroup.label), + subtext: optgroup.getAttribute('data-subtext'), + icon: optgroup.getAttribute('data-icon'), + iconBase: iconBase + }, + optgroupClass = ' ' + (optgroup.className || ''), + headerIndex, + lastIndex; + + optID++; + + if (previous) { + addDivider({ optID: optID }); + } + + var labelElement = generateOption.label(config); + + mainElements.push( + generateOption.li(labelElement, 'dropdown-header' + optgroupClass, optID) + ); + + mainData.push({ + display: config.label, + subtext: config.subtext, + type: 'optgroup-label', + optID: optID + }); + + for (var j = 0, len = options.length; j < len; j++) { + var option = options[j]; + + if (j === 0) { + headerIndex = mainData.length - 1; + lastIndex = headerIndex + len; + } + + addOption(option, { + headerIndex: headerIndex, + lastIndex: lastIndex, + optID: optID, + optgroupClass: optgroupClass, + disabled: optgroup.disabled + }); + } + + if (next) { + addDivider({ optID: optID }); + } + } + + for (var len = selectOptions.length; startIndex < len; startIndex++) { + var item = selectOptions[startIndex]; + + if (item.tagName !== 'OPTGROUP') { + addOption(item, {}); + } else { + addOptgroup(startIndex, selectOptions); + } + } + + this.selectpicker.main.elements = mainElements; + this.selectpicker.main.data = mainData; + + this.selectpicker.current = this.selectpicker.main; + }, + + findLis: function () { + return this.$menuInner.find('.inner > li'); + }, + + render: function () { + // ensure titleOption is appended and selected (if necessary) before getting selectedOptions + this.setPlaceholder(); + + var that = this, + selectedOptions = this.$element[0].selectedOptions, + selectedCount = selectedOptions.length, + button = this.$button[0], + buttonInner = button.querySelector('.filter-option-inner-inner'), + multipleSeparator = document.createTextNode(this.options.multipleSeparator), + titleFragment = elementTemplates.fragment.cloneNode(false), + showCount, + countMax, + hasContent = false; + + this.togglePlaceholder(); + + this.tabIndex(); + + if (this.options.selectedTextFormat === 'static') { + titleFragment = generateOption.text({ text: this.options.title }, true); + } else { + showCount = this.multiple && this.options.selectedTextFormat.indexOf('count') !== -1 && selectedCount > 1; + + // determine if the number of selected options will be shown (showCount === true) + if (showCount) { + countMax = this.options.selectedTextFormat.split('>'); + showCount = (countMax.length > 1 && selectedCount > countMax[1]) || (countMax.length === 1 && selectedCount >= 2); + } + + // only loop through all selected options if the count won't be shown + if (showCount === false) { + for (var selectedIndex = 0; selectedIndex < selectedCount; selectedIndex++) { + if (selectedIndex < 50) { + var option = selectedOptions[selectedIndex], + titleOptions = {}, + thisData = { + content: option.getAttribute('data-content'), + subtext: option.getAttribute('data-subtext'), + icon: option.getAttribute('data-icon') + }; + + if (this.multiple && selectedIndex > 0) { + titleFragment.appendChild(multipleSeparator.cloneNode(false)); + } + + if (option.title) { + titleOptions.text = option.title; + } else if (thisData.content && that.options.showContent) { + titleOptions.content = thisData.content.toString(); + hasContent = true; + } else { + if (that.options.showIcon) { + titleOptions.icon = thisData.icon; + titleOptions.iconBase = this.options.iconBase; + } + if (that.options.showSubtext && !that.multiple && thisData.subtext) titleOptions.subtext = ' ' + thisData.subtext; + titleOptions.text = option.textContent.trim(); + } + + titleFragment.appendChild(generateOption.text(titleOptions, true)); + } else { + break; + } + } + + // add ellipsis + if (selectedCount > 49) { + titleFragment.appendChild(document.createTextNode('...')); + } + } else { + var optionSelector = ':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])'; + if (this.options.hideDisabled) optionSelector += ':not(:disabled)'; + + // If this is a multiselect, and selectedTextFormat is count, then show 1 of 2 selected, etc. + var totalCount = this.$element[0].querySelectorAll('select > option' + optionSelector + ', optgroup' + optionSelector + ' option' + optionSelector).length, + tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedCount, totalCount) : this.options.countSelectedText; + + titleFragment = generateOption.text({ + text: tr8nText.replace('{0}', selectedCount.toString()).replace('{1}', totalCount.toString()) + }, true); + } + } + + if (this.options.title == undefined) { + // use .attr to ensure undefined is returned if title attribute is not set + this.options.title = this.$element.attr('title'); + } + + // If the select doesn't have a title, then use the default, or if nothing is set at all, use noneSelectedText + if (!titleFragment.childNodes.length) { + titleFragment = generateOption.text({ + text: typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText + }, true); + } + + // strip all HTML tags and trim the result, then unescape any escaped tags + button.title = titleFragment.textContent.replace(/<[^>]*>?/g, '').trim(); + + if (this.options.sanitize && hasContent) { + sanitizeHtml([titleFragment], that.options.whiteList, that.options.sanitizeFn); + } + + buttonInner.innerHTML = ''; + buttonInner.appendChild(titleFragment); + + if (version.major < 4 && this.$newElement[0].classList.contains('bs3-has-addon')) { + var filterExpand = button.querySelector('.filter-expand'), + clone = buttonInner.cloneNode(true); + + clone.className = 'filter-expand'; + + if (filterExpand) { + button.replaceChild(clone, filterExpand); + } else { + button.appendChild(clone); + } + } + + this.$element.trigger('rendered' + EVENT_KEY); + }, + + /** + * @param [style] + * @param [status] + */ + setStyle: function (newStyle, status) { + var button = this.$button[0], + newElement = this.$newElement[0], + style = this.options.style.trim(), + buttonClass; + + if (this.$element.attr('class')) { + this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, '')); + } + + if (version.major < 4) { + newElement.classList.add('bs3'); + + if (newElement.parentNode.classList.contains('input-group') && + (newElement.previousElementSibling || newElement.nextElementSibling) && + (newElement.previousElementSibling || newElement.nextElementSibling).classList.contains('input-group-addon') + ) { + newElement.classList.add('bs3-has-addon'); + } + } + + if (newStyle) { + buttonClass = newStyle.trim(); + } else { + buttonClass = style; + } + + if (status == 'add') { + if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' ')); + } else if (status == 'remove') { + if (buttonClass) button.classList.remove.apply(button.classList, buttonClass.split(' ')); + } else { + if (style) button.classList.remove.apply(button.classList, style.split(' ')); + if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' ')); + } + }, + + liHeight: function (refresh) { + if (!refresh && (this.options.size === false || this.sizeInfo)) return; + + if (!this.sizeInfo) this.sizeInfo = {}; + + var newElement = document.createElement('div'), + menu = document.createElement('div'), + menuInner = document.createElement('div'), + menuInnerInner = document.createElement('ul'), + divider = document.createElement('li'), + dropdownHeader = document.createElement('li'), + li = document.createElement('li'), + a = document.createElement('a'), + text = document.createElement('span'), + header = this.options.header && this.$menu.find('.' + classNames.POPOVERHEADER).length > 0 ? this.$menu.find('.' + classNames.POPOVERHEADER)[0].cloneNode(true) : null, + search = this.options.liveSearch ? document.createElement('div') : null, + actions = this.options.actionsBox && this.multiple && this.$menu.find('.bs-actionsbox').length > 0 ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null, + doneButton = this.options.doneButton && this.multiple && this.$menu.find('.bs-donebutton').length > 0 ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null, + firstOption = this.$element.find('option')[0]; + + this.sizeInfo.selectWidth = this.$newElement[0].offsetWidth; + + text.className = 'text'; + a.className = 'dropdown-item ' + (firstOption ? firstOption.className : ''); + newElement.className = this.$menu[0].parentNode.className + ' ' + classNames.SHOW; + newElement.style.width = this.sizeInfo.selectWidth + 'px'; + if (this.options.width === 'auto') menu.style.minWidth = 0; + menu.className = classNames.MENU + ' ' + classNames.SHOW; + menuInner.className = 'inner ' + classNames.SHOW; + menuInnerInner.className = classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : ''); + divider.className = classNames.DIVIDER; + dropdownHeader.className = 'dropdown-header'; + + text.appendChild(document.createTextNode('\u200b')); + a.appendChild(text); + li.appendChild(a); + dropdownHeader.appendChild(text.cloneNode(true)); + + if (this.selectpicker.view.widestOption) { + menuInnerInner.appendChild(this.selectpicker.view.widestOption.cloneNode(true)); + } + + menuInnerInner.appendChild(li); + menuInnerInner.appendChild(divider); + menuInnerInner.appendChild(dropdownHeader); + if (header) menu.appendChild(header); + if (search) { + var input = document.createElement('input'); + search.className = 'bs-searchbox'; + input.className = 'form-control'; + search.appendChild(input); + menu.appendChild(search); + } + if (actions) menu.appendChild(actions); + menuInner.appendChild(menuInnerInner); + menu.appendChild(menuInner); + if (doneButton) menu.appendChild(doneButton); + newElement.appendChild(menu); + + document.body.appendChild(newElement); + + var liHeight = li.offsetHeight, + dropdownHeaderHeight = dropdownHeader ? dropdownHeader.offsetHeight : 0, + headerHeight = header ? header.offsetHeight : 0, + searchHeight = search ? search.offsetHeight : 0, + actionsHeight = actions ? actions.offsetHeight : 0, + doneButtonHeight = doneButton ? doneButton.offsetHeight : 0, + dividerHeight = $(divider).outerHeight(true), + // fall back to jQuery if getComputedStyle is not supported + menuStyle = window.getComputedStyle ? window.getComputedStyle(menu) : false, + menuWidth = menu.offsetWidth, + $menu = menuStyle ? null : $(menu), + menuPadding = { + vert: toInteger(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) + + toInteger(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) + + toInteger(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) + + toInteger(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')), + horiz: toInteger(menuStyle ? menuStyle.paddingLeft : $menu.css('paddingLeft')) + + toInteger(menuStyle ? menuStyle.paddingRight : $menu.css('paddingRight')) + + toInteger(menuStyle ? menuStyle.borderLeftWidth : $menu.css('borderLeftWidth')) + + toInteger(menuStyle ? menuStyle.borderRightWidth : $menu.css('borderRightWidth')) + }, + menuExtras = { + vert: menuPadding.vert + + toInteger(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) + + toInteger(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2, + horiz: menuPadding.horiz + + toInteger(menuStyle ? menuStyle.marginLeft : $menu.css('marginLeft')) + + toInteger(menuStyle ? menuStyle.marginRight : $menu.css('marginRight')) + 2 + }, + scrollBarWidth; + + menuInner.style.overflowY = 'scroll'; + + scrollBarWidth = menu.offsetWidth - menuWidth; + + document.body.removeChild(newElement); + + this.sizeInfo.liHeight = liHeight; + this.sizeInfo.dropdownHeaderHeight = dropdownHeaderHeight; + this.sizeInfo.headerHeight = headerHeight; + this.sizeInfo.searchHeight = searchHeight; + this.sizeInfo.actionsHeight = actionsHeight; + this.sizeInfo.doneButtonHeight = doneButtonHeight; + this.sizeInfo.dividerHeight = dividerHeight; + this.sizeInfo.menuPadding = menuPadding; + this.sizeInfo.menuExtras = menuExtras; + this.sizeInfo.menuWidth = menuWidth; + this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth; + this.sizeInfo.scrollBarWidth = scrollBarWidth; + this.sizeInfo.selectHeight = this.$newElement[0].offsetHeight; + + this.setPositionData(); + }, + + getSelectPosition: function () { + var that = this, + $window = $(window), + pos = that.$newElement.offset(), + $container = $(that.options.container), + containerPos; + + if (that.options.container && $container.length && !$container.is('body')) { + containerPos = $container.offset(); + containerPos.top += parseInt($container.css('borderTopWidth')); + containerPos.left += parseInt($container.css('borderLeftWidth')); + } else { + containerPos = { top: 0, left: 0 }; + } + + var winPad = that.options.windowPadding; + + this.sizeInfo.selectOffsetTop = pos.top - containerPos.top - $window.scrollTop(); + this.sizeInfo.selectOffsetBot = $window.height() - this.sizeInfo.selectOffsetTop - this.sizeInfo.selectHeight - containerPos.top - winPad[2]; + this.sizeInfo.selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft(); + this.sizeInfo.selectOffsetRight = $window.width() - this.sizeInfo.selectOffsetLeft - this.sizeInfo.selectWidth - containerPos.left - winPad[1]; + this.sizeInfo.selectOffsetTop -= winPad[0]; + this.sizeInfo.selectOffsetLeft -= winPad[3]; + }, + + setMenuSize: function (isAuto) { + this.getSelectPosition(); + + var selectWidth = this.sizeInfo.selectWidth, + liHeight = this.sizeInfo.liHeight, + headerHeight = this.sizeInfo.headerHeight, + searchHeight = this.sizeInfo.searchHeight, + actionsHeight = this.sizeInfo.actionsHeight, + doneButtonHeight = this.sizeInfo.doneButtonHeight, + divHeight = this.sizeInfo.dividerHeight, + menuPadding = this.sizeInfo.menuPadding, + menuInnerHeight, + menuHeight, + divLength = 0, + minHeight, + _minHeight, + maxHeight, + menuInnerMinHeight, + estimate; + + if (this.options.dropupAuto) { + // Get the estimated height of the menu without scrollbars. + // This is useful for smaller menus, where there might be plenty of room + // below the button without setting dropup, but we can't know + // the exact height of the menu until createView is called later + estimate = liHeight * this.selectpicker.current.elements.length + menuPadding.vert; + this.$newElement.toggleClass(classNames.DROPUP, this.sizeInfo.selectOffsetTop - this.sizeInfo.selectOffsetBot > this.sizeInfo.menuExtras.vert && estimate + this.sizeInfo.menuExtras.vert + 50 > this.sizeInfo.selectOffsetBot); + } + + if (this.options.size === 'auto') { + _minHeight = this.selectpicker.current.elements.length > 3 ? this.sizeInfo.liHeight * 3 + this.sizeInfo.menuExtras.vert - 2 : 0; + menuHeight = this.sizeInfo.selectOffsetBot - this.sizeInfo.menuExtras.vert; + minHeight = _minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight; + menuInnerMinHeight = Math.max(_minHeight - menuPadding.vert, 0); + + if (this.$newElement.hasClass(classNames.DROPUP)) { + menuHeight = this.sizeInfo.selectOffsetTop - this.sizeInfo.menuExtras.vert; + } + + maxHeight = menuHeight; + menuInnerHeight = menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding.vert; + } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) { + for (var i = 0; i < this.options.size; i++) { + if (this.selectpicker.current.data[i].type === 'divider') divLength++; + } + + menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert; + menuInnerHeight = menuHeight - menuPadding.vert; + maxHeight = menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight; + minHeight = menuInnerMinHeight = ''; + } + + if (this.options.dropdownAlignRight === 'auto') { + this.$menu.toggleClass(classNames.MENURIGHT, this.sizeInfo.selectOffsetLeft > this.sizeInfo.selectOffsetRight && this.sizeInfo.selectOffsetRight < (this.sizeInfo.totalMenuWidth - selectWidth)); + } + + this.$menu.css({ + 'max-height': maxHeight + 'px', + 'overflow': 'hidden', + 'min-height': minHeight + 'px' + }); + + this.$menuInner.css({ + 'max-height': menuInnerHeight + 'px', + 'overflow-y': 'auto', + 'min-height': menuInnerMinHeight + 'px' + }); + + // ensure menuInnerHeight is always a positive number to prevent issues calculating chunkSize in createView + this.sizeInfo.menuInnerHeight = Math.max(menuInnerHeight, 1); + + if (this.selectpicker.current.data.length && this.selectpicker.current.data[this.selectpicker.current.data.length - 1].position > this.sizeInfo.menuInnerHeight) { + this.sizeInfo.hasScrollBar = true; + this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth + this.sizeInfo.scrollBarWidth; + + this.$menu.css('min-width', this.sizeInfo.totalMenuWidth); + } + + if (this.dropdown && this.dropdown._popper) this.dropdown._popper.update(); + }, + + setSize: function (refresh) { + this.liHeight(refresh); + + if (this.options.header) this.$menu.css('padding-top', 0); + if (this.options.size === false) return; + + var that = this, + $window = $(window), + selectedIndex, + offset = 0; + + this.setMenuSize(); + + if (this.options.liveSearch) { + this.$searchbox + .off('input.setMenuSize propertychange.setMenuSize') + .on('input.setMenuSize propertychange.setMenuSize', function () { + return that.setMenuSize(); + }); + } + + if (this.options.size === 'auto') { + $window + .off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize') + .on('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize', function () { + return that.setMenuSize(); + }); + } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) { + $window.off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize'); + } + + if (refresh) { + offset = this.$menuInner[0].scrollTop; + } else if (!that.multiple) { + var element = that.$element[0]; + selectedIndex = (element.options[element.selectedIndex] || {}).liIndex; + + if (typeof selectedIndex === 'number' && that.options.size !== false) { + offset = that.sizeInfo.liHeight * selectedIndex; + offset = offset - (that.sizeInfo.menuInnerHeight / 2) + (that.sizeInfo.liHeight / 2); + } + } + + that.createView(false, offset); + }, + + setWidth: function () { + var that = this; + + if (this.options.width === 'auto') { + requestAnimationFrame(function () { + that.$menu.css('min-width', '0'); + + that.$element.on('loaded' + EVENT_KEY, function () { + that.liHeight(); + that.setMenuSize(); + + // Get correct width if element is hidden + var $selectClone = that.$newElement.clone().appendTo('body'), + btnWidth = $selectClone.css('width', 'auto').children('button').outerWidth(); + + $selectClone.remove(); + + // Set width to whatever's larger, button title or longest option + that.sizeInfo.selectWidth = Math.max(that.sizeInfo.totalMenuWidth, btnWidth); + that.$newElement.css('width', that.sizeInfo.selectWidth + 'px'); + }); + }); + } else if (this.options.width === 'fit') { + // Remove inline min-width so width can be changed from 'auto' + this.$menu.css('min-width', ''); + this.$newElement.css('width', '').addClass('fit-width'); + } else if (this.options.width) { + // Remove inline min-width so width can be changed from 'auto' + this.$menu.css('min-width', ''); + this.$newElement.css('width', this.options.width); + } else { + // Remove inline min-width/width so width can be changed + this.$menu.css('min-width', ''); + this.$newElement.css('width', ''); + } + // Remove fit-width class if width is changed programmatically + if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') { + this.$newElement[0].classList.remove('fit-width'); + } + }, + + selectPosition: function () { + this.$bsContainer = $('
    '); + + var that = this, + $container = $(this.options.container), + pos, + containerPos, + actualHeight, + getPlacement = function ($element) { + var containerPosition = {}, + // fall back to dropdown's default display setting if display is not manually set + display = that.options.display || ( + // Bootstrap 3 doesn't have $.fn.dropdown.Constructor.Default + $.fn.dropdown.Constructor.Default ? $.fn.dropdown.Constructor.Default.display + : false + ); + + that.$bsContainer.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass(classNames.DROPUP, $element.hasClass(classNames.DROPUP)); + pos = $element.offset(); + + if (!$container.is('body')) { + containerPos = $container.offset(); + containerPos.top += parseInt($container.css('borderTopWidth')) - $container.scrollTop(); + containerPos.left += parseInt($container.css('borderLeftWidth')) - $container.scrollLeft(); + } else { + containerPos = { top: 0, left: 0 }; + } + + actualHeight = $element.hasClass(classNames.DROPUP) ? 0 : $element[0].offsetHeight; + + // Bootstrap 4+ uses Popper for menu positioning + if (version.major < 4 || display === 'static') { + containerPosition.top = pos.top - containerPos.top + actualHeight; + containerPosition.left = pos.left - containerPos.left; + } + + containerPosition.width = $element[0].offsetWidth; + + that.$bsContainer.css(containerPosition); + }; + + this.$button.on('click.bs.dropdown.data-api', function () { + if (that.isDisabled()) { + return; + } + + getPlacement(that.$newElement); + + that.$bsContainer + .appendTo(that.options.container) + .toggleClass(classNames.SHOW, !that.$button.hasClass(classNames.SHOW)) + .append(that.$menu); + }); + + $(window) + .off('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId) + .on('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId, function () { + var isActive = that.$newElement.hasClass(classNames.SHOW); + + if (isActive) getPlacement(that.$newElement); + }); + + this.$element.on('hide' + EVENT_KEY, function () { + that.$menu.data('height', that.$menu.height()); + that.$bsContainer.detach(); + }); + }, + + setOptionStatus: function () { + var that = this; + + that.noScroll = false; + + if (that.selectpicker.view.visibleElements && that.selectpicker.view.visibleElements.length) { + for (var i = 0; i < that.selectpicker.view.visibleElements.length; i++) { + var liData = that.selectpicker.current.data[i + that.selectpicker.view.position0], + option = liData.option; + + if (option) { + that.setDisabled( + liData.index, + liData.disabled + ); + + that.setSelected( + liData.index, + option.selected + ); + } + } + } + }, + + /** + * @param {number} index - the index of the option that is being changed + * @param {boolean} selected - true if the option is being selected, false if being deselected + */ + setSelected: function (index, selected) { + var li = this.selectpicker.main.elements[index], + liData = this.selectpicker.main.data[index], + activeIndexIsSet = this.activeIndex !== undefined, + thisIsActive = this.activeIndex === index, + prevActive, + a, + // if current option is already active + // OR + // if the current option is being selected, it's NOT multiple, and + // activeIndex is undefined: + // - when the menu is first being opened, OR + // - after a search has been performed, OR + // - when retainActive is false when selecting a new option (i.e. index of the newly selected option is not the same as the current activeIndex) + keepActive = thisIsActive || (selected && !this.multiple && !activeIndexIsSet); + + liData.selected = selected; + + a = li.firstChild; + + if (selected) { + this.selectedIndex = index; + } + + li.classList.toggle('selected', selected); + li.classList.toggle('active', keepActive); + + if (keepActive) { + this.selectpicker.view.currentActive = li; + this.activeIndex = index; + } + + if (a) { + a.classList.toggle('selected', selected); + a.classList.toggle('active', keepActive); + a.setAttribute('aria-selected', selected); + } + + if (!keepActive) { + if (!activeIndexIsSet && selected && this.prevActiveIndex !== undefined) { + prevActive = this.selectpicker.main.elements[this.prevActiveIndex]; + + prevActive.classList.remove('active'); + if (prevActive.firstChild) { + prevActive.firstChild.classList.remove('active'); + } + } + } + }, + + /** + * @param {number} index - the index of the option that is being disabled + * @param {boolean} disabled - true if the option is being disabled, false if being enabled + */ + setDisabled: function (index, disabled) { + var li = this.selectpicker.main.elements[index], + a; + + this.selectpicker.main.data[index].disabled = disabled; + + a = li.firstChild; + + li.classList.toggle(classNames.DISABLED, disabled); + + if (a) { + if (version.major === '4') a.classList.toggle(classNames.DISABLED, disabled); + + a.setAttribute('aria-disabled', disabled); + + if (disabled) { + a.setAttribute('tabindex', -1); + } else { + a.setAttribute('tabindex', 0); + } + } + }, + + isDisabled: function () { + return this.$element[0].disabled; + }, + + checkDisabled: function () { + var that = this; + + if (this.isDisabled()) { + this.$newElement[0].classList.add(classNames.DISABLED); + this.$button.addClass(classNames.DISABLED).attr('tabindex', -1).attr('aria-disabled', true); + } else { + if (this.$button[0].classList.contains(classNames.DISABLED)) { + this.$newElement[0].classList.remove(classNames.DISABLED); + this.$button.removeClass(classNames.DISABLED).attr('aria-disabled', false); + } + + if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) { + this.$button.removeAttr('tabindex'); + } + } + + this.$button.on('click', function () { + return !that.isDisabled(); + }); + }, + + togglePlaceholder: function () { + // much faster than calling $.val() + var element = this.$element[0], + selectedIndex = element.selectedIndex, + nothingSelected = selectedIndex === -1; + + if (!nothingSelected && !element.options[selectedIndex].value) nothingSelected = true; + + this.$button.toggleClass('bs-placeholder', nothingSelected); + }, + + tabIndex: function () { + if (this.$element.data('tabindex') !== this.$element.attr('tabindex') && + (this.$element.attr('tabindex') !== -98 && this.$element.attr('tabindex') !== '-98')) { + this.$element.data('tabindex', this.$element.attr('tabindex')); + this.$button.attr('tabindex', this.$element.data('tabindex')); + } + + this.$element.attr('tabindex', -98); + }, + + clickListener: function () { + var that = this, + $document = $(document); + + $document.data('spaceSelect', false); + + this.$button.on('keyup', function (e) { + if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) { + e.preventDefault(); + $document.data('spaceSelect', false); + } + }); + + this.$newElement.on('show.bs.dropdown', function () { + if (version.major > 3 && !that.dropdown) { + that.dropdown = that.$button.data('bs.dropdown'); + that.dropdown._menu = that.$menu[0]; + } + }); + + this.$button.on('click.bs.dropdown.data-api', function () { + if (!that.$newElement.hasClass(classNames.SHOW)) { + that.setSize(); + } + }); + + function setFocus () { + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } else { + that.$menuInner.trigger('focus'); + } + } + + function checkPopperExists () { + if (that.dropdown && that.dropdown._popper && that.dropdown._popper.state.isCreated) { + setFocus(); + } else { + requestAnimationFrame(checkPopperExists); + } + } + + this.$element.on('shown' + EVENT_KEY, function () { + if (that.$menuInner[0].scrollTop !== that.selectpicker.view.scrollTop) { + that.$menuInner[0].scrollTop = that.selectpicker.view.scrollTop; + } + + if (version.major > 3) { + requestAnimationFrame(checkPopperExists); + } else { + setFocus(); + } + }); + + this.$menuInner.on('click', 'li a', function (e, retainActive) { + var $this = $(this), + position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0, + clickedData = that.selectpicker.current.data[$this.parent().index() + position0], + clickedIndex = clickedData.index, + prevValue = getSelectValues(that.$element[0]), + prevIndex = that.$element.prop('selectedIndex'), + triggerChange = true; + + // Don't close on multi choice menu + if (that.multiple && that.options.maxOptions !== 1) { + e.stopPropagation(); + } + + e.preventDefault(); + + // Don't run if the select is disabled + if (!that.isDisabled() && !$this.parent().hasClass(classNames.DISABLED)) { + var $options = that.$element.find('option'), + option = clickedData.option, + $option = $(option), + state = option.selected, + $optgroup = $option.parent('optgroup'), + $optgroupOptions = $optgroup.find('option'), + maxOptions = that.options.maxOptions, + maxOptionsGrp = $optgroup.data('maxOptions') || false; + + if (clickedIndex === that.activeIndex) retainActive = true; + + if (!retainActive) { + that.prevActiveIndex = that.activeIndex; + that.activeIndex = undefined; + } + + if (!that.multiple) { // Deselect all others if not multi select box + $options.prop('selected', false); + option.selected = true; + that.setSelected(clickedIndex, true); + } else { // Toggle the one we have chosen if we are multi select. + option.selected = !state; + + that.setSelected(clickedIndex, !state); + $this.trigger('blur'); + + if (maxOptions !== false || maxOptionsGrp !== false) { + var maxReached = maxOptions < $options.filter(':selected').length, + maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length; + + if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) { + if (maxOptions && maxOptions == 1) { + $options.prop('selected', false); + $option.prop('selected', true); + + for (var i = 0; i < $options.length; i++) { + that.setSelected(i, false); + } + + that.setSelected(clickedIndex, true); + } else if (maxOptionsGrp && maxOptionsGrp == 1) { + $optgroup.find('option:selected').prop('selected', false); + $option.prop('selected', true); + + for (var i = 0; i < $optgroupOptions.length; i++) { + var option = $optgroupOptions[i]; + that.setSelected($options.index(option), false); + } + + that.setSelected(clickedIndex, true); + } else { + var maxOptionsText = typeof that.options.maxOptionsText === 'string' ? [that.options.maxOptionsText, that.options.maxOptionsText] : that.options.maxOptionsText, + maxOptionsArr = typeof maxOptionsText === 'function' ? maxOptionsText(maxOptions, maxOptionsGrp) : maxOptionsText, + maxTxt = maxOptionsArr[0].replace('{n}', maxOptions), + maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp), + $notify = $('
    '); + // If {var} is set in array, replace it + /** @deprecated */ + if (maxOptionsArr[2]) { + maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]); + maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]); + } + + $option.prop('selected', false); + + that.$menu.append($notify); + + if (maxOptions && maxReached) { + $notify.append($('
    ' + maxTxt + '
    ')); + triggerChange = false; + that.$element.trigger('maxReached' + EVENT_KEY); + } + + if (maxOptionsGrp && maxReachedGrp) { + $notify.append($('
    ' + maxTxtGrp + '
    ')); + triggerChange = false; + that.$element.trigger('maxReachedGrp' + EVENT_KEY); + } + + setTimeout(function () { + that.setSelected(clickedIndex, false); + }, 10); + + $notify.delay(750).fadeOut(300, function () { + $(this).remove(); + }); + } + } + } + } + + if (!that.multiple || (that.multiple && that.options.maxOptions === 1)) { + that.$button.trigger('focus'); + } else if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } + + // Trigger select 'change' + if (triggerChange) { + if ((prevValue != getSelectValues(that.$element[0]) && that.multiple) || (prevIndex != that.$element.prop('selectedIndex') && !that.multiple)) { + // $option.prop('selected') is current option state (selected/unselected). prevValue is the value of the select prior to being changed. + changedArguments = [option.index, $option.prop('selected'), prevValue]; + that.$element + .triggerNative('change'); + } + } + } + }); + + this.$menu.on('click', 'li.' + classNames.DISABLED + ' a, .' + classNames.POPOVERHEADER + ', .' + classNames.POPOVERHEADER + ' :not(.close)', function (e) { + if (e.currentTarget == this) { + e.preventDefault(); + e.stopPropagation(); + if (that.options.liveSearch && !$(e.target).hasClass('close')) { + that.$searchbox.trigger('focus'); + } else { + that.$button.trigger('focus'); + } + } + }); + + this.$menuInner.on('click', '.divider, .dropdown-header', function (e) { + e.preventDefault(); + e.stopPropagation(); + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } else { + that.$button.trigger('focus'); + } + }); + + this.$menu.on('click', '.' + classNames.POPOVERHEADER + ' .close', function () { + that.$button.trigger('click'); + }); + + this.$searchbox.on('click', function (e) { + e.stopPropagation(); + }); + + this.$menu.on('click', '.actions-btn', function (e) { + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } else { + that.$button.trigger('focus'); + } + + e.preventDefault(); + e.stopPropagation(); + + if ($(this).hasClass('bs-select-all')) { + that.selectAll(); + } else { + that.deselectAll(); + } + }); + + this.$element + .on('change' + EVENT_KEY, function () { + that.render(); + that.$element.trigger('changed' + EVENT_KEY, changedArguments); + changedArguments = null; + }) + .on('focus' + EVENT_KEY, function () { + if (!that.options.mobile) that.$button.trigger('focus'); + }); + }, + + liveSearchListener: function () { + var that = this, + noResults = document.createElement('li'); + + this.$button.on('click.bs.dropdown.data-api', function () { + if (!!that.$searchbox.val()) { + that.$searchbox.val(''); + } + }); + + this.$searchbox.on('click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api', function (e) { + e.stopPropagation(); + }); + + this.$searchbox.on('input propertychange', function () { + var searchValue = that.$searchbox.val(); + + that.selectpicker.search.elements = []; + that.selectpicker.search.data = []; + + if (searchValue) { + var i, + searchMatch = [], + q = searchValue.toUpperCase(), + cache = {}, + cacheArr = [], + searchStyle = that._searchStyle(), + normalizeSearch = that.options.liveSearchNormalize; + + if (normalizeSearch) q = normalizeToBase(q); + + that._$lisSelected = that.$menuInner.find('.selected'); + + for (var i = 0; i < that.selectpicker.main.data.length; i++) { + var li = that.selectpicker.main.data[i]; + + if (!cache[i]) { + cache[i] = stringSearch(li, q, searchStyle, normalizeSearch); + } + + if (cache[i] && li.headerIndex !== undefined && cacheArr.indexOf(li.headerIndex) === -1) { + if (li.headerIndex > 0) { + cache[li.headerIndex - 1] = true; + cacheArr.push(li.headerIndex - 1); + } + + cache[li.headerIndex] = true; + cacheArr.push(li.headerIndex); + + cache[li.lastIndex + 1] = true; + } + + if (cache[i] && li.type !== 'optgroup-label') cacheArr.push(i); + } + + for (var i = 0, cacheLen = cacheArr.length; i < cacheLen; i++) { + var index = cacheArr[i], + prevIndex = cacheArr[i - 1], + li = that.selectpicker.main.data[index], + liPrev = that.selectpicker.main.data[prevIndex]; + + if (li.type !== 'divider' || (li.type === 'divider' && liPrev && liPrev.type !== 'divider' && cacheLen - 1 !== i)) { + that.selectpicker.search.data.push(li); + searchMatch.push(that.selectpicker.main.elements[index]); + } + } + + that.activeIndex = undefined; + that.noScroll = true; + that.$menuInner.scrollTop(0); + that.selectpicker.search.elements = searchMatch; + that.createView(true); + + if (!searchMatch.length) { + noResults.className = 'no-results'; + noResults.innerHTML = that.options.noneResultsText.replace('{0}', '"' + htmlEscape(searchValue) + '"'); + that.$menuInner[0].firstChild.appendChild(noResults); + } + } else { + that.$menuInner.scrollTop(0); + that.createView(false); + } + }); + }, + + _searchStyle: function () { + return this.options.liveSearchStyle || 'contains'; + }, + + val: function (value) { + if (typeof value !== 'undefined') { + var prevValue = getSelectValues(this.$element[0]); + + changedArguments = [null, null, prevValue]; + + this.$element + .val(value) + .trigger('changed' + EVENT_KEY, changedArguments); + + this.render(); + + changedArguments = null; + + return this.$element; + } else { + return this.$element.val(); + } + }, + + changeAll: function (status) { + if (!this.multiple) return; + if (typeof status === 'undefined') status = true; + + var element = this.$element[0], + previousSelected = 0, + currentSelected = 0, + prevValue = getSelectValues(element); + + element.classList.add('bs-select-hidden'); + + for (var i = 0, len = this.selectpicker.current.elements.length; i < len; i++) { + var liData = this.selectpicker.current.data[i], + option = liData.option; + + if (option && !liData.disabled && liData.type !== 'divider') { + if (liData.selected) previousSelected++; + option.selected = status; + if (status) currentSelected++; + } + } + + element.classList.remove('bs-select-hidden'); + + if (previousSelected === currentSelected) return; + + this.setOptionStatus(); + + this.togglePlaceholder(); + + changedArguments = [null, null, prevValue]; + + this.$element + .triggerNative('change'); + }, + + selectAll: function () { + return this.changeAll(true); + }, + + deselectAll: function () { + return this.changeAll(false); + }, + + toggle: function (e) { + e = e || window.event; + + if (e) e.stopPropagation(); + + this.$button.trigger('click.bs.dropdown.data-api'); + }, + + keydown: function (e) { + var $this = $(this), + isToggle = $this.hasClass('dropdown-toggle'), + $parent = isToggle ? $this.closest('.dropdown') : $this.closest(Selector.MENU), + that = $parent.data('this'), + $items = that.findLis(), + index, + isActive, + liActive, + activeLi, + offset, + updateScroll = false, + downOnTab = e.which === keyCodes.TAB && !isToggle && !that.options.selectOnTab, + isArrowKey = REGEXP_ARROW.test(e.which) || downOnTab, + scrollTop = that.$menuInner[0].scrollTop, + isVirtual = that.isVirtual(), + position0 = isVirtual === true ? that.selectpicker.view.position0 : 0; + + isActive = that.$newElement.hasClass(classNames.SHOW); + + if ( + !isActive && + ( + isArrowKey || + (e.which >= 48 && e.which <= 57) || + (e.which >= 96 && e.which <= 105) || + (e.which >= 65 && e.which <= 90) + ) + ) { + that.$button.trigger('click.bs.dropdown.data-api'); + + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + return; + } + } + + if (e.which === keyCodes.ESCAPE && isActive) { + e.preventDefault(); + that.$button.trigger('click.bs.dropdown.data-api').trigger('focus'); + } + + if (isArrowKey) { // if up or down + if (!$items.length) return; + + // $items.index/.filter is too slow with a large list and no virtual scroll + index = isVirtual === true ? $items.index($items.filter('.active')) : that.activeIndex; + + if (index === undefined) index = -1; + + if (index !== -1) { + liActive = that.selectpicker.current.elements[index + position0]; + liActive.classList.remove('active'); + if (liActive.firstChild) liActive.firstChild.classList.remove('active'); + } + + if (e.which === keyCodes.ARROW_UP) { // up + if (index !== -1) index--; + if (index + position0 < 0) index += $items.length; + + if (!that.selectpicker.view.canHighlight[index + position0]) { + index = that.selectpicker.view.canHighlight.slice(0, index + position0).lastIndexOf(true) - position0; + if (index === -1) index = $items.length - 1; + } + } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down + index++; + if (index + position0 >= that.selectpicker.view.canHighlight.length) index = 0; + + if (!that.selectpicker.view.canHighlight[index + position0]) { + index = index + 1 + that.selectpicker.view.canHighlight.slice(index + position0 + 1).indexOf(true); + } + } + + e.preventDefault(); + + var liActiveIndex = position0 + index; + + if (e.which === keyCodes.ARROW_UP) { // up + // scroll to bottom and highlight last option + if (position0 === 0 && index === $items.length - 1) { + that.$menuInner[0].scrollTop = that.$menuInner[0].scrollHeight; + + liActiveIndex = that.selectpicker.current.elements.length - 1; + } else { + activeLi = that.selectpicker.current.data[liActiveIndex]; + offset = activeLi.position - activeLi.height; + + updateScroll = offset < scrollTop; + } + } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down + // scroll to top and highlight first option + if (index === 0) { + that.$menuInner[0].scrollTop = 0; + + liActiveIndex = 0; + } else { + activeLi = that.selectpicker.current.data[liActiveIndex]; + offset = activeLi.position - that.sizeInfo.menuInnerHeight; + + updateScroll = offset > scrollTop; + } + } + + liActive = that.selectpicker.current.elements[liActiveIndex]; + + if (liActive) { + liActive.classList.add('active'); + if (liActive.firstChild) liActive.firstChild.classList.add('active'); + } + + that.activeIndex = that.selectpicker.current.data[liActiveIndex].index; + + that.selectpicker.view.currentActive = liActive; + + if (updateScroll) that.$menuInner[0].scrollTop = offset; + + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } else { + $this.trigger('focus'); + } + } else if ( + (!$this.is('input') && !REGEXP_TAB_OR_ESCAPE.test(e.which)) || + (e.which === keyCodes.SPACE && that.selectpicker.keydown.keyHistory) + ) { + var searchMatch, + matches = [], + keyHistory; + + e.preventDefault(); + + that.selectpicker.keydown.keyHistory += keyCodeMap[e.which]; + + if (that.selectpicker.keydown.resetKeyHistory.cancel) clearTimeout(that.selectpicker.keydown.resetKeyHistory.cancel); + that.selectpicker.keydown.resetKeyHistory.cancel = that.selectpicker.keydown.resetKeyHistory.start(); + + keyHistory = that.selectpicker.keydown.keyHistory; + + // if all letters are the same, set keyHistory to just the first character when searching + if (/^(.)\1+$/.test(keyHistory)) { + keyHistory = keyHistory.charAt(0); + } + + // find matches + for (var i = 0; i < that.selectpicker.current.data.length; i++) { + var li = that.selectpicker.current.data[i], + hasMatch; + + hasMatch = stringSearch(li, keyHistory, 'startsWith', true); + + if (hasMatch && that.selectpicker.view.canHighlight[i]) { + matches.push(li.index); + } + } + + if (matches.length) { + var matchIndex = 0; + + $items.removeClass('active').find('a').removeClass('active'); + + // either only one key has been pressed or they are all the same key + if (keyHistory.length === 1) { + matchIndex = matches.indexOf(that.activeIndex); + + if (matchIndex === -1 || matchIndex === matches.length - 1) { + matchIndex = 0; + } else { + matchIndex++; + } + } + + searchMatch = matches[matchIndex]; + + activeLi = that.selectpicker.main.data[searchMatch]; + + if (scrollTop - activeLi.position > 0) { + offset = activeLi.position - activeLi.height; + updateScroll = true; + } else { + offset = activeLi.position - that.sizeInfo.menuInnerHeight; + // if the option is already visible at the current scroll position, just keep it the same + updateScroll = activeLi.position > scrollTop + that.sizeInfo.menuInnerHeight; + } + + liActive = that.selectpicker.main.elements[searchMatch]; + liActive.classList.add('active'); + if (liActive.firstChild) liActive.firstChild.classList.add('active'); + that.activeIndex = matches[matchIndex]; + + liActive.firstChild.focus(); + + if (updateScroll) that.$menuInner[0].scrollTop = offset; + + $this.trigger('focus'); + } + } + + // Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu. + if ( + isActive && + ( + (e.which === keyCodes.SPACE && !that.selectpicker.keydown.keyHistory) || + e.which === keyCodes.ENTER || + (e.which === keyCodes.TAB && that.options.selectOnTab) + ) + ) { + if (e.which !== keyCodes.SPACE) e.preventDefault(); + + if (!that.options.liveSearch || e.which !== keyCodes.SPACE) { + that.$menuInner.find('.active a').trigger('click', true); // retain active class + $this.trigger('focus'); + + if (!that.options.liveSearch) { + // Prevent screen from scrolling if the user hits the spacebar + e.preventDefault(); + // Fixes spacebar selection of dropdown items in FF & IE + $(document).data('spaceSelect', true); + } + } + } + }, + + mobile: function () { + this.$element[0].classList.add('mobile-device'); + }, + + refresh: function () { + // update options if data attributes have been changed + var config = $.extend({}, this.options, this.$element.data()); + this.options = config; + + this.checkDisabled(); + this.setStyle(); + this.render(); + this.createLi(); + this.setWidth(); + + this.setSize(true); + + this.$element.trigger('refreshed' + EVENT_KEY); + }, + + hide: function () { + this.$newElement.hide(); + }, + + show: function () { + this.$newElement.show(); + }, + + remove: function () { + this.$newElement.remove(); + this.$element.remove(); + }, + + destroy: function () { + this.$newElement.before(this.$element).remove(); + + if (this.$bsContainer) { + this.$bsContainer.remove(); + } else { + this.$menu.remove(); + } + + this.$element + .off(EVENT_KEY) + .removeData('selectpicker') + .removeClass('bs-select-hidden selectpicker'); + + $(window).off(EVENT_KEY + '.' + this.selectId); + } + }; + + // SELECTPICKER PLUGIN DEFINITION + // ============================== + function Plugin (option) { + // get the args of the outer function.. + var args = arguments; + // The arguments of the function are explicitly re-defined from the argument list, because the shift causes them + // to get lost/corrupted in android 2.3 and IE9 #715 #775 + var _option = option; + + [].shift.apply(args); + + // if the version was not set successfully + if (!version.success) { + // try to retreive it again + try { + version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.'); + } catch (err) { + // fall back to use BootstrapVersion if set + if (Selectpicker.BootstrapVersion) { + version.full = Selectpicker.BootstrapVersion.split(' ')[0].split('.'); + } else { + version.full = [version.major, '0', '0']; + + console.warn( + 'There was an issue retrieving Bootstrap\'s version. ' + + 'Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. ' + + 'If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.', + err + ); + } + } + + version.major = version.full[0]; + version.success = true; + } + + if (version.major === '4') { + // some defaults need to be changed if using Bootstrap 4 + // check to see if they have already been manually changed before forcing them to update + var toUpdate = []; + + if (Selectpicker.DEFAULTS.style === classNames.BUTTONCLASS) toUpdate.push({ name: 'style', className: 'BUTTONCLASS' }); + if (Selectpicker.DEFAULTS.iconBase === classNames.ICONBASE) toUpdate.push({ name: 'iconBase', className: 'ICONBASE' }); + if (Selectpicker.DEFAULTS.tickIcon === classNames.TICKICON) toUpdate.push({ name: 'tickIcon', className: 'TICKICON' }); + + classNames.DIVIDER = 'dropdown-divider'; + classNames.SHOW = 'show'; + classNames.BUTTONCLASS = 'btn-light'; + classNames.POPOVERHEADER = 'popover-header'; + classNames.ICONBASE = ''; + classNames.TICKICON = 'bs-ok-default'; + + for (var i = 0; i < toUpdate.length; i++) { + var option = toUpdate[i]; + Selectpicker.DEFAULTS[option.name] = classNames[option.className]; + } + } + + var value; + var chain = this.each(function () { + var $this = $(this); + if ($this.is('select')) { + var data = $this.data('selectpicker'), + options = typeof _option == 'object' && _option; + + if (!data) { + var dataAttributes = $this.data(); + + for (var dataAttr in dataAttributes) { + if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) { + delete dataAttributes[dataAttr]; + } + } + + var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, dataAttributes, options); + config.template = $.extend({}, Selectpicker.DEFAULTS.template, ($.fn.selectpicker.defaults ? $.fn.selectpicker.defaults.template : {}), dataAttributes.template, options.template); + $this.data('selectpicker', (data = new Selectpicker(this, config))); + } else if (options) { + for (var i in options) { + if (options.hasOwnProperty(i)) { + data.options[i] = options[i]; + } + } + } + + if (typeof _option == 'string') { + if (data[_option] instanceof Function) { + value = data[_option].apply(data, args); + } else { + value = data.options[_option]; + } + } + } + }); + + if (typeof value !== 'undefined') { + // noinspection JSUnusedAssignment + return value; + } else { + return chain; + } + } + + var old = $.fn.selectpicker; + $.fn.selectpicker = Plugin; + $.fn.selectpicker.Constructor = Selectpicker; + + // SELECTPICKER NO CONFLICT + // ======================== + $.fn.selectpicker.noConflict = function () { + $.fn.selectpicker = old; + return this; + }; + + $(document) + .off('keydown.bs.dropdown.data-api') + .on('keydown' + EVENT_KEY, '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', Selectpicker.prototype.keydown) + .on('focusin.modal', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', function (e) { + e.stopPropagation(); + }); + + // SELECTPICKER DATA-API + // ===================== + $(window).on('load' + EVENT_KEY + '.data-api', function () { + $('.selectpicker').each(function () { + var $selectpicker = $(this); + Plugin.call($selectpicker, $selectpicker.data()); + }) + }); +})(jQuery); + + +})); +//# sourceMappingURL=bootstrap-select.js.map \ No newline at end of file diff --git a/web/resource/js/lib/bootstrap.min.js b/web/resource/js/lib/bootstrap.min.js new file mode 100644 index 0000000..07cf295 --- /dev/null +++ b/web/resource/js/lib/bootstrap.min.js @@ -0,0 +1,7 @@ +/*! + * Bootstrap v3.3.7 (http://getbootstrap.com) + * Copyright 2011-2017 Twitter, Inc. + * Licensed under the MIT license + */ +if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1||b[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){if(a(b.target).is(this))return b.handleObj.handler.apply(this,arguments)}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.7",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a("#"===f?[]:f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.7",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c).prop(c,!0)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c).prop(c,!1))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target).closest(".btn");b.call(d,"toggle"),a(c.target).is('input[type="radio"], input[type="checkbox"]')||(c.preventDefault(),d.is("input,button")?d.trigger("focus"):d.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.7",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(a>this.$items.length-1||a<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.7",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.7",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&jdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth
    ',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);if(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),!c.isInStateTrue())return clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-mo.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null,a.$element=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;!e&&/destroy|hide/.test(b)||(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.7",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.7",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.7",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return e=a-d&&"bottom"},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); \ No newline at end of file diff --git a/web/resource/js/lib/bootstrapValidator.min.js b/web/resource/js/lib/bootstrapValidator.min.js new file mode 100644 index 0000000..88e6077 --- /dev/null +++ b/web/resource/js/lib/bootstrapValidator.min.js @@ -0,0 +1,12 @@ +/*! + * BootstrapValidator (http://bootstrapvalidator.com) + * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3 + * + * @version v0.5.1-dev, built on 2014-07-23 6:05:15 AM + * @author https://twitter.com/nghuuphuoc + * @copyright (c) 2013 - 2014 Nguyen Huu Phuoc + * @license MIT + */ +!function(a){var b=function(b,c){this.$form=a(b),this.options=a.extend({},a.fn.bootstrapValidator.DEFAULT_OPTIONS,c),this.$invalidFields=a([]),this.$submitButton=null,this.STATUS_NOT_VALIDATED="NOT_VALIDATED",this.STATUS_VALIDATING="VALIDATING",this.STATUS_INVALID="INVALID",this.STATUS_VALID="VALID";var d=function(){for(var a=3,b=document.createElement("div"),c=b.all||[];b.innerHTML="",c[0];);return a>4?a:!a}(),e=document.createElement("div");this._changeEvent=9!==d&&"oninput"in e?"input":"keyup",this._submitIfValid=null,this._cacheFields={},this._init()};b.prototype={constructor:b,_init:function(){var b=this,c={excluded:this.$form.attr("data-bv-excluded"),trigger:this.$form.attr("data-bv-trigger"),message:this.$form.attr("data-bv-message"),container:this.$form.attr("data-bv-container"),group:this.$form.attr("data-bv-group"),submitButtons:this.$form.attr("data-bv-submitbuttons"),threshold:this.$form.attr("data-bv-threshold"),live:this.$form.attr("data-bv-live"),onSuccess:this.$form.attr("data-bv-onsuccess"),onError:this.$form.attr("data-bv-onerror"),fields:{},feedbackIcons:{valid:this.$form.attr("data-bv-feedbackicons-valid"),invalid:this.$form.attr("data-bv-feedbackicons-invalid"),validating:this.$form.attr("data-bv-feedbackicons-validating")}};this.$form.attr("novalidate","novalidate").addClass(this.options.elementClass).on("submit.bv",function(a){a.preventDefault(),b.validate()}).on("click.bv",this.options.submitButtons,function(){b.$submitButton=a(this),b._submitIfValid=!0}).find("[name], [data-bv-field]").each(function(){var d=a(this),e=d.attr("name")||d.attr("data-bv-field"),f=b._parseOptions(d);f&&(d.attr("data-bv-field",e),c.fields[e]=a.extend({},f,c.fields[e]))}),this.options=a.extend(!0,this.options,c);for(var d in this.options.fields)this._initField(d);this.$form.trigger(a.Event("init.form.bv"),{bv:this,options:this.options}),this.options.onSuccess&&this.$form.on("success.form.bv",function(c){a.fn.bootstrapValidator.helpers.call(b.options.onSuccess,[c])}),this.options.onError&&this.$form.on("error.form.bv",function(c){a.fn.bootstrapValidator.helpers.call(b.options.onError,[c])})},_parseOptions:function(b){var c,d,e,f,g,h,i,j=b.attr("name")||b.attr("data-bv-field"),k={};for(d in a.fn.bootstrapValidator.validators)if(c=a.fn.bootstrapValidator.validators[d],e=b.attr("data-bv-"+d.toLowerCase())+"",i="function"==typeof c.enableByHtml5?c.enableByHtml5(b):null,i&&"false"!==e||i!==!0&&(""===e||"true"===e)){c.html5Attributes=a.extend({},{message:"message",onerror:"onError",onsuccess:"onSuccess"},c.html5Attributes),k[d]=a.extend({},i===!0?{}:i,k[d]);for(h in c.html5Attributes)f=c.html5Attributes[h],g=b.attr("data-bv-"+d.toLowerCase()+"-"+h),g&&("true"===g?g=!0:"false"===g&&(g=!1),k[d][f]=g)}var l={excluded:b.attr("data-bv-excluded"),feedbackIcons:b.attr("data-bv-feedbackicons"),trigger:b.attr("data-bv-trigger"),message:b.attr("data-bv-message"),container:b.attr("data-bv-container"),group:b.attr("data-bv-group"),selector:b.attr("data-bv-selector"),threshold:b.attr("data-bv-threshold"),onStatus:b.attr("data-bv-onstatus"),onSuccess:b.attr("data-bv-onsuccess"),onError:b.attr("data-bv-onerror"),validators:k},m=a.isEmptyObject(l),n=a.isEmptyObject(k);return!n||!m&&this.options.fields&&this.options.fields[j]?(l.validators=k,l):null},_initField:function(b){var c=a([]);switch(typeof b){case"object":c=b,b=b.attr("data-bv-field");break;case"string":c=this.getFieldElements(b),c.attr("data-bv-field",b)}if(null!==this.options.fields[b]&&null!==this.options.fields[b].validators){if(0===c.length)return void delete this.options.fields[b];var d;for(d in this.options.fields[b].validators)a.fn.bootstrapValidator.validators[d]||delete this.options.fields[b].validators[d];null===this.options.fields[b].enabled&&(this.options.fields[b].enabled=!0);for(var e=this,f=c.length,g=c.attr("type"),h=1===f||"radio"===g||"checkbox"===g,i="radio"===g||"checkbox"===g||"file"===g||"SELECT"===c.eq(0).get(0).tagName?"change":this._changeEvent,j=(this.options.fields[b].trigger||this.options.trigger||i).split(" "),k=a.map(j,function(a){return a+".update.bv"}).join(" "),l=0;f>l;l++){var m=c.eq(l),n=this.options.fields[b].group||this.options.group,o=m.parents(n),p=this.options.fields[b].container||this.options.container,q=p&&"tooltip"!==p&&"popover"!==p?a(p):this._getMessageContainer(m,n);p&&"tooltip"!==p&&"popover"!==p&&q.addClass("has-error"),q.find('.help-block[data-bv-validator][data-bv-for="'+b+'"]').remove(),o.find('i[data-bv-icon-for="'+b+'"]').remove(),m.off(k).on(k,function(){e.updateStatus(a(this),e.STATUS_NOT_VALIDATED)}),m.data("bv.messages",q);for(d in this.options.fields[b].validators)m.data("bv.result."+d,this.STATUS_NOT_VALIDATED),h&&l!==f-1||a("").css("display","none").addClass("help-block").attr("data-bv-validator",d).attr("data-bv-for",b).attr("data-bv-result",this.STATUS_NOT_VALIDATED).html(this._getMessage(b,d)).appendTo(q),this.options.fields[b].validators[d].onSuccess&&m.on("success.validator.bv",function(c,f){a.fn.bootstrapValidator.helpers.call(e.options.fields[b].validators[d].onSuccess,[c,f])}),this.options.fields[b].validators[d].onError&&m.on("error.validator.bv",function(c,f){a.fn.bootstrapValidator.helpers.call(e.options.fields[b].validators[d].onError,[c,f])});if(this.options.fields[b].feedbackIcons!==!1&&"false"!==this.options.fields[b].feedbackIcons&&this.options.feedbackIcons&&this.options.feedbackIcons.validating&&this.options.feedbackIcons.invalid&&this.options.feedbackIcons.valid&&(!h||l===f-1)){o.removeClass("has-success").removeClass("has-error").addClass("has-feedback");var r=a("").css("display","none").addClass("form-control-feedback").attr("data-bv-icon-for",b).insertAfter("checkbox"===g||"radio"===g?m.parent():m);0===o.find("label").length&&r.css("top",0),0!==o.find(".input-group").length&&r.css({top:0,"z-index":100}).insertAfter(o.find(".input-group").eq(0))}}switch(this.options.fields[b].onSuccess&&c.on("success.field.bv",function(c,d){a.fn.bootstrapValidator.helpers.call(e.options.fields[b].onSuccess,[c,d])}),this.options.fields[b].onError&&c.on("error.field.bv",function(c,d){a.fn.bootstrapValidator.helpers.call(e.options.fields[b].onError,[c,d])}),this.options.fields[b].onStatus&&c.on("status.field.bv",function(c,d){a.fn.bootstrapValidator.helpers.call(e.options.fields[b].onStatus,[c,d])}),k=a.map(j,function(a){return a+".live.bv"}).join(" "),this.options.live){case"submitted":break;case"disabled":c.off(k);break;case"enabled":default:c.off(k).on(k,function(){e._exceedThreshold(a(this))&&e.validateField(a(this))})}c.trigger(a.Event("init.field.bv"),{bv:this,field:b,element:c})}},_getMessage:function(b,c){if(!(this.options.fields[b]&&a.fn.bootstrapValidator.validators[c]&&this.options.fields[b].validators&&this.options.fields[b].validators[c]))return"";var d=this.options.fields[b].validators[c];switch(!0){case!!d.message:return d.message;case!!this.options.fields[b].message:return this.options.fields[b].message;case!!a.fn.bootstrapValidator.i18n[c]:return a.fn.bootstrapValidator.i18n[c]["default"];default:return this.options.message}},_getMessageContainer:function(a,b){var c=a.parent();if(c.is(b))return c;var d=c.attr("class");if(!d)return this._getMessageContainer(c,b);d=d.split(" ");for(var e=d.length,f=0;e>f;f++)if(/^col-(xs|sm|md|lg)-\d+$/.test(d[f])||/^col-(xs|sm|md|lg)-offset-\d+$/.test(d[f]))return c;return this._getMessageContainer(c,b)},_submit:function(){var b=this.isValid(),c=b?"success.form.bv":"error.form.bv",d=a.Event(c);this.$form.trigger(d),this.$submitButton&&(b?this._onSuccess(d):this._onError(d))},_isExcluded:function(b){var c=b.attr("data-bv-excluded"),d=b.attr("data-bv-field")||b.attr("name");switch(!0){case!!d&&this.options.fields&&this.options.fields[d]&&("true"===this.options.fields[d].excluded||this.options.fields[d].excluded===!0):case"true"===c:case""===c:return!0;case!!d&&this.options.fields&&this.options.fields[d]&&("false"===this.options.fields[d].excluded||this.options.fields[d].excluded===!1):case"false"===c:return!1;default:if(this.options.excluded){"string"==typeof this.options.excluded&&(this.options.excluded=a.map(this.options.excluded.split(","),function(b){return a.trim(b)}));for(var e=this.options.excluded.length,f=0;e>f;f++)if("string"==typeof this.options.excluded[f]&&b.is(this.options.excluded[f])||"function"==typeof this.options.excluded[f]&&this.options.excluded[f].call(this,b,this)===!0)return!0}return!1}},_exceedThreshold:function(b){var c=b.attr("data-bv-field"),d=this.options.fields[c].threshold||this.options.threshold;if(!d)return!0;var e=-1!==a.inArray(b.attr("type"),["button","checkbox","file","hidden","image","radio","reset","submit"]);return e||b.val().length>=d},_onError:function(b){if(!b.isDefaultPrevented()){if("submitted"===this.options.live){this.options.live="enabled";var c=this;for(var d in this.options.fields)!function(b){var e=c.getFieldElements(b);if(e.length){var f=a(e[0]).attr("type"),g="radio"===f||"checkbox"===f||"file"===f||"SELECT"===a(e[0]).get(0).tagName?"change":c._changeEvent,h=c.options.fields[d].trigger||c.options.trigger||g,i=a.map(h.split(" "),function(a){return a+".live.bv"}).join(" ");e.off(i).on(i,function(){c._exceedThreshold(a(this))&&c.validateField(a(this))})}}(d)}var e=this.$invalidFields.eq(0);if(e){var f,g=e.parents(".tab-pane");g&&(f=g.attr("id"))&&a('a[href="#'+f+'"][data-toggle="tab"]').tab("show"),e.focus()}}},_onSuccess:function(a){a.isDefaultPrevented()||this.disableSubmitButtons(!0).defaultSubmit()},_onFieldValidated:function(b,c){var d=b.attr("data-bv-field"),e=this.options.fields[d].validators,f={},g=0,h={bv:this,field:d,element:b,validator:c};if(c)switch(b.data("bv.result."+c)){case this.STATUS_INVALID:b.trigger(a.Event("error.validator.bv"),h);break;case this.STATUS_VALID:b.trigger(a.Event("success.validator.bv"),h)}f[this.STATUS_NOT_VALIDATED]=0,f[this.STATUS_VALIDATING]=0,f[this.STATUS_INVALID]=0,f[this.STATUS_VALID]=0;for(var i in e)if(e[i].enabled!==!1){g++;var j=b.data("bv.result."+i);j&&f[j]++}f[this.STATUS_VALID]===g?(this.$invalidFields=this.$invalidFields.not(b),b.trigger(a.Event("success.field.bv"),h)):0===f[this.STATUS_NOT_VALIDATED]&&0===f[this.STATUS_VALIDATING]&&f[this.STATUS_INVALID]>0&&(this.$invalidFields=this.$invalidFields.add(b),b.trigger(a.Event("error.field.bv"),h))},getFieldElements:function(b){return this._cacheFields[b]||(this._cacheFields[b]=this.options.fields[b]&&this.options.fields[b].selector?a(this.options.fields[b].selector):this.$form.find('[name="'+b+'"]')),this._cacheFields[b]},disableSubmitButtons:function(a){return a?"disabled"!==this.options.live&&this.$form.find(this.options.submitButtons).attr("disabled","disabled"):this.$form.find(this.options.submitButtons).removeAttr("disabled"),this},validate:function(){if(!this.options.fields)return this;this.disableSubmitButtons(!0);for(var a in this.options.fields)this.validateField(a);return this._submit(),this},validateField:function(b){var c=a([]);switch(typeof b){case"object":c=b,b=b.attr("data-bv-field");break;case"string":c=this.getFieldElements(b)}if(this.options.fields[b]&&this.options.fields[b].enabled===!1)return this;for(var d,e,f=this,g=c.attr("type"),h="radio"===g||"checkbox"===g?1:c.length,i="radio"===g||"checkbox"===g,j=this.options.fields[b].validators,k=0;h>k;k++){var l=c.eq(k);if(!this._isExcluded(l))for(d in j){l.data("bv.dfs."+d)&&l.data("bv.dfs."+d).reject();var m=l.data("bv.result."+d);m!==this.STATUS_VALID&&m!==this.STATUS_INVALID&&j[d].enabled!==!1?(l.data("bv.result."+d,this.STATUS_VALIDATING),e=a.fn.bootstrapValidator.validators[d].validate(this,l,j[d]),"object"==typeof e&&e.resolve?(this.updateStatus(i?b:l,this.STATUS_VALIDATING,d),l.data("bv.dfs."+d,e),e.done(function(a,b,c,d){a.removeData("bv.dfs."+b),d&&f.updateMessage(a,b,d),f.updateStatus(i?a.attr("data-bv-field"):a,c?f.STATUS_VALID:f.STATUS_INVALID,b),c&&f._submitIfValid===!0&&f._submit()})):"object"==typeof e&&void 0!==e.valid&&void 0!==e.message?(this.updateMessage(i?b:l,d,e.message),this.updateStatus(i?b:l,e.valid?this.STATUS_VALID:this.STATUS_INVALID,d)):"boolean"==typeof e&&this.updateStatus(i?b:l,e?this.STATUS_VALID:this.STATUS_INVALID,d)):this._onFieldValidated(l,d)}}return this},updateMessage:function(b,c,d){var e=a([]);switch(typeof b){case"object":e=b,b=b.attr("data-bv-field");break;case"string":e=this.getFieldElements(b)}e.each(function(){a(this).data("bv.messages").find('.help-block[data-bv-validator="'+c+'"][data-bv-for="'+b+'"]').html(d)})},updateStatus:function(b,c,d){var e=a([]);switch(typeof b){case"object":e=b,b=b.attr("data-bv-field");break;case"string":e=this.getFieldElements(b)}c===this.STATUS_NOT_VALIDATED&&(this._submitIfValid=!1);for(var f=this,g=e.attr("type"),h=this.options.fields[b].group||this.options.group,i="radio"===g||"checkbox"===g?1:e.length,j=0;i>j;j++){var k=e.eq(j);if(!this._isExcluded(k)){var l=k.parents(h),m=k.data("bv.messages"),n=m.find('.help-block[data-bv-validator][data-bv-for="'+b+'"]'),o=d?n.filter('[data-bv-validator="'+d+'"]'):n,p=l.find('.form-control-feedback[data-bv-icon-for="'+b+'"]'),q=this.options.fields[b].container||this.options.container,r=null;if(d)k.data("bv.result."+d,c);else for(var s in this.options.fields[b].validators)k.data("bv.result."+s,c);o.attr("data-bv-result",c);var t,u,v=k.parents(".tab-pane");switch(v&&(t=v.attr("id"))&&(u=a('a[href="#'+t+'"][data-toggle="tab"]').parent()),c){case this.STATUS_VALIDATING:r=null,this.disableSubmitButtons(!0),l.removeClass("has-success").removeClass("has-error"),p&&p.removeClass(this.options.feedbackIcons.valid).removeClass(this.options.feedbackIcons.invalid).addClass(this.options.feedbackIcons.validating).show(),u&&u.removeClass("bv-tab-success").removeClass("bv-tab-error");break;case this.STATUS_INVALID:r=!1,this.disableSubmitButtons(!0),l.removeClass("has-success").addClass("has-error"),p&&p.removeClass(this.options.feedbackIcons.valid).removeClass(this.options.feedbackIcons.validating).addClass(this.options.feedbackIcons.invalid).show(),u&&u.removeClass("bv-tab-success").addClass("bv-tab-error");break;case this.STATUS_VALID:r=0===n.filter('[data-bv-result="'+this.STATUS_NOT_VALIDATED+'"]').length?n.filter('[data-bv-result="'+this.STATUS_VALID+'"]').length===n.length:null,null!==r&&(this.disableSubmitButtons(this.$submitButton?!this.isValid():!r),p&&p.removeClass(this.options.feedbackIcons.invalid).removeClass(this.options.feedbackIcons.validating).removeClass(this.options.feedbackIcons.valid).addClass(r?this.options.feedbackIcons.valid:this.options.feedbackIcons.invalid).show()),l.removeClass("has-error has-success").addClass(this.isValidContainer(l)?"has-success":"has-error"),u&&u.removeClass("bv-tab-success").removeClass("bv-tab-error").addClass(this.isValidContainer(v)?"bv-tab-success":"bv-tab-error");break;case this.STATUS_NOT_VALIDATED:default:r=null,this.disableSubmitButtons(!1),l.removeClass("has-success").removeClass("has-error"),p&&p.removeClass(this.options.feedbackIcons.valid).removeClass(this.options.feedbackIcons.invalid).removeClass(this.options.feedbackIcons.validating).hide(),u&&u.removeClass("bv-tab-success").removeClass("bv-tab-error")}switch(!0){case p&&"tooltip"===q:r===!1?p.css("cursor","pointer").tooltip("destroy").tooltip({html:!0,placement:"top",title:n.filter('[data-bv-result="'+f.STATUS_INVALID+'"]').eq(0).html()}):p.css("cursor","").tooltip("destroy");break;case p&&"popover"===q:r===!1?p.css("cursor","pointer").popover("destroy").popover({content:n.filter('[data-bv-result="'+f.STATUS_INVALID+'"]').eq(0).html(),html:!0,placement:"top",trigger:"hover click"}):p.css("cursor","").popover("destroy");break;default:c===this.STATUS_INVALID?o.show():o.hide()}k.trigger(a.Event("status.field.bv"),{bv:this,field:b,element:k,status:c}),this._onFieldValidated(k,d)}}return this},isValid:function(){for(var a in this.options.fields)if(!this.isValidField(a))return!1;return!0},isValidField:function(b){var c=a([]);switch(typeof b){case"object":c=b,b=b.attr("data-bv-field");break;case"string":c=this.getFieldElements(b)}if(0===c.length||null===this.options.fields[b]||this.options.fields[b].enabled===!1)return!0;for(var d,e,f,g=c.attr("type"),h="radio"===g||"checkbox"===g?1:c.length,i=0;h>i;i++)if(d=c.eq(i),!this._isExcluded(d))for(e in this.options.fields[b].validators)if(this.options.fields[b].validators[e].enabled!==!1&&(f=d.data("bv.result."+e),f!==this.STATUS_VALID))return!1;return!0},isValidContainer:function(b){var c=this,d={},e="string"==typeof b?a(b):b;if(0===e.length)return!0;e.find("[data-bv-field]").each(function(){var b=a(this),e=b.attr("data-bv-field");c._isExcluded(b)||d[e]||(d[e]=b)});for(var f in d){var g=d[f];if(0!==g.data("bv.messages").find('.help-block[data-bv-validator][data-bv-for="'+f+'"]').filter(function(){var b=a(this).attr("data-bv-validator"),d=a(this).attr("data-bv-for");return c.options.fields[d].validators[b].enabled!==!1&&g.data("bv.result."+b)&&g.data("bv.result."+b)!==c.STATUS_VALID}).length)return!1}return!0},defaultSubmit:function(){this.$submitButton&&a("").attr("type","hidden").attr("data-bv-submit-hidden","").attr("name",this.$submitButton.attr("name")).val(this.$submitButton.val()).appendTo(this.$form),this.$form.off("submit.bv").submit()},getInvalidFields:function(){return this.$invalidFields},getSubmitButton:function(){return this.$submitButton},getMessages:function(b,c){var d=this,e=[],f=a([]);switch(!0){case b&&"object"==typeof b:f=b;break;case b&&"string"==typeof b:var g=this.getFieldElements(b);if(g.length>0){var h=g.attr("type");f="radio"===h||"checkbox"===h?g.eq(0):g}break;default:f=this.$invalidFields}var i=c?'[data-bv-validator="'+c+'"]':"";return f.each(function(){e=e.concat(a(this).data("bv.messages").find('.help-block[data-bv-for="'+a(this).attr("data-bv-field")+'"][data-bv-result="'+d.STATUS_INVALID+'"]'+i).map(function(){var b=a(this).attr("data-bv-validator"),c=a(this).attr("data-bv-for");return d.options.fields[c].validators[b].enabled===!1?"":a(this).html()}).get())}),e},getOptions:function(a,b,c){if(!a)return this.options;if("object"==typeof a&&(a=a.attr("data-bv-field")),!this.options.fields[a])return null;var d=this.options.fields[a];return b?d.validators&&d.validators[b]?c?d.validators[b][c]:d.validators[b]:null:d},updateOption:function(a,b,c,d){return"object"==typeof a&&(a=a.attr("data-bv-field")),this.options.fields[a]&&this.options.fields[a].validators[b]&&(this.options.fields[a].validators[b][c]=d,this.updateStatus(a,this.STATUS_NOT_VALIDATED,b)),this},addField:function(b,c){var d=a([]);switch(typeof b){case"object":d=b,b=b.attr("data-bv-field")||b.attr("name");break;case"string":delete this._cacheFields[b],d=this.getFieldElements(b)}d.attr("data-bv-field",b);for(var e=d.attr("type"),f="radio"===e||"checkbox"===e?1:d.length,g=0;f>g;g++){var h=d.eq(g),i=this._parseOptions(h);i=null===i?c:a.extend(!0,c,i),this.options.fields[b]=a.extend(!0,this.options.fields[b],i),this._cacheFields[b]=this._cacheFields[b]?this._cacheFields[b].add(h):h,this._initField("checkbox"===e||"radio"===e?b:h)}return this.disableSubmitButtons(!1),this.$form.trigger(a.Event("added.field.bv"),{field:b,element:d,options:this.options.fields[b]}),this},removeField:function(b){var c=a([]);switch(typeof b){case"object":c=b,b=b.attr("data-bv-field")||b.attr("name"),c.attr("data-bv-field",b);break;case"string":c=this.getFieldElements(b)}if(0===c.length)return this;for(var d=c.attr("type"),e="radio"===d||"checkbox"===d?1:c.length,f=0;e>f;f++){var g=c.eq(f);this.$invalidFields=this.$invalidFields.not(g),this._cacheFields[b]=this._cacheFields[b].not(g)}return this._cacheFields[b]&&0!==this._cacheFields[b].length||delete this.options.fields[b],("checkbox"===d||"radio"===d)&&this._initField(b),this.disableSubmitButtons(!1),this.$form.trigger(a.Event("removed.field.bv"),{field:b,element:c}),this},resetField:function(b,c){var d=a([]);switch(typeof b){case"object":d=b,b=b.attr("data-bv-field");break;case"string":d=this.getFieldElements(b)}var e=d.length;if(this.options.fields[b])for(var f=0;e>f;f++)for(var g in this.options.fields[b].validators)d.eq(f).removeData("bv.dfs."+g);if(this.updateStatus(b,this.STATUS_NOT_VALIDATED),c){var h=d.attr("type");"radio"===h||"checkbox"===h?d.removeAttr("checked").removeAttr("selected"):d.val("")}return this},resetForm:function(b){for(var c in this.options.fields)this.resetField(c,b);return this.$invalidFields=a([]),this.$submitButton=null,this.disableSubmitButtons(!1),this},revalidateField:function(a){return this.updateStatus(a,this.STATUS_NOT_VALIDATED).validateField(a),this},enableFieldValidators:function(a,b,c){var d=this.options.fields[a].validators;if(c&&d&&d[c]&&d[c].enabled!==b)this.options.fields[a].validators[c].enabled=b,this.updateStatus(a,this.STATUS_NOT_VALIDATED,c);else if(!c&&this.options.fields[a].enabled!==b){this.options.fields[a].enabled=b;for(var e in d)this.enableFieldValidators(a,b,e)}return this},getDynamicOption:function(b,c){var d="string"==typeof b?this.getFieldElements(b):b,e=d.val();if("function"==typeof c)return a.fn.bootstrapValidator.helpers.call(c,[e,this,d]);if("string"==typeof c){var f=this.getFieldElements(c);return f.length?f.val():a.fn.bootstrapValidator.helpers.call(c,[e,this,d])}return null},destroy:function(){var a,b,c,d,e,f,g;for(a in this.options.fields){b=this.getFieldElements(a),f=this.options.fields[a].container||this.options.container,g=this.options.fields[a].group||this.options.group;for(var h=0;ha||a>9999||0>=b||b>12)return!1;var e=[31,28,31,30,31,30,31,31,30,31,30,31];if((a%400===0||a%100!==0&&a%4===0)&&(e[1]=29),0>=c||c>e[b-1])return!1;if(d===!0){var f=new Date,g=f.getFullYear(),h=f.getMonth(),i=f.getDate();return g>a||a===g&&h>b-1||a===g&&b-1===h&&i>c}return!0},luhn:function(a){for(var b=a.length,c=0,d=[[0,1,2,3,4,5,6,7,8,9],[0,2,4,6,8,1,3,5,7,9]],e=0;b--;)e+=d[c][parseInt(a.charAt(b),10)],c^=1;return e%10===0&&e>0},mod11And10:function(a){for(var b=5,c=a.length,d=0;c>d;d++)b=(2*(b||10)%11+parseInt(a.charAt(d),10))%10;return 1===b},mod37And36:function(a,b){b=b||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";for(var c=b.length,d=a.length,e=Math.floor(c/2),f=0;d>f;f++)e=(2*(e||c)%(c+1)+b.indexOf(a.charAt(f)))%c;return 1===e}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.base64=a.extend(a.fn.bootstrapValidator.i18n.base64||{},{"default":"Please enter a valid base 64 encoded"}),a.fn.bootstrapValidator.validators.base64={validate:function(a,b){var c=b.val();return""===c?!0:/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$/.test(c)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.between=a.extend(a.fn.bootstrapValidator.i18n.between||{},{"default":"Please enter a value between %s and %s",notInclusive:"Please enter a value between %s and %s strictly"}),a.fn.bootstrapValidator.validators.between={html5Attributes:{message:"message",min:"min",max:"max",inclusive:"inclusive"},enableByHtml5:function(a){return"range"===a.attr("type")?{min:a.attr("min"),max:a.attr("max")}:!1},validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f=a.isNumeric(d.min)?d.min:b.getDynamicOption(c,d.min),g=a.isNumeric(d.max)?d.max:b.getDynamicOption(c,d.max);return e=parseFloat(e),d.inclusive===!0||void 0===d.inclusive?{valid:e>=f&&g>=e,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.between["default"],[f,g])}:{valid:e>f&&g>e,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.between.notInclusive,[f,g])}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.callback=a.extend(a.fn.bootstrapValidator.i18n.callback||{},{"default":"Please enter a valid value"}),a.fn.bootstrapValidator.validators.callback={html5Attributes:{message:"message",callback:"callback"},validate:function(b,c,d){var e=c.val();if(d.callback){var f=new a.Deferred,g=a.fn.bootstrapValidator.helpers.call(d.callback,[e,b,c]);return f.resolve(c,"callback","boolean"==typeof g?g:g.valid,"object"==typeof g&&g.message?g.message:null),f}return!0}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.choice=a.extend(a.fn.bootstrapValidator.i18n.choice||{},{"default":"Please enter a valid value",less:"Please choose %s options at minimum",more:"Please choose %s options at maximum",between:"Please choose %s - %s options"}),a.fn.bootstrapValidator.validators.choice={html5Attributes:{message:"message",min:"min",max:"max"},validate:function(b,c,d){var e=c.is("select")?b.getFieldElements(c.attr("data-bv-field")).find("option").filter(":selected").length:b.getFieldElements(c.attr("data-bv-field")).filter(":checked").length,f=d.min?a.isNumeric(d.min)?d.min:b.getDynamicOption(c,d.min):null,g=d.max?a.isNumeric(d.max)?d.max:b.getDynamicOption(c,d.max):null,h=!0,i=d.message||a.fn.bootstrapValidator.i18n.choice["default"];switch((f&&eparseInt(g,10))&&(h=!1),!0){case!!f&&!!g:i=a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.choice.between,[parseInt(f,10),parseInt(g,10)]);break;case!!f:i=a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.choice.less,parseInt(f,10));break;case!!g:i=a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.choice.more,parseInt(g,10))}return{valid:h,message:i}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.creditCard=a.extend(a.fn.bootstrapValidator.i18n.creditCard||{},{"default":"Please enter a valid credit card number"}),a.fn.bootstrapValidator.validators.creditCard={validate:function(b,c){var d=c.val();if(""===d)return!0;if(/[^0-9-\s]+/.test(d))return!1;if(d=d.replace(/\D/g,""),!a.fn.bootstrapValidator.helpers.luhn(d))return!1;var e,f,g={AMERICAN_EXPRESS:{length:[15],prefix:["34","37"]},DINERS_CLUB:{length:[14],prefix:["300","301","302","303","304","305","36"]},DINERS_CLUB_US:{length:[16],prefix:["54","55"]},DISCOVER:{length:[16],prefix:["6011","622126","622127","622128","622129","62213","62214","62215","62216","62217","62218","62219","6222","6223","6224","6225","6226","6227","6228","62290","62291","622920","622921","622922","622923","622924","622925","644","645","646","647","648","649","65"]},JCB:{length:[16],prefix:["3528","3529","353","354","355","356","357","358"]},LASER:{length:[16,17,18,19],prefix:["6304","6706","6771","6709"]},MAESTRO:{length:[12,13,14,15,16,17,18,19],prefix:["5018","5020","5038","6304","6759","6761","6762","6763","6764","6765","6766"]},MASTERCARD:{length:[16],prefix:["51","52","53","54","55"]},SOLO:{length:[16,18,19],prefix:["6334","6767"]},UNIONPAY:{length:[16,17,18,19],prefix:["622126","622127","622128","622129","62213","62214","62215","62216","62217","62218","62219","6222","6223","6224","6225","6226","6227","6228","62290","62291","622920","622921","622922","622923","622924","622925"]},VISA:{length:[16],prefix:["4"]}};for(e in g)for(f in g[e].prefix)if(d.substr(0,g[e].prefix[f].length)===g[e].prefix[f]&&-1!==a.inArray(d.length,g[e].length))return!0;return!1}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.cusip=a.extend(a.fn.bootstrapValidator.i18n.cusip||{},{"default":"Please enter a valid CUSIP number"}),a.fn.bootstrapValidator.validators.cusip={validate:function(b,c){var d=c.val();if(""===d)return!0;if(d=d.toUpperCase(),!/^[0-9A-Z]{9}$/.test(d))return!1;for(var e=a.map(d.split(""),function(a){var b=a.charCodeAt(0);return b>="A".charCodeAt(0)&&b<="Z".charCodeAt(0)?b-"A".charCodeAt(0)+10:a}),f=e.length,g=0,h=0;f-1>h;h++){var i=parseInt(e[h],10);h%2!==0&&(i*=2),i>9&&(i-=9),g+=i}return g=(10-g%10)%10,g===e[f-1]}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.cvv=a.extend(a.fn.bootstrapValidator.i18n.cvv||{},{"default":"Please enter a valid CVV number"}),a.fn.bootstrapValidator.validators.cvv={html5Attributes:{message:"message",ccfield:"creditCardField"},validate:function(b,c,d){var e=c.val();if(""===e)return!0;if(!/^[0-9]{3,4}$/.test(e))return!1;if(!d.creditCardField)return!0;var f=b.getFieldElements(d.creditCardField).val();if(""===f)return!0;f=f.replace(/\D/g,"");var g,h,i={AMERICAN_EXPRESS:{length:[15],prefix:["34","37"]},DINERS_CLUB:{length:[14],prefix:["300","301","302","303","304","305","36"]},DINERS_CLUB_US:{length:[16],prefix:["54","55"]},DISCOVER:{length:[16],prefix:["6011","622126","622127","622128","622129","62213","62214","62215","62216","62217","62218","62219","6222","6223","6224","6225","6226","6227","6228","62290","62291","622920","622921","622922","622923","622924","622925","644","645","646","647","648","649","65"]},JCB:{length:[16],prefix:["3528","3529","353","354","355","356","357","358"]},LASER:{length:[16,17,18,19],prefix:["6304","6706","6771","6709"]},MAESTRO:{length:[12,13,14,15,16,17,18,19],prefix:["5018","5020","5038","6304","6759","6761","6762","6763","6764","6765","6766"]},MASTERCARD:{length:[16],prefix:["51","52","53","54","55"]},SOLO:{length:[16,18,19],prefix:["6334","6767"]},UNIONPAY:{length:[16,17,18,19],prefix:["622126","622127","622128","622129","62213","62214","62215","62216","62217","62218","62219","6222","6223","6224","6225","6226","6227","6228","62290","62291","622920","622921","622922","622923","622924","622925"]},VISA:{length:[16],prefix:["4"]}},j=null;for(g in i)for(h in i[g].prefix)if(f.substr(0,i[g].prefix[h].length)===i[g].prefix[h]&&-1!==a.inArray(f.length,i[g].length)){j=g;break}return null===j?!1:"AMERICAN_EXPRESS"===j?4===e.length:3===e.length}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.date=a.extend(a.fn.bootstrapValidator.i18n.date||{},{"default":"Please enter a valid date"}),a.fn.bootstrapValidator.validators.date={html5Attributes:{message:"message",format:"format",separator:"separator"},validate:function(b,c,d){var e=c.val();if(""===e)return!0;d.format=d.format||"MM/DD/YYYY";var f=d.format.split(" "),g=f[0],h=f.length>1?f[1]:null,i=f.length>2?f[2]:null,j=e.split(" "),k=j[0],l=j.length>1?j[1]:null;if(f.length!==j.length)return!1;var m=d.separator;if(m||(m=-1!==k.indexOf("/")?"/":-1!==k.indexOf("-")?"-":null),null===m||-1===k.indexOf(m))return!1;if(k=k.split(m),g=g.split(m),k.length!==g.length)return!1;var n=k[a.inArray("YYYY",g)],o=k[a.inArray("MM",g)],p=k[a.inArray("DD",g)]; +if(!n||!o||!p)return!1;var q=null,r=null,s=null;if(h){if(h=h.split(":"),l=l.split(":"),h.length!==l.length)return!1;if(r=l.length>0?l[0]:null,q=l.length>1?l[1]:null,s=l.length>2?l[2]:null,s&&(s=parseInt(s,10),isNaN(s)||0>s||s>60))return!1;if(r&&(r=parseInt(r,10),isNaN(r)||0>r||r>=24||i&&r>12))return!1;if(q&&(q=parseInt(q,10),isNaN(q)||0>q||q>59))return!1}return a.fn.bootstrapValidator.helpers.date(n,o,p)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.different=a.extend(a.fn.bootstrapValidator.i18n.different||{},{"default":"Please enter a different value"}),a.fn.bootstrapValidator.validators.different={html5Attributes:{message:"message",field:"field"},validate:function(a,b,c){var d=b.val();if(""===d)return!0;var e=a.getFieldElements(c.field);return null===e?!0:d!==e.val()?(a.updateStatus(c.field,a.STATUS_VALID,"different"),!0):!1}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.digits=a.extend(a.fn.bootstrapValidator.i18n.digits||{},{"default":"Please enter only digits"}),a.fn.bootstrapValidator.validators.digits={validate:function(a,b){var c=b.val();return""===c?!0:/^\d+$/.test(c)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.ean=a.extend(a.fn.bootstrapValidator.i18n.ean||{},{"default":"Please enter a valid EAN number"}),a.fn.bootstrapValidator.validators.ean={validate:function(a,b){var c=b.val();if(""===c)return!0;if(!/^(\d{8}|\d{12}|\d{13})$/.test(c))return!1;for(var d=c.length,e=0,f=8===d?[3,1]:[1,3],g=0;d-1>g;g++)e+=parseInt(c.charAt(g),10)*f[g%2];return e=(10-e%10)%10,e+""===c.charAt(d-1)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.emailAddress=a.extend(a.fn.bootstrapValidator.i18n.emailAddress||{},{"default":"Please enter a valid email address"}),a.fn.bootstrapValidator.validators.emailAddress={enableByHtml5:function(a){return"email"===a.attr("type")},validate:function(a,b){var c=b.val();if(""===c)return!0;var d=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return d.test(c)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.file=a.extend(a.fn.bootstrapValidator.i18n.file||{},{"default":"Please choose a valid file"}),a.fn.bootstrapValidator.validators.file={html5Attributes:{extension:"extension",maxsize:"maxSize",message:"message",type:"type"},validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f,g=d.extension?d.extension.toLowerCase().split(","):null,h=d.type?d.type.toLowerCase().split(","):null,i=window.File&&window.FileList&&window.FileReader;if(i)for(var j=c.get(0).files,k=j.length,l=0;k>l;l++){if(d.maxSize&&j[l].size>parseInt(d.maxSize,10))return!1;if(f=j[l].name.substr(j[l].name.lastIndexOf(".")+1),g&&-1===a.inArray(f.toLowerCase(),g))return!1;if(h&&-1===a.inArray(j[l].type.toLowerCase(),h))return!1}else if(f=e.substr(e.lastIndexOf(".")+1),g&&-1===a.inArray(f.toLowerCase(),g))return!1;return!0}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.greaterThan=a.extend(a.fn.bootstrapValidator.i18n.greaterThan||{},{"default":"Please enter a value greater than or equal to %s",notInclusive:"Please enter a value greater than %s"}),a.fn.bootstrapValidator.validators.greaterThan={html5Attributes:{message:"message",value:"value",inclusive:"inclusive"},enableByHtml5:function(a){var b=a.attr("min");return b?{value:b}:!1},validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f=a.isNumeric(d.value)?d.value:b.getDynamicOption(c,d.value);return e=parseFloat(e),d.inclusive===!0||void 0===d.inclusive?{valid:e>=f,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.greaterThan["default"],f)}:{valid:e>f,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.greaterThan.notInclusive,f)}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.grid=a.extend(a.fn.bootstrapValidator.i18n.grid||{},{"default":"Please enter a valid GRId number"}),a.fn.bootstrapValidator.validators.grid={validate:function(b,c){var d=c.val();return""===d?!0:(d=d.toUpperCase(),/^[GRID:]*([0-9A-Z]{2})[-\s]*([0-9A-Z]{5})[-\s]*([0-9A-Z]{10})[-\s]*([0-9A-Z]{1})$/g.test(d)?(d=d.replace(/\s/g,"").replace(/-/g,""),"GRID:"===d.substr(0,5)&&(d=d.substr(5)),a.fn.bootstrapValidator.helpers.mod37And36(d)):!1)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.hex=a.extend(a.fn.bootstrapValidator.i18n.hex||{},{"default":"Please enter a valid hexadecimal number"}),a.fn.bootstrapValidator.validators.hex={validate:function(a,b){var c=b.val();return""===c?!0:/^[0-9a-fA-F]+$/.test(c)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.hexColor=a.extend(a.fn.bootstrapValidator.i18n.hexColor||{},{"default":"Please enter a valid hex color"}),a.fn.bootstrapValidator.validators.hexColor={enableByHtml5:function(a){return"color"===a.attr("type")},validate:function(a,b){var c=b.val();return""===c?!0:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(c)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.iban=a.extend(a.fn.bootstrapValidator.i18n.iban||{},{"default":"Please enter a valid IBAN number",countryNotSupported:"The country code %s is not supported",country:"Please enter a valid IBAN number in %s",countries:{AD:"Andorra",AE:"United Arab Emirates",AL:"Albania",AO:"Angola",AT:"Austria",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BR:"Brazil",CH:"Switzerland",CI:"Ivory Coast",CM:"Cameroon",CR:"Costa Rica",CV:"Cape Verde",CY:"Cyprus",CZ:"Czech Republic",DE:"Germany",DK:"Denmark",DO:"Dominican Republic",DZ:"Algeria",EE:"Estonia",ES:"Spain",FI:"Finland",FO:"Faroe Islands",FR:"France",GB:"United Kingdom",GE:"Georgia",GI:"Gibraltar",GL:"Greenland",GR:"Greece",GT:"Guatemala",HR:"Croatia",HU:"Hungary",IE:"Ireland",IL:"Israel",IR:"Iran",IS:"Iceland",IT:"Italy",JO:"Jordan",KW:"Kuwait",KZ:"Kazakhstan",LB:"Lebanon",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MG:"Madagascar",MK:"Macedonia",ML:"Mali",MR:"Mauritania",MT:"Malta",MU:"Mauritius",MZ:"Mozambique",NL:"Netherlands",NO:"Norway",PK:"Pakistan",PL:"Poland",PS:"Palestinian",PT:"Portugal",QA:"Qatar",RO:"Romania",RS:"Serbia",SA:"Saudi Arabia",SE:"Sweden",SI:"Slovenia",SK:"Slovakia",SM:"San Marino",SN:"Senegal",TN:"Tunisia",TR:"Turkey",VG:"Virgin Islands, British"}}),a.fn.bootstrapValidator.validators.iban={html5Attributes:{message:"message",country:"country"},REGEX:{AD:"AD[0-9]{2}[0-9]{4}[0-9]{4}[A-Z0-9]{12}",AE:"AE[0-9]{2}[0-9]{3}[0-9]{16}",AL:"AL[0-9]{2}[0-9]{8}[A-Z0-9]{16}",AO:"AO[0-9]{2}[0-9]{21}",AT:"AT[0-9]{2}[0-9]{5}[0-9]{11}",AZ:"AZ[0-9]{2}[A-Z]{4}[A-Z0-9]{20}",BA:"BA[0-9]{2}[0-9]{3}[0-9]{3}[0-9]{8}[0-9]{2}",BE:"BE[0-9]{2}[0-9]{3}[0-9]{7}[0-9]{2}",BF:"BF[0-9]{2}[0-9]{23}",BG:"BG[0-9]{2}[A-Z]{4}[0-9]{4}[0-9]{2}[A-Z0-9]{8}",BH:"BH[0-9]{2}[A-Z]{4}[A-Z0-9]{14}",BI:"BI[0-9]{2}[0-9]{12}",BJ:"BJ[0-9]{2}[A-Z]{1}[0-9]{23}",BR:"BR[0-9]{2}[0-9]{8}[0-9]{5}[0-9]{10}[A-Z][A-Z0-9]",CH:"CH[0-9]{2}[0-9]{5}[A-Z0-9]{12}",CI:"CI[0-9]{2}[A-Z]{1}[0-9]{23}",CM:"CM[0-9]{2}[0-9]{23}",CR:"CR[0-9]{2}[0-9]{3}[0-9]{14}",CV:"CV[0-9]{2}[0-9]{21}",CY:"CY[0-9]{2}[0-9]{3}[0-9]{5}[A-Z0-9]{16}",CZ:"CZ[0-9]{2}[0-9]{20}",DE:"DE[0-9]{2}[0-9]{8}[0-9]{10}",DK:"DK[0-9]{2}[0-9]{14}",DO:"DO[0-9]{2}[A-Z0-9]{4}[0-9]{20}",DZ:"DZ[0-9]{2}[0-9]{20}",EE:"EE[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{11}[0-9]{1}",ES:"ES[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{1}[0-9]{1}[0-9]{10}",FI:"FI[0-9]{2}[0-9]{6}[0-9]{7}[0-9]{1}",FO:"FO[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}",FR:"FR[0-9]{2}[0-9]{5}[0-9]{5}[A-Z0-9]{11}[0-9]{2}",GB:"GB[0-9]{2}[A-Z]{4}[0-9]{6}[0-9]{8}",GE:"GE[0-9]{2}[A-Z]{2}[0-9]{16}",GI:"GI[0-9]{2}[A-Z]{4}[A-Z0-9]{15}",GL:"GL[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}",GR:"GR[0-9]{2}[0-9]{3}[0-9]{4}[A-Z0-9]{16}",GT:"GT[0-9]{2}[A-Z0-9]{4}[A-Z0-9]{20}",HR:"HR[0-9]{2}[0-9]{7}[0-9]{10}",HU:"HU[0-9]{2}[0-9]{3}[0-9]{4}[0-9]{1}[0-9]{15}[0-9]{1}",IE:"IE[0-9]{2}[A-Z]{4}[0-9]{6}[0-9]{8}",IL:"IL[0-9]{2}[0-9]{3}[0-9]{3}[0-9]{13}",IR:"IR[0-9]{2}[0-9]{22}",IS:"IS[0-9]{2}[0-9]{4}[0-9]{2}[0-9]{6}[0-9]{10}",IT:"IT[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}",JO:"JO[0-9]{2}[A-Z]{4}[0-9]{4}[0]{8}[A-Z0-9]{10}",KW:"KW[0-9]{2}[A-Z]{4}[0-9]{22}",KZ:"KZ[0-9]{2}[0-9]{3}[A-Z0-9]{13}",LB:"LB[0-9]{2}[0-9]{4}[A-Z0-9]{20}",LI:"LI[0-9]{2}[0-9]{5}[A-Z0-9]{12}",LT:"LT[0-9]{2}[0-9]{5}[0-9]{11}",LU:"LU[0-9]{2}[0-9]{3}[A-Z0-9]{13}",LV:"LV[0-9]{2}[A-Z]{4}[A-Z0-9]{13}",MC:"MC[0-9]{2}[0-9]{5}[0-9]{5}[A-Z0-9]{11}[0-9]{2}",MD:"MD[0-9]{2}[A-Z0-9]{20}",ME:"ME[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}",MG:"MG[0-9]{2}[0-9]{23}",MK:"MK[0-9]{2}[0-9]{3}[A-Z0-9]{10}[0-9]{2}",ML:"ML[0-9]{2}[A-Z]{1}[0-9]{23}",MR:"MR13[0-9]{5}[0-9]{5}[0-9]{11}[0-9]{2}",MT:"MT[0-9]{2}[A-Z]{4}[0-9]{5}[A-Z0-9]{18}",MU:"MU[0-9]{2}[A-Z]{4}[0-9]{2}[0-9]{2}[0-9]{12}[0-9]{3}[A-Z]{3}",MZ:"MZ[0-9]{2}[0-9]{21}",NL:"NL[0-9]{2}[A-Z]{4}[0-9]{10}",NO:"NO[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{1}",PK:"PK[0-9]{2}[A-Z]{4}[A-Z0-9]{16}",PL:"PL[0-9]{2}[0-9]{8}[0-9]{16}",PS:"PS[0-9]{2}[A-Z]{4}[A-Z0-9]{21}",PT:"PT[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{11}[0-9]{2}",QA:"QA[0-9]{2}[A-Z]{4}[A-Z0-9]{21}",RO:"RO[0-9]{2}[A-Z]{4}[A-Z0-9]{16}",RS:"RS[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}",SA:"SA[0-9]{2}[0-9]{2}[A-Z0-9]{18}",SE:"SE[0-9]{2}[0-9]{3}[0-9]{16}[0-9]{1}",SI:"SI[0-9]{2}[0-9]{5}[0-9]{8}[0-9]{2}",SK:"SK[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{10}",SM:"SM[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}",SN:"SN[0-9]{2}[A-Z]{1}[0-9]{23}",TN:"TN59[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}",TR:"TR[0-9]{2}[0-9]{5}[A-Z0-9]{1}[A-Z0-9]{16}",VG:"VG[0-9]{2}[A-Z]{4}[0-9]{16}"},validate:function(b,c,d){var e=c.val();if(""===e)return!0;e=e.replace(/[^a-zA-Z0-9]/g,"").toUpperCase();var f=d.country;if(f?"string"==typeof f&&this.REGEX[f]||(f=b.getDynamicOption(c,f)):f=e.substr(0,2),!this.REGEX[f])return{valid:!1,message:a.fn.bootstrapValidator.helpers.format(a.fn.bootstrapValidator.i18n.iban.countryNotSupported,f)};if(!new RegExp("^"+this.REGEX[f]+"$").test(e))return{valid:!1,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.iban.country,a.fn.bootstrapValidator.i18n.iban.countries[f])};e=e.substr(4)+e.substr(0,4),e=a.map(e.split(""),function(a){var b=a.charCodeAt(0);return b>="A".charCodeAt(0)&&b<="Z".charCodeAt(0)?b-"A".charCodeAt(0)+10:a}),e=e.join("");for(var g=parseInt(e.substr(0,1),10),h=e.length,i=1;h>i;++i)g=(10*g+parseInt(e.substr(i,1),10))%97;return{valid:1===g,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.iban.country,a.fn.bootstrapValidator.i18n.iban.countries[f])}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.id=a.extend(a.fn.bootstrapValidator.i18n.id||{},{"default":"Please enter a valid identification number",countryNotSupported:"The country code %s is not supported",country:"Please enter a valid %s identification number",countries:{BA:"Bosnia and Herzegovina",BG:"Bulgarian",BR:"Brazilian",CH:"Swiss",CL:"Chilean",CZ:"Czech",DK:"Danish",EE:"Estonian",ES:"Spanish",FI:"Finnish",HR:"Croatian",IE:"Irish",IS:"Iceland",LT:"Lithuanian",LV:"Latvian",ME:"Montenegro",MK:"Macedonian",NL:"Dutch",RO:"Romanian",RS:"Serbian",SE:"Swedish",SI:"Slovenian",SK:"Slovak",SM:"San Marino",ZA:"South African"}}),a.fn.bootstrapValidator.validators.id={html5Attributes:{message:"message",country:"country"},COUNTRY_CODES:["BA","BG","BR","CH","CL","CZ","DK","EE","ES","FI","HR","IE","IS","LT","LV","ME","MK","NL","RO","RS","SE","SI","SK","SM","ZA"],validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f=d.country;if(f?("string"!=typeof f||-1===a.inArray(f.toUpperCase(),this.COUNTRY_CODES))&&(f=b.getDynamicOption(c,f)):f=e.substr(0,2),-1===a.inArray(f,this.COUNTRY_CODES))return{valid:!1,message:a.fn.bootstrapValidator.helpers.format(a.fn.bootstrapValidator.i18n.id.countryNotSupported,f)};var g=["_",f.toLowerCase()].join("");return this[g](e)?!0:{valid:!1,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.id.country,a.fn.bootstrapValidator.i18n.id.countries[f.toUpperCase()])}},_validateJMBG:function(a,b){if(!/^\d{13}$/.test(a))return!1;var c=parseInt(a.substr(0,2),10),d=parseInt(a.substr(2,2),10),e=(parseInt(a.substr(4,3),10),parseInt(a.substr(7,2),10)),f=parseInt(a.substr(12,1),10);if(c>31||d>12)return!1;for(var g=0,h=0;6>h;h++)g+=(7-h)*(parseInt(a.charAt(h),10)+parseInt(a.charAt(h+6),10));if(g=11-g%11,(10===g||11===g)&&(g=0),g!==f)return!1;switch(b.toUpperCase()){case"BA":return e>=10&&19>=e;case"MK":return e>=41&&49>=e;case"ME":return e>=20&&29>=e;case"RS":return e>=70&&99>=e;case"SI":return e>=50&&59>=e;default:return!0}},_ba:function(a){return this._validateJMBG(a,"BA")},_mk:function(a){return this._validateJMBG(a,"MK")},_me:function(a){return this._validateJMBG(a,"ME")},_rs:function(a){return this._validateJMBG(a,"RS")},_si:function(a){return this._validateJMBG(a,"SI")},_bg:function(b){if(!/^\d{10}$/.test(b)&&!/^\d{6}\s\d{3}\s\d{1}$/.test(b))return!1;b=b.replace(/\s/g,"");var c=parseInt(b.substr(0,2),10)+1900,d=parseInt(b.substr(2,2),10),e=parseInt(b.substr(4,2),10);if(d>40?(c+=100,d-=40):d>20&&(c-=100,d-=20),!a.fn.bootstrapValidator.helpers.date(c,d,e))return!1;for(var f=0,g=[2,4,8,5,10,9,7,3,6],h=0;9>h;h++)f+=parseInt(b.charAt(h),10)*g[h];return f=f%11%10,f+""===b.substr(9,1)},_br:function(a){if(/^1{11}|2{11}|3{11}|4{11}|5{11}|6{11}|7{11}|8{11}|9{11}|0{11}$/.test(a))return!1;if(!/^\d{11}$/.test(a)&&!/^\d{3}\.\d{3}\.\d{3}-\d{2}$/.test(a))return!1;a=a.replace(/\./g,"").replace(/-/g,"");for(var b=0,c=0;9>c;c++)b+=(10-c)*parseInt(a.charAt(c),10);if(b=11-b%11,(10===b||11===b)&&(b=0),b+""!==a.charAt(9))return!1;var d=0;for(c=0;10>c;c++)d+=(11-c)*parseInt(a.charAt(c),10);return d=11-d%11,(10===d||11===d)&&(d=0),d+""===a.charAt(10)},_ch:function(a){if(!/^756[\.]{0,1}[0-9]{4}[\.]{0,1}[0-9]{4}[\.]{0,1}[0-9]{2}$/.test(a))return!1;a=a.replace(/\D/g,"").substr(3);for(var b=a.length,c=0,d=8===b?[3,1]:[1,3],e=0;b-1>e;e++)c+=parseInt(a.charAt(e),10)*d[e%2];return c=10-c%10,c+""===a.charAt(b-1)},_cl:function(a){if(!/^\d{7,8}[-]{0,1}[0-9K]$/i.test(a))return!1;for(a=a.replace(/\-/g,"");a.length<9;)a="0"+a;for(var b=0,c=[3,2,7,6,5,4,3,2],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b=11-b%11,11===b?b=0:10===b&&(b="K"),b+""===a.charAt(8).toUpperCase()},_cz:function(b){if(!/^\d{9,10}$/.test(b))return!1;var c=1900+parseInt(b.substr(0,2),10),d=parseInt(b.substr(2,2),10)%50%20,e=parseInt(b.substr(4,2),10);if(9===b.length){if(c>=1980&&(c-=100),c>1953)return!1}else 1954>c&&(c+=100);if(!a.fn.bootstrapValidator.helpers.date(c,d,e))return!1;if(10===b.length){var f=parseInt(b.substr(0,9),10)%11;return 1985>c&&(f%=10),f+""===b.substr(9,1)}return!0},_dk:function(b){if(!/^[0-9]{6}[-]{0,1}[0-9]{4}$/.test(b))return!1;b=b.replace(/-/g,"");var c=parseInt(b.substr(0,2),10),d=parseInt(b.substr(2,2),10),e=parseInt(b.substr(4,2),10);switch(!0){case-1!=="5678".indexOf(b.charAt(6))&&e>=58:e+=1800;break;case-1!=="0123".indexOf(b.charAt(6)):case-1!=="49".indexOf(b.charAt(6))&&e>=37:e+=1900;break;default:e+=2e3}return a.fn.bootstrapValidator.helpers.date(e,d,c)},_ee:function(a){return this._lt(a)},_es:function(a){if(!/^[0-9A-Z]{8}[-]{0,1}[0-9A-Z]$/.test(a)&&!/^[XYZ][-]{0,1}[0-9]{7}[-]{0,1}[0-9A-Z]$/.test(a))return!1;a=a.replace(/-/g,"");var b="XYZ".indexOf(a.charAt(0));-1!==b&&(a=b+a.substr(1)+"");var c=parseInt(a.substr(0,8),10);return c="TRWAGMYFPDXBNJZSQVHLCKE"[c%23],c===a.substr(8,1)},_fi:function(b){if(!/^[0-9]{6}[-+A][0-9]{3}[0-9ABCDEFHJKLMNPRSTUVWXY]$/.test(b))return!1;var c=parseInt(b.substr(0,2),10),d=parseInt(b.substr(2,2),10),e=parseInt(b.substr(4,2),10),f={"+":1800,"-":1900,A:2e3};if(e=f[b.charAt(6)]+e,!a.fn.bootstrapValidator.helpers.date(e,d,c))return!1;var g=parseInt(b.substr(7,3),10);if(2>g)return!1;var h=b.substr(0,6)+b.substr(7,3)+"";return h=parseInt(h,10),"0123456789ABCDEFHJKLMNPRSTUVWXY".charAt(h%31)===b.charAt(10)},_hr:function(b){return/^[0-9]{11}$/.test(b)?a.fn.bootstrapValidator.helpers.mod11And10(b):!1},_ie:function(a){if(!/^\d{7}[A-W][AHWTX]?$/.test(a))return!1;var b=function(a){for(;a.length<7;)a="0"+a;for(var b="WABCDEFGHIJKLMNOPQRSTUV",c=0,d=0;7>d;d++)c+=parseInt(a.charAt(d),10)*(8-d);return c+=9*b.indexOf(a.substr(7)),b[c%23]};return 9!==a.length||"A"!==a.charAt(8)&&"H"!==a.charAt(8)?a.charAt(7)===b(a.substr(0,7)):a.charAt(7)===b(a.substr(0,7)+a.substr(8)+"")},_is:function(b){if(!/^[0-9]{6}[-]{0,1}[0-9]{4}$/.test(b))return!1;b=b.replace(/-/g,"");var c=parseInt(b.substr(0,2),10),d=parseInt(b.substr(2,2),10),e=parseInt(b.substr(4,2),10),f=parseInt(b.charAt(9),10);if(e=9===f?1900+e:100*(20+f)+e,!a.fn.bootstrapValidator.helpers.date(e,d,c,!0))return!1;for(var g=0,h=[3,2,7,6,5,4,3,2],i=0;8>i;i++)g+=parseInt(b.charAt(i),10)*h[i];return g=11-g%11,g+""===b.charAt(8)},_lt:function(b){if(!/^[0-9]{11}$/.test(b))return!1;var c=parseInt(b.charAt(0),10),d=parseInt(b.substr(1,2),10),e=parseInt(b.substr(3,2),10),f=parseInt(b.substr(5,2),10),g=c%2===0?17+c/2:17+(c+1)/2;if(d=100*g+d,!a.fn.bootstrapValidator.helpers.date(d,e,f,!0))return!1;for(var h=0,i=[1,2,3,4,5,6,7,8,9,1],j=0;10>j;j++)h+=parseInt(b.charAt(j),10)*i[j];if(h%=11,10!==h)return h+""===b.charAt(10);for(h=0,i=[3,4,5,6,7,8,9,1,2,3],j=0;10>j;j++)h+=parseInt(b.charAt(j),10)*i[j];return h%=11,10===h&&(h=0),h+""===b.charAt(10)},_lv:function(b){if(!/^[0-9]{6}[-]{0,1}[0-9]{5}$/.test(b))return!1;b=b.replace(/\D/g,"");var c=parseInt(b.substr(0,2),10),d=parseInt(b.substr(2,2),10),e=parseInt(b.substr(4,2),10);if(e=e+1800+100*parseInt(b.charAt(6),10),!a.fn.bootstrapValidator.helpers.date(e,d,c,!0))return!1;for(var f=0,g=[10,5,8,4,2,1,6,3,7,9],h=0;10>h;h++)f+=parseInt(b.charAt(h),10)*g[h];return f=(f+1)%11%10,f+""===b.charAt(10)},_nl:function(a){for(;a.length<9;)a="0"+a;if(!/^[0-9]{4}[.]{0,1}[0-9]{2}[.]{0,1}[0-9]{3}$/.test(a))return!1;if(a=a.replace(/\./g,""),0===parseInt(a,10))return!1;for(var b=0,c=a.length,d=0;c-1>d;d++)b+=(9-d)*parseInt(a.charAt(d),10);return b%=11,10===b&&(b=0),b+""===a.charAt(c-1)},_ro:function(b){if(!/^[0-9]{13}$/.test(b))return!1;var c=parseInt(b.charAt(0),10);if(0===c||7===c||8===c)return!1;var d=parseInt(b.substr(1,2),10),e=parseInt(b.substr(3,2),10),f=parseInt(b.substr(5,2),10),g={1:1900,2:1900,3:1800,4:1800,5:2e3,6:2e3};if(f>31&&e>12)return!1;if(9!==c&&(d=g[c+""]+d,!a.fn.bootstrapValidator.helpers.date(d,e,f)))return!1;for(var h=0,i=[2,7,9,1,4,6,3,5,8,2,7,9],j=b.length,k=0;j-1>k;k++)h+=parseInt(b.charAt(k),10)*i[k];return h%=11,10===h&&(h=1),h+""===b.charAt(j-1)},_se:function(b){if(!/^[0-9]{10}$/.test(b)&&!/^[0-9]{6}[-|+][0-9]{4}$/.test(b))return!1;b=b.replace(/[^0-9]/g,"");var c=parseInt(b.substr(0,2),10)+1900,d=parseInt(b.substr(2,2),10),e=parseInt(b.substr(4,2),10);return a.fn.bootstrapValidator.helpers.date(c,d,e)?a.fn.bootstrapValidator.helpers.luhn(b):!1},_sk:function(a){return this._cz(a)},_sm:function(a){return/^\d{5}$/.test(a)},_za:function(b){if(!/^[0-9]{10}[0|1][8|9][0-9]$/.test(b))return!1;var c=parseInt(b.substr(0,2),10),d=(new Date).getFullYear()%100,e=parseInt(b.substr(2,2),10),f=parseInt(b.substr(4,2),10);return c=c>=d?c+1900:c+2e3,a.fn.bootstrapValidator.helpers.date(c,e,f)?a.fn.bootstrapValidator.helpers.luhn(b):!1}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.identical=a.extend(a.fn.bootstrapValidator.i18n.identical||{},{"default":"Please enter the same value"}),a.fn.bootstrapValidator.validators.identical={html5Attributes:{message:"message",field:"field"},validate:function(a,b,c){var d=b.val();if(""===d)return!0;var e=a.getFieldElements(c.field);return null===e?!0:d===e.val()?(a.updateStatus(c.field,a.STATUS_VALID,"identical"),!0):!1}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.imei=a.extend(a.fn.bootstrapValidator.i18n.imei||{},{"default":"Please enter a valid IMEI number"}),a.fn.bootstrapValidator.validators.imei={validate:function(b,c){var d=c.val();if(""===d)return!0;switch(!0){case/^\d{15}$/.test(d):case/^\d{2}-\d{6}-\d{6}-\d{1}$/.test(d):case/^\d{2}\s\d{6}\s\d{6}\s\d{1}$/.test(d):return d=d.replace(/[^0-9]/g,""),a.fn.bootstrapValidator.helpers.luhn(d);case/^\d{14}$/.test(d):case/^\d{16}$/.test(d):case/^\d{2}-\d{6}-\d{6}(|-\d{2})$/.test(d):case/^\d{2}\s\d{6}\s\d{6}(|\s\d{2})$/.test(d):return!0;default:return!1}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.imo=a.extend(a.fn.bootstrapValidator.i18n.imo||{},{"default":"Please enter a valid IMO number"}),a.fn.bootstrapValidator.validators.imo={validate:function(a,b){var c=b.val();if(""===c)return!0;if(!/^IMO \d{7}$/i.test(c))return!1;for(var d=0,e=c.replace(/^.*(\d{7})$/,"$1"),f=6;f>=1;f--)d+=e.slice(6-f,-f)*(f+1);return d%10===parseInt(e.charAt(6),10)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.integer=a.extend(a.fn.bootstrapValidator.i18n.integer||{},{"default":"Please enter a valid number"}),a.fn.bootstrapValidator.validators.integer={enableByHtml5:function(a){return"number"===a.attr("type")&&(void 0===a.attr("step")||a.attr("step")%1===0)},validate:function(a,b){var c=b.val();return""===c?!0:/^(?:-?(?:0|[1-9][0-9]*))$/.test(c)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.ip=a.extend(a.fn.bootstrapValidator.i18n.ip||{},{"default":"Please enter a valid IP address",ipv4:"Please enter a valid IPv4 address",ipv6:"Please enter a valid IPv6 address"}),a.fn.bootstrapValidator.validators.ip={html5Attributes:{message:"message",ipv4:"ipv4",ipv6:"ipv6"},validate:function(b,c,d){var e=c.val();if(""===e)return!0;d=a.extend({},{ipv4:!0,ipv6:!0},d);var f,g=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,h=/^\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*$/,i=!1;switch(!0){case d.ipv4&&!d.ipv6:i=g.test(e),f=d.message||a.fn.bootstrapValidator.i18n.ip.ipv4;break;case!d.ipv4&&d.ipv6:i=h.test(e),f=d.message||a.fn.bootstrapValidator.i18n.ip.ipv6;break;case d.ipv4&&d.ipv6:default:i=g.test(e)&&h.test(e),f=d.message||a.fn.bootstrapValidator.i18n.ip.default}return{valid:i,message:f}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.isbn=a.extend(a.fn.bootstrapValidator.i18n.isbn||{},{"default":"Please enter a valid ISBN number"}),a.fn.bootstrapValidator.validators.isbn={validate:function(a,b){var c=b.val();if(""===c)return!0;var d;switch(!0){case/^\d{9}[\dX]$/.test(c):case 13===c.length&&/^(\d+)-(\d+)-(\d+)-([\dX])$/.test(c):case 13===c.length&&/^(\d+)\s(\d+)\s(\d+)\s([\dX])$/.test(c):d="ISBN10";break;case/^(978|979)\d{9}[\dX]$/.test(c):case 17===c.length&&/^(978|979)-(\d+)-(\d+)-(\d+)-([\dX])$/.test(c):case 17===c.length&&/^(978|979)\s(\d+)\s(\d+)\s(\d+)\s([\dX])$/.test(c):d="ISBN13";break;default:return!1}c=c.replace(/[^0-9X]/gi,"");var e,f,g=c.split(""),h=g.length,i=0;switch(d){case"ISBN10":for(i=0,e=0;h-1>e;e++)i+=parseInt(g[e],10)*(10-e);return f=11-i%11,11===f?f=0:10===f&&(f="X"),f+""===g[h-1];case"ISBN13":for(i=0,e=0;h-1>e;e++)i+=e%2===0?parseInt(g[e],10):3*parseInt(g[e],10);return f=10-i%10,10===f&&(f="0"),f+""===g[h-1];default:return!1}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.isin=a.extend(a.fn.bootstrapValidator.i18n.isin||{},{"default":"Please enter a valid ISIN number"}),a.fn.bootstrapValidator.validators.isin={COUNTRY_CODES:"AF|AX|AL|DZ|AS|AD|AO|AI|AQ|AG|AR|AM|AW|AU|AT|AZ|BS|BH|BD|BB|BY|BE|BZ|BJ|BM|BT|BO|BQ|BA|BW|BV|BR|IO|BN|BG|BF|BI|KH|CM|CA|CV|KY|CF|TD|CL|CN|CX|CC|CO|KM|CG|CD|CK|CR|CI|HR|CU|CW|CY|CZ|DK|DJ|DM|DO|EC|EG|SV|GQ|ER|EE|ET|FK|FO|FJ|FI|FR|GF|PF|TF|GA|GM|GE|DE|GH|GI|GR|GL|GD|GP|GU|GT|GG|GN|GW|GY|HT|HM|VA|HN|HK|HU|IS|IN|ID|IR|IQ|IE|IM|IL|IT|JM|JP|JE|JO|KZ|KE|KI|KP|KR|KW|KG|LA|LV|LB|LS|LR|LY|LI|LT|LU|MO|MK|MG|MW|MY|MV|ML|MT|MH|MQ|MR|MU|YT|MX|FM|MD|MC|MN|ME|MS|MA|MZ|MM|NA|NR|NP|NL|NC|NZ|NI|NE|NG|NU|NF|MP|NO|OM|PK|PW|PS|PA|PG|PY|PE|PH|PN|PL|PT|PR|QA|RE|RO|RU|RW|BL|SH|KN|LC|MF|PM|VC|WS|SM|ST|SA|SN|RS|SC|SL|SG|SX|SK|SI|SB|SO|ZA|GS|SS|ES|LK|SD|SR|SJ|SZ|SE|CH|SY|TW|TJ|TZ|TH|TL|TG|TK|TO|TT|TN|TR|TM|TC|TV|UG|UA|AE|GB|US|UM|UY|UZ|VU|VE|VN|VG|VI|WF|EH|YE|ZM|ZW",validate:function(a,b){var c=b.val();if(""===c)return!0;c=c.toUpperCase();var d=new RegExp("^("+this.COUNTRY_CODES+")[0-9A-Z]{10}$");if(!d.test(c))return!1;for(var e="",f=c.length,g=0;f-1>g;g++){var h=c.charCodeAt(g);e+=h>57?(h-55).toString():c.charAt(g)}var i="",j=e.length,k=j%2!==0?0:1;for(g=0;j>g;g++)i+=parseInt(e[g],10)*(g%2===k?2:1)+"";var l=0;for(g=0;gh;h++)f+=parseInt(c.charAt(h),10)*g[h%2];return f=10-f%10,f+""===c.charAt(e-1)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.issn=a.extend(a.fn.bootstrapValidator.i18n.issn||{},{"default":"Please enter a valid ISSN number"}),a.fn.bootstrapValidator.validators.issn={validate:function(a,b){var c=b.val();if(""===c)return!0;if(!/^\d{4}\-\d{3}[\dX]$/.test(c))return!1;c=c.replace(/[^0-9X]/gi,"");var d=c.split(""),e=d.length,f=0;"X"===d[7]&&(d[7]=10);for(var g=0;e>g;g++)f+=parseInt(d[g],10)*(8-g);return f%11===0}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.lessThan=a.extend(a.fn.bootstrapValidator.i18n.lessThan||{},{"default":"Please enter a value less than or equal to %s",notInclusive:"Please enter a value less than %s"}),a.fn.bootstrapValidator.validators.lessThan={html5Attributes:{message:"message",value:"value",inclusive:"inclusive"},enableByHtml5:function(a){var b=a.attr("max");return b?{value:b}:!1},validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f=a.isNumeric(d.value)?d.value:b.getDynamicOption(c,d.value);return e=parseFloat(e),d.inclusive===!0||void 0===d.inclusive?{valid:f>=e,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.lessThan["default"],f)}:{valid:f>e,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.lessThan.notInclusive,f)}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.mac=a.extend(a.fn.bootstrapValidator.i18n.mac||{},{"default":"Please enter a valid MAC address"}),a.fn.bootstrapValidator.validators.mac={validate:function(a,b){var c=b.val();return""===c?!0:/^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$/.test(c)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.meid=a.extend(a.fn.bootstrapValidator.i18n.meid||{},{"default":"Please enter a valid MEID number"}),a.fn.bootstrapValidator.validators.meid={validate:function(b,c){var d=c.val();if(""===d)return!0;switch(!0){case/^[0-9A-F]{15}$/i.test(d):case/^[0-9A-F]{2}[- ][0-9A-F]{6}[- ][0-9A-F]{6}[- ][0-9A-F]$/i.test(d):case/^\d{19}$/.test(d):case/^\d{5}[- ]\d{5}[- ]\d{4}[- ]\d{4}[- ]\d$/.test(d):var e=d.charAt(d.length-1);if(d=d.replace(/[- ]/g,""),d.match(/^\d*$/i))return a.fn.bootstrapValidator.helpers.luhn(d);d=d.slice(0,-1);for(var f="",g=1;13>=g;g+=2)f+=(2*parseInt(d.charAt(g),16)).toString(16);var h=0;for(g=0;g0:""!==a.trim(c.val())}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.numeric=a.extend(a.fn.bootstrapValidator.i18n.numeric||{},{"default":"Please enter a valid float number"}),a.fn.bootstrapValidator.validators.numeric={html5Attributes:{message:"message",separator:"separator"},enableByHtml5:function(a){return"number"===a.attr("type")&&void 0!==a.attr("step")&&a.attr("step")%1!==0},validate:function(a,b,c){var d=b.val();if(""===d)return!0;var e=c.separator||".";return"."!==e&&(d=d.replace(e,".")),!isNaN(parseFloat(d))&&isFinite(d)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.phone=a.extend(a.fn.bootstrapValidator.i18n.phone||{},{"default":"Please enter a valid phone number",countryNotSupported:"The country code %s is not supported",country:"Please enter a valid phone number in %s",countries:{ES:"Spain",FR:"France",GB:"United Kingdom",US:"USA"}}),a.fn.bootstrapValidator.validators.phone={html5Attributes:{message:"message",country:"country"},COUNTRY_CODES:["ES","FR","GB","US"],validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f=d.country;if(("string"!=typeof f||-1===a.inArray(f,this.COUNTRY_CODES))&&(f=b.getDynamicOption(c,f)),!f||-1===a.inArray(f.toUpperCase(),this.COUNTRY_CODES))return{valid:!1,message:a.fn.bootstrapValidator.helpers.format(a.fn.bootstrapValidator.i18n.phone.countryNotSupported,f)};var g=!0;switch(f.toUpperCase()){case"ES":e=a.trim(e),g=/^(?:(?:(?:\+|00)34\D?))?(?:9|6)(?:\d\D?){8}$/.test(e);break;case"FR":e=a.trim(e),g=/^(?:(?:(?:\+|00)33\D?(?:\D?\(0\)\D?)?)|0){1}[1-9]{1}(?:\D?\d{2}){4}$/.test(e);break;case"GB":e=a.trim(e),g=/^\(?(?:(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?\(?(?:0\)?[\s-]?\(?)?|0)(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}|\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4}|\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3})|\d{5}\)?[\s-]?\d{4,5}|8(?:00[\s-]?11[\s-]?11|45[\s-]?46[\s-]?4\d))(?:(?:[\s-]?(?:x|ext\.?\s?|\#)\d+)?)$/.test(e);break;case"US":default:e=e.replace(/\D/g,""),g=/^(?:(1\-?)|(\+1 ?))?\(?(\d{3})[\)\-\.]?(\d{3})[\-\.]?(\d{4})$/.test(e)&&10===e.length}return{valid:g,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.phone.country,a.fn.bootstrapValidator.i18n.phone.countries[f])}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.regexp=a.extend(a.fn.bootstrapValidator.i18n.regexp||{},{"default":"Please enter a value matching the pattern"}),a.fn.bootstrapValidator.validators.regexp={html5Attributes:{message:"message",regexp:"regexp"},enableByHtml5:function(a){var b=a.attr("pattern");return b?{regexp:b}:!1},validate:function(a,b,c){var d=b.val();if(""===d)return!0;var e="string"==typeof c.regexp?new RegExp(c.regexp):c.regexp;return e.test(d)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.remote=a.extend(a.fn.bootstrapValidator.i18n.remote||{},{"default":"Please enter a valid value"}),a.fn.bootstrapValidator.validators.remote={html5Attributes:{message:"message",url:"url",name:"name"},validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f=c.attr("data-bv-field"),g=d.data||{},h=d.url,i=d.type||"POST";"function"==typeof g&&(g=g.call(this,b)),"function"==typeof h&&(h=h.call(this,b)),g[d.name||f]=e; +var j=new a.Deferred,k=a.ajax({type:i,url:h,dataType:"json",data:g});return k.then(function(a){j.resolve(c,"remote",a.valid===!0||"true"===a.valid,a.message?a.message:null)}),j.fail(function(){k.abort()}),j}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.rtn=a.extend(a.fn.bootstrapValidator.i18n.rtn||{},{"default":"Please enter a valid RTN number"}),a.fn.bootstrapValidator.validators.rtn={validate:function(a,b){var c=b.val();if(""===c)return!0;if(!/^\d{9}$/.test(c))return!1;for(var d=0,e=0;eg;g++)d+=e[g]*parseInt(c.charAt(g),36);return d=(10-d%10)%10,d+""===c.charAt(f-1)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.siren=a.extend(a.fn.bootstrapValidator.i18n.siren||{},{"default":"Please enter a valid SIREN number"}),a.fn.bootstrapValidator.validators.siren={validate:function(b,c){var d=c.val();return""===d?!0:/^\d{9}$/.test(d)?a.fn.bootstrapValidator.helpers.luhn(d):!1}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.siret=a.extend(a.fn.bootstrapValidator.i18n.siret||{},{"default":"Please enter a valid SIRET number"}),a.fn.bootstrapValidator.validators.siret={validate:function(a,b){var c=b.val();if(""===c)return!0;for(var d,e=0,f=c.length,g=0;f>g;g++)d=parseInt(c.charAt(g),10),g%2===0&&(d=2*d,d>9&&(d-=9)),e+=d;return e%10===0}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.step=a.extend(a.fn.bootstrapValidator.i18n.step||{},{"default":"Please enter a valid step of %s"}),a.fn.bootstrapValidator.validators.step={html5Attributes:{message:"message",base:"baseValue",step:"step"},validate:function(b,c,d){var e=c.val();if(""===e)return!0;if(d=a.extend({},{baseValue:0,step:1},d),e=parseFloat(e),!a.isNumeric(e))return!1;var f=function(a,b){var c=Math.pow(10,b);a*=c;var d=a>0|-(0>a),e=a%1===.5*d;return e?(Math.floor(a)+(d>0))/c:Math.round(a)/c},g=function(a,b){if(0===b)return 1;var c=(a+"").split("."),d=(b+"").split("."),e=(1===c.length?0:c[1].length)+(1===d.length?0:d[1].length);return f(a-b*Math.floor(a/b),e)},h=g(e-d.baseValue,d.step);return{valid:0===h||h===d.step,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.step["default"],[d.step])}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.stringCase=a.extend(a.fn.bootstrapValidator.i18n.stringCase||{},{"default":"Please enter only lowercase characters",upper:"Please enter only uppercase characters"}),a.fn.bootstrapValidator.validators.stringCase={html5Attributes:{message:"message","case":"case"},validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f=(d["case"]||"lower").toLowerCase();return{valid:"upper"===f?e===e.toUpperCase():e===e.toLowerCase(),message:d.message||("upper"===f?a.fn.bootstrapValidator.i18n.stringCase.upper:a.fn.bootstrapValidator.i18n.stringCase["default"])}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.stringLength=a.extend(a.fn.bootstrapValidator.i18n.stringLength||{},{"default":"Please enter a value with valid length",less:"Please enter less than %s characters",more:"Please enter more than %s characters",between:"Please enter value between %s and %s characters long"}),a.fn.bootstrapValidator.validators.stringLength={html5Attributes:{message:"message",min:"min",max:"max"},enableByHtml5:function(a){var b=a.attr("maxlength");return b?{max:parseInt(b,10)}:!1},validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f=a.isNumeric(d.min)?d.min:b.getDynamicOption(c,d.min),g=a.isNumeric(d.max)?d.max:b.getDynamicOption(c,d.max),h=e.length,i=!0,j=d.message||a.fn.bootstrapValidator.i18n.stringLength["default"];switch((f&&hparseInt(g,10))&&(i=!1),!0){case!!f&&!!g:j=a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.stringLength.between,[parseInt(f,10),parseInt(g,10)]);break;case!!f:j=a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.stringLength.more,parseInt(f,10));break;case!!g:j=a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.stringLength.less,parseInt(g,10))}return{valid:i,message:j}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.uri=a.extend(a.fn.bootstrapValidator.i18n.uri||{},{"default":"Please enter a valid URI"}),a.fn.bootstrapValidator.validators.uri={html5Attributes:{message:"message",allowlocal:"allowLocal"},enableByHtml5:function(a){return"url"===a.attr("type")},validate:function(a,b,c){var d=b.val();if(""===d)return!0;var e=c.allowLocal===!0||"true"===c.allowLocal,f=new RegExp("^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:"+(e?"":"(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})")+"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))"+(e?"?":"")+")(?::\\d{2,5})?(?:/[^\\s]*)?$","i");return f.test(d)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.uuid=a.extend(a.fn.bootstrapValidator.i18n.uuid||{},{"default":"Please enter a valid UUID number",version:"Please enter a valid UUID version %s number"}),a.fn.bootstrapValidator.validators.uuid={html5Attributes:{message:"message",version:"version"},validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i},g=d.version?d.version+"":"all";return{valid:null===f[g]?!0:f[g].test(e),message:d.version?a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.uuid.version,d.version):d.message||a.fn.bootstrapValidator.i18n.uuid["default"]}}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.vat=a.extend(a.fn.bootstrapValidator.i18n.vat||{},{"default":"Please enter a valid VAT number",countryNotSupported:"The country code %s is not supported",country:"Please enter a valid %s VAT number",countries:{AT:"Austrian",BE:"Belgian",BG:"Bulgarian",CH:"Swiss",CY:"Cypriot",CZ:"Czech",DE:"German",DK:"Danish",EE:"Estonian",ES:"Spanish",FI:"Finnish",FR:"French",GB:"United Kingdom",GR:"Greek",EL:"Greek",HU:"Hungarian",HR:"Croatian",IE:"Irish",IT:"Italian",LT:"Lithuanian",LU:"Luxembourg",LV:"Latvian",MT:"Maltese",NL:"Dutch",NO:"Norwegian",PL:"Polish",PT:"Portuguese",RO:"Romanian",RU:"Russian",RS:"Serbian",SE:"Swedish",SI:"Slovenian",SK:"Slovak"}}),a.fn.bootstrapValidator.validators.vat={html5Attributes:{message:"message",country:"country"},COUNTRY_CODES:["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","EL","HU","IE","IT","LV","LT","LU","MT","NL","NO","PL","PT","RO","RU","RS","SK","SI","ES","SE","CH","GB"],validate:function(b,c,d){var e=c.val();if(""===e)return!0;var f=d.country;if(f?("string"!=typeof f||-1===a.inArray(f.toUpperCase(),this.COUNTRY_CODES))&&(f=b.getDynamicOption(c,f)):f=e.substr(0,2),-1===a.inArray(f,this.COUNTRY_CODES))return{valid:!1,message:a.fn.bootstrapValidator.helpers.format(a.fn.bootstrapValidator.i18n.vat.countryNotSupported,f)};var g=["_",f.toLowerCase()].join("");return this[g](e)?!0:{valid:!1,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.vat.country,a.fn.bootstrapValidator.i18n.vat.countries[f.toUpperCase()])}},_at:function(a){if(!/^ATU[0-9]{8}$/.test(a))return!1;a=a.substr(3);for(var b=0,c=[1,2,1,2,1,2,1],d=0,e=0;7>e;e++)d=parseInt(a.charAt(e),10)*c[e],d>9&&(d=Math.floor(d/10)+d%10),b+=d;return b=10-(b+4)%10,10===b&&(b=0),b+""===a.substr(7,1)},_be:function(a){if(!/^BE[0]{0,1}[0-9]{9}$/.test(a))return!1;if(a=a.substr(2),9===a.length&&(a="0"+a),"0"===a.substr(1,1))return!1;var b=parseInt(a.substr(0,8),10)+parseInt(a.substr(8,2),10);return b%97===0},_bg:function(b){if(!/^BG[0-9]{9,10}$/.test(b))return!1;b=b.substr(2);var c=0,d=0;if(9===b.length){for(d=0;8>d;d++)c+=parseInt(b.charAt(d),10)*(d+1);if(c%=11,10===c)for(c=0,d=0;8>d;d++)c+=parseInt(b.charAt(d),10)*(d+3);return c%=10,c+""===b.substr(8)}if(10===b.length){var e=function(b){var c=parseInt(b.substr(0,2),10)+1900,d=parseInt(b.substr(2,2),10),e=parseInt(b.substr(4,2),10);if(d>40?(c+=100,d-=40):d>20&&(c-=100,d-=20),!a.fn.bootstrapValidator.helpers.date(c,d,e))return!1;for(var f=0,g=[2,4,8,5,10,9,7,3,6],h=0;9>h;h++)f+=parseInt(b.charAt(h),10)*g[h];return f=f%11%10,f+""===b.substr(9,1)},f=function(a){for(var b=0,c=[21,19,17,13,11,9,7,3,1],d=0;9>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b%=10,b+""===a.substr(9,1)},g=function(a){for(var b=0,c=[4,3,2,7,6,5,4,3,2],d=0;9>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b=11-b%11,10===b?!1:(11===b&&(b=0),b+""===a.substr(9,1))};return e(b)||f(b)||g(b)}return!1},_ch:function(a){if(!/^CHE[0-9]{9}(MWST)?$/.test(a))return!1;a=a.substr(3);for(var b=0,c=[5,4,3,2,7,6,5,4],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b=11-b%11,10===b?!1:(11===b&&(b=0),b+""===a.substr(8,1))},_cy:function(a){if(!/^CY[0-5|9]{1}[0-9]{7}[A-Z]{1}$/.test(a))return!1;if(a=a.substr(2),"12"===a.substr(0,2))return!1;for(var b=0,c={0:1,1:0,2:5,3:7,4:9,5:13,6:15,7:17,8:19,9:21},d=0;8>d;d++){var e=parseInt(a.charAt(d),10);d%2===0&&(e=c[e+""]),b+=e}return b="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[b%26],b+""===a.substr(8,1)},_cz:function(b){if(!/^CZ[0-9]{8,10}$/.test(b))return!1;b=b.substr(2);var c=0,d=0;if(8===b.length){if(b.charAt(0)+""=="9")return!1;for(c=0,d=0;7>d;d++)c+=parseInt(b.charAt(d),10)*(8-d);return c=11-c%11,10===c&&(c=0),11===c&&(c=1),c+""===b.substr(7,1)}if(9===b.length&&b.charAt(0)+""=="6"){for(c=0,d=0;7>d;d++)c+=parseInt(b.charAt(d+1),10)*(8-d);return c=11-c%11,10===c&&(c=0),11===c&&(c=1),c=[8,7,6,5,4,3,2,1,0,9,10][c-1],c+""===b.substr(8,1)}if(9===b.length||10===b.length){var e=1900+parseInt(b.substr(0,2),10),f=parseInt(b.substr(2,2),10)%50%20,g=parseInt(b.substr(4,2),10);if(9===b.length){if(e>=1980&&(e-=100),e>1953)return!1}else 1954>e&&(e+=100);if(!a.fn.bootstrapValidator.helpers.date(e,f,g))return!1;if(10===b.length){var h=parseInt(b.substr(0,9),10)%11;return 1985>e&&(h%=10),h+""===b.substr(9,1)}return!0}return!1},_de:function(b){return/^DE[0-9]{9}$/.test(b)?(b=b.substr(2),a.fn.bootstrapValidator.helpers.mod11And10(b)):!1},_dk:function(a){if(!/^DK[0-9]{8}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[2,7,6,5,4,3,2,1],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b%11===0},_ee:function(a){if(!/^EE[0-9]{9}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[3,7,1,3,7,1,3,7,1],d=0;9>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b%10===0},_es:function(a){if(!/^ES[0-9A-Z][0-9]{7}[0-9A-Z]$/.test(a))return!1;a=a.substr(2);var b=function(a){var b=parseInt(a.substr(0,8),10);return b="TRWAGMYFPDXBNJZSQVHLCKE"[b%23],b+""===a.substr(8,1)},c=function(a){var b=["XYZ".indexOf(a.charAt(0)),a.substr(1)].join("");return b=parseInt(b,10),b="TRWAGMYFPDXBNJZSQVHLCKE"[b%23],b+""===a.substr(8,1)},d=function(a){var b,c=a.charAt(0);if(-1!=="KLM".indexOf(c))return b=parseInt(a.substr(1,8),10),b="TRWAGMYFPDXBNJZSQVHLCKE"[b%23],b+""===a.substr(8,1);if(-1!=="ABCDEFGHJNPQRSUVW".indexOf(c)){for(var d=0,e=[2,1,2,1,2,1,2],f=0,g=0;7>g;g++)f=parseInt(a.charAt(g+1),10)*e[g],f>9&&(f=Math.floor(f/10)+f%10),d+=f;return d=10-d%10,d+""===a.substr(8,1)||"JABCDEFGHI"[d]===a.substr(8,1)}return!1},e=a.charAt(0);return/^[0-9]$/.test(e)?b(a):/^[XYZ]$/.test(e)?c(a):d(a)},_fi:function(a){if(!/^FI[0-9]{8}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[7,9,10,5,8,4,2,1],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b%11===0},_fr:function(b){if(!/^FR[0-9A-Z]{2}[0-9]{9}$/.test(b))return!1;if(b=b.substr(2),!a.fn.bootstrapValidator.helpers.luhn(b.substr(2)))return!1;if(/^[0-9]{2}$/.test(b.substr(0,2)))return b.substr(0,2)===parseInt(b.substr(2)+"12",10)%97+"";var c,d="0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";return c=/^[0-9]{1}$/.test(b.charAt(0))?24*d.indexOf(b.charAt(0))+d.indexOf(b.charAt(1))-10:34*d.indexOf(b.charAt(0))+d.indexOf(b.charAt(1))-100,(parseInt(b.substr(2),10)+1+Math.floor(c/11))%11===c%11},_gb:function(a){if(!(/^GB[0-9]{9}$/.test(a)||/^GB[0-9]{12}$/.test(a)||/^GBGD[0-9]{3}$/.test(a)||/^GBHA[0-9]{3}$/.test(a)||/^GB(GD|HA)8888[0-9]{5}$/.test(a)))return!1;a=a.substr(2);var b=a.length;if(5===b){var c=a.substr(0,2),d=parseInt(a.substr(2),10);return"GD"===c&&500>d||"HA"===c&&d>=500}if(11===b&&("GD8888"===a.substr(0,6)||"HA8888"===a.substr(0,6)))return"GD"===a.substr(0,2)&&parseInt(a.substr(6,3),10)>=500||"HA"===a.substr(0,2)&&parseInt(a.substr(6,3),10)<500?!1:parseInt(a.substr(6,3),10)%97===parseInt(a.substr(9,2),10);if(9===b||12===b){for(var e=0,f=[8,7,6,5,4,3,2,10,1],g=0;9>g;g++)e+=parseInt(a.charAt(g),10)*f[g];return e%=97,parseInt(a.substr(0,3),10)>=100?0===e||42===e||55===e:0===e}return!0},_gr:function(a){if(!/^GR[0-9]{9}$/.test(a))return!1;a=a.substr(2),8===a.length&&(a="0"+a);for(var b=0,c=[256,128,64,32,16,8,4,2],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b=b%11%10,b+""===a.substr(8,1)},_el:function(a){return/^EL[0-9]{9}$/.test(a)?(a="GR"+a.substr(2),this._gr(a)):!1},_hu:function(a){if(!/^HU[0-9]{8}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[9,7,3,1,9,7,3,1],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b%10===0},_hr:function(b){return/^HR[0-9]{11}$/.test(b)?(b=b.substr(2),a.fn.bootstrapValidator.helpers.mod11And10(b)):!1},_ie:function(a){if(!/^IE[0-9]{1}[0-9A-Z\*\+]{1}[0-9]{5}[A-Z]{1,2}$/.test(a))return!1;a=a.substr(2);var b=function(a){for(;a.length<7;)a="0"+a;for(var b="WABCDEFGHIJKLMNOPQRSTUV",c=0,d=0;7>d;d++)c+=parseInt(a.charAt(d),10)*(8-d);return c+=9*b.indexOf(a.substr(7)),b[c%23]};return/^[0-9]+$/.test(a.substr(0,7))?a.charAt(7)===b(a.substr(0,7)+a.substr(8)+""):-1!=="ABCDEFGHIJKLMNOPQRSTUVWXYZ+*".indexOf(a.charAt(1))?a.charAt(7)===b(a.substr(2,5)+a.substr(0,1)+""):!0},_it:function(b){if(!/^IT[0-9]{11}$/.test(b))return!1;if(b=b.substr(2),0===parseInt(b.substr(0,7),10))return!1;var c=parseInt(b.substr(7,3),10);return 1>c||c>201&&999!==c&&888!==c?!1:a.fn.bootstrapValidator.helpers.luhn(b)},_lt:function(a){if(!/^LT([0-9]{7}1[0-9]{1}|[0-9]{10}1[0-9]{1})$/.test(a))return!1;a=a.substr(2);var b,c=a.length,d=0;for(b=0;c-1>b;b++)d+=parseInt(a.charAt(b),10)*(1+b%9);var e=d%11;if(10===e)for(d=0,b=0;c-1>b;b++)d+=parseInt(a.charAt(b),10)*(1+(b+2)%9);return e=e%11%10,e+""===a.charAt(c-1)},_lu:function(a){return/^LU[0-9]{8}$/.test(a)?(a=a.substr(2),parseInt(a.substr(0,6),10)%89+""===a.substr(6,2)):!1},_lv:function(b){if(!/^LV[0-9]{11}$/.test(b))return!1;b=b.substr(2);var c,d=parseInt(b.charAt(0),10),e=0,f=[],g=b.length;if(d>3){for(e=0,f=[9,1,4,8,3,10,2,5,7,6,1],c=0;g>c;c++)e+=parseInt(b.charAt(c),10)*f[c];return e%=11,3===e}var h=parseInt(b.substr(0,2),10),i=parseInt(b.substr(2,2),10),j=parseInt(b.substr(4,2),10);if(j=j+1800+100*parseInt(b.charAt(6),10),!a.fn.bootstrapValidator.helpers.date(j,i,h))return!1;for(e=0,f=[10,5,8,4,2,1,6,3,7,9],c=0;g-1>c;c++)e+=parseInt(b.charAt(c),10)*f[c];return e=(e+1)%11%10,e+""===b.charAt(g-1)},_mt:function(a){if(!/^MT[0-9]{8}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[3,4,6,7,8,9,10,1],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b%37===0},_nl:function(a){if(!/^NL[0-9]{9}B[0-9]{2}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[9,8,7,6,5,4,3,2],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b%=11,b>9&&(b=0),b+""===a.substr(8,1)},_no:function(a){if(!/^NO[0-9]{9}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[3,2,7,6,5,4,3,2],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b=11-b%11,11===b&&(b=0),b+""===a.substr(8,1)},_pl:function(a){if(!/^PL[0-9]{10}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[6,5,7,2,3,4,5,6,7,-1],d=0;10>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b%11===0},_pt:function(a){if(!/^PT[0-9]{9}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[9,8,7,6,5,4,3,2],d=0;8>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b=11-b%11,b>9&&(b=0),b+""===a.substr(8,1)},_ro:function(a){if(!/^RO[1-9][0-9]{1,9}$/.test(a))return!1;a=a.substr(2);for(var b=a.length,c=[7,5,3,2,1,7,5,3,2].slice(10-b),d=0,e=0;b-1>e;e++)d+=parseInt(a.charAt(e),10)*c[e];return d=10*d%11%10,d+""===a.substr(b-1,1)},_ru:function(a){if(!/^RU([0-9]{9}|[0-9]{12})$/.test(a))return!1;a=a.substr(2);var b=0;if(10===a.length){var c=0,d=[2,4,10,3,5,9,4,6,8,0];for(b=0;10>b;b++)c+=parseInt(a.charAt(b),10)*d[b];return c%=11,c>9&&(c%=10),c+""===a.substr(9,1)}if(12===a.length){var e=0,f=[7,2,4,10,3,5,9,4,6,8,0],g=0,h=[3,7,2,4,10,3,5,9,4,6,8,0];for(b=0;11>b;b++)e+=parseInt(a.charAt(b),10)*f[b],g+=parseInt(a.charAt(b),10)*h[b];return e%=11,e>9&&(e%=10),g%=11,g>9&&(g%=10),e+""===a.substr(10,1)&&g+""===a.substr(11,1)}return!1},_rs:function(a){if(!/^RS[0-9]{9}$/.test(a))return!1;a=a.substr(2);for(var b=10,c=0,d=0;8>d;d++)c=(parseInt(a.charAt(d),10)+b)%10,0===c&&(c=10),b=2*c%11;return(b+parseInt(a.substr(8,1),10))%10===1},_se:function(b){return/^SE[0-9]{10}01$/.test(b)?(b=b.substr(2,10),a.fn.bootstrapValidator.helpers.luhn(b)):!1},_si:function(a){if(!/^SI[0-9]{8}$/.test(a))return!1;a=a.substr(2);for(var b=0,c=[8,7,6,5,4,3,2],d=0;7>d;d++)b+=parseInt(a.charAt(d),10)*c[d];return b=11-b%11,10===b&&(b=0),b+""===a.substr(7,1)},_sk:function(a){return/^SK[1-9][0-9][(2-4)|(6-9)][0-9]{7}$/.test(a)?parseInt(a.substr(2),10)%11===0:!1}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.vin=a.extend(a.fn.bootstrapValidator.i18n.vin||{},{"default":"Please enter a valid VIN number"}),a.fn.bootstrapValidator.validators.vin={validate:function(a,b){var c=b.val();if(""===c)return!0;if(!/^[a-hj-npr-z0-9]{8}[0-9xX][a-hj-npr-z0-9]{8}$/i.test(c))return!1;c=c.toUpperCase();for(var d={A:1,B:2,C:3,D:4,E:5,F:6,G:7,H:8,J:1,K:2,L:3,M:4,N:5,P:7,R:9,S:2,T:3,U:4,V:5,W:6,X:7,Y:8,Z:9,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,0:0},e=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2],f=0,g=c.length,h=0;g>h;h++)f+=d[c.charAt(h)+""]*e[h];var i=f%11;return 10===i&&(i="X"),i+""===c.charAt(8)}}}(window.jQuery),function(a){a.fn.bootstrapValidator.i18n.zipCode=a.extend(a.fn.bootstrapValidator.i18n.zipCode||{},{"default":"Please enter a valid zip code",countryNotSupported:"The country code %s is not supported",country:"Please enter a valid %s",countries:{CA:"Canadian postal code",DK:"Danish postal code",GB:"United Kingdom postal code",IT:"Italian postal code",NL:"Dutch postal code",SE:"Swiss postal code",SG:"Singapore postal code",US:"US zip code"}}),a.fn.bootstrapValidator.validators.zipCode={html5Attributes:{message:"message",country:"country"},COUNTRY_CODES:["CA","DK","GB","IT","NL","SE","SG","US"],validate:function(b,c,d){var e=c.val();if(""===e||!d.country)return!0;var f=d.country;if(("string"!=typeof f||-1===a.inArray(f,this.COUNTRY_CODES))&&(f=b.getDynamicOption(c,f)),!f||-1===a.inArray(f.toUpperCase(),this.COUNTRY_CODES))return{valid:!1,message:a.fn.bootstrapValidator.helpers.format(a.fn.bootstrapValidator.i18n.zipCode.countryNotSupported,f)};var g=!1;switch(f=f.toUpperCase()){case"CA":g=/^(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}\s?[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}[0-9]{1}$/i.test(e);break;case"DK":g=/^(DK(-|\s)?)?\d{4}$/i.test(e);break;case"GB":g=this._gb(e);break;case"IT":g=/^(I-|IT-)?\d{5}$/i.test(e);break;case"NL":g=/^[1-9][0-9]{3} ?(?!sa|sd|ss)[a-z]{2}$/i.test(e);break;case"SE":g=/^(S-)?\d{3}\s?\d{2}$/i.test(e);break;case"SG":g=/^([0][1-9]|[1-6][0-9]|[7]([0-3]|[5-9])|[8][0-2])(\d{4})$/i.test(e);break;case"US":default:g=/^\d{4,5}([\-]?\d{4})?$/.test(e)}return{valid:g,message:a.fn.bootstrapValidator.helpers.format(d.message||a.fn.bootstrapValidator.i18n.zipCode.country,a.fn.bootstrapValidator.i18n.zipCode.countries[f])}},_gb:function(a){for(var b="[ABCDEFGHIJKLMNOPRSTUWYZ]",c="[ABCDEFGHKLMNOPQRSTUVWXY]",d="[ABCDEFGHJKPMNRSTUVWXY]",e="[ABEHMNPRVWXY]",f="[ABDEFGHJLNPQRSTUWXYZ]",g=[new RegExp("^("+b+"{1}"+c+"?[0-9]{1,2})(\\s*)([0-9]{1}"+f+"{2})$","i"),new RegExp("^("+b+"{1}[0-9]{1}"+d+"{1})(\\s*)([0-9]{1}"+f+"{2})$","i"),new RegExp("^("+b+"{1}"+c+"{1}?[0-9]{1}"+e+"{1})(\\s*)([0-9]{1}"+f+"{2})$","i"),new RegExp("^(BF1)(\\s*)([0-6]{1}[ABDEFGHJLNPQRST]{1}[ABDEFGHJLNPQRSTUWZYZ]{1})$","i"),/^(GIR)(\s*)(0AA)$/i,/^(BFPO)(\s*)([0-9]{1,4})$/i,/^(BFPO)(\s*)(c\/o\s*[0-9]{1,3})$/i,/^([A-Z]{4})(\s*)(1ZZ)$/i,/^(AI-2640)$/i],h=0;h ACCOUNT_TYPE_APP_NORMAL))); + } +} + +$account_all_type = uni_account_type(); +$account_all_type_sign = uni_account_type_sign(); +$account_param = WeAccount::create(array('type' => $_GPC['account_type'])); +define('ACCOUNT_TYPE', $account_param->type); +define('TYPE_SIGN', $account_param->typeSign); +define('ACCOUNT_TYPE_NAME', $account_param->typeName); +define('ACCOUNT_TYPE_TEMPLATE', $account_param->typeTempalte); diff --git a/web/source/account/auth.ctrl.php b/web/source/account/auth.ctrl.php new file mode 100644 index 0000000..f5a8b7c --- /dev/null +++ b/web/source/account/auth.ctrl.php @@ -0,0 +1,204 @@ +func('communication'); +load()->classs('weixin.platform'); +load()->model('account'); +set_time_limit(0); + +$dos = array('ticket', 'forward', 'test', 'confirm'); +$do = in_array($do, $dos) ? $do : 'forward'; + +$account_platform = new WeixinPlatform(); + +if ('forward' == $do) { + if (empty($_GPC['auth_code'])) { + itoast('授权登录失败,请重试', url('account/manage'), 'error'); + } + $auth_info = $account_platform->getAuthInfo($_GPC['auth_code']); + if (is_error($auth_info)) { + itoast('授权登录新建公众号失败:' . $auth_info['message'], url('account/manage'), 'error'); + } + $auth_refresh_token = $auth_info['authorization_info']['authorizer_refresh_token']; + $auth_appid = $auth_info['authorization_info']['authorizer_appid']; + + $account_info = $account_platform->getAuthorizerInfo($auth_appid); + if (is_error($account_info)) { + itoast('授权登录新建公众号失败:' . $account_info['message'], url('account/manage'), 'error'); + } + if (!empty($_GPC['test'])) { + echo "此为测试平台接入返回结果:
    公众号名称:{$account_info['authorizer_info']['nick_name']}
    接入状态:成功"; + exit; + } + if ($account_info['authorizer_info']['service_type_info']['id'] == '0' || $account_info['authorizer_info']['service_type_info']['id'] == '1') { + if ($account_info['authorizer_info']['verify_type_info']['id'] > '-1') { + $level = '3'; + } else { + $level = '1'; + } + } elseif ($account_info['authorizer_info']['service_type_info']['id'] == '2') { + if ($account_info['authorizer_info']['verify_type_info']['id'] > '-1') { + $level = '4'; + } else { + $level = '2'; + } + } + $account_found = $account_platform->fetchSameAccountByAppid($auth_appid); + if (!empty($account_found)) { + message('公众号已经在系统中接入,是否要更改为授权接入方式?
      
    ', '', 'tips'); + } + $account_insert = array( + 'name' => $account_info['authorizer_info']['nick_name'], + 'description' => '', + 'groupid' => 0, + ); + $insert_result = table('uni_account')->fill($account_insert)->save(); + if (!$insert_result) { + itoast('授权登录新建公众号失败,请重试', url('account/manage'), 'error'); + } + $uniacid = pdo_insertid(); + $template = table('modules')->getTemplateByName('default'); + $style_insert = array( + 'uniacid' => $uniacid, + 'templateid' => $template['mid'], + 'name' => $template['title'] . '_' . random(4), + ); + table('site_styles')->fill($style_insert)->save(); + $styleid = pdo_insertid(); + + $multi_insert = array( + 'uniacid' => $uniacid, + 'title' => $account_insert['name'], + 'styleid' => $styleid, + ); + table('site_multi')->fill($multi_insert)->save(); + $multi_id = pdo_insertid(); + + $unisetting_insert = array( + 'creditnames' => iserializer(array( + 'credit1' => array('title' => '积分', 'enabled' => 1), + 'credit2' => array('title' => '余额', 'enabled' => 1), + )), + 'creditbehaviors' => iserializer(array( + 'activity' => 'credit1', + 'currency' => 'credit2', + )), + 'uniacid' => $uniacid, + 'default_site' => $multi_id, + 'sync' => iserializer(array('switch' => 0, 'acid' => '')), + ); + pdo_insert('uni_settings', $unisetting_insert); + table('mc_groups')->fill(array('uniacid' => $uniacid, 'title' => '默认会员组', 'isdefault' => 1))->save(); + + $account_index_insert = array( + 'uniacid' => $uniacid, + 'type' => ACCOUNT_OAUTH_LOGIN, + 'hash' => random(8), + 'isconnect' => 1, + ); + if (!$_W['isadmin'] && $_W['user']['endtime'] > USER_ENDTIME_GROUP_UNLIMIT_TYPE) { + $account_index_insert['endtime'] = $_W['user']['endtime']; + } + table('account')->fill($account_index_insert)->save(); + $acid = pdo_insertid(); + if (is_error($acid)) { + itoast('授权登录新建公众号失败,请重试', url('account/manage'), 'error'); + } + $subaccount_insert = array( + 'acid' => $acid, + 'uniacid' => $uniacid, + 'name' => $account_insert['name'], + 'account' => $account_info['authorizer_info']['alias'], + 'original' => $account_info['authorizer_info']['user_name'], + 'level' => $level, + 'key' => $auth_appid, + 'auth_refresh_token' => $auth_refresh_token, + 'encodingaeskey' => $account_platform->encodingaeskey, + 'token' => $account_platform->token, + ); + pdo_insert('account_wechats', $subaccount_insert); + $user_create_account_info = permission_user_account_num(); + if (empty($_W['isfounder']) && empty($user_create_account_info["usergroup_account_limit"])) { + pdo_insert('site_store_create_account', array('endtime' => strtotime('+1 month', time()), 'uid' => $_W['uid'], 'uniacid' => $uniacid, 'type' => ACCOUNT_TYPE_OFFCIAL_AUTH)); + } + if (user_is_vice_founder()) { + uni_account_user_role_insert($uniacid, $_W['uid'], ACCOUNT_MANAGE_NAME_VICE_FOUNDER); + } + if (empty($_W['isfounder'])) { + uni_account_user_role_insert($uniacid, $_W['uid'], ACCOUNT_MANAGE_NAME_OWNER); + if (!empty($_W['user']['owner_uid'])) { + uni_account_user_role_insert($uniacid, $_W['user']['owner_uid'], ACCOUNT_MANAGE_NAME_VICE_FOUNDER); + } + } + pdo_update('uni_account', array('default_acid' => $acid, 'logo' => $account_info['authorizer_info']['head_img'], 'qrcode' => $account_info['authorizer_info']['qrcode_url']), array('uniacid' => $uniacid)); + $headimg = ihttp_request($account_info['authorizer_info']['head_img']); + $qrcode = ihttp_request($account_info['authorizer_info']['qrcode_url']); + file_put_contents(IA_ROOT . '/attachment/headimg_' . $acid . '.jpg', $headimg['content']); + file_put_contents(IA_ROOT . '/attachment/qrcode_' . $acid . '.jpg', $qrcode['content']); + + cache_build_account($uniacid); + cache_delete(cache_system_key('proxy_wechatpay_account')); + cache_clean(cache_system_key('user_accounts')); + itoast('授权登录成功', url('account/manage'), 'success'); +} +if ('confirm' == $do) { + $auth_refresh_token = $_GPC['auth_refresh_token']; + $auth_appid = $_GPC['auth_appid']; + $level = intval($_GPC['level']); + $uniacid = intval($_GPC['uniacid']); + + if ($_W['isfounder']) { + $user_accounts = table('account')->getAll(); + } else { + $user_accounts = uni_user_accounts($_W['uid']); + } + $user_accounts = array_column($user_accounts, 'uniacid'); + if (empty($user_accounts) || !in_array($uniacid, $user_accounts)) { + itoast('账号或用户信息错误!', url('account/post', array('uniacid' => $uniacid)), 'error'); + } + + $account_wechats_data = array( + 'auth_refresh_token' => $auth_refresh_token, + 'encodingaeskey' => $account_platform->encodingaeskey, + 'token' => $account_platform->token, + 'level' => $level, + 'key' => $auth_appid, + ); + table('account_wechats')->where(array('uniacid' => $uniacid))->fill($account_wechats_data)->save(); + $account_index_insert = array( + 'isdeleted' => 0, + 'type' => ACCOUNT_OAUTH_LOGIN, + 'isconnect' => 1, + ); + if (!$_W['isadmin'] && $_W['user']['endtime'] > USER_ENDTIME_GROUP_UNLIMIT_TYPE) { + $account_index_insert['endtime'] = $_W['user']['endtime']; + } + table('account')->where(array('uniacid' => $uniacid))->fill($account_index_insert)->save(); + cache_delete(cache_system_key('uniaccount', array('uniacid' => $uniacid))); + cache_delete(cache_system_key('accesstoken', array('uniacid' => $uniacid))); + cache_delete(cache_system_key('account_auth_refreshtoken', array('uniacid' => $uniacid))); + itoast('更改公众号授权接入成功', url('account/post', array('uniacid' => $uniacid)), 'success'); +} +if ('ticket' == $do) { + $post = file_get_contents('php://input'); + WeUtility::logging('debug', 'account-ticket' . $post); + $encode_ticket = isimplexml_load_string($post, 'SimpleXMLElement', LIBXML_NOCDATA); + if (empty($post) || empty($encode_ticket) || strval($encode_ticket->AppId) != $_W['setting']['platform']['appid']) { + exit('fail'); + } + $decode_ticket = aes_decode($encode_ticket->Encrypt, $account_platform->encodingaeskey); + $ticket_xml = isimplexml_load_string($decode_ticket, 'SimpleXMLElement', LIBXML_NOCDATA); + if (empty($ticket_xml)) { + exit('fail'); + } + if (!empty($ticket_xml->ComponentVerifyTicket) && 'component_verify_ticket' == $ticket_xml->InfoType) { + $ticket = strval($ticket_xml->ComponentVerifyTicket); + setting_save($ticket, 'account_ticket'); + } + exit('success'); +} +if ('test' == $do) { + $authurl = $account_platform->getAuthLoginUrl(); + echo ''; +} \ No newline at end of file diff --git a/web/source/cloud/__init.php b/web/source/cloud/__init.php new file mode 100644 index 0000000..6623a10 --- /dev/null +++ b/web/source/cloud/__init.php @@ -0,0 +1,3 @@ + ['auth', 'auth'], + 'auth_upgrade' => ['upgrade', 'auth'], + 'auth_upgrade_log' => ['upgrade_log', 'auth'], + 'app_info' => ['index', 'plugin'], + 'app_pem' => ['account_list', 'plugin'], + 'db_m' => ['datemana', 'database'], + 'db_sql' => ['run', 'database'], + 'set_info' => ['base', 'wlsysset'], + 'set_que' => ['taskcover', 'wlsysset'], + 'set_url' => ['jumpadmin', 'wlsysset'], +); +$do = in_array($do, array_keys($dos)) ? $do : 'auth_info'; + +$url = url('site/entry/' . $dos[$do][0], ['m' => MODULE_NAME, 'p' => 'cloud', 'ac' => $dos[$do][1], 'lct' => 'wl'], true); + +template('cloud/index'); \ No newline at end of file diff --git a/web/source/site/__init.php b/web/source/site/__init.php new file mode 100644 index 0000000..1b97d7a --- /dev/null +++ b/web/source/site/__init.php @@ -0,0 +1,23 @@ +checkIntoManage(); + + if (is_error($check_manange)) { + itoast('', $account_api->displayUrl); + } + $account_type = $account_api->menuFrame; + if (!('multi' == $action && 'post' == $do)) { + define('FRAME', $account_type); + } else { + define('FRAME', ''); + } +} else { + define('FRAME', 'account'); +} \ No newline at end of file diff --git a/web/source/system/__init.php b/web/source/system/__init.php new file mode 100644 index 0000000..3d6e872 --- /dev/null +++ b/web/source/system/__init.php @@ -0,0 +1,16 @@ +model('setting'); +load()->model('attachment'); + +$dos = array('attachment', 'remote', 'buckets', 'oss', 'cos', 'qiniu', 'ftp', 'upload_remote'); +$do = in_array($do, $dos) ? $do : 'global'; + +if ('upload_remote' == $do) { + if (!empty($_W['setting']['remote_complete_info']['type'])) { + $_W['setting']['remote'] = $_W['setting']['remote_complete_info']; + $result = file_dir_remote_upload(ATTACHMENT_ROOT . 'images'); + if (is_error($result)) { + iajax(-1, $result['message']); + } else { + if (file_dir_exist_image(ATTACHMENT_ROOT . 'images')) { + iajax(0, array('status' => 1)); + } else { + iajax(0, array('status' => 0, 'message' => '完成')); + } + } + } else { + iajax(-1, '请先填写并开启远程附件设置'); + } +} + +if ('global' == $do) { + if (empty($_W['setting']['upload'])) { + $upload = $_W['config']['upload']; + } else { + $upload = $_W['setting']['upload']; + } + $post_max_size = ini_get('post_max_size'); + $post_max_size = $post_max_size > 0 ? bytecount($post_max_size) / 1024 : 0; + $upload_max_filesize = ini_get('upload_max_filesize'); + if ($_W['ispost']) { + $harmtype = array('asp', 'php', 'jsp', 'js', 'css', 'php3', 'php4', 'php5', 'ashx', 'aspx', 'exe', 'cgi'); + + switch ($_GPC['key']) { + case 'attachment_limit': + $upload['attachment_limit'] = max(0, intval($_GPC['value'])); break; + case 'image_thumb': + $upload['image']['thumb'] = empty($_GPC['value']) ? 0 : 1; + break; + case 'image_width': + $upload['image']['width'] = intval($_GPC['value']); break; + case 'image_extentions': + $upload['image']['extentions'] = array(); + $image_extentions = explode("\n", safe_gpc_string($_GPC['value'])); + foreach ($image_extentions as $item) { + $item = safe_gpc_string(trim($item)); + if (!empty($item) && !in_array($item, $harmtype) && !in_array($item, $upload['image']['extentions'])) { + $upload['image']['extentions'][] = $item; + } + } + break; + case 'image_limit': + $upload['image']['limit'] = max(0, min(intval($_GPC['value']), $post_max_size)); break; + case 'image_zip_percentage': + $zip_percentage = intval($_GPC['value']); + $upload['image']['zip_percentage'] = $zip_percentage; + if ($zip_percentage <= 0 || $zip_percentage > 100) { + $upload['image']['zip_percentage'] = 100; } + break; + case 'audio_extentions': + $upload['audio']['extentions'] = array(); + $audio_extentions = explode("\n", safe_gpc_string($_GPC['value'])); + foreach ($audio_extentions as $item) { + $item = safe_gpc_string(trim($item)); + if (!empty($item) && !in_array($item, $harmtype) && !in_array($item, $upload['audio']['extentions'])) { + $upload['audio']['extentions'][] = $item; + } + } + break; + case 'audio_limit': + $upload['audio']['limit'] = max(0, min(intval($_GPC['value']), $post_max_size)); break; + } + setting_save($upload, 'upload'); + iajax(0, '更新设置成功', url('system/attachment')); + } + + if (empty($upload['image']['thumb'])) { + $upload['image']['thumb'] = 0; + } else { + $upload['image']['thumb'] = 1; + } + $upload['image']['width'] = intval($upload['image']['width']); + if (empty($upload['image']['width'])) { + $upload['image']['width'] = 800; + } + if (!empty($upload['image']['extentions']) && is_array($upload['image']['extentions'])) { + $upload['image']['extentions'] = implode("\n", $upload['image']['extentions']); + } + if (!empty($upload['audio']['extentions']) && is_array($upload['audio']['extentions'])) { + $upload['audio']['extentions'] = implode("\n", $upload['audio']['extentions']); + } + if (empty($upload['image']['zip_percentage'])) { + $upload['image']['zip_percentage'] = 100; + } + + if ($_W['isajax']) { + $message = array( + 'upload_max_filesize' => $upload_max_filesize, + 'post_max_size' => $post_max_size, + 'upload' => $upload + ); + iajax(0, $message); + } +} + +if ('remote' == $do) { + $remote = $_W['setting']['remote_complete_info']; + $remote_urls = array( + 'alioss' => array('old_url' => $remote['alioss']['url']), + 'ftp' => array('old_url' => $remote['ftp']['url']), + 'qiniu' => array('old_url' => $remote['qiniu']['url']), + 'cos' => array('old_url' => $remote['cos']['url']), + ); + + if ($_W['ispost']) { + $remote = array( + 'type' => intval($_GPC['type']), + 'ftp' => array( + 'ssl' => intval($_GPC['ftp']['ssl']), + 'host' => $_GPC['ftp']['host'], + 'port' => $_GPC['ftp']['port'], + 'username' => $_GPC['ftp']['username'], + 'password' => strexists($_GPC['ftp']['password'], '*') ? $_W['setting']['remote_complete_info']['ftp']['password'] : $_GPC['ftp']['password'], + 'pasv' => intval($_GPC['ftp']['pasv']), + 'dir' => $_GPC['ftp']['dir'], + 'url' => $_GPC['ftp']['url'], + 'overtime' => intval($_GPC['ftp']['overtime']), + ), + 'alioss' => array( + 'key' => $_GPC['alioss']['key'], + 'secret' => strexists($_GPC['alioss']['secret'], '*') ? $_W['setting']['remote_complete_info']['alioss']['secret'] : $_GPC['alioss']['secret'], + 'bucket' => $_GPC['alioss']['bucket'], + 'internal' => $_GPC['alioss']['internal'], + ), + 'qiniu' => array( + 'accesskey' => trim($_GPC['qiniu']['accesskey']), + 'secretkey' => strexists($_GPC['qiniu']['secretkey'], '*') ? $_W['setting']['remote_complete_info']['qiniu']['secretkey'] : trim($_GPC['qiniu']['secretkey']), + 'bucket' => trim($_GPC['qiniu']['bucket']), + 'url' => trim($_GPC['qiniu']['url']), + ), + 'cos' => array( + 'appid' => trim($_GPC['cos']['appid']), + 'secretid' => trim($_GPC['cos']['secretid']), + 'secretkey' => strexists(trim($_GPC['cos']['secretkey']), '*') ? $_W['setting']['remote_complete_info']['cos']['secretkey'] : trim($_GPC['cos']['secretkey']), + 'bucket' => trim($_GPC['cos']['bucket']), + 'local' => trim($_GPC['cos']['local']), + 'url' => trim($_GPC['cos']['url']), + ), + ); + if (ATTACH_OSS == $remote['type']) { + if ('' == trim($remote['alioss']['key'])) { + if ($_W['isajax']) { + iajax(-1, '阿里云OSS-Access Key ID不能为空'); + } + itoast('阿里云OSS-Access Key ID不能为空', '', ''); + } + if ('' == trim($remote['alioss']['secret'])) { + if ($_W['isajax']) { + iajax(-1, '阿里云OSS-Access Key Secret不能为空'); + } + itoast('阿里云OSS-Access Key Secret不能为空', '', ''); + } + $buckets = attachment_alioss_buctkets($remote['alioss']['key'], $remote['alioss']['secret']); + if (is_error($buckets)) { + if ($_W['isajax']) { + iajax(-1, 'OSS-Access Key ID 或 OSS-Access Key Secret错误,请重新填写'); + } + itoast('OSS-Access Key ID 或 OSS-Access Key Secret错误,请重新填写', '', ''); + } + list($remote['alioss']['bucket'], $remote['alioss']['url']) = explode('@@', $_GPC['alioss']['bucket']); + if (empty($buckets[$remote['alioss']['bucket']])) { + if ($_W['isajax']) { + iajax(-1, 'Bucket不存在或是已经被删除'); + } + itoast('Bucket不存在或是已经被删除', '', ''); + } + $remote['alioss']['url'] = 'http://' . $remote['alioss']['bucket'] . '.' . $buckets[$remote['alioss']['bucket']]['location'] . '.aliyuncs.com'; + $remote['alioss']['ossurl'] = $buckets[$remote['alioss']['bucket']]['location'] . '.aliyuncs.com'; + if (!empty($_GPC['custom']['url'])) { + $url = trim($_GPC['custom']['url'], '/'); + if (!strexists($url, 'http://') && !strexists($url, 'https://')) { + $url = 'http://' . $url; + } + $remote['alioss']['url'] = $url; + } + attachment_replace_article_remote_url($remote_urls['alioss']['old_url'], $remote['alioss']['url']); + } elseif (ATTACH_FTP == $remote['type']) { + if (empty($remote['ftp']['host'])) { + if ($_W['isajax']) { + iajax(-1, 'FTP服务器地址为必填项.'); + } + itoast('FTP服务器地址为必填项.', '', ''); + } + if (empty($remote['ftp']['username'])) { + if ($_W['isajax']) { + iajax(-1, 'FTP帐号为必填项.'); + } + itoast('FTP帐号为必填项.', '', ''); + } + if (empty($remote['ftp']['password'])) { + if ($_W['isajax']) { + iajax(-1, 'FTP密码为必填项.'); + } + itoast('FTP密码为必填项.', '', ''); + } + attachment_replace_article_remote_url($remote_urls['ftp']['old_url'], $_GPC['ftp']['url']); + } elseif (ATTACH_QINIU == $remote['type']) { + if (empty($remote['qiniu']['accesskey'])) { + if ($_W['isajax']) iajax(-1, '请填写Accesskey.'); + itoast('请填写Accesskey', referer(), 'info'); + } + if (empty($remote['qiniu']['secretkey'])) { + if ($_W['isajax']) iajax(-1, '请填写secretkey.'); + itoast('请填写secretkey', referer(), 'info'); + } + if (empty($remote['qiniu']['bucket'])) { + if ($_W['isajax']) iajax(-1, '请填写bucket.'); + itoast('请填写bucket', referer(), 'info'); + } + if (empty($remote['qiniu']['url'])) { + if ($_W['isajax']) iajax(-1, '请填写url.'); + itoast('请填写url', referer(), 'info'); + } else { + $remote['qiniu']['url'] = strexists($remote['qiniu']['url'], 'http') ? trim($remote['qiniu']['url'], '/') : 'http://' . trim($remote['qiniu']['url'], '/'); + } + attachment_replace_article_remote_url($remote_urls['qiniu']['old_url'], $remote['qiniu']['url']); +// $auth = attachment_qiniu_auth($remote['qiniu']['accesskey'], $remote['qiniu']['secretkey'], $remote['qiniu']['bucket']); +// if (is_error($auth)) { +// $message = $auth['message']['error'] == 'bad token' ? 'Accesskey或Secretkey填写错误, 请检查后重新提交' : 'bucket填写错误或是bucket所对应的存储区域选择错误,请检查后重新提交'; +// if ($_W['isajax']) iajax(-1, $message); +// itoast($message, referer(), 'info'); +// } + + } elseif (ATTACH_COS == $remote['type']) { + if (empty($remote['cos']['appid'])) { + if ($_W['isajax']) { + iajax(-1, '请填写APPID'); + } + itoast('请填写APPID', referer(), 'info'); + } + if (empty($remote['cos']['secretid'])) { + if ($_W['isajax']) { + iajax(-1, '请填写SECRETID'); + } + itoast('请填写SECRETID', referer(), 'info'); + } + if (empty($remote['cos']['secretkey'])) { + if ($_W['isajax']) { + iajax(-1, '请填写SECRETKEY'); + } + itoast('请填写SECRETKEY', referer(), 'info'); + } + if (empty($remote['cos']['bucket'])) { + if ($_W['isajax']) { + iajax(-1, '请填写BUCKET'); + } + itoast('请填写BUCKET', referer(), 'info'); + } + $remote['cos']['bucket'] = str_replace("-{$remote['cos']['appid']}", '', trim($remote['cos']['bucket'])); + + if (empty($url)) { + $url = sprintf('https://%s-%s.cos%s.myqcloud.com', $bucket, $appid, $_GPC['local']); + } + if (empty($remote['cos']['url'])) { + $remote['cos']['url'] = sprintf('https://%s-%s.cos%s.myqcloud.com', $remote['cos']['bucket'], $remote['cos']['appid'], $remote['cos']['local']); + } + $remote['cos']['url'] = rtrim($remote['cos']['url'], '/'); + $_W['setting']['remote']['cos'] = array(); + attachment_replace_article_remote_url($remote_urls['cos']['old_url'], $remote['cos']['url']); + $auth = attachment_cos_auth($remote['cos']['bucket'], $remote['cos']['appid'], $remote['cos']['secretid'], $remote['cos']['secretkey'], $remote['cos']['local']); + + if (is_error($auth)) { + if ($_W['isajax']) { + iajax(-1, $auth['message']); + } + itoast($auth['message'], referer(), 'info'); + } + } + $_W['setting']['remote_complete_info']['type'] = $remote['type']; + $_W['setting']['remote_complete_info']['alioss'] = $remote['alioss']; + $_W['setting']['remote_complete_info']['ftp'] = $remote['ftp']; + $_W['setting']['remote_complete_info']['qiniu'] = $remote['qiniu']; + $_W['setting']['remote_complete_info']['cos'] = $remote['cos']; + setting_save($_W['setting']['remote_complete_info'], 'remote'); + if ($_W['isajax']) { + iajax(0, '远程附件配置信息更新成功!'); + } + itoast('远程附件配置信息更新成功!', url('system/attachment/remote'), 'success'); + } + $bucket_datacenter = attachment_alioss_datacenters(); + $local_attachment = file_dir_exist_image(ATTACHMENT_ROOT . 'images'); + if ($_W['isajax']) { + $message = array( + 'remote' => $remote, + 'bucket_datacenter' => $bucket_datacenter, + 'local_attachment' => $local_attachment + ); + iajax(0, $message); + } +} + +if ('buckets' == $do) { + $key = $_GPC['key']; + $secret = $_GPC['secret']; + $buckets = attachment_alioss_buctkets($key, $secret); + if (is_error($buckets)) { + iajax(-1, ''); + } + $bucket_datacenter = attachment_alioss_datacenters(); + $bucket = array(); + foreach ($buckets as $key => $value) { + $value['bucket_key'] = $value['name'] . '@@' . $value['location']; + $value['loca_name'] = $key . '@@' . $bucket_datacenter[$value['location']]; + $bucket[] = $value; + } + iajax(0, $bucket); +} + +if ('ftp' == $do) { + load()->library('ftp'); + $ftp_config = array( + 'hostname' => trim($_GPC['host']), + 'username' => trim($_GPC['username']), + 'password' => strexists($_GPC['password'], '*') ? $_W['setting']['remote_complete_info']['ftp']['password'] : trim($_GPC['password']), + 'port' => intval($_GPC['port']), + 'ssl' => trim($_GPC['ssl']), + 'passive' => trim($_GPC['pasv']), + 'timeout' => intval($_GPC['overtime']), + 'rootdir' => trim($_GPC['dir']), + ); + $url = trim($_GPC['url']); + $filename = 'MicroEngine.ico'; + $ftp = new Ftp($ftp_config); + if (true === $ftp->connect()) { + if ($ftp->upload(ATTACHMENT_ROOT . 'images/global/' . $filename, $filename)) { + load()->func('communication'); + $response = ihttp_get($url . '/' . $filename); + if (is_error($response)) { + iajax(-1, '配置失败,FTP远程访问url错误'); + } + if (200 != intval($response['code'])) { + iajax(-1, '配置失败,FTP远程访问url错误'); + } + $image = getimagesizefromstring($response['content']); + if (!empty($image) && strexists($image['mime'], 'image')) { + iajax(0, '配置成功'); + } else { + iajax(-1, '配置失败,FTP远程访问url错误'); + } + } else { + iajax(-1, '上传图片失败,请检查配置'); + } + } else { + iajax(-1, 'FTP服务器连接失败,请检查配置'); + } +} + +if ('oss' == $do) { + load()->model('attachment'); + $key = $_GPC['key']; + $secret = strexists($_GPC['secret'], '*') ? $_W['setting']['remote_complete_info']['alioss']['secret'] : $_GPC['secret']; + $bucket = $_GPC['bucket']; + $buckets = attachment_alioss_buctkets($key, $secret); + list($bucket, $url) = explode('@@', $_GPC['bucket']); + $result = attachment_newalioss_auth($key, $secret, $bucket, $_GPC['internal']); + if (is_error($result)) { + iajax(-1, 'OSS-Access Key ID 或 OSS-Access Key Secret错误,请重新填写'); + } + $ossurl = $buckets[$bucket]['location'] . '.aliyuncs.com'; + if (!empty($_GPC['url'])) { + if (!strexists($_GPC['url'], 'http://') && !strexists($_GPC['url'], 'https://')) { + $url = 'http://' . trim($_GPC['url']); + } else { + $url = trim($_GPC['url']); + } + $url = trim($url, '/') . '/'; + } else { + $url = 'http://' . $bucket . '.' . $buckets[$bucket]['location'] . '.aliyuncs.com/'; + } + load()->func('communication'); + $filename = 'MicroEngine.ico'; + $response = ihttp_request($url . '/' . $filename, array(), array('CURLOPT_REFERER' => $_SERVER['SERVER_NAME'])); + if (is_error($response)) { + iajax(-1, '配置失败,阿里云访问url错误'); + } + if (200 != intval($response['code'])) { + iajax(-1, '配置失败,阿里云访问url错误,请保证bucket为公共读取的'); + } + $image = getimagesizefromstring($response['content']); + if (!empty($image) && strexists($image['mime'], 'image')) { + iajax(0, '配置成功'); + } else { + iajax(-1, '配置失败,阿里云访问url错误'); + } +} + +if ('qiniu' == $do) { + + load()->model('attachment'); + $_GPC['secretkey'] = strexists($_GPC['secretkey'], '*') ? $_W['setting']['remote_complete_info']['qiniu']['secretkey'] : $_GPC['secretkey']; + +// $auth = attachment_qiniu_auth(trim($_GPC['accesskey']), trim($_GPC['secretkey']), trim($_GPC['bucket'])); +// if (is_error($auth)) iajax(-1, '配置失败,请检查配置。注:请检查存储区域是否选择的是和bucket对应
    的区域', ''); + + load()->func('communication'); + $url = $_GPC['url']; + $url = strexists($url, 'http') ? trim($url, '/') : 'http://' . trim($url, '/'); + $filename = 'MicroEngine.ico'; + $response = ihttp_request($url . '/' . $filename, array(), array('CURLOPT_REFERER' => $_SERVER['SERVER_NAME'])); + if (is_error($response)) iajax(-1, '配置失败,七牛访问url错误'); + if (200 != intval($response['code'])) iajax(-1, '配置失败,七牛访问url错误,请保证bucket为公共读取的'); + $image = getimagesizefromstring($response['content']); + if (!empty($image) && strexists($image['mime'], 'image')) { + iajax(0, '配置成功'); + } else { + iajax(-1, '配置失败,七牛访问url错误'); + } +} + +if ('cos' == $do) { + load()->model('attachment'); + $url = $_GPC['url']; + $appid = trim($_GPC['appid']); + $secretid = trim($_GPC['secretid']); + $secretkey = strexists($_GPC['secretkey'], '*') ? $_W['setting']['remote_complete_info']['cos']['secretkey'] : trim($_GPC['secretkey']); + $bucket = str_replace("-{$appid}", '', trim($_GPC['bucket'])); + + if (empty($url)) { + $url = sprintf('https://%s-%s.cos%s.myqcloud.com', $bucket, $appid, $_GPC['local']); + } + $url = rtrim($url, '/'); + $_W['setting']['remote']['cos'] = array(); + $auth = attachment_cos_auth($bucket, $appid, $secretid, $secretkey, $_GPC['local']); + + if (is_error($auth)) { + iajax(-1, '配置失败,请检查配置' . $auth['message'], ''); + } + load()->func('communication'); + $response = ihttp_request($url . '/MicroEngine.ico', array(), array('CURLOPT_REFERER' => $_SERVER['SERVER_NAME'])); + if (is_error($response)) { + iajax(-1, '配置失败,腾讯cos访问url错误'); + } + if (200 != intval($response['code'])) { + iajax(-1, '配置失败,腾讯cos访问url错误,请保证bucket为公共读取的'); + } + $image = getimagesizefromstring($response['content']); + if (!empty($image) && strexists($image['mime'], 'image')) { + iajax(0, '配置成功'); + } else { + iajax(-1, '配置失败,腾讯cos访问url错误'); + } +} + +template('system/attachment'); \ No newline at end of file diff --git a/web/source/user/__init.php b/web/source/user/__init.php new file mode 100644 index 0000000..b1dd3e6 --- /dev/null +++ b/web/source/user/__init.php @@ -0,0 +1,15 @@ +model('module'); + +$modulename = trim($_GPC['modulename']); +$callname = trim($_GPC['callname']); +$uniacid = intval($_GPC['uniacid']); +$_W['uniacid'] = intval($_GPC['uniacid']); + +$args = $_GPC['args']; +$module_info = module_fetch($modulename); +if (empty($module_info)) { + iajax(0, array()); +} +$site = WeUtility::createModuleSite($modulename); +if (empty($site)) { + iajax(0, array()); +} +if (!method_exists($site, $callname)) { + iajax(0, array()); +} +$ret = @$site->$callname($args); +iajax(0, $ret); \ No newline at end of file diff --git a/web/themes/default/account/account-header.html b/web/themes/default/account/account-header.html new file mode 100644 index 0000000..be58709 --- /dev/null +++ b/web/themes/default/account/account-header.html @@ -0,0 +1,28 @@ +{if $_W['iscontroller']} + +{/if} +
    + +
    +
    + {$account['name']} +
    +
    + {$account['end']} +
    +
    + {if $state == ACCOUNT_MANAGE_NAME_FOUNDER || $state == ACCOUNT_MANAGE_NAME_OWNER || $state == ACCOUNT_MANAGE_NAME_VICE_FOUNDER} + 进入平台    + {/if} +
    +
    +
    + {if $state == ACCOUNT_MANAGE_NAME_FOUNDER || $state == ACCOUNT_MANAGE_NAME_OWNER || $state == ACCOUNT_MANAGE_NAME_VICE_FOUNDER} + 基础信息 + {/if} + 使用者管理 +
    \ No newline at end of file diff --git a/web/themes/default/system/attachment.html b/web/themes/default/system/attachment.html new file mode 100644 index 0000000..6b918ef --- /dev/null +++ b/web/themes/default/system/attachment.html @@ -0,0 +1,446 @@ +{template 'common/header'} +
    +
    + + + + + + + + + +
    + + + + + +
    + + +{template 'common/footer'}